|
clang 24.0.0git
|
#include "mlir/IR/BuiltinAttributes.h"#include "mlir/Interfaces/DataLayoutInterfaces.h"#include "mlir/Transforms/DialectConversion.h"#include "clang/CIR/Dialect/IR/CIRDialect.h"#include "llvm/ADT/StringMap.h"Go to the source code of this file.
Typedefs | |
| using | CIRPreConversionTypeMap = llvm::StringMap<mlir::Type> |
Functions | |
| mlir::DenseElementsAttr | convertStringAttrToDenseElementsAttr (cir::ConstArrayAttr attr, mlir::Type type) |
| template<typename StorageTy> | |
| StorageTy | getZeroInitFromType (mlir::Type ty) |
| Return a zero with the lowered element type's width or float semantics. | |
| template<> | |
| mlir::APInt | getZeroInitFromType (mlir::Type ty) |
| template<> | |
| mlir::APFloat | getZeroInitFromType (mlir::Type ty) |
| template<typename AttrTy, typename StorageTy> | |
| std::optional< mlir::DenseElementsAttr > | convertToDenseElementsAttr (cir::ConstArrayAttr attr, const llvm::SmallVectorImpl< int64_t > &dims, mlir::Type convertedElementType) |
| 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::Attribute | spellOutSplitTrailingZeros (mlir::Attribute attr) |
Return attr with the trailing zeros of any array that adjustGlobalTypeForInit would split off written out as explicit zero elements, so that it lowers to its own type. | |
| 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 with init actually lowers to. | |
| mlir::Type | adjustGlobalTypeForInit (mlir::Type llvmType, mlir::Attribute init, const mlir::TypeConverter &converter, const mlir::DataLayout &dataLayout, llvm::SmallVectorImpl< unsigned > &paddingAddedIndexes, mlir::Type *failedType=nullptr) |
| mlir::Value | getConstAPInt (mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ, const llvm::APInt &val) |
| mlir::Value | getConst (mlir::OpBuilder &bld, mlir::Location loc, mlir::Type typ, unsigned val) |
| mlir::Value | createShL (mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs) |
| mlir::Value | createAShR (mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs) |
| mlir::Value | createAnd (mlir::OpBuilder &bld, mlir::Value lhs, const llvm::APInt &rhs) |
| mlir::Value | createLShR (mlir::OpBuilder &bld, mlir::Value lhs, unsigned rhs) |
| mlir::Type | convertTypeForMemory (const mlir::TypeConverter &converter, mlir::DataLayout const &dataLayout, mlir::Type type, bool isForHLSL=false) |
| 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::TypedAttr | lowerScalarConstAttr (mlir::Attribute attr, mlir::Type llvmType) |
Lower a scalar CIR constant (#cir.int, #cir.fp or #cir.bool) to a builtin attribute of type llvmType. | |
| mlir::Attribute | getBitIntStorageAttr (mlir::ConversionPatternRewriter &rewriter, cir::IntAttr attr, const mlir::DataLayout &dataLayout) |
| using CIRPreConversionTypeMap = llvm::StringMap<mlir::Type> |
Definition at line 27 of file LoweringHelpers.h.
| mlir::Type adjustGlobalTypeForInit | ( | mlir::Type | llvmType, |
| mlir::Attribute | init, | ||
| const mlir::TypeConverter & | converter, | ||
| const mlir::DataLayout & | dataLayout, | ||
| llvm::SmallVectorImpl< unsigned > & | paddingAddedIndexes, | ||
| mlir::Type * | failedType = nullptr ) |
Definition at line 913 of file LoweringHelpers.cpp.
References adjustGlobalArrayTypeForInit(), adjustGlobalStructTypeForInit(), and adjustGlobalUnionTypeForInit().
Referenced by adjustGlobalArrayTypeForInit(), adjustGlobalStructTypeForInit(), adjustGlobalTypeForInit(), adjustGlobalUnionTypeForInit(), lowerConstArrayAttrByElement(), and lowerConstRecordAttr().
| 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 with init actually lowers to.
This differs from a plain type conversion for flexible-array-member and union initializers, and the adjustment recurses through nested aggregates. Returns llvmType unchanged when no adjustment is needed. This is the single source of truth for the shape of a lowered record constant; the value-producing paths (the insertvalue visitor and lowerConstRecordAttr) conform to it. Returns null if the input type or an initializer type cannot be lowered. If provided, failedType receives the CIR initializer type whose conversion failed, including in nested aggregates.
Definition at line 954 of file LoweringHelpers.cpp.
References adjustGlobalTypeForInit().
| mlir::DenseElementsAttr convertStringAttrToDenseElementsAttr | ( | cir::ConstArrayAttr | attr, |
| mlir::Type | type ) |
Definition at line 168 of file LoweringHelpers.cpp.
References getIntOrBoolBitWidth().
Referenced by lowerConstArrayAttr().
| std::optional< mlir::DenseElementsAttr > convertToDenseElementsAttr | ( | cir::ConstArrayAttr | attr, |
| const llvm::SmallVectorImpl< int64_t > & | dims, | ||
| mlir::Type | convertedElementType ) |
Definition at line 273 of file LoweringHelpers.cpp.
References convertToDenseElementsAttrImpl(), and getZeroInitFromType().
Referenced by lowerConstArrayAttr().
| 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.
The two are effectively identical except with split-storage bit-int.
Definition at line 138 of file LoweringHelpers.cpp.
References convertTypeForMemory(), cir::isBitIntType(), and uint64_t.
| mlir::Type convertTypeForMemory | ( | const mlir::TypeConverter & | converter, |
| mlir::DataLayout const & | dataLayout, | ||
| mlir::Type | type, | ||
| bool | isForHLSL = false ) |
Definition at line 88 of file LoweringHelpers.cpp.
References cir::MissingFeatures::hlsl(), cir::isBitIntType(), and uint64_t.
Referenced by adjustGlobalUnionTypeForInit(), cir::direct::convertTypedArgAttrs(), convertTypeForLoadStore(), lowerConstArrayAttr(), lowerConstRecordMemberAttr(), and cir::direct::prepareTypeConverter().
| mlir::Value createAnd | ( | mlir::OpBuilder & | bld, |
| mlir::Value | lhs, | ||
| const llvm::APInt & | rhs ) |
Definition at line 1047 of file LoweringHelpers.cpp.
References getConstAPInt().
| mlir::Value createAShR | ( | mlir::OpBuilder & | bld, |
| mlir::Value | lhs, | ||
| unsigned | rhs ) |
Definition at line 1040 of file LoweringHelpers.cpp.
References getConst().
| mlir::Value createLShR | ( | mlir::OpBuilder & | bld, |
| mlir::Value | lhs, | ||
| unsigned | rhs ) |
Definition at line 1053 of file LoweringHelpers.cpp.
References getConst().
| mlir::Value createShL | ( | mlir::OpBuilder & | bld, |
| mlir::Value | lhs, | ||
| unsigned | rhs ) |
Definition at line 1033 of file LoweringHelpers.cpp.
References getConst().
| mlir::Attribute getBitIntStorageAttr | ( | mlir::ConversionPatternRewriter & | rewriter, |
| cir::IntAttr | attr, | ||
| const mlir::DataLayout & | dataLayout ) |
Definition at line 60 of file LoweringHelpers.cpp.
References bytes().
| mlir::Value getConst | ( | mlir::OpBuilder & | bld, |
| mlir::Location | loc, | ||
| mlir::Type | typ, | ||
| unsigned | val ) |
Definition at line 1028 of file LoweringHelpers.cpp.
Referenced by createAShR(), createLShR(), and createShL().
| mlir::Value getConstAPInt | ( | mlir::OpBuilder & | bld, |
| mlir::Location | loc, | ||
| mlir::Type | typ, | ||
| const llvm::APInt & | val ) |
Definition at line 1023 of file LoweringHelpers.cpp.
Referenced by createAnd().
| StorageTy getZeroInitFromType | ( | mlir::Type | ty | ) |
Return a zero with the lowered element type's width or float semantics.
Referenced by convertToDenseElementsAttr().
| mlir::APInt getZeroInitFromType | ( | mlir::Type | ty | ) |
Definition at line 194 of file LoweringHelpers.cpp.
| mlir::APFloat getZeroInitFromType | ( | mlir::Type | ty | ) |
Definition at line 194 of file LoweringHelpers.cpp.
| std::optional< mlir::Attribute > lowerConstArrayAttr | ( | cir::ConstArrayAttr | constArr, |
| mlir::SymbolTableCollection & | symbolTables, | ||
| const mlir::TypeConverter * | converter, | ||
| const CIRPreConversionTypeMap & | preConversionTypes, | ||
| mlir::ModuleOp | moduleOp ) |
Definition at line 497 of file LoweringHelpers.cpp.
References containsBlockAddress(), containsPoison(), containsSplitTrailingZeros(), convertStringAttrToDenseElementsAttr(), convertToDenseElementsAttr(), convertTypeForMemory(), lowerConstArrayAttrByElement(), lowerConstRecordMemberAttr(), and lowerPointerElementAttr().
Referenced by lowerConstArrayAttrByElement(), and lowerConstRecordMemberAttr().
| std::optional< mlir::Attribute > lowerConstRecordAttr | ( | cir::ConstRecordAttr | constRecord, |
| mlir::SymbolTableCollection & | symbolTables, | ||
| const mlir::TypeConverter * | converter, | ||
| const CIRPreConversionTypeMap & | preConversionTypes, | ||
| mlir::ModuleOp | moduleOp ) |
Definition at line 964 of file LoweringHelpers.cpp.
References adjustGlobalTypeForInit(), and lowerConstRecordMemberAttr().
Referenced by lowerConstRecordMemberAttr().
| mlir::TypedAttr lowerScalarConstAttr | ( | mlir::Attribute | attr, |
| mlir::Type | llvmType ) |
Lower a scalar CIR constant (#cir.int, #cir.fp or #cir.bool) to a builtin attribute of type llvmType.
Callers pass the value type (i1 for a bool) or the memory type (i8 for a bool); a split-storage _BitInt has no scalar memory form and goes through getBitIntStorageAttr instead. Returns null for any other attribute.
Definition at line 49 of file LoweringHelpers.cpp.
Referenced by lowerConstRecordMemberAttr().
| mlir::Attribute spellOutSplitTrailingZeros | ( | mlir::Attribute | attr | ) |
Return attr with the trailing zeros of any array that adjustGlobalTypeForInit would split off written out as explicit zero elements, so that it lowers to its own type.
For constants that, unlike global initializers, cannot change type.
Definition at line 419 of file LoweringHelpers.cpp.
References containsSplitTrailingZeros(), shouldSplitTrailingZeros(), and spellOutSplitTrailingZeros().
Referenced by spellOutSplitTrailingZeros().