+// Base class for Orc tests that will execute code.
+class OrcExecutionTest {
+public:
+
+ OrcExecutionTest() {
+ if (!NativeTargetInitialized) {
+ InitializeNativeTarget();
+ InitializeNativeTargetAsmParser();
+ 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());
+
+ const Triple& TT = TM->getTargetTriple();
+
+ if (TT.getArch() == Triple::x86_64)
+ return std::move(TM);
+
+ return nullptr;
+ }
+
+private:
+ static bool NativeTargetInitialized;
+};
+