MLIR: mlir::LLVM::ModuleTranslation Class Reference (original) (raw)

Implementation class for module translation. More...

#include "[mlir/Target/LLVMIR/ModuleTranslation.h](ModuleTranslation%5F8h%5Fsource.html)"

Classes
struct SaveStack
RAII object calling stackPush/stackPop on construction/destruction. More...
class StackFrame
Common CRTP base class for ModuleTranslation stack frames. More...
class StackFrameBase
Concrete CRTP base class for ModuleTranslation stack frames. More...
Public Member Functions
void mapFunction (StringRef name, llvm::Function *func)
Stores the mapping between a function name and its LLVM IR representation. More...
llvm::Function * lookupFunction (StringRef name) const
Finds an LLVM IR function by its name. More...
void mapValue (Value mlir, llvm::Value *llvm)
Stores the mapping between an MLIR value and its LLVM IR counterpart. More...
llvm::Value *& mapValue (Value value)
Provides write-once access to store the LLVM IR value corresponding to the given MLIR value. More...
llvm::Value * lookupValue (Value value) const
Finds an LLVM IR value corresponding to the given MLIR value. More...
SmallVector< llvm::Value * > lookupValues (ValueRange values)
Looks up remapped a list of remapped values. More...
void mapBlock (Block *mlir, llvm::BasicBlock *llvm)
Stores the mapping between an MLIR block and LLVM IR basic block. More...
llvm::BasicBlock * lookupBlock (Block *block) const
Finds an LLVM IR basic block that corresponds to the given MLIR block. More...
void mapBranch (Operation *mlir, llvm::Instruction *llvm)
Stores the mapping between an MLIR operation with successors and a corresponding LLVM IR instruction. More...
llvm::Instruction * lookupBranch (Operation *op) const
Finds an LLVM IR instruction that corresponds to the given MLIR operation with successors. More...
void mapCall (Operation *mlir, llvm::CallInst *llvm)
Stores a mapping between an MLIR call operation and a corresponding LLVM call instruction. More...
llvm::CallInst * lookupCall (Operation *op) const
Finds an LLVM call instruction that corresponds to the given MLIR call operation. More...
void mapUnresolvedBlockAddress (BlockAddressOp op, llvm::Value *cst)
Maps a blockaddress operation to its corresponding placeholder LLVM value. More...
void mapBlockAddress (BlockAddressAttr attr, llvm::BasicBlock *block)
Maps a BlockAddressAttr to its corresponding LLVM basic block. More...
llvm::BasicBlock * lookupBlockAddress (BlockAddressAttr attr) const
Finds the LLVM basic block that corresponds to the given BlockAddressAttr. More...
void forgetMapping (Region &region)
Removes the mapping for blocks contained in the region and values defined in these blocks. More...
llvm::MDNode * getOrCreateAliasScope (AliasScopeAttr aliasScopeAttr)
Returns the LLVM metadata corresponding to a mlir LLVM dialect alias scope attribute. More...
llvm::MDNode * getOrCreateAliasScopes (ArrayRef< AliasScopeAttr > aliasScopeAttrs)
Returns the LLVM metadata corresponding to an array of mlir LLVM dialect alias scope attributes. More...
void setAccessGroupsMetadata (AccessGroupOpInterface op, llvm::Instruction *inst)
void setAliasScopeMetadata (AliasAnalysisOpInterface op, llvm::Instruction *inst)
void setTBAAMetadata (AliasAnalysisOpInterface op, llvm::Instruction *inst)
Sets LLVM TBAA metadata for memory operations that have TBAA attributes. More...
void setDereferenceableMetadata (DereferenceableOpInterface op, llvm::Instruction *inst)
Sets LLVM dereferenceable metadata for operations that have dereferenceable attributes. More...
void setBranchWeightsMetadata (BranchWeightOpInterface op)
Sets LLVM profiling metadata for operations that have branch weights. More...
void setLoopMetadata (Operation *op, llvm::Instruction *inst)
Sets LLVM loop metadata for branch operations that have a loop annotation attribute. More...
void setDisjointFlag (Operation *op, llvm::Value *value)
Sets the disjoint flag attribute for the exported instruction value given the original operation op. More...
llvm::Type * convertType (Type type)
Converts the type from MLIR LLVM dialect to LLVM. More...
MLIRContext & getContext ()
Returns the MLIR context of the module being translated. More...
llvm::LLVMContext & getLLVMContext () const
Returns the LLVM context in which the IR is being constructed. More...
llvm::GlobalValue * lookupGlobal (Operation *op)
Finds an LLVM IR global value that corresponds to the given MLIR operation defining a global value. More...
llvm::GlobalValue * lookupAlias (Operation *op)
Finds an LLVM IR global value that corresponds to the given MLIR operation defining a global alias value. More...
llvm::OpenMPIRBuilder * getOpenMPBuilder ()
Returns the OpenMP IR builder associated with the LLVM IR module being constructed. More...
llvm::Module * getLLVMModule ()
Returns the LLVM module in which the IR is being constructed. More...
llvm::DILocation * translateLoc (Location loc, llvm::DILocalScope *scope)
Translates the given location. More...
llvm::DIExpression * translateExpression (LLVM::DIExpressionAttr attr)
Translates the given LLVM DWARF expression metadata. More...
llvm::DIGlobalVariableExpression * translateGlobalVariableExpression (LLVM::DIGlobalVariableExpressionAttr attr)
Translates the given LLVM global variable expression metadata. More...
llvm::Metadata * translateDebugInfo (LLVM::DINodeAttr attr)
Translates the given LLVM debug info metadata. More...
llvm::RoundingMode translateRoundingMode (LLVM::RoundingMode rounding)
Translates the given LLVM rounding mode metadata. More...
llvm::fp::ExceptionBehavior translateFPExceptionBehavior (LLVM::FPExceptionBehavior exceptionBehavior)
Translates the given LLVM FP exception behavior metadata. More...
LogicalResult convertBlock (Block &bb, bool ignoreArguments, llvm::IRBuilderBase &builder)
Translates the contents of the given block to LLVM IR using this translator. More...
FailureOr< llvm::AttrBuilder > convertParameterAttrs (mlir::Location loc, DictionaryAttr paramAttrs)
Translates parameter attributes of a call and adds them to the returned AttrBuilder. More...
llvm::NamedMDNode * getOrInsertNamedModuleMetadata (StringRef name)
Gets the named metadata in the LLVM IR module being constructed, creating it if it does not exist. More...
template<typename T , typename... Args>
void stackPush (Args &&...args)
Creates a stack frame of type T on ModuleTranslation stack. More...
void stackPop ()
Pops the last element from the ModuleTranslation stack. More...
template
WalkResult stackWalk (llvm::function_ref< WalkResult(T &)> callback)
Calls callback for every ModuleTranslation stack frame of type T starting from the top of the stack. More...
SymbolTableCollection & symbolTable ()

Implementation class for module translation.

Holds a reference to the module being translated, and the mappings between the original and the translated functions, basic blocks and values. It is practically easier to hold these mappings in one class since the conversion of control flow operations needs to look up block and function mappings.

Definition at line 59 of file ModuleTranslation.h.

convertBlock()

LogicalResult mlir::LLVM::ModuleTranslation::convertBlock ( Block & bb, bool ignoreArguments, llvm::IRBuilderBase & builder ) inline

convertParameterAttrs()

FailureOr< llvm::AttrBuilder > ModuleTranslation::convertParameterAttrs ( mlir::Location loc,
DictionaryAttr paramAttrs
)

convertType()

llvm::Type * ModuleTranslation::convertType ( Type type )

Converts the type from MLIR LLVM dialect to LLVM.

Definition at line 2157 of file ModuleTranslation.cpp.

References mlir::LLVM::TypeToLLVMIRTranslator::translateType().

Referenced by allocatePrivateVars(), allocReductionVars(), collectReductionInfo(), convertCallLLVMIntrinsicOp(), convertFunctionKernelAttributes(), convertOmpAtomicCapture(), convertOmpAtomicRead(), convertOmpAtomicUpdate(), convertOmpAtomicWrite(), convertOmpOpRegions(), convertOmpTaskOp(), convertOperationImpl(), convertParameterAttr(), convertTargetOpsInNest(), mlir::LLVM::detail::createIntrinsicCall(), emitUserDefinedMapper(), findAssociatedValue(), getOverloadedDeclaration(), initReductionVars(), and inlineOmpRegionCleanup().

forgetMapping()

void ModuleTranslation::forgetMapping ( Region & region )

getContext()

MLIRContext& mlir::LLVM::ModuleTranslation::getContext ( ) inline

getLLVMContext()

llvm::LLVMContext& mlir::LLVM::ModuleTranslation::getLLVMContext ( ) const inline

getLLVMModule()

llvm::Module* mlir::LLVM::ModuleTranslation::getLLVMModule ( ) inline

getOpenMPBuilder()

llvm::OpenMPIRBuilder * ModuleTranslation::getOpenMPBuilder ( )

Returns the OpenMP IR builder associated with the LLVM IR module being constructed.

Definition at line 2170 of file ModuleTranslation.cpp.

Referenced by convertDataOp(), convertDeclareTargetAttr(), convertFlagsAttr(), convertHostOrTargetOperation(), convertOmpAtomicCapture(), convertOmpAtomicRead(), convertOmpAtomicUpdate(), convertOmpAtomicWrite(), convertOmpCancel(), convertOmpCancellationPoint(), convertOmpCritical(), convertOmpDistribute(), convertOmpLoopNest(), convertOmpMasked(), convertOmpMaster(), convertOmpOrdered(), convertOmpOrderedRegion(), convertOmpParallel(), convertOmpSections(), convertOmpSimd(), convertOmpSingle(), convertOmpTarget(), convertOmpTargetData(), convertOmpTaskgroupOp(), convertOmpTaskOp(), convertOmpTaskwaitOp(), convertOmpTeams(), convertOmpThreadprivate(), convertOmpWsloop(), convertStandaloneDataOp(), copyFirstPrivateVars(), createAlteredByCaptureMap(), createReductionsAndCleanup(), emitUserDefinedMapper(), genMapInfos(), getOrCreateUserDefinedMapperFunc(), getRefPtrIfDeclareTarget(), handleDeclareTargetMapVar(), initTargetRuntimeAttrs(), and processOperands().

getOrCreateAliasScope()

llvm::MDNode * ModuleTranslation::getOrCreateAliasScope ( AliasScopeAttr aliasScopeAttr )

getOrCreateAliasScopes()

llvm::MDNode * ModuleTranslation::getOrCreateAliasScopes ( ArrayRef< AliasScopeAttr > aliasScopeAttrs )

getOrInsertNamedModuleMetadata()

llvm::NamedMDNode * ModuleTranslation::getOrInsertNamedModuleMetadata ( StringRef name )

Gets the named metadata in the LLVM IR module being constructed, creating it if it does not exist.

Definition at line 2220 of file ModuleTranslation.cpp.

lookupAlias()

llvm::GlobalValue* mlir::LLVM::ModuleTranslation::lookupAlias ( Operation * op) inline

lookupBlock()

llvm::BasicBlock* mlir::LLVM::ModuleTranslation::lookupBlock ( Block * block) const inline

lookupBlockAddress()

llvm::BasicBlock* mlir::LLVM::ModuleTranslation::lookupBlockAddress ( BlockAddressAttr attr) const inline

lookupBranch()

llvm::Instruction* mlir::LLVM::ModuleTranslation::lookupBranch ( Operation * op) const inline

lookupCall()

llvm::CallInst* mlir::LLVM::ModuleTranslation::lookupCall ( Operation * op) const inline

lookupFunction()

llvm::Function* mlir::LLVM::ModuleTranslation::lookupFunction ( StringRef name) const inline

lookupGlobal()

llvm::GlobalValue* mlir::LLVM::ModuleTranslation::lookupGlobal ( Operation * op) inline

lookupValue()

llvm::Value* mlir::LLVM::ModuleTranslation::lookupValue ( Value value) const inline

Finds an LLVM IR value corresponding to the given MLIR value.

Definition at line 91 of file ModuleTranslation.h.

Referenced by buildDependData(), calculateBoundsOffset(), collectReductionInfo(), convertOmpAtomicCapture(), convertOmpAtomicRead(), convertOmpAtomicUpdate(), convertOmpAtomicWrite(), convertOmpCancel(), convertOmpLoopNest(), convertOmpMasked(), convertOmpOpRegions(), convertOmpParallel(), convertOmpSections(), convertOmpSimd(), convertOmpSingle(), convertOmpTarget(), convertOmpTargetData(), convertOmpTaskOp(), convertOmpTeams(), convertOmpWsloop(), convertOperandBundle(), convertOperationImpl(), convertTargetOpsInNest(), findAssociatedValue(), forwardArgs(), getSizeInBytes(), initTargetRuntimeAttrs(), lookupValues(), mapInitializationArgs(), and processOperands().

lookupValues()

mapBlock()

void mlir::LLVM::ModuleTranslation::mapBlock ( Block * mlir, llvm::BasicBlock * llvm ) inline

mapBlockAddress()

void mlir::LLVM::ModuleTranslation::mapBlockAddress ( BlockAddressAttr attr, llvm::BasicBlock * block ) inline

mapBranch()

void mlir::LLVM::ModuleTranslation::mapBranch ( Operation * mlir, llvm::Instruction * llvm ) inline

mapCall()

void mlir::LLVM::ModuleTranslation::mapCall ( Operation * mlir, llvm::CallInst * llvm ) inline

mapFunction()

void mlir::LLVM::ModuleTranslation::mapFunction ( StringRef name, llvm::Function * func ) inline

mapUnresolvedBlockAddress()

void mlir::LLVM::ModuleTranslation::mapUnresolvedBlockAddress ( BlockAddressOp op, llvm::Value * cst ) inline

mapValue() [1/2]

void mlir::LLVM::ModuleTranslation::mapValue ( Value mlir, llvm::Value * llvm ) inline

Stores the mapping between an MLIR value and its LLVM IR counterpart.

Definition at line 79 of file ModuleTranslation.h.

References mapValue().

Referenced by allocReductionVars(), convertCallLLVMIntrinsicOp(), convertOmpAtomicCapture(), convertOmpAtomicUpdate(), convertOmpLoopNest(), convertOmpSections(), convertOmpTarget(), convertOmpTargetData(), convertOmpTaskOp(), convertOmpThreadprivate(), convertOperationImpl(), convertTargetOpsInNest(), copyFirstPrivateVars(), emitUserDefinedMapper(), forwardArgs(), initPrivateVar(), initPrivateVars(), initReductionVars(), inlineOmpRegionCleanup(), makeAtomicReductionGen(), makeReductionGen(), mapInitializationArgs(), and mapValue().

mapValue() [2/2]

llvm::Value*& mlir::LLVM::ModuleTranslation::mapValue ( Value value) inline

Provides write-once access to store the LLVM IR value corresponding to the given MLIR value.

Definition at line 83 of file ModuleTranslation.h.

setAccessGroupsMetadata()

void ModuleTranslation::setAccessGroupsMetadata ( AccessGroupOpInterface op,
llvm::Instruction * inst
)

setAliasScopeMetadata()

void ModuleTranslation::setAliasScopeMetadata ( AliasAnalysisOpInterface op,
llvm::Instruction * inst
)

setBranchWeightsMetadata()

void ModuleTranslation::setBranchWeightsMetadata ( BranchWeightOpInterface op )

setDereferenceableMetadata()

void ModuleTranslation::setDereferenceableMetadata ( DereferenceableOpInterface op,
llvm::Instruction * inst
)

setDisjointFlag()

void ModuleTranslation::setDisjointFlag ( Operation * op,
llvm::Value * value
)

Sets the disjoint flag attribute for the exported instruction value given the original operation op.

Asserts if the operation does not implement the disjoint flag interface, and asserts if the value is an instruction that implements the disjoint flag.

Definition at line 2150 of file ModuleTranslation.cpp.

setLoopMetadata()

void ModuleTranslation::setLoopMetadata ( Operation * op,
llvm::Instruction * inst
)

setTBAAMetadata()

void ModuleTranslation::setTBAAMetadata ( AliasAnalysisOpInterface op,
llvm::Instruction * inst
)

stackPop()

void mlir::LLVM::ModuleTranslation::stackPop ( ) inline

stackPush()

template<typename T , typename... Args>

void mlir::LLVM::ModuleTranslation::stackPush ( Args &&... args) inline

stackWalk()

symbolTable()

translateDebugInfo()

translateExpression()

llvm::DIExpression * ModuleTranslation::translateExpression ( LLVM::DIExpressionAttr attr )

translateFPExceptionBehavior()

llvm::fp::ExceptionBehavior ModuleTranslation::translateFPExceptionBehavior ( LLVM::FPExceptionBehavior exceptionBehavior )

translateGlobalVariableExpression()

llvm::DIGlobalVariableExpression * ModuleTranslation::translateGlobalVariableExpression ( LLVM::DIGlobalVariableExpressionAttr attr )

translateLoc()

llvm::DILocation * ModuleTranslation::translateLoc ( Location loc,
llvm::DILocalScope * scope
)

translateRoundingMode()

llvm::RoundingMode ModuleTranslation::translateRoundingMode ( LLVM::RoundingMode rounding )

mlir::translateModuleToLLVMIR


The documentation for this class was generated from the following files: