blob: e6e3e1701ae96b222e00ddb4c253e7f49d83c0d8 [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
Richard Sandifordc2312692014-03-06 10:38:30 +000086 // Extracts the value of a 32-bit access register. Operand 0 is
87 // the number of the register.
88 EXTRACT_ACCESS,
Ulrich Weigand5f613df2013-05-06 16:15:19 +000089
Ulrich Weigandb4012182015-03-31 12:56:33 +000090 // Count number of bits set in operand 0 per byte.
91 POPCNT,
92
Richard Sandifordc2312692014-03-06 10:38:30 +000093 // Wrappers around the ISD opcodes of the same name. The output and
94 // first input operands are GR128s. The trailing numbers are the
95 // widths of the second operand in bits.
96 UMUL_LOHI64,
97 SDIVREM32,
98 SDIVREM64,
99 UDIVREM32,
100 UDIVREM64,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000101
Richard Sandifordc2312692014-03-06 10:38:30 +0000102 // Use a series of MVCs to copy bytes from one memory location to another.
103 // The operands are:
104 // - the target address
105 // - the source address
106 // - the constant length
107 //
108 // This isn't a memory opcode because we'd need to attach two
109 // MachineMemOperands rather than one.
110 MVC,
Richard Sandifordd131ff82013-07-08 09:35:23 +0000111
Richard Sandifordc2312692014-03-06 10:38:30 +0000112 // Like MVC, but implemented as a loop that handles X*256 bytes
113 // followed by straight-line code to handle the rest (if any).
114 // The value of X is passed as an additional operand.
115 MVC_LOOP,
Richard Sandiford5e318f02013-08-27 09:54:29 +0000116
Richard Sandifordc2312692014-03-06 10:38:30 +0000117 // Similar to MVC and MVC_LOOP, but for logic operations (AND, OR, XOR).
118 NC,
119 NC_LOOP,
120 OC,
121 OC_LOOP,
122 XC,
123 XC_LOOP,
Richard Sandiford178273a2013-09-05 10:36:45 +0000124
Richard Sandifordc2312692014-03-06 10:38:30 +0000125 // Use CLC to compare two blocks of memory, with the same comments
126 // as for MVC and MVC_LOOP.
127 CLC,
128 CLC_LOOP,
Richard Sandiford761703a2013-08-12 10:17:33 +0000129
Richard Sandifordc2312692014-03-06 10:38:30 +0000130 // Use an MVST-based sequence to implement stpcpy().
131 STPCPY,
Richard Sandifordbb83a502013-08-16 11:29:37 +0000132
Richard Sandifordc2312692014-03-06 10:38:30 +0000133 // Use a CLST-based sequence to implement strcmp(). The two input operands
134 // are the addresses of the strings to compare.
135 STRCMP,
Richard Sandifordca232712013-08-16 11:21:54 +0000136
Richard Sandifordc2312692014-03-06 10:38:30 +0000137 // Use an SRST-based sequence to search a block of memory. The first
138 // operand is the end address, the second is the start, and the third
139 // is the character to search for. CC is set to 1 on success and 2
140 // on failure.
141 SEARCH_STRING,
Richard Sandiford0dec06a2013-08-16 11:41:43 +0000142
Richard Sandifordc2312692014-03-06 10:38:30 +0000143 // Store the CC value in bits 29 and 28 of an integer.
144 IPM,
Richard Sandiford564681c2013-08-12 10:28:10 +0000145
Richard Sandifordc2312692014-03-06 10:38:30 +0000146 // Perform a serialization operation. (BCR 15,0 or BCR 14,0.)
147 SERIALIZE,
Richard Sandiford9afe6132013-12-10 10:36:34 +0000148
Ulrich Weiganda9ac6d62016-04-04 12:45:44 +0000149 // Compiler barrier only; generate a no-op.
150 MEMBARRIER,
151
Ulrich Weigand57c85f52015-04-01 12:51:43 +0000152 // Transaction begin. The first operand is the chain, the second
153 // the TDB pointer, and the third the immediate control field.
154 // Returns chain and glue.
155 TBEGIN,
156 TBEGIN_NOFLOAT,
157
158 // Transaction end. Just the chain operand. Returns chain and glue.
159 TEND,
160
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000161 // Create a vector constant by filling byte N of the result with bit
162 // 15-N of the single operand.
163 BYTE_MASK,
164
165 // Create a vector constant by replicating an element-sized RISBG-style mask.
166 // The first operand specifies the starting set bit and the second operand
167 // specifies the ending set bit. Both operands count from the MSB of the
168 // element.
169 ROTATE_MASK,
170
171 // Replicate a GPR scalar value into all elements of a vector.
172 REPLICATE,
173
174 // Create a vector from two i64 GPRs.
175 JOIN_DWORDS,
176
177 // Replicate one element of a vector into all elements. The first operand
178 // is the vector and the second is the index of the element to replicate.
179 SPLAT,
180
181 // Interleave elements from the high half of operand 0 and the high half
182 // of operand 1.
183 MERGE_HIGH,
184
185 // Likewise for the low halves.
186 MERGE_LOW,
187
188 // Concatenate the vectors in the first two operands, shift them left
189 // by the third operand, and take the first half of the result.
190 SHL_DOUBLE,
191
192 // Take one element of the first v2i64 operand and the one element of
193 // the second v2i64 operand and concatenate them to form a v2i64 result.
194 // The third operand is a 4-bit value of the form 0A0B, where A and B
195 // are the element selectors for the first operand and second operands
196 // respectively.
197 PERMUTE_DWORDS,
198
199 // Perform a general vector permute on vector operands 0 and 1.
200 // Each byte of operand 2 controls the corresponding byte of the result,
201 // in the same way as a byte-level VECTOR_SHUFFLE mask.
202 PERMUTE,
203
204 // Pack vector operands 0 and 1 into a single vector with half-sized elements.
205 PACK,
206
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000207 // Likewise, but saturate the result and set CC. PACKS_CC does signed
208 // saturation and PACKLS_CC does unsigned saturation.
209 PACKS_CC,
210 PACKLS_CC,
211
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000212 // Unpack the first half of vector operand 0 into double-sized elements.
213 // UNPACK_HIGH sign-extends and UNPACKL_HIGH zero-extends.
214 UNPACK_HIGH,
215 UNPACKL_HIGH,
216
217 // Likewise for the second half.
218 UNPACK_LOW,
219 UNPACKL_LOW,
220
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000221 // Shift each element of vector operand 0 by the number of bits specified
222 // by scalar operand 1.
223 VSHL_BY_SCALAR,
224 VSRL_BY_SCALAR,
225 VSRA_BY_SCALAR,
226
227 // For each element of the output type, sum across all sub-elements of
228 // operand 0 belonging to the corresponding element, and add in the
229 // rightmost sub-element of the corresponding element of operand 1.
230 VSUM,
231
232 // Compare integer vector operands 0 and 1 to produce the usual 0/-1
233 // vector result. VICMPE is for equality, VICMPH for "signed greater than"
234 // and VICMPHL for "unsigned greater than".
235 VICMPE,
236 VICMPH,
237 VICMPHL,
238
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000239 // Likewise, but also set the condition codes on the result.
240 VICMPES,
241 VICMPHS,
242 VICMPHLS,
243
Ulrich Weigandcd808232015-05-05 19:26:48 +0000244 // Compare floating-point vector operands 0 and 1 to preoduce the usual 0/-1
245 // vector result. VFCMPE is for "ordered and equal", VFCMPH for "ordered and
246 // greater than" and VFCMPHE for "ordered and greater than or equal to".
247 VFCMPE,
248 VFCMPH,
249 VFCMPHE,
250
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000251 // Likewise, but also set the condition codes on the result.
252 VFCMPES,
253 VFCMPHS,
254 VFCMPHES,
255
256 // Test floating-point data class for vectors.
257 VFTCI,
258
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000259 // Extend the even f32 elements of vector operand 0 to produce a vector
260 // of f64 elements.
261 VEXTEND,
262
263 // Round the f64 elements of vector operand 0 to f32s and store them in the
264 // even elements of the result.
265 VROUND,
266
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000267 // AND the two vector operands together and set CC based on the result.
268 VTM,
269
270 // String operations that set CC as a side-effect.
271 VFAE_CC,
272 VFAEZ_CC,
273 VFEE_CC,
274 VFEEZ_CC,
275 VFENE_CC,
276 VFENEZ_CC,
277 VISTR_CC,
278 VSTRC_CC,
279 VSTRCZ_CC,
280
Richard Sandifordc2312692014-03-06 10:38:30 +0000281 // Wrappers around the inner loop of an 8- or 16-bit ATOMIC_SWAP or
282 // ATOMIC_LOAD_<op>.
283 //
284 // Operand 0: the address of the containing 32-bit-aligned field
285 // Operand 1: the second operand of <op>, in the high bits of an i32
286 // for everything except ATOMIC_SWAPW
287 // Operand 2: how many bits to rotate the i32 left to bring the first
288 // operand into the high bits
289 // Operand 3: the negative of operand 2, for rotating the other way
290 // Operand 4: the width of the field in bits (8 or 16)
291 ATOMIC_SWAPW = ISD::FIRST_TARGET_MEMORY_OPCODE,
292 ATOMIC_LOADW_ADD,
293 ATOMIC_LOADW_SUB,
294 ATOMIC_LOADW_AND,
295 ATOMIC_LOADW_OR,
296 ATOMIC_LOADW_XOR,
297 ATOMIC_LOADW_NAND,
298 ATOMIC_LOADW_MIN,
299 ATOMIC_LOADW_MAX,
300 ATOMIC_LOADW_UMIN,
301 ATOMIC_LOADW_UMAX,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000302
Richard Sandifordc2312692014-03-06 10:38:30 +0000303 // A wrapper around the inner loop of an ATOMIC_CMP_SWAP.
304 //
305 // Operand 0: the address of the containing 32-bit-aligned field
306 // Operand 1: the compare value, in the low bits of an i32
307 // Operand 2: the swap value, in the low bits of an i32
308 // Operand 3: how many bits to rotate the i32 left to bring the first
309 // operand into the high bits
310 // Operand 4: the negative of operand 2, for rotating the other way
311 // Operand 5: the width of the field in bits (8 or 16)
312 ATOMIC_CMP_SWAPW,
Richard Sandiford03481332013-08-23 11:36:42 +0000313
Richard Sandifordc2312692014-03-06 10:38:30 +0000314 // Prefetch from the second operand using the 4-bit control code in
315 // the first operand. The code is 1 for a load prefetch and 2 for
316 // a store prefetch.
317 PREFETCH
318};
Richard Sandiford54b36912013-09-27 15:14:04 +0000319
Richard Sandifordc2312692014-03-06 10:38:30 +0000320// Return true if OPCODE is some kind of PC-relative address.
321inline bool isPCREL(unsigned Opcode) {
322 return Opcode == PCREL_WRAPPER || Opcode == PCREL_OFFSET;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000323}
Richard Sandifordc2312692014-03-06 10:38:30 +0000324} // end namespace SystemZISD
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000325
Richard Sandiford5bc670b2013-09-06 11:51:39 +0000326namespace SystemZICMP {
Richard Sandifordc2312692014-03-06 10:38:30 +0000327// Describes whether an integer comparison needs to be signed or unsigned,
328// or whether either type is OK.
329enum {
330 Any,
331 UnsignedOnly,
332 SignedOnly
333};
334} // end namespace SystemZICMP
Richard Sandiford5bc670b2013-09-06 11:51:39 +0000335
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000336class SystemZSubtarget;
337class SystemZTargetMachine;
338
339class SystemZTargetLowering : public TargetLowering {
340public:
Eric Christophera6734172015-01-31 00:06:45 +0000341 explicit SystemZTargetLowering(const TargetMachine &TM,
342 const SystemZSubtarget &STI);
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000343
344 // Override TargetLowering.
Mehdi Aminieaabc512015-07-09 15:12:23 +0000345 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000346 return MVT::i32;
347 }
Mehdi Amini44ede332015-07-09 02:09:04 +0000348 MVT getVectorIdxTy(const DataLayout &DL) const override {
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000349 // Only the lower 12 bits of an element index are used, so we don't
350 // want to clobber the upper 32 bits of a GPR unnecessarily.
351 return MVT::i32;
352 }
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000353 TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(EVT VT)
354 const override {
355 // Widen subvectors to the full width rather than promoting integer
356 // elements. This is better because:
357 //
358 // (a) it means that we can handle the ABI for passing and returning
359 // sub-128 vectors without having to handle them as legal types.
360 //
361 // (b) we don't have instructions to extend on load and truncate on store,
362 // so promoting the integers is less efficient.
363 //
364 // (c) there are no multiplication instructions for the widest integer
365 // type (v2i64).
366 if (VT.getVectorElementType().getSizeInBits() % 8 == 0)
367 return TypeWidenVector;
368 return TargetLoweringBase::getPreferredVectorAction(VT);
369 }
Mehdi Amini44ede332015-07-09 02:09:04 +0000370 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &,
371 EVT) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000372 bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
373 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
Ulrich Weigand1f6666a2015-03-31 12:52:27 +0000374 bool isLegalICmpImmediate(int64_t Imm) const override;
375 bool isLegalAddImmediate(int64_t Imm) const override;
Mehdi Amini0cdec1e2015-07-09 02:09:40 +0000376 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
Matt Arsenaultbd7d80a2015-06-01 05:31:59 +0000377 unsigned AS) const override;
Matt Arsenault6f2a5262014-07-27 17:46:40 +0000378 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
379 unsigned Align,
380 bool *Fast) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000381 bool isTruncateFree(Type *, Type *) const override;
382 bool isTruncateFree(EVT, EVT) const override;
383 const char *getTargetNodeName(unsigned Opcode) const override;
384 std::pair<unsigned, const TargetRegisterClass *>
Eric Christopher11e4df72015-02-26 22:38:43 +0000385 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000386 StringRef Constraint, MVT VT) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000387 TargetLowering::ConstraintType
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000388 getConstraintType(StringRef Constraint) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000389 TargetLowering::ConstraintWeight
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000390 getSingleConstraintMatchWeight(AsmOperandInfo &info,
Craig Topper73156022014-03-02 09:09:27 +0000391 const char *constraint) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000392 void LowerAsmOperandForConstraint(SDValue Op,
393 std::string &Constraint,
394 std::vector<SDValue> &Ops,
395 SelectionDAG &DAG) const override;
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000396
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000397 unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
Daniel Sanders2eeace22015-03-17 16:16:14 +0000398 if (ConstraintCode.size() == 1) {
399 switch(ConstraintCode[0]) {
400 default:
401 break;
402 case 'Q':
403 return InlineAsm::Constraint_Q;
404 case 'R':
405 return InlineAsm::Constraint_R;
406 case 'S':
407 return InlineAsm::Constraint_S;
408 case 'T':
409 return InlineAsm::Constraint_T;
410 }
411 }
412 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000413 }
414
Joseph Tremouletf748c892015-11-07 01:11:31 +0000415 /// If a physical register, this returns the register that receives the
416 /// exception address on entry to an EH pad.
417 unsigned
418 getExceptionPointerRegister(const Constant *PersonalityFn) const override {
419 return SystemZ::R6D;
420 }
421
422 /// If a physical register, this returns the register that receives the
423 /// exception typeid on entry to a landing pad.
424 unsigned
425 getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
426 return SystemZ::R7D;
427 }
428
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000429 MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
430 MachineBasicBlock *BB) const
431 override;
432 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
433 bool allowTruncateForTailCall(Type *, Type *) const override;
434 bool mayBeEmittedAsTailCall(CallInst *CI) const override;
435 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
436 bool isVarArg,
437 const SmallVectorImpl<ISD::InputArg> &Ins,
438 SDLoc DL, SelectionDAG &DAG,
439 SmallVectorImpl<SDValue> &InVals) const override;
440 SDValue LowerCall(CallLoweringInfo &CLI,
441 SmallVectorImpl<SDValue> &InVals) const override;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000442
Ulrich Weiganda887f062015-08-13 13:37:06 +0000443 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
444 bool isVarArg,
445 const SmallVectorImpl<ISD::OutputArg> &Outs,
446 LLVMContext &Context) const override;
Richard Sandifordb4d67b52014-03-06 12:03:36 +0000447 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
448 const SmallVectorImpl<ISD::OutputArg> &Outs,
449 const SmallVectorImpl<SDValue> &OutVals,
450 SDLoc DL, SelectionDAG &DAG) const override;
451 SDValue prepareVolatileOrAtomicLoad(SDValue Chain, SDLoc DL,
452 SelectionDAG &DAG) const override;
Richard Sandiford95bc5f92014-03-07 11:34:35 +0000453 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000454
455private:
456 const SystemZSubtarget &Subtarget;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000457
458 // Implement LowerOperation for individual opcodes.
Richard Sandifordf722a8e302013-10-16 11:10:55 +0000459 SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000460 SDValue lowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
461 SDValue lowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
462 SDValue lowerGlobalAddress(GlobalAddressSDNode *Node,
463 SelectionDAG &DAG) const;
Ulrich Weigand7db69182015-02-18 09:13:27 +0000464 SDValue lowerTLSGetOffset(GlobalAddressSDNode *Node,
465 SelectionDAG &DAG, unsigned Opcode,
466 SDValue GOTOffset) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000467 SDValue lowerGlobalTLSAddress(GlobalAddressSDNode *Node,
468 SelectionDAG &DAG) const;
469 SDValue lowerBlockAddress(BlockAddressSDNode *Node,
470 SelectionDAG &DAG) const;
471 SDValue lowerJumpTable(JumpTableSDNode *JT, SelectionDAG &DAG) const;
472 SDValue lowerConstantPool(ConstantPoolSDNode *CP, SelectionDAG &DAG) const;
Ulrich Weigandf557d082016-04-04 12:44:55 +0000473 SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
474 SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000475 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
476 SDValue lowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
477 SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
Richard Sandiford7d86e472013-08-21 09:34:56 +0000478 SDValue lowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000479 SDValue lowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
480 SDValue lowerSDIVREM(SDValue Op, SelectionDAG &DAG) const;
481 SDValue lowerUDIVREM(SDValue Op, SelectionDAG &DAG) const;
482 SDValue lowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
483 SDValue lowerOR(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandb4012182015-03-31 12:56:33 +0000484 SDValue lowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weiganda9ac6d62016-04-04 12:45:44 +0000485 SDValue lowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const;
Richard Sandifordbef3d7a2013-12-10 10:49:34 +0000486 SDValue lowerATOMIC_LOAD(SDValue Op, SelectionDAG &DAG) const;
487 SDValue lowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) const;
488 SDValue lowerATOMIC_LOAD_OP(SDValue Op, SelectionDAG &DAG,
489 unsigned Opcode) const;
Richard Sandiford41350a52013-12-24 15:18:04 +0000490 SDValue lowerATOMIC_LOAD_SUB(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000491 SDValue lowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
Richard Sandiford9afe6132013-12-10 10:36:34 +0000492 SDValue lowerLOAD_SEQUENCE_POINT(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000493 SDValue lowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
494 SDValue lowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
Richard Sandiford03481332013-08-23 11:36:42 +0000495 SDValue lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigand57c85f52015-04-01 12:51:43 +0000496 SDValue lowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000497 SDValue lowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000498 SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
499 SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
500 SDValue lowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000501 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
502 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000503 SDValue lowerExtendVectorInreg(SDValue Op, SelectionDAG &DAG,
NAKAMURA Takumi0a7d0ad2015-09-22 11:15:07 +0000504 unsigned UnpackHigh) const;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000505 SDValue lowerShift(SDValue Op, SelectionDAG &DAG, unsigned ByScalar) const;
506
507 SDValue combineExtract(SDLoc DL, EVT ElemVT, EVT VecVT, SDValue OrigOp,
508 unsigned Index, DAGCombinerInfo &DCI,
509 bool Force) const;
510 SDValue combineTruncateExtract(SDLoc DL, EVT TruncVT, SDValue Op,
511 DAGCombinerInfo &DCI) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000512
Richard Sandiford0fb90ab2013-05-28 10:41:11 +0000513 // If the last instruction before MBBI in MBB was some form of COMPARE,
514 // try to replace it with a COMPARE AND BRANCH just before MBBI.
515 // CCMask and Target are the BRC-like operands for the branch.
516 // Return true if the change was made.
517 bool convertPrevCompareToBranch(MachineBasicBlock *MBB,
518 MachineBasicBlock::iterator MBBI,
519 unsigned CCMask,
520 MachineBasicBlock *Target) const;
521
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000522 // Implement EmitInstrWithCustomInserter for individual operation types.
523 MachineBasicBlock *emitSelect(MachineInstr *MI,
524 MachineBasicBlock *BB) const;
Richard Sandifordb86a8342013-06-27 09:27:40 +0000525 MachineBasicBlock *emitCondStore(MachineInstr *MI,
526 MachineBasicBlock *BB,
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000527 unsigned StoreOpcode, unsigned STOCOpcode,
528 bool Invert) const;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000529 MachineBasicBlock *emitExt128(MachineInstr *MI,
530 MachineBasicBlock *MBB,
531 bool ClearEven, unsigned SubReg) const;
532 MachineBasicBlock *emitAtomicLoadBinary(MachineInstr *MI,
533 MachineBasicBlock *BB,
534 unsigned BinOpcode, unsigned BitSize,
535 bool Invert = false) const;
536 MachineBasicBlock *emitAtomicLoadMinMax(MachineInstr *MI,
537 MachineBasicBlock *MBB,
538 unsigned CompareOpcode,
539 unsigned KeepOldMask,
540 unsigned BitSize) const;
541 MachineBasicBlock *emitAtomicCmpSwapW(MachineInstr *MI,
542 MachineBasicBlock *BB) const;
Richard Sandiford564681c2013-08-12 10:28:10 +0000543 MachineBasicBlock *emitMemMemWrapper(MachineInstr *MI,
544 MachineBasicBlock *BB,
545 unsigned Opcode) const;
Richard Sandifordca232712013-08-16 11:21:54 +0000546 MachineBasicBlock *emitStringWrapper(MachineInstr *MI,
547 MachineBasicBlock *BB,
548 unsigned Opcode) const;
Ulrich Weigand57c85f52015-04-01 12:51:43 +0000549 MachineBasicBlock *emitTransactionBegin(MachineInstr *MI,
550 MachineBasicBlock *MBB,
551 unsigned Opcode,
552 bool NoFloat) const;
Jonas Paulsson7c5ce102015-10-08 07:40:16 +0000553 MachineBasicBlock *emitLoadAndTestCmp0(MachineInstr *MI,
NAKAMURA Takumi50df0c22015-11-02 01:38:12 +0000554 MachineBasicBlock *MBB,
555 unsigned Opcode) const;
Jonas Paulsson7c5ce102015-10-08 07:40:16 +0000556
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000557};
558} // end namespace llvm
559
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000560#endif