blob: d5ee009487ee3856166d351497d404aa7f7398dc [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- ARMSubtarget.h - Define Subtarget for the ARM ----------*- C++ -*--===//
Evan Chenga8e29892007-01-19 07:51:42 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file declares the ARM specific subclass of TargetSubtargetInfo.
Evan Chenga8e29892007-01-19 07:51:42 +000011//
12//===----------------------------------------------------------------------===//
13
Stephen Hines37ed9c12014-12-01 14:51:49 -080014#ifndef LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H
15#define LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H
Evan Chenga8e29892007-01-19 07:51:42 +000016
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070017
18#include "ARMFrameLowering.h"
19#include "ARMISelLowering.h"
20#include "ARMInstrInfo.h"
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070021#include "ARMSelectionDAGInfo.h"
22#include "ARMSubtarget.h"
23#include "Thumb1FrameLowering.h"
24#include "Thumb1InstrInfo.h"
25#include "Thumb2InstrInfo.h"
Evan Cheng94ca42f2011-07-07 00:08:19 +000026#include "MCTargetDesc/ARMMCTargetDesc.h"
Evan Chengb72d2a92011-01-11 21:46:47 +000027#include "llvm/ADT/Triple.h"
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070028#include "llvm/IR/DataLayout.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000029#include "llvm/MC/MCInstrItineraries.h"
30#include "llvm/Target/TargetSubtargetInfo.h"
Evan Chenga8e29892007-01-19 07:51:42 +000031#include <string>
32
Evan Cheng94214702011-07-01 20:45:01 +000033#define GET_SUBTARGETINFO_HEADER
Evan Cheng385e9302011-07-01 22:36:09 +000034#include "ARMGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000035
Evan Chenga8e29892007-01-19 07:51:42 +000036namespace llvm {
Evan Chenge4e4ed32009-08-28 23:18:09 +000037class GlobalValue;
Evan Cheng0ddff1b2011-07-07 07:07:08 +000038class StringRef;
Renato Golin3382a842013-03-21 18:47:47 +000039class TargetOptions;
Evan Chenga8e29892007-01-19 07:51:42 +000040
Evan Cheng94214702011-07-01 20:45:01 +000041class ARMSubtarget : public ARMGenSubtargetInfo {
Evan Chenga8e29892007-01-19 07:51:42 +000042protected:
Evan Cheng3ef1c872010-09-10 01:29:16 +000043 enum ARMProcFamilyEnum {
Stephen Hinesdce4a402014-05-29 02:49:00 -070044 Others, CortexA5, CortexA7, CortexA8, CortexA9, CortexA12, CortexA15,
Stephen Hines37ed9c12014-12-01 14:51:49 -080045 CortexA17, CortexR5, Swift, CortexA53, CortexA57, Krait,
Evan Cheng3ef1c872010-09-10 01:29:16 +000046 };
Amara Emerson0f22c132013-09-23 14:26:15 +000047 enum ARMProcClassEnum {
48 None, AClass, RClass, MClass
49 };
Evan Cheng3ef1c872010-09-10 01:29:16 +000050
Evan Cheng3ef1c872010-09-10 01:29:16 +000051 /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
52 ARMProcFamilyEnum ARMProcFamily;
53
Amara Emerson0f22c132013-09-23 14:26:15 +000054 /// ARMProcClass - ARM processor class: None, AClass, RClass or MClass.
55 ARMProcClassEnum ARMProcClass;
56
Joey Gouly849eedc2013-06-26 16:58:26 +000057 /// HasV4TOps, HasV5TOps, HasV5TEOps,
Tim Northovercf3e4cb2013-10-07 11:10:47 +000058 /// HasV6Ops, HasV6MOps, HasV6T2Ops, HasV7Ops, HasV8Ops -
Evan Cheng39dfb0f2011-07-07 03:55:05 +000059 /// Specify whether target support specific ARM ISA variants.
60 bool HasV4TOps;
61 bool HasV5TOps;
62 bool HasV5TEOps;
63 bool HasV6Ops;
Tim Northovercf3e4cb2013-10-07 11:10:47 +000064 bool HasV6MOps;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000065 bool HasV6T2Ops;
66 bool HasV7Ops;
Joey Gouly849eedc2013-06-26 16:58:26 +000067 bool HasV8Ops;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000068
Joey Gouly2a9af9f2013-09-13 13:46:57 +000069 /// HasVFPv2, HasVFPv3, HasVFPv4, HasFPARMv8, HasNEON - Specify what
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +000070 /// floating point ISAs are supported.
Evan Cheng39dfb0f2011-07-07 03:55:05 +000071 bool HasVFPv2;
72 bool HasVFPv3;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +000073 bool HasVFPv4;
Joey Gouly2a9af9f2013-09-13 13:46:57 +000074 bool HasFPARMv8;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000075 bool HasNEON;
Evan Chenga8e29892007-01-19 07:51:42 +000076
David Goodwin1f0e4042009-08-05 16:01:19 +000077 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
78 /// specified. Use the method useNEONForSinglePrecisionFP() to
79 /// determine if NEON should actually be used.
David Goodwin42a83f22009-08-04 17:53:06 +000080 bool UseNEONForSinglePrecisionFP;
81
Bob Wilsoneb1641d2012-09-29 21:43:49 +000082 /// UseMulOps - True if non-microcoded fused integer multiply-add and
83 /// multiply-subtract instructions should be used.
84 bool UseMulOps;
85
Evan Cheng48575f62010-12-05 22:04:16 +000086 /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
87 /// whether the FP VML[AS] instructions are slow (if so, don't use them).
88 bool SlowFPVMLx;
Jim Grosbach26767372010-03-24 22:31:46 +000089
Evan Cheng463d3582011-03-31 19:38:48 +000090 /// HasVMLxForwarding - If true, NEON has special multiplier accumulator
91 /// forwarding to allow mul + mla being issued back to back.
92 bool HasVMLxForwarding;
93
Evan Cheng7a415992010-07-13 19:21:50 +000094 /// SlowFPBrcc - True if floating point compare + branch is slow.
95 bool SlowFPBrcc;
96
Evan Cheng4761a8d2011-07-07 19:09:06 +000097 /// InThumbMode - True if compiling for Thumb, false for ARM.
Evan Cheng963b03c2011-07-07 19:05:12 +000098 bool InThumbMode;
Anton Korobeynikov70459be2009-06-01 20:00:48 +000099
Evan Cheng94ca42f2011-07-07 00:08:19 +0000100 /// HasThumb2 - True if Thumb2 instructions are supported.
101 bool HasThumb2;
Evan Chenga8e29892007-01-19 07:51:42 +0000102
Evan Cheng7b4d3112010-08-11 07:17:46 +0000103 /// NoARM - True if subtarget does not support ARM mode execution.
104 bool NoARM;
105
Evan Chenga8e29892007-01-19 07:51:42 +0000106 /// IsR9Reserved - True if R9 is a not available as general purpose register.
107 bool IsR9Reserved;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000108
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000109 /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit
110 /// imms (including global addresses).
111 bool UseMovt;
112
Bob Wilson6d2f9ce2011-10-07 17:17:49 +0000113 /// SupportsTailCall - True if the OS supports tail call. The dynamic linker
114 /// must be able to synthesize call stubs for interworking between ARM and
115 /// Thumb.
116 bool SupportsTailCall;
117
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000118 /// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF
119 /// only so far)
120 bool HasFP16;
121
Bob Wilson77f42b52010-10-12 16:22:47 +0000122 /// HasD16 - True if subtarget is limited to 16 double precision
123 /// FP registers for VFPv3.
124 bool HasD16;
125
Jim Grosbach29402132010-05-05 23:44:43 +0000126 /// HasHardwareDivide - True if subtarget supports [su]div
127 bool HasHardwareDivide;
128
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000129 /// HasHardwareDivideInARM - True if subtarget supports [su]div in ARM mode
130 bool HasHardwareDivideInARM;
131
Jim Grosbach29402132010-05-05 23:44:43 +0000132 /// HasT2ExtractPack - True if subtarget supports thumb2 extract/pack
133 /// instructions.
134 bool HasT2ExtractPack;
135
Evan Cheng11db0682010-08-11 06:22:01 +0000136 /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
137 /// instructions.
138 bool HasDataBarrier;
139
Evan Chenge44be632010-08-09 18:35:19 +0000140 /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
141 /// over 16-bit ones.
142 bool Pref32BitThumb;
143
Bob Wilson5dde8932011-04-19 18:11:49 +0000144 /// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
145 /// that partially update CPSR and add false dependency on the previous
146 /// CPSR setting instruction.
147 bool AvoidCPSRPartialUpdate;
148
Evan Cheng139e4072012-12-20 19:59:30 +0000149 /// AvoidMOVsShifterOperand - If true, codegen should avoid using flag setting
150 /// movs with shifter operand (i.e. asr, lsl, lsr).
151 bool AvoidMOVsShifterOperand;
152
Evan Cheng4bfcd4a2012-02-28 18:51:51 +0000153 /// HasRAS - Some processors perform return stack prediction. CodeGen should
154 /// avoid issue "normal" call instructions to callees which do not return.
155 bool HasRAS;
156
Evan Chengdfed19f2010-11-03 06:34:55 +0000157 /// HasMPExtension - True if the subtarget supports Multiprocessing
158 /// extension (ARMv7 only).
159 bool HasMPExtension;
160
Bradley Smith6186de52013-11-01 13:27:35 +0000161 /// HasVirtualization - True if the subtarget supports the Virtualization
162 /// extension.
163 bool HasVirtualization;
164
Jim Grosbachfcba5e62010-08-11 15:44:15 +0000165 /// FPOnlySP - If true, the floating point unit only supports single
166 /// precision.
167 bool FPOnlySP;
168
Tim Northoverb94a3532013-05-23 19:11:14 +0000169 /// If true, the processor supports the Performance Monitor Extensions. These
170 /// include a generic cycle-counter as well as more fine-grained (often
171 /// implementation-specific) events.
172 bool HasPerfMon;
173
Tim Northover8c9e52a2013-04-10 12:08:35 +0000174 /// HasTrustZone - if true, processor supports TrustZone security extensions
175 bool HasTrustZone;
176
Amara Emerson5df37da2013-09-19 11:59:01 +0000177 /// HasCrypto - if true, processor supports Cryptography extensions
178 bool HasCrypto;
179
Bernard Ogden47c6d172013-10-29 09:47:35 +0000180 /// HasCRC - if true, processor supports CRC instructions
181 bool HasCRC;
182
Stephen Hines36b56882014-04-23 16:57:46 -0700183 /// If true, the instructions "vmov.i32 d0, #0" and "vmov.i32 q0, #0" are
184 /// particularly effective at zeroing a VFP register.
185 bool HasZeroCycleZeroing;
186
Bob Wilson02aba732010-09-28 04:09:35 +0000187 /// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
188 /// accesses for some types. For details, see
Stephen Hines37ed9c12014-12-01 14:51:49 -0800189 /// ARMTargetLowering::allowsMisalignedMemoryAccesses().
Bob Wilson02aba732010-09-28 04:09:35 +0000190 bool AllowsUnalignedMem;
191
Weiming Zhao929bdb22013-11-13 18:29:49 +0000192 /// RestrictIT - If true, the subtarget disallows generation of deprecated IT
193 /// blocks to conform to ARMv8 rule.
194 bool RestrictIT;
195
Jim Grosbacha7603982011-07-01 21:12:19 +0000196 /// Thumb2DSP - If true, the subtarget supports the v7 DSP (saturating arith
197 /// and such) instructions in Thumb2 code.
198 bool Thumb2DSP;
199
Eli Bendersky0f156af2013-01-30 16:30:19 +0000200 /// NaCl TRAP instruction is generated instead of the regular TRAP.
201 bool UseNaClTrap;
202
Stephen Hines373aa5c2014-02-06 23:41:26 -0800203 /// Force long to be a 64-bit type (RenderScript-specific)
204 bool UseLong64;
205
Stephen Hines36b56882014-04-23 16:57:46 -0700206 /// Target machine allowed unsafe FP math (such as use of NEON fp)
207 bool UnsafeFPMath;
208
Evan Chenga8e29892007-01-19 07:51:42 +0000209 /// stackAlignment - The minimum alignment known to hold of the stack frame on
210 /// entry to the function and which must be maintained by every function.
211 unsigned stackAlignment;
212
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000213 /// CPUString - String name of used CPU.
214 std::string CPUString;
215
Stephen Hines36b56882014-04-23 16:57:46 -0700216 /// IsLittle - The target is Little Endian
217 bool IsLittle;
218
Evan Chengb72d2a92011-01-11 21:46:47 +0000219 /// TargetTriple - What processor and OS we're targeting.
220 Triple TargetTriple;
221
Andrew Trickd43b5c92012-08-08 02:44:16 +0000222 /// SchedModel - Processor specific instruction costs.
Stephen Hines37ed9c12014-12-01 14:51:49 -0800223 MCSchedModel SchedModel;
Andrew Trickd43b5c92012-08-08 02:44:16 +0000224
Evan Cheng8557c2b2009-06-19 01:51:50 +0000225 /// Selected instruction itineraries (one entry per itinerary class.)
226 InstrItineraryData InstrItins;
Jim Grosbach764ab522009-08-11 15:33:49 +0000227
Renato Golin3382a842013-03-21 18:47:47 +0000228 /// Options passed via command line that could influence the target
229 const TargetOptions &Options;
230
Evan Chenga8e29892007-01-19 07:51:42 +0000231 public:
Evan Cheng1a3771e2007-01-19 19:22:40 +0000232 enum {
Stephen Hines36b56882014-04-23 16:57:46 -0700233 ARM_ABI_UNKNOWN,
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000234 ARM_ABI_APCS,
235 ARM_ABI_AAPCS // ARM EABI
236 } TargetABI;
237
Evan Chenga8e29892007-01-19 07:51:42 +0000238 /// This constructor initializes the data members to match that
Daniel Dunbar3be03402009-08-02 22:11:08 +0000239 /// of the specified triple.
Evan Chenga8e29892007-01-19 07:51:42 +0000240 ///
Evan Cheng276365d2011-06-30 01:53:36 +0000241 ARMSubtarget(const std::string &TT, const std::string &CPU,
Stephen Hines37ed9c12014-12-01 14:51:49 -0800242 const std::string &FS, const TargetMachine &TM, bool IsLittle);
Evan Chenga8e29892007-01-19 07:51:42 +0000243
Dan Gohman707e0182008-04-12 04:36:06 +0000244 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
245 /// that still makes it profitable to inline the call.
Rafael Espindolae0703c82007-10-31 14:39:58 +0000246 unsigned getMaxInlineSizeThreshold() const {
Stephen Hinesdce4a402014-05-29 02:49:00 -0700247 return 64;
Rafael Espindolae0703c82007-10-31 14:39:58 +0000248 }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +0000249 /// ParseSubtargetFeatures - Parses features string setting specified
Evan Chenga8e29892007-01-19 07:51:42 +0000250 /// subtarget options. Definition of function is auto generated by tblgen.
Evan Cheng0ddff1b2011-07-07 07:07:08 +0000251 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Evan Chenga8e29892007-01-19 07:51:42 +0000252
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700253 /// initializeSubtargetDependencies - Initializes using a CPU and feature string
254 /// so that we can use initializer lists for subtarget initialization.
255 ARMSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
256
Stephen Hines37ed9c12014-12-01 14:51:49 -0800257 const DataLayout *getDataLayout() const override { return &DL; }
258 const ARMSelectionDAGInfo *getSelectionDAGInfo() const override {
259 return &TSInfo;
260 }
261 const ARMBaseInstrInfo *getInstrInfo() const override {
262 return InstrInfo.get();
263 }
264 const ARMTargetLowering *getTargetLowering() const override {
265 return &TLInfo;
266 }
267 const ARMFrameLowering *getFrameLowering() const override {
268 return FrameLowering.get();
269 }
270 const ARMBaseRegisterInfo *getRegisterInfo() const override {
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700271 return &InstrInfo->getRegisterInfo();
272 }
273
Bill Wendling901d8002013-02-16 01:36:26 +0000274private:
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700275 const DataLayout DL;
276 ARMSelectionDAGInfo TSInfo;
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700277 // Either Thumb1InstrInfo or Thumb2InstrInfo.
278 std::unique_ptr<ARMBaseInstrInfo> InstrInfo;
279 ARMTargetLowering TLInfo;
280 // Either Thumb1FrameLowering or ARMFrameLowering.
281 std::unique_ptr<ARMFrameLowering> FrameLowering;
282
Bill Wendling901d8002013-02-16 01:36:26 +0000283 void initializeEnvironment();
Stephen Hines37ed9c12014-12-01 14:51:49 -0800284 void initSubtargetFeatures(StringRef CPU, StringRef FS);
Bill Wendling901d8002013-02-16 01:36:26 +0000285public:
Andrew Trick2da8bc82010-12-24 05:03:26 +0000286 void computeIssueWidth();
287
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000288 bool hasV4TOps() const { return HasV4TOps; }
289 bool hasV5TOps() const { return HasV5TOps; }
290 bool hasV5TEOps() const { return HasV5TEOps; }
291 bool hasV6Ops() const { return HasV6Ops; }
Amara Emersonca7b2d02013-10-07 16:55:23 +0000292 bool hasV6MOps() const { return HasV6MOps; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000293 bool hasV6T2Ops() const { return HasV6T2Ops; }
294 bool hasV7Ops() const { return HasV7Ops; }
Joey Gouly849eedc2013-06-26 16:58:26 +0000295 bool hasV8Ops() const { return HasV8Ops; }
Evan Chenga8e29892007-01-19 07:51:42 +0000296
Quentin Colombet8facb9e2012-11-29 19:48:01 +0000297 bool isCortexA5() const { return ARMProcFamily == CortexA5; }
Stephen Hines36b56882014-04-23 16:57:46 -0700298 bool isCortexA7() const { return ARMProcFamily == CortexA7; }
Evan Cheng3ef1c872010-09-10 01:29:16 +0000299 bool isCortexA8() const { return ARMProcFamily == CortexA8; }
300 bool isCortexA9() const { return ARMProcFamily == CortexA9; }
Silviu Baranga616471d2012-09-13 15:05:10 +0000301 bool isCortexA15() const { return ARMProcFamily == CortexA15; }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000302 bool isSwift() const { return ARMProcFamily == Swift; }
Evan Cheng44ee4712011-11-09 01:57:03 +0000303 bool isCortexM3() const { return CPUString == "cortex-m3"; }
Stephen Hines36b56882014-04-23 16:57:46 -0700304 bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); }
Quentin Colombete0f1d712012-12-21 04:35:05 +0000305 bool isCortexR5() const { return ARMProcFamily == CortexR5; }
Stephen Hines36b56882014-04-23 16:57:46 -0700306 bool isKrait() const { return ARMProcFamily == Krait; }
Evan Cheng3ef1c872010-09-10 01:29:16 +0000307
Evan Cheng7b4d3112010-08-11 07:17:46 +0000308 bool hasARMOps() const { return !NoARM; }
309
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000310 bool hasVFP2() const { return HasVFPv2; }
311 bool hasVFP3() const { return HasVFPv3; }
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000312 bool hasVFP4() const { return HasVFPv4; }
Joey Gouly2a9af9f2013-09-13 13:46:57 +0000313 bool hasFPARMv8() const { return HasFPARMv8; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000314 bool hasNEON() const { return HasNEON; }
Amara Emerson5df37da2013-09-19 11:59:01 +0000315 bool hasCrypto() const { return HasCrypto; }
Bernard Ogden47c6d172013-10-29 09:47:35 +0000316 bool hasCRC() const { return HasCRC; }
Bradley Smith6186de52013-11-01 13:27:35 +0000317 bool hasVirtualization() const { return HasVirtualization; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000318 bool useNEONForSinglePrecisionFP() const {
David Goodwin42a83f22009-08-04 17:53:06 +0000319 return hasNEON() && UseNEONForSinglePrecisionFP; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000320
Shantonu Seneae216c2010-05-06 14:57:47 +0000321 bool hasDivide() const { return HasHardwareDivide; }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000322 bool hasDivideInARMMode() const { return HasHardwareDivideInARM; }
Shantonu Seneae216c2010-05-06 14:57:47 +0000323 bool hasT2ExtractPack() const { return HasT2ExtractPack; }
Evan Cheng11db0682010-08-11 06:22:01 +0000324 bool hasDataBarrier() const { return HasDataBarrier; }
Tim Northover214c37d2013-10-25 09:30:24 +0000325 bool hasAnyDataBarrier() const {
326 return HasDataBarrier || (hasV6Ops() && !isThumb());
327 }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000328 bool useMulOps() const { return UseMulOps; }
Evan Cheng48575f62010-12-05 22:04:16 +0000329 bool useFPVMLx() const { return !SlowFPVMLx; }
Evan Cheng463d3582011-03-31 19:38:48 +0000330 bool hasVMLxForwarding() const { return HasVMLxForwarding; }
Evan Cheng7a415992010-07-13 19:21:50 +0000331 bool isFPBrccSlow() const { return SlowFPBrcc; }
Jim Grosbachfcba5e62010-08-11 15:44:15 +0000332 bool isFPOnlySP() const { return FPOnlySP; }
Tim Northoverb94a3532013-05-23 19:11:14 +0000333 bool hasPerfMon() const { return HasPerfMon; }
Tim Northover8c9e52a2013-04-10 12:08:35 +0000334 bool hasTrustZone() const { return HasTrustZone; }
Stephen Hines36b56882014-04-23 16:57:46 -0700335 bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
Evan Chenge44be632010-08-09 18:35:19 +0000336 bool prefers32BitThumb() const { return Pref32BitThumb; }
Bob Wilson5dde8932011-04-19 18:11:49 +0000337 bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
Evan Cheng139e4072012-12-20 19:59:30 +0000338 bool avoidMOVsShifterOperand() const { return AvoidMOVsShifterOperand; }
Evan Cheng4bfcd4a2012-02-28 18:51:51 +0000339 bool hasRAS() const { return HasRAS; }
Evan Chengdfed19f2010-11-03 06:34:55 +0000340 bool hasMPExtension() const { return HasMPExtension; }
Jim Grosbacha7603982011-07-01 21:12:19 +0000341 bool hasThumb2DSP() const { return Thumb2DSP; }
Eli Bendersky0f156af2013-01-30 16:30:19 +0000342 bool useNaClTrap() const { return UseNaClTrap; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000343
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000344 bool hasFP16() const { return HasFP16; }
Bob Wilson77f42b52010-10-12 16:22:47 +0000345 bool hasD16() const { return HasD16; }
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000346
Evan Chengc8578942011-04-20 22:20:12 +0000347 const Triple &getTargetTriple() const { return TargetTriple; }
348
Daniel Dunbar912225e2011-04-19 21:14:45 +0000349 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
Stephen Hines36b56882014-04-23 16:57:46 -0700350 bool isTargetIOS() const { return TargetTriple.isiOS(); }
Cameron Esfahani441c5572013-08-29 20:23:14 +0000351 bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
Stephen Hines36b56882014-04-23 16:57:46 -0700352 bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
353 bool isTargetNetBSD() const { return TargetTriple.getOS() == Triple::NetBSD; }
354 bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
355
356 bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
357 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
358 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
359
Renato Golin103ba842013-07-16 09:32:17 +0000360 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
361 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
362 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
363 // even for GNUEABI, so we can make a distinction here and still conform to
364 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
Stephen Hines36b56882014-04-23 16:57:46 -0700365 // FIXME: The Darwin exception is temporary, while we move users to
366 // "*-*-*-macho" triples as quickly as possible.
Renato Golin103ba842013-07-16 09:32:17 +0000367 bool isTargetAEABI() const {
Stephen Hines36b56882014-04-23 16:57:46 -0700368 return (TargetTriple.getEnvironment() == Triple::EABI ||
369 TargetTriple.getEnvironment() == Triple::EABIHF) &&
370 !isTargetDarwin() && !isTargetWindows();
Renato Golin103ba842013-07-16 09:32:17 +0000371 }
Evan Cheng1a3771e2007-01-19 19:22:40 +0000372
Stephen Hines36b56882014-04-23 16:57:46 -0700373 // ARM Targets that support EHABI exception handling standard
374 // Darwin uses SjLj. Other targets might need more checks.
375 bool isTargetEHABICompatible() const {
376 return (TargetTriple.getEnvironment() == Triple::EABI ||
377 TargetTriple.getEnvironment() == Triple::GNUEABI ||
378 TargetTriple.getEnvironment() == Triple::EABIHF ||
379 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
380 TargetTriple.getEnvironment() == Triple::Android) &&
381 !isTargetDarwin() && !isTargetWindows();
382 }
383
384 bool isTargetHardFloat() const {
385 // FIXME: this is invalid for WindowsCE
386 return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
387 TargetTriple.getEnvironment() == Triple::EABIHF ||
388 isTargetWindows();
389 }
390 bool isTargetAndroid() const {
391 return TargetTriple.getEnvironment() == Triple::Android;
392 }
393
394 bool isAPCS_ABI() const {
395 assert(TargetABI != ARM_ABI_UNKNOWN);
396 return TargetABI == ARM_ABI_APCS;
397 }
398 bool isAAPCS_ABI() const {
399 assert(TargetABI != ARM_ABI_UNKNOWN);
400 return TargetABI == ARM_ABI_AAPCS;
401 }
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000402
Evan Cheng963b03c2011-07-07 19:05:12 +0000403 bool isThumb() const { return InThumbMode; }
404 bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
405 bool isThumb2() const { return InThumbMode && HasThumb2; }
Evan Cheng94ca42f2011-07-07 00:08:19 +0000406 bool hasThumb2() const { return HasThumb2; }
Amara Emerson0f22c132013-09-23 14:26:15 +0000407 bool isMClass() const { return ARMProcClass == MClass; }
408 bool isRClass() const { return ARMProcClass == RClass; }
409 bool isAClass() const { return ARMProcClass == AClass; }
Evan Chenga8e29892007-01-19 07:51:42 +0000410
Stephen Hines37ed9c12014-12-01 14:51:49 -0800411 bool isV6M() const {
412 return isThumb1Only() && isMClass();
413 }
414
Evan Chenga8e29892007-01-19 07:51:42 +0000415 bool isR9Reserved() const { return IsR9Reserved; }
416
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700417 bool useMovt(const MachineFunction &MF) const;
418
Bob Wilson6d2f9ce2011-10-07 17:17:49 +0000419 bool supportsTailCall() const { return SupportsTailCall; }
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000420
Bob Wilson02aba732010-09-28 04:09:35 +0000421 bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
422
Weiming Zhao929bdb22013-11-13 18:29:49 +0000423 bool restrictIT() const { return RestrictIT; }
424
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000425 const std::string & getCPUString() const { return CPUString; }
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000426
Stephen Hines36b56882014-04-23 16:57:46 -0700427 bool isLittle() const { return IsLittle; }
428
Owen Anderson654d5442010-09-28 21:57:50 +0000429 unsigned getMispredictionPenalty() const;
Stephen Hinesdce4a402014-05-29 02:49:00 -0700430
Bob Wilsoncb01efb2013-11-03 06:14:38 +0000431 /// This function returns true if the target has sincos() routine in its
432 /// compiler runtime or math libraries.
433 bool hasSinCos() const;
Andrew Trick6e8f4c42010-12-24 04:28:06 +0000434
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700435 /// True for some subtargets at > -O0.
Stephen Hines37ed9c12014-12-01 14:51:49 -0800436 bool enablePostMachineScheduler() const override;
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700437
Stephen Hines37ed9c12014-12-01 14:51:49 -0800438 // enableAtomicExpand- True if we need to expand our atomics.
439 bool enableAtomicExpand() const override;
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000440
Stephen Hines37ed9c12014-12-01 14:51:49 -0800441 /// getInstrItins - Return the instruction itineraries based on subtarget
Evan Cheng8557c2b2009-06-19 01:51:50 +0000442 /// selection.
Stephen Hines37ed9c12014-12-01 14:51:49 -0800443 const InstrItineraryData *getInstrItineraryData() const override {
444 return &InstrItins;
445 }
Evan Cheng8557c2b2009-06-19 01:51:50 +0000446
Evan Chenga8e29892007-01-19 07:51:42 +0000447 /// getStackAlignment - Returns the minimum alignment known to hold of the
448 /// stack frame on entry to the function and which must be maintained by every
449 /// function for this subtarget.
450 unsigned getStackAlignment() const { return stackAlignment; }
Evan Chenge4e4ed32009-08-28 23:18:09 +0000451
452 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
453 /// symbol.
Dan Gohman46510a72010-04-15 01:51:59 +0000454 bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
Stephen Hines37ed9c12014-12-01 14:51:49 -0800455
Evan Chenga8e29892007-01-19 07:51:42 +0000456};
457} // End llvm namespace
458
459#endif // ARMSUBTARGET_H