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 TargetSubtargetInfo.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMSUBTARGET_H
15 #define ARMSUBTARGET_H
17 #include "MCTargetDesc/ARMMCTargetDesc.h"
18 #include "llvm/Target/TargetSubtargetInfo.h"
19 #include "llvm/MC/MCInstrItineraries.h"
20 #include "llvm/ADT/Triple.h"
23 #define GET_SUBTARGETINFO_HEADER
24 #include "ARMGenSubtargetInfo.inc"
30 class ARMSubtarget : public ARMGenSubtargetInfo {
32 enum ARMProcFamilyEnum {
33 Others, CortexA8, CortexA9
36 /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
37 ARMProcFamilyEnum ARMProcFamily;
39 /// HasV4TOps, HasV5TOps, HasV5TEOps, HasV6Ops, HasV6T2Ops, HasV7Ops -
40 /// Specify whether target support specific ARM ISA variants.
48 /// HasVFPv2, HasVFPv3, HasNEON - Specify what floating point ISAs are
54 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
55 /// specified. Use the method useNEONForSinglePrecisionFP() to
56 /// determine if NEON should actually be used.
57 bool UseNEONForSinglePrecisionFP;
59 /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
60 /// whether the FP VML[AS] instructions are slow (if so, don't use them).
63 /// HasVMLxForwarding - If true, NEON has special multiplier accumulator
64 /// forwarding to allow mul + mla being issued back to back.
65 bool HasVMLxForwarding;
67 /// SlowFPBrcc - True if floating point compare + branch is slow.
70 /// InThumbMode - True if compiling for Thumb, false for ARM.
73 /// HasThumb2 - True if Thumb2 instructions are supported.
76 /// IsMClass - True if the subtarget belongs to the 'M' profile of CPUs -
77 /// v6m, v7m for example.
80 /// NoARM - True if subtarget does not support ARM mode execution.
83 /// PostRAScheduler - True if using post-register-allocation scheduler.
86 /// IsR9Reserved - True if R9 is a not available as general purpose register.
89 /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit
90 /// imms (including global addresses).
93 /// SupportsTailCall - True if the OS supports tail call. The dynamic linker
94 /// must be able to synthesize call stubs for interworking between ARM and
96 bool SupportsTailCall;
98 /// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF
102 /// HasD16 - True if subtarget is limited to 16 double precision
103 /// FP registers for VFPv3.
106 /// HasHardwareDivide - True if subtarget supports [su]div
107 bool HasHardwareDivide;
109 /// HasT2ExtractPack - True if subtarget supports thumb2 extract/pack
111 bool HasT2ExtractPack;
113 /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
117 /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
118 /// over 16-bit ones.
121 /// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
122 /// that partially update CPSR and add false dependency on the previous
123 /// CPSR setting instruction.
124 bool AvoidCPSRPartialUpdate;
126 /// HasMPExtension - True if the subtarget supports Multiprocessing
127 /// extension (ARMv7 only).
130 /// FPOnlySP - If true, the floating point unit only supports single
134 /// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
135 /// accesses for some types. For details, see
136 /// ARMTargetLowering::allowsUnalignedMemoryAccesses().
137 bool AllowsUnalignedMem;
139 /// Thumb2DSP - If true, the subtarget supports the v7 DSP (saturating arith
140 /// and such) instructions in Thumb2 code.
143 /// stackAlignment - The minimum alignment known to hold of the stack frame on
144 /// entry to the function and which must be maintained by every function.
145 unsigned stackAlignment;
147 /// CPUString - String name of used CPU.
148 std::string CPUString;
150 /// TargetTriple - What processor and OS we're targeting.
153 /// Selected instruction itineraries (one entry per itinerary class.)
154 InstrItineraryData InstrItins;
163 ARM_ABI_AAPCS // ARM EABI
166 /// This constructor initializes the data members to match that
167 /// of the specified triple.
169 ARMSubtarget(const std::string &TT, const std::string &CPU,
170 const std::string &FS);
172 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
173 /// that still makes it profitable to inline the call.
174 unsigned getMaxInlineSizeThreshold() const {
175 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb1.
176 // Change this once Thumb1 ldmia / stmia support is added.
177 return isThumb1Only() ? 0 : 64;
179 /// ParseSubtargetFeatures - Parses features string setting specified
180 /// subtarget options. Definition of function is auto generated by tblgen.
181 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
183 void computeIssueWidth();
185 bool hasV4TOps() const { return HasV4TOps; }
186 bool hasV5TOps() const { return HasV5TOps; }
187 bool hasV5TEOps() const { return HasV5TEOps; }
188 bool hasV6Ops() const { return HasV6Ops; }
189 bool hasV6T2Ops() const { return HasV6T2Ops; }
190 bool hasV7Ops() const { return HasV7Ops; }
192 bool isCortexA8() const { return ARMProcFamily == CortexA8; }
193 bool isCortexA9() const { return ARMProcFamily == CortexA9; }
194 bool isCortexM3() const { return CPUString == "cortex-m3"; }
196 bool hasARMOps() const { return !NoARM; }
198 bool hasVFP2() const { return HasVFPv2; }
199 bool hasVFP3() const { return HasVFPv3; }
200 bool hasNEON() const { return HasNEON; }
201 bool useNEONForSinglePrecisionFP() const {
202 return hasNEON() && UseNEONForSinglePrecisionFP; }
204 bool hasDivide() const { return HasHardwareDivide; }
205 bool hasT2ExtractPack() const { return HasT2ExtractPack; }
206 bool hasDataBarrier() const { return HasDataBarrier; }
207 bool useFPVMLx() const { return !SlowFPVMLx; }
208 bool hasVMLxForwarding() const { return HasVMLxForwarding; }
209 bool isFPBrccSlow() const { return SlowFPBrcc; }
210 bool isFPOnlySP() const { return FPOnlySP; }
211 bool prefers32BitThumb() const { return Pref32BitThumb; }
212 bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
213 bool hasMPExtension() const { return HasMPExtension; }
214 bool hasThumb2DSP() const { return Thumb2DSP; }
216 bool hasFP16() const { return HasFP16; }
217 bool hasD16() const { return HasD16; }
219 const Triple &getTargetTriple() const { return TargetTriple; }
221 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
222 bool isTargetNaCl() const {
223 return TargetTriple.getOS() == Triple::NativeClient;
225 bool isTargetELF() const { return !isTargetDarwin(); }
227 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
228 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
230 bool isThumb() const { return InThumbMode; }
231 bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
232 bool isThumb2() const { return InThumbMode && HasThumb2; }
233 bool hasThumb2() const { return HasThumb2; }
234 bool isMClass() const { return IsMClass; }
235 bool isARClass() const { return !IsMClass; }
237 bool isR9Reserved() const { return IsR9Reserved; }
239 bool useMovt() const { return UseMovt && hasV6T2Ops(); }
240 bool supportsTailCall() const { return SupportsTailCall; }
242 bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
244 const std::string & getCPUString() const { return CPUString; }
246 unsigned getMispredictionPenalty() const;
248 /// enablePostRAScheduler - True at 'More' optimization.
249 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
250 TargetSubtargetInfo::AntiDepBreakMode& Mode,
251 RegClassVector& CriticalPathRCs) const;
253 /// getInstrItins - Return the instruction itineraies based on subtarget
255 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
257 /// getStackAlignment - Returns the minimum alignment known to hold of the
258 /// stack frame on entry to the function and which must be maintained by every
259 /// function for this subtarget.
260 unsigned getStackAlignment() const { return stackAlignment; }
262 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
264 bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
266 } // End llvm namespace
268 #endif // ARMSUBTARGET_H