[llvm] r182220 - SubArch support in MCJIT unittest

Renato Golin renato.golin at linaro.org
Sun May 19 13:10:11 PDT 2013


Author: rengolin
Date: Sun May 19 15:10:10 2013
New Revision: 182220

URL: http://llvm.org/viewvc/llvm-project?rev=182220&view=rev
Log:
SubArch support in MCJIT unittest

Modified:
    llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
    llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h
    llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h

Modified: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp?rev=182220&r1=182219&r2=182220&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp Sun May 19 15:10:10 2013
@@ -35,6 +35,13 @@ protected:
     SupportedArchs.push_back(Triple::x86);
     SupportedArchs.push_back(Triple::x86_64);
 
+    // Some architectures have sub-architectures in which tests will fail, like
+    // ARM. These two vectors will define if they do have sub-archs (to avoid
+    // extra work for those who don't), and if so, if they are listed to work
+    HasSubArchs.push_back(Triple::arm);
+    SupportedSubArchs.push_back("armv6");
+    SupportedSubArchs.push_back("armv7");
+
     // The operating systems below are known to be sufficiently incompatible
     // that they will fail the MCJIT C API tests.
     UnsupportedOSs.push_back(Triple::Cygwin);

Modified: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h?rev=182220&r1=182219&r2=182220&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h (original)
+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h Sun May 19 15:10:10 2013
@@ -49,11 +49,23 @@ 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
@@ -68,6 +80,8 @@ protected:
 
   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;
 };
 

Modified: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h?rev=182220&r1=182219&r2=182220&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h (original)
+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h Sun May 19 15:10:10 2013
@@ -50,6 +50,13 @@ protected:
     SupportedArchs.push_back(Triple::x86);
     SupportedArchs.push_back(Triple::x86_64);
 
+    // Some architectures have sub-architectures in which tests will fail, like
+    // ARM. These two vectors will define if they do have sub-archs (to avoid
+    // extra work for those who don't), and if so, if they are listed to work
+    HasSubArchs.push_back(Triple::arm);
+    SupportedSubArchs.push_back("armv6");
+    SupportedSubArchs.push_back("armv7");
+
     // The operating systems below are known to be incompatible with MCJIT as
     // they are copied from the test/ExecutionEngine/MCJIT/lit.local.cfg and
     // should be kept in sync.





More information about the llvm-commits mailing list