Revert 74164. We'll want to use this method later.
[oota-llvm.git] / lib / Target / ARM / ARMSubtarget.h
1 //=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the ARM specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARMSUBTARGET_H
15 #define ARMSUBTARGET_H
16
17 #include "llvm/Target/TargetInstrItineraries.h"
18 #include "llvm/Target/TargetSubtarget.h"
19 #include <string>
20
21 namespace llvm {
22 class Module;
23
24 class ARMSubtarget : public TargetSubtarget {
25 protected:
26   enum ARMArchEnum {
27     V4T, V5T, V5TE, V6, V6T2, V7A
28   };
29
30   enum ARMFPEnum {
31     None, VFPv2, VFPv3, NEON
32   };
33
34   enum ThumbTypeEnum {
35     Thumb1,
36     Thumb2
37   };
38
39   /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
40   /// V6, V6T2, V7A.
41   ARMArchEnum ARMArchVersion;
42
43   /// ARMFPUType - Floating Point Unit type.
44   ARMFPEnum ARMFPUType;
45
46   /// IsThumb - True if we are in thumb mode, false if in ARM mode.
47   bool IsThumb;
48
49   /// ThumbMode - Indicates supported Thumb version.
50   ThumbTypeEnum ThumbMode;
51
52   /// IsR9Reserved - True if R9 is a not available as general purpose register.
53   bool IsR9Reserved;
54
55   /// stackAlignment - The minimum alignment known to hold of the stack frame on
56   /// entry to the function and which must be maintained by every function.
57   unsigned stackAlignment;
58
59   /// CPUString - String name of used CPU.
60   std::string CPUString;
61
62   /// Selected instruction itineraries (one entry per itinerary class.)
63   InstrItineraryData InstrItins;
64   
65  public:
66   enum {
67     isELF, isDarwin
68   } TargetType;
69
70   enum {
71     ARM_ABI_APCS,
72     ARM_ABI_AAPCS // ARM EABI
73   } TargetABI;
74
75   /// This constructor initializes the data members to match that
76   /// of the specified module.
77   ///
78   ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
79
80   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
81   /// that still makes it profitable to inline the call.
82   unsigned getMaxInlineSizeThreshold() const {
83     // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
84     // Change this once Thumb ldmia / stmia support is added.
85     return isThumb() ? 0 : 64;
86   }
87   /// ParseSubtargetFeatures - Parses features string setting specified
88   /// subtarget options.  Definition of function is auto generated by tblgen.
89   std::string ParseSubtargetFeatures(const std::string &FS,
90                                      const std::string &CPU);
91
92   bool hasV4TOps()  const { return ARMArchVersion >= V4T;  }
93   bool hasV5TOps()  const { return ARMArchVersion >= V5T;  }
94   bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
95   bool hasV6Ops()   const { return ARMArchVersion >= V6;   }
96   bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
97   bool hasV7Ops()   const { return ARMArchVersion >= V7A;  }
98
99   bool hasVFP2() const { return ARMFPUType >= VFPv2; }
100   bool hasVFP3() const { return ARMFPUType >= VFPv3; }
101   bool hasNEON() const { return ARMFPUType >= NEON;  }
102
103   bool isTargetDarwin() const { return TargetType == isDarwin; }
104   bool isTargetELF() const { return TargetType == isELF; }
105
106   bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
107   bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
108
109   bool isThumb() const { return IsThumb; }
110   bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
111   bool hasThumb2() const { return IsThumb && (ThumbMode >= Thumb2); }
112
113   bool isR9Reserved() const { return IsR9Reserved; }
114
115   const std::string & getCPUString() const { return CPUString; }
116
117   /// getInstrItins - Return the instruction itineraies based on subtarget 
118   /// selection.
119   const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
120
121   /// getStackAlignment - Returns the minimum alignment known to hold of the
122   /// stack frame on entry to the function and which must be maintained by every
123   /// function for this subtarget.
124   unsigned getStackAlignment() const { return stackAlignment; }
125 };
126 } // End llvm namespace
127
128 #endif  // ARMSUBTARGET_H