Add placeholder for thumb2 stuff
[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/TargetSubtarget.h"
18 #include <string>
19
20 namespace llvm {
21 class Module;
22
23 class ARMSubtarget : public TargetSubtarget {
24 protected:
25   enum ARMArchEnum {
26     V4T, V5T, V5TE, V6, V7A
27   };
28
29   enum ARMFPEnum {
30     None, VFPv2, VFPv3, NEON
31   };
32
33   enum ThumbTypeEnum {
34     ThumbNone,
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   /// ThumbMode - ARM if in ARM mode, otherwise indicates Thumb version.
47   ThumbTypeEnum ThumbMode;
48
49   /// UseThumbBacktraces - True if we use thumb style backtraces.
50   bool UseThumbBacktraces;
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  public:
63   enum {
64     isELF, isDarwin
65   } TargetType;
66
67   enum {
68     ARM_ABI_APCS,
69     ARM_ABI_AAPCS // ARM EABI
70   } TargetABI;
71
72   /// This constructor initializes the data members to match that
73   /// of the specified module.
74   ///
75   ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
76
77   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
78   /// that still makes it profitable to inline the call.
79   unsigned getMaxInlineSizeThreshold() const {
80     // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
81     // Change this once Thumb ldmia / stmia support is added.
82     return isThumb() ? 0 : 64;
83   }
84   /// ParseSubtargetFeatures - Parses features string setting specified
85   /// subtarget options.  Definition of function is auto generated by tblgen.
86   std::string ParseSubtargetFeatures(const std::string &FS,
87                                      const std::string &CPU);
88
89   bool hasV4TOps()  const { return ARMArchVersion >= V4T;  }
90   bool hasV5TOps()  const { return ARMArchVersion >= V5T;  }
91   bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
92   bool hasV6Ops()   const { return ARMArchVersion >= V6;   }
93   bool hasV7Ops()   const { return ARMArchVersion >= V7A;  }
94
95   bool hasVFP2() const { return ARMFPUType >= VFPv2; }
96   bool hasVFP3() const { return ARMFPUType >= VFPv3; }
97   bool hasNEON() const { return ARMFPUType >= NEON;  }
98
99   bool isTargetDarwin() const { return TargetType == isDarwin; }
100   bool isTargetELF() const { return TargetType == isELF; }
101
102   bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
103   bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
104
105   bool isThumb() const { return ThumbMode >= Thumb1; }
106   bool isThumb2() const { return ThumbMode >= Thumb2; }
107
108   bool useThumbBacktraces() const { return UseThumbBacktraces; }
109   bool isR9Reserved() const { return IsR9Reserved; }
110
111   const std::string & getCPUString() const { return CPUString; }
112
113   /// getStackAlignment - Returns the minimum alignment known to hold of the
114   /// stack frame on entry to the function and which must be maintained by every
115   /// function for this subtarget.
116   unsigned getStackAlignment() const { return stackAlignment; }
117 };
118 } // End llvm namespace
119
120 #endif  // ARMSUBTARGET_H