Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- ARMSubtarget.cpp - ARM Subtarget Information ----------------------===// |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Evan Cheng | 0d639a2 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file implements the ARM specific subclass of TargetSubtargetInfo. |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "ARMSubtarget.h" |
Andrew Trick | ab722bd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 15 | #include "ARMBaseInstrInfo.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 16 | #include "ARMBaseRegisterInfo.h" |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 17 | #include "llvm/IR/Attributes.h" |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 18 | #include "llvm/IR/Function.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 19 | #include "llvm/IR/GlobalValue.h" |
Bob Wilson | 4582530 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 20 | #include "llvm/Support/CommandLine.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 21 | #include "llvm/Target/TargetInstrInfo.h" |
Renato Golin | b4dd6c5 | 2013-03-21 18:47:47 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetOptions.h" |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 23 | |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 24 | #define GET_SUBTARGETINFO_TARGET_DESC |
Evan Cheng | 4d1ca96 | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 25 | #define GET_SUBTARGETINFO_CTOR |
Evan Cheng | c9c090d | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 26 | #include "ARMGenSubtargetInfo.inc" |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 27 | |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 28 | using namespace llvm; |
| 29 | |
Bob Wilson | 4582530 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 30 | static cl::opt<bool> |
| 31 | ReserveR9("arm-reserve-r9", cl::Hidden, |
| 32 | cl::desc("Reserve R9, making it unavailable as GPR")); |
| 33 | |
Anton Korobeynikov | 2522908 | 2009-11-24 00:44:37 +0000 | [diff] [blame] | 34 | static cl::opt<bool> |
Renato Golin | ca57063 | 2013-08-15 20:54:38 +0000 | [diff] [blame] | 35 | ArmUseMOVT("arm-use-movt", cl::init(true), cl::Hidden); |
Anton Korobeynikov | 2522908 | 2009-11-24 00:44:37 +0000 | [diff] [blame] | 36 | |
Bob Wilson | 3dc9732 | 2010-09-28 04:09:35 +0000 | [diff] [blame] | 37 | static cl::opt<bool> |
Bob Wilson | e8a549c | 2012-09-29 21:43:49 +0000 | [diff] [blame] | 38 | UseFusedMulOps("arm-use-mulops", |
| 39 | cl::init(true), cl::Hidden); |
| 40 | |
JF Bastien | 97b08c40 | 2013-05-17 23:49:01 +0000 | [diff] [blame] | 41 | enum AlignMode { |
| 42 | DefaultAlign, |
| 43 | StrictAlign, |
| 44 | NoStrictAlign |
| 45 | }; |
| 46 | |
| 47 | static cl::opt<AlignMode> |
| 48 | Align(cl::desc("Load/store alignment support"), |
| 49 | cl::Hidden, cl::init(DefaultAlign), |
| 50 | cl::values( |
| 51 | clEnumValN(DefaultAlign, "arm-default-align", |
| 52 | "Generate unaligned accesses only on hardware/OS " |
| 53 | "combinations that are known to support them"), |
| 54 | clEnumValN(StrictAlign, "arm-strict-align", |
| 55 | "Disallow all unaligned memory accesses"), |
| 56 | clEnumValN(NoStrictAlign, "arm-no-strict-align", |
| 57 | "Allow unaligned memory accesses"), |
| 58 | clEnumValEnd)); |
Bob Wilson | 3dc9732 | 2010-09-28 04:09:35 +0000 | [diff] [blame] | 59 | |
Weiming Zhao | 0da5cc0 | 2013-11-13 18:29:49 +0000 | [diff] [blame] | 60 | enum ITMode { |
| 61 | DefaultIT, |
| 62 | RestrictedIT, |
| 63 | NoRestrictedIT |
| 64 | }; |
| 65 | |
| 66 | static cl::opt<ITMode> |
| 67 | IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), |
| 68 | cl::ZeroOrMore, |
| 69 | cl::values(clEnumValN(DefaultIT, "arm-default-it", |
| 70 | "Generate IT block based on arch"), |
| 71 | clEnumValN(RestrictedIT, "arm-restrict-it", |
| 72 | "Disallow deprecated IT based on ARMv8"), |
| 73 | clEnumValN(NoRestrictedIT, "arm-no-restrict-it", |
| 74 | "Allow IT blocks based on ARMv7"), |
| 75 | clEnumValEnd)); |
| 76 | |
Evan Cheng | fe6e405 | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 77 | ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU, |
Christian Pirker | 2a11160 | 2014-03-28 14:35:30 +0000 | [diff] [blame] | 78 | const std::string &FS, bool IsLittle, |
| 79 | const TargetOptions &Options) |
Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 80 | : ARMGenSubtargetInfo(TT, CPU, FS) |
Evan Cheng | bf40707 | 2010-09-10 01:29:16 +0000 | [diff] [blame] | 81 | , ARMProcFamily(Others) |
Amara Emerson | 330afb5 | 2013-09-23 14:26:15 +0000 | [diff] [blame] | 82 | , ARMProcClass(None) |
Lauro Ramos Venancio | 048e16ff | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 83 | , stackAlignment(4) |
Evan Cheng | fe6e405 | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 84 | , CPUString(CPU) |
Christian Pirker | 2a11160 | 2014-03-28 14:35:30 +0000 | [diff] [blame] | 85 | , IsLittle(IsLittle) |
Evan Cheng | e45d685 | 2011-01-11 21:46:47 +0000 | [diff] [blame] | 86 | , TargetTriple(TT) |
Renato Golin | b4dd6c5 | 2013-03-21 18:47:47 +0000 | [diff] [blame] | 87 | , Options(Options) |
Rafael Espindola | d89b16d | 2014-01-02 13:40:08 +0000 | [diff] [blame] | 88 | , TargetABI(ARM_ABI_UNKNOWN) { |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 89 | initializeEnvironment(); |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 90 | resetSubtargetFeatures(CPU, FS); |
| 91 | } |
| 92 | |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 93 | void ARMSubtarget::initializeEnvironment() { |
| 94 | HasV4TOps = false; |
| 95 | HasV5TOps = false; |
| 96 | HasV5TEOps = false; |
| 97 | HasV6Ops = false; |
Amara Emerson | 5035ee0 | 2013-10-07 16:55:23 +0000 | [diff] [blame] | 98 | HasV6MOps = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 99 | HasV6T2Ops = false; |
| 100 | HasV7Ops = false; |
Joey Gouly | b3f550e | 2013-06-26 16:58:26 +0000 | [diff] [blame] | 101 | HasV8Ops = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 102 | HasVFPv2 = false; |
| 103 | HasVFPv3 = false; |
| 104 | HasVFPv4 = false; |
Joey Gouly | ccd0489 | 2013-09-13 13:46:57 +0000 | [diff] [blame] | 105 | HasFPARMv8 = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 106 | HasNEON = false; |
Tim Northover | dee8604 | 2013-12-02 14:46:26 +0000 | [diff] [blame] | 107 | MinSize = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 108 | UseNEONForSinglePrecisionFP = false; |
| 109 | UseMulOps = UseFusedMulOps; |
| 110 | SlowFPVMLx = false; |
| 111 | HasVMLxForwarding = false; |
| 112 | SlowFPBrcc = false; |
| 113 | InThumbMode = false; |
| 114 | HasThumb2 = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 115 | NoARM = false; |
| 116 | PostRAScheduler = false; |
| 117 | IsR9Reserved = ReserveR9; |
| 118 | UseMovt = false; |
| 119 | SupportsTailCall = false; |
| 120 | HasFP16 = false; |
| 121 | HasD16 = false; |
| 122 | HasHardwareDivide = false; |
| 123 | HasHardwareDivideInARM = false; |
| 124 | HasT2ExtractPack = false; |
| 125 | HasDataBarrier = false; |
| 126 | Pref32BitThumb = false; |
| 127 | AvoidCPSRPartialUpdate = false; |
| 128 | AvoidMOVsShifterOperand = false; |
| 129 | HasRAS = false; |
| 130 | HasMPExtension = false; |
Bradley Smith | 2521975 | 2013-11-01 13:27:35 +0000 | [diff] [blame] | 131 | HasVirtualization = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 132 | FPOnlySP = false; |
Tim Northover | cedd481 | 2013-05-23 19:11:14 +0000 | [diff] [blame] | 133 | HasPerfMon = false; |
Tim Northover | c604765 | 2013-04-10 12:08:35 +0000 | [diff] [blame] | 134 | HasTrustZone = false; |
Amara Emerson | 3308909 | 2013-09-19 11:59:01 +0000 | [diff] [blame] | 135 | HasCrypto = false; |
Amara Emerson | f9a67fc | 2013-10-29 16:54:52 +0000 | [diff] [blame] | 136 | HasCRC = false; |
Tim Northover | 1351030 | 2014-04-01 13:22:02 +0000 | [diff] [blame] | 137 | HasZeroCycleZeroing = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 138 | AllowsUnalignedMem = false; |
| 139 | Thumb2DSP = false; |
| 140 | UseNaClTrap = false; |
Renato Golin | b4dd6c5 | 2013-03-21 18:47:47 +0000 | [diff] [blame] | 141 | UnsafeFPMath = false; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 144 | void ARMSubtarget::resetSubtargetFeatures(const MachineFunction *MF) { |
| 145 | AttributeSet FnAttrs = MF->getFunction()->getAttributes(); |
| 146 | Attribute CPUAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex, |
| 147 | "target-cpu"); |
| 148 | Attribute FSAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex, |
| 149 | "target-features"); |
| 150 | std::string CPU = |
| 151 | !CPUAttr.hasAttribute(Attribute::None) ?CPUAttr.getValueAsString() : ""; |
| 152 | std::string FS = |
| 153 | !FSAttr.hasAttribute(Attribute::None) ? FSAttr.getValueAsString() : ""; |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 154 | if (!FS.empty()) { |
| 155 | initializeEnvironment(); |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 156 | resetSubtargetFeatures(CPU, FS); |
Bill Wendling | 61375d8 | 2013-02-16 01:36:26 +0000 | [diff] [blame] | 157 | } |
Tim Northover | dee8604 | 2013-12-02 14:46:26 +0000 | [diff] [blame] | 158 | |
| 159 | MinSize = |
| 160 | FnAttrs.hasAttribute(AttributeSet::FunctionIndex, Attribute::MinSize); |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | void ARMSubtarget::resetSubtargetFeatures(StringRef CPU, StringRef FS) { |
Tilmann Scheller | 63872ce | 2013-09-02 17:09:01 +0000 | [diff] [blame] | 164 | if (CPUString.empty()) { |
| 165 | if (isTargetIOS() && TargetTriple.getArchName().endswith("v7s")) |
| 166 | // Default to the Swift CPU when targeting armv7s/thumbv7s. |
| 167 | CPUString = "swift"; |
| 168 | else |
| 169 | CPUString = "generic"; |
| 170 | } |
Evan Cheng | ec415ef | 2009-03-08 04:02:49 +0000 | [diff] [blame] | 171 | |
Evan Cheng | 0b33a32 | 2011-06-30 02:12:44 +0000 | [diff] [blame] | 172 | // Insert the architecture feature derived from the target triple into the |
| 173 | // feature string. This is important for setting features that are implied |
| 174 | // based on the architecture version. |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 175 | std::string ArchFS = ARM_MC::ParseARMTriple(TargetTriple.getTriple(), |
| 176 | CPUString); |
Evan Cheng | 2bd6536 | 2011-07-07 00:08:19 +0000 | [diff] [blame] | 177 | if (!FS.empty()) { |
| 178 | if (!ArchFS.empty()) |
Bill Wendling | 5a92eec | 2013-02-15 22:41:25 +0000 | [diff] [blame] | 179 | ArchFS = ArchFS + "," + FS.str(); |
Evan Cheng | 2bd6536 | 2011-07-07 00:08:19 +0000 | [diff] [blame] | 180 | else |
| 181 | ArchFS = FS; |
| 182 | } |
Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 183 | ParseSubtargetFeatures(CPUString, ArchFS); |
Evan Cheng | 2bd6536 | 2011-07-07 00:08:19 +0000 | [diff] [blame] | 184 | |
Joerg Sonnenberger | 002a147 | 2013-12-13 11:16:00 +0000 | [diff] [blame] | 185 | // FIXME: This used enable V6T2 support implicitly for Thumb2 mode. |
| 186 | // Assert this for now to make the change obvious. |
| 187 | assert(hasV6T2Ops() || !hasThumb2()); |
Bob Wilson | d0046ca | 2010-11-09 22:50:47 +0000 | [diff] [blame] | 188 | |
Andrew Trick | 352abc1 | 2012-08-08 02:44:16 +0000 | [diff] [blame] | 189 | // Keep a pointer to static instruction cost data for the specified CPU. |
| 190 | SchedModel = getSchedModelForCPU(CPUString); |
| 191 | |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 192 | // Initialize scheduling itinerary for the specified CPU. |
| 193 | InstrItins = getInstrItineraryForCPU(CPUString); |
| 194 | |
Rafael Espindola | d89b16d | 2014-01-02 13:40:08 +0000 | [diff] [blame] | 195 | if (TargetABI == ARM_ABI_UNKNOWN) { |
| 196 | switch (TargetTriple.getEnvironment()) { |
| 197 | case Triple::Android: |
| 198 | case Triple::EABI: |
| 199 | case Triple::EABIHF: |
| 200 | case Triple::GNUEABI: |
| 201 | case Triple::GNUEABIHF: |
Joerg Sonnenberger | 7466979 | 2013-12-15 00:12:52 +0000 | [diff] [blame] | 202 | TargetABI = ARM_ABI_AAPCS; |
Rafael Espindola | d89b16d | 2014-01-02 13:40:08 +0000 | [diff] [blame] | 203 | break; |
| 204 | default: |
Saleem Abdulrasool | 3547633 | 2014-03-06 20:47:11 +0000 | [diff] [blame] | 205 | if ((isTargetIOS() && isMClass()) || |
| 206 | (TargetTriple.isOSBinFormatMachO() && |
| 207 | TargetTriple.getOS() == Triple::UnknownOS)) |
Rafael Espindola | d89b16d | 2014-01-02 13:40:08 +0000 | [diff] [blame] | 208 | TargetABI = ARM_ABI_AAPCS; |
| 209 | else |
| 210 | TargetABI = ARM_ABI_APCS; |
| 211 | break; |
| 212 | } |
Joerg Sonnenberger | 7466979 | 2013-12-15 00:12:52 +0000 | [diff] [blame] | 213 | } |
Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 214 | |
Saleem Abdulrasool | cd13082 | 2014-04-02 20:32:05 +0000 | [diff] [blame^] | 215 | // FIXME: this is invalid for WindowsCE |
| 216 | if (isTargetWindows()) { |
| 217 | TargetABI = ARM_ABI_AAPCS; |
| 218 | NoARM = true; |
| 219 | } |
| 220 | |
Lauro Ramos Venancio | 048e16ff | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 221 | if (isAAPCS_ABI()) |
| 222 | stackAlignment = 8; |
Mark Seaborn | be266aa | 2014-02-16 18:59:48 +0000 | [diff] [blame] | 223 | if (isTargetNaCl()) |
| 224 | stackAlignment = 16; |
Lauro Ramos Venancio | 048e16ff | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 225 | |
Renato Golin | ca57063 | 2013-08-15 20:54:38 +0000 | [diff] [blame] | 226 | UseMovt = hasV6T2Ops() && ArmUseMOVT; |
| 227 | |
Tim Northover | d6a729b | 2014-01-06 14:28:05 +0000 | [diff] [blame] | 228 | if (isTargetMachO()) { |
Evan Cheng | 8b2bda0 | 2011-07-07 03:55:05 +0000 | [diff] [blame] | 229 | IsR9Reserved = ReserveR9 | !HasV6Ops; |
Tim Northover | d6a729b | 2014-01-06 14:28:05 +0000 | [diff] [blame] | 230 | SupportsTailCall = !isTargetIOS() || !getTargetTriple().isOSVersionLT(5, 0); |
Saleem Abdulrasool | ec1ec1b | 2014-03-11 15:09:44 +0000 | [diff] [blame] | 231 | } else { |
Tim Northover | d6a729b | 2014-01-06 14:28:05 +0000 | [diff] [blame] | 232 | IsR9Reserved = ReserveR9; |
Saleem Abdulrasool | ec1ec1b | 2014-03-11 15:09:44 +0000 | [diff] [blame] | 233 | SupportsTailCall = !isThumb1Only(); |
| 234 | } |
David Goodwin | 9a051a5 | 2009-10-01 21:46:35 +0000 | [diff] [blame] | 235 | |
Evan Cheng | 03da4db | 2009-10-16 06:11:08 +0000 | [diff] [blame] | 236 | if (!isThumb() || hasThumb2()) |
| 237 | PostRAScheduler = true; |
Bob Wilson | 3dc9732 | 2010-09-28 04:09:35 +0000 | [diff] [blame] | 238 | |
JF Bastien | 97b08c40 | 2013-05-17 23:49:01 +0000 | [diff] [blame] | 239 | switch (Align) { |
| 240 | case DefaultAlign: |
| 241 | // Assume pre-ARMv6 doesn't support unaligned accesses. |
| 242 | // |
| 243 | // ARMv6 may or may not support unaligned accesses depending on the |
| 244 | // SCTLR.U bit, which is architecture-specific. We assume ARMv6 |
Jim Grosbach | 4a1a9ce | 2014-04-02 19:28:13 +0000 | [diff] [blame] | 245 | // Darwin and NetBSD targets support unaligned accesses, and others don't. |
JF Bastien | 97b08c40 | 2013-05-17 23:49:01 +0000 | [diff] [blame] | 246 | // |
| 247 | // ARMv7 always has SCTLR.U set to 1, but it has a new SCTLR.A bit |
| 248 | // which raises an alignment fault on unaligned accesses. Linux |
| 249 | // defaults this bit to 0 and handles it as a system-wide (not |
| 250 | // per-process) setting. It is therefore safe to assume that ARMv7+ |
| 251 | // Linux targets support unaligned accesses. The same goes for NaCl. |
| 252 | // |
| 253 | // The above behavior is consistent with GCC. |
Joerg Sonnenberger | 4455ffc | 2014-02-02 21:18:36 +0000 | [diff] [blame] | 254 | AllowsUnalignedMem = |
| 255 | (hasV7Ops() && (isTargetLinux() || isTargetNaCl() || |
| 256 | isTargetNetBSD())) || |
| 257 | (hasV6Ops() && (isTargetMachO() || isTargetNetBSD())); |
Jim Grosbach | 4a1a9ce | 2014-04-02 19:28:13 +0000 | [diff] [blame] | 258 | // The one exception is cortex-m0, which despite being v6, does not |
| 259 | // support unaligned accesses. Rather than make the above boolean |
| 260 | // expression even more obtuse, just override the value here. |
| 261 | if (isThumb1Only() && isMClass()) |
| 262 | AllowsUnalignedMem = false; |
JF Bastien | 97b08c40 | 2013-05-17 23:49:01 +0000 | [diff] [blame] | 263 | break; |
| 264 | case StrictAlign: |
| 265 | AllowsUnalignedMem = false; |
| 266 | break; |
| 267 | case NoStrictAlign: |
| 268 | AllowsUnalignedMem = true; |
| 269 | break; |
| 270 | } |
Renato Golin | b4dd6c5 | 2013-03-21 18:47:47 +0000 | [diff] [blame] | 271 | |
Weiming Zhao | 0da5cc0 | 2013-11-13 18:29:49 +0000 | [diff] [blame] | 272 | switch (IT) { |
| 273 | case DefaultIT: |
| 274 | RestrictIT = hasV8Ops() ? true : false; |
| 275 | break; |
| 276 | case RestrictedIT: |
| 277 | RestrictIT = true; |
| 278 | break; |
| 279 | case NoRestrictedIT: |
| 280 | RestrictIT = false; |
| 281 | break; |
| 282 | } |
| 283 | |
Renato Golin | b4dd6c5 | 2013-03-21 18:47:47 +0000 | [diff] [blame] | 284 | // NEON f32 ops are non-IEEE 754 compliant. Darwin is ok with it by default. |
| 285 | uint64_t Bits = getFeatureBits(); |
| 286 | if ((Bits & ARM::ProcA5 || Bits & ARM::ProcA8) && // Where this matters |
| 287 | (Options.UnsafeFPMath || isTargetDarwin())) |
| 288 | UseNEONForSinglePrecisionFP = true; |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 289 | } |
Evan Cheng | 43b9ca6 | 2009-08-28 23:18:09 +0000 | [diff] [blame] | 290 | |
| 291 | /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol. |
Evan Cheng | 1b38952 | 2009-09-03 07:04:02 +0000 | [diff] [blame] | 292 | bool |
Dan Gohman | bcaf681 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 293 | ARMSubtarget::GVIsIndirectSymbol(const GlobalValue *GV, |
| 294 | Reloc::Model RelocM) const { |
Evan Cheng | 1b38952 | 2009-09-03 07:04:02 +0000 | [diff] [blame] | 295 | if (RelocM == Reloc::Static) |
Evan Cheng | 43b9ca6 | 2009-08-28 23:18:09 +0000 | [diff] [blame] | 296 | return false; |
Evan Cheng | 1b38952 | 2009-09-03 07:04:02 +0000 | [diff] [blame] | 297 | |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 298 | // Materializable GVs (in JIT lazy compilation mode) do not require an extra |
| 299 | // load from stub. |
Evan Cheng | 2ce6630 | 2011-02-22 06:58:34 +0000 | [diff] [blame] | 300 | bool isDecl = GV->hasAvailableExternallyLinkage(); |
| 301 | if (GV->isDeclaration() && !GV->isMaterializable()) |
| 302 | isDecl = true; |
Evan Cheng | 1b38952 | 2009-09-03 07:04:02 +0000 | [diff] [blame] | 303 | |
Tim Northover | d6a729b | 2014-01-06 14:28:05 +0000 | [diff] [blame] | 304 | if (!isTargetMachO()) { |
Evan Cheng | 1b38952 | 2009-09-03 07:04:02 +0000 | [diff] [blame] | 305 | // Extra load is needed for all externally visible. |
| 306 | if (GV->hasLocalLinkage() || GV->hasHiddenVisibility()) |
| 307 | return false; |
| 308 | return true; |
| 309 | } else { |
| 310 | if (RelocM == Reloc::PIC_) { |
| 311 | // If this is a strong reference to a definition, it is definitely not |
| 312 | // through a stub. |
| 313 | if (!isDecl && !GV->isWeakForLinker()) |
| 314 | return false; |
| 315 | |
| 316 | // Unless we have a symbol with hidden visibility, we have to go through a |
| 317 | // normal $non_lazy_ptr stub because this symbol might be resolved late. |
| 318 | if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference. |
| 319 | return true; |
| 320 | |
| 321 | // If symbol visibility is hidden, we have a stub for common symbol |
| 322 | // references and external declarations. |
| 323 | if (isDecl || GV->hasCommonLinkage()) |
| 324 | // Hidden $non_lazy_ptr reference. |
| 325 | return true; |
| 326 | |
| 327 | return false; |
| 328 | } else { |
| 329 | // If this is a strong reference to a definition, it is definitely not |
| 330 | // through a stub. |
| 331 | if (!isDecl && !GV->isWeakForLinker()) |
| 332 | return false; |
Andrew Trick | c416ba6 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 333 | |
Evan Cheng | 1b38952 | 2009-09-03 07:04:02 +0000 | [diff] [blame] | 334 | // Unless we have a symbol with hidden visibility, we have to go through a |
| 335 | // normal $non_lazy_ptr stub because this symbol might be resolved late. |
| 336 | if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference. |
| 337 | return true; |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | return false; |
Evan Cheng | 43b9ca6 | 2009-08-28 23:18:09 +0000 | [diff] [blame] | 342 | } |
David Goodwin | 0d412c2 | 2009-11-10 00:48:55 +0000 | [diff] [blame] | 343 | |
Owen Anderson | a3181e2 | 2010-09-28 21:57:50 +0000 | [diff] [blame] | 344 | unsigned ARMSubtarget::getMispredictionPenalty() const { |
Andrew Trick | 352abc1 | 2012-08-08 02:44:16 +0000 | [diff] [blame] | 345 | return SchedModel->MispredictPenalty; |
Owen Anderson | a3181e2 | 2010-09-28 21:57:50 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Bob Wilson | e7dde0c | 2013-11-03 06:14:38 +0000 | [diff] [blame] | 348 | bool ARMSubtarget::hasSinCos() const { |
| 349 | return getTargetTriple().getOS() == Triple::IOS && |
| 350 | !getTargetTriple().isOSVersionLT(7, 0); |
| 351 | } |
| 352 | |
David Goodwin | 0d412c2 | 2009-11-10 00:48:55 +0000 | [diff] [blame] | 353 | bool ARMSubtarget::enablePostRAScheduler( |
| 354 | CodeGenOpt::Level OptLevel, |
Evan Cheng | 0d639a2 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 355 | TargetSubtargetInfo::AntiDepBreakMode& Mode, |
David Goodwin | b9fe5d5 | 2009-11-13 19:52:48 +0000 | [diff] [blame] | 356 | RegClassVector& CriticalPathRCs) const { |
Andrew Trick | d24698c | 2013-09-25 00:26:16 +0000 | [diff] [blame] | 357 | Mode = TargetSubtargetInfo::ANTIDEP_NONE; |
David Goodwin | 0d412c2 | 2009-11-10 00:48:55 +0000 | [diff] [blame] | 358 | return PostRAScheduler && OptLevel >= CodeGenOpt::Default; |
| 359 | } |