fcf3490e15fe1320d09effb2bebae5f02f99e9f9
[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     Thumb1,
35     Thumb2
36   };
37
38   /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
39   /// V6, V6T2, V7A.
40   ARMArchEnum ARMArchVersion;
41
42   /// ARMFPUType - Floating Point Unit type.
43   ARMFPEnum ARMFPUType;
44
45   /// IsThumb - True if we are in thumb mode, false if in ARM mode.
46   bool IsThumb;
47
48   /// ThumbMode - Indicates supported Thumb version.
49   ThumbTypeEnum ThumbMode;
50
51   /// UseThumbBacktraces - True if we use thumb style backtraces.
52   bool UseThumbBacktraces;
53
54   /// IsR9Reserved - True if R9 is a not available as general purpose register.
55   bool IsR9Reserved;
56
57   /// stackAlignment - The minimum alignment known to hold of the stack frame on
58   /// entry to the function and which must be maintained by every function.
59   unsigned stackAlignment;
60
61   /// CPUString - String name of used CPU.
62   std::string CPUString;
63
64  public:
65   enum {
66     isELF, isDarwin
67   } TargetType;
68
69   enum {
70     ARM_ABI_APCS,
71     ARM_ABI_AAPCS // ARM EABI
72   } TargetABI;
73
74   /// This constructor initializes the data members to match that
75   /// of the specified module.
76   ///
77   ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
78
79   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
80   /// that still makes it profitable to inline the call.
81   unsigned getMaxInlineSizeThreshold() const {
82     // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
83     // Change this once Thumb ldmia / stmia support is added.
84     return isThumb() ? 0 : 64;
85   }
86   /// ParseSubtargetFeatures - Parses features string setting specified
87   /// subtarget options.  Definition of function is auto generated by tblgen.
88   std::string ParseSubtargetFeatures(const std::string &FS,
89                                      const std::string &CPU);
90
91   bool hasV4TOps()  const { return ARMArchVersion >= V4T;  }
92   bool hasV5TOps()  const { return ARMArchVersion >= V5T;  }
93   bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
94   bool hasV6Ops()   const { return ARMArchVersion >= V6;   }
95   bool hasV7Ops()   const { return ARMArchVersion >= V7A;  }
96
97   bool hasVFP2() const { return ARMFPUType >= VFPv2; }
98   bool hasVFP3() const { return ARMFPUType >= VFPv3; }
99   bool hasNEON() const { return ARMFPUType >= NEON;  }
100
101   bool isTargetDarwin() const { return TargetType == isDarwin; }
102   bool isTargetELF() const { return TargetType == isELF; }
103
104   bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
105   bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
106
107   bool isThumb() const { return IsThumb; }
108   bool isThumb1() const { return IsThumb && (ThumbMode == Thumb1); }
109   bool isThumb2() const { return IsThumb && (ThumbMode >= Thumb2); }
110
111   bool useThumbBacktraces() const { return UseThumbBacktraces; }
112   bool isR9Reserved() const { return IsR9Reserved; }
113
114   const std::string & getCPUString() const { return CPUString; }
115
116   /// getStackAlignment - Returns the minimum alignment known to hold of the
117   /// stack frame on entry to the function and which must be maintained by every
118   /// function for this subtarget.
119   unsigned getStackAlignment() const { return stackAlignment; }
120 };
121 } // End llvm namespace
122
123 #endif  // ARMSUBTARGET_H