blob: 5dcb19c0a35dbb76e8f328107ff017053a3e60c8 [file] [log] [blame]
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001//===-- SystemZISelLowering.h - SystemZ DAG lowering interface --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the interfaces that SystemZ uses to lower LLVM code into a
11// selection DAG.
12//
13//===----------------------------------------------------------------------===//
14
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZISELLOWERING_H
16#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZISELLOWERING_H
Ulrich Weigand5f613df2013-05-06 16:15:19 +000017
18#include "SystemZ.h"
Richard Sandiford0fb90ab2013-05-28 10:41:11 +000019#include "llvm/CodeGen/MachineBasicBlock.h"
Ulrich Weigand5f613df2013-05-06 16:15:19 +000020#include "llvm/CodeGen/SelectionDAG.h"
21#include "llvm/Target/TargetLowering.h"
22
23namespace llvm {
24namespace SystemZISD {
Matthias Braund04893f2015-05-07 21:33:59 +000025enum NodeType : unsigned {
Richard Sandifordc2312692014-03-06 10:38:30 +000026 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000027
Richard Sandifordc2312692014-03-06 10:38:30 +000028 // Return with a flag operand. Operand 0 is the chain operand.
29 RET_FLAG,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000030
Richard Sandifordc2312692014-03-06 10:38:30 +000031 // Calls a function. Operand 0 is the chain operand and operand 1
32 // is the target address. The arguments start at operand 2.
33 // There is an optional glue operand at the end.
34 CALL,
35 SIBCALL,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000036
Ulrich Weigand7db69182015-02-18 09:13:27 +000037 // TLS calls. Like regular calls, except operand 1 is the TLS symbol.
38 // (The call target is implicitly __tls_get_offset.)
39 TLS_GDCALL,
40 TLS_LDCALL,
41
Richard Sandifordc2312692014-03-06 10:38:30 +000042 // Wraps a TargetGlobalAddress that should be loaded using PC-relative
43 // accesses (LARL). Operand 0 is the address.
44 PCREL_WRAPPER,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000045
Richard Sandifordc2312692014-03-06 10:38:30 +000046 // Used in cases where an offset is applied to a TargetGlobalAddress.
47 // Operand 0 is the full TargetGlobalAddress and operand 1 is a
48 // PCREL_WRAPPER for an anchor point. This is used so that we can
49 // cheaply refer to either the full address or the anchor point
50 // as a register base.
51 PCREL_OFFSET,
Richard Sandiford54b36912013-09-27 15:14:04 +000052
Richard Sandifordc2312692014-03-06 10:38:30 +000053 // Integer absolute.
54 IABS,
Richard Sandiford57485472013-12-13 15:35:00 +000055
Richard Sandifordc2312692014-03-06 10:38:30 +000056 // Integer comparisons. There are three operands: the two values
57 // to compare, and an integer of type SystemZICMP.
58 ICMP,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000059
Richard Sandifordc2312692014-03-06 10:38:30 +000060 // Floating-point comparisons. The two operands are the values to compare.
61 FCMP,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000062
Richard Sandifordc2312692014-03-06 10:38:30 +000063 // Test under mask. The first operand is ANDed with the second operand
64 // and the condition codes are set on the result. The third operand is
65 // a boolean that is true if the condition codes need to distinguish
66 // between CCMASK_TM_MIXED_MSB_0 and CCMASK_TM_MIXED_MSB_1 (which the
67 // register forms do but the memory forms don't).
68 TM,
Richard Sandiford35b9be22013-08-28 10:31:43 +000069
Richard Sandifordc2312692014-03-06 10:38:30 +000070 // Branches if a condition is true. Operand 0 is the chain operand;
71 // operand 1 is the 4-bit condition-code mask, with bit N in
72 // big-endian order meaning "branch if CC=N"; operand 2 is the
73 // target block and operand 3 is the flag operand.
74 BR_CCMASK,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000075
Richard Sandifordc2312692014-03-06 10:38:30 +000076 // Selects between operand 0 and operand 1. Operand 2 is the
77 // mask of condition-code values for which operand 0 should be
78 // chosen over operand 1; it has the same form as BR_CCMASK.
79 // Operand 3 is the flag operand.
80 SELECT_CCMASK,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000081
Richard Sandifordc2312692014-03-06 10:38:30 +000082 // Evaluates to the gap between the stack pointer and the
83 // base of the dynamically-allocatable area.
84 ADJDYNALLOC,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000085
Ulrich Weigandb4012182015-03-31 12:56:33 +000086 // Count number of bits set in operand 0 per byte.
87 POPCNT,
88
Richard Sandifordc2312692014-03-06 10:38:30 +000089 // Wrappers around the ISD opcodes of the same name. The output and
90 // first input operands are GR128s. The trailing numbers are the
91 // widths of the second operand in bits.
92 UMUL_LOHI64,
93 SDIVREM32,
94 SDIVREM64,
95 UDIVREM32,
96 UDIVREM64,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000097
Richard Sandifordc2312692014-03-06 10:38:30 +000098 // Use a series of MVCs to copy bytes from one memory location to another.
99 // The operands are:
100 // - the target address
101 // - the source address
102 // - the constant length
103 //
104 // This isn't a memory opcode because we'd need to attach two
105 // MachineMemOperands rather than one.
106 MVC,
Richard Sandifordd131ff82013-07-08 09:35:23 +0000107
Richard Sandifordc2312692014-03-06 10:38:30 +0000108 // Like MVC, but implemented as a loop that handles X*256 bytes
109 // followed by straight-line code to handle the rest (if any).
110 // The value of X is passed as an additional operand.
111 MVC_LOOP,
Richard Sandiford5e318f02013-08-27 09:54:29 +0000112
Richard Sandifordc2312692014-03-06 10:38:30 +0000113 // Similar to MVC and MVC_LOOP, but for logic operations (AND, OR, XOR).
114 NC,
115 NC_LOOP,
116 OC,
117 OC_LOOP,
118 XC,
119 XC_LOOP,
Richard Sandiford178273a2013-09-05 10:36:45 +0000120
Richard Sandifordc2312692014-03-06 10:38:30 +0000121 // Use CLC to compare two blocks of memory, with the same comments
122 // as for MVC and MVC_LOOP.
123 CLC,
124 CLC_LOOP,
Richard Sandiford761703a2013-08-12 10:17:33 +0000125
Richard Sandifordc2312692014-03-06 10:38:30 +0000126 // Use an MVST-based sequence to implement stpcpy().
127 STPCPY,
Richard Sandifordbb83a502013-08-16 11:29:37 +0000128
Richard Sandifordc2312692014-03-06 10:38:30 +0000129 // Use a CLST-based sequence to implement strcmp(). The two input operands
130 // are the addresses of the strings to compare.
131 STRCMP,
Richard Sandifordca232712013-08-16 11:21:54 +0000132
Richard Sandifordc2312692014-03-06 10:38:30 +0000133 // Use an SRST-based sequence to search a block of memory. The first
134 // operand is the end address, the second is the start, and the third
135 // is the character to search for. CC is set to 1 on success and 2
136 // on failure.
137 SEARCH_STRING,
Richard Sandiford0dec06a2013-08-16 11:41:43 +0000138
Richard Sandifordc2312692014-03-06 10:38:30 +0000139 // Store the CC value in bits 29 and 28 of an integer.
140 IPM,
Richard Sandiford564681c2013-08-12 10:28:10 +0000141
Ulrich Weiganda9ac6d62016-04-04 12:45:44 +0000142 // Compiler barrier only; generate a no-op.
143 MEMBARRIER,
144
Ulrich Weigand57c85f52015-04-01 12:51:43 +0000145 // Transaction begin. The first operand is the chain, the second
146 // the TDB pointer, and the third the immediate control field.
147 // Returns chain and glue.
148 TBEGIN,
149 TBEGIN_NOFLOAT,
150
151 // Transaction end. Just the chain operand. Returns chain and glue.
152 TEND,
153
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000154 // Create a vector constant by filling byte N of the result with bit
155 // 15-N of the single operand.
156 BYTE_MASK,
157
158 // Create a vector constant by replicating an element-sized RISBG-style mask.
159 // The first operand specifies the starting set bit and the second operand
160 // specifies the ending set bit. Both operands count from the MSB of the
161 // element.
162 ROTATE_MASK,
163
164 // Replicate a GPR scalar value into all elements of a vector.
165 REPLICATE,
166
167 // Create a vector from two i64 GPRs.
168 JOIN_DWORDS,
169
170 // Replicate one element of a vector into all elements. The first operand
171 // is the vector and the second is the index of the element to replicate.
172 SPLAT,
173
174 // Interleave elements from the high half of operand 0 and the high half
175 // of operand 1.
176 MERGE_HIGH,
177
178 // Likewise for the low halves.
179 MERGE_LOW,
180
181 // Concatenate the vectors in the first two operands, shift them left
182 // by the third operand, and take the first half of the result.
183 SHL_DOUBLE,
184
185 // Take one element of the first v2i64 operand and the one element of
186 // the second v2i64 operand and concatenate them to form a v2i64 result.
187 // The third operand is a 4-bit value of the form 0A0B, where A and B
188 // are the element selectors for the first operand and second operands
189 // respectively.
190 PERMUTE_DWORDS,
191
192 // Perform a general vector permute on vector operands 0 and 1.
193 // Each byte of operand 2 controls the corresponding byte of the result,
194 // in the same way as a byte-level VECTOR_SHUFFLE mask.
195 PERMUTE,
196
197 // Pack vector operands 0 and 1 into a single vector with half-sized elements.
198 PACK,
199
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000200 // Likewise, but saturate the result and set CC. PACKS_CC does signed
201 // saturation and PACKLS_CC does unsigned saturation.
202 PACKS_CC,
203 PACKLS_CC,
204
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000205 // Unpack the first half of vector operand 0 into double-sized elements.
206 // UNPACK_HIGH sign-extends and UNPACKL_HIGH zero-extends.
207 UNPACK_HIGH,
208 UNPACKL_HIGH,
209
210 // Likewise for the second half.
211 UNPACK_LOW,
212 UNPACKL_LOW,
213
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000214 // Shift each element of vector operand 0 by the number of bits specified
215 // by scalar operand 1.
216 VSHL_BY_SCALAR,
217 VSRL_BY_SCALAR,
218 VSRA_BY_SCALAR,
219
220 // For each element of the output type, sum across all sub-elements of
221 // operand 0 belonging to the corresponding element, and add in the
222 // rightmost sub-element of the corresponding element of operand 1.
223 VSUM,
224
225 // Compare integer vector operands 0 and 1 to produce the usual 0/-1
226 // vector result. VICMPE is for equality, VICMPH for "signed greater than"
227 // and VICMPHL for "unsigned greater than".
228 VICMPE,
229 VICMPH,
230 VICMPHL,
231
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000232 // Likewise, but also set the condition codes on the result.
233 VICMPES,
234 VICMPHS,
235 VICMPHLS,
236
Ulrich Weigandcd808232015-05-05 19:26:48 +0000237 // Compare floating-point vector operands 0 and 1 to preoduce the usual 0/-1
238 // vector result. VFCMPE is for "ordered and equal", VFCMPH for "ordered and
239 // greater than" and VFCMPHE for "ordered and greater than or equal to".
240 VFCMPE,
241 VFCMPH,
242 VFCMPHE,
243
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000244 // Likewise, but also set the condition codes on the result.
245 VFCMPES,
246 VFCMPHS,
247 VFCMPHES,
248
249 // Test floating-point data class for vectors.
250 VFTCI,
251
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000252 // Extend the even f32 elements of vector operand 0 to produce a vector
253 // of f64 elements.
254 VEXTEND,
255
256 // Round the f64 elements of vector operand 0 to f32s and store them in the
257 // even elements of the result.
258 VROUND,
259
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000260 // AND the two vector operands together and set CC based on the result.
261 VTM,
262
263 // String operations that set CC as a side-effect.
264 VFAE_CC,
265 VFAEZ_CC,
266 VFEE_CC,
267 VFEEZ_CC,
268 VFENE_CC,
269 VFENEZ_CC,
270 VISTR_CC,
271 VSTRC_CC,
272 VSTRCZ_CC,
273
Marcin Koscielnicki32e87342016-07-02 02:20:40 +0000274 // Test Data Class.
275 //
276 // Operand 0: the value to test
277 // Operand 1: the bit mask
278 TDC,
279
Richard Sandifordc2312692014-03-06 10:38:30 +0000280 // Wrappers around the inner loop of an 8- or 16-bit ATOMIC_SWAP or
281 // ATOMIC_LOAD_<op>.
282 //
283 // Operand 0: the address of the containing 32-bit-aligned field
284 // Operand 1: the second operand of <op>, in the high bits of an i32
285 // for everything except ATOMIC_SWAPW
286 // Operand 2: how many bits to rotate the i32 left to bring the first
287 // operand into the high bits
288 // Operand 3: the negative of operand 2, for rotating the other way
289 // Operand 4: the width of the field in bits (8 or 16)
290 ATOMIC_SWAPW = ISD::FIRST_TARGET_MEMORY_OPCODE,
291 ATOMIC_LOADW_ADD,
292 ATOMIC_LOADW_SUB,
293 ATOMIC_LOADW_AND,
294 ATOMIC_LOADW_OR,
295 ATOMIC_LOADW_XOR,
296 ATOMIC_LOADW_NAND,
297 ATOMIC_LOADW_MIN,
298 ATOMIC_LOADW_MAX,
299 ATOMIC_LOADW_UMIN,
300 ATOMIC_LOADW_UMAX,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000301
Richard Sandifordc2312692014-03-06 10:38:30 +0000302 // A wrapper around the inner loop of an ATOMIC_CMP_SWAP.
303 //
304 // Operand 0: the address of the containing 32-bit-aligned field
305 // Operand 1: the compare value, in the low bits of an i32
306 // Operand 2: the swap value, in the low bits of an i32
307 // Operand 3: how many bits to rotate the i32 left to bring the first
308 // operand into the high bits
309 // Operand 4: the negative of operand 2, for rotating the other way
310 // Operand 5: the width of the field in bits (8 or 16)
311 ATOMIC_CMP_SWAPW,
Richard Sandiford03481332013-08-23 11:36:42 +0000312
Bryan Chan28b759c2016-05-16 20:32:22 +0000313 // Byte swapping load.
314 //
315 // Operand 0: the address to load from
316 // Operand 1: the type of load (i16, i32, i64)
317 LRV,
318
319 // Byte swapping store.
320 //
321 // Operand 0: the value to store
322 // Operand 1: the address to store to
323 // Operand 2: the type of store (i16, i32, i64)
324 STRV,
325
Richard Sandifordc2312692014-03-06 10:38:30 +0000326 // Prefetch from the second operand using the 4-bit control code in
327 // the first operand. The code is 1 for a load prefetch and 2 for
328 // a store prefetch.
329 PREFETCH
330};
Richard Sandiford54b36912013-09-27 15:14:04 +0000331
Richard Sandifordc2312692014-03-06 10:38:30 +0000332// Return true if OPCODE is some kind of PC-relative address.
333inline bool isPCREL(unsigned Opcode) {
334 return Opcode == PCREL_WRAPPER || Opcode == PCREL_OFFSET;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000335}
Richard Sandifordc2312692014-03-06 10:38:30 +0000336} // end namespace SystemZISD
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000337
Richard Sandiford5bc670b2013-09-06 11:51:39 +0000338namespace SystemZICMP {
Richard Sandifordc2312692014-03-06 10:38:30 +0000339// Describes whether an integer comparison needs to be signed or unsigned,
340// or whether either type is OK.
341enum {
342 Any,
343 UnsignedOnly,
344 SignedOnly
345};
346} // end namespace SystemZICMP
Richard Sandiford5bc670b2013-09-06 11:51:39 +0000347
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000348class SystemZSubtarget;
349class SystemZTargetMachine;
350
351class SystemZTargetLowering : public TargetLowering {
352public:
Eric Christophera6734172015-01-31 00:06:45 +0000353 explicit SystemZTargetLowering(const TargetMachine &TM,
354 const SystemZSubtarget &STI);
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000355
356 // Override TargetLowering.
Mehdi Aminieaabc512015-07-09 15:12:23 +0000357 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000358 return MVT::i32;
359 }
Mehdi Amini44ede332015-07-09 02:09:04 +0000360 MVT getVectorIdxTy(const DataLayout &DL) const override {
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000361 // Only the lower 12 bits of an element index are used, so we don't
362 // want to clobber the upper 32 bits of a GPR unnecessarily.
363 return MVT::i32;
364 }
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000365 TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(EVT VT)
366 const override {
367 // Widen subvectors to the full width rather than promoting integer
368 // elements. This is better because:
369 //
370 // (a) it means that we can handle the ABI for passing and returning
371 // sub-128 vectors without having to handle them as legal types.
372 //
373 // (b) we don't have instructions to extend on load and truncate on store,
374 // so promoting the integers is less efficient.
375 //
376 // (c) there are no multiplication instructions for the widest integer
377 // type (v2i64).
Sanjay Patel1ed771f2016-09-14 16:37:15 +0000378 if (VT.getScalarSizeInBits() % 8 == 0)
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000379 return TypeWidenVector;
380 return TargetLoweringBase::getPreferredVectorAction(VT);
381 }
Mehdi Amini44ede332015-07-09 02:09:04 +0000382 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &,
383 EVT) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000384 bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
385 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
Ulrich Weigand1f6666a2015-03-31 12:52:27 +0000386 bool isLegalICmpImmediate(int64_t Imm) const override;
387 bool isLegalAddImmediate(int64_t Imm) const override;
Mehdi Amini0cdec1e2015-07-09 02:09:40 +0000388 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
Matt Arsenaultbd7d80a2015-06-01 05:31:59 +0000389 unsigned AS) const override;
Jonas Paulsson7a794222016-08-17 13:24:19 +0000390 bool isFoldableMemAccessOffset(Instruction *I, int64_t Offset) const override;
Matt Arsenault6f2a5262014-07-27 17:46:40 +0000391 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
392 unsigned Align,
393 bool *Fast) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000394 bool isTruncateFree(Type *, Type *) const override;
395 bool isTruncateFree(EVT, EVT) const override;
396 const char *getTargetNodeName(unsigned Opcode) const override;
397 std::pair<unsigned, const TargetRegisterClass *>
Eric Christopher11e4df72015-02-26 22:38:43 +0000398 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000399 StringRef Constraint, MVT VT) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000400 TargetLowering::ConstraintType
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000401 getConstraintType(StringRef Constraint) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000402 TargetLowering::ConstraintWeight
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000403 getSingleConstraintMatchWeight(AsmOperandInfo &info,
Craig Topper73156022014-03-02 09:09:27 +0000404 const char *constraint) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000405 void LowerAsmOperandForConstraint(SDValue Op,
406 std::string &Constraint,
407 std::vector<SDValue> &Ops,
408 SelectionDAG &DAG) const override;
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000409
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000410 unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
Daniel Sanders2eeace22015-03-17 16:16:14 +0000411 if (ConstraintCode.size() == 1) {
412 switch(ConstraintCode[0]) {
413 default:
414 break;
415 case 'Q':
416 return InlineAsm::Constraint_Q;
417 case 'R':
418 return InlineAsm::Constraint_R;
419 case 'S':
420 return InlineAsm::Constraint_S;
421 case 'T':
422 return InlineAsm::Constraint_T;
423 }
424 }
425 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000426 }
427
Joseph Tremouletf748c892015-11-07 01:11:31 +0000428 /// If a physical register, this returns the register that receives the
429 /// exception address on entry to an EH pad.
430 unsigned
431 getExceptionPointerRegister(const Constant *PersonalityFn) const override {
432 return SystemZ::R6D;
433 }
434
435 /// If a physical register, this returns the register that receives the
436 /// exception typeid on entry to a landing pad.
437 unsigned
438 getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
439 return SystemZ::R7D;
440 }
441
Marcin Koscielnickiaef3b5b2016-04-24 13:57:49 +0000442 /// Override to support customized stack guard loading.
443 bool useLoadStackGuardNode() const override {
444 return true;
445 }
446 void insertSSPDeclarations(Module &M) const override {
447 }
448
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000449 MachineBasicBlock *
450 EmitInstrWithCustomInserter(MachineInstr &MI,
451 MachineBasicBlock *BB) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000452 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
453 bool allowTruncateForTailCall(Type *, Type *) const override;
Matt Arsenault31380752017-04-18 21:16:46 +0000454 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000455 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
456 bool isVarArg,
457 const SmallVectorImpl<ISD::InputArg> &Ins,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000458 const SDLoc &DL, SelectionDAG &DAG,
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000459 SmallVectorImpl<SDValue> &InVals) const override;
460 SDValue LowerCall(CallLoweringInfo &CLI,
461 SmallVectorImpl<SDValue> &InVals) const override;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000462
Ulrich Weiganda887f062015-08-13 13:37:06 +0000463 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
464 bool isVarArg,
465 const SmallVectorImpl<ISD::OutputArg> &Outs,
466 LLVMContext &Context) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000467 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
468 const SmallVectorImpl<ISD::OutputArg> &Outs,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000469 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
470 SelectionDAG &DAG) const override;
Richard Sandiford95bc5f92014-03-07 11:34:35 +0000471 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000472
Marcin Koscielnickibbac8902016-05-10 16:49:04 +0000473 ISD::NodeType getExtendForAtomicOps() const override {
474 return ISD::ANY_EXTEND;
475 }
476
Bryan Chan893110e2016-04-28 00:17:23 +0000477 bool supportSwiftError() const override {
478 return true;
479 }
480
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000481private:
482 const SystemZSubtarget &Subtarget;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000483
484 // Implement LowerOperation for individual opcodes.
Richard Sandifordf722a8e302013-10-16 11:10:55 +0000485 SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000486 SDValue lowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
487 SDValue lowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
488 SDValue lowerGlobalAddress(GlobalAddressSDNode *Node,
489 SelectionDAG &DAG) const;
Ulrich Weigand7db69182015-02-18 09:13:27 +0000490 SDValue lowerTLSGetOffset(GlobalAddressSDNode *Node,
491 SelectionDAG &DAG, unsigned Opcode,
492 SDValue GOTOffset) const;
Marcin Koscielnickif12609c2016-04-20 01:03:48 +0000493 SDValue lowerThreadPointer(const SDLoc &DL, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000494 SDValue lowerGlobalTLSAddress(GlobalAddressSDNode *Node,
495 SelectionDAG &DAG) const;
496 SDValue lowerBlockAddress(BlockAddressSDNode *Node,
497 SelectionDAG &DAG) const;
498 SDValue lowerJumpTable(JumpTableSDNode *JT, SelectionDAG &DAG) const;
499 SDValue lowerConstantPool(ConstantPoolSDNode *CP, SelectionDAG &DAG) const;
Ulrich Weigandf557d082016-04-04 12:44:55 +0000500 SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
501 SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000502 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
503 SDValue lowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
504 SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
Marcin Koscielnicki9de88d92016-05-04 23:31:26 +0000505 SDValue lowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const;
Richard Sandiford7d86e472013-08-21 09:34:56 +0000506 SDValue lowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000507 SDValue lowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
508 SDValue lowerSDIVREM(SDValue Op, SelectionDAG &DAG) const;
509 SDValue lowerUDIVREM(SDValue Op, SelectionDAG &DAG) const;
510 SDValue lowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
511 SDValue lowerOR(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandb4012182015-03-31 12:56:33 +0000512 SDValue lowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weiganda9ac6d62016-04-04 12:45:44 +0000513 SDValue lowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const;
Richard Sandifordbef3d7a2013-12-10 10:49:34 +0000514 SDValue lowerATOMIC_LOAD(SDValue Op, SelectionDAG &DAG) const;
515 SDValue lowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) const;
516 SDValue lowerATOMIC_LOAD_OP(SDValue Op, SelectionDAG &DAG,
517 unsigned Opcode) const;
Richard Sandiford41350a52013-12-24 15:18:04 +0000518 SDValue lowerATOMIC_LOAD_SUB(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000519 SDValue lowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
520 SDValue lowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
521 SDValue lowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
Richard Sandiford03481332013-08-23 11:36:42 +0000522 SDValue lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand57c85f52015-04-01 12:51:43 +0000523 SDValue lowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000524 SDValue lowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000525 SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
526 SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
527 SDValue lowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000528 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
529 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000530 SDValue lowerExtendVectorInreg(SDValue Op, SelectionDAG &DAG,
NAKAMURA Takumi0a7d0ad2015-09-22 11:15:07 +0000531 unsigned UnpackHigh) const;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000532 SDValue lowerShift(SDValue Op, SelectionDAG &DAG, unsigned ByScalar) const;
533
Jonas Paulssoncad72ef2017-04-07 12:35:11 +0000534 bool canTreatAsByteVector(EVT VT) const;
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000535 SDValue combineExtract(const SDLoc &DL, EVT ElemVT, EVT VecVT, SDValue OrigOp,
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000536 unsigned Index, DAGCombinerInfo &DCI,
537 bool Force) const;
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000538 SDValue combineTruncateExtract(const SDLoc &DL, EVT TruncVT, SDValue Op,
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000539 DAGCombinerInfo &DCI) const;
Marcin Koscielnicki68747ac2016-06-30 00:08:54 +0000540 SDValue combineSIGN_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
541 SDValue combineMERGE(SDNode *N, DAGCombinerInfo &DCI) const;
542 SDValue combineSTORE(SDNode *N, DAGCombinerInfo &DCI) const;
543 SDValue combineEXTRACT_VECTOR_ELT(SDNode *N, DAGCombinerInfo &DCI) const;
544 SDValue combineJOIN_DWORDS(SDNode *N, DAGCombinerInfo &DCI) const;
545 SDValue combineFP_ROUND(SDNode *N, DAGCombinerInfo &DCI) const;
546 SDValue combineBSWAP(SDNode *N, DAGCombinerInfo &DCI) const;
Elliot Colpbc2cfc22016-07-06 18:13:11 +0000547 SDValue combineSHIFTROT(SDNode *N, DAGCombinerInfo &DCI) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000548
Richard Sandiford0fb90ab2013-05-28 10:41:11 +0000549 // If the last instruction before MBBI in MBB was some form of COMPARE,
550 // try to replace it with a COMPARE AND BRANCH just before MBBI.
551 // CCMask and Target are the BRC-like operands for the branch.
552 // Return true if the change was made.
553 bool convertPrevCompareToBranch(MachineBasicBlock *MBB,
554 MachineBasicBlock::iterator MBBI,
555 unsigned CCMask,
556 MachineBasicBlock *Target) const;
557
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000558 // Implement EmitInstrWithCustomInserter for individual operation types.
Ulrich Weigand524f2762016-11-28 13:34:08 +0000559 MachineBasicBlock *emitSelect(MachineInstr &MI, MachineBasicBlock *BB,
560 unsigned LOCROpcode) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000561 MachineBasicBlock *emitCondStore(MachineInstr &MI, MachineBasicBlock *BB,
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000562 unsigned StoreOpcode, unsigned STOCOpcode,
563 bool Invert) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000564 MachineBasicBlock *emitExt128(MachineInstr &MI, MachineBasicBlock *MBB,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000565 bool ClearEven, unsigned SubReg) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000566 MachineBasicBlock *emitAtomicLoadBinary(MachineInstr &MI,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000567 MachineBasicBlock *BB,
568 unsigned BinOpcode, unsigned BitSize,
569 bool Invert = false) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000570 MachineBasicBlock *emitAtomicLoadMinMax(MachineInstr &MI,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000571 MachineBasicBlock *MBB,
572 unsigned CompareOpcode,
573 unsigned KeepOldMask,
574 unsigned BitSize) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000575 MachineBasicBlock *emitAtomicCmpSwapW(MachineInstr &MI,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000576 MachineBasicBlock *BB) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000577 MachineBasicBlock *emitMemMemWrapper(MachineInstr &MI, MachineBasicBlock *BB,
Richard Sandiford564681c2013-08-12 10:28:10 +0000578 unsigned Opcode) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000579 MachineBasicBlock *emitStringWrapper(MachineInstr &MI, MachineBasicBlock *BB,
Richard Sandifordca232712013-08-16 11:21:54 +0000580 unsigned Opcode) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000581 MachineBasicBlock *emitTransactionBegin(MachineInstr &MI,
Ulrich Weigand57c85f52015-04-01 12:51:43 +0000582 MachineBasicBlock *MBB,
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000583 unsigned Opcode, bool NoFloat) const;
584 MachineBasicBlock *emitLoadAndTestCmp0(MachineInstr &MI,
NAKAMURA Takumi50df0c22015-11-02 01:38:12 +0000585 MachineBasicBlock *MBB,
586 unsigned Opcode) const;
Jonas Paulsson11d251c2017-05-10 13:03:25 +0000587
588 const TargetRegisterClass *getRepRegClassFor(MVT VT) const override;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000589};
590} // end namespace llvm
591
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000592#endif