[Orc] Expose the compile callback API through the C bindings.
[oota-llvm.git] / unittests / ExecutionEngine / Orc / OrcTestCommon.h
index bfdaced05b14d9a50f8ad83eaf9321d3a028d11a..15d9f54a37fc59992394fad4098f016e49952314 100644 (file)
@@ -38,23 +38,20 @@ public:
       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;
 };