Nate Begeman | 6cca84e | 2005-10-16 05:39:50 +0000 | [diff] [blame] | 1 | //===-- PPCISelLowering.h - PPC32 DAG Lowering Interface --------*- C++ -*-===// |
Chris Lattner | f22556d | 2005-08-16 17:14:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | f22556d | 2005-08-16 17:14:42 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that PPC uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H |
| 16 | #define LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H |
Chris Lattner | f22556d | 2005-08-16 17:14:42 +0000 | [diff] [blame] | 17 | |
Chris Lattner | bfca1ab | 2005-10-14 23:51:18 +0000 | [diff] [blame] | 18 | #include "PPC.h" |
Hal Finkel | ed6a285 | 2013-04-05 23:29:01 +0000 | [diff] [blame] | 19 | #include "PPCInstrInfo.h" |
Bill Schmidt | 230b451 | 2013-06-12 16:39:22 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/CallingConvLower.h" |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineFunction.h" |
| 22 | #include "llvm/CodeGen/MachineMemOperand.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/SelectionDAG.h" |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/SelectionDAGNodes.h" |
David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 25 | #include "llvm/CodeGen/TargetLowering.h" |
Craig Topper | 2fa1436 | 2018-03-29 17:21:10 +0000 | [diff] [blame] | 26 | #include "llvm/CodeGen/ValueTypes.h" |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 27 | #include "llvm/IR/Attributes.h" |
| 28 | #include "llvm/IR/CallingConv.h" |
| 29 | #include "llvm/IR/Function.h" |
| 30 | #include "llvm/IR/InlineAsm.h" |
| 31 | #include "llvm/IR/Metadata.h" |
| 32 | #include "llvm/IR/Type.h" |
David Blaikie | 13e77db | 2018-03-23 23:58:25 +0000 | [diff] [blame] | 33 | #include "llvm/Support/MachineValueType.h" |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 34 | #include <utility> |
Chris Lattner | f22556d | 2005-08-16 17:14:42 +0000 | [diff] [blame] | 35 | |
| 36 | namespace llvm { |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 37 | |
Chris Lattner | b2854fa | 2005-08-26 20:25:03 +0000 | [diff] [blame] | 38 | namespace PPCISD { |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 39 | |
Stefan Pintilie | df0ee9e | 2017-07-26 13:44:59 +0000 | [diff] [blame] | 40 | // When adding a NEW PPCISD node please add it to the correct position in |
| 41 | // the enum. The order of elements in this enum matters! |
| 42 | // Values that are added after this entry: |
| 43 | // STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE |
| 44 | // are considerd memory opcodes and are treated differently than entries |
| 45 | // that come before it. For example, ADD or MUL should be placed before |
| 46 | // the ISD::FIRST_TARGET_MEMORY_OPCODE while a LOAD or STORE should come |
| 47 | // after it. |
Matthias Braun | d04893f | 2015-05-07 21:33:59 +0000 | [diff] [blame] | 48 | enum NodeType : unsigned { |
Nate Begeman | debcb55 | 2007-01-26 22:40:50 +0000 | [diff] [blame] | 49 | // Start the numbering where the builtin ops and target ops leave off. |
Dan Gohman | ed1cf1a | 2008-09-23 18:42:32 +0000 | [diff] [blame] | 50 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
Chris Lattner | b2854fa | 2005-08-26 20:25:03 +0000 | [diff] [blame] | 51 | |
| 52 | /// FSEL - Traditional three-operand fsel node. |
| 53 | /// |
| 54 | FSEL, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 55 | |
Nate Begeman | 6095214 | 2005-09-06 22:03:27 +0000 | [diff] [blame] | 56 | /// FCFID - The FCFID instruction, taking an f64 operand and producing |
| 57 | /// and f64 value containing the FP representation of the integer that |
| 58 | /// was temporarily in the f64 operand. |
| 59 | FCFID, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 60 | |
Hal Finkel | f6d45f2 | 2013-04-01 17:52:07 +0000 | [diff] [blame] | 61 | /// Newer FCFID[US] integer-to-floating-point conversion instructions for |
| 62 | /// unsigned integers and single-precision outputs. |
| 63 | FCFIDU, FCFIDS, FCFIDUS, |
| 64 | |
David Majnemer | 08249a3 | 2013-09-26 05:22:11 +0000 | [diff] [blame] | 65 | /// FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64 |
| 66 | /// operand, producing an f64 value containing the integer representation |
| 67 | /// of that FP value. |
| 68 | FCTIDZ, FCTIWZ, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 69 | |
Hal Finkel | f6d45f2 | 2013-04-01 17:52:07 +0000 | [diff] [blame] | 70 | /// Newer FCTI[D,W]UZ floating-point-to-integer conversion instructions for |
Tony Jiang | 3a2f00b | 2017-01-05 15:00:45 +0000 | [diff] [blame] | 71 | /// unsigned integers with round toward zero. |
Hal Finkel | f6d45f2 | 2013-04-01 17:52:07 +0000 | [diff] [blame] | 72 | FCTIDUZ, FCTIWUZ, |
| 73 | |
Lei Huang | c29229a | 2018-05-08 17:36:40 +0000 | [diff] [blame] | 74 | /// Floating-point-to-interger conversion instructions |
| 75 | FP_TO_UINT_IN_VSR, FP_TO_SINT_IN_VSR, |
| 76 | |
Nemanja Ivanovic | 11049f8 | 2016-10-04 06:59:23 +0000 | [diff] [blame] | 77 | /// VEXTS, ByteWidth - takes an input in VSFRC and produces an output in |
| 78 | /// VSFRC that is sign-extended from ByteWidth to a 64-byte integer. |
| 79 | VEXTS, |
| 80 | |
Tony Jiang | 9a91a18 | 2017-07-05 16:00:38 +0000 | [diff] [blame] | 81 | /// SExtVElems, takes an input vector of a smaller type and sign |
| 82 | /// extends to an output vector of a larger type. |
| 83 | SExtVElems, |
| 84 | |
Hal Finkel | 2e10331 | 2013-04-03 04:01:11 +0000 | [diff] [blame] | 85 | /// Reciprocal estimate instructions (unary FP ops). |
| 86 | FRE, FRSQRTE, |
| 87 | |
Nate Begeman | 69caef2 | 2005-12-13 22:55:22 +0000 | [diff] [blame] | 88 | // VMADDFP, VNMSUBFP - The VMADDFP and VNMSUBFP instructions, taking |
| 89 | // three v4f32 operands and producing a v4f32 result. |
| 90 | VMADDFP, VNMSUBFP, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 91 | |
Chris Lattner | a8713b1 | 2006-03-20 01:53:53 +0000 | [diff] [blame] | 92 | /// VPERM - The PPC VPERM Instruction. |
| 93 | /// |
| 94 | VPERM, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 95 | |
Nemanja Ivanovic | 1a2b2f0 | 2016-05-04 16:04:02 +0000 | [diff] [blame] | 96 | /// XXSPLT - The PPC VSX splat instructions |
| 97 | /// |
| 98 | XXSPLT, |
| 99 | |
Tony Jiang | 61ef1c5 | 2017-09-05 18:08:02 +0000 | [diff] [blame] | 100 | /// VECINSERT - The PPC vector insert instruction |
Nemanja Ivanovic | b43bb61 | 2016-07-12 21:00:10 +0000 | [diff] [blame] | 101 | /// |
Tony Jiang | 61ef1c5 | 2017-09-05 18:08:02 +0000 | [diff] [blame] | 102 | VECINSERT, |
Nemanja Ivanovic | b43bb61 | 2016-07-12 21:00:10 +0000 | [diff] [blame] | 103 | |
Tony Jiang | 1a8eec1 | 2017-06-12 18:24:36 +0000 | [diff] [blame] | 104 | /// XXREVERSE - The PPC VSX reverse instruction |
| 105 | /// |
| 106 | XXREVERSE, |
| 107 | |
Tony Jiang | 61ef1c5 | 2017-09-05 18:08:02 +0000 | [diff] [blame] | 108 | /// VECSHL - The PPC vector shift left instruction |
Nemanja Ivanovic | b43bb61 | 2016-07-12 21:00:10 +0000 | [diff] [blame] | 109 | /// |
| 110 | VECSHL, |
| 111 | |
Tony Jiang | 60c247d | 2017-05-31 13:09:57 +0000 | [diff] [blame] | 112 | /// XXPERMDI - The PPC XXPERMDI instruction |
| 113 | /// |
| 114 | XXPERMDI, |
| 115 | |
Hal Finkel | 4edc66b | 2015-01-03 01:16:37 +0000 | [diff] [blame] | 116 | /// The CMPB instruction (takes two operands of i32 or i64). |
| 117 | CMPB, |
| 118 | |
Chris Lattner | 595088a | 2005-11-17 07:30:41 +0000 | [diff] [blame] | 119 | /// Hi/Lo - These represent the high and low 16-bit parts of a global |
| 120 | /// address respectively. These nodes have two operands, the first of |
| 121 | /// which must be a TargetGlobalAddress, and the second of which must be a |
| 122 | /// Constant. Selected naively, these turn into 'lis G+C' and 'li G+C', |
| 123 | /// though these are usually folded into other nodes. |
| 124 | Hi, Lo, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 125 | |
Ulrich Weigand | ad0cb91 | 2014-06-18 17:52:49 +0000 | [diff] [blame] | 126 | /// The following two target-specific nodes are used for calls through |
Tilmann Scheller | 79fef93 | 2009-12-18 13:00:15 +0000 | [diff] [blame] | 127 | /// function pointers in the 64-bit SVR4 ABI. |
| 128 | |
Jim Laskey | 48850c1 | 2006-11-16 22:43:37 +0000 | [diff] [blame] | 129 | /// OPRC, CHAIN = DYNALLOC(CHAIN, NEGSIZE, FRAME_INDEX) |
| 130 | /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to |
| 131 | /// compute an allocation on the stack. |
| 132 | DYNALLOC, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 133 | |
Yury Gribov | d7dbb66 | 2015-12-01 11:40:55 +0000 | [diff] [blame] | 134 | /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to |
| 135 | /// compute an offset from native SP to the address of the most recent |
| 136 | /// dynamic alloca. |
| 137 | DYNAREAOFFSET, |
| 138 | |
Chris Lattner | 595088a | 2005-11-17 07:30:41 +0000 | [diff] [blame] | 139 | /// GlobalBaseReg - On Darwin, this node represents the result of the mflr |
| 140 | /// at function entry, used for PIC code. |
| 141 | GlobalBaseReg, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 142 | |
Tim Shen | 10c64e6 | 2017-05-12 19:25:37 +0000 | [diff] [blame] | 143 | /// These nodes represent PPC shifts. |
| 144 | /// |
| 145 | /// For scalar types, only the last `n + 1` bits of the shift amounts |
| 146 | /// are used, where n is log2(sizeof(element) * 8). See sld/slw, etc. |
| 147 | /// for exact behaviors. |
| 148 | /// |
| 149 | /// For vector types, only the last n bits are used. See vsld. |
Chris Lattner | fea33f7 | 2005-12-06 02:10:38 +0000 | [diff] [blame] | 150 | SRL, SRA, SHL, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 151 | |
Hal Finkel | 13d104b | 2014-12-11 18:37:52 +0000 | [diff] [blame] | 152 | /// The combination of sra[wd]i and addze used to implemented signed |
| 153 | /// integer division by a power of 2. The first operand is the dividend, |
| 154 | /// and the second is the constant shift amount (representing the |
| 155 | /// divisor). |
| 156 | SRA_ADDZE, |
| 157 | |
Chris Lattner | eb755fc | 2006-05-17 19:00:46 +0000 | [diff] [blame] | 158 | /// CALL - A direct function call. |
Ulrich Weigand | f62e83f | 2013-03-22 15:24:13 +0000 | [diff] [blame] | 159 | /// CALL_NOP is a call with the special NOP which follows 64-bit |
Hal Finkel | 51861b4 | 2012-03-31 14:45:15 +0000 | [diff] [blame] | 160 | /// SVR4 calls. |
Ulrich Weigand | f62e83f | 2013-03-22 15:24:13 +0000 | [diff] [blame] | 161 | CALL, CALL_NOP, |
Tilmann Scheller | d1aaa32 | 2009-08-15 11:54:46 +0000 | [diff] [blame] | 162 | |
Chris Lattner | eb755fc | 2006-05-17 19:00:46 +0000 | [diff] [blame] | 163 | /// CHAIN,FLAG = MTCTR(VAL, CHAIN[, INFLAG]) - Directly corresponds to a |
| 164 | /// MTCTR instruction. |
| 165 | MTCTR, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 166 | |
Chris Lattner | eb755fc | 2006-05-17 19:00:46 +0000 | [diff] [blame] | 167 | /// CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a |
| 168 | /// BCTRL instruction. |
Ulrich Weigand | f62e83f | 2013-03-22 15:24:13 +0000 | [diff] [blame] | 169 | BCTRL, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 170 | |
Hal Finkel | fc096c9 | 2014-12-23 22:29:40 +0000 | [diff] [blame] | 171 | /// CHAIN,FLAG = BCTRL(CHAIN, ADDR, INFLAG) - The combination of a bctrl |
| 172 | /// instruction and the TOC reload required on SVR4 PPC64. |
| 173 | BCTRL_LOAD_TOC, |
| 174 | |
Nate Begeman | b11b8e4 | 2005-12-20 00:26:01 +0000 | [diff] [blame] | 175 | /// Return with a flag operand, matched by 'blr' |
| 176 | RET_FLAG, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 177 | |
Ulrich Weigand | d5ebc62 | 2013-07-03 17:05:42 +0000 | [diff] [blame] | 178 | /// R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction. |
| 179 | /// This copies the bits corresponding to the specified CRREG into the |
| 180 | /// resultant GPR. Bits corresponding to other CR regs are undefined. |
| 181 | MFOCRF, |
Chris Lattner | d7495ae | 2006-03-31 05:13:27 +0000 | [diff] [blame] | 182 | |
Nemanja Ivanovic | c38b531 | 2015-04-11 10:40:42 +0000 | [diff] [blame] | 183 | /// Direct move from a VSX register to a GPR |
| 184 | MFVSR, |
| 185 | |
| 186 | /// Direct move from a GPR to a VSX register (algebraic) |
| 187 | MTVSRA, |
| 188 | |
| 189 | /// Direct move from a GPR to a VSX register (zero) |
| 190 | MTVSRZ, |
| 191 | |
Nemanja Ivanovic | 44513e5 | 2016-07-05 09:22:29 +0000 | [diff] [blame] | 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 | |
| 198 | /// Extract a subvector from unsigned integer vector and convert to FP. |
| 199 | /// As with SINT_VEC_TO_FP, used for converting illegal types. |
| 200 | UINT_VEC_TO_FP, |
| 201 | |
Hal Finkel | 940ab93 | 2014-02-28 00:27:01 +0000 | [diff] [blame] | 202 | // FIXME: Remove these once the ANDI glue bug is fixed: |
| 203 | /// i1 = ANDIo_1_[EQ|GT]_BIT(i32 or i64 x) - Represents the result of the |
| 204 | /// eq or gt bit of CR0 after executing andi. x, 1. This is used to |
| 205 | /// implement truncation of i32 or i64 to i1. |
| 206 | ANDIo_1_EQ_BIT, ANDIo_1_GT_BIT, |
| 207 | |
Hal Finkel | bbdee93 | 2014-12-02 22:01:00 +0000 | [diff] [blame] | 208 | // READ_TIME_BASE - A read of the 64-bit time-base register on a 32-bit |
| 209 | // target (returns (Lo, Hi)). It takes a chain operand. |
| 210 | READ_TIME_BASE, |
| 211 | |
Hal Finkel | 756810f | 2013-03-21 21:37:52 +0000 | [diff] [blame] | 212 | // EH_SJLJ_SETJMP - SjLj exception handling setjmp. |
| 213 | EH_SJLJ_SETJMP, |
| 214 | |
| 215 | // EH_SJLJ_LONGJMP - SjLj exception handling longjmp. |
| 216 | EH_SJLJ_LONGJMP, |
| 217 | |
Chris Lattner | d7495ae | 2006-03-31 05:13:27 +0000 | [diff] [blame] | 218 | /// RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP* |
| 219 | /// instructions. For lack of better number, we use the opcode number |
| 220 | /// encoding for the OPC field to identify the compare. For example, 838 |
| 221 | /// is VCMPGTSH. |
| 222 | VCMP, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 223 | |
Chris Lattner | 6961fc7 | 2006-03-26 10:06:40 +0000 | [diff] [blame] | 224 | /// RESVEC, OUTFLAG = VCMPo(LHS, RHS, OPC) - Represents one of the |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 225 | /// altivec VCMP*o instructions. For lack of better number, we use the |
Chris Lattner | 6961fc7 | 2006-03-26 10:06:40 +0000 | [diff] [blame] | 226 | /// opcode number encoding for the OPC field to identify the compare. For |
| 227 | /// example, 838 is VCMPGTSH. |
Chris Lattner | 9754d14 | 2006-04-18 17:59:36 +0000 | [diff] [blame] | 228 | VCMPo, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 229 | |
Chris Lattner | 9754d14 | 2006-04-18 17:59:36 +0000 | [diff] [blame] | 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. |
Chris Lattner | a7976d3 | 2006-07-10 20:56:58 +0000 | [diff] [blame] | 235 | COND_BRANCH, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 236 | |
Hal Finkel | 25c1992 | 2013-05-15 21:37:41 +0000 | [diff] [blame] | 237 | /// CHAIN = BDNZ CHAIN, DESTBB - These are used to create counter-based |
| 238 | /// loops. |
| 239 | BDNZ, BDZ, |
| 240 | |
Ulrich Weigand | 874fc62 | 2013-03-26 10:56:22 +0000 | [diff] [blame] | 241 | /// F8RC = FADDRTZ F8RC, F8RC - This is an FADD done with rounding |
| 242 | /// towards zero. Used only as part of the long double-to-int |
| 243 | /// conversion sequence. |
Dale Johannesen | 666323e | 2007-10-10 01:01:31 +0000 | [diff] [blame] | 244 | FADDRTZ, |
| 245 | |
Ulrich Weigand | 874fc62 | 2013-03-26 10:56:22 +0000 | [diff] [blame] | 246 | /// F8RC = MFFS - This moves the FPSCR (not modeled) into the register. |
| 247 | MFFS, |
Evan Cheng | 51096af | 2008-04-19 01:30:48 +0000 | [diff] [blame] | 248 | |
Arnold Schwaighofer | be0de34 | 2008-04-30 09:16:33 +0000 | [diff] [blame] | 249 | /// TC_RETURN - A tail call return. |
| 250 | /// operand #0 chain |
| 251 | /// operand #1 callee (register or absolute) |
| 252 | /// operand #2 stack adjustment |
| 253 | /// operand #3 optional in flag |
Dan Gohman | 48b185d | 2009-09-25 20:36:54 +0000 | [diff] [blame] | 254 | TC_RETURN, |
| 255 | |
Hal Finkel | 5ab3780 | 2012-08-28 02:10:27 +0000 | [diff] [blame] | 256 | /// ch, gl = CR6[UN]SET ch, inglue - Toggle CR bit 6 for SVR4 vararg calls |
| 257 | CR6SET, |
| 258 | CR6UNSET, |
| 259 | |
Roman Divacky | 8854e76 | 2013-12-22 09:48:38 +0000 | [diff] [blame] | 260 | /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by initial-exec TLS |
| 261 | /// on PPC32. |
Roman Divacky | 32143e2 | 2013-12-20 18:08:54 +0000 | [diff] [blame] | 262 | PPC32_GOT, |
| 263 | |
Hal Finkel | 7c8ae53 | 2014-07-25 17:47:22 +0000 | [diff] [blame] | 264 | /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by general dynamic and |
Hal Finkel | 0746211 | 2015-02-25 18:06:45 +0000 | [diff] [blame] | 265 | /// local dynamic TLS on PPC32. |
Hal Finkel | 7c8ae53 | 2014-07-25 17:47:22 +0000 | [diff] [blame] | 266 | PPC32_PICGOT, |
| 267 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 268 | /// G8RC = ADDIS_GOT_TPREL_HA %x2, Symbol - Used by the initial-exec |
Bill Schmidt | 9f0b4ec | 2012-12-14 17:02:38 +0000 | [diff] [blame] | 269 | /// TLS model, produces an ADDIS8 instruction that adds the GOT |
NAKAMURA Takumi | dc9f013 | 2013-05-15 18:01:35 +0000 | [diff] [blame] | 270 | /// base to sym\@got\@tprel\@ha. |
Bill Schmidt | 9f0b4ec | 2012-12-14 17:02:38 +0000 | [diff] [blame] | 271 | ADDIS_GOT_TPREL_HA, |
| 272 | |
| 273 | /// G8RC = LD_GOT_TPREL_L Symbol, G8RReg - Used by the initial-exec |
Bill Schmidt | ca4a0c9 | 2012-12-04 16:18:08 +0000 | [diff] [blame] | 274 | /// TLS model, produces a LD instruction with base register G8RReg |
NAKAMURA Takumi | dc9f013 | 2013-05-15 18:01:35 +0000 | [diff] [blame] | 275 | /// and offset sym\@got\@tprel\@l. This completes the addition that |
Bill Schmidt | 9f0b4ec | 2012-12-14 17:02:38 +0000 | [diff] [blame] | 276 | /// finds the offset of "sym" relative to the thread pointer. |
| 277 | LD_GOT_TPREL_L, |
Bill Schmidt | ca4a0c9 | 2012-12-04 16:18:08 +0000 | [diff] [blame] | 278 | |
| 279 | /// G8RC = ADD_TLS G8RReg, Symbol - Used by the initial-exec TLS |
| 280 | /// model, produces an ADD instruction that adds the contents of |
| 281 | /// G8RReg to the thread pointer. Symbol contains a relocation |
NAKAMURA Takumi | dc9f013 | 2013-05-15 18:01:35 +0000 | [diff] [blame] | 282 | /// sym\@tls which is to be replaced by the thread pointer and |
Bill Schmidt | ca4a0c9 | 2012-12-04 16:18:08 +0000 | [diff] [blame] | 283 | /// identifies to the linker that the instruction is part of a |
| 284 | /// TLS sequence. |
| 285 | ADD_TLS, |
| 286 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 287 | /// G8RC = ADDIS_TLSGD_HA %x2, Symbol - For the general-dynamic TLS |
Bill Schmidt | c56f1d3 | 2012-12-11 20:30:11 +0000 | [diff] [blame] | 288 | /// model, produces an ADDIS8 instruction that adds the GOT base |
NAKAMURA Takumi | dc9f013 | 2013-05-15 18:01:35 +0000 | [diff] [blame] | 289 | /// register to sym\@got\@tlsgd\@ha. |
Bill Schmidt | c56f1d3 | 2012-12-11 20:30:11 +0000 | [diff] [blame] | 290 | ADDIS_TLSGD_HA, |
| 291 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 292 | /// %x3 = ADDI_TLSGD_L G8RReg, Symbol - For the general-dynamic TLS |
Bill Schmidt | c56f1d3 | 2012-12-11 20:30:11 +0000 | [diff] [blame] | 293 | /// model, produces an ADDI8 instruction that adds G8RReg to |
Bill Schmidt | 82f1c77 | 2015-02-10 19:09:05 +0000 | [diff] [blame] | 294 | /// sym\@got\@tlsgd\@l and stores the result in X3. Hidden by |
| 295 | /// ADDIS_TLSGD_L_ADDR until after register assignment. |
Bill Schmidt | c56f1d3 | 2012-12-11 20:30:11 +0000 | [diff] [blame] | 296 | ADDI_TLSGD_L, |
| 297 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 298 | /// %x3 = GET_TLS_ADDR %x3, Symbol - For the general-dynamic TLS |
Bill Schmidt | 82f1c77 | 2015-02-10 19:09:05 +0000 | [diff] [blame] | 299 | /// model, produces a call to __tls_get_addr(sym\@tlsgd). Hidden by |
| 300 | /// ADDIS_TLSGD_L_ADDR until after register assignment. |
| 301 | GET_TLS_ADDR, |
| 302 | |
| 303 | /// G8RC = ADDI_TLSGD_L_ADDR G8RReg, Symbol, Symbol - Op that |
| 304 | /// combines ADDI_TLSGD_L and GET_TLS_ADDR until expansion following |
| 305 | /// register assignment. |
| 306 | ADDI_TLSGD_L_ADDR, |
| 307 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 308 | /// G8RC = ADDIS_TLSLD_HA %x2, Symbol - For the local-dynamic TLS |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 309 | /// model, produces an ADDIS8 instruction that adds the GOT base |
NAKAMURA Takumi | dc9f013 | 2013-05-15 18:01:35 +0000 | [diff] [blame] | 310 | /// register to sym\@got\@tlsld\@ha. |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 311 | ADDIS_TLSLD_HA, |
| 312 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 313 | /// %x3 = ADDI_TLSLD_L G8RReg, Symbol - For the local-dynamic TLS |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 314 | /// model, produces an ADDI8 instruction that adds G8RReg to |
Bill Schmidt | 82f1c77 | 2015-02-10 19:09:05 +0000 | [diff] [blame] | 315 | /// sym\@got\@tlsld\@l and stores the result in X3. Hidden by |
| 316 | /// ADDIS_TLSLD_L_ADDR until after register assignment. |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 317 | ADDI_TLSLD_L, |
| 318 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 319 | /// %x3 = GET_TLSLD_ADDR %x3, Symbol - For the local-dynamic TLS |
Bill Schmidt | 82f1c77 | 2015-02-10 19:09:05 +0000 | [diff] [blame] | 320 | /// model, produces a call to __tls_get_addr(sym\@tlsld). Hidden by |
| 321 | /// ADDIS_TLSLD_L_ADDR until after register assignment. |
| 322 | GET_TLSLD_ADDR, |
| 323 | |
| 324 | /// G8RC = ADDI_TLSLD_L_ADDR G8RReg, Symbol, Symbol - Op that |
| 325 | /// combines ADDI_TLSLD_L and GET_TLSLD_ADDR until expansion |
| 326 | /// following register assignment. |
| 327 | ADDI_TLSLD_L_ADDR, |
| 328 | |
Francis Visoiu Mistrih | 9d7bb0c | 2017-11-28 17:15:09 +0000 | [diff] [blame] | 329 | /// G8RC = ADDIS_DTPREL_HA %x3, Symbol - For the local-dynamic TLS |
Bill Schmidt | 82f1c77 | 2015-02-10 19:09:05 +0000 | [diff] [blame] | 330 | /// model, produces an ADDIS8 instruction that adds X3 to |
| 331 | /// sym\@dtprel\@ha. |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 332 | ADDIS_DTPREL_HA, |
| 333 | |
| 334 | /// G8RC = ADDI_DTPREL_L G8RReg, Symbol - For the local-dynamic TLS |
| 335 | /// model, produces an ADDI8 instruction that adds G8RReg to |
NAKAMURA Takumi | dc9f013 | 2013-05-15 18:01:35 +0000 | [diff] [blame] | 336 | /// sym\@got\@dtprel\@l. |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 337 | ADDI_DTPREL_L, |
| 338 | |
Bill Schmidt | 51e7951 | 2013-02-20 15:50:31 +0000 | [diff] [blame] | 339 | /// VRRC = VADD_SPLAT Elt, EltSize - Temporary node to be expanded |
Bill Schmidt | c6cbecc | 2013-02-20 20:41:42 +0000 | [diff] [blame] | 340 | /// during instruction selection to optimize a BUILD_VECTOR into |
| 341 | /// operations on splats. This is necessary to avoid losing these |
| 342 | /// optimizations due to constant folding. |
Bill Schmidt | 51e7951 | 2013-02-20 15:50:31 +0000 | [diff] [blame] | 343 | VADD_SPLAT, |
| 344 | |
Bill Schmidt | a87a7e2 | 2013-05-14 19:35:45 +0000 | [diff] [blame] | 345 | /// CHAIN = SC CHAIN, Imm128 - System call. The 7-bit unsigned |
| 346 | /// operand identifies the operating system entry point. |
| 347 | SC, |
| 348 | |
Bill Schmidt | e26236e | 2015-05-22 16:44:10 +0000 | [diff] [blame] | 349 | /// CHAIN = CLRBHRB CHAIN - Clear branch history rolling buffer. |
| 350 | CLRBHRB, |
| 351 | |
| 352 | /// GPRC, CHAIN = MFBHRBE CHAIN, Entry, Dummy - Move from branch |
| 353 | /// history rolling buffer entry. |
| 354 | MFBHRBE, |
| 355 | |
| 356 | /// CHAIN = RFEBB CHAIN, State - Return from event-based branch. |
| 357 | RFEBB, |
| 358 | |
Bill Schmidt | fae5d71 | 2014-12-09 16:35:51 +0000 | [diff] [blame] | 359 | /// VSRC, CHAIN = XXSWAPD CHAIN, VSRC - Occurs only for little |
| 360 | /// endian. Maps to an xxswapd instruction that corrects an lxvd2x |
| 361 | /// or stxvd2x instruction. The chain is necessary because the |
| 362 | /// sequence replaces a load and needs to provide the same number |
| 363 | /// of outputs. |
| 364 | XXSWAPD, |
| 365 | |
Nemanja Ivanovic | eebbcb6 | 2016-07-12 12:16:27 +0000 | [diff] [blame] | 366 | /// An SDNode for swaps that are not associated with any loads/stores |
| 367 | /// and thereby have no chain. |
| 368 | SWAP_NO_CHAIN, |
| 369 | |
Hal Finkel | c93a9a2 | 2015-02-25 01:06:45 +0000 | [diff] [blame] | 370 | /// QVFPERM = This corresponds to the QPX qvfperm instruction. |
| 371 | QVFPERM, |
| 372 | |
| 373 | /// QVGPCI = This corresponds to the QPX qvgpci instruction. |
| 374 | QVGPCI, |
| 375 | |
| 376 | /// QVALIGNI = This corresponds to the QPX qvaligni instruction. |
| 377 | QVALIGNI, |
| 378 | |
| 379 | /// QVESPLATI = This corresponds to the QPX qvesplati instruction. |
| 380 | QVESPLATI, |
| 381 | |
| 382 | /// QBFLT = Access the underlying QPX floating-point boolean |
| 383 | /// representation. |
| 384 | QBFLT, |
| 385 | |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 386 | /// CHAIN = STBRX CHAIN, GPRC, Ptr, Type - This is a |
Dan Gohman | 48b185d | 2009-09-25 20:36:54 +0000 | [diff] [blame] | 387 | /// byte-swapping store instruction. It byte-swaps the low "Type" bits of |
| 388 | /// the GPRC input, then stores it through Ptr. Type can be either i16 or |
| 389 | /// i32. |
Hal Finkel | e53429a | 2013-03-31 01:58:02 +0000 | [diff] [blame] | 390 | STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 391 | |
| 392 | /// GPRC, CHAIN = LBRX CHAIN, Ptr, Type - This is a |
Dan Gohman | 48b185d | 2009-09-25 20:36:54 +0000 | [diff] [blame] | 393 | /// byte-swapping load instruction. It loads "Type" bits, byte swaps it, |
| 394 | /// then puts it in the bottom bits of the GPRC. TYPE can be either i16 |
| 395 | /// or i32. |
Bill Schmidt | 34627e3 | 2012-11-27 17:35:46 +0000 | [diff] [blame] | 396 | LBRX, |
| 397 | |
Hal Finkel | 60c7510 | 2013-04-01 15:37:53 +0000 | [diff] [blame] | 398 | /// STFIWX - The STFIWX instruction. The first operand is an input token |
| 399 | /// chain, then an f64 value to store, then an address to store it to. |
| 400 | STFIWX, |
| 401 | |
Hal Finkel | beb296b | 2013-03-31 10:12:51 +0000 | [diff] [blame] | 402 | /// GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point |
| 403 | /// load which sign-extends from a 32-bit integer value into the |
| 404 | /// destination 64-bit register. |
| 405 | LFIWAX, |
| 406 | |
Hal Finkel | f6d45f2 | 2013-04-01 17:52:07 +0000 | [diff] [blame] | 407 | /// GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point |
| 408 | /// load which zero-extends from a 32-bit integer value into the |
| 409 | /// destination 64-bit register. |
| 410 | LFIWZX, |
| 411 | |
Nemanja Ivanovic | 11049f8 | 2016-10-04 06:59:23 +0000 | [diff] [blame] | 412 | /// GPRC, CHAIN = LXSIZX, CHAIN, Ptr, ByteWidth - This is a load of an |
| 413 | /// integer smaller than 64 bits into a VSR. The integer is zero-extended. |
| 414 | /// This can be used for converting loaded integers to floating point. |
| 415 | LXSIZX, |
| 416 | |
| 417 | /// STXSIX - The STXSI[bh]X instruction. The first operand is an input |
| 418 | /// chain, then an f64 value to store, then an address to store it to, |
| 419 | /// followed by a byte-width for the store. |
| 420 | STXSIX, |
| 421 | |
Bill Schmidt | fae5d71 | 2014-12-09 16:35:51 +0000 | [diff] [blame] | 422 | /// VSRC, CHAIN = LXVD2X_LE CHAIN, Ptr - Occurs only for little endian. |
| 423 | /// Maps directly to an lxvd2x instruction that will be followed by |
| 424 | /// an xxswapd. |
| 425 | LXVD2X, |
| 426 | |
| 427 | /// CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian. |
| 428 | /// Maps directly to an stxvd2x instruction that will be preceded by |
| 429 | /// an xxswapd. |
Hal Finkel | c93a9a2 | 2015-02-25 01:06:45 +0000 | [diff] [blame] | 430 | STXVD2X, |
| 431 | |
Lei Huang | c29229a | 2018-05-08 17:36:40 +0000 | [diff] [blame] | 432 | /// Store scalar integers from VSR. |
| 433 | ST_VSR_SCAL_INT, |
| 434 | |
Hal Finkel | c93a9a2 | 2015-02-25 01:06:45 +0000 | [diff] [blame] | 435 | /// QBRC, CHAIN = QVLFSb CHAIN, Ptr |
| 436 | /// The 4xf32 load used for v4i1 constants. |
Hal Finkel | cf59921 | 2015-02-25 21:36:59 +0000 | [diff] [blame] | 437 | QVLFSb, |
| 438 | |
Nemanja Ivanovic | ebb2307 | 2018-01-12 14:58:41 +0000 | [diff] [blame] | 439 | /// ATOMIC_CMP_SWAP - the exact same as the target-independent nodes |
| 440 | /// except they ensure that the compare input is zero-extended for |
| 441 | /// sub-word versions because the atomic loads zero-extend. |
| 442 | ATOMIC_CMP_SWAP_8, ATOMIC_CMP_SWAP_16, |
| 443 | |
Hal Finkel | cf59921 | 2015-02-25 21:36:59 +0000 | [diff] [blame] | 444 | /// GPRC = TOC_ENTRY GA, TOC |
| 445 | /// Loads the entry for GA from the TOC, where the TOC base is given by |
| 446 | /// the last operand. |
| 447 | TOC_ENTRY |
Chris Lattner | f424a66 | 2006-01-27 23:34:02 +0000 | [diff] [blame] | 448 | }; |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 449 | |
| 450 | } // end namespace PPCISD |
Chris Lattner | 382f356 | 2006-03-20 06:15:45 +0000 | [diff] [blame] | 451 | |
| 452 | /// Define some predicates that are used for node matching. |
| 453 | namespace PPC { |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 454 | |
Chris Lattner | e8b83b4 | 2006-04-06 17:23:16 +0000 | [diff] [blame] | 455 | /// isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a |
| 456 | /// VPKUHUM instruction. |
Ulrich Weigand | cc9909b | 2014-08-04 13:53:40 +0000 | [diff] [blame] | 457 | bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, |
Bill Schmidt | f910a06 | 2014-06-10 14:35:01 +0000 | [diff] [blame] | 458 | SelectionDAG &DAG); |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 459 | |
Chris Lattner | e8b83b4 | 2006-04-06 17:23:16 +0000 | [diff] [blame] | 460 | /// isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a |
| 461 | /// VPKUWUM instruction. |
Ulrich Weigand | cc9909b | 2014-08-04 13:53:40 +0000 | [diff] [blame] | 462 | bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, |
Bill Schmidt | f910a06 | 2014-06-10 14:35:01 +0000 | [diff] [blame] | 463 | SelectionDAG &DAG); |
Chris Lattner | d1dcb52 | 2006-04-06 21:11:54 +0000 | [diff] [blame] | 464 | |
Bill Schmidt | 5ed84cd | 2015-05-16 01:02:12 +0000 | [diff] [blame] | 465 | /// isVPKUDUMShuffleMask - Return true if this is the shuffle mask for a |
| 466 | /// VPKUDUM instruction. |
| 467 | bool isVPKUDUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, |
| 468 | SelectionDAG &DAG); |
| 469 | |
Chris Lattner | d1dcb52 | 2006-04-06 21:11:54 +0000 | [diff] [blame] | 470 | /// isVMRGLShuffleMask - Return true if this is a shuffle mask suitable for |
| 471 | /// a VRGL* instruction with the specified unit size (1,2 or 4 bytes). |
Nate Begeman | 8d6d4b9 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 472 | bool isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize, |
Bill Schmidt | c9fa5dd | 2014-07-25 01:55:55 +0000 | [diff] [blame] | 473 | unsigned ShuffleKind, SelectionDAG &DAG); |
Chris Lattner | d1dcb52 | 2006-04-06 21:11:54 +0000 | [diff] [blame] | 474 | |
| 475 | /// isVMRGHShuffleMask - Return true if this is a shuffle mask suitable for |
| 476 | /// a VRGH* instruction with the specified unit size (1,2 or 4 bytes). |
Nate Begeman | 8d6d4b9 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 477 | bool isVMRGHShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize, |
Bill Schmidt | c9fa5dd | 2014-07-25 01:55:55 +0000 | [diff] [blame] | 478 | unsigned ShuffleKind, SelectionDAG &DAG); |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 479 | |
Kit Barton | 13894c7 | 2015-06-25 15:17:40 +0000 | [diff] [blame] | 480 | /// isVMRGEOShuffleMask - Return true if this is a shuffle mask suitable for |
| 481 | /// a VMRGEW or VMRGOW instruction |
| 482 | bool isVMRGEOShuffleMask(ShuffleVectorSDNode *N, bool CheckEven, |
| 483 | unsigned ShuffleKind, SelectionDAG &DAG); |
Tony Jiang | 0a429f0 | 2017-05-24 23:48:29 +0000 | [diff] [blame] | 484 | /// isXXSLDWIShuffleMask - Return true if this is a shuffle mask suitable |
| 485 | /// for a XXSLDWI instruction. |
| 486 | bool isXXSLDWIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, |
| 487 | bool &Swap, bool IsLE); |
Tony Jiang | 1a8eec1 | 2017-06-12 18:24:36 +0000 | [diff] [blame] | 488 | |
| 489 | /// isXXBRHShuffleMask - Return true if this is a shuffle mask suitable |
| 490 | /// for a XXBRH instruction. |
| 491 | bool isXXBRHShuffleMask(ShuffleVectorSDNode *N); |
| 492 | |
| 493 | /// isXXBRWShuffleMask - Return true if this is a shuffle mask suitable |
| 494 | /// for a XXBRW instruction. |
| 495 | bool isXXBRWShuffleMask(ShuffleVectorSDNode *N); |
| 496 | |
| 497 | /// isXXBRDShuffleMask - Return true if this is a shuffle mask suitable |
| 498 | /// for a XXBRD instruction. |
| 499 | bool isXXBRDShuffleMask(ShuffleVectorSDNode *N); |
| 500 | |
| 501 | /// isXXBRQShuffleMask - Return true if this is a shuffle mask suitable |
| 502 | /// for a XXBRQ instruction. |
| 503 | bool isXXBRQShuffleMask(ShuffleVectorSDNode *N); |
| 504 | |
Tony Jiang | 60c247d | 2017-05-31 13:09:57 +0000 | [diff] [blame] | 505 | /// isXXPERMDIShuffleMask - Return true if this is a shuffle mask suitable |
| 506 | /// for a XXPERMDI instruction. |
| 507 | bool isXXPERMDIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, |
| 508 | bool &Swap, bool IsLE); |
Tony Jiang | 0a429f0 | 2017-05-24 23:48:29 +0000 | [diff] [blame] | 509 | |
Bill Schmidt | 42a6936 | 2014-08-05 20:47:25 +0000 | [diff] [blame] | 510 | /// isVSLDOIShuffleMask - If this is a vsldoi shuffle mask, return the |
| 511 | /// shift amount, otherwise return -1. |
| 512 | int isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind, |
| 513 | SelectionDAG &DAG); |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 514 | |
Chris Lattner | 382f356 | 2006-03-20 06:15:45 +0000 | [diff] [blame] | 515 | /// isSplatShuffleMask - Return true if the specified VECTOR_SHUFFLE operand |
| 516 | /// specifies a splat of a single element that is suitable for input to |
| 517 | /// VSPLTB/VSPLTH/VSPLTW. |
Nate Begeman | 8d6d4b9 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 518 | bool isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize); |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 519 | |
Nemanja Ivanovic | b43bb61 | 2016-07-12 21:00:10 +0000 | [diff] [blame] | 520 | /// isXXINSERTWMask - Return true if this VECTOR_SHUFFLE can be handled by |
| 521 | /// the XXINSERTW instruction introduced in ISA 3.0. This is essentially any |
| 522 | /// shuffle of v4f32/v4i32 vectors that just inserts one element from one |
| 523 | /// vector into the other. This function will also set a couple of |
| 524 | /// output parameters for how much the source vector needs to be shifted and |
| 525 | /// what byte number needs to be specified for the instruction to put the |
| 526 | /// element in the desired location of the target vector. |
| 527 | bool isXXINSERTWMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, |
| 528 | unsigned &InsertAtByte, bool &Swap, bool IsLE); |
| 529 | |
Chris Lattner | 382f356 | 2006-03-20 06:15:45 +0000 | [diff] [blame] | 530 | /// getVSPLTImmediate - Return the appropriate VSPLT* immediate to splat the |
| 531 | /// specified isSplatShuffleMask VECTOR_SHUFFLE mask. |
Bill Schmidt | f910a06 | 2014-06-10 14:35:01 +0000 | [diff] [blame] | 532 | unsigned getVSPLTImmediate(SDNode *N, unsigned EltSize, SelectionDAG &DAG); |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 533 | |
Chris Lattner | 74cf9ff | 2006-04-12 17:37:20 +0000 | [diff] [blame] | 534 | /// get_VSPLTI_elt - If this is a build_vector of constants which can be |
Chris Lattner | d71a1f9 | 2006-04-08 06:46:53 +0000 | [diff] [blame] | 535 | /// formed by using a vspltis[bhw] instruction of the specified element |
| 536 | /// size, return the constant being splatted. The ByteSize field indicates |
| 537 | /// the number of bytes of each element [124] -> [bhw]. |
Dan Gohman | 2ce6f2a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 538 | SDValue get_VSPLTI_elt(SDNode *N, unsigned ByteSize, SelectionDAG &DAG); |
Hal Finkel | c93a9a2 | 2015-02-25 01:06:45 +0000 | [diff] [blame] | 539 | |
| 540 | /// If this is a qvaligni shuffle mask, return the shift |
| 541 | /// amount, otherwise return -1. |
| 542 | int isQVALIGNIShuffleMask(SDNode *N); |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 543 | |
| 544 | } // end namespace PPC |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 545 | |
Nate Begeman | 6cca84e | 2005-10-16 05:39:50 +0000 | [diff] [blame] | 546 | class PPCTargetLowering : public TargetLowering { |
Eric Christopher | b1aaebe | 2014-06-12 22:38:18 +0000 | [diff] [blame] | 547 | const PPCSubtarget &Subtarget; |
Dan Gohman | 31ae586 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 548 | |
Chris Lattner | f22556d | 2005-08-16 17:14:42 +0000 | [diff] [blame] | 549 | public: |
Eric Christopher | cccae79 | 2015-01-30 22:02:31 +0000 | [diff] [blame] | 550 | explicit PPCTargetLowering(const PPCTargetMachine &TM, |
| 551 | const PPCSubtarget &STI); |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 552 | |
Chris Lattner | 347ed8a | 2006-01-09 23:52:17 +0000 | [diff] [blame] | 553 | /// getTargetNodeName() - This method returns the name of a target specific |
| 554 | /// DAG node. |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 555 | const char *getTargetNodeName(unsigned Opcode) const override; |
Chris Lattner | a801fced | 2006-11-08 02:15:41 +0000 | [diff] [blame] | 556 | |
Nemanja Ivanovic | 44513e5 | 2016-07-05 09:22:29 +0000 | [diff] [blame] | 557 | /// getPreferredVectorAction - The code we generate when vector types are |
| 558 | /// legalized by promoting the integer element type is often much worse |
| 559 | /// than code we generate if we widen the type for applicable vector types. |
| 560 | /// The issue with promoting is that the vector is scalaraized, individual |
| 561 | /// elements promoted and then the vector is rebuilt. So say we load a pair |
| 562 | /// of v4i8's and shuffle them. This will turn into a mess of 8 extending |
| 563 | /// loads, moves back into VSR's (or memory ops if we don't have moves) and |
| 564 | /// then the VPERM for the shuffle. All in all a very slow sequence. |
| 565 | TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(EVT VT) |
| 566 | const override { |
Sanjay Patel | 1ed771f | 2016-09-14 16:37:15 +0000 | [diff] [blame] | 567 | if (VT.getScalarSizeInBits() % 8 == 0) |
Nemanja Ivanovic | 44513e5 | 2016-07-05 09:22:29 +0000 | [diff] [blame] | 568 | return TypeWidenVector; |
| 569 | return TargetLoweringBase::getPreferredVectorAction(VT); |
| 570 | } |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 571 | |
Petar Jovanovic | 280f710 | 2015-12-14 17:57:33 +0000 | [diff] [blame] | 572 | bool useSoftFloat() const override; |
| 573 | |
Mehdi Amini | eaabc51 | 2015-07-09 15:12:23 +0000 | [diff] [blame] | 574 | MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override { |
Mehdi Amini | 9639d65 | 2015-07-09 02:09:20 +0000 | [diff] [blame] | 575 | return MVT::i32; |
| 576 | } |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 577 | |
Hal Finkel | 9bb61de | 2015-01-05 05:24:42 +0000 | [diff] [blame] | 578 | bool isCheapToSpeculateCttz() const override { |
| 579 | return true; |
| 580 | } |
| 581 | |
| 582 | bool isCheapToSpeculateCtlz() const override { |
| 583 | return true; |
| 584 | } |
| 585 | |
Pierre Gousseau | 051db7d | 2016-08-16 13:53:53 +0000 | [diff] [blame] | 586 | bool isCtlzFast() const override { |
| 587 | return true; |
| 588 | } |
| 589 | |
Hal Finkel | 5ef4b03 | 2016-09-02 02:58:25 +0000 | [diff] [blame] | 590 | bool hasAndNotCompare(SDValue) const override { |
| 591 | return true; |
| 592 | } |
| 593 | |
Sanjay Patel | b2f1621 | 2017-04-05 14:09:39 +0000 | [diff] [blame] | 594 | bool convertSetCCLogicToBitwiseLogic(EVT VT) const override { |
| 595 | return VT.isScalarInteger(); |
| 596 | } |
| 597 | |
Chuang-Yu Cheng | 98c1894 | 2016-04-08 12:04:32 +0000 | [diff] [blame] | 598 | bool supportSplitCSR(MachineFunction *MF) const override { |
| 599 | return |
Matthias Braun | f1caa28 | 2017-12-15 22:22:58 +0000 | [diff] [blame] | 600 | MF->getFunction().getCallingConv() == CallingConv::CXX_FAST_TLS && |
| 601 | MF->getFunction().hasFnAttribute(Attribute::NoUnwind); |
Chuang-Yu Cheng | 98c1894 | 2016-04-08 12:04:32 +0000 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | void initializeSplitCSR(MachineBasicBlock *Entry) const override; |
| 605 | |
| 606 | void insertCopiesSplitCSR( |
| 607 | MachineBasicBlock *Entry, |
| 608 | const SmallVectorImpl<MachineBasicBlock *> &Exits) const override; |
| 609 | |
Scott Michel | a6729e8 | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 610 | /// getSetCCResultType - Return the ISD::SETCC ValueType |
Mehdi Amini | 44ede33 | 2015-07-09 02:09:04 +0000 | [diff] [blame] | 611 | EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, |
| 612 | EVT VT) const override; |
Scott Michel | a6729e8 | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 613 | |
Hal Finkel | 62ac736 | 2014-09-19 11:42:56 +0000 | [diff] [blame] | 614 | /// Return true if target always beneficiates from combining into FMA for a |
| 615 | /// given value type. This must typically return false on targets where FMA |
| 616 | /// takes more cycles to execute than FADD. |
| 617 | bool enableAggressiveFMAFusion(EVT VT) const override; |
| 618 | |
Chris Lattner | a801fced | 2006-11-08 02:15:41 +0000 | [diff] [blame] | 619 | /// getPreIndexedAddressParts - returns true by value, base pointer and |
| 620 | /// offset pointer and addressing mode by reference if the node's address |
| 621 | /// can be legally represented as pre-indexed load / store address. |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 622 | bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, |
| 623 | SDValue &Offset, |
| 624 | ISD::MemIndexedMode &AM, |
| 625 | SelectionDAG &DAG) const override; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 626 | |
Chris Lattner | a801fced | 2006-11-08 02:15:41 +0000 | [diff] [blame] | 627 | /// SelectAddressRegReg - Given the specified addressed, check to see if it |
| 628 | /// can be represented as an indexed [r+r] operation. Returns false if it |
| 629 | /// can be more efficiently represented with [r+imm]. |
Dan Gohman | 2ce6f2a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 630 | bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index, |
Dan Gohman | 02b9313 | 2009-01-15 16:29:45 +0000 | [diff] [blame] | 631 | SelectionDAG &DAG) const; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 632 | |
Chris Lattner | a801fced | 2006-11-08 02:15:41 +0000 | [diff] [blame] | 633 | /// SelectAddressRegImm - Returns true if the address N can be represented |
| 634 | /// by a base register plus a signed 16-bit displacement [r+imm], and if it |
Ulrich Weigand | 9d980cb | 2013-05-16 17:58:02 +0000 | [diff] [blame] | 635 | /// is not better represented as reg+reg. If Aligned is true, only accept |
| 636 | /// displacements suitable for STD and friends, i.e. multiples of 4. |
Dan Gohman | 2ce6f2a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 637 | bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base, |
Nemanja Ivanovic | 3c7e276d | 2017-07-13 18:17:10 +0000 | [diff] [blame] | 638 | SelectionDAG &DAG, unsigned Alignment) const; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 639 | |
Chris Lattner | a801fced | 2006-11-08 02:15:41 +0000 | [diff] [blame] | 640 | /// SelectAddressRegRegOnly - Given the specified addressed, force it to be |
| 641 | /// represented as an indexed [r+r] operation. |
Dan Gohman | 2ce6f2a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 642 | bool SelectAddressRegRegOnly(SDValue N, SDValue &Base, SDValue &Index, |
Dan Gohman | 02b9313 | 2009-01-15 16:29:45 +0000 | [diff] [blame] | 643 | SelectionDAG &DAG) const; |
Chris Lattner | a801fced | 2006-11-08 02:15:41 +0000 | [diff] [blame] | 644 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 645 | Sched::Preference getSchedulingPreference(SDNode *N) const override; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 646 | |
Chris Lattner | f3d06c6 | 2005-08-26 00:52:45 +0000 | [diff] [blame] | 647 | /// LowerOperation - Provide custom lowering hooks for some operations. |
| 648 | /// |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 649 | SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; |
Chris Lattner | 57ee7c6 | 2007-11-28 18:44:47 +0000 | [diff] [blame] | 650 | |
Duncan Sands | 6ed4014 | 2008-12-01 11:39:25 +0000 | [diff] [blame] | 651 | /// ReplaceNodeResults - Replace the results of node with an illegal result |
| 652 | /// type with new values built out of custom code. |
| 653 | /// |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 654 | void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, |
| 655 | SelectionDAG &DAG) const override; |
Duncan Sands | 6ed4014 | 2008-12-01 11:39:25 +0000 | [diff] [blame] | 656 | |
Bill Schmidt | fae5d71 | 2014-12-09 16:35:51 +0000 | [diff] [blame] | 657 | SDValue expandVSXLoadForLE(SDNode *N, DAGCombinerInfo &DCI) const; |
| 658 | SDValue expandVSXStoreForLE(SDNode *N, DAGCombinerInfo &DCI) const; |
| 659 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 660 | SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 661 | |
Hal Finkel | 13d104b | 2014-12-11 18:37:52 +0000 | [diff] [blame] | 662 | SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, |
| 663 | std::vector<SDNode *> *Created) const override; |
| 664 | |
Pat Gavlin | a717f25 | 2015-07-09 17:40:29 +0000 | [diff] [blame] | 665 | unsigned getRegisterByName(const char* RegName, EVT VT, |
| 666 | SelectionDAG &DAG) const override; |
Hal Finkel | 0d8db46 | 2014-05-11 19:29:11 +0000 | [diff] [blame] | 667 | |
Jay Foad | a0653a3 | 2014-05-14 21:14:37 +0000 | [diff] [blame] | 668 | void computeKnownBitsForTargetNode(const SDValue Op, |
Craig Topper | d0af7e8 | 2017-04-28 05:31:46 +0000 | [diff] [blame] | 669 | KnownBits &Known, |
Simon Pilgrim | 37b536e | 2017-03-31 11:24:16 +0000 | [diff] [blame] | 670 | const APInt &DemandedElts, |
Jay Foad | a0653a3 | 2014-05-14 21:14:37 +0000 | [diff] [blame] | 671 | const SelectionDAG &DAG, |
| 672 | unsigned Depth = 0) const override; |
Nate Begeman | 78afac2 | 2005-10-18 23:23:37 +0000 | [diff] [blame] | 673 | |
Hal Finkel | 5772566 | 2015-01-03 17:58:24 +0000 | [diff] [blame] | 674 | unsigned getPrefLoopAlignment(MachineLoop *ML) const override; |
| 675 | |
James Y Knight | f44fc52 | 2016-03-16 22:12:04 +0000 | [diff] [blame] | 676 | bool shouldInsertFencesForAtomic(const Instruction *I) const override { |
| 677 | return true; |
| 678 | } |
| 679 | |
Tim Shen | 04de70d | 2017-05-09 15:27:17 +0000 | [diff] [blame] | 680 | Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst, |
| 681 | AtomicOrdering Ord) const override; |
| 682 | Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst, |
| 683 | AtomicOrdering Ord) const override; |
Robin Morisset | 2212996 | 2014-09-23 20:46:49 +0000 | [diff] [blame] | 684 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 685 | MachineBasicBlock * |
Duncan P. N. Exon Smith | e4f5e4f | 2016-06-30 22:52:52 +0000 | [diff] [blame] | 686 | EmitInstrWithCustomInserter(MachineInstr &MI, |
| 687 | MachineBasicBlock *MBB) const override; |
| 688 | MachineBasicBlock *EmitAtomicBinary(MachineInstr &MI, |
Nemanja Ivanovic | 0adf26b | 2015-03-10 20:51:07 +0000 | [diff] [blame] | 689 | MachineBasicBlock *MBB, |
| 690 | unsigned AtomicSize, |
Hal Finkel | 5728200 | 2016-08-28 16:17:58 +0000 | [diff] [blame] | 691 | unsigned BinOpcode, |
| 692 | unsigned CmpOpcode = 0, |
| 693 | unsigned CmpPred = 0) const; |
Duncan P. N. Exon Smith | e4f5e4f | 2016-06-30 22:52:52 +0000 | [diff] [blame] | 694 | MachineBasicBlock *EmitPartwordAtomicBinary(MachineInstr &MI, |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 695 | MachineBasicBlock *MBB, |
Duncan P. N. Exon Smith | e4f5e4f | 2016-06-30 22:52:52 +0000 | [diff] [blame] | 696 | bool is8bit, |
Hal Finkel | 5728200 | 2016-08-28 16:17:58 +0000 | [diff] [blame] | 697 | unsigned Opcode, |
| 698 | unsigned CmpOpcode = 0, |
| 699 | unsigned CmpPred = 0) const; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 700 | |
Duncan P. N. Exon Smith | e4f5e4f | 2016-06-30 22:52:52 +0000 | [diff] [blame] | 701 | MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr &MI, |
Hal Finkel | 756810f | 2013-03-21 21:37:52 +0000 | [diff] [blame] | 702 | MachineBasicBlock *MBB) const; |
| 703 | |
Duncan P. N. Exon Smith | e4f5e4f | 2016-06-30 22:52:52 +0000 | [diff] [blame] | 704 | MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr &MI, |
Hal Finkel | 756810f | 2013-03-21 21:37:52 +0000 | [diff] [blame] | 705 | MachineBasicBlock *MBB) const; |
| 706 | |
Benjamin Kramer | 9bfb627 | 2015-07-05 19:29:18 +0000 | [diff] [blame] | 707 | ConstraintType getConstraintType(StringRef Constraint) const override; |
John Thompson | e8360b7 | 2010-10-29 17:29:13 +0000 | [diff] [blame] | 708 | |
| 709 | /// Examine constraint string and operand type and determine a weight value. |
| 710 | /// The operand object must already have been set up with the operand type. |
| 711 | ConstraintWeight getSingleConstraintMatchWeight( |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 712 | AsmOperandInfo &info, const char *constraint) const override; |
John Thompson | e8360b7 | 2010-10-29 17:29:13 +0000 | [diff] [blame] | 713 | |
Eric Christopher | 11e4df7 | 2015-02-26 22:38:43 +0000 | [diff] [blame] | 714 | std::pair<unsigned, const TargetRegisterClass *> |
| 715 | getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, |
Benjamin Kramer | 9bfb627 | 2015-07-05 19:29:18 +0000 | [diff] [blame] | 716 | StringRef Constraint, MVT VT) const override; |
Evan Cheng | 2dd2c65 | 2006-03-13 23:20:37 +0000 | [diff] [blame] | 717 | |
Dale Johannesen | cbde4c2 | 2008-02-28 22:31:51 +0000 | [diff] [blame] | 718 | /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate |
| 719 | /// function arguments in the caller parameter area. This is the actual |
| 720 | /// alignment, not its logarithm. |
Mehdi Amini | 5c183d5 | 2015-07-09 02:09:28 +0000 | [diff] [blame] | 721 | unsigned getByValTypeAlignment(Type *Ty, |
| 722 | const DataLayout &DL) const override; |
Dale Johannesen | cbde4c2 | 2008-02-28 22:31:51 +0000 | [diff] [blame] | 723 | |
Chris Lattner | d8c9cb9 | 2007-08-25 00:47:38 +0000 | [diff] [blame] | 724 | /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops |
Dale Johannesen | ce97d55 | 2010-06-25 21:55:36 +0000 | [diff] [blame] | 725 | /// vector. If it is invalid, don't add anything to Ops. |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 726 | void LowerAsmOperandForConstraint(SDValue Op, |
| 727 | std::string &Constraint, |
| 728 | std::vector<SDValue> &Ops, |
| 729 | SelectionDAG &DAG) const override; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 730 | |
Benjamin Kramer | 9bfb627 | 2015-07-05 19:29:18 +0000 | [diff] [blame] | 731 | unsigned |
| 732 | getInlineAsmMemConstraint(StringRef ConstraintCode) const override { |
Daniel Sanders | 0828860 | 2015-03-17 11:09:13 +0000 | [diff] [blame] | 733 | if (ConstraintCode == "es") |
| 734 | return InlineAsm::Constraint_es; |
| 735 | else if (ConstraintCode == "o") |
| 736 | return InlineAsm::Constraint_o; |
| 737 | else if (ConstraintCode == "Q") |
| 738 | return InlineAsm::Constraint_Q; |
| 739 | else if (ConstraintCode == "Z") |
| 740 | return InlineAsm::Constraint_Z; |
| 741 | else if (ConstraintCode == "Zy") |
| 742 | return InlineAsm::Constraint_Zy; |
| 743 | return TargetLowering::getInlineAsmMemConstraint(ConstraintCode); |
Daniel Sanders | bf5b80f | 2015-03-16 13:13:41 +0000 | [diff] [blame] | 744 | } |
| 745 | |
Chris Lattner | 1eb94d9 | 2007-03-30 23:15:24 +0000 | [diff] [blame] | 746 | /// isLegalAddressingMode - Return true if the addressing mode represented |
| 747 | /// by AM is legal for this target, for a load/store of the specified type. |
Mehdi Amini | 0cdec1e | 2015-07-09 02:09:40 +0000 | [diff] [blame] | 748 | bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, |
Jonas Paulsson | 024e319 | 2017-07-21 11:59:37 +0000 | [diff] [blame] | 749 | Type *Ty, unsigned AS, |
| 750 | Instruction *I = nullptr) const override; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 751 | |
Hal Finkel | 34974ed | 2014-04-12 21:52:38 +0000 | [diff] [blame] | 752 | /// isLegalICmpImmediate - Return true if the specified immediate is legal |
| 753 | /// icmp immediate, that is the target has icmp instructions which can |
| 754 | /// compare a register against the immediate without having to materialize |
| 755 | /// the immediate into a register. |
| 756 | bool isLegalICmpImmediate(int64_t Imm) const override; |
| 757 | |
| 758 | /// isLegalAddImmediate - Return true if the specified immediate is legal |
| 759 | /// add immediate, that is the target has add instructions which can |
| 760 | /// add a register and the immediate without having to materialize |
| 761 | /// the immediate into a register. |
| 762 | bool isLegalAddImmediate(int64_t Imm) const override; |
| 763 | |
| 764 | /// isTruncateFree - Return true if it's free to truncate a value of |
| 765 | /// type Ty1 to type Ty2. e.g. On PPC it's free to truncate a i64 value in |
| 766 | /// register X1 to i32 by referencing its sub-register R1. |
| 767 | bool isTruncateFree(Type *Ty1, Type *Ty2) const override; |
| 768 | bool isTruncateFree(EVT VT1, EVT VT2) const override; |
| 769 | |
Hal Finkel | 5d5d153 | 2015-01-10 08:21:59 +0000 | [diff] [blame] | 770 | bool isZExtFree(SDValue Val, EVT VT2) const override; |
| 771 | |
Matt Arsenault | f2db97d | 2017-10-13 19:55:45 +0000 | [diff] [blame] | 772 | bool isFPExtFree(EVT DestVT, EVT SrcVT) const override; |
Olivier Sallenave | 3250969 | 2015-01-13 15:06:36 +0000 | [diff] [blame] | 773 | |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 774 | /// Returns true if it is beneficial to convert a load of a constant |
Hal Finkel | 34974ed | 2014-04-12 21:52:38 +0000 | [diff] [blame] | 775 | /// to just the constant itself. |
| 776 | bool shouldConvertConstantLoadToIntImm(const APInt &Imm, |
| 777 | Type *Ty) const override; |
| 778 | |
Sanjay Patel | e404cbf | 2017-08-24 23:24:43 +0000 | [diff] [blame] | 779 | bool convertSelectOfConstantsToMath(EVT VT) const override { |
Sanjay Patel | 066f320 | 2017-03-04 19:18:09 +0000 | [diff] [blame] | 780 | return true; |
| 781 | } |
| 782 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 783 | bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override; |
Owen Anderson | b2c80da | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 784 | |
Hal Finkel | 46ef7ce | 2014-08-13 01:15:40 +0000 | [diff] [blame] | 785 | bool getTgtMemIntrinsic(IntrinsicInfo &Info, |
| 786 | const CallInst &I, |
Matt Arsenault | 7d7adf4 | 2017-12-14 22:34:10 +0000 | [diff] [blame] | 787 | MachineFunction &MF, |
Hal Finkel | 46ef7ce | 2014-08-13 01:15:40 +0000 | [diff] [blame] | 788 | unsigned Intrinsic) const override; |
| 789 | |
Evan Cheng | d9929f0 | 2010-04-01 20:10:42 +0000 | [diff] [blame] | 790 | /// getOptimalMemOpType - Returns the target specific optimal type for load |
Evan Cheng | 6139937 | 2010-04-02 19:36:14 +0000 | [diff] [blame] | 791 | /// and store operations as a result of memset, memcpy, and memmove |
| 792 | /// lowering. If DstAlign is zero that means it's safe to destination |
| 793 | /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it |
| 794 | /// means there isn't a need to check it against alignment requirement, |
Evan Cheng | 962711e | 2012-12-12 02:34:41 +0000 | [diff] [blame] | 795 | /// probably because the source does not need to be loaded. If 'IsMemset' is |
| 796 | /// true, that means it's expanding a memset. If 'ZeroMemset' is true, that |
| 797 | /// means it's a memset of zero. 'MemcpyStrSrc' indicates whether the memcpy |
| 798 | /// source is constant so it does not need to be loaded. |
Dan Gohman | 148c69a | 2010-04-16 20:11:05 +0000 | [diff] [blame] | 799 | /// It returns EVT::Other if the type should be determined using generic |
| 800 | /// target-independent logic. |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 801 | EVT |
NAKAMURA Takumi | dcc6645 | 2013-05-15 18:01:28 +0000 | [diff] [blame] | 802 | getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, |
Evan Cheng | 962711e | 2012-12-12 02:34:41 +0000 | [diff] [blame] | 803 | bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 804 | MachineFunction &MF) const override; |
Dan Gohman | c14e522 | 2008-10-21 03:41:46 +0000 | [diff] [blame] | 805 | |
Hal Finkel | 8d7fbc9 | 2013-03-15 15:27:13 +0000 | [diff] [blame] | 806 | /// Is unaligned memory access allowed for the given type, and is it fast |
| 807 | /// relative to software emulation. |
Matt Arsenault | 6f2a526 | 2014-07-27 17:46:40 +0000 | [diff] [blame] | 808 | bool allowsMisalignedMemoryAccesses(EVT VT, |
| 809 | unsigned AddrSpace, |
| 810 | unsigned Align = 1, |
| 811 | bool *Fast = nullptr) const override; |
Hal Finkel | 8d7fbc9 | 2013-03-15 15:27:13 +0000 | [diff] [blame] | 812 | |
Stephen Lin | 73de7bf | 2013-07-09 18:16:56 +0000 | [diff] [blame] | 813 | /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster |
| 814 | /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be |
| 815 | /// expanded to FMAs when this method returns true, otherwise fmuladd is |
| 816 | /// expanded to fmul + fadd. |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 817 | bool isFMAFasterThanFMulAndFAdd(EVT VT) const override; |
Hal Finkel | 0a479ae | 2012-06-22 00:49:52 +0000 | [diff] [blame] | 818 | |
Hal Finkel | 934361a | 2015-01-14 01:07:51 +0000 | [diff] [blame] | 819 | const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override; |
| 820 | |
Hal Finkel | b4240ca | 2014-03-31 17:48:16 +0000 | [diff] [blame] | 821 | // Should we expand the build vector with shuffles? |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 822 | bool |
Hal Finkel | b4240ca | 2014-03-31 17:48:16 +0000 | [diff] [blame] | 823 | shouldExpandBuildVectorWithShuffles(EVT VT, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 824 | unsigned DefinedValues) const override; |
Hal Finkel | b4240ca | 2014-03-31 17:48:16 +0000 | [diff] [blame] | 825 | |
Bill Schmidt | 0cf702f | 2013-07-30 00:50:39 +0000 | [diff] [blame] | 826 | /// createFastISel - This method returns a target-specific FastISel object, |
| 827 | /// or null if the target does not support "fast" instruction selection. |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 828 | FastISel *createFastISel(FunctionLoweringInfo &FuncInfo, |
| 829 | const TargetLibraryInfo *LibInfo) const override; |
Bill Schmidt | 0cf702f | 2013-07-30 00:50:39 +0000 | [diff] [blame] | 830 | |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 831 | /// Returns true if an argument of type Ty needs to be passed in a |
Ulrich Weigand | 85d5df2 | 2014-07-21 00:13:26 +0000 | [diff] [blame] | 832 | /// contiguous block of registers in calling convention CallConv. |
| 833 | bool functionArgumentNeedsConsecutiveRegisters( |
| 834 | Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override { |
| 835 | // We support any array type as "consecutive" block in the parameter |
| 836 | // save area. The element type defines the alignment requirement and |
| 837 | // whether the argument should go in GPRs, FPRs, or VRs if available. |
| 838 | // |
| 839 | // Note that clang uses this capability both to implement the ELFv2 |
| 840 | // homogeneous float/vector aggregate ABI, and to avoid having to use |
| 841 | // "byval" when passing aggregates that might fully fit in registers. |
| 842 | return Ty->isArrayTy(); |
| 843 | } |
| 844 | |
Joseph Tremoulet | f748c89 | 2015-11-07 01:11:31 +0000 | [diff] [blame] | 845 | /// If a physical register, this returns the register that receives the |
| 846 | /// exception address on entry to an EH pad. |
| 847 | unsigned |
| 848 | getExceptionPointerRegister(const Constant *PersonalityFn) const override; |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 849 | |
Joseph Tremoulet | f748c89 | 2015-11-07 01:11:31 +0000 | [diff] [blame] | 850 | /// If a physical register, this returns the register that receives the |
| 851 | /// exception typeid on entry to a landing pad. |
| 852 | unsigned |
| 853 | getExceptionSelectorRegister(const Constant *PersonalityFn) const override; |
| 854 | |
Tim Shen | a1d8bc5 | 2016-04-19 20:14:52 +0000 | [diff] [blame] | 855 | /// Override to support customized stack guard loading. |
| 856 | bool useLoadStackGuardNode() const override; |
| 857 | void insertSSPDeclarations(Module &M) const override; |
| 858 | |
Ehsan Amiri | c90b02c | 2016-10-24 17:31:09 +0000 | [diff] [blame] | 859 | bool isFPImmLegal(const APFloat &Imm, EVT VT) const override; |
Joerg Sonnenberger | 8c1a9ac | 2016-11-16 00:37:30 +0000 | [diff] [blame] | 860 | |
| 861 | unsigned getJumpTableEncoding() const override; |
| 862 | bool isJumpTableRelative() const override; |
| 863 | SDValue getPICJumpTableRelocBase(SDValue Table, |
| 864 | SelectionDAG &DAG) const override; |
| 865 | const MCExpr *getPICJumpTableRelocBaseExpr(const MachineFunction *MF, |
| 866 | unsigned JTI, |
| 867 | MCContext &Ctx) const override; |
| 868 | |
Joseph Tremoulet | f748c89 | 2015-11-07 01:11:31 +0000 | [diff] [blame] | 869 | private: |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 870 | struct ReuseLoadInfo { |
| 871 | SDValue Ptr; |
| 872 | SDValue Chain; |
| 873 | SDValue ResChain; |
| 874 | MachinePointerInfo MPI; |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 875 | bool IsDereferenceable = false; |
| 876 | bool IsInvariant = false; |
| 877 | unsigned Alignment = 0; |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 878 | AAMDNodes AAInfo; |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 879 | const MDNode *Ranges = nullptr; |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 880 | |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 881 | ReuseLoadInfo() = default; |
Justin Lebar | adbf09e | 2016-09-11 01:38:58 +0000 | [diff] [blame] | 882 | |
| 883 | MachineMemOperand::Flags MMOFlags() const { |
| 884 | MachineMemOperand::Flags F = MachineMemOperand::MONone; |
| 885 | if (IsDereferenceable) |
| 886 | F |= MachineMemOperand::MODereferenceable; |
| 887 | if (IsInvariant) |
| 888 | F |= MachineMemOperand::MOInvariant; |
| 889 | return F; |
| 890 | } |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 891 | }; |
| 892 | |
Nemanja Ivanovic | d9d5bd3 | 2018-03-19 18:50:02 +0000 | [diff] [blame] | 893 | bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override { |
| 894 | // Addrspacecasts are always noops. |
| 895 | return true; |
| 896 | } |
| 897 | |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 898 | bool canReuseLoadAddress(SDValue Op, EVT MemVT, ReuseLoadInfo &RLI, |
Hal Finkel | 6c39269 | 2015-01-09 01:34:30 +0000 | [diff] [blame] | 899 | SelectionDAG &DAG, |
| 900 | ISD::LoadExtType ET = ISD::NON_EXTLOAD) const; |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 901 | void spliceIntoChain(SDValue ResChain, SDValue NewResChain, |
| 902 | SelectionDAG &DAG) const; |
| 903 | |
| 904 | void LowerFP_TO_INTForReuse(SDValue Op, ReuseLoadInfo &RLI, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 905 | SelectionDAG &DAG, const SDLoc &dl) const; |
Nemanja Ivanovic | c38b531 | 2015-04-11 10:40:42 +0000 | [diff] [blame] | 906 | SDValue LowerFP_TO_INTDirectMove(SDValue Op, SelectionDAG &DAG, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 907 | const SDLoc &dl) const; |
Guozhi Wei | 1fd553c | 2016-12-12 22:09:02 +0000 | [diff] [blame] | 908 | |
| 909 | bool directMoveIsProfitable(const SDValue &Op) const; |
Nemanja Ivanovic | c38b531 | 2015-04-11 10:40:42 +0000 | [diff] [blame] | 910 | SDValue LowerINT_TO_FPDirectMove(SDValue Op, SelectionDAG &DAG, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 911 | const SDLoc &dl) const; |
Hal Finkel | ed844c4 | 2015-01-06 22:31:02 +0000 | [diff] [blame] | 912 | |
Dan Gohman | 2ce6f2a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 913 | SDValue getFramePointerFrameIndex(SelectionDAG & DAG) const; |
| 914 | SDValue getReturnAddrFrameIndex(SelectionDAG & DAG) const; |
Arnold Schwaighofer | be0de34 | 2008-04-30 09:16:33 +0000 | [diff] [blame] | 915 | |
Evan Cheng | 67a69dd | 2010-01-27 00:07:07 +0000 | [diff] [blame] | 916 | bool |
| 917 | IsEligibleForTailCallOptimization(SDValue Callee, |
| 918 | CallingConv::ID CalleeCC, |
| 919 | bool isVarArg, |
| 920 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 921 | SelectionDAG& DAG) const; |
| 922 | |
Chuang-Yu Cheng | 2e5973e | 2016-04-06 02:04:38 +0000 | [diff] [blame] | 923 | bool |
| 924 | IsEligibleForTailCallOptimization_64SVR4( |
| 925 | SDValue Callee, |
| 926 | CallingConv::ID CalleeCC, |
Peter Collingbourne | 081ffe2 | 2017-07-26 19:15:29 +0000 | [diff] [blame] | 927 | ImmutableCallSite CS, |
Chuang-Yu Cheng | 2e5973e | 2016-04-06 02:04:38 +0000 | [diff] [blame] | 928 | bool isVarArg, |
| 929 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 930 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 931 | SelectionDAG& DAG) const; |
| 932 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 933 | SDValue EmitTailCallLoadFPAndRetAddr(SelectionDAG &DAG, int SPDiff, |
| 934 | SDValue Chain, SDValue &LROpOut, |
Eric Christopher | e0d09ba | 2016-07-07 01:08:21 +0000 | [diff] [blame] | 935 | SDValue &FPOpOut, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 936 | const SDLoc &dl) const; |
Arnold Schwaighofer | be0de34 | 2008-04-30 09:16:33 +0000 | [diff] [blame] | 937 | |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 938 | SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; |
| 939 | SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const; |
| 940 | SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; |
| 941 | SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; |
Roman Divacky | e3f15c98 | 2012-06-04 17:36:38 +0000 | [diff] [blame] | 942 | SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 943 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 944 | SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const; |
| 945 | SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const; |
Duncan Sands | a098436 | 2011-09-06 13:37:06 +0000 | [diff] [blame] | 946 | SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const; |
| 947 | SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const; |
Eric Christopher | b976a39 | 2016-07-07 00:39:27 +0000 | [diff] [blame] | 948 | SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const; |
| 949 | SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const; |
| 950 | SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const; |
| 951 | SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const; |
| 952 | SDValue LowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const; |
| 953 | SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; |
Hal Finkel | 5081ac2 | 2016-09-01 10:28:47 +0000 | [diff] [blame] | 954 | SDValue LowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const; |
Hal Finkel | 940ab93 | 2014-02-28 00:27:01 +0000 | [diff] [blame] | 955 | SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const; |
| 956 | SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const; |
| 957 | SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 958 | SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 959 | SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG, |
| 960 | const SDLoc &dl) const; |
Hal Finkel | f6d45f2 | 2013-04-01 17:52:07 +0000 | [diff] [blame] | 961 | SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 962 | SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const; |
| 963 | SDValue LowerSHL_PARTS(SDValue Op, SelectionDAG &DAG) const; |
| 964 | SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const; |
| 965 | SDValue LowerSRA_PARTS(SDValue Op, SelectionDAG &DAG) const; |
| 966 | SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const; |
| 967 | SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const; |
Nemanja Ivanovic | d5deb48 | 2016-09-14 14:19:09 +0000 | [diff] [blame] | 968 | SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; |
Hal Finkel | c93a9a2 | 2015-02-25 01:06:45 +0000 | [diff] [blame] | 969 | SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 970 | SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const; |
Tim Shen | 3bef27c | 2017-05-16 20:18:06 +0000 | [diff] [blame] | 971 | SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const; |
Tony Jiang | 30a49d1 | 2017-06-12 17:58:42 +0000 | [diff] [blame] | 972 | SDValue LowerREM(SDValue Op, SelectionDAG &DAG) const; |
Guozhi Wei | e3b8d9a | 2017-11-06 19:09:38 +0000 | [diff] [blame] | 973 | SDValue LowerBSWAP(SDValue Op, SelectionDAG &DAG) const; |
Nemanja Ivanovic | ebb2307 | 2018-01-12 14:58:41 +0000 | [diff] [blame] | 974 | SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 975 | SDValue LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const; |
Hal Finkel | 5c0d145 | 2014-03-30 13:22:59 +0000 | [diff] [blame] | 976 | SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 977 | SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 978 | |
Hal Finkel | c93a9a2 | 2015-02-25 01:06:45 +0000 | [diff] [blame] | 979 | SDValue LowerVectorLoad(SDValue Op, SelectionDAG &DAG) const; |
| 980 | SDValue LowerVectorStore(SDValue Op, SelectionDAG &DAG) const; |
| 981 | |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 982 | SDValue LowerCallResult(SDValue Chain, SDValue InFlag, |
Sandeep Patel | 68c5f47 | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 983 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 984 | const SmallVectorImpl<ISD::InputArg> &Ins, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 985 | const SDLoc &dl, SelectionDAG &DAG, |
Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 986 | SmallVectorImpl<SDValue> &InVals) const; |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 987 | SDValue FinishCall(CallingConv::ID CallConv, const SDLoc &dl, |
Eric Christopher | 2454a3b | 2016-07-07 01:08:23 +0000 | [diff] [blame] | 988 | bool isTailCall, bool isVarArg, bool isPatchPoint, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 989 | bool hasNest, SelectionDAG &DAG, |
| 990 | SmallVector<std::pair<unsigned, SDValue>, 8> &RegsToPass, |
Hal Finkel | e2ab0f1 | 2015-01-15 21:17:34 +0000 | [diff] [blame] | 991 | SDValue InFlag, SDValue Chain, SDValue CallSeqStart, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 992 | SDValue &Callee, int SPDiff, unsigned NumBytes, |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 993 | const SmallVectorImpl<ISD::InputArg> &Ins, |
Hal Finkel | e2ab0f1 | 2015-01-15 21:17:34 +0000 | [diff] [blame] | 994 | SmallVectorImpl<SDValue> &InVals, |
Peter Collingbourne | 081ffe2 | 2017-07-26 19:15:29 +0000 | [diff] [blame] | 995 | ImmutableCallSite CS) const; |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 996 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 997 | SDValue |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 998 | LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, |
| 999 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 1000 | const SDLoc &dl, SelectionDAG &DAG, |
| 1001 | SmallVectorImpl<SDValue> &InVals) const override; |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 1002 | |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 1003 | SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, |
| 1004 | SmallVectorImpl<SDValue> &InVals) const override; |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 1005 | |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 1006 | bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, |
| 1007 | bool isVarArg, |
| 1008 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 1009 | LLVMContext &Context) const override; |
Hal Finkel | 450128a | 2011-10-14 19:51:36 +0000 | [diff] [blame] | 1010 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1011 | SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, |
| 1012 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 1013 | const SmallVectorImpl<SDValue> &OutVals, |
| 1014 | const SDLoc &dl, SelectionDAG &DAG) const override; |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 1015 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1016 | SDValue extendArgForPPC64(ISD::ArgFlagsTy Flags, EVT ObjectVT, |
| 1017 | SelectionDAG &DAG, SDValue ArgVal, |
| 1018 | const SDLoc &dl) const; |
Bill Schmidt | 57d6de5 | 2012-10-23 15:51:16 +0000 | [diff] [blame] | 1019 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1020 | SDValue LowerFormalArguments_Darwin( |
| 1021 | SDValue Chain, CallingConv::ID CallConv, bool isVarArg, |
| 1022 | const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl, |
| 1023 | SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const; |
| 1024 | SDValue LowerFormalArguments_64SVR4( |
| 1025 | SDValue Chain, CallingConv::ID CallConv, bool isVarArg, |
| 1026 | const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl, |
| 1027 | SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const; |
| 1028 | SDValue LowerFormalArguments_32SVR4( |
| 1029 | SDValue Chain, CallingConv::ID CallConv, bool isVarArg, |
| 1030 | const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl, |
| 1031 | SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 1032 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1033 | SDValue createMemcpyOutsideCallSeq(SDValue Arg, SDValue PtrOff, |
| 1034 | SDValue CallSeqStart, |
| 1035 | ISD::ArgFlagsTy Flags, SelectionDAG &DAG, |
| 1036 | const SDLoc &dl) const; |
Bill Schmidt | 57d6de5 | 2012-10-23 15:51:16 +0000 | [diff] [blame] | 1037 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1038 | SDValue LowerCall_Darwin(SDValue Chain, SDValue Callee, |
| 1039 | CallingConv::ID CallConv, bool isVarArg, |
Eric Christopher | 2454a3b | 2016-07-07 01:08:23 +0000 | [diff] [blame] | 1040 | bool isTailCall, bool isPatchPoint, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1041 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 1042 | const SmallVectorImpl<SDValue> &OutVals, |
| 1043 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 1044 | const SDLoc &dl, SelectionDAG &DAG, |
| 1045 | SmallVectorImpl<SDValue> &InVals, |
Peter Collingbourne | 081ffe2 | 2017-07-26 19:15:29 +0000 | [diff] [blame] | 1046 | ImmutableCallSite CS) const; |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1047 | SDValue LowerCall_64SVR4(SDValue Chain, SDValue Callee, |
| 1048 | CallingConv::ID CallConv, bool isVarArg, |
Eric Christopher | 2454a3b | 2016-07-07 01:08:23 +0000 | [diff] [blame] | 1049 | bool isTailCall, bool isPatchPoint, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1050 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 1051 | const SmallVectorImpl<SDValue> &OutVals, |
| 1052 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 1053 | const SDLoc &dl, SelectionDAG &DAG, |
| 1054 | SmallVectorImpl<SDValue> &InVals, |
Peter Collingbourne | 081ffe2 | 2017-07-26 19:15:29 +0000 | [diff] [blame] | 1055 | ImmutableCallSite CS) const; |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1056 | SDValue LowerCall_32SVR4(SDValue Chain, SDValue Callee, |
| 1057 | CallingConv::ID CallConv, bool isVarArg, |
Eric Christopher | 2454a3b | 2016-07-07 01:08:23 +0000 | [diff] [blame] | 1058 | bool isTailCall, bool isPatchPoint, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 1059 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 1060 | const SmallVectorImpl<SDValue> &OutVals, |
| 1061 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 1062 | const SDLoc &dl, SelectionDAG &DAG, |
| 1063 | SmallVectorImpl<SDValue> &InVals, |
Peter Collingbourne | 081ffe2 | 2017-07-26 19:15:29 +0000 | [diff] [blame] | 1064 | ImmutableCallSite CS) const; |
Hal Finkel | 756810f | 2013-03-21 21:37:52 +0000 | [diff] [blame] | 1065 | |
| 1066 | SDValue lowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const; |
| 1067 | SDValue lowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const; |
Hal Finkel | 2e10331 | 2013-04-03 04:01:11 +0000 | [diff] [blame] | 1068 | |
Hal Finkel | 940ab93 | 2014-02-28 00:27:01 +0000 | [diff] [blame] | 1069 | SDValue DAGCombineExtBoolTrunc(SDNode *N, DAGCombinerInfo &DCI) const; |
Nemanja Ivanovic | 44513e5 | 2016-07-05 09:22:29 +0000 | [diff] [blame] | 1070 | SDValue DAGCombineBuildVector(SDNode *N, DAGCombinerInfo &DCI) const; |
Hal Finkel | 940ab93 | 2014-02-28 00:27:01 +0000 | [diff] [blame] | 1071 | SDValue DAGCombineTruncBoolExt(SDNode *N, DAGCombinerInfo &DCI) const; |
Lei Huang | c29229a | 2018-05-08 17:36:40 +0000 | [diff] [blame] | 1072 | SDValue combineStoreFPToInt(SDNode *N, DAGCombinerInfo &DCI) const; |
Hal Finkel | 5efb918 | 2015-01-06 06:01:57 +0000 | [diff] [blame] | 1073 | SDValue combineFPToIntToFP(SDNode *N, DAGCombinerInfo &DCI) const; |
Tim Shen | 10c64e6 | 2017-05-12 19:25:37 +0000 | [diff] [blame] | 1074 | SDValue combineSHL(SDNode *N, DAGCombinerInfo &DCI) const; |
| 1075 | SDValue combineSRA(SDNode *N, DAGCombinerInfo &DCI) const; |
| 1076 | SDValue combineSRL(SDNode *N, DAGCombinerInfo &DCI) const; |
Sanjay Patel | bdf1e38 | 2014-09-26 23:01:47 +0000 | [diff] [blame] | 1077 | |
Ehsan Amiri | 8581868 | 2016-11-18 10:41:44 +0000 | [diff] [blame] | 1078 | /// ConvertSETCCToSubtract - looks at SETCC that compares ints. It replaces |
| 1079 | /// SETCC with integer subtraction when (1) there is a legal way of doing it |
| 1080 | /// (2) keeping the result of comparison in GPR has performance benefit. |
| 1081 | SDValue ConvertSETCCToSubtract(SDNode *N, DAGCombinerInfo &DCI) const; |
| 1082 | |
Evandro Menezes | 21f9ce1 | 2016-11-10 23:31:06 +0000 | [diff] [blame] | 1083 | SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, |
| 1084 | int &RefinementSteps, bool &UseOneConstNR, |
| 1085 | bool Reciprocal) const override; |
Sanjay Patel | 0051efc | 2016-10-20 16:55:45 +0000 | [diff] [blame] | 1086 | SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, |
| 1087 | int &RefinementSteps) const override; |
Sanjay Patel | 1dd1559 | 2015-07-28 23:05:48 +0000 | [diff] [blame] | 1088 | unsigned combineRepeatedFPDivisors() const override; |
Bill Schmidt | 8c3976e | 2013-08-26 20:11:46 +0000 | [diff] [blame] | 1089 | |
| 1090 | CCAssignFn *useFastISelCCs(unsigned Flag) const; |
Nemanja Ivanovic | 8c11e79 | 2016-11-29 23:36:03 +0000 | [diff] [blame] | 1091 | |
| 1092 | SDValue |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 1093 | combineElementTruncationToVectorTruncation(SDNode *N, |
| 1094 | DAGCombinerInfo &DCI) const; |
Graham Yiu | 6715261 | 2017-11-01 18:06:56 +0000 | [diff] [blame] | 1095 | |
| 1096 | /// lowerToVINSERTH - Return the SDValue if this VECTOR_SHUFFLE can be |
| 1097 | /// handled by the VINSERTH instruction introduced in ISA 3.0. This is |
| 1098 | /// essentially any shuffle of v8i16 vectors that just inserts one element |
| 1099 | /// from one vector into the other. |
| 1100 | SDValue lowerToVINSERTH(ShuffleVectorSDNode *N, SelectionDAG &DAG) const; |
| 1101 | |
Graham Yiu | 030621b | 2017-11-06 20:18:30 +0000 | [diff] [blame] | 1102 | /// lowerToVINSERTB - Return the SDValue if this VECTOR_SHUFFLE can be |
| 1103 | /// handled by the VINSERTB instruction introduced in ISA 3.0. This is |
| 1104 | /// essentially v16i8 vector version of VINSERTH. |
| 1105 | SDValue lowerToVINSERTB(ShuffleVectorSDNode *N, SelectionDAG &DAG) const; |
| 1106 | |
Sean Fertile | 0f0837e | 2017-11-15 18:58:27 +0000 | [diff] [blame] | 1107 | // Return whether the call instruction can potentially be optimized to a |
| 1108 | // tail call. This will cause the optimizers to attempt to move, or |
| 1109 | // duplicate return instructions to help enable tail call optimizations. |
| 1110 | bool mayBeEmittedAsTailCall(const CallInst *CI) const override; |
Nemanja Ivanovic | 01e2e79 | 2018-05-02 23:55:23 +0000 | [diff] [blame] | 1111 | bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override; |
Graham Yiu | 6715261 | 2017-11-01 18:06:56 +0000 | [diff] [blame] | 1112 | }; // end class PPCTargetLowering |
Bill Schmidt | 230b451 | 2013-06-12 16:39:22 +0000 | [diff] [blame] | 1113 | |
Bill Schmidt | 0cf702f | 2013-07-30 00:50:39 +0000 | [diff] [blame] | 1114 | namespace PPC { |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 1115 | |
Bill Schmidt | 0cf702f | 2013-07-30 00:50:39 +0000 | [diff] [blame] | 1116 | FastISel *createFastISel(FunctionLoweringInfo &FuncInfo, |
| 1117 | const TargetLibraryInfo *LibInfo); |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 1118 | |
| 1119 | } // end namespace PPC |
Bill Schmidt | 0cf702f | 2013-07-30 00:50:39 +0000 | [diff] [blame] | 1120 | |
Bill Schmidt | 230b451 | 2013-06-12 16:39:22 +0000 | [diff] [blame] | 1121 | bool CC_PPC32_SVR4_Custom_Dummy(unsigned &ValNo, MVT &ValVT, MVT &LocVT, |
| 1122 | CCValAssign::LocInfo &LocInfo, |
| 1123 | ISD::ArgFlagsTy &ArgFlags, |
| 1124 | CCState &State); |
| 1125 | |
| 1126 | bool CC_PPC32_SVR4_Custom_AlignArgRegs(unsigned &ValNo, MVT &ValVT, |
| 1127 | MVT &LocVT, |
| 1128 | CCValAssign::LocInfo &LocInfo, |
| 1129 | ISD::ArgFlagsTy &ArgFlags, |
| 1130 | CCState &State); |
| 1131 | |
Strahinja Petrovic | 30e0ce8 | 2016-08-05 08:47:26 +0000 | [diff] [blame] | 1132 | bool |
| 1133 | CC_PPC32_SVR4_Custom_SkipLastArgRegsPPCF128(unsigned &ValNo, MVT &ValVT, |
| 1134 | MVT &LocVT, |
| 1135 | CCValAssign::LocInfo &LocInfo, |
| 1136 | ISD::ArgFlagsTy &ArgFlags, |
| 1137 | CCState &State); |
| 1138 | |
Bill Schmidt | 230b451 | 2013-06-12 16:39:22 +0000 | [diff] [blame] | 1139 | bool CC_PPC32_SVR4_Custom_AlignFPArgRegs(unsigned &ValNo, MVT &ValVT, |
| 1140 | MVT &LocVT, |
| 1141 | CCValAssign::LocInfo &LocInfo, |
| 1142 | ISD::ArgFlagsTy &ArgFlags, |
| 1143 | CCState &State); |
Chris Lattner | f22556d | 2005-08-16 17:14:42 +0000 | [diff] [blame] | 1144 | |
Hiroshi Inoue | 70b1af5 | 2017-07-10 06:32:52 +0000 | [diff] [blame] | 1145 | bool isIntS16Immediate(SDNode *N, int16_t &Imm); |
| 1146 | bool isIntS16Immediate(SDValue Op, int16_t &Imm); |
Lei Huang | 3171041 | 2017-07-07 21:12:35 +0000 | [diff] [blame] | 1147 | |
Eugene Zelenko | 8187c19 | 2017-01-13 00:58:58 +0000 | [diff] [blame] | 1148 | } // end namespace llvm |
| 1149 | |
| 1150 | #endif // LLVM_TARGET_POWERPC_PPC32ISELLOWERING_H |