blob: 38536b2e43e9515ea89a03c916be06b96fb8a42e [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
14#ifndef ARMSUBTARGET_H
15#define ARMSUBTARGET_H
16
Evan Cheng94ca42f2011-07-07 00:08:19 +000017#include "MCTargetDesc/ARMMCTargetDesc.h"
Evan Chengb72d2a92011-01-11 21:46:47 +000018#include "llvm/ADT/Triple.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000019#include "llvm/MC/MCInstrItineraries.h"
20#include "llvm/Target/TargetSubtargetInfo.h"
Evan Chenga8e29892007-01-19 07:51:42 +000021#include <string>
22
Evan Cheng94214702011-07-01 20:45:01 +000023#define GET_SUBTARGETINFO_HEADER
Evan Cheng385e9302011-07-01 22:36:09 +000024#include "ARMGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000025
Evan Chenga8e29892007-01-19 07:51:42 +000026namespace llvm {
Evan Chenge4e4ed32009-08-28 23:18:09 +000027class GlobalValue;
Evan Cheng0ddff1b2011-07-07 07:07:08 +000028class StringRef;
Renato Golin3382a842013-03-21 18:47:47 +000029class TargetOptions;
Evan Chenga8e29892007-01-19 07:51:42 +000030
Evan Cheng94214702011-07-01 20:45:01 +000031class ARMSubtarget : public ARMGenSubtargetInfo {
Evan Chenga8e29892007-01-19 07:51:42 +000032protected:
Evan Cheng3ef1c872010-09-10 01:29:16 +000033 enum ARMProcFamilyEnum {
Stephen Hinesdce4a402014-05-29 02:49:00 -070034 Others, CortexA5, CortexA7, CortexA8, CortexA9, CortexA12, CortexA15,
Stephen Hines36b56882014-04-23 16:57:46 -070035 CortexR5, Swift, CortexA53, CortexA57, Krait
Evan Cheng3ef1c872010-09-10 01:29:16 +000036 };
Amara Emerson0f22c132013-09-23 14:26:15 +000037 enum ARMProcClassEnum {
38 None, AClass, RClass, MClass
39 };
Evan Cheng3ef1c872010-09-10 01:29:16 +000040
Evan Cheng3ef1c872010-09-10 01:29:16 +000041 /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
42 ARMProcFamilyEnum ARMProcFamily;
43
Amara Emerson0f22c132013-09-23 14:26:15 +000044 /// ARMProcClass - ARM processor class: None, AClass, RClass or MClass.
45 ARMProcClassEnum ARMProcClass;
46
Joey Gouly849eedc2013-06-26 16:58:26 +000047 /// HasV4TOps, HasV5TOps, HasV5TEOps,
Tim Northovercf3e4cb2013-10-07 11:10:47 +000048 /// HasV6Ops, HasV6MOps, HasV6T2Ops, HasV7Ops, HasV8Ops -
Evan Cheng39dfb0f2011-07-07 03:55:05 +000049 /// Specify whether target support specific ARM ISA variants.
50 bool HasV4TOps;
51 bool HasV5TOps;
52 bool HasV5TEOps;
53 bool HasV6Ops;
Tim Northovercf3e4cb2013-10-07 11:10:47 +000054 bool HasV6MOps;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000055 bool HasV6T2Ops;
56 bool HasV7Ops;
Joey Gouly849eedc2013-06-26 16:58:26 +000057 bool HasV8Ops;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000058
Joey Gouly2a9af9f2013-09-13 13:46:57 +000059 /// HasVFPv2, HasVFPv3, HasVFPv4, HasFPARMv8, HasNEON - Specify what
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +000060 /// floating point ISAs are supported.
Evan Cheng39dfb0f2011-07-07 03:55:05 +000061 bool HasVFPv2;
62 bool HasVFPv3;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +000063 bool HasVFPv4;
Joey Gouly2a9af9f2013-09-13 13:46:57 +000064 bool HasFPARMv8;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000065 bool HasNEON;
Evan Chenga8e29892007-01-19 07:51:42 +000066
Stephen Hines36b56882014-04-23 16:57:46 -070067 /// MinSize - True if the function being compiled has the "minsize" attribute
68 /// and should be optimised for size at the expense of speed.
69 bool MinSize;
70
David Goodwin1f0e4042009-08-05 16:01:19 +000071 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
72 /// specified. Use the method useNEONForSinglePrecisionFP() to
73 /// determine if NEON should actually be used.
David Goodwin42a83f22009-08-04 17:53:06 +000074 bool UseNEONForSinglePrecisionFP;
75
Bob Wilsoneb1641d2012-09-29 21:43:49 +000076 /// UseMulOps - True if non-microcoded fused integer multiply-add and
77 /// multiply-subtract instructions should be used.
78 bool UseMulOps;
79
Evan Cheng48575f62010-12-05 22:04:16 +000080 /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
81 /// whether the FP VML[AS] instructions are slow (if so, don't use them).
82 bool SlowFPVMLx;
Jim Grosbach26767372010-03-24 22:31:46 +000083
Evan Cheng463d3582011-03-31 19:38:48 +000084 /// HasVMLxForwarding - If true, NEON has special multiplier accumulator
85 /// forwarding to allow mul + mla being issued back to back.
86 bool HasVMLxForwarding;
87
Evan Cheng7a415992010-07-13 19:21:50 +000088 /// SlowFPBrcc - True if floating point compare + branch is slow.
89 bool SlowFPBrcc;
90
Evan Cheng4761a8d2011-07-07 19:09:06 +000091 /// InThumbMode - True if compiling for Thumb, false for ARM.
Evan Cheng963b03c2011-07-07 19:05:12 +000092 bool InThumbMode;
Anton Korobeynikov70459be2009-06-01 20:00:48 +000093
Evan Cheng94ca42f2011-07-07 00:08:19 +000094 /// HasThumb2 - True if Thumb2 instructions are supported.
95 bool HasThumb2;
Evan Chenga8e29892007-01-19 07:51:42 +000096
Evan Cheng7b4d3112010-08-11 07:17:46 +000097 /// NoARM - True if subtarget does not support ARM mode execution.
98 bool NoARM;
99
David Goodwin0dad89f2009-09-30 00:10:16 +0000100 /// PostRAScheduler - True if using post-register-allocation scheduler.
101 bool PostRAScheduler;
102
Evan Chenga8e29892007-01-19 07:51:42 +0000103 /// IsR9Reserved - True if R9 is a not available as general purpose register.
104 bool IsR9Reserved;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000105
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000106 /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit
107 /// imms (including global addresses).
108 bool UseMovt;
109
Bob Wilson6d2f9ce2011-10-07 17:17:49 +0000110 /// SupportsTailCall - True if the OS supports tail call. The dynamic linker
111 /// must be able to synthesize call stubs for interworking between ARM and
112 /// Thumb.
113 bool SupportsTailCall;
114
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000115 /// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF
116 /// only so far)
117 bool HasFP16;
118
Bob Wilson77f42b52010-10-12 16:22:47 +0000119 /// HasD16 - True if subtarget is limited to 16 double precision
120 /// FP registers for VFPv3.
121 bool HasD16;
122
Jim Grosbach29402132010-05-05 23:44:43 +0000123 /// HasHardwareDivide - True if subtarget supports [su]div
124 bool HasHardwareDivide;
125
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000126 /// HasHardwareDivideInARM - True if subtarget supports [su]div in ARM mode
127 bool HasHardwareDivideInARM;
128
Jim Grosbach29402132010-05-05 23:44:43 +0000129 /// HasT2ExtractPack - True if subtarget supports thumb2 extract/pack
130 /// instructions.
131 bool HasT2ExtractPack;
132
Evan Cheng11db0682010-08-11 06:22:01 +0000133 /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
134 /// instructions.
135 bool HasDataBarrier;
136
Evan Chenge44be632010-08-09 18:35:19 +0000137 /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
138 /// over 16-bit ones.
139 bool Pref32BitThumb;
140
Bob Wilson5dde8932011-04-19 18:11:49 +0000141 /// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
142 /// that partially update CPSR and add false dependency on the previous
143 /// CPSR setting instruction.
144 bool AvoidCPSRPartialUpdate;
145
Evan Cheng139e4072012-12-20 19:59:30 +0000146 /// AvoidMOVsShifterOperand - If true, codegen should avoid using flag setting
147 /// movs with shifter operand (i.e. asr, lsl, lsr).
148 bool AvoidMOVsShifterOperand;
149
Evan Cheng4bfcd4a2012-02-28 18:51:51 +0000150 /// HasRAS - Some processors perform return stack prediction. CodeGen should
151 /// avoid issue "normal" call instructions to callees which do not return.
152 bool HasRAS;
153
Evan Chengdfed19f2010-11-03 06:34:55 +0000154 /// HasMPExtension - True if the subtarget supports Multiprocessing
155 /// extension (ARMv7 only).
156 bool HasMPExtension;
157
Bradley Smith6186de52013-11-01 13:27:35 +0000158 /// HasVirtualization - True if the subtarget supports the Virtualization
159 /// extension.
160 bool HasVirtualization;
161
Jim Grosbachfcba5e62010-08-11 15:44:15 +0000162 /// FPOnlySP - If true, the floating point unit only supports single
163 /// precision.
164 bool FPOnlySP;
165
Tim Northoverb94a3532013-05-23 19:11:14 +0000166 /// If true, the processor supports the Performance Monitor Extensions. These
167 /// include a generic cycle-counter as well as more fine-grained (often
168 /// implementation-specific) events.
169 bool HasPerfMon;
170
Tim Northover8c9e52a2013-04-10 12:08:35 +0000171 /// HasTrustZone - if true, processor supports TrustZone security extensions
172 bool HasTrustZone;
173
Amara Emerson5df37da2013-09-19 11:59:01 +0000174 /// HasCrypto - if true, processor supports Cryptography extensions
175 bool HasCrypto;
176
Bernard Ogden47c6d172013-10-29 09:47:35 +0000177 /// HasCRC - if true, processor supports CRC instructions
178 bool HasCRC;
179
Stephen Hines36b56882014-04-23 16:57:46 -0700180 /// If true, the instructions "vmov.i32 d0, #0" and "vmov.i32 q0, #0" are
181 /// particularly effective at zeroing a VFP register.
182 bool HasZeroCycleZeroing;
183
Bob Wilson02aba732010-09-28 04:09:35 +0000184 /// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
185 /// accesses for some types. For details, see
186 /// ARMTargetLowering::allowsUnalignedMemoryAccesses().
187 bool AllowsUnalignedMem;
188
Weiming Zhao929bdb22013-11-13 18:29:49 +0000189 /// RestrictIT - If true, the subtarget disallows generation of deprecated IT
190 /// blocks to conform to ARMv8 rule.
191 bool RestrictIT;
192
Jim Grosbacha7603982011-07-01 21:12:19 +0000193 /// Thumb2DSP - If true, the subtarget supports the v7 DSP (saturating arith
194 /// and such) instructions in Thumb2 code.
195 bool Thumb2DSP;
196
Eli Bendersky0f156af2013-01-30 16:30:19 +0000197 /// NaCl TRAP instruction is generated instead of the regular TRAP.
198 bool UseNaClTrap;
199
Stephen Hines373aa5c2014-02-06 23:41:26 -0800200 /// Force long to be a 64-bit type (RenderScript-specific)
201 bool UseLong64;
202
Stephen Hines36b56882014-04-23 16:57:46 -0700203 /// Target machine allowed unsafe FP math (such as use of NEON fp)
204 bool UnsafeFPMath;
205
Evan Chenga8e29892007-01-19 07:51:42 +0000206 /// stackAlignment - The minimum alignment known to hold of the stack frame on
207 /// entry to the function and which must be maintained by every function.
208 unsigned stackAlignment;
209
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000210 /// CPUString - String name of used CPU.
211 std::string CPUString;
212
Stephen Hines36b56882014-04-23 16:57:46 -0700213 /// IsLittle - The target is Little Endian
214 bool IsLittle;
215
Evan Chengb72d2a92011-01-11 21:46:47 +0000216 /// TargetTriple - What processor and OS we're targeting.
217 Triple TargetTriple;
218
Andrew Trickd43b5c92012-08-08 02:44:16 +0000219 /// SchedModel - Processor specific instruction costs.
220 const MCSchedModel *SchedModel;
221
Evan Cheng8557c2b2009-06-19 01:51:50 +0000222 /// Selected instruction itineraries (one entry per itinerary class.)
223 InstrItineraryData InstrItins;
Jim Grosbach764ab522009-08-11 15:33:49 +0000224
Renato Golin3382a842013-03-21 18:47:47 +0000225 /// Options passed via command line that could influence the target
226 const TargetOptions &Options;
227
Evan Chenga8e29892007-01-19 07:51:42 +0000228 public:
Evan Cheng1a3771e2007-01-19 19:22:40 +0000229 enum {
Stephen Hines36b56882014-04-23 16:57:46 -0700230 ARM_ABI_UNKNOWN,
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000231 ARM_ABI_APCS,
232 ARM_ABI_AAPCS // ARM EABI
233 } TargetABI;
234
Evan Chenga8e29892007-01-19 07:51:42 +0000235 /// This constructor initializes the data members to match that
Daniel Dunbar3be03402009-08-02 22:11:08 +0000236 /// of the specified triple.
Evan Chenga8e29892007-01-19 07:51:42 +0000237 ///
Evan Cheng276365d2011-06-30 01:53:36 +0000238 ARMSubtarget(const std::string &TT, const std::string &CPU,
Stephen Hines36b56882014-04-23 16:57:46 -0700239 const std::string &FS, bool IsLittle,
240 const TargetOptions &Options);
Evan Chenga8e29892007-01-19 07:51:42 +0000241
Dan Gohman707e0182008-04-12 04:36:06 +0000242 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
243 /// that still makes it profitable to inline the call.
Rafael Espindolae0703c82007-10-31 14:39:58 +0000244 unsigned getMaxInlineSizeThreshold() const {
Stephen Hinesdce4a402014-05-29 02:49:00 -0700245 return 64;
Rafael Espindolae0703c82007-10-31 14:39:58 +0000246 }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +0000247 /// ParseSubtargetFeatures - Parses features string setting specified
Evan Chenga8e29892007-01-19 07:51:42 +0000248 /// subtarget options. Definition of function is auto generated by tblgen.
Evan Cheng0ddff1b2011-07-07 07:07:08 +0000249 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Evan Chenga8e29892007-01-19 07:51:42 +0000250
Renato Golinb26f98f2013-02-16 19:14:59 +0000251 /// \brief Reset the features for the ARM target.
Stephen Hines36b56882014-04-23 16:57:46 -0700252 void resetSubtargetFeatures(const MachineFunction *MF) override;
Bill Wendling901d8002013-02-16 01:36:26 +0000253private:
254 void initializeEnvironment();
Bill Wendling4788d142013-02-15 22:41:25 +0000255 void resetSubtargetFeatures(StringRef CPU, StringRef FS);
Bill Wendling901d8002013-02-16 01:36:26 +0000256public:
Andrew Trick2da8bc82010-12-24 05:03:26 +0000257 void computeIssueWidth();
258
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000259 bool hasV4TOps() const { return HasV4TOps; }
260 bool hasV5TOps() const { return HasV5TOps; }
261 bool hasV5TEOps() const { return HasV5TEOps; }
262 bool hasV6Ops() const { return HasV6Ops; }
Amara Emersonca7b2d02013-10-07 16:55:23 +0000263 bool hasV6MOps() const { return HasV6MOps; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000264 bool hasV6T2Ops() const { return HasV6T2Ops; }
265 bool hasV7Ops() const { return HasV7Ops; }
Joey Gouly849eedc2013-06-26 16:58:26 +0000266 bool hasV8Ops() const { return HasV8Ops; }
Evan Chenga8e29892007-01-19 07:51:42 +0000267
Quentin Colombet8facb9e2012-11-29 19:48:01 +0000268 bool isCortexA5() const { return ARMProcFamily == CortexA5; }
Stephen Hines36b56882014-04-23 16:57:46 -0700269 bool isCortexA7() const { return ARMProcFamily == CortexA7; }
Evan Cheng3ef1c872010-09-10 01:29:16 +0000270 bool isCortexA8() const { return ARMProcFamily == CortexA8; }
271 bool isCortexA9() const { return ARMProcFamily == CortexA9; }
Silviu Baranga616471d2012-09-13 15:05:10 +0000272 bool isCortexA15() const { return ARMProcFamily == CortexA15; }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000273 bool isSwift() const { return ARMProcFamily == Swift; }
Evan Cheng44ee4712011-11-09 01:57:03 +0000274 bool isCortexM3() const { return CPUString == "cortex-m3"; }
Stephen Hines36b56882014-04-23 16:57:46 -0700275 bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); }
Quentin Colombete0f1d712012-12-21 04:35:05 +0000276 bool isCortexR5() const { return ARMProcFamily == CortexR5; }
Stephen Hines36b56882014-04-23 16:57:46 -0700277 bool isKrait() const { return ARMProcFamily == Krait; }
Evan Cheng3ef1c872010-09-10 01:29:16 +0000278
Evan Cheng7b4d3112010-08-11 07:17:46 +0000279 bool hasARMOps() const { return !NoARM; }
280
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000281 bool hasVFP2() const { return HasVFPv2; }
282 bool hasVFP3() const { return HasVFPv3; }
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000283 bool hasVFP4() const { return HasVFPv4; }
Joey Gouly2a9af9f2013-09-13 13:46:57 +0000284 bool hasFPARMv8() const { return HasFPARMv8; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000285 bool hasNEON() const { return HasNEON; }
Amara Emerson5df37da2013-09-19 11:59:01 +0000286 bool hasCrypto() const { return HasCrypto; }
Bernard Ogden47c6d172013-10-29 09:47:35 +0000287 bool hasCRC() const { return HasCRC; }
Bradley Smith6186de52013-11-01 13:27:35 +0000288 bool hasVirtualization() const { return HasVirtualization; }
Stephen Hines36b56882014-04-23 16:57:46 -0700289 bool isMinSize() const { return MinSize; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000290 bool useNEONForSinglePrecisionFP() const {
David Goodwin42a83f22009-08-04 17:53:06 +0000291 return hasNEON() && UseNEONForSinglePrecisionFP; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000292
Shantonu Seneae216c2010-05-06 14:57:47 +0000293 bool hasDivide() const { return HasHardwareDivide; }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000294 bool hasDivideInARMMode() const { return HasHardwareDivideInARM; }
Shantonu Seneae216c2010-05-06 14:57:47 +0000295 bool hasT2ExtractPack() const { return HasT2ExtractPack; }
Evan Cheng11db0682010-08-11 06:22:01 +0000296 bool hasDataBarrier() const { return HasDataBarrier; }
Tim Northover214c37d2013-10-25 09:30:24 +0000297 bool hasAnyDataBarrier() const {
298 return HasDataBarrier || (hasV6Ops() && !isThumb());
299 }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000300 bool useMulOps() const { return UseMulOps; }
Evan Cheng48575f62010-12-05 22:04:16 +0000301 bool useFPVMLx() const { return !SlowFPVMLx; }
Evan Cheng463d3582011-03-31 19:38:48 +0000302 bool hasVMLxForwarding() const { return HasVMLxForwarding; }
Evan Cheng7a415992010-07-13 19:21:50 +0000303 bool isFPBrccSlow() const { return SlowFPBrcc; }
Jim Grosbachfcba5e62010-08-11 15:44:15 +0000304 bool isFPOnlySP() const { return FPOnlySP; }
Tim Northoverb94a3532013-05-23 19:11:14 +0000305 bool hasPerfMon() const { return HasPerfMon; }
Tim Northover8c9e52a2013-04-10 12:08:35 +0000306 bool hasTrustZone() const { return HasTrustZone; }
Stephen Hines36b56882014-04-23 16:57:46 -0700307 bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
Evan Chenge44be632010-08-09 18:35:19 +0000308 bool prefers32BitThumb() const { return Pref32BitThumb; }
Bob Wilson5dde8932011-04-19 18:11:49 +0000309 bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
Evan Cheng139e4072012-12-20 19:59:30 +0000310 bool avoidMOVsShifterOperand() const { return AvoidMOVsShifterOperand; }
Evan Cheng4bfcd4a2012-02-28 18:51:51 +0000311 bool hasRAS() const { return HasRAS; }
Evan Chengdfed19f2010-11-03 06:34:55 +0000312 bool hasMPExtension() const { return HasMPExtension; }
Jim Grosbacha7603982011-07-01 21:12:19 +0000313 bool hasThumb2DSP() const { return Thumb2DSP; }
Eli Bendersky0f156af2013-01-30 16:30:19 +0000314 bool useNaClTrap() const { return UseNaClTrap; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000315
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000316 bool hasFP16() const { return HasFP16; }
Bob Wilson77f42b52010-10-12 16:22:47 +0000317 bool hasD16() const { return HasD16; }
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000318
Evan Chengc8578942011-04-20 22:20:12 +0000319 const Triple &getTargetTriple() const { return TargetTriple; }
320
Daniel Dunbar912225e2011-04-19 21:14:45 +0000321 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
Stephen Hines36b56882014-04-23 16:57:46 -0700322 bool isTargetIOS() const { return TargetTriple.isiOS(); }
Cameron Esfahani441c5572013-08-29 20:23:14 +0000323 bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
Stephen Hines36b56882014-04-23 16:57:46 -0700324 bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
325 bool isTargetNetBSD() const { return TargetTriple.getOS() == Triple::NetBSD; }
326 bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
327
328 bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
329 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
330 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
331
Renato Golin103ba842013-07-16 09:32:17 +0000332 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
333 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
334 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
335 // even for GNUEABI, so we can make a distinction here and still conform to
336 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
Stephen Hines36b56882014-04-23 16:57:46 -0700337 // FIXME: The Darwin exception is temporary, while we move users to
338 // "*-*-*-macho" triples as quickly as possible.
Renato Golin103ba842013-07-16 09:32:17 +0000339 bool isTargetAEABI() const {
Stephen Hines36b56882014-04-23 16:57:46 -0700340 return (TargetTriple.getEnvironment() == Triple::EABI ||
341 TargetTriple.getEnvironment() == Triple::EABIHF) &&
342 !isTargetDarwin() && !isTargetWindows();
Renato Golin103ba842013-07-16 09:32:17 +0000343 }
Evan Cheng1a3771e2007-01-19 19:22:40 +0000344
Stephen Hines36b56882014-04-23 16:57:46 -0700345 // ARM Targets that support EHABI exception handling standard
346 // Darwin uses SjLj. Other targets might need more checks.
347 bool isTargetEHABICompatible() const {
348 return (TargetTriple.getEnvironment() == Triple::EABI ||
349 TargetTriple.getEnvironment() == Triple::GNUEABI ||
350 TargetTriple.getEnvironment() == Triple::EABIHF ||
351 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
352 TargetTriple.getEnvironment() == Triple::Android) &&
353 !isTargetDarwin() && !isTargetWindows();
354 }
355
356 bool isTargetHardFloat() const {
357 // FIXME: this is invalid for WindowsCE
358 return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
359 TargetTriple.getEnvironment() == Triple::EABIHF ||
360 isTargetWindows();
361 }
362 bool isTargetAndroid() const {
363 return TargetTriple.getEnvironment() == Triple::Android;
364 }
365
366 bool isAPCS_ABI() const {
367 assert(TargetABI != ARM_ABI_UNKNOWN);
368 return TargetABI == ARM_ABI_APCS;
369 }
370 bool isAAPCS_ABI() const {
371 assert(TargetABI != ARM_ABI_UNKNOWN);
372 return TargetABI == ARM_ABI_AAPCS;
373 }
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000374
Evan Cheng963b03c2011-07-07 19:05:12 +0000375 bool isThumb() const { return InThumbMode; }
376 bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
377 bool isThumb2() const { return InThumbMode && HasThumb2; }
Evan Cheng94ca42f2011-07-07 00:08:19 +0000378 bool hasThumb2() const { return HasThumb2; }
Amara Emerson0f22c132013-09-23 14:26:15 +0000379 bool isMClass() const { return ARMProcClass == MClass; }
380 bool isRClass() const { return ARMProcClass == RClass; }
381 bool isAClass() const { return ARMProcClass == AClass; }
Evan Chenga8e29892007-01-19 07:51:42 +0000382
Evan Chenga8e29892007-01-19 07:51:42 +0000383 bool isR9Reserved() const { return IsR9Reserved; }
384
Stephen Hines36b56882014-04-23 16:57:46 -0700385 bool useMovt() const { return UseMovt && !isMinSize(); }
Bob Wilson6d2f9ce2011-10-07 17:17:49 +0000386 bool supportsTailCall() const { return SupportsTailCall; }
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000387
Bob Wilson02aba732010-09-28 04:09:35 +0000388 bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
389
Weiming Zhao929bdb22013-11-13 18:29:49 +0000390 bool restrictIT() const { return RestrictIT; }
391
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000392 const std::string & getCPUString() const { return CPUString; }
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000393
Stephen Hines36b56882014-04-23 16:57:46 -0700394 bool isLittle() const { return IsLittle; }
395
Owen Anderson654d5442010-09-28 21:57:50 +0000396 unsigned getMispredictionPenalty() const;
Stephen Hinesdce4a402014-05-29 02:49:00 -0700397
Bob Wilsoncb01efb2013-11-03 06:14:38 +0000398 /// This function returns true if the target has sincos() routine in its
399 /// compiler runtime or math libraries.
400 bool hasSinCos() const;
Andrew Trick6e8f4c42010-12-24 04:28:06 +0000401
David Goodwinc2e8a7e2009-11-10 00:48:55 +0000402 /// enablePostRAScheduler - True at 'More' optimization.
David Goodwin4c3715c2009-10-22 23:19:17 +0000403 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
Evan Cheng5b1b44892011-07-01 21:01:15 +0000404 TargetSubtargetInfo::AntiDepBreakMode& Mode,
Stephen Hines36b56882014-04-23 16:57:46 -0700405 RegClassVector& CriticalPathRCs) const override;
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000406
Jim Grosbach764ab522009-08-11 15:33:49 +0000407 /// getInstrItins - Return the instruction itineraies based on subtarget
Evan Cheng8557c2b2009-06-19 01:51:50 +0000408 /// selection.
409 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
410
Evan Chenga8e29892007-01-19 07:51:42 +0000411 /// getStackAlignment - Returns the minimum alignment known to hold of the
412 /// stack frame on entry to the function and which must be maintained by every
413 /// function for this subtarget.
414 unsigned getStackAlignment() const { return stackAlignment; }
Evan Chenge4e4ed32009-08-28 23:18:09 +0000415
416 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
417 /// symbol.
Dan Gohman46510a72010-04-15 01:51:59 +0000418 bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
Evan Chenga8e29892007-01-19 07:51:42 +0000419};
420} // End llvm namespace
421
422#endif // ARMSUBTARGET_H