[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / llvm / lib / Target / PowerPC / PPCISelLowering.h
blobe08b16367d62667e731dea48ad0ffceef6ecbac6
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.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H
15 #define LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H
17 #include "PPCInstrInfo.h"
18 #include "llvm/CodeGen/CallingConvLower.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/CodeGen/MachineMemOperand.h"
21 #include "llvm/CodeGen/SelectionDAG.h"
22 #include "llvm/CodeGen/SelectionDAGNodes.h"
23 #include "llvm/CodeGen/TargetLowering.h"
24 #include "llvm/CodeGen/ValueTypes.h"
25 #include "llvm/IR/Attributes.h"
26 #include "llvm/IR/CallingConv.h"
27 #include "llvm/IR/Function.h"
28 #include "llvm/IR/InlineAsm.h"
29 #include "llvm/IR/Metadata.h"
30 #include "llvm/IR/Type.h"
31 #include "llvm/Support/MachineValueType.h"
32 #include <utility>
34 namespace llvm {
36 namespace PPCISD {
38 // When adding a NEW PPCISD node please add it to the correct position in
39 // the enum. The order of elements in this enum matters!
40 // Values that are added after this entry:
41 // STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE
42 // are considered memory opcodes and are treated differently than entries
43 // that come before it. For example, ADD or MUL should be placed before
44 // the ISD::FIRST_TARGET_MEMORY_OPCODE while a LOAD or STORE should come
45 // after it.
46 enum NodeType : unsigned {
47 // Start the numbering where the builtin ops and target ops leave off.
48 FIRST_NUMBER = ISD::BUILTIN_OP_END,
50 /// FSEL - Traditional three-operand fsel node.
51 ///
52 FSEL,
54 /// XSMAXCDP, XSMINCDP - C-type min/max instructions.
55 XSMAXCDP,
56 XSMINCDP,
58 /// FCFID - The FCFID instruction, taking an f64 operand and producing
59 /// and f64 value containing the FP representation of the integer that
60 /// was temporarily in the f64 operand.
61 FCFID,
63 /// Newer FCFID[US] integer-to-floating-point conversion instructions for
64 /// unsigned integers and single-precision outputs.
65 FCFIDU,
66 FCFIDS,
67 FCFIDUS,
69 /// FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64
70 /// operand, producing an f64 value containing the integer representation
71 /// of that FP value.
72 FCTIDZ,
73 FCTIWZ,
75 /// Newer FCTI[D,W]UZ floating-point-to-integer conversion instructions for
76 /// unsigned integers with round toward zero.
77 FCTIDUZ,
78 FCTIWUZ,
80 /// Floating-point-to-interger conversion instructions
81 FP_TO_UINT_IN_VSR,
82 FP_TO_SINT_IN_VSR,
84 /// VEXTS, ByteWidth - takes an input in VSFRC and produces an output in
85 /// VSFRC that is sign-extended from ByteWidth to a 64-byte integer.
86 VEXTS,
88 /// SExtVElems, takes an input vector of a smaller type and sign
89 /// extends to an output vector of a larger type.
90 SExtVElems,
92 /// Reciprocal estimate instructions (unary FP ops).
93 FRE,
94 FRSQRTE,
96 // VMADDFP, VNMSUBFP - The VMADDFP and VNMSUBFP instructions, taking
97 // three v4f32 operands and producing a v4f32 result.
98 VMADDFP,
99 VNMSUBFP,
101 /// VPERM - The PPC VPERM Instruction.
103 VPERM,
105 /// XXSPLT - The PPC VSX splat instructions
107 XXSPLT,
109 /// VECINSERT - The PPC vector insert instruction
111 VECINSERT,
113 /// VECSHL - The PPC vector shift left instruction
115 VECSHL,
117 /// XXPERMDI - The PPC XXPERMDI instruction
119 XXPERMDI,
121 /// The CMPB instruction (takes two operands of i32 or i64).
122 CMPB,
124 /// Hi/Lo - These represent the high and low 16-bit parts of a global
125 /// address respectively. These nodes have two operands, the first of
126 /// which must be a TargetGlobalAddress, and the second of which must be a
127 /// Constant. Selected naively, these turn into 'lis G+C' and 'li G+C',
128 /// though these are usually folded into other nodes.
132 /// The following two target-specific nodes are used for calls through
133 /// function pointers in the 64-bit SVR4 ABI.
135 /// OPRC, CHAIN = DYNALLOC(CHAIN, NEGSIZE, FRAME_INDEX)
136 /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to
137 /// compute an allocation on the stack.
138 DYNALLOC,
140 /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to
141 /// compute an offset from native SP to the address of the most recent
142 /// dynamic alloca.
143 DYNAREAOFFSET,
145 /// GlobalBaseReg - On Darwin, this node represents the result of the mflr
146 /// at function entry, used for PIC code.
147 GlobalBaseReg,
149 /// These nodes represent PPC shifts.
151 /// For scalar types, only the last `n + 1` bits of the shift amounts
152 /// are used, where n is log2(sizeof(element) * 8). See sld/slw, etc.
153 /// for exact behaviors.
155 /// For vector types, only the last n bits are used. See vsld.
156 SRL,
157 SRA,
158 SHL,
160 /// EXTSWSLI = The PPC extswsli instruction, which does an extend-sign
161 /// word and shift left immediate.
162 EXTSWSLI,
164 /// The combination of sra[wd]i and addze used to implemented signed
165 /// integer division by a power of 2. The first operand is the dividend,
166 /// and the second is the constant shift amount (representing the
167 /// divisor).
168 SRA_ADDZE,
170 /// CALL - A direct function call.
171 /// CALL_NOP is a call with the special NOP which follows 64-bit
172 /// SVR4 calls and 32-bit/64-bit AIX calls.
173 CALL,
174 CALL_NOP,
176 /// CHAIN,FLAG = MTCTR(VAL, CHAIN[, INFLAG]) - Directly corresponds to a
177 /// MTCTR instruction.
178 MTCTR,
180 /// CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a
181 /// BCTRL instruction.
182 BCTRL,
184 /// CHAIN,FLAG = BCTRL(CHAIN, ADDR, INFLAG) - The combination of a bctrl
185 /// instruction and the TOC reload required on 64-bit ELF, 32-bit AIX
186 /// and 64-bit AIX.
187 BCTRL_LOAD_TOC,
189 /// Return with a flag operand, matched by 'blr'
190 RET_FLAG,
192 /// R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction.
193 /// This copies the bits corresponding to the specified CRREG into the
194 /// resultant GPR. Bits corresponding to other CR regs are undefined.
195 MFOCRF,
197 /// Direct move from a VSX register to a GPR
198 MFVSR,
200 /// Direct move from a GPR to a VSX register (algebraic)
201 MTVSRA,
203 /// Direct move from a GPR to a VSX register (zero)
204 MTVSRZ,
206 /// Direct move of 2 consecutive GPR to a VSX register.
207 BUILD_FP128,
209 /// BUILD_SPE64 and EXTRACT_SPE are analogous to BUILD_PAIR and
210 /// EXTRACT_ELEMENT but take f64 arguments instead of i64, as i64 is
211 /// unsupported for this target.
212 /// Merge 2 GPRs to a single SPE register.
213 BUILD_SPE64,
215 /// Extract SPE register component, second argument is high or low.
216 EXTRACT_SPE,
218 /// Extract a subvector from signed integer vector and convert to FP.
219 /// It is primarily used to convert a (widened) illegal integer vector
220 /// type to a legal floating point vector type.
221 /// For example v2i32 -> widened to v4i32 -> v2f64
222 SINT_VEC_TO_FP,
224 /// Extract a subvector from unsigned integer vector and convert to FP.
225 /// As with SINT_VEC_TO_FP, used for converting illegal types.
226 UINT_VEC_TO_FP,
228 // FIXME: Remove these once the ANDI glue bug is fixed:
229 /// i1 = ANDI_rec_1_[EQ|GT]_BIT(i32 or i64 x) - Represents the result of the
230 /// eq or gt bit of CR0 after executing andi. x, 1. This is used to
231 /// implement truncation of i32 or i64 to i1.
232 ANDI_rec_1_EQ_BIT,
233 ANDI_rec_1_GT_BIT,
235 // READ_TIME_BASE - A read of the 64-bit time-base register on a 32-bit
236 // target (returns (Lo, Hi)). It takes a chain operand.
237 READ_TIME_BASE,
239 // EH_SJLJ_SETJMP - SjLj exception handling setjmp.
240 EH_SJLJ_SETJMP,
242 // EH_SJLJ_LONGJMP - SjLj exception handling longjmp.
243 EH_SJLJ_LONGJMP,
245 /// RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP*
246 /// instructions. For lack of better number, we use the opcode number
247 /// encoding for the OPC field to identify the compare. For example, 838
248 /// is VCMPGTSH.
249 VCMP,
251 /// RESVEC, OUTFLAG = VCMPo(LHS, RHS, OPC) - Represents one of the
252 /// altivec VCMP*o instructions. For lack of better number, we use the
253 /// opcode number encoding for the OPC field to identify the compare. For
254 /// example, 838 is VCMPGTSH.
255 VCMPo,
257 /// CHAIN = COND_BRANCH CHAIN, CRRC, OPC, DESTBB [, INFLAG] - This
258 /// corresponds to the COND_BRANCH pseudo instruction. CRRC is the
259 /// condition register to branch on, OPC is the branch opcode to use (e.g.
260 /// PPC::BLE), DESTBB is the destination block to branch to, and INFLAG is
261 /// an optional input flag argument.
262 COND_BRANCH,
264 /// CHAIN = BDNZ CHAIN, DESTBB - These are used to create counter-based
265 /// loops.
266 BDNZ,
267 BDZ,
269 /// F8RC = FADDRTZ F8RC, F8RC - This is an FADD done with rounding
270 /// towards zero. Used only as part of the long double-to-int
271 /// conversion sequence.
272 FADDRTZ,
274 /// F8RC = MFFS - This moves the FPSCR (not modeled) into the register.
275 MFFS,
277 /// TC_RETURN - A tail call return.
278 /// operand #0 chain
279 /// operand #1 callee (register or absolute)
280 /// operand #2 stack adjustment
281 /// operand #3 optional in flag
282 TC_RETURN,
284 /// ch, gl = CR6[UN]SET ch, inglue - Toggle CR bit 6 for SVR4 vararg calls
285 CR6SET,
286 CR6UNSET,
288 /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by initial-exec TLS
289 /// for non-position independent code on PPC32.
290 PPC32_GOT,
292 /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by general dynamic and
293 /// local dynamic TLS and position indendepent code on PPC32.
294 PPC32_PICGOT,
296 /// G8RC = ADDIS_GOT_TPREL_HA %x2, Symbol - Used by the initial-exec
297 /// TLS model, produces an ADDIS8 instruction that adds the GOT
298 /// base to sym\@got\@tprel\@ha.
299 ADDIS_GOT_TPREL_HA,
301 /// G8RC = LD_GOT_TPREL_L Symbol, G8RReg - Used by the initial-exec
302 /// TLS model, produces a LD instruction with base register G8RReg
303 /// and offset sym\@got\@tprel\@l. This completes the addition that
304 /// finds the offset of "sym" relative to the thread pointer.
305 LD_GOT_TPREL_L,
307 /// G8RC = ADD_TLS G8RReg, Symbol - Used by the initial-exec TLS
308 /// model, produces an ADD instruction that adds the contents of
309 /// G8RReg to the thread pointer. Symbol contains a relocation
310 /// sym\@tls which is to be replaced by the thread pointer and
311 /// identifies to the linker that the instruction is part of a
312 /// TLS sequence.
313 ADD_TLS,
315 /// G8RC = ADDIS_TLSGD_HA %x2, Symbol - For the general-dynamic TLS
316 /// model, produces an ADDIS8 instruction that adds the GOT base
317 /// register to sym\@got\@tlsgd\@ha.
318 ADDIS_TLSGD_HA,
320 /// %x3 = ADDI_TLSGD_L G8RReg, Symbol - For the general-dynamic TLS
321 /// model, produces an ADDI8 instruction that adds G8RReg to
322 /// sym\@got\@tlsgd\@l and stores the result in X3. Hidden by
323 /// ADDIS_TLSGD_L_ADDR until after register assignment.
324 ADDI_TLSGD_L,
326 /// %x3 = GET_TLS_ADDR %x3, Symbol - For the general-dynamic TLS
327 /// model, produces a call to __tls_get_addr(sym\@tlsgd). Hidden by
328 /// ADDIS_TLSGD_L_ADDR until after register assignment.
329 GET_TLS_ADDR,
331 /// G8RC = ADDI_TLSGD_L_ADDR G8RReg, Symbol, Symbol - Op that
332 /// combines ADDI_TLSGD_L and GET_TLS_ADDR until expansion following
333 /// register assignment.
334 ADDI_TLSGD_L_ADDR,
336 /// G8RC = ADDIS_TLSLD_HA %x2, Symbol - For the local-dynamic TLS
337 /// model, produces an ADDIS8 instruction that adds the GOT base
338 /// register to sym\@got\@tlsld\@ha.
339 ADDIS_TLSLD_HA,
341 /// %x3 = ADDI_TLSLD_L G8RReg, Symbol - For the local-dynamic TLS
342 /// model, produces an ADDI8 instruction that adds G8RReg to
343 /// sym\@got\@tlsld\@l and stores the result in X3. Hidden by
344 /// ADDIS_TLSLD_L_ADDR until after register assignment.
345 ADDI_TLSLD_L,
347 /// %x3 = GET_TLSLD_ADDR %x3, Symbol - For the local-dynamic TLS
348 /// model, produces a call to __tls_get_addr(sym\@tlsld). Hidden by
349 /// ADDIS_TLSLD_L_ADDR until after register assignment.
350 GET_TLSLD_ADDR,
352 /// G8RC = ADDI_TLSLD_L_ADDR G8RReg, Symbol, Symbol - Op that
353 /// combines ADDI_TLSLD_L and GET_TLSLD_ADDR until expansion
354 /// following register assignment.
355 ADDI_TLSLD_L_ADDR,
357 /// G8RC = ADDIS_DTPREL_HA %x3, Symbol - For the local-dynamic TLS
358 /// model, produces an ADDIS8 instruction that adds X3 to
359 /// sym\@dtprel\@ha.
360 ADDIS_DTPREL_HA,
362 /// G8RC = ADDI_DTPREL_L G8RReg, Symbol - For the local-dynamic TLS
363 /// model, produces an ADDI8 instruction that adds G8RReg to
364 /// sym\@got\@dtprel\@l.
365 ADDI_DTPREL_L,
367 /// VRRC = VADD_SPLAT Elt, EltSize - Temporary node to be expanded
368 /// during instruction selection to optimize a BUILD_VECTOR into
369 /// operations on splats. This is necessary to avoid losing these
370 /// optimizations due to constant folding.
371 VADD_SPLAT,
373 /// CHAIN = SC CHAIN, Imm128 - System call. The 7-bit unsigned
374 /// operand identifies the operating system entry point.
377 /// CHAIN = CLRBHRB CHAIN - Clear branch history rolling buffer.
378 CLRBHRB,
380 /// GPRC, CHAIN = MFBHRBE CHAIN, Entry, Dummy - Move from branch
381 /// history rolling buffer entry.
382 MFBHRBE,
384 /// CHAIN = RFEBB CHAIN, State - Return from event-based branch.
385 RFEBB,
387 /// VSRC, CHAIN = XXSWAPD CHAIN, VSRC - Occurs only for little
388 /// endian. Maps to an xxswapd instruction that corrects an lxvd2x
389 /// or stxvd2x instruction. The chain is necessary because the
390 /// sequence replaces a load and needs to provide the same number
391 /// of outputs.
392 XXSWAPD,
394 /// An SDNode for swaps that are not associated with any loads/stores
395 /// and thereby have no chain.
396 SWAP_NO_CHAIN,
398 /// An SDNode for Power9 vector absolute value difference.
399 /// operand #0 vector
400 /// operand #1 vector
401 /// operand #2 constant i32 0 or 1, to indicate whether needs to patch
402 /// the most significant bit for signed i32
404 /// Power9 VABSD* instructions are designed to support unsigned integer
405 /// vectors (byte/halfword/word), if we want to make use of them for signed
406 /// integer vectors, we have to flip their sign bits first. To flip sign bit
407 /// for byte/halfword integer vector would become inefficient, but for word
408 /// integer vector, we can leverage XVNEGSP to make it efficiently. eg:
409 /// abs(sub(a,b)) => VABSDUW(a+0x80000000, b+0x80000000)
410 /// => VABSDUW((XVNEGSP a), (XVNEGSP b))
411 VABSD,
413 /// QVFPERM = This corresponds to the QPX qvfperm instruction.
414 QVFPERM,
416 /// QVGPCI = This corresponds to the QPX qvgpci instruction.
417 QVGPCI,
419 /// QVALIGNI = This corresponds to the QPX qvaligni instruction.
420 QVALIGNI,
422 /// QVESPLATI = This corresponds to the QPX qvesplati instruction.
423 QVESPLATI,
425 /// QBFLT = Access the underlying QPX floating-point boolean
426 /// representation.
427 QBFLT,
429 /// FP_EXTEND_HALF(VECTOR, IDX) - Custom extend upper (IDX=0) half or
430 /// lower (IDX=1) half of v4f32 to v2f64.
431 FP_EXTEND_HALF,
433 /// CHAIN = STBRX CHAIN, GPRC, Ptr, Type - This is a
434 /// byte-swapping store instruction. It byte-swaps the low "Type" bits of
435 /// the GPRC input, then stores it through Ptr. Type can be either i16 or
436 /// i32.
437 STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE,
439 /// GPRC, CHAIN = LBRX CHAIN, Ptr, Type - This is a
440 /// byte-swapping load instruction. It loads "Type" bits, byte swaps it,
441 /// then puts it in the bottom bits of the GPRC. TYPE can be either i16
442 /// or i32.
443 LBRX,
445 /// STFIWX - The STFIWX instruction. The first operand is an input token
446 /// chain, then an f64 value to store, then an address to store it to.
447 STFIWX,
449 /// GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point
450 /// load which sign-extends from a 32-bit integer value into the
451 /// destination 64-bit register.
452 LFIWAX,
454 /// GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point
455 /// load which zero-extends from a 32-bit integer value into the
456 /// destination 64-bit register.
457 LFIWZX,
459 /// GPRC, CHAIN = LXSIZX, CHAIN, Ptr, ByteWidth - This is a load of an
460 /// integer smaller than 64 bits into a VSR. The integer is zero-extended.
461 /// This can be used for converting loaded integers to floating point.
462 LXSIZX,
464 /// STXSIX - The STXSI[bh]X instruction. The first operand is an input
465 /// chain, then an f64 value to store, then an address to store it to,
466 /// followed by a byte-width for the store.
467 STXSIX,
469 /// VSRC, CHAIN = LXVD2X_LE CHAIN, Ptr - Occurs only for little endian.
470 /// Maps directly to an lxvd2x instruction that will be followed by
471 /// an xxswapd.
472 LXVD2X,
474 /// VSRC, CHAIN = LOAD_VEC_BE CHAIN, Ptr - Occurs only for little endian.
475 /// Maps directly to one of lxvd2x/lxvw4x/lxvh8x/lxvb16x depending on
476 /// the vector type to load vector in big-endian element order.
477 LOAD_VEC_BE,
479 /// VSRC, CHAIN = LD_VSX_LH CHAIN, Ptr - This is a floating-point load of a
480 /// v2f32 value into the lower half of a VSR register.
481 LD_VSX_LH,
483 /// VSRC, CHAIN = LD_SPLAT, CHAIN, Ptr - a splatting load memory
484 /// instructions such as LXVDSX, LXVWSX.
485 LD_SPLAT,
487 /// CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian.
488 /// Maps directly to an stxvd2x instruction that will be preceded by
489 /// an xxswapd.
490 STXVD2X,
492 /// CHAIN = STORE_VEC_BE CHAIN, VSRC, Ptr - Occurs only for little endian.
493 /// Maps directly to one of stxvd2x/stxvw4x/stxvh8x/stxvb16x depending on
494 /// the vector type to store vector in big-endian element order.
495 STORE_VEC_BE,
497 /// Store scalar integers from VSR.
498 ST_VSR_SCAL_INT,
500 /// QBRC, CHAIN = QVLFSb CHAIN, Ptr
501 /// The 4xf32 load used for v4i1 constants.
502 QVLFSb,
504 /// ATOMIC_CMP_SWAP - the exact same as the target-independent nodes
505 /// except they ensure that the compare input is zero-extended for
506 /// sub-word versions because the atomic loads zero-extend.
507 ATOMIC_CMP_SWAP_8,
508 ATOMIC_CMP_SWAP_16,
510 /// GPRC = TOC_ENTRY GA, TOC
511 /// Loads the entry for GA from the TOC, where the TOC base is given by
512 /// the last operand.
513 TOC_ENTRY
516 } // end namespace PPCISD
518 /// Define some predicates that are used for node matching.
519 namespace PPC {
521 /// isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a
522 /// VPKUHUM instruction.
523 bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
524 SelectionDAG &DAG);
526 /// isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a
527 /// VPKUWUM instruction.
528 bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
529 SelectionDAG &DAG);
531 /// isVPKUDUMShuffleMask - Return true if this is the shuffle mask for a
532 /// VPKUDUM instruction.
533 bool isVPKUDUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
534 SelectionDAG &DAG);
536 /// isVMRGLShuffleMask - Return true if this is a shuffle mask suitable for
537 /// a VRGL* instruction with the specified unit size (1,2 or 4 bytes).
538 bool isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
539 unsigned ShuffleKind, SelectionDAG &DAG);
541 /// isVMRGHShuffleMask - Return true if this is a shuffle mask suitable for
542 /// a VRGH* instruction with the specified unit size (1,2 or 4 bytes).
543 bool isVMRGHShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
544 unsigned ShuffleKind, SelectionDAG &DAG);
546 /// isVMRGEOShuffleMask - Return true if this is a shuffle mask suitable for
547 /// a VMRGEW or VMRGOW instruction
548 bool isVMRGEOShuffleMask(ShuffleVectorSDNode *N, bool CheckEven,
549 unsigned ShuffleKind, SelectionDAG &DAG);
550 /// isXXSLDWIShuffleMask - Return true if this is a shuffle mask suitable
551 /// for a XXSLDWI instruction.
552 bool isXXSLDWIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts,
553 bool &Swap, bool IsLE);
555 /// isXXBRHShuffleMask - Return true if this is a shuffle mask suitable
556 /// for a XXBRH instruction.
557 bool isXXBRHShuffleMask(ShuffleVectorSDNode *N);
559 /// isXXBRWShuffleMask - Return true if this is a shuffle mask suitable
560 /// for a XXBRW instruction.
561 bool isXXBRWShuffleMask(ShuffleVectorSDNode *N);
563 /// isXXBRDShuffleMask - Return true if this is a shuffle mask suitable
564 /// for a XXBRD instruction.
565 bool isXXBRDShuffleMask(ShuffleVectorSDNode *N);
567 /// isXXBRQShuffleMask - Return true if this is a shuffle mask suitable
568 /// for a XXBRQ instruction.
569 bool isXXBRQShuffleMask(ShuffleVectorSDNode *N);
571 /// isXXPERMDIShuffleMask - Return true if this is a shuffle mask suitable
572 /// for a XXPERMDI instruction.
573 bool isXXPERMDIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts,
574 bool &Swap, bool IsLE);
576 /// isVSLDOIShuffleMask - If this is a vsldoi shuffle mask, return the
577 /// shift amount, otherwise return -1.
578 int isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind,
579 SelectionDAG &DAG);
581 /// isSplatShuffleMask - Return true if the specified VECTOR_SHUFFLE operand
582 /// specifies a splat of a single element that is suitable for input to
583 /// VSPLTB/VSPLTH/VSPLTW.
584 bool isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize);
586 /// isXXINSERTWMask - Return true if this VECTOR_SHUFFLE can be handled by
587 /// the XXINSERTW instruction introduced in ISA 3.0. This is essentially any
588 /// shuffle of v4f32/v4i32 vectors that just inserts one element from one
589 /// vector into the other. This function will also set a couple of
590 /// output parameters for how much the source vector needs to be shifted and
591 /// what byte number needs to be specified for the instruction to put the
592 /// element in the desired location of the target vector.
593 bool isXXINSERTWMask(ShuffleVectorSDNode *N, unsigned &ShiftElts,
594 unsigned &InsertAtByte, bool &Swap, bool IsLE);
596 /// getSplatIdxForPPCMnemonics - Return the splat index as a value that is
597 /// appropriate for PPC mnemonics (which have a big endian bias - namely
598 /// elements are counted from the left of the vector register).
599 unsigned getSplatIdxForPPCMnemonics(SDNode *N, unsigned EltSize,
600 SelectionDAG &DAG);
602 /// get_VSPLTI_elt - If this is a build_vector of constants which can be
603 /// formed by using a vspltis[bhw] instruction of the specified element
604 /// size, return the constant being splatted. The ByteSize field indicates
605 /// the number of bytes of each element [124] -> [bhw].
606 SDValue get_VSPLTI_elt(SDNode *N, unsigned ByteSize, SelectionDAG &DAG);
608 /// If this is a qvaligni shuffle mask, return the shift
609 /// amount, otherwise return -1.
610 int isQVALIGNIShuffleMask(SDNode *N);
612 } // end namespace PPC
614 class PPCTargetLowering : public TargetLowering {
615 const PPCSubtarget &Subtarget;
617 public:
618 explicit PPCTargetLowering(const PPCTargetMachine &TM,
619 const PPCSubtarget &STI);
621 /// getTargetNodeName() - This method returns the name of a target specific
622 /// DAG node.
623 const char *getTargetNodeName(unsigned Opcode) const override;
625 bool isSelectSupported(SelectSupportKind Kind) const override {
626 // PowerPC does not support scalar condition selects on vectors.
627 return (Kind != SelectSupportKind::ScalarCondVectorVal);
630 /// getPreferredVectorAction - The code we generate when vector types are
631 /// legalized by promoting the integer element type is often much worse
632 /// than code we generate if we widen the type for applicable vector types.
633 /// The issue with promoting is that the vector is scalaraized, individual
634 /// elements promoted and then the vector is rebuilt. So say we load a pair
635 /// of v4i8's and shuffle them. This will turn into a mess of 8 extending
636 /// loads, moves back into VSR's (or memory ops if we don't have moves) and
637 /// then the VPERM for the shuffle. All in all a very slow sequence.
638 TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT)
639 const override {
640 if (VT.getScalarSizeInBits() % 8 == 0)
641 return TypeWidenVector;
642 return TargetLoweringBase::getPreferredVectorAction(VT);
645 bool useSoftFloat() const override;
647 bool hasSPE() const;
649 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
650 return MVT::i32;
653 bool isCheapToSpeculateCttz() const override {
654 return true;
657 bool isCheapToSpeculateCtlz() const override {
658 return true;
661 bool isCtlzFast() const override {
662 return true;
665 bool isEqualityCmpFoldedWithSignedCmp() const override {
666 return false;
669 bool hasAndNotCompare(SDValue) const override {
670 return true;
673 bool preferIncOfAddToSubOfNot(EVT VT) const override;
675 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
676 return VT.isScalarInteger();
679 bool supportSplitCSR(MachineFunction *MF) const override {
680 return
681 MF->getFunction().getCallingConv() == CallingConv::CXX_FAST_TLS &&
682 MF->getFunction().hasFnAttribute(Attribute::NoUnwind);
685 void initializeSplitCSR(MachineBasicBlock *Entry) const override;
687 void insertCopiesSplitCSR(
688 MachineBasicBlock *Entry,
689 const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
691 /// getSetCCResultType - Return the ISD::SETCC ValueType
692 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
693 EVT VT) const override;
695 /// Return true if target always beneficiates from combining into FMA for a
696 /// given value type. This must typically return false on targets where FMA
697 /// takes more cycles to execute than FADD.
698 bool enableAggressiveFMAFusion(EVT VT) const override;
700 /// getPreIndexedAddressParts - returns true by value, base pointer and
701 /// offset pointer and addressing mode by reference if the node's address
702 /// can be legally represented as pre-indexed load / store address.
703 bool getPreIndexedAddressParts(SDNode *N, SDValue &Base,
704 SDValue &Offset,
705 ISD::MemIndexedMode &AM,
706 SelectionDAG &DAG) const override;
708 /// SelectAddressEVXRegReg - Given the specified addressed, check to see if
709 /// it can be more efficiently represented as [r+imm].
710 bool SelectAddressEVXRegReg(SDValue N, SDValue &Base, SDValue &Index,
711 SelectionDAG &DAG) const;
713 /// SelectAddressRegReg - Given the specified addressed, check to see if it
714 /// can be more efficiently represented as [r+imm]. If \p EncodingAlignment
715 /// is non-zero, only accept displacement which is not suitable for [r+imm].
716 /// Returns false if it can be represented by [r+imm], which are preferred.
717 bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index,
718 SelectionDAG &DAG,
719 unsigned EncodingAlignment = 0) const;
721 /// SelectAddressRegImm - Returns true if the address N can be represented
722 /// by a base register plus a signed 16-bit displacement [r+imm], and if it
723 /// is not better represented as reg+reg. If \p EncodingAlignment is
724 /// non-zero, only accept displacements suitable for instruction encoding
725 /// requirement, i.e. multiples of 4 for DS form.
726 bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base,
727 SelectionDAG &DAG,
728 unsigned EncodingAlignment) const;
730 /// SelectAddressRegRegOnly - Given the specified addressed, force it to be
731 /// represented as an indexed [r+r] operation.
732 bool SelectAddressRegRegOnly(SDValue N, SDValue &Base, SDValue &Index,
733 SelectionDAG &DAG) const;
735 Sched::Preference getSchedulingPreference(SDNode *N) const override;
737 /// LowerOperation - Provide custom lowering hooks for some operations.
739 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
741 /// ReplaceNodeResults - Replace the results of node with an illegal result
742 /// type with new values built out of custom code.
744 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
745 SelectionDAG &DAG) const override;
747 SDValue expandVSXLoadForLE(SDNode *N, DAGCombinerInfo &DCI) const;
748 SDValue expandVSXStoreForLE(SDNode *N, DAGCombinerInfo &DCI) const;
750 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
752 SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
753 SmallVectorImpl<SDNode *> &Created) const override;
755 Register getRegisterByName(const char* RegName, LLT VT,
756 const MachineFunction &MF) const override;
758 void computeKnownBitsForTargetNode(const SDValue Op,
759 KnownBits &Known,
760 const APInt &DemandedElts,
761 const SelectionDAG &DAG,
762 unsigned Depth = 0) const override;
764 Align getPrefLoopAlignment(MachineLoop *ML) const override;
766 bool shouldInsertFencesForAtomic(const Instruction *I) const override {
767 return true;
770 Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst,
771 AtomicOrdering Ord) const override;
772 Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst,
773 AtomicOrdering Ord) const override;
775 MachineBasicBlock *
776 EmitInstrWithCustomInserter(MachineInstr &MI,
777 MachineBasicBlock *MBB) const override;
778 MachineBasicBlock *EmitAtomicBinary(MachineInstr &MI,
779 MachineBasicBlock *MBB,
780 unsigned AtomicSize,
781 unsigned BinOpcode,
782 unsigned CmpOpcode = 0,
783 unsigned CmpPred = 0) const;
784 MachineBasicBlock *EmitPartwordAtomicBinary(MachineInstr &MI,
785 MachineBasicBlock *MBB,
786 bool is8bit,
787 unsigned Opcode,
788 unsigned CmpOpcode = 0,
789 unsigned CmpPred = 0) const;
791 MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr &MI,
792 MachineBasicBlock *MBB) const;
794 MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr &MI,
795 MachineBasicBlock *MBB) const;
797 ConstraintType getConstraintType(StringRef Constraint) const override;
799 /// Examine constraint string and operand type and determine a weight value.
800 /// The operand object must already have been set up with the operand type.
801 ConstraintWeight getSingleConstraintMatchWeight(
802 AsmOperandInfo &info, const char *constraint) const override;
804 std::pair<unsigned, const TargetRegisterClass *>
805 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
806 StringRef Constraint, MVT VT) const override;
808 /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
809 /// function arguments in the caller parameter area. This is the actual
810 /// alignment, not its logarithm.
811 unsigned getByValTypeAlignment(Type *Ty,
812 const DataLayout &DL) const override;
814 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
815 /// vector. If it is invalid, don't add anything to Ops.
816 void LowerAsmOperandForConstraint(SDValue Op,
817 std::string &Constraint,
818 std::vector<SDValue> &Ops,
819 SelectionDAG &DAG) const override;
821 unsigned
822 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
823 if (ConstraintCode == "es")
824 return InlineAsm::Constraint_es;
825 else if (ConstraintCode == "o")
826 return InlineAsm::Constraint_o;
827 else if (ConstraintCode == "Q")
828 return InlineAsm::Constraint_Q;
829 else if (ConstraintCode == "Z")
830 return InlineAsm::Constraint_Z;
831 else if (ConstraintCode == "Zy")
832 return InlineAsm::Constraint_Zy;
833 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
836 /// isLegalAddressingMode - Return true if the addressing mode represented
837 /// by AM is legal for this target, for a load/store of the specified type.
838 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
839 Type *Ty, unsigned AS,
840 Instruction *I = nullptr) const override;
842 /// isLegalICmpImmediate - Return true if the specified immediate is legal
843 /// icmp immediate, that is the target has icmp instructions which can
844 /// compare a register against the immediate without having to materialize
845 /// the immediate into a register.
846 bool isLegalICmpImmediate(int64_t Imm) const override;
848 /// isLegalAddImmediate - Return true if the specified immediate is legal
849 /// add immediate, that is the target has add instructions which can
850 /// add a register and the immediate without having to materialize
851 /// the immediate into a register.
852 bool isLegalAddImmediate(int64_t Imm) const override;
854 /// isTruncateFree - Return true if it's free to truncate a value of
855 /// type Ty1 to type Ty2. e.g. On PPC it's free to truncate a i64 value in
856 /// register X1 to i32 by referencing its sub-register R1.
857 bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
858 bool isTruncateFree(EVT VT1, EVT VT2) const override;
860 bool isZExtFree(SDValue Val, EVT VT2) const override;
862 bool isFPExtFree(EVT DestVT, EVT SrcVT) const override;
864 /// Returns true if it is beneficial to convert a load of a constant
865 /// to just the constant itself.
866 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
867 Type *Ty) const override;
869 bool convertSelectOfConstantsToMath(EVT VT) const override {
870 return true;
873 bool isDesirableToTransformToIntegerOp(unsigned Opc,
874 EVT VT) const override {
875 // Only handle float load/store pair because float(fpr) load/store
876 // instruction has more cycles than integer(gpr) load/store in PPC.
877 if (Opc != ISD::LOAD && Opc != ISD::STORE)
878 return false;
879 if (VT != MVT::f32 && VT != MVT::f64)
880 return false;
882 return true;
885 // Returns true if the address of the global is stored in TOC entry.
886 bool isAccessedAsGotIndirect(SDValue N) const;
888 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
890 bool getTgtMemIntrinsic(IntrinsicInfo &Info,
891 const CallInst &I,
892 MachineFunction &MF,
893 unsigned Intrinsic) const override;
895 /// getOptimalMemOpType - Returns the target specific optimal type for load
896 /// and store operations as a result of memset, memcpy, and memmove
897 /// lowering. If DstAlign is zero that means it's safe to destination
898 /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it
899 /// means there isn't a need to check it against alignment requirement,
900 /// probably because the source does not need to be loaded. If 'IsMemset' is
901 /// true, that means it's expanding a memset. If 'ZeroMemset' is true, that
902 /// means it's a memset of zero. 'MemcpyStrSrc' indicates whether the memcpy
903 /// source is constant so it does not need to be loaded.
904 /// It returns EVT::Other if the type should be determined using generic
905 /// target-independent logic.
907 getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign,
908 bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
909 const AttributeList &FuncAttributes) const override;
911 /// Is unaligned memory access allowed for the given type, and is it fast
912 /// relative to software emulation.
913 bool allowsMisalignedMemoryAccesses(
914 EVT VT, unsigned AddrSpace, unsigned Align = 1,
915 MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
916 bool *Fast = nullptr) const override;
918 /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
919 /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
920 /// expanded to FMAs when this method returns true, otherwise fmuladd is
921 /// expanded to fmul + fadd.
922 bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
923 EVT VT) const override;
925 const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;
927 // Should we expand the build vector with shuffles?
928 bool
929 shouldExpandBuildVectorWithShuffles(EVT VT,
930 unsigned DefinedValues) const override;
932 /// createFastISel - This method returns a target-specific FastISel object,
933 /// or null if the target does not support "fast" instruction selection.
934 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
935 const TargetLibraryInfo *LibInfo) const override;
937 /// Returns true if an argument of type Ty needs to be passed in a
938 /// contiguous block of registers in calling convention CallConv.
939 bool functionArgumentNeedsConsecutiveRegisters(
940 Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override {
941 // We support any array type as "consecutive" block in the parameter
942 // save area. The element type defines the alignment requirement and
943 // whether the argument should go in GPRs, FPRs, or VRs if available.
945 // Note that clang uses this capability both to implement the ELFv2
946 // homogeneous float/vector aggregate ABI, and to avoid having to use
947 // "byval" when passing aggregates that might fully fit in registers.
948 return Ty->isArrayTy();
951 /// If a physical register, this returns the register that receives the
952 /// exception address on entry to an EH pad.
953 unsigned
954 getExceptionPointerRegister(const Constant *PersonalityFn) const override;
956 /// If a physical register, this returns the register that receives the
957 /// exception typeid on entry to a landing pad.
958 unsigned
959 getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
961 /// Override to support customized stack guard loading.
962 bool useLoadStackGuardNode() const override;
963 void insertSSPDeclarations(Module &M) const override;
965 bool isFPImmLegal(const APFloat &Imm, EVT VT,
966 bool ForCodeSize) const override;
968 unsigned getJumpTableEncoding() const override;
969 bool isJumpTableRelative() const override;
970 SDValue getPICJumpTableRelocBase(SDValue Table,
971 SelectionDAG &DAG) const override;
972 const MCExpr *getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
973 unsigned JTI,
974 MCContext &Ctx) const override;
976 /// Structure that collects some common arguments that get passed around
977 /// between the functions for call lowering.
978 struct CallFlags {
979 const CallingConv::ID CallConv;
980 const bool IsTailCall : 1;
981 const bool IsVarArg : 1;
982 const bool IsPatchPoint : 1;
983 const bool IsIndirect : 1;
984 const bool HasNest : 1;
986 CallFlags(CallingConv::ID CC, bool IsTailCall, bool IsVarArg,
987 bool IsPatchPoint, bool IsIndirect, bool HasNest)
988 : CallConv(CC), IsTailCall(IsTailCall), IsVarArg(IsVarArg),
989 IsPatchPoint(IsPatchPoint), IsIndirect(IsIndirect),
990 HasNest(HasNest) {}
993 private:
994 struct ReuseLoadInfo {
995 SDValue Ptr;
996 SDValue Chain;
997 SDValue ResChain;
998 MachinePointerInfo MPI;
999 bool IsDereferenceable = false;
1000 bool IsInvariant = false;
1001 unsigned Alignment = 0;
1002 AAMDNodes AAInfo;
1003 const MDNode *Ranges = nullptr;
1005 ReuseLoadInfo() = default;
1007 MachineMemOperand::Flags MMOFlags() const {
1008 MachineMemOperand::Flags F = MachineMemOperand::MONone;
1009 if (IsDereferenceable)
1010 F |= MachineMemOperand::MODereferenceable;
1011 if (IsInvariant)
1012 F |= MachineMemOperand::MOInvariant;
1013 return F;
1017 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
1018 // Addrspacecasts are always noops.
1019 return true;
1022 bool canReuseLoadAddress(SDValue Op, EVT MemVT, ReuseLoadInfo &RLI,
1023 SelectionDAG &DAG,
1024 ISD::LoadExtType ET = ISD::NON_EXTLOAD) const;
1025 void spliceIntoChain(SDValue ResChain, SDValue NewResChain,
1026 SelectionDAG &DAG) const;
1028 void LowerFP_TO_INTForReuse(SDValue Op, ReuseLoadInfo &RLI,
1029 SelectionDAG &DAG, const SDLoc &dl) const;
1030 SDValue LowerFP_TO_INTDirectMove(SDValue Op, SelectionDAG &DAG,
1031 const SDLoc &dl) const;
1033 bool directMoveIsProfitable(const SDValue &Op) const;
1034 SDValue LowerINT_TO_FPDirectMove(SDValue Op, SelectionDAG &DAG,
1035 const SDLoc &dl) const;
1037 SDValue LowerINT_TO_FPVector(SDValue Op, SelectionDAG &DAG,
1038 const SDLoc &dl) const;
1040 SDValue LowerTRUNCATEVector(SDValue Op, SelectionDAG &DAG) const;
1042 SDValue getFramePointerFrameIndex(SelectionDAG & DAG) const;
1043 SDValue getReturnAddrFrameIndex(SelectionDAG & DAG) const;
1045 bool
1046 IsEligibleForTailCallOptimization(SDValue Callee,
1047 CallingConv::ID CalleeCC,
1048 bool isVarArg,
1049 const SmallVectorImpl<ISD::InputArg> &Ins,
1050 SelectionDAG& DAG) const;
1052 bool
1053 IsEligibleForTailCallOptimization_64SVR4(
1054 SDValue Callee,
1055 CallingConv::ID CalleeCC,
1056 ImmutableCallSite CS,
1057 bool isVarArg,
1058 const SmallVectorImpl<ISD::OutputArg> &Outs,
1059 const SmallVectorImpl<ISD::InputArg> &Ins,
1060 SelectionDAG& DAG) const;
1062 SDValue EmitTailCallLoadFPAndRetAddr(SelectionDAG &DAG, int SPDiff,
1063 SDValue Chain, SDValue &LROpOut,
1064 SDValue &FPOpOut,
1065 const SDLoc &dl) const;
1067 SDValue getTOCEntry(SelectionDAG &DAG, const SDLoc &dl, SDValue GA) const;
1069 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
1070 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
1071 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
1072 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
1073 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
1074 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
1075 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
1076 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
1077 SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
1078 SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
1079 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
1080 SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
1081 SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
1082 SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
1083 SDValue LowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const;
1084 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
1085 SDValue LowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const;
1086 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
1087 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
1088 SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const;
1089 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
1090 SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG,
1091 const SDLoc &dl) const;
1092 SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
1093 SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
1094 SDValue LowerSHL_PARTS(SDValue Op, SelectionDAG &DAG) const;
1095 SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const;
1096 SDValue LowerSRA_PARTS(SDValue Op, SelectionDAG &DAG) const;
1097 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
1098 SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
1099 SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1100 SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1101 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
1102 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
1103 SDValue LowerREM(SDValue Op, SelectionDAG &DAG) const;
1104 SDValue LowerBSWAP(SDValue Op, SelectionDAG &DAG) const;
1105 SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
1106 SDValue LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
1107 SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;
1108 SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const;
1109 SDValue LowerABS(SDValue Op, SelectionDAG &DAG) const;
1110 SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
1112 SDValue LowerVectorLoad(SDValue Op, SelectionDAG &DAG) const;
1113 SDValue LowerVectorStore(SDValue Op, SelectionDAG &DAG) const;
1115 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
1116 CallingConv::ID CallConv, bool isVarArg,
1117 const SmallVectorImpl<ISD::InputArg> &Ins,
1118 const SDLoc &dl, SelectionDAG &DAG,
1119 SmallVectorImpl<SDValue> &InVals) const;
1121 SDValue FinishCall(CallFlags CFlags, const SDLoc &dl, SelectionDAG &DAG,
1122 SmallVector<std::pair<unsigned, SDValue>, 8> &RegsToPass,
1123 SDValue InFlag, SDValue Chain, SDValue CallSeqStart,
1124 SDValue &Callee, int SPDiff, unsigned NumBytes,
1125 const SmallVectorImpl<ISD::InputArg> &Ins,
1126 SmallVectorImpl<SDValue> &InVals,
1127 ImmutableCallSite CS) const;
1129 SDValue
1130 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1131 const SmallVectorImpl<ISD::InputArg> &Ins,
1132 const SDLoc &dl, SelectionDAG &DAG,
1133 SmallVectorImpl<SDValue> &InVals) const override;
1135 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
1136 SmallVectorImpl<SDValue> &InVals) const override;
1138 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
1139 bool isVarArg,
1140 const SmallVectorImpl<ISD::OutputArg> &Outs,
1141 LLVMContext &Context) const override;
1143 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1144 const SmallVectorImpl<ISD::OutputArg> &Outs,
1145 const SmallVectorImpl<SDValue> &OutVals,
1146 const SDLoc &dl, SelectionDAG &DAG) const override;
1148 SDValue extendArgForPPC64(ISD::ArgFlagsTy Flags, EVT ObjectVT,
1149 SelectionDAG &DAG, SDValue ArgVal,
1150 const SDLoc &dl) const;
1152 SDValue LowerFormalArguments_AIX(
1153 SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1154 const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
1155 SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const;
1156 SDValue LowerFormalArguments_Darwin(
1157 SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1158 const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
1159 SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const;
1160 SDValue LowerFormalArguments_64SVR4(
1161 SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1162 const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
1163 SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const;
1164 SDValue LowerFormalArguments_32SVR4(
1165 SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1166 const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
1167 SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const;
1169 SDValue createMemcpyOutsideCallSeq(SDValue Arg, SDValue PtrOff,
1170 SDValue CallSeqStart,
1171 ISD::ArgFlagsTy Flags, SelectionDAG &DAG,
1172 const SDLoc &dl) const;
1174 SDValue LowerCall_Darwin(SDValue Chain, SDValue Callee, CallFlags CFlags,
1175 const SmallVectorImpl<ISD::OutputArg> &Outs,
1176 const SmallVectorImpl<SDValue> &OutVals,
1177 const SmallVectorImpl<ISD::InputArg> &Ins,
1178 const SDLoc &dl, SelectionDAG &DAG,
1179 SmallVectorImpl<SDValue> &InVals,
1180 ImmutableCallSite CS) const;
1181 SDValue LowerCall_64SVR4(SDValue Chain, SDValue Callee, CallFlags CFlags,
1182 const SmallVectorImpl<ISD::OutputArg> &Outs,
1183 const SmallVectorImpl<SDValue> &OutVals,
1184 const SmallVectorImpl<ISD::InputArg> &Ins,
1185 const SDLoc &dl, SelectionDAG &DAG,
1186 SmallVectorImpl<SDValue> &InVals,
1187 ImmutableCallSite CS) const;
1188 SDValue LowerCall_32SVR4(SDValue Chain, SDValue Callee, CallFlags CFlags,
1189 const SmallVectorImpl<ISD::OutputArg> &Outs,
1190 const SmallVectorImpl<SDValue> &OutVals,
1191 const SmallVectorImpl<ISD::InputArg> &Ins,
1192 const SDLoc &dl, SelectionDAG &DAG,
1193 SmallVectorImpl<SDValue> &InVals,
1194 ImmutableCallSite CS) const;
1195 SDValue LowerCall_AIX(SDValue Chain, SDValue Callee, CallFlags CFlags,
1196 const SmallVectorImpl<ISD::OutputArg> &Outs,
1197 const SmallVectorImpl<SDValue> &OutVals,
1198 const SmallVectorImpl<ISD::InputArg> &Ins,
1199 const SDLoc &dl, SelectionDAG &DAG,
1200 SmallVectorImpl<SDValue> &InVals,
1201 ImmutableCallSite CS) const;
1203 SDValue lowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
1204 SDValue lowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
1205 SDValue LowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
1207 SDValue DAGCombineExtBoolTrunc(SDNode *N, DAGCombinerInfo &DCI) const;
1208 SDValue DAGCombineBuildVector(SDNode *N, DAGCombinerInfo &DCI) const;
1209 SDValue DAGCombineTruncBoolExt(SDNode *N, DAGCombinerInfo &DCI) const;
1210 SDValue combineStoreFPToInt(SDNode *N, DAGCombinerInfo &DCI) const;
1211 SDValue combineFPToIntToFP(SDNode *N, DAGCombinerInfo &DCI) const;
1212 SDValue combineSHL(SDNode *N, DAGCombinerInfo &DCI) const;
1213 SDValue combineSRA(SDNode *N, DAGCombinerInfo &DCI) const;
1214 SDValue combineSRL(SDNode *N, DAGCombinerInfo &DCI) const;
1215 SDValue combineMUL(SDNode *N, DAGCombinerInfo &DCI) const;
1216 SDValue combineADD(SDNode *N, DAGCombinerInfo &DCI) const;
1217 SDValue combineTRUNCATE(SDNode *N, DAGCombinerInfo &DCI) const;
1218 SDValue combineSetCC(SDNode *N, DAGCombinerInfo &DCI) const;
1219 SDValue combineABS(SDNode *N, DAGCombinerInfo &DCI) const;
1220 SDValue combineVSelect(SDNode *N, DAGCombinerInfo &DCI) const;
1221 SDValue combineVReverseMemOP(ShuffleVectorSDNode *SVN, LSBaseSDNode *LSBase,
1222 DAGCombinerInfo &DCI) const;
1224 /// ConvertSETCCToSubtract - looks at SETCC that compares ints. It replaces
1225 /// SETCC with integer subtraction when (1) there is a legal way of doing it
1226 /// (2) keeping the result of comparison in GPR has performance benefit.
1227 SDValue ConvertSETCCToSubtract(SDNode *N, DAGCombinerInfo &DCI) const;
1229 SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled,
1230 int &RefinementSteps, bool &UseOneConstNR,
1231 bool Reciprocal) const override;
1232 SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled,
1233 int &RefinementSteps) const override;
1234 unsigned combineRepeatedFPDivisors() const override;
1236 SDValue
1237 combineElementTruncationToVectorTruncation(SDNode *N,
1238 DAGCombinerInfo &DCI) const;
1240 /// lowerToVINSERTH - Return the SDValue if this VECTOR_SHUFFLE can be
1241 /// handled by the VINSERTH instruction introduced in ISA 3.0. This is
1242 /// essentially any shuffle of v8i16 vectors that just inserts one element
1243 /// from one vector into the other.
1244 SDValue lowerToVINSERTH(ShuffleVectorSDNode *N, SelectionDAG &DAG) const;
1246 /// lowerToVINSERTB - Return the SDValue if this VECTOR_SHUFFLE can be
1247 /// handled by the VINSERTB instruction introduced in ISA 3.0. This is
1248 /// essentially v16i8 vector version of VINSERTH.
1249 SDValue lowerToVINSERTB(ShuffleVectorSDNode *N, SelectionDAG &DAG) const;
1251 // Return whether the call instruction can potentially be optimized to a
1252 // tail call. This will cause the optimizers to attempt to move, or
1253 // duplicate return instructions to help enable tail call optimizations.
1254 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
1255 bool hasBitPreservingFPLogic(EVT VT) const override;
1256 bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override;
1257 }; // end class PPCTargetLowering
1259 namespace PPC {
1261 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
1262 const TargetLibraryInfo *LibInfo);
1264 } // end namespace PPC
1266 bool isIntS16Immediate(SDNode *N, int16_t &Imm);
1267 bool isIntS16Immediate(SDValue Op, int16_t &Imm);
1269 } // end namespace llvm
1271 #endif // LLVM_TARGET_POWERPC_PPC32ISELLOWERING_H