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/TargetInstrItineraries.h"
18 #include "llvm/Target/TargetSubtarget.h"
24 class ARMSubtarget : public TargetSubtarget {
27 V4T, V5T, V5TE, V6, V6T2, V7A
31 None, VFPv2, VFPv3, NEON
39 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
41 ARMArchEnum ARMArchVersion;
43 /// ARMFPUType - Floating Point Unit type.
46 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
49 /// ThumbMode - Indicates supported Thumb version.
50 ThumbTypeEnum ThumbMode;
52 /// IsR9Reserved - True if R9 is a not available as general purpose register.
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;
59 /// CPUString - String name of used CPU.
60 std::string CPUString;
62 /// Selected instruction itineraries (one entry per itinerary class.)
63 InstrItineraryData InstrItins;
72 ARM_ABI_AAPCS // ARM EABI
75 /// This constructor initializes the data members to match that
76 /// of the specified module.
78 ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
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;
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);
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; }
99 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
100 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
101 bool hasNEON() const { return ARMFPUType >= NEON; }
103 bool isTargetDarwin() const { return TargetType == isDarwin; }
104 bool isTargetELF() const { return TargetType == isELF; }
106 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
107 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
109 bool isThumb() const { return IsThumb; }
110 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
111 bool hasThumb2() const { return IsThumb && (ThumbMode >= Thumb2); }
113 bool isR9Reserved() const { return IsR9Reserved; }
115 const std::string & getCPUString() const { return CPUString; }
117 /// getInstrItins - Return the instruction itineraies based on subtarget
119 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
121 /// getStackAlignment - Returns the minimum alignment known to hold of the
122 /// stack frame on entry to the function and which must be maintained by every
123 /// function for this subtarget.
124 unsigned getStackAlignment() const { return stackAlignment; }
126 } // End llvm namespace
128 #endif // ARMSUBTARGET_H