ARMSubtarget.h revision 195340
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
21namespace llvm {
22class Module;
23
24class ARMSubtarget : public TargetSubtarget {
25protected:
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 isThumb2() const { return IsThumb && (ThumbMode >= Thumb2); }
112  bool hasThumb2() const { return ThumbMode >= Thumb2; }
113
114  bool isR9Reserved() const { return IsR9Reserved; }
115
116  const std::string & getCPUString() const { return CPUString; }
117
118  /// getInstrItins - Return the instruction itineraies based on subtarget
119  /// selection.
120  const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
121
122  /// getStackAlignment - Returns the minimum alignment known to hold of the
123  /// stack frame on entry to the function and which must be maintained by every
124  /// function for this subtarget.
125  unsigned getStackAlignment() const { return stackAlignment; }
126};
127} // End llvm namespace
128
129#endif  // ARMSUBTARGET_H
130