18 #define GEN_PASS_DEF_LLVMTARGETTODATALAYOUT
19 #include "mlir/Target/LLVMIR/Transforms/Passes.h.inc"
26 :
public LLVM::impl::LLVMTargetToDataLayoutBase<TargetToDataLayoutPass> {
27 using LLVM::impl::LLVMTargetToDataLayoutBase<
33 if (initializeLLVMTargets)
36 auto targetAttr = op->
getAttrOfType<LLVM::TargetAttrInterface>(
37 LLVM::LLVMDialect::getTargetAttrName());
40 <<
"no TargetAttrInterface-implementing attribute at key \""
41 << LLVM::LLVMDialect::getTargetAttrName() <<
"\"";
42 return signalPassFailure();
45 FailureOr<llvm::DataLayout> dataLayout =
48 op->
emitError() <<
"failed to obtain llvm::DataLayout for " << targetAttr;
49 return signalPassFailure();
52 DataLayoutSpecInterface dataLayoutSpec =
55 if (
auto existingDlSpec = op->
getAttrOfType<DataLayoutSpecInterface>(
56 DLTIDialect::kDataLayoutAttrName)) {
57 dataLayoutSpec = existingDlSpec.combineWith({dataLayoutSpec});
60 op->
setAttr(DLTIDialect::kDataLayoutAttrName, dataLayoutSpec);
static MLIRContext * getContext(OpFoldResult val)
Operation is the basic unit of execution within MLIR.
AttrClass getAttrOfType(StringAttr name)
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
void setAttr(StringAttr name, Attribute value)
If the an attribute exists with the specified name, change it to the new value.
FailureOr< llvm::DataLayout > getDataLayout(mlir::LLVM::TargetAttrInterface attr)
Helper to obtain the DataLayout of the target specified by the properties of the TargetAttrInterface-...
void initializeBackendsOnce()
Idempotent helper to register/initialize all backends that LLVM has been configured to support.
Include the generated interface declarations.
DataLayoutSpecInterface translateDataLayout(const llvm::DataLayout &dataLayout, MLIRContext *context)
Translate the given LLVM data layout into an MLIR equivalent using the DLTI dialect.
void runOnOperation() override