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