AArch64Subtarget.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. //===--- AArch64Subtarget.h - Define Subtarget for the AArch64 -*- C++ -*--===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file declares the AArch64 specific subclass of TargetSubtarget.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
  13. #define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
  14. #include "AArch64FrameLowering.h"
  15. #include "AArch64ISelLowering.h"
  16. #include "AArch64InstrInfo.h"
  17. #include "AArch64RegisterInfo.h"
  18. #include "AArch64SelectionDAGInfo.h"
  19. #include "llvm/CodeGen/GlobalISel/CallLowering.h"
  20. #include "llvm/CodeGen/GlobalISel/InlineAsmLowering.h"
  21. #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
  22. #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
  23. #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
  24. #include "llvm/CodeGen/TargetSubtargetInfo.h"
  25. #include "llvm/IR/DataLayout.h"
  26. #include <string>
  27. #define GET_SUBTARGETINFO_HEADER
  28. #include "AArch64GenSubtargetInfo.inc"
  29. namespace llvm {
  30. class GlobalValue;
  31. class StringRef;
  32. class Triple;
  33. class AArch64Subtarget final : public AArch64GenSubtargetInfo {
  34. public:
  35. enum ARMProcFamilyEnum : uint8_t {
  36. Others,
  37. A64FX,
  38. Ampere1,
  39. AppleA7,
  40. AppleA10,
  41. AppleA11,
  42. AppleA12,
  43. AppleA13,
  44. AppleA14,
  45. Carmel,
  46. CortexA35,
  47. CortexA53,
  48. CortexA55,
  49. CortexA510,
  50. CortexA57,
  51. CortexA65,
  52. CortexA72,
  53. CortexA73,
  54. CortexA75,
  55. CortexA76,
  56. CortexA77,
  57. CortexA78,
  58. CortexA78C,
  59. CortexA710,
  60. CortexR82,
  61. CortexX1,
  62. CortexX1C,
  63. CortexX2,
  64. ExynosM3,
  65. Falkor,
  66. Kryo,
  67. NeoverseE1,
  68. NeoverseN1,
  69. NeoverseN2,
  70. Neoverse512TVB,
  71. NeoverseV1,
  72. Saphira,
  73. ThunderX2T99,
  74. ThunderX,
  75. ThunderXT81,
  76. ThunderXT83,
  77. ThunderXT88,
  78. ThunderX3T110,
  79. TSV110
  80. };
  81. protected:
  82. /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
  83. ARMProcFamilyEnum ARMProcFamily = Others;
  84. bool HasV8_0aOps = false;
  85. bool HasV8_1aOps = false;
  86. bool HasV8_2aOps = false;
  87. bool HasV8_3aOps = false;
  88. bool HasV8_4aOps = false;
  89. bool HasV8_5aOps = false;
  90. bool HasV8_6aOps = false;
  91. bool HasV8_7aOps = false;
  92. bool HasV8_8aOps = false;
  93. bool HasV9_0aOps = false;
  94. bool HasV9_1aOps = false;
  95. bool HasV9_2aOps = false;
  96. bool HasV9_3aOps = false;
  97. bool HasV8_0rOps = false;
  98. bool HasCONTEXTIDREL2 = false;
  99. bool HasEL2VMSA = false;
  100. bool HasEL3 = false;
  101. bool HasFPARMv8 = false;
  102. bool HasNEON = false;
  103. bool HasCrypto = false;
  104. bool HasDotProd = false;
  105. bool HasCRC = false;
  106. bool HasLSE = false;
  107. bool HasLSE2 = false;
  108. bool HasRAS = false;
  109. bool HasRDM = false;
  110. bool HasPerfMon = false;
  111. bool HasFullFP16 = false;
  112. bool HasFP16FML = false;
  113. bool HasSPE = false;
  114. bool FixCortexA53_835769 = false;
  115. // ARMv8.1 extensions
  116. bool HasVH = false;
  117. bool HasPAN = false;
  118. bool HasLOR = false;
  119. // ARMv8.2 extensions
  120. bool HasPsUAO = false;
  121. bool HasPAN_RWV = false;
  122. bool HasCCPP = false;
  123. // SVE extensions
  124. bool HasSVE = false;
  125. bool UseExperimentalZeroingPseudos = false;
  126. bool UseScalarIncVL = false;
  127. // Armv8.2 Crypto extensions
  128. bool HasSM4 = false;
  129. bool HasSHA3 = false;
  130. bool HasSHA2 = false;
  131. bool HasAES = false;
  132. // ARMv8.3 extensions
  133. bool HasPAuth = false;
  134. bool HasJS = false;
  135. bool HasCCIDX = false;
  136. bool HasComplxNum = false;
  137. // ARMv8.4 extensions
  138. bool HasNV = false;
  139. bool HasMPAM = false;
  140. bool HasDIT = false;
  141. bool HasTRACEV8_4 = false;
  142. bool HasAM = false;
  143. bool HasSEL2 = false;
  144. bool HasTLB_RMI = false;
  145. bool HasFlagM = false;
  146. bool HasRCPC_IMMO = false;
  147. bool HasLSLFast = false;
  148. bool HasRCPC = false;
  149. bool HasAggressiveFMA = false;
  150. // Armv8.5-A Extensions
  151. bool HasAlternativeNZCV = false;
  152. bool HasFRInt3264 = false;
  153. bool HasSpecRestrict = false;
  154. bool HasSSBS = false;
  155. bool HasSB = false;
  156. bool HasPredRes = false;
  157. bool HasCCDP = false;
  158. bool HasBTI = false;
  159. bool HasRandGen = false;
  160. bool HasMTE = false;
  161. bool HasTME = false;
  162. // Armv8.6-A Extensions
  163. bool HasBF16 = false;
  164. bool HasMatMulInt8 = false;
  165. bool HasMatMulFP32 = false;
  166. bool HasMatMulFP64 = false;
  167. bool HasAMVS = false;
  168. bool HasFineGrainedTraps = false;
  169. bool HasEnhancedCounterVirtualization = false;
  170. // Armv8.7-A Extensions
  171. bool HasXS = false;
  172. bool HasWFxT = false;
  173. bool HasHCX = false;
  174. bool HasLS64 = false;
  175. // Armv8.8-A Extensions
  176. bool HasHBC = false;
  177. bool HasMOPS = false;
  178. // Arm SVE2 extensions
  179. bool HasSVE2 = false;
  180. bool HasSVE2AES = false;
  181. bool HasSVE2SM4 = false;
  182. bool HasSVE2SHA3 = false;
  183. bool HasSVE2BitPerm = false;
  184. // Armv9-A Extensions
  185. bool HasRME = false;
  186. // Arm Scalable Matrix Extension (SME)
  187. bool HasSME = false;
  188. bool HasSMEF64 = false;
  189. bool HasSMEI64 = false;
  190. bool HasStreamingSVE = false;
  191. // AppleA7 system register.
  192. bool HasAppleA7SysReg = false;
  193. // Future architecture extensions.
  194. bool HasETE = false;
  195. bool HasTRBE = false;
  196. bool HasBRBE = false;
  197. bool HasSPE_EEF = false;
  198. // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
  199. bool HasZeroCycleRegMove = false;
  200. // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
  201. bool HasZeroCycleZeroing = false;
  202. bool HasZeroCycleZeroingGP = false;
  203. bool HasZeroCycleZeroingFPWorkaround = false;
  204. // It is generally beneficial to rewrite "fmov s0, wzr" to "movi d0, #0".
  205. // as movi is more efficient across all cores. Newer cores can eliminate
  206. // fmovs early and there is no difference with movi, but this not true for
  207. // all implementations.
  208. bool HasZeroCycleZeroingFP = true;
  209. // StrictAlign - Disallow unaligned memory accesses.
  210. bool StrictAlign = false;
  211. // NegativeImmediates - transform instructions with negative immediates
  212. bool NegativeImmediates = true;
  213. // Enable 64-bit vectorization in SLP.
  214. unsigned MinVectorRegisterBitWidth = 64;
  215. // Do not place a BTI instruction after a call to a return twice function like
  216. // setjmp.
  217. bool NoBTIAtReturnTwice = false;
  218. bool OutlineAtomics = false;
  219. bool PredictableSelectIsExpensive = false;
  220. bool BalanceFPOps = false;
  221. bool CustomAsCheapAsMove = false;
  222. bool ExynosAsCheapAsMove = false;
  223. bool UsePostRAScheduler = false;
  224. bool Misaligned128StoreIsSlow = false;
  225. bool Paired128IsSlow = false;
  226. bool STRQroIsSlow = false;
  227. bool UseAlternateSExtLoadCVTF32Pattern = false;
  228. bool HasArithmeticBccFusion = false;
  229. bool HasArithmeticCbzFusion = false;
  230. bool HasCmpBccFusion = false;
  231. bool HasFuseAddress = false;
  232. bool HasFuseAES = false;
  233. bool HasFuseArithmeticLogic = false;
  234. bool HasFuseCCSelect = false;
  235. bool HasFuseCryptoEOR = false;
  236. bool HasFuseLiterals = false;
  237. bool DisableLatencySchedHeuristic = false;
  238. bool UseRSqrt = false;
  239. bool Force32BitJumpTables = false;
  240. bool UseEL1ForTP = false;
  241. bool UseEL2ForTP = false;
  242. bool UseEL3ForTP = false;
  243. bool AllowTaggedGlobals = false;
  244. bool HardenSlsRetBr = false;
  245. bool HardenSlsBlr = false;
  246. bool HardenSlsNoComdat = false;
  247. uint8_t MaxInterleaveFactor = 2;
  248. uint8_t VectorInsertExtractBaseCost = 3;
  249. uint16_t CacheLineSize = 0;
  250. uint16_t PrefetchDistance = 0;
  251. uint16_t MinPrefetchStride = 1;
  252. unsigned MaxPrefetchIterationsAhead = UINT_MAX;
  253. unsigned PrefFunctionLogAlignment = 0;
  254. unsigned PrefLoopLogAlignment = 0;
  255. unsigned MaxBytesForLoopAlignment = 0;
  256. unsigned MaxJumpTableSize = 0;
  257. unsigned WideningBaseCost = 0;
  258. // ReserveXRegister[i] - X#i is not available as a general purpose register.
  259. BitVector ReserveXRegister;
  260. // CustomCallUsedXRegister[i] - X#i call saved.
  261. BitVector CustomCallSavedXRegs;
  262. bool IsLittle;
  263. unsigned MinSVEVectorSizeInBits;
  264. unsigned MaxSVEVectorSizeInBits;
  265. unsigned VScaleForTuning = 2;
  266. /// TargetTriple - What processor and OS we're targeting.
  267. Triple TargetTriple;
  268. AArch64FrameLowering FrameLowering;
  269. AArch64InstrInfo InstrInfo;
  270. AArch64SelectionDAGInfo TSInfo;
  271. AArch64TargetLowering TLInfo;
  272. /// GlobalISel related APIs.
  273. std::unique_ptr<CallLowering> CallLoweringInfo;
  274. std::unique_ptr<InlineAsmLowering> InlineAsmLoweringInfo;
  275. std::unique_ptr<InstructionSelector> InstSelector;
  276. std::unique_ptr<LegalizerInfo> Legalizer;
  277. std::unique_ptr<RegisterBankInfo> RegBankInfo;
  278. private:
  279. /// initializeSubtargetDependencies - Initializes using CPUString and the
  280. /// passed in feature string so that we can use initializer lists for
  281. /// subtarget initialization.
  282. AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
  283. StringRef CPUString,
  284. StringRef TuneCPUString);
  285. /// Initialize properties based on the selected processor family.
  286. void initializeProperties();
  287. public:
  288. /// This constructor initializes the data members to match that
  289. /// of the specified triple.
  290. AArch64Subtarget(const Triple &TT, const std::string &CPU,
  291. const std::string &TuneCPU, const std::string &FS,
  292. const TargetMachine &TM, bool LittleEndian,
  293. unsigned MinSVEVectorSizeInBitsOverride = 0,
  294. unsigned MaxSVEVectorSizeInBitsOverride = 0);
  295. const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
  296. return &TSInfo;
  297. }
  298. const AArch64FrameLowering *getFrameLowering() const override {
  299. return &FrameLowering;
  300. }
  301. const AArch64TargetLowering *getTargetLowering() const override {
  302. return &TLInfo;
  303. }
  304. const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
  305. const AArch64RegisterInfo *getRegisterInfo() const override {
  306. return &getInstrInfo()->getRegisterInfo();
  307. }
  308. const CallLowering *getCallLowering() const override;
  309. const InlineAsmLowering *getInlineAsmLowering() const override;
  310. InstructionSelector *getInstructionSelector() const override;
  311. const LegalizerInfo *getLegalizerInfo() const override;
  312. const RegisterBankInfo *getRegBankInfo() const override;
  313. const Triple &getTargetTriple() const { return TargetTriple; }
  314. bool enableMachineScheduler() const override { return true; }
  315. bool enablePostRAScheduler() const override {
  316. return UsePostRAScheduler;
  317. }
  318. /// Returns ARM processor family.
  319. /// Avoid this function! CPU specifics should be kept local to this class
  320. /// and preferably modeled with SubtargetFeatures or properties in
  321. /// initializeProperties().
  322. ARMProcFamilyEnum getProcFamily() const {
  323. return ARMProcFamily;
  324. }
  325. bool hasV8_0aOps() const { return HasV8_0aOps; }
  326. bool hasV8_1aOps() const { return HasV8_1aOps; }
  327. bool hasV8_2aOps() const { return HasV8_2aOps; }
  328. bool hasV8_3aOps() const { return HasV8_3aOps; }
  329. bool hasV8_4aOps() const { return HasV8_4aOps; }
  330. bool hasV8_5aOps() const { return HasV8_5aOps; }
  331. bool hasV9_0aOps() const { return HasV9_0aOps; }
  332. bool hasV9_1aOps() const { return HasV9_1aOps; }
  333. bool hasV9_2aOps() const { return HasV9_2aOps; }
  334. bool hasV9_3aOps() const { return HasV9_3aOps; }
  335. bool hasV8_0rOps() const { return HasV8_0rOps; }
  336. bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
  337. bool hasZeroCycleZeroingGP() const { return HasZeroCycleZeroingGP; }
  338. bool hasZeroCycleZeroingFP() const { return HasZeroCycleZeroingFP; }
  339. bool hasZeroCycleZeroingFPWorkaround() const {
  340. return HasZeroCycleZeroingFPWorkaround;
  341. }
  342. bool requiresStrictAlign() const { return StrictAlign; }
  343. bool isXRaySupported() const override { return true; }
  344. unsigned getMinVectorRegisterBitWidth() const {
  345. return MinVectorRegisterBitWidth;
  346. }
  347. bool isXRegisterReserved(size_t i) const { return ReserveXRegister[i]; }
  348. unsigned getNumXRegisterReserved() const { return ReserveXRegister.count(); }
  349. bool isXRegCustomCalleeSaved(size_t i) const {
  350. return CustomCallSavedXRegs[i];
  351. }
  352. bool hasCustomCallingConv() const { return CustomCallSavedXRegs.any(); }
  353. bool hasFPARMv8() const { return HasFPARMv8; }
  354. bool hasNEON() const { return HasNEON; }
  355. bool hasCrypto() const { return HasCrypto; }
  356. bool hasDotProd() const { return HasDotProd; }
  357. bool hasCRC() const { return HasCRC; }
  358. bool hasLSE() const { return HasLSE; }
  359. bool hasLSE2() const { return HasLSE2; }
  360. bool hasRAS() const { return HasRAS; }
  361. bool hasRDM() const { return HasRDM; }
  362. bool hasSM4() const { return HasSM4; }
  363. bool hasSHA3() const { return HasSHA3; }
  364. bool hasSHA2() const { return HasSHA2; }
  365. bool hasAES() const { return HasAES; }
  366. bool hasCONTEXTIDREL2() const { return HasCONTEXTIDREL2; }
  367. bool balanceFPOps() const { return BalanceFPOps; }
  368. bool predictableSelectIsExpensive() const {
  369. return PredictableSelectIsExpensive;
  370. }
  371. bool hasCustomCheapAsMoveHandling() const { return CustomAsCheapAsMove; }
  372. bool hasExynosCheapAsMoveHandling() const { return ExynosAsCheapAsMove; }
  373. bool isMisaligned128StoreSlow() const { return Misaligned128StoreIsSlow; }
  374. bool isPaired128Slow() const { return Paired128IsSlow; }
  375. bool isSTRQroSlow() const { return STRQroIsSlow; }
  376. bool useAlternateSExtLoadCVTF32Pattern() const {
  377. return UseAlternateSExtLoadCVTF32Pattern;
  378. }
  379. bool hasArithmeticBccFusion() const { return HasArithmeticBccFusion; }
  380. bool hasArithmeticCbzFusion() const { return HasArithmeticCbzFusion; }
  381. bool hasCmpBccFusion() const { return HasCmpBccFusion; }
  382. bool hasFuseAddress() const { return HasFuseAddress; }
  383. bool hasFuseAES() const { return HasFuseAES; }
  384. bool hasFuseArithmeticLogic() const { return HasFuseArithmeticLogic; }
  385. bool hasFuseCCSelect() const { return HasFuseCCSelect; }
  386. bool hasFuseCryptoEOR() const { return HasFuseCryptoEOR; }
  387. bool hasFuseLiterals() const { return HasFuseLiterals; }
  388. /// Return true if the CPU supports any kind of instruction fusion.
  389. bool hasFusion() const {
  390. return hasArithmeticBccFusion() || hasArithmeticCbzFusion() ||
  391. hasFuseAES() || hasFuseArithmeticLogic() ||
  392. hasFuseCCSelect() || hasFuseLiterals();
  393. }
  394. bool hardenSlsRetBr() const { return HardenSlsRetBr; }
  395. bool hardenSlsBlr() const { return HardenSlsBlr; }
  396. bool hardenSlsNoComdat() const { return HardenSlsNoComdat; }
  397. bool useEL1ForTP() const { return UseEL1ForTP; }
  398. bool useEL2ForTP() const { return UseEL2ForTP; }
  399. bool useEL3ForTP() const { return UseEL3ForTP; }
  400. bool useRSqrt() const { return UseRSqrt; }
  401. bool force32BitJumpTables() const { return Force32BitJumpTables; }
  402. unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
  403. unsigned getVectorInsertExtractBaseCost() const {
  404. return VectorInsertExtractBaseCost;
  405. }
  406. unsigned getCacheLineSize() const override { return CacheLineSize; }
  407. unsigned getPrefetchDistance() const override { return PrefetchDistance; }
  408. unsigned getMinPrefetchStride(unsigned NumMemAccesses,
  409. unsigned NumStridedMemAccesses,
  410. unsigned NumPrefetches,
  411. bool HasCall) const override {
  412. return MinPrefetchStride;
  413. }
  414. unsigned getMaxPrefetchIterationsAhead() const override {
  415. return MaxPrefetchIterationsAhead;
  416. }
  417. unsigned getPrefFunctionLogAlignment() const {
  418. return PrefFunctionLogAlignment;
  419. }
  420. unsigned getPrefLoopLogAlignment() const { return PrefLoopLogAlignment; }
  421. unsigned getMaxBytesForLoopAlignment() const {
  422. return MaxBytesForLoopAlignment;
  423. }
  424. unsigned getMaximumJumpTableSize() const { return MaxJumpTableSize; }
  425. unsigned getWideningBaseCost() const { return WideningBaseCost; }
  426. bool useExperimentalZeroingPseudos() const {
  427. return UseExperimentalZeroingPseudos;
  428. }
  429. bool useScalarIncVL() const { return UseScalarIncVL; }
  430. /// CPU has TBI (top byte of addresses is ignored during HW address
  431. /// translation) and OS enables it.
  432. bool supportsAddressTopByteIgnored() const;
  433. bool hasPerfMon() const { return HasPerfMon; }
  434. bool hasFullFP16() const { return HasFullFP16; }
  435. bool hasFP16FML() const { return HasFP16FML; }
  436. bool hasSPE() const { return HasSPE; }
  437. bool hasLSLFast() const { return HasLSLFast; }
  438. bool hasSVE() const { return HasSVE; }
  439. bool hasSVE2() const { return HasSVE2; }
  440. bool hasRCPC() const { return HasRCPC; }
  441. bool hasAggressiveFMA() const { return HasAggressiveFMA; }
  442. bool hasAlternativeNZCV() const { return HasAlternativeNZCV; }
  443. bool hasFRInt3264() const { return HasFRInt3264; }
  444. bool hasSpecRestrict() const { return HasSpecRestrict; }
  445. bool hasSSBS() const { return HasSSBS; }
  446. bool hasSB() const { return HasSB; }
  447. bool hasPredRes() const { return HasPredRes; }
  448. bool hasCCDP() const { return HasCCDP; }
  449. bool hasBTI() const { return HasBTI; }
  450. bool hasRandGen() const { return HasRandGen; }
  451. bool hasMTE() const { return HasMTE; }
  452. bool hasTME() const { return HasTME; }
  453. // Arm SVE2 extensions
  454. bool hasSVE2AES() const { return HasSVE2AES; }
  455. bool hasSVE2SM4() const { return HasSVE2SM4; }
  456. bool hasSVE2SHA3() const { return HasSVE2SHA3; }
  457. bool hasSVE2BitPerm() const { return HasSVE2BitPerm; }
  458. bool hasMatMulInt8() const { return HasMatMulInt8; }
  459. bool hasMatMulFP32() const { return HasMatMulFP32; }
  460. bool hasMatMulFP64() const { return HasMatMulFP64; }
  461. // Armv8.6-A Extensions
  462. bool hasBF16() const { return HasBF16; }
  463. bool hasFineGrainedTraps() const { return HasFineGrainedTraps; }
  464. bool hasEnhancedCounterVirtualization() const {
  465. return HasEnhancedCounterVirtualization;
  466. }
  467. // Arm Scalable Matrix Extension (SME)
  468. bool hasSME() const { return HasSME; }
  469. bool hasSMEF64() const { return HasSMEF64; }
  470. bool hasSMEI64() const { return HasSMEI64; }
  471. bool hasStreamingSVE() const { return HasStreamingSVE; }
  472. bool isLittleEndian() const { return IsLittle; }
  473. bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
  474. bool isTargetIOS() const { return TargetTriple.isiOS(); }
  475. bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
  476. bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
  477. bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
  478. bool isTargetFuchsia() const { return TargetTriple.isOSFuchsia(); }
  479. bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
  480. bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
  481. bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
  482. bool isTargetILP32() const {
  483. return TargetTriple.isArch32Bit() ||
  484. TargetTriple.getEnvironment() == Triple::GNUILP32;
  485. }
  486. bool useAA() const override;
  487. bool outlineAtomics() const { return OutlineAtomics; }
  488. bool hasVH() const { return HasVH; }
  489. bool hasPAN() const { return HasPAN; }
  490. bool hasLOR() const { return HasLOR; }
  491. bool hasPsUAO() const { return HasPsUAO; }
  492. bool hasPAN_RWV() const { return HasPAN_RWV; }
  493. bool hasCCPP() const { return HasCCPP; }
  494. bool hasPAuth() const { return HasPAuth; }
  495. bool hasJS() const { return HasJS; }
  496. bool hasCCIDX() const { return HasCCIDX; }
  497. bool hasComplxNum() const { return HasComplxNum; }
  498. bool hasNV() const { return HasNV; }
  499. bool hasMPAM() const { return HasMPAM; }
  500. bool hasDIT() const { return HasDIT; }
  501. bool hasTRACEV8_4() const { return HasTRACEV8_4; }
  502. bool hasAM() const { return HasAM; }
  503. bool hasAMVS() const { return HasAMVS; }
  504. bool hasXS() const { return HasXS; }
  505. bool hasWFxT() const { return HasWFxT; }
  506. bool hasHCX() const { return HasHCX; }
  507. bool hasLS64() const { return HasLS64; }
  508. bool hasSEL2() const { return HasSEL2; }
  509. bool hasTLB_RMI() const { return HasTLB_RMI; }
  510. bool hasFlagM() const { return HasFlagM; }
  511. bool hasRCPC_IMMO() const { return HasRCPC_IMMO; }
  512. bool hasEL2VMSA() const { return HasEL2VMSA; }
  513. bool hasEL3() const { return HasEL3; }
  514. bool hasHBC() const { return HasHBC; }
  515. bool hasMOPS() const { return HasMOPS; }
  516. bool fixCortexA53_835769() const { return FixCortexA53_835769; }
  517. bool noBTIAtReturnTwice() const { return NoBTIAtReturnTwice; }
  518. bool addrSinkUsingGEPs() const override {
  519. // Keeping GEPs inbounds is important for exploiting AArch64
  520. // addressing-modes in ILP32 mode.
  521. return useAA() || isTargetILP32();
  522. }
  523. bool useSmallAddressing() const {
  524. switch (TLInfo.getTargetMachine().getCodeModel()) {
  525. case CodeModel::Kernel:
  526. // Kernel is currently allowed only for Fuchsia targets,
  527. // where it is the same as Small for almost all purposes.
  528. case CodeModel::Small:
  529. return true;
  530. default:
  531. return false;
  532. }
  533. }
  534. /// ParseSubtargetFeatures - Parses features string setting specified
  535. /// subtarget options. Definition of function is auto generated by tblgen.
  536. void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
  537. /// ClassifyGlobalReference - Find the target operand flags that describe
  538. /// how a global value should be referenced for the current subtarget.
  539. unsigned ClassifyGlobalReference(const GlobalValue *GV,
  540. const TargetMachine &TM) const;
  541. unsigned classifyGlobalFunctionReference(const GlobalValue *GV,
  542. const TargetMachine &TM) const;
  543. void overrideSchedPolicy(MachineSchedPolicy &Policy,
  544. unsigned NumRegionInstrs) const override;
  545. bool enableEarlyIfConversion() const override;
  546. bool enableAdvancedRASplitCost() const override { return false; }
  547. std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
  548. bool isCallingConvWin64(CallingConv::ID CC) const {
  549. switch (CC) {
  550. case CallingConv::C:
  551. case CallingConv::Fast:
  552. case CallingConv::Swift:
  553. return isTargetWindows();
  554. case CallingConv::Win64:
  555. return true;
  556. default:
  557. return false;
  558. }
  559. }
  560. /// Return whether FrameLowering should always set the "extended frame
  561. /// present" bit in FP, or set it based on a symbol in the runtime.
  562. bool swiftAsyncContextIsDynamicallySet() const {
  563. // Older OS versions (particularly system unwinders) are confused by the
  564. // Swift extended frame, so when building code that might be run on them we
  565. // must dynamically query the concurrency library to determine whether
  566. // extended frames should be flagged as present.
  567. const Triple &TT = getTargetTriple();
  568. unsigned Major = TT.getOSVersion().getMajor();
  569. switch(TT.getOS()) {
  570. default:
  571. return false;
  572. case Triple::IOS:
  573. case Triple::TvOS:
  574. return Major < 15;
  575. case Triple::WatchOS:
  576. return Major < 8;
  577. case Triple::MacOSX:
  578. case Triple::Darwin:
  579. return Major < 12;
  580. }
  581. }
  582. void mirFileLoaded(MachineFunction &MF) const override;
  583. // Return the known range for the bit length of SVE data registers. A value
  584. // of 0 means nothing is known about that particular limit beyong what's
  585. // implied by the architecture.
  586. unsigned getMaxSVEVectorSizeInBits() const {
  587. assert(HasSVE && "Tried to get SVE vector length without SVE support!");
  588. return MaxSVEVectorSizeInBits;
  589. }
  590. unsigned getMinSVEVectorSizeInBits() const {
  591. assert(HasSVE && "Tried to get SVE vector length without SVE support!");
  592. return MinSVEVectorSizeInBits;
  593. }
  594. bool useSVEForFixedLengthVectors() const {
  595. // Prefer NEON unless larger SVE registers are available.
  596. return hasSVE() && getMinSVEVectorSizeInBits() >= 256;
  597. }
  598. unsigned getVScaleForTuning() const { return VScaleForTuning; }
  599. };
  600. } // End llvm namespace
  601. #endif