[llvm-commits] CVS: llvm/lib/Target/ARM/ARMSubtarget.cpp ARMSubtarget.h ARMTargetMachine.cpp ARMTargetMachine.h

Evan Cheng evan.cheng at apple.com
Thu Feb 22 19:14:47 PST 2007



Changes in directory llvm/lib/Target/ARM:

ARMSubtarget.cpp updated: 1.3 -> 1.4
ARMSubtarget.h updated: 1.3 -> 1.4
ARMTargetMachine.cpp updated: 1.24 -> 1.25
ARMTargetMachine.h updated: 1.7 -> 1.8
---
Log message:

Added -march=thumb; removed -enable-thumb.

---
Diffs of the changes:  (+36 -20)

 ARMSubtarget.cpp     |   10 ++--------
 ARMSubtarget.h       |    2 +-
 ARMTargetMachine.cpp |   33 +++++++++++++++++++++++----------
 ARMTargetMachine.h   |   11 ++++++++++-
 4 files changed, 36 insertions(+), 20 deletions(-)


Index: llvm/lib/Target/ARM/ARMSubtarget.cpp
diff -u llvm/lib/Target/ARM/ARMSubtarget.cpp:1.3 llvm/lib/Target/ARM/ARMSubtarget.cpp:1.4
--- llvm/lib/Target/ARM/ARMSubtarget.cpp:1.3	Tue Feb 13 13:52:28 2007
+++ llvm/lib/Target/ARM/ARMSubtarget.cpp	Thu Feb 22 21:14:31 2007
@@ -14,16 +14,12 @@
 #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 @@
   // 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: llvm/lib/Target/ARM/ARMSubtarget.h
diff -u llvm/lib/Target/ARM/ARMSubtarget.h:1.3 llvm/lib/Target/ARM/ARMSubtarget.h:1.4
--- llvm/lib/Target/ARM/ARMSubtarget.h:1.3	Tue Feb 13 13:52:28 2007
+++ llvm/lib/Target/ARM/ARMSubtarget.h	Thu Feb 22 21:14:31 2007
@@ -60,7 +60,7 @@
   /// 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: llvm/lib/Target/ARM/ARMTargetMachine.cpp
diff -u llvm/lib/Target/ARM/ARMTargetMachine.cpp:1.24 llvm/lib/Target/ARM/ARMTargetMachine.cpp:1.25
--- llvm/lib/Target/ARM/ARMTargetMachine.cpp:1.24	Tue Feb 13 23:52:17 2007
+++ llvm/lib/Target/ARM/ARMTargetMachine.cpp	Thu Feb 22 21:14:31 2007
@@ -27,21 +27,37 @@
 
 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 @@
   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: llvm/lib/Target/ARM/ARMTargetMachine.h
diff -u llvm/lib/Target/ARM/ARMTargetMachine.h:1.7 llvm/lib/Target/ARM/ARMTargetMachine.h:1.8
--- llvm/lib/Target/ARM/ARMTargetMachine.h:1.7	Fri Jan 19 01:51:42 2007
+++ llvm/lib/Target/ARM/ARMTargetMachine.h	Thu Feb 22 21:14:31 2007
@@ -32,7 +32,7 @@
   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 @@
                                   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






More information about the llvm-commits mailing list