Add a target lowering hook to control whether it's worthwhile to compress fp constant.
[oota-llvm.git] / lib / Target / ARM / ARMSubtarget.cpp
index 35bb9accc3507ee46afa767960b60182360101d1..bbc2202c3ba2047f660a7a247c8c1fd5814a93da 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Evan Cheng and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
 #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)
-  : ARMArchVersion(V4T), HasVFP2(false), IsDarwin(false),
-    UseThumbBacktraces(false), IsR9Reserved(false), stackAlignment(8) {
+ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb)
+  : ARMArchVersion(V4T)
+  , HasVFP2(false)
+  , IsThumb(thumb)
+  , UseThumbBacktraces(false)
+  , IsR9Reserved(false)
+  , stackAlignment(4)
+  , TargetType(isELF) // Default to ELF unless otherwise specified.
+  , TargetABI(ARM_ABI_APCS) {
 
   // Determine default and user specified characteristics
   std::string CPU = "generic";
@@ -31,22 +32,26 @@ 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();
   if (TT.length() > 5) {
-    IsDarwin = TT.find("-darwin") != std::string::npos;
+    if (TT.find("-darwin") != std::string::npos)
+      TargetType = isDarwin;
   } else if (TT.empty()) {
 #if defined(__APPLE__)
-    IsDarwin = true;
+    TargetType = isDarwin;
 #endif
   }
 
-  if (IsDarwin) {
+  if (TT.find("eabi") != std::string::npos)
+    TargetABI = ARM_ABI_AAPCS;
+
+  if (isAAPCS_ABI())
+    stackAlignment = 8;
+
+  if (isTargetDarwin()) {
     UseThumbBacktraces = true;
     IsR9Reserved = true;
-    stackAlignment = 4;
-  } 
+  }
 }