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)
37 LLVM::LLVMDialect::getTargetAttrName());
40 <<
"no TargetAttrInterface-implementing attribute at key \""
41 << LLVM::LLVMDialect::getTargetAttrName() <<
"\"";
42 return signalPassFailure();
45 FailureOr<llvm::DataLayout> dataLayout =
47 if (failed(dataLayout)) {
48 op->
emitError() <<
"failed to obtain llvm::DataLayout for " << targetAttr;
49 return signalPassFailure();
52 DataLayoutSpecInterface dataLayoutSpec =
55 if (
auto existingDlSpec =
57 DLTIDialect::kDataLayoutAttrName)) {
58 dataLayoutSpec = existingDlSpec.combineWith({dataLayoutSpec});
Operation is the basic unit of execution within MLIR.
void setDiscardableAttr(StringAttr name, Attribute value)
Set a discardable attribute by name.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
AttrClass getDiscardableAttrOfType(StringRef name)
Access a discardable attribute by name and cast it to AttrClass.
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