12#ifndef LLVM_CLANG_CIR_LOWERINGHELPERS_H
13#define LLVM_CLANG_CIR_LOWERINGHELPERS_H
15#include "mlir/IR/BuiltinAttributes.h"
16#include "mlir/Interfaces/DataLayoutInterfaces.h"
17#include "mlir/Transforms/DialectConversion.h"
20mlir::DenseElementsAttr
27template <
typename AttrTy,
typename StorageTy>
31template <
typename AttrTy,
typename StorageTy>
32mlir::DenseElementsAttr
37std::optional<mlir::Attribute>
39 const mlir::TypeConverter *converter,
40 mlir::ModuleOp moduleOp = {});
42std::optional<mlir::Attribute>
44 const mlir::TypeConverter *converter,
45 mlir::ModuleOp moduleOp = {});
56 const mlir::TypeConverter &converter,
57 const mlir::DataLayout &dataLayout);
59mlir::Value
getConstAPInt(mlir::OpBuilder &bld, mlir::Location loc,
60 mlir::Type typ,
const llvm::APInt &val);
62mlir::Value
getConst(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ,
65mlir::Value
createShL(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
67mlir::Value
createAShR(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
69mlir::Value
createAnd(mlir::OpBuilder &bld, mlir::Value lhs,
70 const llvm::APInt &rhs);
72mlir::Value
createLShR(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
mlir::DenseElementsAttr convertStringAttrToDenseElementsAttr(cir::ConstArrayAttr attr, mlir::Type type)
mlir::Value createLShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs)
mlir::Value createShL(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs)
mlir::Value getConst(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ, unsigned val)
mlir::Value getConstAPInt(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ, const llvm::APInt &val)
mlir::Type adjustGlobalTypeForInit(mlir::Type llvmType, mlir::Attribute init, const mlir::TypeConverter &converter, const mlir::DataLayout &dataLayout)
Adjust llvmType (the converted type of init) to the concrete LLVM type a global constant initialized ...
mlir::DenseElementsAttr convertToDenseElementsAttr(cir::ConstArrayAttr attr, const llvm::SmallVectorImpl< int64_t > &dims, mlir::Type type)
mlir::Value createAShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs)
StorageTy getZeroInitFromType(mlir::Type ty)
mlir::Value createAnd(mlir::OpBuilder &bld, mlir::Value lhs, const llvm::APInt &rhs)
std::optional< mlir::Attribute > lowerConstArrayAttr(cir::ConstArrayAttr constArr, const mlir::TypeConverter *converter, mlir::ModuleOp moduleOp={})
void convertToDenseElementsAttrImpl(cir::ConstArrayAttr attr, llvm::SmallVectorImpl< StorageTy > &values)
std::optional< mlir::Attribute > lowerConstRecordAttr(cir::ConstRecordAttr constRecord, const mlir::TypeConverter *converter, mlir::ModuleOp moduleOp={})