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/TargetMachine.h"
19 #include "llvm/Target/TargetSubtarget.h"
20 #include "llvm/ADT/Triple.h"
26 class ARMSubtarget : public TargetSubtarget {
29 V4, V4T, V5T, V5TE, V6, V6M, V6T2, V7A, V7M
32 enum ARMProcFamilyEnum {
33 Others, CortexA8, CortexA9
37 None, VFPv2, VFPv3, NEON
45 /// ARMArchVersion - ARM architecture version: V4, V4T (base), V5T, V5TE,
46 /// V6, V6T2, V7A, V7M.
47 ARMArchEnum ARMArchVersion;
49 /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
50 ARMProcFamilyEnum ARMProcFamily;
52 /// ARMFPUType - Floating Point Unit type.
55 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
56 /// specified. Use the method useNEONForSinglePrecisionFP() to
57 /// determine if NEON should actually be used.
58 bool UseNEONForSinglePrecisionFP;
60 /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
61 /// whether the FP VML[AS] instructions are slow (if so, don't use them).
64 /// HasVMLxForwarding - If true, NEON has special multiplier accumulator
65 /// forwarding to allow mul + mla being issued back to back.
66 bool HasVMLxForwarding;
68 /// SlowFPBrcc - True if floating point compare + branch is slow.
71 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
74 /// ThumbMode - Indicates supported Thumb version.
75 ThumbTypeEnum ThumbMode;
77 /// NoARM - True if subtarget does not support ARM mode execution.
80 /// PostRAScheduler - True if using post-register-allocation scheduler.
83 /// IsR9Reserved - True if R9 is a not available as general purpose register.
86 /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit
87 /// imms (including global addresses).
90 /// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF
94 /// HasD16 - True if subtarget is limited to 16 double precision
95 /// FP registers for VFPv3.
98 /// HasHardwareDivide - True if subtarget supports [su]div
99 bool HasHardwareDivide;
101 /// HasT2ExtractPack - True if subtarget supports thumb2 extract/pack
103 bool HasT2ExtractPack;
105 /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
109 /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
110 /// over 16-bit ones.
113 /// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
114 /// that partially update CPSR and add false dependency on the previous
115 /// CPSR setting instruction.
116 bool AvoidCPSRPartialUpdate;
118 /// HasMPExtension - True if the subtarget supports Multiprocessing
119 /// extension (ARMv7 only).
122 /// FPOnlySP - If true, the floating point unit only supports single
126 /// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
127 /// accesses for some types. For details, see
128 /// ARMTargetLowering::allowsUnalignedMemoryAccesses().
129 bool AllowsUnalignedMem;
131 /// stackAlignment - The minimum alignment known to hold of the stack frame on
132 /// entry to the function and which must be maintained by every function.
133 unsigned stackAlignment;
135 /// CPUString - String name of used CPU.
136 std::string CPUString;
138 /// TargetTriple - What processor and OS we're targeting.
141 /// Selected instruction itineraries (one entry per itinerary class.)
142 InstrItineraryData InstrItins;
151 ARM_ABI_AAPCS // ARM EABI
154 /// This constructor initializes the data members to match that
155 /// of the specified triple.
157 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
159 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
160 /// that still makes it profitable to inline the call.
161 unsigned getMaxInlineSizeThreshold() const {
162 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb1.
163 // Change this once Thumb1 ldmia / stmia support is added.
164 return isThumb1Only() ? 0 : 64;
166 /// ParseSubtargetFeatures - Parses features string setting specified
167 /// subtarget options. Definition of function is auto generated by tblgen.
168 std::string ParseSubtargetFeatures(const std::string &FS,
169 const std::string &CPU);
171 void computeIssueWidth();
173 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
174 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
175 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
176 bool hasV6Ops() const { return ARMArchVersion >= V6; }
177 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
178 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
180 bool isCortexA8() const { return ARMProcFamily == CortexA8; }
181 bool isCortexA9() const { return ARMProcFamily == CortexA9; }
183 bool hasARMOps() const { return !NoARM; }
185 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
186 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
187 bool hasNEON() const { return ARMFPUType >= NEON; }
188 bool useNEONForSinglePrecisionFP() const {
189 return hasNEON() && UseNEONForSinglePrecisionFP; }
190 bool hasDivide() const { return HasHardwareDivide; }
191 bool hasT2ExtractPack() const { return HasT2ExtractPack; }
192 bool hasDataBarrier() const { return HasDataBarrier; }
193 bool useFPVMLx() const { return !SlowFPVMLx; }
194 bool hasVMLxForwarding() const { return HasVMLxForwarding; }
195 bool isFPBrccSlow() const { return SlowFPBrcc; }
196 bool isFPOnlySP() const { return FPOnlySP; }
197 bool prefers32BitThumb() const { return Pref32BitThumb; }
198 bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
199 bool hasMPExtension() const { return HasMPExtension; }
201 bool hasFP16() const { return HasFP16; }
202 bool hasD16() const { return HasD16; }
204 const Triple &getTargetTriple() const { return TargetTriple; }
206 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
207 bool isTargetELF() const { return !isTargetDarwin(); }
209 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
210 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
212 bool isThumb() const { return IsThumb; }
213 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
214 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
215 bool hasThumb2() const { return ThumbMode >= Thumb2; }
217 bool isR9Reserved() const { return IsR9Reserved; }
219 bool useMovt() const { return UseMovt && hasV6T2Ops(); }
221 bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
223 const std::string & getCPUString() const { return CPUString; }
225 unsigned getMispredictionPenalty() const;
227 /// enablePostRAScheduler - True at 'More' optimization.
228 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
229 TargetSubtarget::AntiDepBreakMode& Mode,
230 RegClassVector& CriticalPathRCs) const;
232 /// getInstrItins - Return the instruction itineraies based on subtarget
234 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
236 /// getStackAlignment - Returns the minimum alignment known to hold of the
237 /// stack frame on entry to the function and which must be maintained by every
238 /// function for this subtarget.
239 unsigned getStackAlignment() const { return stackAlignment; }
241 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
243 bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
245 } // End llvm namespace
247 #endif // ARMSUBTARGET_H