Change -prefer-32bit-thumb to attribute -mattr=+32bit instead to disable more 32...
authorEvan Cheng <evan.cheng@apple.com>
Mon, 9 Aug 2010 18:35:19 +0000 (18:35 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 9 Aug 2010 18:35:19 +0000 (18:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110584 91177308-0d34-0410-b5e6-96231b3b80d8

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

index fa64d6c2a4b4de1e5218065daedcf870e4c8da55..e76a47dff9dfebb0a0bf8584a46baf891c956f02 100644 (file)
@@ -65,6 +65,9 @@ def FeatureNEONForFP : SubtargetFeature<"neonfp", "UseNEONForSinglePrecisionFP",
                                         "true",
                                         "Use NEON for single precision FP">;
 
+// Disable 32-bit to 16-bit narrowing for experimentation.
+def FeaturePref32BitThumb : SubtargetFeature<"32bit", "Pref32BitThumb", "true",
+                                             "Prefer 32-bit Thumb instrs">;
 
 //===----------------------------------------------------------------------===//
 // ARM Processors supported.
index 118b2de7f4f36cd9b4d919aa7e3ff6cc05d92656..224842d0700d368e71377876c6bdb6f2e7e63ea4 100644 (file)
@@ -357,7 +357,7 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &MF) {
   }
 
   // Shrink 32-bit Thumb2 branch, load, and store instructions.
-  if (isThumb2)
+  if (isThumb2 && !STI->prefers32BitThumb())
     MadeChange |= OptimizeThumb2Instructions(MF);
 
   // After a while, this might be made debug-only, but it is not expensive.
index e7d92ede9b984137ce8c099aa1ef1a429973a0f7..3f2455838f121fef4824b55d879360c2377d7a92 100644 (file)
@@ -84,6 +84,10 @@ protected:
   /// instructions.
   bool HasT2ExtractPack;
 
+  /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
+  /// over 16-bit ones.
+  bool Pref32BitThumb;
+
   /// stackAlignment - The minimum alignment known to hold of the stack frame on
   /// entry to the function and which must be maintained by every function.
   unsigned stackAlignment;
@@ -137,6 +141,7 @@ protected:
   bool hasT2ExtractPack() const { return HasT2ExtractPack; }
   bool useVMLx() const {return hasVFP2() && !SlowVMLx; }
   bool isFPBrccSlow() const { return SlowFPBrcc; }
+  bool prefers32BitThumb() const { return Pref32BitThumb; }
 
   bool hasFP16() const { return HasFP16; }
 
index 2c8460b877fc5aa02b1391c3519a7555cf78f7d0..ac9b6bfbd4646b1a6ec4c63b48e91d213a90d304 100644 (file)
 #include "ARM.h"
 #include "llvm/PassManager.h"
 #include "llvm/CodeGen/Passes.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetRegistry.h"
 using namespace llvm;
 
-static cl::opt<bool>
-Prefer32BitThumbInstrs("prefer-32bit-thumb",
-                       cl::desc("Prefer 32-bit Thumb instructions"),
-                       cl::init(false));
-
 static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
   Triple TheTriple(TT);
   switch (TheTriple.getOS()) {
@@ -143,7 +137,7 @@ bool ARMBaseTargetMachine::addPreSched2(PassManagerBase &PM,
 
 bool ARMBaseTargetMachine::addPreEmitPass(PassManagerBase &PM,
                                           CodeGenOpt::Level OptLevel) {
-  if (!Prefer32BitThumbInstrs && Subtarget.isThumb2())
+  if (Subtarget.isThumb2() && !Subtarget.prefers32BitThumb())
     PM.add(createThumb2SizeReductionPass());
 
   PM.add(createARMConstantIslandPass());