ARMSubtarget.h revision e4e4ed3b56f63e9343e01bf0b2ecd7c1f45d296c
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 GlobalValue;
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  /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
47  /// specified. Use the method useNEONForSinglePrecisionFP() to
48  /// determine if NEON should actually be used.
49  bool UseNEONForSinglePrecisionFP;
50
51  /// IsThumb - True if we are in thumb mode, false if in ARM mode.
52  bool IsThumb;
53
54  /// ThumbMode - Indicates supported Thumb version.
55  ThumbTypeEnum ThumbMode;
56
57  /// IsR9Reserved - True if R9 is a not available as general purpose register.
58  bool IsR9Reserved;
59
60  /// stackAlignment - The minimum alignment known to hold of the stack frame on
61  /// entry to the function and which must be maintained by every function.
62  unsigned stackAlignment;
63
64  /// CPUString - String name of used CPU.
65  std::string CPUString;
66
67  /// Selected instruction itineraries (one entry per itinerary class.)
68  InstrItineraryData InstrItins;
69
70 public:
71  enum {
72    isELF, isDarwin
73  } TargetType;
74
75  enum {
76    ARM_ABI_APCS,
77    ARM_ABI_AAPCS // ARM EABI
78  } TargetABI;
79
80  /// This constructor initializes the data members to match that
81  /// of the specified triple.
82  ///
83  ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
84
85  /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
86  /// that still makes it profitable to inline the call.
87  unsigned getMaxInlineSizeThreshold() const {
88    // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
89    // Change this once Thumb ldmia / stmia support is added.
90    return isThumb() ? 0 : 64;
91  }
92  /// ParseSubtargetFeatures - Parses features string setting specified
93  /// subtarget options.  Definition of function is auto generated by tblgen.
94  std::string ParseSubtargetFeatures(const std::string &FS,
95                                     const std::string &CPU);
96
97  bool hasV4TOps()  const { return ARMArchVersion >= V4T;  }
98  bool hasV5TOps()  const { return ARMArchVersion >= V5T;  }
99  bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
100  bool hasV6Ops()   const { return ARMArchVersion >= V6;   }
101  bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
102  bool hasV7Ops()   const { return ARMArchVersion >= V7A;  }
103
104  bool hasVFP2() const { return ARMFPUType >= VFPv2; }
105  bool hasVFP3() const { return ARMFPUType >= VFPv3; }
106  bool hasNEON() const { return ARMFPUType >= NEON;  }
107  bool useNEONForSinglePrecisionFP() const {
108    return hasNEON() && UseNEONForSinglePrecisionFP; }
109
110  bool isTargetDarwin() const { return TargetType == isDarwin; }
111  bool isTargetELF() const { return TargetType == isELF; }
112
113  bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
114  bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
115
116  bool isThumb() const { return IsThumb; }
117  bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
118  bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
119  bool hasThumb2() const { return ThumbMode >= Thumb2; }
120
121  bool isR9Reserved() const { return IsR9Reserved; }
122
123  const std::string & getCPUString() const { return CPUString; }
124
125  /// getInstrItins - Return the instruction itineraies based on subtarget
126  /// selection.
127  const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
128
129  /// getStackAlignment - Returns the minimum alignment known to hold of the
130  /// stack frame on entry to the function and which must be maintained by every
131  /// function for this subtarget.
132  unsigned getStackAlignment() const { return stackAlignment; }
133
134  /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
135  /// symbol.
136  bool GVIsIndirectSymbol(GlobalValue *GV, bool isStatic) const;
137};
138} // End llvm namespace
139
140#endif  // ARMSUBTARGET_H
141