Canonicalize header guards into a common format.
[oota-llvm.git] / unittests / ExecutionEngine / MCJIT / MCJITTestAPICommon.h
index 8160a186f413be40f90c413e087013f59307ac14..7d704def4617e694586c7c194023798083043165 100644 (file)
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MCJIT_TEST_API_COMMON_H
-#define MCJIT_TEST_API_COMMON_H
+#ifndef LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTAPICOMMON_H
+#define LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTAPICOMMON_H
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Triple.h"
@@ -49,29 +49,49 @@ protected:
   /// Returns true if the host architecture is known to support MCJIT
   bool ArchSupportsMCJIT() {
     Triple Host(HostTriple);
+    // If ARCH is not supported, bail
     if (std::find(SupportedArchs.begin(), SupportedArchs.end(), Host.getArch())
-        == SupportedArchs.end()) {
+        == SupportedArchs.end())
       return false;
-    }
-    return true;
+
+    // If ARCH is supported and has no specific sub-arch support
+    if (std::find(HasSubArchs.begin(), HasSubArchs.end(), Host.getArch())
+        == HasSubArchs.end())
+      return true;
+
+    // If ARCH has sub-arch support, find it
+    SmallVectorImpl<std::string>::const_iterator I = SupportedSubArchs.begin();
+    for(; I != SupportedSubArchs.end(); ++I)
+      if (Host.getArchName().startswith(I->c_str()))
+        return true;
+
+    return false;
   }
 
   /// Returns true if the host OS is known to support MCJIT
   bool OSSupportsMCJIT() {
     Triple Host(HostTriple);
+
+    if (std::find(UnsupportedEnvironments.begin(), UnsupportedEnvironments.end(),
+                  Host.getEnvironment()) != UnsupportedEnvironments.end())
+      return false;
+
     if (std::find(UnsupportedOSs.begin(), UnsupportedOSs.end(), Host.getOS())
-        == UnsupportedOSs.end()) {
+        == UnsupportedOSs.end())
       return true;
-    }
+
     return false;
   }
 
   std::string HostTriple;
   SmallVector<Triple::ArchType, 4> SupportedArchs;
+  SmallVector<Triple::ArchType, 1> HasSubArchs;
+  SmallVector<std::string, 2> SupportedSubArchs; // We need to own the memory
   SmallVector<Triple::OSType, 4> UnsupportedOSs;
+  SmallVector<Triple::EnvironmentType, 1> UnsupportedEnvironments;
 };
 
 } // namespace llvm
 
-#endif // MCJIT_TEST_API_COMMON_H
+#endif