InitializeNativeTargetAsmPrinter();
NativeTargetInitialized = true;
}
- };
-
- // Get a target machine for the host if it supports JIT execution.
- std::unique_ptr<TargetMachine> getHostTargetMachineIfSupported() {
- std::unique_ptr<TargetMachine> TM(EngineBuilder().selectTarget());
-
- if (!TM)
- return nullptr;
-
- const Triple& TT = TM->getTargetTriple();
- if (TT.getArch() != Triple::x86_64 || !TT.isOSDarwin())
- return nullptr;
+ // Try to select a TargetMachine for the host.
+ TM.reset(EngineBuilder().selectTarget());
- return TM;
- }
+ if (TM) {
+ // If we found a TargetMachine, check that it's one that Orc supports.
+ const Triple& TT = TM->getTargetTriple();
+ if (TT.getArch() != Triple::x86_64 || !TT.isOSDarwin())
+ TM = nullptr;
+ }
+ };
+protected:
+ std::unique_ptr<TargetMachine> TM;
private:
static bool NativeTargetInitialized;
};