NVPTXISelLowering.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. //===-- NVPTXISelLowering.h - NVPTX DAG Lowering Interface ------*- 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 defines the interfaces that NVPTX uses to lower LLVM code into a
  10. // selection DAG.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXISELLOWERING_H
  14. #define LLVM_LIB_TARGET_NVPTX_NVPTXISELLOWERING_H
  15. #include "NVPTX.h"
  16. #include "llvm/CodeGen/SelectionDAG.h"
  17. #include "llvm/CodeGen/TargetLowering.h"
  18. namespace llvm {
  19. namespace NVPTXISD {
  20. enum NodeType : unsigned {
  21. // Start the numbering from where ISD NodeType finishes.
  22. FIRST_NUMBER = ISD::BUILTIN_OP_END,
  23. Wrapper,
  24. CALL,
  25. RET_FLAG,
  26. LOAD_PARAM,
  27. DeclareParam,
  28. DeclareScalarParam,
  29. DeclareRetParam,
  30. DeclareRet,
  31. DeclareScalarRet,
  32. PrintCall,
  33. PrintConvergentCall,
  34. PrintCallUni,
  35. PrintConvergentCallUni,
  36. CallArgBegin,
  37. CallArg,
  38. LastCallArg,
  39. CallArgEnd,
  40. CallVoid,
  41. CallVal,
  42. CallSymbol,
  43. Prototype,
  44. MoveParam,
  45. PseudoUseParam,
  46. RETURN,
  47. CallSeqBegin,
  48. CallSeqEnd,
  49. CallPrototype,
  50. ProxyReg,
  51. FUN_SHFL_CLAMP,
  52. FUN_SHFR_CLAMP,
  53. MUL_WIDE_SIGNED,
  54. MUL_WIDE_UNSIGNED,
  55. IMAD,
  56. SETP_F16X2,
  57. Dummy,
  58. LoadV2 = ISD::FIRST_TARGET_MEMORY_OPCODE,
  59. LoadV4,
  60. LDGV2, // LDG.v2
  61. LDGV4, // LDG.v4
  62. LDUV2, // LDU.v2
  63. LDUV4, // LDU.v4
  64. StoreV2,
  65. StoreV4,
  66. LoadParam,
  67. LoadParamV2,
  68. LoadParamV4,
  69. StoreParam,
  70. StoreParamV2,
  71. StoreParamV4,
  72. StoreParamS32, // to sext and store a <32bit value, not used currently
  73. StoreParamU32, // to zext and store a <32bit value, not used currently
  74. StoreRetval,
  75. StoreRetvalV2,
  76. StoreRetvalV4,
  77. // Texture intrinsics
  78. Tex1DFloatS32,
  79. Tex1DFloatFloat,
  80. Tex1DFloatFloatLevel,
  81. Tex1DFloatFloatGrad,
  82. Tex1DS32S32,
  83. Tex1DS32Float,
  84. Tex1DS32FloatLevel,
  85. Tex1DS32FloatGrad,
  86. Tex1DU32S32,
  87. Tex1DU32Float,
  88. Tex1DU32FloatLevel,
  89. Tex1DU32FloatGrad,
  90. Tex1DArrayFloatS32,
  91. Tex1DArrayFloatFloat,
  92. Tex1DArrayFloatFloatLevel,
  93. Tex1DArrayFloatFloatGrad,
  94. Tex1DArrayS32S32,
  95. Tex1DArrayS32Float,
  96. Tex1DArrayS32FloatLevel,
  97. Tex1DArrayS32FloatGrad,
  98. Tex1DArrayU32S32,
  99. Tex1DArrayU32Float,
  100. Tex1DArrayU32FloatLevel,
  101. Tex1DArrayU32FloatGrad,
  102. Tex2DFloatS32,
  103. Tex2DFloatFloat,
  104. Tex2DFloatFloatLevel,
  105. Tex2DFloatFloatGrad,
  106. Tex2DS32S32,
  107. Tex2DS32Float,
  108. Tex2DS32FloatLevel,
  109. Tex2DS32FloatGrad,
  110. Tex2DU32S32,
  111. Tex2DU32Float,
  112. Tex2DU32FloatLevel,
  113. Tex2DU32FloatGrad,
  114. Tex2DArrayFloatS32,
  115. Tex2DArrayFloatFloat,
  116. Tex2DArrayFloatFloatLevel,
  117. Tex2DArrayFloatFloatGrad,
  118. Tex2DArrayS32S32,
  119. Tex2DArrayS32Float,
  120. Tex2DArrayS32FloatLevel,
  121. Tex2DArrayS32FloatGrad,
  122. Tex2DArrayU32S32,
  123. Tex2DArrayU32Float,
  124. Tex2DArrayU32FloatLevel,
  125. Tex2DArrayU32FloatGrad,
  126. Tex3DFloatS32,
  127. Tex3DFloatFloat,
  128. Tex3DFloatFloatLevel,
  129. Tex3DFloatFloatGrad,
  130. Tex3DS32S32,
  131. Tex3DS32Float,
  132. Tex3DS32FloatLevel,
  133. Tex3DS32FloatGrad,
  134. Tex3DU32S32,
  135. Tex3DU32Float,
  136. Tex3DU32FloatLevel,
  137. Tex3DU32FloatGrad,
  138. TexCubeFloatFloat,
  139. TexCubeFloatFloatLevel,
  140. TexCubeS32Float,
  141. TexCubeS32FloatLevel,
  142. TexCubeU32Float,
  143. TexCubeU32FloatLevel,
  144. TexCubeArrayFloatFloat,
  145. TexCubeArrayFloatFloatLevel,
  146. TexCubeArrayS32Float,
  147. TexCubeArrayS32FloatLevel,
  148. TexCubeArrayU32Float,
  149. TexCubeArrayU32FloatLevel,
  150. Tld4R2DFloatFloat,
  151. Tld4G2DFloatFloat,
  152. Tld4B2DFloatFloat,
  153. Tld4A2DFloatFloat,
  154. Tld4R2DS64Float,
  155. Tld4G2DS64Float,
  156. Tld4B2DS64Float,
  157. Tld4A2DS64Float,
  158. Tld4R2DU64Float,
  159. Tld4G2DU64Float,
  160. Tld4B2DU64Float,
  161. Tld4A2DU64Float,
  162. TexUnified1DFloatS32,
  163. TexUnified1DFloatFloat,
  164. TexUnified1DFloatFloatLevel,
  165. TexUnified1DFloatFloatGrad,
  166. TexUnified1DS32S32,
  167. TexUnified1DS32Float,
  168. TexUnified1DS32FloatLevel,
  169. TexUnified1DS32FloatGrad,
  170. TexUnified1DU32S32,
  171. TexUnified1DU32Float,
  172. TexUnified1DU32FloatLevel,
  173. TexUnified1DU32FloatGrad,
  174. TexUnified1DArrayFloatS32,
  175. TexUnified1DArrayFloatFloat,
  176. TexUnified1DArrayFloatFloatLevel,
  177. TexUnified1DArrayFloatFloatGrad,
  178. TexUnified1DArrayS32S32,
  179. TexUnified1DArrayS32Float,
  180. TexUnified1DArrayS32FloatLevel,
  181. TexUnified1DArrayS32FloatGrad,
  182. TexUnified1DArrayU32S32,
  183. TexUnified1DArrayU32Float,
  184. TexUnified1DArrayU32FloatLevel,
  185. TexUnified1DArrayU32FloatGrad,
  186. TexUnified2DFloatS32,
  187. TexUnified2DFloatFloat,
  188. TexUnified2DFloatFloatLevel,
  189. TexUnified2DFloatFloatGrad,
  190. TexUnified2DS32S32,
  191. TexUnified2DS32Float,
  192. TexUnified2DS32FloatLevel,
  193. TexUnified2DS32FloatGrad,
  194. TexUnified2DU32S32,
  195. TexUnified2DU32Float,
  196. TexUnified2DU32FloatLevel,
  197. TexUnified2DU32FloatGrad,
  198. TexUnified2DArrayFloatS32,
  199. TexUnified2DArrayFloatFloat,
  200. TexUnified2DArrayFloatFloatLevel,
  201. TexUnified2DArrayFloatFloatGrad,
  202. TexUnified2DArrayS32S32,
  203. TexUnified2DArrayS32Float,
  204. TexUnified2DArrayS32FloatLevel,
  205. TexUnified2DArrayS32FloatGrad,
  206. TexUnified2DArrayU32S32,
  207. TexUnified2DArrayU32Float,
  208. TexUnified2DArrayU32FloatLevel,
  209. TexUnified2DArrayU32FloatGrad,
  210. TexUnified3DFloatS32,
  211. TexUnified3DFloatFloat,
  212. TexUnified3DFloatFloatLevel,
  213. TexUnified3DFloatFloatGrad,
  214. TexUnified3DS32S32,
  215. TexUnified3DS32Float,
  216. TexUnified3DS32FloatLevel,
  217. TexUnified3DS32FloatGrad,
  218. TexUnified3DU32S32,
  219. TexUnified3DU32Float,
  220. TexUnified3DU32FloatLevel,
  221. TexUnified3DU32FloatGrad,
  222. TexUnifiedCubeFloatFloat,
  223. TexUnifiedCubeFloatFloatLevel,
  224. TexUnifiedCubeS32Float,
  225. TexUnifiedCubeS32FloatLevel,
  226. TexUnifiedCubeU32Float,
  227. TexUnifiedCubeU32FloatLevel,
  228. TexUnifiedCubeArrayFloatFloat,
  229. TexUnifiedCubeArrayFloatFloatLevel,
  230. TexUnifiedCubeArrayS32Float,
  231. TexUnifiedCubeArrayS32FloatLevel,
  232. TexUnifiedCubeArrayU32Float,
  233. TexUnifiedCubeArrayU32FloatLevel,
  234. Tld4UnifiedR2DFloatFloat,
  235. Tld4UnifiedG2DFloatFloat,
  236. Tld4UnifiedB2DFloatFloat,
  237. Tld4UnifiedA2DFloatFloat,
  238. Tld4UnifiedR2DS64Float,
  239. Tld4UnifiedG2DS64Float,
  240. Tld4UnifiedB2DS64Float,
  241. Tld4UnifiedA2DS64Float,
  242. Tld4UnifiedR2DU64Float,
  243. Tld4UnifiedG2DU64Float,
  244. Tld4UnifiedB2DU64Float,
  245. Tld4UnifiedA2DU64Float,
  246. // Surface intrinsics
  247. Suld1DI8Clamp,
  248. Suld1DI16Clamp,
  249. Suld1DI32Clamp,
  250. Suld1DI64Clamp,
  251. Suld1DV2I8Clamp,
  252. Suld1DV2I16Clamp,
  253. Suld1DV2I32Clamp,
  254. Suld1DV2I64Clamp,
  255. Suld1DV4I8Clamp,
  256. Suld1DV4I16Clamp,
  257. Suld1DV4I32Clamp,
  258. Suld1DArrayI8Clamp,
  259. Suld1DArrayI16Clamp,
  260. Suld1DArrayI32Clamp,
  261. Suld1DArrayI64Clamp,
  262. Suld1DArrayV2I8Clamp,
  263. Suld1DArrayV2I16Clamp,
  264. Suld1DArrayV2I32Clamp,
  265. Suld1DArrayV2I64Clamp,
  266. Suld1DArrayV4I8Clamp,
  267. Suld1DArrayV4I16Clamp,
  268. Suld1DArrayV4I32Clamp,
  269. Suld2DI8Clamp,
  270. Suld2DI16Clamp,
  271. Suld2DI32Clamp,
  272. Suld2DI64Clamp,
  273. Suld2DV2I8Clamp,
  274. Suld2DV2I16Clamp,
  275. Suld2DV2I32Clamp,
  276. Suld2DV2I64Clamp,
  277. Suld2DV4I8Clamp,
  278. Suld2DV4I16Clamp,
  279. Suld2DV4I32Clamp,
  280. Suld2DArrayI8Clamp,
  281. Suld2DArrayI16Clamp,
  282. Suld2DArrayI32Clamp,
  283. Suld2DArrayI64Clamp,
  284. Suld2DArrayV2I8Clamp,
  285. Suld2DArrayV2I16Clamp,
  286. Suld2DArrayV2I32Clamp,
  287. Suld2DArrayV2I64Clamp,
  288. Suld2DArrayV4I8Clamp,
  289. Suld2DArrayV4I16Clamp,
  290. Suld2DArrayV4I32Clamp,
  291. Suld3DI8Clamp,
  292. Suld3DI16Clamp,
  293. Suld3DI32Clamp,
  294. Suld3DI64Clamp,
  295. Suld3DV2I8Clamp,
  296. Suld3DV2I16Clamp,
  297. Suld3DV2I32Clamp,
  298. Suld3DV2I64Clamp,
  299. Suld3DV4I8Clamp,
  300. Suld3DV4I16Clamp,
  301. Suld3DV4I32Clamp,
  302. Suld1DI8Trap,
  303. Suld1DI16Trap,
  304. Suld1DI32Trap,
  305. Suld1DI64Trap,
  306. Suld1DV2I8Trap,
  307. Suld1DV2I16Trap,
  308. Suld1DV2I32Trap,
  309. Suld1DV2I64Trap,
  310. Suld1DV4I8Trap,
  311. Suld1DV4I16Trap,
  312. Suld1DV4I32Trap,
  313. Suld1DArrayI8Trap,
  314. Suld1DArrayI16Trap,
  315. Suld1DArrayI32Trap,
  316. Suld1DArrayI64Trap,
  317. Suld1DArrayV2I8Trap,
  318. Suld1DArrayV2I16Trap,
  319. Suld1DArrayV2I32Trap,
  320. Suld1DArrayV2I64Trap,
  321. Suld1DArrayV4I8Trap,
  322. Suld1DArrayV4I16Trap,
  323. Suld1DArrayV4I32Trap,
  324. Suld2DI8Trap,
  325. Suld2DI16Trap,
  326. Suld2DI32Trap,
  327. Suld2DI64Trap,
  328. Suld2DV2I8Trap,
  329. Suld2DV2I16Trap,
  330. Suld2DV2I32Trap,
  331. Suld2DV2I64Trap,
  332. Suld2DV4I8Trap,
  333. Suld2DV4I16Trap,
  334. Suld2DV4I32Trap,
  335. Suld2DArrayI8Trap,
  336. Suld2DArrayI16Trap,
  337. Suld2DArrayI32Trap,
  338. Suld2DArrayI64Trap,
  339. Suld2DArrayV2I8Trap,
  340. Suld2DArrayV2I16Trap,
  341. Suld2DArrayV2I32Trap,
  342. Suld2DArrayV2I64Trap,
  343. Suld2DArrayV4I8Trap,
  344. Suld2DArrayV4I16Trap,
  345. Suld2DArrayV4I32Trap,
  346. Suld3DI8Trap,
  347. Suld3DI16Trap,
  348. Suld3DI32Trap,
  349. Suld3DI64Trap,
  350. Suld3DV2I8Trap,
  351. Suld3DV2I16Trap,
  352. Suld3DV2I32Trap,
  353. Suld3DV2I64Trap,
  354. Suld3DV4I8Trap,
  355. Suld3DV4I16Trap,
  356. Suld3DV4I32Trap,
  357. Suld1DI8Zero,
  358. Suld1DI16Zero,
  359. Suld1DI32Zero,
  360. Suld1DI64Zero,
  361. Suld1DV2I8Zero,
  362. Suld1DV2I16Zero,
  363. Suld1DV2I32Zero,
  364. Suld1DV2I64Zero,
  365. Suld1DV4I8Zero,
  366. Suld1DV4I16Zero,
  367. Suld1DV4I32Zero,
  368. Suld1DArrayI8Zero,
  369. Suld1DArrayI16Zero,
  370. Suld1DArrayI32Zero,
  371. Suld1DArrayI64Zero,
  372. Suld1DArrayV2I8Zero,
  373. Suld1DArrayV2I16Zero,
  374. Suld1DArrayV2I32Zero,
  375. Suld1DArrayV2I64Zero,
  376. Suld1DArrayV4I8Zero,
  377. Suld1DArrayV4I16Zero,
  378. Suld1DArrayV4I32Zero,
  379. Suld2DI8Zero,
  380. Suld2DI16Zero,
  381. Suld2DI32Zero,
  382. Suld2DI64Zero,
  383. Suld2DV2I8Zero,
  384. Suld2DV2I16Zero,
  385. Suld2DV2I32Zero,
  386. Suld2DV2I64Zero,
  387. Suld2DV4I8Zero,
  388. Suld2DV4I16Zero,
  389. Suld2DV4I32Zero,
  390. Suld2DArrayI8Zero,
  391. Suld2DArrayI16Zero,
  392. Suld2DArrayI32Zero,
  393. Suld2DArrayI64Zero,
  394. Suld2DArrayV2I8Zero,
  395. Suld2DArrayV2I16Zero,
  396. Suld2DArrayV2I32Zero,
  397. Suld2DArrayV2I64Zero,
  398. Suld2DArrayV4I8Zero,
  399. Suld2DArrayV4I16Zero,
  400. Suld2DArrayV4I32Zero,
  401. Suld3DI8Zero,
  402. Suld3DI16Zero,
  403. Suld3DI32Zero,
  404. Suld3DI64Zero,
  405. Suld3DV2I8Zero,
  406. Suld3DV2I16Zero,
  407. Suld3DV2I32Zero,
  408. Suld3DV2I64Zero,
  409. Suld3DV4I8Zero,
  410. Suld3DV4I16Zero,
  411. Suld3DV4I32Zero
  412. };
  413. }
  414. class NVPTXSubtarget;
  415. //===--------------------------------------------------------------------===//
  416. // TargetLowering Implementation
  417. //===--------------------------------------------------------------------===//
  418. class NVPTXTargetLowering : public TargetLowering {
  419. public:
  420. explicit NVPTXTargetLowering(const NVPTXTargetMachine &TM,
  421. const NVPTXSubtarget &STI);
  422. SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
  423. SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
  424. const char *getTargetNodeName(unsigned Opcode) const override;
  425. bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
  426. MachineFunction &MF,
  427. unsigned Intrinsic) const override;
  428. /// getFunctionParamOptimizedAlign - since function arguments are passed via
  429. /// .param space, we may want to increase their alignment in a way that
  430. /// ensures that we can effectively vectorize their loads & stores. We can
  431. /// increase alignment only if the function has internal or has private
  432. /// linkage as for other linkage types callers may already rely on default
  433. /// alignment. To allow using 128-bit vectorized loads/stores, this function
  434. /// ensures that alignment is 16 or greater.
  435. Align getFunctionParamOptimizedAlign(const Function *F, Type *ArgTy,
  436. const DataLayout &DL) const;
  437. /// Helper for computing alignment of a device function byval parameter.
  438. Align getFunctionByValParamAlign(const Function *F, Type *ArgTy,
  439. Align InitialAlign,
  440. const DataLayout &DL) const;
  441. /// isLegalAddressingMode - Return true if the addressing mode represented
  442. /// by AM is legal for this target, for a load/store of the specified type
  443. /// Used to guide target specific optimizations, like loop strength
  444. /// reduction (LoopStrengthReduce.cpp) and memory optimization for
  445. /// address mode (CodeGenPrepare.cpp)
  446. bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
  447. unsigned AS,
  448. Instruction *I = nullptr) const override;
  449. bool isTruncateFree(Type *SrcTy, Type *DstTy) const override {
  450. // Truncating 64-bit to 32-bit is free in SASS.
  451. if (!SrcTy->isIntegerTy() || !DstTy->isIntegerTy())
  452. return false;
  453. return SrcTy->getPrimitiveSizeInBits() == 64 &&
  454. DstTy->getPrimitiveSizeInBits() == 32;
  455. }
  456. EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Ctx,
  457. EVT VT) const override {
  458. if (VT.isVector())
  459. return EVT::getVectorVT(Ctx, MVT::i1, VT.getVectorNumElements());
  460. return MVT::i1;
  461. }
  462. ConstraintType getConstraintType(StringRef Constraint) const override;
  463. std::pair<unsigned, const TargetRegisterClass *>
  464. getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
  465. StringRef Constraint, MVT VT) const override;
  466. SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
  467. bool isVarArg,
  468. const SmallVectorImpl<ISD::InputArg> &Ins,
  469. const SDLoc &dl, SelectionDAG &DAG,
  470. SmallVectorImpl<SDValue> &InVals) const override;
  471. SDValue LowerCall(CallLoweringInfo &CLI,
  472. SmallVectorImpl<SDValue> &InVals) const override;
  473. std::string
  474. getPrototype(const DataLayout &DL, Type *, const ArgListTy &,
  475. const SmallVectorImpl<ISD::OutputArg> &, MaybeAlign retAlignment,
  476. std::optional<std::pair<unsigned, const APInt &>> VAInfo,
  477. const CallBase &CB, unsigned UniqueCallSite) const;
  478. SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
  479. const SmallVectorImpl<ISD::OutputArg> &Outs,
  480. const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
  481. SelectionDAG &DAG) const override;
  482. void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
  483. std::vector<SDValue> &Ops,
  484. SelectionDAG &DAG) const override;
  485. const NVPTXTargetMachine *nvTM;
  486. // PTX always uses 32-bit shift amounts
  487. MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
  488. return MVT::i32;
  489. }
  490. TargetLoweringBase::LegalizeTypeAction
  491. getPreferredVectorAction(MVT VT) const override;
  492. // Get the degree of precision we want from 32-bit floating point division
  493. // operations.
  494. //
  495. // 0 - Use ptx div.approx
  496. // 1 - Use ptx.div.full (approximate, but less so than div.approx)
  497. // 2 - Use IEEE-compliant div instructions, if available.
  498. int getDivF32Level() const;
  499. // Get whether we should use a precise or approximate 32-bit floating point
  500. // sqrt instruction.
  501. bool usePrecSqrtF32() const;
  502. // Get whether we should use instructions that flush floating-point denormals
  503. // to sign-preserving zero.
  504. bool useF32FTZ(const MachineFunction &MF) const;
  505. SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled,
  506. int &ExtraSteps, bool &UseOneConst,
  507. bool Reciprocal) const override;
  508. unsigned combineRepeatedFPDivisors() const override { return 2; }
  509. bool allowFMA(MachineFunction &MF, CodeGenOpt::Level OptLevel) const;
  510. bool allowUnsafeFPMath(MachineFunction &MF) const;
  511. bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
  512. EVT) const override {
  513. return true;
  514. }
  515. bool enableAggressiveFMAFusion(EVT VT) const override { return true; }
  516. // The default is to transform llvm.ctlz(x, false) (where false indicates that
  517. // x == 0 is not undefined behavior) into a branch that checks whether x is 0
  518. // and avoids calling ctlz in that case. We have a dedicated ctlz
  519. // instruction, so we say that ctlz is cheap to speculate.
  520. bool isCheapToSpeculateCtlz(Type *Ty) const override { return true; }
  521. AtomicExpansionKind shouldCastAtomicLoadInIR(LoadInst *LI) const override {
  522. return AtomicExpansionKind::None;
  523. }
  524. AtomicExpansionKind shouldCastAtomicStoreInIR(StoreInst *SI) const override {
  525. return AtomicExpansionKind::None;
  526. }
  527. AtomicExpansionKind
  528. shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
  529. private:
  530. const NVPTXSubtarget &STI; // cache the subtarget here
  531. SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
  532. SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
  533. SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
  534. SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
  535. SDValue LowerFROUND(SDValue Op, SelectionDAG &DAG) const;
  536. SDValue LowerFROUND32(SDValue Op, SelectionDAG &DAG) const;
  537. SDValue LowerFROUND64(SDValue Op, SelectionDAG &DAG) const;
  538. SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
  539. SDValue LowerLOADi1(SDValue Op, SelectionDAG &DAG) const;
  540. SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
  541. SDValue LowerSTOREi1(SDValue Op, SelectionDAG &DAG) const;
  542. SDValue LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const;
  543. SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
  544. SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
  545. SDValue LowerSelect(SDValue Op, SelectionDAG &DAG) const;
  546. SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
  547. SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
  548. void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
  549. SelectionDAG &DAG) const override;
  550. SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
  551. Align getArgumentAlignment(SDValue Callee, const CallBase *CB, Type *Ty,
  552. unsigned Idx, const DataLayout &DL) const;
  553. };
  554. } // namespace llvm
  555. #endif