1 //=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the ARM specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMSUBTARGET_H
15 #define ARMSUBTARGET_H
17 #include "llvm/Target/TargetSubtarget.h"
23 class ARMSubtarget : public TargetSubtarget {
26 V4T, V5T, V5TE, V6, V6T2, V7A
30 None, VFPv2, VFPv3, NEON
38 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
40 ARMArchEnum ARMArchVersion;
42 /// ARMFPUType - Floating Point Unit type.
45 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
48 /// ThumbMode - Indicates supported Thumb version.
49 ThumbTypeEnum ThumbMode;
51 /// UseThumbBacktraces - True if we use thumb style backtraces.
52 bool UseThumbBacktraces;
54 /// IsR9Reserved - True if R9 is a not available as general purpose register.
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;
61 /// CPUString - String name of used CPU.
62 std::string CPUString;
71 ARM_ABI_AAPCS // ARM EABI
74 /// This constructor initializes the data members to match that
75 /// of the specified module.
77 ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
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;
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);
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 hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
96 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
98 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
99 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
100 bool hasNEON() const { return ARMFPUType >= NEON; }
102 bool isTargetDarwin() const { return TargetType == isDarwin; }
103 bool isTargetELF() const { return TargetType == isELF; }
105 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
106 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
108 bool isThumb() const { return IsThumb; }
109 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
110 bool hasThumb2() const { return IsThumb && (ThumbMode >= Thumb2); }
112 bool useThumbBacktraces() const { return UseThumbBacktraces; }
113 bool isR9Reserved() const { return IsR9Reserved; }
115 const std::string & getCPUString() const { return CPUString; }
117 /// getStackAlignment - Returns the minimum alignment known to hold of the
118 /// stack frame on entry to the function and which must be maintained by every
119 /// function for this subtarget.
120 unsigned getStackAlignment() const { return stackAlignment; }
122 } // End llvm namespace
124 #endif // ARMSUBTARGET_H