20 #define GEN_PASS_DEF_UBTOLLVMCONVERSIONPASS
21 #include "mlir/Conversion/Passes.h.inc"
32 matchAndRewrite(ub::PoisonOp op, OpAdaptor adaptor,
43 PoisonOpLowering::matchAndRewrite(ub::PoisonOp op, OpAdaptor adaptor,
45 if (!isa<ub::PoisonAttr>(op.getValue())) {
47 diag <<
"pattern can only convert op with '"
48 << ub::PoisonAttr::getMnemonic() <<
"' poison value";
52 Type resType = getTypeConverter()->convertType(op.getType());
55 diag <<
"failed to convert result type " << op.getType();
68 struct UBToLLVMConversionPass
69 :
public impl::UBToLLVMConversionPassBase<UBToLLVMConversionPass> {
72 void runOnOperation()
override {
78 options.overrideIndexBitwidth(indexBitwidth);
96 patterns.add<PoisonOpLowering>(converter);
107 void loadDependentDialects(
MLIRContext *context)
const final {
108 context->loadDialect<LLVM::LLVMDialect>();
113 void populateConvertToLLVMConversionPatterns(
123 dialect->addInterfaces<UBToLLVMDialectInterface>();
static MLIRContext * getContext(OpFoldResult val)
static std::string diag(const llvm::Value &value)
static llvm::ManagedStatic< PassManagerOptions > options
This class implements a pattern rewriter for use with ConversionPatterns.
This class describes a specific conversion target.
Utility class for operation conversions targeting the LLVM dialect that match exactly one source oper...
ConvertOpToLLVMPattern(const LLVMTypeConverter &typeConverter, PatternBenefit benefit=1)
Base class for dialect interfaces providing translation to LLVM IR.
ConvertToLLVMPatternInterface(Dialect *dialect)
This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Derived class that automatically populates legalization information for different LLVM ops.
Conversion from types to the LLVM IR dialect.
Options to control the LLVM lowering.
MLIRContext is the top-level object for a collection of MLIR operations.
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
void registerConvertUBToLLVMInterface(DialectRegistry ®istry)
void populateUBToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns)
Include the generated interface declarations.
static constexpr unsigned kDeriveIndexBitwidthFromDataLayout
Value to pass as bitwidth for the index type when the converter is expected to derive the bitwidth fr...
const FrozenRewritePatternSet & patterns
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, ConversionConfig config=ConversionConfig())
Below we define several entry points for operation conversion.