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
40mlir::Value getConstAPInt(mlir::OpBuilder &bld, mlir::Location loc,
41 mlir::Type typ, const llvm::APInt &val);
42
43mlir::Value getConst(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ,
44 unsigned val);
45
46mlir::Value createShL(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs);
47
48mlir::Value createAShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs);
49
50mlir::Value createAnd(mlir::OpBuilder &bld, mlir::Value lhs,
51 const llvm::APInt &rhs);
52
53mlir::Value createLShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs);
54#endif
55

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