1//====- LoweringHelpers.h - Lowering helper functions ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares helper functions for lowering from CIR to LLVM or MLIR.
10//
11//===----------------------------------------------------------------------===//
12#ifndef LLVM_CLANG_CIR_LOWERINGHELPERS_H
13#define LLVM_CLANG_CIR_LOWERINGHELPERS_H
14
15#include "mlir/IR/BuiltinAttributes.h"
16#include "mlir/Transforms/DialectConversion.h"
17#include "clang/CIR/Dialect/IR/CIRDialect.h"
18
19mlir::DenseElementsAttr
20convertStringAttrToDenseElementsAttr(cir::ConstArrayAttr attr, mlir::Type type);
21
22template <typename StorageTy> StorageTy getZeroInitFromType(mlir::Type ty);
23template <> mlir::APInt getZeroInitFromType(mlir::Type ty);
24template <> mlir::APFloat getZeroInitFromType(mlir::Type ty);
25
26template <typename AttrTy, typename StorageTy>
27void convertToDenseElementsAttrImpl(cir::ConstArrayAttr attr,
28 llvm::SmallVectorImpl<StorageTy> &values);
29
30template <typename AttrTy, typename StorageTy>
31mlir::DenseElementsAttr
32convertToDenseElementsAttr(cir::ConstArrayAttr attr,
33 const llvm::SmallVectorImpl<int64_t> &dims,
34 mlir::Type type);
35
36std::optional<mlir::Attribute>
37lowerConstArrayAttr(cir::ConstArrayAttr constArr,
38 const mlir::TypeConverter *converter);
39
40#endif
41

source code of clang/include/clang/CIR/LoweringHelpers.h