This allows client to be able to reuse the same logic to setup a module
for the ExecutionEngine without instanciating one. One use case is running
the optimization pipeline but not JIT-ing.
--
PiperOrigin-RevId:
242614380
// Initialize LLVM targets.
llvm::InitializeNativeTarget();
llvm::InitializeNativeTargetAsmPrinter();
+ mlir::ExecutionEngine::setupTargetTriple(llvmModule.get());
auto optPipeline = mlir::makeOptimizingTransformer(
/* optLevel=*/EnableOpt ? 3 : 0, /* sizeLevel=*/0);
if (auto err = optPipeline(llvmModule.get())) {
/// the templated `invoke`.
llvm::Error invoke(StringRef name, MutableArrayRef<void *> args);
+ /// Set the target triple on the module. This is implicitly done when creating
+ /// the engine.
+ static bool setupTargetTriple(llvm::Module *llvmModule);
+
private:
// Ordering of llvmContext and jit is important for destruction purposes: the
// jit must be destroyed before the context.
}
// Setup LLVM target triple from the current machine.
-static bool setupTargetTriple(llvm::Module *llvmModule) {
+bool ExecutionEngine::setupTargetTriple(llvm::Module *llvmModule) {
// Setup the machine properties from the current architecture.
auto targetTriple = llvm::sys::getDefaultTargetTriple();
std::string errorMessage;