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
38 cir::ConstArrayAttr constArr, mlir::SymbolTableCollection &symbolTables,
39 const mlir::TypeConverter *converter, mlir::ModuleOp moduleOp = {});
42 cir::ConstRecordAttr constRecord, mlir::SymbolTableCollection &symbolTables,
43 const mlir::TypeConverter *converter, mlir::ModuleOp moduleOp = {});
54 const mlir::TypeConverter &converter,
55 const mlir::DataLayout &dataLayout);
57mlir::Value
getConstAPInt(mlir::OpBuilder &bld, mlir::Location loc,
58 mlir::Type typ,
const llvm::APInt &val);
60mlir::Value
getConst(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ,
63mlir::Value
createShL(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
65mlir::Value
createAShR(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
67mlir::Value
createAnd(mlir::OpBuilder &bld, mlir::Value lhs,
68 const llvm::APInt &rhs);
70mlir::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)
std::optional< mlir::Attribute > lowerConstRecordAttr(cir::ConstRecordAttr constRecord, mlir::SymbolTableCollection &symbolTables, const mlir::TypeConverter *converter, mlir::ModuleOp moduleOp={})
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)
void convertToDenseElementsAttrImpl(cir::ConstArrayAttr attr, llvm::SmallVectorImpl< StorageTy > &values)
std::optional< mlir::Attribute > lowerConstArrayAttr(cir::ConstArrayAttr constArr, mlir::SymbolTableCollection &symbolTables, const mlir::TypeConverter *converter, mlir::ModuleOp moduleOp={})