PPCISelLowering.h 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. //===-- PPCISelLowering.h - PPC32 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 PPC uses to lower LLVM code into a
  10. // selection DAG.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H
  14. #define LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H
  15. #include "PPCInstrInfo.h"
  16. #include "llvm/CodeGen/CallingConvLower.h"
  17. #include "llvm/CodeGen/MachineFunction.h"
  18. #include "llvm/CodeGen/MachineMemOperand.h"
  19. #include "llvm/CodeGen/SelectionDAG.h"
  20. #include "llvm/CodeGen/SelectionDAGNodes.h"
  21. #include "llvm/CodeGen/TargetLowering.h"
  22. #include "llvm/CodeGen/ValueTypes.h"
  23. #include "llvm/IR/Attributes.h"
  24. #include "llvm/IR/CallingConv.h"
  25. #include "llvm/IR/Function.h"
  26. #include "llvm/IR/InlineAsm.h"
  27. #include "llvm/IR/Metadata.h"
  28. #include "llvm/IR/Type.h"
  29. #include "llvm/Support/MachineValueType.h"
  30. #include <utility>
  31. namespace llvm {
  32. namespace PPCISD {
  33. // When adding a NEW PPCISD node please add it to the correct position in
  34. // the enum. The order of elements in this enum matters!
  35. // Values that are added after this entry:
  36. // STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE
  37. // are considered memory opcodes and are treated differently than entries
  38. // that come before it. For example, ADD or MUL should be placed before
  39. // the ISD::FIRST_TARGET_MEMORY_OPCODE while a LOAD or STORE should come
  40. // after it.
  41. enum NodeType : unsigned {
  42. // Start the numbering where the builtin ops and target ops leave off.
  43. FIRST_NUMBER = ISD::BUILTIN_OP_END,
  44. /// FSEL - Traditional three-operand fsel node.
  45. ///
  46. FSEL,
  47. /// XSMAXCDP, XSMINCDP - C-type min/max instructions.
  48. XSMAXCDP,
  49. XSMINCDP,
  50. /// FCFID - The FCFID instruction, taking an f64 operand and producing
  51. /// and f64 value containing the FP representation of the integer that
  52. /// was temporarily in the f64 operand.
  53. FCFID,
  54. /// Newer FCFID[US] integer-to-floating-point conversion instructions for
  55. /// unsigned integers and single-precision outputs.
  56. FCFIDU,
  57. FCFIDS,
  58. FCFIDUS,
  59. /// FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64
  60. /// operand, producing an f64 value containing the integer representation
  61. /// of that FP value.
  62. FCTIDZ,
  63. FCTIWZ,
  64. /// Newer FCTI[D,W]UZ floating-point-to-integer conversion instructions for
  65. /// unsigned integers with round toward zero.
  66. FCTIDUZ,
  67. FCTIWUZ,
  68. /// Floating-point-to-interger conversion instructions
  69. FP_TO_UINT_IN_VSR,
  70. FP_TO_SINT_IN_VSR,
  71. /// VEXTS, ByteWidth - takes an input in VSFRC and produces an output in
  72. /// VSFRC that is sign-extended from ByteWidth to a 64-byte integer.
  73. VEXTS,
  74. /// Reciprocal estimate instructions (unary FP ops).
  75. FRE,
  76. FRSQRTE,
  77. /// Test instruction for software square root.
  78. FTSQRT,
  79. /// Square root instruction.
  80. FSQRT,
  81. /// VPERM - The PPC VPERM Instruction.
  82. ///
  83. VPERM,
  84. /// XXSPLT - The PPC VSX splat instructions
  85. ///
  86. XXSPLT,
  87. /// XXSPLTI_SP_TO_DP - The PPC VSX splat instructions for immediates for
  88. /// converting immediate single precision numbers to double precision
  89. /// vector or scalar.
  90. XXSPLTI_SP_TO_DP,
  91. /// XXSPLTI32DX - The PPC XXSPLTI32DX instruction.
  92. ///
  93. XXSPLTI32DX,
  94. /// VECINSERT - The PPC vector insert instruction
  95. ///
  96. VECINSERT,
  97. /// VECSHL - The PPC vector shift left instruction
  98. ///
  99. VECSHL,
  100. /// XXPERMDI - The PPC XXPERMDI instruction
  101. ///
  102. XXPERMDI,
  103. /// The CMPB instruction (takes two operands of i32 or i64).
  104. CMPB,
  105. /// Hi/Lo - These represent the high and low 16-bit parts of a global
  106. /// address respectively. These nodes have two operands, the first of
  107. /// which must be a TargetGlobalAddress, and the second of which must be a
  108. /// Constant. Selected naively, these turn into 'lis G+C' and 'li G+C',
  109. /// though these are usually folded into other nodes.
  110. Hi,
  111. Lo,
  112. /// The following two target-specific nodes are used for calls through
  113. /// function pointers in the 64-bit SVR4 ABI.
  114. /// OPRC, CHAIN = DYNALLOC(CHAIN, NEGSIZE, FRAME_INDEX)
  115. /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to
  116. /// compute an allocation on the stack.
  117. DYNALLOC,
  118. /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to
  119. /// compute an offset from native SP to the address of the most recent
  120. /// dynamic alloca.
  121. DYNAREAOFFSET,
  122. /// To avoid stack clash, allocation is performed by block and each block is
  123. /// probed.
  124. PROBED_ALLOCA,
  125. /// The result of the mflr at function entry, used for PIC code.
  126. GlobalBaseReg,
  127. /// These nodes represent PPC shifts.
  128. ///
  129. /// For scalar types, only the last `n + 1` bits of the shift amounts
  130. /// are used, where n is log2(sizeof(element) * 8). See sld/slw, etc.
  131. /// for exact behaviors.
  132. ///
  133. /// For vector types, only the last n bits are used. See vsld.
  134. SRL,
  135. SRA,
  136. SHL,
  137. /// FNMSUB - Negated multiply-subtract instruction.
  138. FNMSUB,
  139. /// EXTSWSLI = The PPC extswsli instruction, which does an extend-sign
  140. /// word and shift left immediate.
  141. EXTSWSLI,
  142. /// The combination of sra[wd]i and addze used to implemented signed
  143. /// integer division by a power of 2. The first operand is the dividend,
  144. /// and the second is the constant shift amount (representing the
  145. /// divisor).
  146. SRA_ADDZE,
  147. /// CALL - A direct function call.
  148. /// CALL_NOP is a call with the special NOP which follows 64-bit
  149. /// CALL_NOTOC the caller does not use the TOC.
  150. /// SVR4 calls and 32-bit/64-bit AIX calls.
  151. CALL,
  152. CALL_NOP,
  153. CALL_NOTOC,
  154. /// CHAIN,FLAG = MTCTR(VAL, CHAIN[, INFLAG]) - Directly corresponds to a
  155. /// MTCTR instruction.
  156. MTCTR,
  157. /// CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a
  158. /// BCTRL instruction.
  159. BCTRL,
  160. /// CHAIN,FLAG = BCTRL(CHAIN, ADDR, INFLAG) - The combination of a bctrl
  161. /// instruction and the TOC reload required on 64-bit ELF, 32-bit AIX
  162. /// and 64-bit AIX.
  163. BCTRL_LOAD_TOC,
  164. /// The variants that implicitly define rounding mode for calls with
  165. /// strictfp semantics.
  166. CALL_RM,
  167. CALL_NOP_RM,
  168. CALL_NOTOC_RM,
  169. BCTRL_RM,
  170. BCTRL_LOAD_TOC_RM,
  171. /// Return with a flag operand, matched by 'blr'
  172. RET_FLAG,
  173. /// R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction.
  174. /// This copies the bits corresponding to the specified CRREG into the
  175. /// resultant GPR. Bits corresponding to other CR regs are undefined.
  176. MFOCRF,
  177. /// Direct move from a VSX register to a GPR
  178. MFVSR,
  179. /// Direct move from a GPR to a VSX register (algebraic)
  180. MTVSRA,
  181. /// Direct move from a GPR to a VSX register (zero)
  182. MTVSRZ,
  183. /// Direct move of 2 consecutive GPR to a VSX register.
  184. BUILD_FP128,
  185. /// BUILD_SPE64 and EXTRACT_SPE are analogous to BUILD_PAIR and
  186. /// EXTRACT_ELEMENT but take f64 arguments instead of i64, as i64 is
  187. /// unsupported for this target.
  188. /// Merge 2 GPRs to a single SPE register.
  189. BUILD_SPE64,
  190. /// Extract SPE register component, second argument is high or low.
  191. EXTRACT_SPE,
  192. /// Extract a subvector from signed integer vector and convert to FP.
  193. /// It is primarily used to convert a (widened) illegal integer vector
  194. /// type to a legal floating point vector type.
  195. /// For example v2i32 -> widened to v4i32 -> v2f64
  196. SINT_VEC_TO_FP,
  197. /// Extract a subvector from unsigned integer vector and convert to FP.
  198. /// As with SINT_VEC_TO_FP, used for converting illegal types.
  199. UINT_VEC_TO_FP,
  200. /// PowerPC instructions that have SCALAR_TO_VECTOR semantics tend to
  201. /// place the value into the least significant element of the most
  202. /// significant doubleword in the vector. This is not element zero for
  203. /// anything smaller than a doubleword on either endianness. This node has
  204. /// the same semantics as SCALAR_TO_VECTOR except that the value remains in
  205. /// the aforementioned location in the vector register.
  206. SCALAR_TO_VECTOR_PERMUTED,
  207. // FIXME: Remove these once the ANDI glue bug is fixed:
  208. /// i1 = ANDI_rec_1_[EQ|GT]_BIT(i32 or i64 x) - Represents the result of the
  209. /// eq or gt bit of CR0 after executing andi. x, 1. This is used to
  210. /// implement truncation of i32 or i64 to i1.
  211. ANDI_rec_1_EQ_BIT,
  212. ANDI_rec_1_GT_BIT,
  213. // READ_TIME_BASE - A read of the 64-bit time-base register on a 32-bit
  214. // target (returns (Lo, Hi)). It takes a chain operand.
  215. READ_TIME_BASE,
  216. // EH_SJLJ_SETJMP - SjLj exception handling setjmp.
  217. EH_SJLJ_SETJMP,
  218. // EH_SJLJ_LONGJMP - SjLj exception handling longjmp.
  219. EH_SJLJ_LONGJMP,
  220. /// RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP*
  221. /// instructions. For lack of better number, we use the opcode number
  222. /// encoding for the OPC field to identify the compare. For example, 838
  223. /// is VCMPGTSH.
  224. VCMP,
  225. /// RESVEC, OUTFLAG = VCMP_rec(LHS, RHS, OPC) - Represents one of the
  226. /// altivec VCMP*_rec instructions. For lack of better number, we use the
  227. /// opcode number encoding for the OPC field to identify the compare. For
  228. /// example, 838 is VCMPGTSH.
  229. VCMP_rec,
  230. /// CHAIN = COND_BRANCH CHAIN, CRRC, OPC, DESTBB [, INFLAG] - This
  231. /// corresponds to the COND_BRANCH pseudo instruction. CRRC is the
  232. /// condition register to branch on, OPC is the branch opcode to use (e.g.
  233. /// PPC::BLE), DESTBB is the destination block to branch to, and INFLAG is
  234. /// an optional input flag argument.
  235. COND_BRANCH,
  236. /// CHAIN = BDNZ CHAIN, DESTBB - These are used to create counter-based
  237. /// loops.
  238. BDNZ,
  239. BDZ,
  240. /// F8RC = FADDRTZ F8RC, F8RC - This is an FADD done with rounding
  241. /// towards zero. Used only as part of the long double-to-int
  242. /// conversion sequence.
  243. FADDRTZ,
  244. /// F8RC = MFFS - This moves the FPSCR (not modeled) into the register.
  245. MFFS,
  246. /// TC_RETURN - A tail call return.
  247. /// operand #0 chain
  248. /// operand #1 callee (register or absolute)
  249. /// operand #2 stack adjustment
  250. /// operand #3 optional in flag
  251. TC_RETURN,
  252. /// ch, gl = CR6[UN]SET ch, inglue - Toggle CR bit 6 for SVR4 vararg calls
  253. CR6SET,
  254. CR6UNSET,
  255. /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by initial-exec TLS
  256. /// for non-position independent code on PPC32.
  257. PPC32_GOT,
  258. /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by general dynamic and
  259. /// local dynamic TLS and position indendepent code on PPC32.
  260. PPC32_PICGOT,
  261. /// G8RC = ADDIS_GOT_TPREL_HA %x2, Symbol - Used by the initial-exec
  262. /// TLS model, produces an ADDIS8 instruction that adds the GOT
  263. /// base to sym\@got\@tprel\@ha.
  264. ADDIS_GOT_TPREL_HA,
  265. /// G8RC = LD_GOT_TPREL_L Symbol, G8RReg - Used by the initial-exec
  266. /// TLS model, produces a LD instruction with base register G8RReg
  267. /// and offset sym\@got\@tprel\@l. This completes the addition that
  268. /// finds the offset of "sym" relative to the thread pointer.
  269. LD_GOT_TPREL_L,
  270. /// G8RC = ADD_TLS G8RReg, Symbol - Used by the initial-exec TLS
  271. /// model, produces an ADD instruction that adds the contents of
  272. /// G8RReg to the thread pointer. Symbol contains a relocation
  273. /// sym\@tls which is to be replaced by the thread pointer and
  274. /// identifies to the linker that the instruction is part of a
  275. /// TLS sequence.
  276. ADD_TLS,
  277. /// G8RC = ADDIS_TLSGD_HA %x2, Symbol - For the general-dynamic TLS
  278. /// model, produces an ADDIS8 instruction that adds the GOT base
  279. /// register to sym\@got\@tlsgd\@ha.
  280. ADDIS_TLSGD_HA,
  281. /// %x3 = ADDI_TLSGD_L G8RReg, Symbol - For the general-dynamic TLS
  282. /// model, produces an ADDI8 instruction that adds G8RReg to
  283. /// sym\@got\@tlsgd\@l and stores the result in X3. Hidden by
  284. /// ADDIS_TLSGD_L_ADDR until after register assignment.
  285. ADDI_TLSGD_L,
  286. /// %x3 = GET_TLS_ADDR %x3, Symbol - For the general-dynamic TLS
  287. /// model, produces a call to __tls_get_addr(sym\@tlsgd). Hidden by
  288. /// ADDIS_TLSGD_L_ADDR until after register assignment.
  289. GET_TLS_ADDR,
  290. /// G8RC = ADDI_TLSGD_L_ADDR G8RReg, Symbol, Symbol - Op that
  291. /// combines ADDI_TLSGD_L and GET_TLS_ADDR until expansion following
  292. /// register assignment.
  293. ADDI_TLSGD_L_ADDR,
  294. /// GPRC = TLSGD_AIX, TOC_ENTRY, TOC_ENTRY
  295. /// G8RC = TLSGD_AIX, TOC_ENTRY, TOC_ENTRY
  296. /// Op that combines two register copies of TOC entries
  297. /// (region handle into R3 and variable offset into R4) followed by a
  298. /// GET_TLS_ADDR node which will be expanded to a call to __get_tls_addr.
  299. /// This node is used in 64-bit mode as well (in which case the result is
  300. /// G8RC and inputs are X3/X4).
  301. TLSGD_AIX,
  302. /// G8RC = ADDIS_TLSLD_HA %x2, Symbol - For the local-dynamic TLS
  303. /// model, produces an ADDIS8 instruction that adds the GOT base
  304. /// register to sym\@got\@tlsld\@ha.
  305. ADDIS_TLSLD_HA,
  306. /// %x3 = ADDI_TLSLD_L G8RReg, Symbol - For the local-dynamic TLS
  307. /// model, produces an ADDI8 instruction that adds G8RReg to
  308. /// sym\@got\@tlsld\@l and stores the result in X3. Hidden by
  309. /// ADDIS_TLSLD_L_ADDR until after register assignment.
  310. ADDI_TLSLD_L,
  311. /// %x3 = GET_TLSLD_ADDR %x3, Symbol - For the local-dynamic TLS
  312. /// model, produces a call to __tls_get_addr(sym\@tlsld). Hidden by
  313. /// ADDIS_TLSLD_L_ADDR until after register assignment.
  314. GET_TLSLD_ADDR,
  315. /// G8RC = ADDI_TLSLD_L_ADDR G8RReg, Symbol, Symbol - Op that
  316. /// combines ADDI_TLSLD_L and GET_TLSLD_ADDR until expansion
  317. /// following register assignment.
  318. ADDI_TLSLD_L_ADDR,
  319. /// G8RC = ADDIS_DTPREL_HA %x3, Symbol - For the local-dynamic TLS
  320. /// model, produces an ADDIS8 instruction that adds X3 to
  321. /// sym\@dtprel\@ha.
  322. ADDIS_DTPREL_HA,
  323. /// G8RC = ADDI_DTPREL_L G8RReg, Symbol - For the local-dynamic TLS
  324. /// model, produces an ADDI8 instruction that adds G8RReg to
  325. /// sym\@got\@dtprel\@l.
  326. ADDI_DTPREL_L,
  327. /// G8RC = PADDI_DTPREL %x3, Symbol - For the pc-rel based local-dynamic TLS
  328. /// model, produces a PADDI8 instruction that adds X3 to sym\@dtprel.
  329. PADDI_DTPREL,
  330. /// VRRC = VADD_SPLAT Elt, EltSize - Temporary node to be expanded
  331. /// during instruction selection to optimize a BUILD_VECTOR into
  332. /// operations on splats. This is necessary to avoid losing these
  333. /// optimizations due to constant folding.
  334. VADD_SPLAT,
  335. /// CHAIN = SC CHAIN, Imm128 - System call. The 7-bit unsigned
  336. /// operand identifies the operating system entry point.
  337. SC,
  338. /// CHAIN = CLRBHRB CHAIN - Clear branch history rolling buffer.
  339. CLRBHRB,
  340. /// GPRC, CHAIN = MFBHRBE CHAIN, Entry, Dummy - Move from branch
  341. /// history rolling buffer entry.
  342. MFBHRBE,
  343. /// CHAIN = RFEBB CHAIN, State - Return from event-based branch.
  344. RFEBB,
  345. /// VSRC, CHAIN = XXSWAPD CHAIN, VSRC - Occurs only for little
  346. /// endian. Maps to an xxswapd instruction that corrects an lxvd2x
  347. /// or stxvd2x instruction. The chain is necessary because the
  348. /// sequence replaces a load and needs to provide the same number
  349. /// of outputs.
  350. XXSWAPD,
  351. /// An SDNode for swaps that are not associated with any loads/stores
  352. /// and thereby have no chain.
  353. SWAP_NO_CHAIN,
  354. /// An SDNode for Power9 vector absolute value difference.
  355. /// operand #0 vector
  356. /// operand #1 vector
  357. /// operand #2 constant i32 0 or 1, to indicate whether needs to patch
  358. /// the most significant bit for signed i32
  359. ///
  360. /// Power9 VABSD* instructions are designed to support unsigned integer
  361. /// vectors (byte/halfword/word), if we want to make use of them for signed
  362. /// integer vectors, we have to flip their sign bits first. To flip sign bit
  363. /// for byte/halfword integer vector would become inefficient, but for word
  364. /// integer vector, we can leverage XVNEGSP to make it efficiently. eg:
  365. /// abs(sub(a,b)) => VABSDUW(a+0x80000000, b+0x80000000)
  366. /// => VABSDUW((XVNEGSP a), (XVNEGSP b))
  367. VABSD,
  368. /// FP_EXTEND_HALF(VECTOR, IDX) - Custom extend upper (IDX=0) half or
  369. /// lower (IDX=1) half of v4f32 to v2f64.
  370. FP_EXTEND_HALF,
  371. /// MAT_PCREL_ADDR = Materialize a PC Relative address. This can be done
  372. /// either through an add like PADDI or through a PC Relative load like
  373. /// PLD.
  374. MAT_PCREL_ADDR,
  375. /// TLS_DYNAMIC_MAT_PCREL_ADDR = Materialize a PC Relative address for
  376. /// TLS global address when using dynamic access models. This can be done
  377. /// through an add like PADDI.
  378. TLS_DYNAMIC_MAT_PCREL_ADDR,
  379. /// TLS_LOCAL_EXEC_MAT_ADDR = Materialize an address for TLS global address
  380. /// when using local exec access models, and when prefixed instructions are
  381. /// available. This is used with ADD_TLS to produce an add like PADDI.
  382. TLS_LOCAL_EXEC_MAT_ADDR,
  383. /// ACC_BUILD = Build an accumulator register from 4 VSX registers.
  384. ACC_BUILD,
  385. /// PAIR_BUILD = Build a vector pair register from 2 VSX registers.
  386. PAIR_BUILD,
  387. /// EXTRACT_VSX_REG = Extract one of the underlying vsx registers of
  388. /// an accumulator or pair register. This node is needed because
  389. /// EXTRACT_SUBVECTOR expects the input and output vectors to have the same
  390. /// element type.
  391. EXTRACT_VSX_REG,
  392. /// XXMFACC = This corresponds to the xxmfacc instruction.
  393. XXMFACC,
  394. // Constrained conversion from floating point to int
  395. STRICT_FCTIDZ = ISD::FIRST_TARGET_STRICTFP_OPCODE,
  396. STRICT_FCTIWZ,
  397. STRICT_FCTIDUZ,
  398. STRICT_FCTIWUZ,
  399. /// Constrained integer-to-floating-point conversion instructions.
  400. STRICT_FCFID,
  401. STRICT_FCFIDU,
  402. STRICT_FCFIDS,
  403. STRICT_FCFIDUS,
  404. /// Constrained floating point add in round-to-zero mode.
  405. STRICT_FADDRTZ,
  406. // NOTE: The nodes below may require PC-Rel specific patterns if the
  407. // address could be PC-Relative. When adding new nodes below, consider
  408. // whether or not the address can be PC-Relative and add the corresponding
  409. // PC-relative patterns and tests.
  410. /// CHAIN = STBRX CHAIN, GPRC, Ptr, Type - This is a
  411. /// byte-swapping store instruction. It byte-swaps the low "Type" bits of
  412. /// the GPRC input, then stores it through Ptr. Type can be either i16 or
  413. /// i32.
  414. STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE,
  415. /// GPRC, CHAIN = LBRX CHAIN, Ptr, Type - This is a
  416. /// byte-swapping load instruction. It loads "Type" bits, byte swaps it,
  417. /// then puts it in the bottom bits of the GPRC. TYPE can be either i16
  418. /// or i32.
  419. LBRX,
  420. /// STFIWX - The STFIWX instruction. The first operand is an input token
  421. /// chain, then an f64 value to store, then an address to store it to.
  422. STFIWX,
  423. /// GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point
  424. /// load which sign-extends from a 32-bit integer value into the
  425. /// destination 64-bit register.
  426. LFIWAX,
  427. /// GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point
  428. /// load which zero-extends from a 32-bit integer value into the
  429. /// destination 64-bit register.
  430. LFIWZX,
  431. /// GPRC, CHAIN = LXSIZX, CHAIN, Ptr, ByteWidth - This is a load of an
  432. /// integer smaller than 64 bits into a VSR. The integer is zero-extended.
  433. /// This can be used for converting loaded integers to floating point.
  434. LXSIZX,
  435. /// STXSIX - The STXSI[bh]X instruction. The first operand is an input
  436. /// chain, then an f64 value to store, then an address to store it to,
  437. /// followed by a byte-width for the store.
  438. STXSIX,
  439. /// VSRC, CHAIN = LXVD2X_LE CHAIN, Ptr - Occurs only for little endian.
  440. /// Maps directly to an lxvd2x instruction that will be followed by
  441. /// an xxswapd.
  442. LXVD2X,
  443. /// LXVRZX - Load VSX Vector Rightmost and Zero Extend
  444. /// This node represents v1i128 BUILD_VECTOR of a zero extending load
  445. /// instruction from <byte, halfword, word, or doubleword> to i128.
  446. /// Allows utilization of the Load VSX Vector Rightmost Instructions.
  447. LXVRZX,
  448. /// VSRC, CHAIN = LOAD_VEC_BE CHAIN, Ptr - Occurs only for little endian.
  449. /// Maps directly to one of lxvd2x/lxvw4x/lxvh8x/lxvb16x depending on
  450. /// the vector type to load vector in big-endian element order.
  451. LOAD_VEC_BE,
  452. /// VSRC, CHAIN = LD_VSX_LH CHAIN, Ptr - This is a floating-point load of a
  453. /// v2f32 value into the lower half of a VSR register.
  454. LD_VSX_LH,
  455. /// VSRC, CHAIN = LD_SPLAT, CHAIN, Ptr - a splatting load memory
  456. /// instructions such as LXVDSX, LXVWSX.
  457. LD_SPLAT,
  458. /// VSRC, CHAIN = ZEXT_LD_SPLAT, CHAIN, Ptr - a splatting load memory
  459. /// that zero-extends.
  460. ZEXT_LD_SPLAT,
  461. /// VSRC, CHAIN = SEXT_LD_SPLAT, CHAIN, Ptr - a splatting load memory
  462. /// that sign-extends.
  463. SEXT_LD_SPLAT,
  464. /// CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian.
  465. /// Maps directly to an stxvd2x instruction that will be preceded by
  466. /// an xxswapd.
  467. STXVD2X,
  468. /// CHAIN = STORE_VEC_BE CHAIN, VSRC, Ptr - Occurs only for little endian.
  469. /// Maps directly to one of stxvd2x/stxvw4x/stxvh8x/stxvb16x depending on
  470. /// the vector type to store vector in big-endian element order.
  471. STORE_VEC_BE,
  472. /// Store scalar integers from VSR.
  473. ST_VSR_SCAL_INT,
  474. /// ATOMIC_CMP_SWAP - the exact same as the target-independent nodes
  475. /// except they ensure that the compare input is zero-extended for
  476. /// sub-word versions because the atomic loads zero-extend.
  477. ATOMIC_CMP_SWAP_8,
  478. ATOMIC_CMP_SWAP_16,
  479. /// GPRC = TOC_ENTRY GA, TOC
  480. /// Loads the entry for GA from the TOC, where the TOC base is given by
  481. /// the last operand.
  482. TOC_ENTRY
  483. };
  484. } // end namespace PPCISD
  485. /// Define some predicates that are used for node matching.
  486. namespace PPC {
  487. /// isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a
  488. /// VPKUHUM instruction.
  489. bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
  490. SelectionDAG &DAG);
  491. /// isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a
  492. /// VPKUWUM instruction.
  493. bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
  494. SelectionDAG &DAG);
  495. /// isVPKUDUMShuffleMask - Return true if this is the shuffle mask for a
  496. /// VPKUDUM instruction.
  497. bool isVPKUDUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
  498. SelectionDAG &DAG);
  499. /// isVMRGLShuffleMask - Return true if this is a shuffle mask suitable for
  500. /// a VRGL* instruction with the specified unit size (1,2 or 4 bytes).
  501. bool isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
  502. unsigned ShuffleKind, SelectionDAG &DAG);
  503. /// isVMRGHShuffleMask - Return true if this is a shuffle mask suitable for
  504. /// a VRGH* instruction with the specified unit size (1,2 or 4 bytes).
  505. bool isVMRGHShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
  506. unsigned ShuffleKind, SelectionDAG &DAG);
  507. /// isVMRGEOShuffleMask - Return true if this is a shuffle mask suitable for
  508. /// a VMRGEW or VMRGOW instruction
  509. bool isVMRGEOShuffleMask(ShuffleVectorSDNode *N, bool CheckEven,
  510. unsigned ShuffleKind, SelectionDAG &DAG);
  511. /// isXXSLDWIShuffleMask - Return true if this is a shuffle mask suitable
  512. /// for a XXSLDWI instruction.
  513. bool isXXSLDWIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts,
  514. bool &Swap, bool IsLE);
  515. /// isXXBRHShuffleMask - Return true if this is a shuffle mask suitable
  516. /// for a XXBRH instruction.
  517. bool isXXBRHShuffleMask(ShuffleVectorSDNode *N);
  518. /// isXXBRWShuffleMask - Return true if this is a shuffle mask suitable
  519. /// for a XXBRW instruction.
  520. bool isXXBRWShuffleMask(ShuffleVectorSDNode *N);
  521. /// isXXBRDShuffleMask - Return true if this is a shuffle mask suitable
  522. /// for a XXBRD instruction.
  523. bool isXXBRDShuffleMask(ShuffleVectorSDNode *N);
  524. /// isXXBRQShuffleMask - Return true if this is a shuffle mask suitable
  525. /// for a XXBRQ instruction.
  526. bool isXXBRQShuffleMask(ShuffleVectorSDNode *N);
  527. /// isXXPERMDIShuffleMask - Return true if this is a shuffle mask suitable
  528. /// for a XXPERMDI instruction.
  529. bool isXXPERMDIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts,
  530. bool &Swap, bool IsLE);
  531. /// isVSLDOIShuffleMask - If this is a vsldoi shuffle mask, return the
  532. /// shift amount, otherwise return -1.
  533. int isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind,
  534. SelectionDAG &DAG);
  535. /// isSplatShuffleMask - Return true if the specified VECTOR_SHUFFLE operand
  536. /// specifies a splat of a single element that is suitable for input to
  537. /// VSPLTB/VSPLTH/VSPLTW.
  538. bool isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize);
  539. /// isXXINSERTWMask - Return true if this VECTOR_SHUFFLE can be handled by
  540. /// the XXINSERTW instruction introduced in ISA 3.0. This is essentially any
  541. /// shuffle of v4f32/v4i32 vectors that just inserts one element from one
  542. /// vector into the other. This function will also set a couple of
  543. /// output parameters for how much the source vector needs to be shifted and
  544. /// what byte number needs to be specified for the instruction to put the
  545. /// element in the desired location of the target vector.
  546. bool isXXINSERTWMask(ShuffleVectorSDNode *N, unsigned &ShiftElts,
  547. unsigned &InsertAtByte, bool &Swap, bool IsLE);
  548. /// getSplatIdxForPPCMnemonics - Return the splat index as a value that is
  549. /// appropriate for PPC mnemonics (which have a big endian bias - namely
  550. /// elements are counted from the left of the vector register).
  551. unsigned getSplatIdxForPPCMnemonics(SDNode *N, unsigned EltSize,
  552. SelectionDAG &DAG);
  553. /// get_VSPLTI_elt - If this is a build_vector of constants which can be
  554. /// formed by using a vspltis[bhw] instruction of the specified element
  555. /// size, return the constant being splatted. The ByteSize field indicates
  556. /// the number of bytes of each element [124] -> [bhw].
  557. SDValue get_VSPLTI_elt(SDNode *N, unsigned ByteSize, SelectionDAG &DAG);
  558. // Flags for computing the optimal addressing mode for loads and stores.
  559. enum MemOpFlags {
  560. MOF_None = 0,
  561. // Extension mode for integer loads.
  562. MOF_SExt = 1,
  563. MOF_ZExt = 1 << 1,
  564. MOF_NoExt = 1 << 2,
  565. // Address computation flags.
  566. MOF_NotAddNorCst = 1 << 5, // Not const. or sum of ptr and scalar.
  567. MOF_RPlusSImm16 = 1 << 6, // Reg plus signed 16-bit constant.
  568. MOF_RPlusLo = 1 << 7, // Reg plus signed 16-bit relocation
  569. MOF_RPlusSImm16Mult4 = 1 << 8, // Reg plus 16-bit signed multiple of 4.
  570. MOF_RPlusSImm16Mult16 = 1 << 9, // Reg plus 16-bit signed multiple of 16.
  571. MOF_RPlusSImm34 = 1 << 10, // Reg plus 34-bit signed constant.
  572. MOF_RPlusR = 1 << 11, // Sum of two variables.
  573. MOF_PCRel = 1 << 12, // PC-Relative relocation.
  574. MOF_AddrIsSImm32 = 1 << 13, // A simple 32-bit constant.
  575. // The in-memory type.
  576. MOF_SubWordInt = 1 << 15,
  577. MOF_WordInt = 1 << 16,
  578. MOF_DoubleWordInt = 1 << 17,
  579. MOF_ScalarFloat = 1 << 18, // Scalar single or double precision.
  580. MOF_Vector = 1 << 19, // Vector types and quad precision scalars.
  581. MOF_Vector256 = 1 << 20,
  582. // Subtarget features.
  583. MOF_SubtargetBeforeP9 = 1 << 22,
  584. MOF_SubtargetP9 = 1 << 23,
  585. MOF_SubtargetP10 = 1 << 24,
  586. MOF_SubtargetSPE = 1 << 25
  587. };
  588. // The addressing modes for loads and stores.
  589. enum AddrMode {
  590. AM_None,
  591. AM_DForm,
  592. AM_DSForm,
  593. AM_DQForm,
  594. AM_PrefixDForm,
  595. AM_XForm,
  596. AM_PCRel
  597. };
  598. } // end namespace PPC
  599. class PPCTargetLowering : public TargetLowering {
  600. const PPCSubtarget &Subtarget;
  601. public:
  602. explicit PPCTargetLowering(const PPCTargetMachine &TM,
  603. const PPCSubtarget &STI);
  604. /// getTargetNodeName() - This method returns the name of a target specific
  605. /// DAG node.
  606. const char *getTargetNodeName(unsigned Opcode) const override;
  607. bool isSelectSupported(SelectSupportKind Kind) const override {
  608. // PowerPC does not support scalar condition selects on vectors.
  609. return (Kind != SelectSupportKind::ScalarCondVectorVal);
  610. }
  611. /// getPreferredVectorAction - The code we generate when vector types are
  612. /// legalized by promoting the integer element type is often much worse
  613. /// than code we generate if we widen the type for applicable vector types.
  614. /// The issue with promoting is that the vector is scalaraized, individual
  615. /// elements promoted and then the vector is rebuilt. So say we load a pair
  616. /// of v4i8's and shuffle them. This will turn into a mess of 8 extending
  617. /// loads, moves back into VSR's (or memory ops if we don't have moves) and
  618. /// then the VPERM for the shuffle. All in all a very slow sequence.
  619. TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT)
  620. const override {
  621. // Default handling for scalable and single-element vectors.
  622. if (VT.isScalableVector() || VT.getVectorNumElements() == 1)
  623. return TargetLoweringBase::getPreferredVectorAction(VT);
  624. // Split and promote vNi1 vectors so we don't produce v256i1/v512i1
  625. // types as those are only for MMA instructions.
  626. if (VT.getScalarSizeInBits() == 1 && VT.getSizeInBits() > 16)
  627. return TypeSplitVector;
  628. if (VT.getScalarSizeInBits() == 1)
  629. return TypePromoteInteger;
  630. // Widen vectors that have reasonably sized elements.
  631. if (VT.getScalarSizeInBits() % 8 == 0)
  632. return TypeWidenVector;
  633. return TargetLoweringBase::getPreferredVectorAction(VT);
  634. }
  635. bool useSoftFloat() const override;
  636. bool hasSPE() const;
  637. MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
  638. return MVT::i32;
  639. }
  640. bool isCheapToSpeculateCttz() const override {
  641. return true;
  642. }
  643. bool isCheapToSpeculateCtlz() const override {
  644. return true;
  645. }
  646. bool isCtlzFast() const override {
  647. return true;
  648. }
  649. bool isEqualityCmpFoldedWithSignedCmp() const override {
  650. return false;
  651. }
  652. bool hasAndNotCompare(SDValue) const override {
  653. return true;
  654. }
  655. bool preferIncOfAddToSubOfNot(EVT VT) const override;
  656. bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
  657. return VT.isScalarInteger();
  658. }
  659. SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOps,
  660. bool OptForSize, NegatibleCost &Cost,
  661. unsigned Depth = 0) const override;
  662. /// getSetCCResultType - Return the ISD::SETCC ValueType
  663. EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
  664. EVT VT) const override;
  665. /// Return true if target always benefits from combining into FMA for a
  666. /// given value type. This must typically return false on targets where FMA
  667. /// takes more cycles to execute than FADD.
  668. bool enableAggressiveFMAFusion(EVT VT) const override;
  669. /// getPreIndexedAddressParts - returns true by value, base pointer and
  670. /// offset pointer and addressing mode by reference if the node's address
  671. /// can be legally represented as pre-indexed load / store address.
  672. bool getPreIndexedAddressParts(SDNode *N, SDValue &Base,
  673. SDValue &Offset,
  674. ISD::MemIndexedMode &AM,
  675. SelectionDAG &DAG) const override;
  676. /// SelectAddressEVXRegReg - Given the specified addressed, check to see if
  677. /// it can be more efficiently represented as [r+imm].
  678. bool SelectAddressEVXRegReg(SDValue N, SDValue &Base, SDValue &Index,
  679. SelectionDAG &DAG) const;
  680. /// SelectAddressRegReg - Given the specified addressed, check to see if it
  681. /// can be more efficiently represented as [r+imm]. If \p EncodingAlignment
  682. /// is non-zero, only accept displacement which is not suitable for [r+imm].
  683. /// Returns false if it can be represented by [r+imm], which are preferred.
  684. bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index,
  685. SelectionDAG &DAG,
  686. MaybeAlign EncodingAlignment = None) const;
  687. /// SelectAddressRegImm - Returns true if the address N can be represented
  688. /// by a base register plus a signed 16-bit displacement [r+imm], and if it
  689. /// is not better represented as reg+reg. If \p EncodingAlignment is
  690. /// non-zero, only accept displacements suitable for instruction encoding
  691. /// requirement, i.e. multiples of 4 for DS form.
  692. bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base,
  693. SelectionDAG &DAG,
  694. MaybeAlign EncodingAlignment) const;
  695. bool SelectAddressRegImm34(SDValue N, SDValue &Disp, SDValue &Base,
  696. SelectionDAG &DAG) const;
  697. /// SelectAddressRegRegOnly - Given the specified addressed, force it to be
  698. /// represented as an indexed [r+r] operation.
  699. bool SelectAddressRegRegOnly(SDValue N, SDValue &Base, SDValue &Index,
  700. SelectionDAG &DAG) const;
  701. /// SelectAddressPCRel - Represent the specified address as pc relative to
  702. /// be represented as [pc+imm]
  703. bool SelectAddressPCRel(SDValue N, SDValue &Base) const;
  704. Sched::Preference getSchedulingPreference(SDNode *N) const override;
  705. /// LowerOperation - Provide custom lowering hooks for some operations.
  706. ///
  707. SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
  708. /// ReplaceNodeResults - Replace the results of node with an illegal result
  709. /// type with new values built out of custom code.
  710. ///
  711. void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
  712. SelectionDAG &DAG) const override;
  713. SDValue expandVSXLoadForLE(SDNode *N, DAGCombinerInfo &DCI) const;
  714. SDValue expandVSXStoreForLE(SDNode *N, DAGCombinerInfo &DCI) const;
  715. SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
  716. SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
  717. SmallVectorImpl<SDNode *> &Created) const override;
  718. Register getRegisterByName(const char* RegName, LLT VT,
  719. const MachineFunction &MF) const override;
  720. void computeKnownBitsForTargetNode(const SDValue Op,
  721. KnownBits &Known,
  722. const APInt &DemandedElts,
  723. const SelectionDAG &DAG,
  724. unsigned Depth = 0) const override;
  725. Align getPrefLoopAlignment(MachineLoop *ML) const override;
  726. bool shouldInsertFencesForAtomic(const Instruction *I) const override {
  727. return true;
  728. }
  729. Instruction *emitLeadingFence(IRBuilderBase &Builder, Instruction *Inst,
  730. AtomicOrdering Ord) const override;
  731. Instruction *emitTrailingFence(IRBuilderBase &Builder, Instruction *Inst,
  732. AtomicOrdering Ord) const override;
  733. TargetLowering::AtomicExpansionKind
  734. shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
  735. TargetLowering::AtomicExpansionKind
  736. shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
  737. Value *emitMaskedAtomicRMWIntrinsic(IRBuilderBase &Builder,
  738. AtomicRMWInst *AI, Value *AlignedAddr,
  739. Value *Incr, Value *Mask,
  740. Value *ShiftAmt,
  741. AtomicOrdering Ord) const override;
  742. Value *emitMaskedAtomicCmpXchgIntrinsic(IRBuilderBase &Builder,
  743. AtomicCmpXchgInst *CI,
  744. Value *AlignedAddr, Value *CmpVal,
  745. Value *NewVal, Value *Mask,
  746. AtomicOrdering Ord) const override;
  747. MachineBasicBlock *
  748. EmitInstrWithCustomInserter(MachineInstr &MI,
  749. MachineBasicBlock *MBB) const override;
  750. MachineBasicBlock *EmitAtomicBinary(MachineInstr &MI,
  751. MachineBasicBlock *MBB,
  752. unsigned AtomicSize,
  753. unsigned BinOpcode,
  754. unsigned CmpOpcode = 0,
  755. unsigned CmpPred = 0) const;
  756. MachineBasicBlock *EmitPartwordAtomicBinary(MachineInstr &MI,
  757. MachineBasicBlock *MBB,
  758. bool is8bit,
  759. unsigned Opcode,
  760. unsigned CmpOpcode = 0,
  761. unsigned CmpPred = 0) const;
  762. MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr &MI,
  763. MachineBasicBlock *MBB) const;
  764. MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr &MI,
  765. MachineBasicBlock *MBB) const;
  766. MachineBasicBlock *emitProbedAlloca(MachineInstr &MI,
  767. MachineBasicBlock *MBB) const;
  768. bool hasInlineStackProbe(MachineFunction &MF) const override;
  769. unsigned getStackProbeSize(MachineFunction &MF) const;
  770. ConstraintType getConstraintType(StringRef Constraint) const override;
  771. /// Examine constraint string and operand type and determine a weight value.
  772. /// The operand object must already have been set up with the operand type.
  773. ConstraintWeight getSingleConstraintMatchWeight(
  774. AsmOperandInfo &info, const char *constraint) const override;
  775. std::pair<unsigned, const TargetRegisterClass *>
  776. getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
  777. StringRef Constraint, MVT VT) const override;
  778. /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
  779. /// function arguments in the caller parameter area. This is the actual
  780. /// alignment, not its logarithm.
  781. uint64_t getByValTypeAlignment(Type *Ty,
  782. const DataLayout &DL) const override;
  783. /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
  784. /// vector. If it is invalid, don't add anything to Ops.
  785. void LowerAsmOperandForConstraint(SDValue Op,
  786. std::string &Constraint,
  787. std::vector<SDValue> &Ops,
  788. SelectionDAG &DAG) const override;
  789. unsigned
  790. getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
  791. if (ConstraintCode == "es")
  792. return InlineAsm::Constraint_es;
  793. else if (ConstraintCode == "Q")
  794. return InlineAsm::Constraint_Q;
  795. else if (ConstraintCode == "Z")
  796. return InlineAsm::Constraint_Z;
  797. else if (ConstraintCode == "Zy")
  798. return InlineAsm::Constraint_Zy;
  799. return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
  800. }
  801. /// isLegalAddressingMode - Return true if the addressing mode represented
  802. /// by AM is legal for this target, for a load/store of the specified type.
  803. bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
  804. Type *Ty, unsigned AS,
  805. Instruction *I = nullptr) const override;
  806. /// isLegalICmpImmediate - Return true if the specified immediate is legal
  807. /// icmp immediate, that is the target has icmp instructions which can
  808. /// compare a register against the immediate without having to materialize
  809. /// the immediate into a register.
  810. bool isLegalICmpImmediate(int64_t Imm) const override;
  811. /// isLegalAddImmediate - Return true if the specified immediate is legal
  812. /// add immediate, that is the target has add instructions which can
  813. /// add a register and the immediate without having to materialize
  814. /// the immediate into a register.
  815. bool isLegalAddImmediate(int64_t Imm) const override;
  816. /// isTruncateFree - Return true if it's free to truncate a value of
  817. /// type Ty1 to type Ty2. e.g. On PPC it's free to truncate a i64 value in
  818. /// register X1 to i32 by referencing its sub-register R1.
  819. bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
  820. bool isTruncateFree(EVT VT1, EVT VT2) const override;
  821. bool isZExtFree(SDValue Val, EVT VT2) const override;
  822. bool isFPExtFree(EVT DestVT, EVT SrcVT) const override;
  823. /// Returns true if it is beneficial to convert a load of a constant
  824. /// to just the constant itself.
  825. bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
  826. Type *Ty) const override;
  827. bool convertSelectOfConstantsToMath(EVT VT) const override {
  828. return true;
  829. }
  830. bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
  831. SDValue C) const override;
  832. bool isDesirableToTransformToIntegerOp(unsigned Opc,
  833. EVT VT) const override {
  834. // Only handle float load/store pair because float(fpr) load/store
  835. // instruction has more cycles than integer(gpr) load/store in PPC.
  836. if (Opc != ISD::LOAD && Opc != ISD::STORE)
  837. return false;
  838. if (VT != MVT::f32 && VT != MVT::f64)
  839. return false;
  840. return true;
  841. }
  842. // Returns true if the address of the global is stored in TOC entry.
  843. bool isAccessedAsGotIndirect(SDValue N) const;
  844. bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
  845. bool getTgtMemIntrinsic(IntrinsicInfo &Info,
  846. const CallInst &I,
  847. MachineFunction &MF,
  848. unsigned Intrinsic) const override;
  849. /// It returns EVT::Other if the type should be determined using generic
  850. /// target-independent logic.
  851. EVT getOptimalMemOpType(const MemOp &Op,
  852. const AttributeList &FuncAttributes) const override;
  853. /// Is unaligned memory access allowed for the given type, and is it fast
  854. /// relative to software emulation.
  855. bool allowsMisalignedMemoryAccesses(
  856. EVT VT, unsigned AddrSpace, Align Alignment = Align(1),
  857. MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
  858. bool *Fast = nullptr) const override;
  859. /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
  860. /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
  861. /// expanded to FMAs when this method returns true, otherwise fmuladd is
  862. /// expanded to fmul + fadd.
  863. bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
  864. EVT VT) const override;
  865. bool isFMAFasterThanFMulAndFAdd(const Function &F, Type *Ty) const override;
  866. /// isProfitableToHoist - Check if it is profitable to hoist instruction
  867. /// \p I to its dominator block.
  868. /// For example, it is not profitable if \p I and it's only user can form a
  869. /// FMA instruction, because Powerpc prefers FMADD.
  870. bool isProfitableToHoist(Instruction *I) const override;
  871. const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;
  872. // Should we expand the build vector with shuffles?
  873. bool
  874. shouldExpandBuildVectorWithShuffles(EVT VT,
  875. unsigned DefinedValues) const override;
  876. // Keep the zero-extensions for arguments to libcalls.
  877. bool shouldKeepZExtForFP16Conv() const override { return true; }
  878. /// createFastISel - This method returns a target-specific FastISel object,
  879. /// or null if the target does not support "fast" instruction selection.
  880. FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
  881. const TargetLibraryInfo *LibInfo) const override;
  882. /// Returns true if an argument of type Ty needs to be passed in a
  883. /// contiguous block of registers in calling convention CallConv.
  884. bool functionArgumentNeedsConsecutiveRegisters(
  885. Type *Ty, CallingConv::ID CallConv, bool isVarArg,
  886. const DataLayout &DL) const override {
  887. // We support any array type as "consecutive" block in the parameter
  888. // save area. The element type defines the alignment requirement and
  889. // whether the argument should go in GPRs, FPRs, or VRs if available.
  890. //
  891. // Note that clang uses this capability both to implement the ELFv2
  892. // homogeneous float/vector aggregate ABI, and to avoid having to use
  893. // "byval" when passing aggregates that might fully fit in registers.
  894. return Ty->isArrayTy();
  895. }
  896. /// If a physical register, this returns the register that receives the
  897. /// exception address on entry to an EH pad.
  898. Register
  899. getExceptionPointerRegister(const Constant *PersonalityFn) const override;
  900. /// If a physical register, this returns the register that receives the
  901. /// exception typeid on entry to a landing pad.
  902. Register
  903. getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
  904. /// Override to support customized stack guard loading.
  905. bool useLoadStackGuardNode() const override;
  906. void insertSSPDeclarations(Module &M) const override;
  907. Value *getSDagStackGuard(const Module &M) const override;
  908. bool isFPImmLegal(const APFloat &Imm, EVT VT,
  909. bool ForCodeSize) const override;
  910. unsigned getJumpTableEncoding() const override;
  911. bool isJumpTableRelative() const override;
  912. SDValue getPICJumpTableRelocBase(SDValue Table,
  913. SelectionDAG &DAG) const override;
  914. const MCExpr *getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
  915. unsigned JTI,
  916. MCContext &Ctx) const override;
  917. /// SelectOptimalAddrMode - Based on a node N and it's Parent (a MemSDNode),
  918. /// compute the address flags of the node, get the optimal address mode
  919. /// based on the flags, and set the Base and Disp based on the address mode.
  920. PPC::AddrMode SelectOptimalAddrMode(const SDNode *Parent, SDValue N,
  921. SDValue &Disp, SDValue &Base,
  922. SelectionDAG &DAG,
  923. MaybeAlign Align) const;
  924. /// SelectForceXFormMode - Given the specified address, force it to be
  925. /// represented as an indexed [r+r] operation (an XForm instruction).
  926. PPC::AddrMode SelectForceXFormMode(SDValue N, SDValue &Disp, SDValue &Base,
  927. SelectionDAG &DAG) const;
  928. bool
  929. splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val,
  930. SDValue *Parts, unsigned NumParts, MVT PartVT,
  931. Optional<CallingConv::ID> CC) const override;
  932. /// Structure that collects some common arguments that get passed around
  933. /// between the functions for call lowering.
  934. struct CallFlags {
  935. const CallingConv::ID CallConv;
  936. const bool IsTailCall : 1;
  937. const bool IsVarArg : 1;
  938. const bool IsPatchPoint : 1;
  939. const bool IsIndirect : 1;
  940. const bool HasNest : 1;
  941. const bool NoMerge : 1;
  942. CallFlags(CallingConv::ID CC, bool IsTailCall, bool IsVarArg,
  943. bool IsPatchPoint, bool IsIndirect, bool HasNest, bool NoMerge)
  944. : CallConv(CC), IsTailCall(IsTailCall), IsVarArg(IsVarArg),
  945. IsPatchPoint(IsPatchPoint), IsIndirect(IsIndirect),
  946. HasNest(HasNest), NoMerge(NoMerge) {}
  947. };
  948. CCAssignFn *ccAssignFnForCall(CallingConv::ID CC, bool Return,
  949. bool IsVarArg) const;
  950. private:
  951. struct ReuseLoadInfo {
  952. SDValue Ptr;
  953. SDValue Chain;
  954. SDValue ResChain;
  955. MachinePointerInfo MPI;
  956. bool IsDereferenceable = false;
  957. bool IsInvariant = false;
  958. Align Alignment;
  959. AAMDNodes AAInfo;
  960. const MDNode *Ranges = nullptr;
  961. ReuseLoadInfo() = default;
  962. MachineMemOperand::Flags MMOFlags() const {
  963. MachineMemOperand::Flags F = MachineMemOperand::MONone;
  964. if (IsDereferenceable)
  965. F |= MachineMemOperand::MODereferenceable;
  966. if (IsInvariant)
  967. F |= MachineMemOperand::MOInvariant;
  968. return F;
  969. }
  970. };
  971. // Map that relates a set of common address flags to PPC addressing modes.
  972. std::map<PPC::AddrMode, SmallVector<unsigned, 16>> AddrModesMap;
  973. void initializeAddrModeMap();
  974. bool canReuseLoadAddress(SDValue Op, EVT MemVT, ReuseLoadInfo &RLI,
  975. SelectionDAG &DAG,
  976. ISD::LoadExtType ET = ISD::NON_EXTLOAD) const;
  977. void spliceIntoChain(SDValue ResChain, SDValue NewResChain,
  978. SelectionDAG &DAG) const;
  979. void LowerFP_TO_INTForReuse(SDValue Op, ReuseLoadInfo &RLI,
  980. SelectionDAG &DAG, const SDLoc &dl) const;
  981. SDValue LowerFP_TO_INTDirectMove(SDValue Op, SelectionDAG &DAG,
  982. const SDLoc &dl) const;
  983. bool directMoveIsProfitable(const SDValue &Op) const;
  984. SDValue LowerINT_TO_FPDirectMove(SDValue Op, SelectionDAG &DAG,
  985. const SDLoc &dl) const;
  986. SDValue LowerINT_TO_FPVector(SDValue Op, SelectionDAG &DAG,
  987. const SDLoc &dl) const;
  988. SDValue LowerTRUNCATEVector(SDValue Op, SelectionDAG &DAG) const;
  989. SDValue getFramePointerFrameIndex(SelectionDAG & DAG) const;
  990. SDValue getReturnAddrFrameIndex(SelectionDAG & DAG) const;
  991. bool
  992. IsEligibleForTailCallOptimization(SDValue Callee,
  993. CallingConv::ID CalleeCC,
  994. bool isVarArg,
  995. const SmallVectorImpl<ISD::InputArg> &Ins,
  996. SelectionDAG& DAG) const;
  997. bool IsEligibleForTailCallOptimization_64SVR4(
  998. SDValue Callee, CallingConv::ID CalleeCC, const CallBase *CB,
  999. bool isVarArg, const SmallVectorImpl<ISD::OutputArg> &Outs,
  1000. const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG &DAG) const;
  1001. SDValue EmitTailCallLoadFPAndRetAddr(SelectionDAG &DAG, int SPDiff,
  1002. SDValue Chain, SDValue &LROpOut,
  1003. SDValue &FPOpOut,
  1004. const SDLoc &dl) const;
  1005. SDValue getTOCEntry(SelectionDAG &DAG, const SDLoc &dl, SDValue GA) const;
  1006. SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
  1007. SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
  1008. SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
  1009. SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
  1010. SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
  1011. SDValue LowerGlobalTLSAddressAIX(SDValue Op, SelectionDAG &DAG) const;
  1012. SDValue LowerGlobalTLSAddressLinux(SDValue Op, SelectionDAG &DAG) const;
  1013. SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
  1014. SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
  1015. SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
  1016. SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
  1017. SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
  1018. SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
  1019. SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
  1020. SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
  1021. SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
  1022. SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
  1023. SDValue LowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const;
  1024. SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
  1025. SDValue LowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const;
  1026. SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
  1027. SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
  1028. SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const;
  1029. SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
  1030. SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG,
  1031. const SDLoc &dl) const;
  1032. SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
  1033. SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
  1034. SDValue LowerSHL_PARTS(SDValue Op, SelectionDAG &DAG) const;
  1035. SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const;
  1036. SDValue LowerSRA_PARTS(SDValue Op, SelectionDAG &DAG) const;
  1037. SDValue LowerFunnelShift(SDValue Op, SelectionDAG &DAG) const;
  1038. SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
  1039. SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
  1040. SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
  1041. SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
  1042. SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
  1043. SDValue LowerBSWAP(SDValue Op, SelectionDAG &DAG) const;
  1044. SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
  1045. SDValue LowerATOMIC_LOAD_STORE(SDValue Op, SelectionDAG &DAG) const;
  1046. SDValue LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
  1047. SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const;
  1048. SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
  1049. SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
  1050. SDValue LowerROTL(SDValue Op, SelectionDAG &DAG) const;
  1051. SDValue LowerVectorLoad(SDValue Op, SelectionDAG &DAG) const;
  1052. SDValue LowerVectorStore(SDValue Op, SelectionDAG &DAG) const;
  1053. SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
  1054. CallingConv::ID CallConv, bool isVarArg,
  1055. const SmallVectorImpl<ISD::InputArg> &Ins,
  1056. const SDLoc &dl, SelectionDAG &DAG,
  1057. SmallVectorImpl<SDValue> &InVals) const;
  1058. SDValue FinishCall(CallFlags CFlags, const SDLoc &dl, SelectionDAG &DAG,
  1059. SmallVector<std::pair<unsigned, SDValue>, 8> &RegsToPass,
  1060. SDValue InFlag, SDValue Chain, SDValue CallSeqStart,
  1061. SDValue &Callee, int SPDiff, unsigned NumBytes,
  1062. const SmallVectorImpl<ISD::InputArg> &Ins,
  1063. SmallVectorImpl<SDValue> &InVals,
  1064. const CallBase *CB) const;
  1065. SDValue
  1066. LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
  1067. const SmallVectorImpl<ISD::InputArg> &Ins,
  1068. const SDLoc &dl, SelectionDAG &DAG,
  1069. SmallVectorImpl<SDValue> &InVals) const override;
  1070. SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
  1071. SmallVectorImpl<SDValue> &InVals) const override;
  1072. bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
  1073. bool isVarArg,
  1074. const SmallVectorImpl<ISD::OutputArg> &Outs,
  1075. LLVMContext &Context) const override;
  1076. SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
  1077. const SmallVectorImpl<ISD::OutputArg> &Outs,
  1078. const SmallVectorImpl<SDValue> &OutVals,
  1079. const SDLoc &dl, SelectionDAG &DAG) const override;
  1080. SDValue extendArgForPPC64(ISD::ArgFlagsTy Flags, EVT ObjectVT,
  1081. SelectionDAG &DAG, SDValue ArgVal,
  1082. const SDLoc &dl) const;
  1083. SDValue LowerFormalArguments_AIX(
  1084. SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
  1085. const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
  1086. SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const;
  1087. SDValue LowerFormalArguments_64SVR4(
  1088. SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
  1089. const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
  1090. SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const;
  1091. SDValue LowerFormalArguments_32SVR4(
  1092. SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
  1093. const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
  1094. SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const;
  1095. SDValue createMemcpyOutsideCallSeq(SDValue Arg, SDValue PtrOff,
  1096. SDValue CallSeqStart,
  1097. ISD::ArgFlagsTy Flags, SelectionDAG &DAG,
  1098. const SDLoc &dl) const;
  1099. SDValue LowerCall_64SVR4(SDValue Chain, SDValue Callee, CallFlags CFlags,
  1100. const SmallVectorImpl<ISD::OutputArg> &Outs,
  1101. const SmallVectorImpl<SDValue> &OutVals,
  1102. const SmallVectorImpl<ISD::InputArg> &Ins,
  1103. const SDLoc &dl, SelectionDAG &DAG,
  1104. SmallVectorImpl<SDValue> &InVals,
  1105. const CallBase *CB) const;
  1106. SDValue LowerCall_32SVR4(SDValue Chain, SDValue Callee, CallFlags CFlags,
  1107. const SmallVectorImpl<ISD::OutputArg> &Outs,
  1108. const SmallVectorImpl<SDValue> &OutVals,
  1109. const SmallVectorImpl<ISD::InputArg> &Ins,
  1110. const SDLoc &dl, SelectionDAG &DAG,
  1111. SmallVectorImpl<SDValue> &InVals,
  1112. const CallBase *CB) const;
  1113. SDValue LowerCall_AIX(SDValue Chain, SDValue Callee, CallFlags CFlags,
  1114. const SmallVectorImpl<ISD::OutputArg> &Outs,
  1115. const SmallVectorImpl<SDValue> &OutVals,
  1116. const SmallVectorImpl<ISD::InputArg> &Ins,
  1117. const SDLoc &dl, SelectionDAG &DAG,
  1118. SmallVectorImpl<SDValue> &InVals,
  1119. const CallBase *CB) const;
  1120. SDValue lowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
  1121. SDValue lowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
  1122. SDValue LowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
  1123. SDValue DAGCombineExtBoolTrunc(SDNode *N, DAGCombinerInfo &DCI) const;
  1124. SDValue DAGCombineBuildVector(SDNode *N, DAGCombinerInfo &DCI) const;
  1125. SDValue DAGCombineTruncBoolExt(SDNode *N, DAGCombinerInfo &DCI) const;
  1126. SDValue combineStoreFPToInt(SDNode *N, DAGCombinerInfo &DCI) const;
  1127. SDValue combineFPToIntToFP(SDNode *N, DAGCombinerInfo &DCI) const;
  1128. SDValue combineSHL(SDNode *N, DAGCombinerInfo &DCI) const;
  1129. SDValue combineSRA(SDNode *N, DAGCombinerInfo &DCI) const;
  1130. SDValue combineSRL(SDNode *N, DAGCombinerInfo &DCI) const;
  1131. SDValue combineMUL(SDNode *N, DAGCombinerInfo &DCI) const;
  1132. SDValue combineADD(SDNode *N, DAGCombinerInfo &DCI) const;
  1133. SDValue combineFMALike(SDNode *N, DAGCombinerInfo &DCI) const;
  1134. SDValue combineTRUNCATE(SDNode *N, DAGCombinerInfo &DCI) const;
  1135. SDValue combineSetCC(SDNode *N, DAGCombinerInfo &DCI) const;
  1136. SDValue combineABS(SDNode *N, DAGCombinerInfo &DCI) const;
  1137. SDValue combineVSelect(SDNode *N, DAGCombinerInfo &DCI) const;
  1138. SDValue combineVectorShuffle(ShuffleVectorSDNode *SVN,
  1139. SelectionDAG &DAG) const;
  1140. SDValue combineVReverseMemOP(ShuffleVectorSDNode *SVN, LSBaseSDNode *LSBase,
  1141. DAGCombinerInfo &DCI) const;
  1142. /// ConvertSETCCToSubtract - looks at SETCC that compares ints. It replaces
  1143. /// SETCC with integer subtraction when (1) there is a legal way of doing it
  1144. /// (2) keeping the result of comparison in GPR has performance benefit.
  1145. SDValue ConvertSETCCToSubtract(SDNode *N, DAGCombinerInfo &DCI) const;
  1146. SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled,
  1147. int &RefinementSteps, bool &UseOneConstNR,
  1148. bool Reciprocal) const override;
  1149. SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled,
  1150. int &RefinementSteps) const override;
  1151. SDValue getSqrtInputTest(SDValue Operand, SelectionDAG &DAG,
  1152. const DenormalMode &Mode) const override;
  1153. SDValue getSqrtResultForDenormInput(SDValue Operand,
  1154. SelectionDAG &DAG) const override;
  1155. unsigned combineRepeatedFPDivisors() const override;
  1156. SDValue
  1157. combineElementTruncationToVectorTruncation(SDNode *N,
  1158. DAGCombinerInfo &DCI) const;
  1159. /// lowerToVINSERTH - Return the SDValue if this VECTOR_SHUFFLE can be
  1160. /// handled by the VINSERTH instruction introduced in ISA 3.0. This is
  1161. /// essentially any shuffle of v8i16 vectors that just inserts one element
  1162. /// from one vector into the other.
  1163. SDValue lowerToVINSERTH(ShuffleVectorSDNode *N, SelectionDAG &DAG) const;
  1164. /// lowerToVINSERTB - Return the SDValue if this VECTOR_SHUFFLE can be
  1165. /// handled by the VINSERTB instruction introduced in ISA 3.0. This is
  1166. /// essentially v16i8 vector version of VINSERTH.
  1167. SDValue lowerToVINSERTB(ShuffleVectorSDNode *N, SelectionDAG &DAG) const;
  1168. /// lowerToXXSPLTI32DX - Return the SDValue if this VECTOR_SHUFFLE can be
  1169. /// handled by the XXSPLTI32DX instruction introduced in ISA 3.1.
  1170. SDValue lowerToXXSPLTI32DX(ShuffleVectorSDNode *N, SelectionDAG &DAG) const;
  1171. // Return whether the call instruction can potentially be optimized to a
  1172. // tail call. This will cause the optimizers to attempt to move, or
  1173. // duplicate return instructions to help enable tail call optimizations.
  1174. bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
  1175. bool hasBitPreservingFPLogic(EVT VT) const override;
  1176. bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override;
  1177. /// getAddrModeForFlags - Based on the set of address flags, select the most
  1178. /// optimal instruction format to match by.
  1179. PPC::AddrMode getAddrModeForFlags(unsigned Flags) const;
  1180. /// computeMOFlags - Given a node N and it's Parent (a MemSDNode), compute
  1181. /// the address flags of the load/store instruction that is to be matched.
  1182. /// The address flags are stored in a map, which is then searched
  1183. /// through to determine the optimal load/store instruction format.
  1184. unsigned computeMOFlags(const SDNode *Parent, SDValue N,
  1185. SelectionDAG &DAG) const;
  1186. }; // end class PPCTargetLowering
  1187. namespace PPC {
  1188. FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
  1189. const TargetLibraryInfo *LibInfo);
  1190. } // end namespace PPC
  1191. bool isIntS16Immediate(SDNode *N, int16_t &Imm);
  1192. bool isIntS16Immediate(SDValue Op, int16_t &Imm);
  1193. bool isIntS34Immediate(SDNode *N, int64_t &Imm);
  1194. bool isIntS34Immediate(SDValue Op, int64_t &Imm);
  1195. bool convertToNonDenormSingle(APInt &ArgAPInt);
  1196. bool convertToNonDenormSingle(APFloat &ArgAPFloat);
  1197. bool checkConvertToNonDenormSingle(APFloat &ArgAPFloat);
  1198. } // end namespace llvm
  1199. #endif // LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H