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"
19#include "llvm/ADT/StringMap.h"
29mlir::DenseElementsAttr
37template <
typename AttrTy,
typename StorageTy>
38std::optional<mlir::DenseElementsAttr>
41 mlir::Type convertedElementType);
44 cir::ConstArrayAttr constArr, mlir::SymbolTableCollection &symbolTables,
45 const mlir::TypeConverter *converter,
49 cir::ConstRecordAttr constRecord, mlir::SymbolTableCollection &symbolTables,
50 const mlir::TypeConverter *converter,
70 const mlir::TypeConverter &converter,
71 const mlir::DataLayout &dataLayout,
72 mlir::Type *failedType =
nullptr);
78 const mlir::TypeConverter &converter,
79 const mlir::DataLayout &dataLayout,
81 mlir::Type *failedType =
nullptr);
83mlir::Value
getConstAPInt(mlir::OpBuilder &bld, mlir::Location loc,
84 mlir::Type typ,
const llvm::APInt &val);
86mlir::Value
getConst(mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ,
89mlir::Value
createShL(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
91mlir::Value
createAShR(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
93mlir::Value
createAnd(mlir::OpBuilder &bld, mlir::Value lhs,
94 const llvm::APInt &rhs);
96mlir::Value
createLShR(mlir::OpBuilder &bld, mlir::Value lhs,
unsigned rhs);
99 mlir::DataLayout
const &dataLayout,
100 mlir::Type type,
bool isForHLSL =
false);
106 mlir::DataLayout
const &dataLayout,
113 const mlir::DataLayout &dataLayout);
mlir::Attribute spellOutSplitTrailingZeros(mlir::Attribute attr)
Return attr with the trailing zeros of any array that adjustGlobalTypeForInit would split off written...
mlir::DenseElementsAttr convertStringAttrToDenseElementsAttr(cir::ConstArrayAttr attr, mlir::Type type)
std::optional< mlir::DenseElementsAttr > convertToDenseElementsAttr(cir::ConstArrayAttr attr, const llvm::SmallVectorImpl< int64_t > &dims, mlir::Type convertedElementType)
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::Value createAShR(mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs)
StorageTy getZeroInitFromType(mlir::Type ty)
Return a zero with the lowered element type's width or float semantics.
mlir::Value createAnd(mlir::OpBuilder &bld, mlir::Value lhs, const llvm::APInt &rhs)
mlir::Type convertTypeForLoadStore(const mlir::TypeConverter &converter, mlir::DataLayout const &dataLayout, mlir::Type type)
The type of a load/store's value, as opposed to convertTypeForMemory's type of the memory it lives in...
mlir::Type adjustGlobalTypeForInit(mlir::Type llvmType, mlir::Attribute init, const mlir::TypeConverter &converter, const mlir::DataLayout &dataLayout, mlir::Type *failedType=nullptr)
Adjust llvmType (the converted type of init) to the concrete LLVM type a global constant initialized ...
llvm::StringMap< mlir::Type > CIRPreConversionTypeMap
std::optional< mlir::Attribute > lowerConstArrayAttr(cir::ConstArrayAttr constArr, mlir::SymbolTableCollection &symbolTables, const mlir::TypeConverter *converter, const CIRPreConversionTypeMap &preConversionTypes, mlir::ModuleOp moduleOp)
std::optional< mlir::Attribute > lowerConstRecordAttr(cir::ConstRecordAttr constRecord, mlir::SymbolTableCollection &symbolTables, const mlir::TypeConverter *converter, const CIRPreConversionTypeMap &preConversionTypes, mlir::ModuleOp moduleOp)
mlir::Type convertTypeForMemory(const mlir::TypeConverter &converter, mlir::DataLayout const &dataLayout, mlir::Type type, bool isForHLSL=false)
mlir::Attribute getBitIntStorageAttr(mlir::ConversionPatternRewriter &rewriter, cir::IntAttr attr, const mlir::DataLayout &dataLayout)