#include "mlir/Transforms/Passes.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassNameParser.h"
if (failed(mlirTransformer(m.get())))
return EXIT_FAILURE;
+ auto tmBuilderOrError = llvm::orc::JITTargetMachineBuilder::detectHost();
+ if (!tmBuilderOrError) {
+ llvm::errs() << "Failed to create a JITTargetMachineBuilder for the host\n";
+ return EXIT_FAILURE;
+ }
+ auto tmOrError = tmBuilderOrError->createTargetMachine();
+ if (!tmOrError) {
+ llvm::errs() << "Failed to create a TargetMachine for the host\n";
+ return EXIT_FAILURE;
+ }
+
auto transformer = mlir::makeLLVMPassesTransformer(
- passes, optLevel, /*targetMachine=*/nullptr, optPosition);
+ passes, optLevel, /*targetMachine=*/tmOrError->get(), optPosition);
auto error = mainFuncType.getValue() == "f32"
? compileAndExecuteSingleFloatReturnFunction(
m.get(), mainFuncName.getValue(), transformer)