Added -march=thumb; removed -enable-thumb.
authorEvan Cheng <evan.cheng@apple.com>
Fri, 23 Feb 2007 03:14:31 +0000 (03:14 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 23 Feb 2007 03:14:31 +0000 (03:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34521 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMSubtarget.cpp
lib/Target/ARM/ARMSubtarget.h
lib/Target/ARM/ARMTargetMachine.cpp
lib/Target/ARM/ARMTargetMachine.h

index 4363697d3e37e9bff93d9f9420a163a5a9a3c49c..6db36dff29ca5b2d1bf6a276a73e3bb405a5da81 100644 (file)
 #include "ARMSubtarget.h"
 #include "ARMGenSubtarget.inc"
 #include "llvm/Module.h"
-#include "llvm/Support/CommandLine.h"
 using namespace llvm;
 
-// FIXME: this is temporary.
-static cl::opt<bool> Thumb("enable-thumb",
-                           cl::desc("Switch to thumb mode in ARM backend"));
-
-ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS)
+ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb)
   : ARMArchVersion(V4T)
   , HasVFP2(false)
+  , IsThumb(thumb)
   , UseThumbBacktraces(false)
   , IsR9Reserved(false)
   , stackAlignment(4)
@@ -36,8 +32,6 @@ ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS)
   // Parse features string.
   ParseSubtargetFeatures(FS, CPU);
 
-  IsThumb = Thumb;
-  
   // Set the boolean corresponding to the current target triple, or the default
   // if one cannot be determined, to true.
   const std::string& TT = M.getTargetTriple();
index 88ceaef7b660a95178ee439da4dbad7ac2a6cc79..62367cadb911674fbd676a1e6af3f095fe3711af 100644 (file)
@@ -60,7 +60,7 @@ protected:
   /// This constructor initializes the data members to match that
   /// of the specified module.
   ///
-  ARMSubtarget(const Module &M, const std::string &FS);
+  ARMSubtarget(const Module &M, const std::string &FS, bool thumb);
 
   /// ParseSubtargetFeatures - Parses features string setting specified 
   /// subtarget options.  Definition of function is auto generated by tblgen.
index 2fa701608582a9f3a9a481e5e354658dc02837e4..0b22c15ba35128a51fb7c527e0ec8d1854752879 100644 (file)
@@ -27,21 +27,37 @@ static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden,
 
 namespace {
   // Register the target.
-  RegisterTarget<ARMTargetMachine> X("arm", "  ARM");
+  RegisterTarget<ARMTargetMachine>   X("arm",   "  ARM");
+  RegisterTarget<ThumbTargetMachine> Y("thumb", "  Thumb");
 }
 
-/// TargetMachine ctor - Create an ILP32 architecture model
+/// ThumbTargetMachine - Create an Thumb architecture model.
 ///
-ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
-  : Subtarget(M, FS),
+unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) {
+  std::string TT = M.getTargetTriple();
+  if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "thumb-")
+    return 20;
+
+  return M.getPointerSize() == Module::Pointer32;
+}
+
+ThumbTargetMachine::ThumbTargetMachine(const Module &M, const std::string &FS) 
+  : ARMTargetMachine(M, FS, true) {
+}
+
+/// TargetMachine ctor - Create an ARM architecture model.
+///
+ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS,
+                                   bool isThumb)
+  : Subtarget(M, FS, isThumb),
     DataLayout(Subtarget.isAPCS_ABI() ?
                // APCS ABI
-          (Subtarget.isThumb() ?
+          (isThumb ?
            std::string("e-p:32:32-f64:32:32-i64:32:32-"
                        "i16:16:32-i8:8:32-i1:8:32-a:0:32") :
            std::string("e-p:32:32-f64:32:32-i64:32:32")) :
                // AAPCS ABI
-          (Subtarget.isThumb() ?
+          (isThumb ?
            std::string("e-p:32:32-f64:64:64-i64:64:64-"
                        "i16:16:32-i8:8:32-i1:8:32-a:0:32") :
            std::string("e-p:32:32-f64:64:64-i64:64:64"))),
@@ -53,10 +69,7 @@ unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
   if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-")
     return 20;
 
-  if (M.getPointerSize() == Module::Pointer32)
-    return 1;
-  else
-    return 0;
+  return M.getPointerSize() == Module::Pointer32;
 }
 
 
index 9c888ea3955a23eaf831514b608095d1f68b4fc7..7f45fb6b6c0e2053a6ea0fbf48489414bea23bda 100644 (file)
@@ -32,7 +32,7 @@ class ARMTargetMachine : public LLVMTargetMachine {
   ARMInstrInfo      InstrInfo;
   ARMFrameInfo      FrameInfo;
 public:
-  ARMTargetMachine(const Module &M, const std::string &FS);
+  ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
 
   virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
@@ -52,6 +52,15 @@ public:
                                   std::ostream &Out);
 };
 
+/// ThumbTargetMachine - Thumb target machine.
+///
+class ThumbTargetMachine : public ARMTargetMachine {
+public:
+  ThumbTargetMachine(const Module &M, const std::string &FS);
+
+  static unsigned getModuleMatchQuality(const Module &M);
+};
+
 } // end namespace llvm
 
 #endif