18#define GEN_PASS_DEF_LLVMTARGETTODATALAYOUT
19#include "mlir/Target/LLVMIR/Transforms/Passes.h.inc"
37 LLVM::LLVMDialect::getTargetAttrName());
40 <<
"no TargetAttrInterface-implementing attribute at key \""
41 << LLVM::LLVMDialect::getTargetAttrName() <<
"\"";
45 FailureOr<llvm::DataLayout> dataLayout =
47 if (failed(dataLayout)) {
48 op->
emitError() <<
"failed to obtain llvm::DataLayout for " << targetAttr;
52 DataLayoutSpecInterface dataLayoutSpec =
55 if (
auto existingDlSpec = op->
getAttrOfType<DataLayoutSpecInterface>(
56 DLTIDialect::kDataLayoutAttrName)) {
57 dataLayoutSpec = existingDlSpec.combineWith({dataLayoutSpec});
60 op->
setAttr(DLTIDialect::kDataLayoutAttrName, dataLayoutSpec);
LLVMTargetToDataLayoutBase()
::mlir::Pass::Option< bool > initializeLLVMTargets
OpT getOperation()
Return the current operation being transformed.
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.
MLIRContext & getContext()
Return the MLIR context for the current operation being transformed.
void signalPassFailure()
Signal that some invariant was broken when running.
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
The polymorphic API that runs the pass over the currently held operation.