Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
Show First 20 Lines • Show All 2,841 Lines • ▼ Show 20 Lines | for (auto it : llvm::zip(opOperands, operands)) { | ||||
promotedOperands.push_back(operand); | promotedOperands.push_back(operand); | ||||
} | } | ||||
return promotedOperands; | return promotedOperands; | ||||
} | } | ||||
namespace { | namespace { | ||||
/// A pass converting MLIR operations into the LLVM IR dialect. | /// A pass converting MLIR operations into the LLVM IR dialect. | ||||
struct LLVMLoweringPass : public ModulePass<LLVMLoweringPass> { | struct LLVMLoweringPass : public OperationPass<LLVMLoweringPass, ModuleOp> { | ||||
/// Include the generated pass utilities. | /// Include the generated pass utilities. | ||||
#define GEN_PASS_ConvertStandardToLLVM | #define GEN_PASS_ConvertStandardToLLVM | ||||
#include "mlir/Conversion/Passes.h.inc" | #include "mlir/Conversion/Passes.h.inc" | ||||
/// Creates an LLVM lowering pass. | /// Creates an LLVM lowering pass. | ||||
LLVMLoweringPass(bool useBarePtrCallConv, bool emitCWrappers, | LLVMLoweringPass(bool useBarePtrCallConv, bool emitCWrappers, | ||||
unsigned indexBitwidth) { | unsigned indexBitwidth) { | ||||
this->useBarePtrCallConv = useBarePtrCallConv; | this->useBarePtrCallConv = useBarePtrCallConv; | ||||
this->emitCWrappers = emitCWrappers; | this->emitCWrappers = emitCWrappers; | ||||
this->indexBitwidth = indexBitwidth; | this->indexBitwidth = indexBitwidth; | ||||
} | } | ||||
explicit LLVMLoweringPass() {} | explicit LLVMLoweringPass() {} | ||||
LLVMLoweringPass(const LLVMLoweringPass &pass) {} | LLVMLoweringPass(const LLVMLoweringPass &pass) {} | ||||
/// Run the dialect converter on the module. | /// Run the dialect converter on the module. | ||||
void runOnModule() override { | void runOnOperation() override { | ||||
if (useBarePtrCallConv && emitCWrappers) { | if (useBarePtrCallConv && emitCWrappers) { | ||||
getModule().emitError() | getOperation().emitError() | ||||
<< "incompatible conversion options: bare-pointer calling convention " | << "incompatible conversion options: bare-pointer calling convention " | ||||
"and C wrapper emission"; | "and C wrapper emission"; | ||||
signalPassFailure(); | signalPassFailure(); | ||||
return; | return; | ||||
} | } | ||||
ModuleOp m = getModule(); | ModuleOp m = getOperation(); | ||||
LLVMTypeConverterCustomization customs; | LLVMTypeConverterCustomization customs; | ||||
customs.funcArgConverter = useBarePtrCallConv ? barePtrFuncArgTypeConverter | customs.funcArgConverter = useBarePtrCallConv ? barePtrFuncArgTypeConverter | ||||
: structFuncArgTypeConverter; | : structFuncArgTypeConverter; | ||||
customs.indexBitwidth = indexBitwidth; | customs.indexBitwidth = indexBitwidth; | ||||
LLVMTypeConverter typeConverter(&getContext(), customs); | LLVMTypeConverter typeConverter(&getContext(), customs); | ||||
OwningRewritePatternList patterns; | OwningRewritePatternList patterns; | ||||
Show All 25 Lines |