Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | static void createPrintMsg(OpBuilder &builder, Location loc, ModuleOp moduleOp, | ||||
// Emit call to `printStr` in runtime library. | // Emit call to `printStr` in runtime library. | ||||
builder.restoreInsertionPoint(ip); | builder.restoreInsertionPoint(ip); | ||||
auto msgAddr = builder.create<LLVM::AddressOfOp>( | auto msgAddr = builder.create<LLVM::AddressOfOp>( | ||||
loc, LLVM::LLVMPointerType::get(arrayTy), globalOp.getName()); | loc, LLVM::LLVMPointerType::get(arrayTy), globalOp.getName()); | ||||
SmallVector<LLVM::GEPArg> indices(1, 0); | SmallVector<LLVM::GEPArg> indices(1, 0); | ||||
Value gep = builder.create<LLVM::GEPOp>( | Value gep = builder.create<LLVM::GEPOp>( | ||||
loc, LLVM::LLVMPointerType::get(builder.getI8Type()), msgAddr, indices); | loc, LLVM::LLVMPointerType::get(builder.getI8Type()), msgAddr, indices); | ||||
Operation *printer = LLVM::lookupOrCreatePrintStrFn(moduleOp); | Operation *printer = | ||||
LLVM::lookupOrCreatePrintStrFn(moduleOp, /*TODO: opaquePointers=*/false); | |||||
builder.create<LLVM::CallOp>(loc, TypeRange(), SymbolRefAttr::get(printer), | builder.create<LLVM::CallOp>(loc, TypeRange(), SymbolRefAttr::get(printer), | ||||
gep); | gep); | ||||
} | } | ||||
namespace { | namespace { | ||||
/// Lower `cf.assert`. The default lowering calls the `abort` function if the | /// Lower `cf.assert`. The default lowering calls the `abort` function if the | ||||
/// assertion is violated and has no effect otherwise. The failure message is | /// assertion is violated and has no effect otherwise. The failure message is | ||||
/// ignored by the default lowering but should be propagated by any custom | /// ignored by the default lowering but should be propagated by any custom | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |