1//===-- SystemZISelLowering.h - SystemZ DAG lowering interface --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the interfaces that SystemZ uses to lower LLVM code into a
10// selection DAG.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZISELLOWERING_H
15#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZISELLOWERING_H
16
17#include "SystemZ.h"
18#include "SystemZInstrInfo.h"
19#include "llvm/CodeGen/LibcallLoweringInfo.h"
20#include "llvm/CodeGen/MachineBasicBlock.h"
21#include "llvm/CodeGen/SelectionDAG.h"
22#include "llvm/CodeGen/TargetLowering.h"
23#include <optional>
24
25namespace llvm {
26
27namespace SystemZICMP {
28// Describes whether an integer comparison needs to be signed or unsigned,
29// or whether either type is OK.
30enum {
31 Any,
32 UnsignedOnly,
33 SignedOnly
34};
35} // end namespace SystemZICMP
36
37class SystemZSubtarget;
38
39class SystemZTargetLowering : public TargetLowering {
40public:
41 explicit SystemZTargetLowering(const TargetMachine &TM,
42 const SystemZSubtarget &STI);
43
44 bool useSoftFloat() const override;
45
46 // Override TargetLowering.
47 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
48 return MVT::i32;
49 }
50 unsigned getVectorIdxWidth(const DataLayout &DL) const override {
51 // Only the lower 12 bits of an element index are used, so we don't
52 // want to clobber the upper 32 bits of a GPR unnecessarily.
53 return 32;
54 }
55 TargetLoweringBase::LegalizeTypeAction
56 getPreferredVectorAction(MVT VT) const override;
57 unsigned
58 getNumRegisters(LLVMContext &Context, EVT VT,
59 std::optional<MVT> RegisterVT) const override {
60 // i128 inline assembly operand.
61 if (VT == MVT::i128 && RegisterVT && *RegisterVT == MVT::Untyped)
62 return 1;
63 return TargetLowering::getNumRegisters(Context, VT);
64 }
65 unsigned
66 getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC,
67 EVT VT, EVT &IntermediateVT,
68 unsigned &NumIntermediates,
69 MVT &RegisterVT) const override;
70 MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC,
71 EVT VT) const override;
72 unsigned getNumRegistersForCallingConv(LLVMContext &Context,
73 CallingConv::ID CC,
74 EVT VT) const override;
75 bool isCheapToSpeculateCtlz(Type *) const override { return true; }
76 bool isCheapToSpeculateCttz(Type *) const override { return true; }
77 bool preferZeroCompareBranch() const override { return true; }
78 bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override {
79 ConstantInt* Mask = dyn_cast<ConstantInt>(Val: AndI.getOperand(i: 1));
80 return Mask && Mask->getValue().isIntN(N: 16);
81 }
82 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
83 return VT.isScalarInteger();
84 }
85 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &,
86 EVT) const override;
87 bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
88 EVT VT) const override;
89 FPImmAction getFPImmAction(const APFloat &Imm, EVT VT,
90 bool ForCodeSize) const override;
91 bool ShouldShrinkFPConstant(EVT VT) const override {
92 // Do not shrink 64-bit FP constpool entries since LDEB is slower than
93 // LD, and having the full constant in memory enables reg/mem opcodes.
94 return VT != MVT::f64;
95 }
96 MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr &MI,
97 MachineBasicBlock *MBB) const;
98
99 MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr &MI,
100 MachineBasicBlock *MBB) const;
101
102 bool canMergeStoresTo(unsigned AS, EVT MemVT,
103 const MachineFunction &MF) const override;
104
105 bool aggressivelyPreferBuildVectorSources(EVT VecVT) const override;
106
107 bool hasInlineStackProbe(const MachineFunction &MF) const override;
108 AtomicExpansionKind shouldCastAtomicLoadInIR(LoadInst *LI) const override;
109 AtomicExpansionKind shouldCastAtomicStoreInIR(StoreInst *SI) const override;
110 AtomicExpansionKind
111 shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const override;
112 bool isLegalICmpImmediate(int64_t Imm) const override;
113 bool isLegalAddImmediate(int64_t Imm) const override;
114 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
115 unsigned AS,
116 Instruction *I = nullptr) const override;
117 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, Align Alignment,
118 MachineMemOperand::Flags Flags,
119 unsigned *Fast) const override;
120 bool findOptimalMemOpLowering(LLVMContext &Context, std::vector<EVT> &MemOps,
121 unsigned Limit, const MemOp &Op, unsigned DstAS,
122 unsigned SrcAS,
123 const AttributeList &FuncAttributes,
124 EVT *LargestVT = nullptr) const override;
125 EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op,
126 const AttributeList &FuncAttributes) const override;
127 bool isTruncateFree(Type *, Type *) const override;
128 bool isTruncateFree(EVT, EVT) const override;
129 bool isTypeDesirableForOp(SDNode *N, EVT VT) const override;
130
131 bool shouldFormOverflowOp(unsigned Opcode, EVT VT,
132 bool MathUsed) const override {
133 // Form add and sub with overflow intrinsics regardless of any extra
134 // users of the math result.
135 return VT == MVT::i32 || VT == MVT::i64 || VT == MVT::i128;
136 }
137
138 bool shouldConsiderGEPOffsetSplit() const override { return true; }
139
140 bool preferSelectsOverBooleanArithmetic(EVT VT) const override {
141 return true;
142 }
143
144 bool isProfitableToCombineMinNumMaxNum(EVT VT) const override {
145 // We have instructions for pseudo min/max, no need to convert them to
146 // minnum/maxnum.
147 return false;
148 }
149
150 // This function currently returns cost for srl/ipm/cc sequence for merging.
151 CondMergingParams
152 getJumpConditionMergingParams(Instruction::BinaryOps Opc, const Value *Lhs,
153 const Value *Rhs,
154 const Function *F) const override;
155
156 // Handle Lowering flag assembly outputs.
157 SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Flag,
158 const SDLoc &DL,
159 const AsmOperandInfo &Constraint,
160 SelectionDAG &DAG) const override;
161
162 std::pair<unsigned, const TargetRegisterClass *>
163 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
164 StringRef Constraint, MVT VT) const override;
165 TargetLowering::ConstraintType
166 getConstraintType(StringRef Constraint) const override;
167 TargetLowering::ConstraintWeight
168 getSingleConstraintMatchWeight(AsmOperandInfo &info,
169 const char *constraint) const override;
170 void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint,
171 std::vector<SDValue> &Ops,
172 SelectionDAG &DAG) const override;
173
174 InlineAsm::ConstraintCode
175 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
176 if (ConstraintCode.size() == 1) {
177 switch(ConstraintCode[0]) {
178 default:
179 break;
180 case 'o':
181 return InlineAsm::ConstraintCode::o;
182 case 'Q':
183 return InlineAsm::ConstraintCode::Q;
184 case 'R':
185 return InlineAsm::ConstraintCode::R;
186 case 'S':
187 return InlineAsm::ConstraintCode::S;
188 case 'T':
189 return InlineAsm::ConstraintCode::T;
190 }
191 } else if (ConstraintCode.size() == 2 && ConstraintCode[0] == 'Z') {
192 switch (ConstraintCode[1]) {
193 default:
194 break;
195 case 'Q':
196 return InlineAsm::ConstraintCode::ZQ;
197 case 'R':
198 return InlineAsm::ConstraintCode::ZR;
199 case 'S':
200 return InlineAsm::ConstraintCode::ZS;
201 case 'T':
202 return InlineAsm::ConstraintCode::ZT;
203 }
204 }
205 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
206 }
207
208 Register getRegisterByName(const char *RegName, LLT VT,
209 const MachineFunction &MF) const override;
210
211 /// If a physical register, this returns the register that receives the
212 /// exception address on entry to an EH pad.
213 Register
214 getExceptionPointerRegister(ExceptionHandling EH,
215 const Constant *PersonalityFn) const override;
216
217 /// If a physical register, this returns the register that receives the
218 /// exception typeid on entry to a landing pad.
219 Register
220 getExceptionSelectorRegister(ExceptionHandling EH,
221 const Constant *PersonalityFn) const override;
222
223 /// Override to support customized stack guard loading.
224 bool useLoadStackGuardNode(const Module &M) const override { return true; }
225 /// Insert SSP declaration if global stack protector is used.
226 void
227 insertSSPDeclarations(Module &M,
228 const LibcallLoweringInfo &Libcalls) const override;
229 MachineBasicBlock *
230 EmitInstrWithCustomInserter(MachineInstr &MI,
231 MachineBasicBlock *BB) const override;
232 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
233 void LowerOperationWrapper(SDNode *N, SmallVectorImpl<SDValue> &Results,
234 SelectionDAG &DAG) const override;
235 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
236 SelectionDAG &DAG) const override;
237 const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;
238 bool allowTruncateForTailCall(Type *, Type *) const override;
239 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
240 bool splitValueIntoRegisterParts(
241 SelectionDAG & DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
242 unsigned NumParts, MVT PartVT, std::optional<CallingConv::ID> CC)
243 const override;
244 SDValue joinRegisterPartsIntoValue(
245 SelectionDAG & DAG, const SDLoc &DL, const SDValue *Parts,
246 unsigned NumParts, MVT PartVT, EVT ValueVT,
247 std::optional<CallingConv::ID> CC) const override;
248 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
249 bool isVarArg,
250 const SmallVectorImpl<ISD::InputArg> &Ins,
251 const SDLoc &DL, SelectionDAG &DAG,
252 SmallVectorImpl<SDValue> &InVals) const override;
253 SDValue LowerCall(CallLoweringInfo &CLI,
254 SmallVectorImpl<SDValue> &InVals) const override;
255
256 std::pair<SDValue, SDValue>
257 makeExternalCall(SDValue Chain, SelectionDAG &DAG, const char *CalleeName,
258 EVT RetVT, ArrayRef<SDValue> Ops, CallingConv::ID CallConv,
259 bool IsSigned, SDLoc DL, bool DoesNotReturn,
260 bool IsReturnValueUsed) const;
261
262 SDValue useLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, MVT VT, SDValue Arg,
263 SDLoc DL, SDValue Chain, bool IsStrict) const;
264
265 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
266 bool isVarArg,
267 const SmallVectorImpl<ISD::OutputArg> &Outs,
268 LLVMContext &Context,
269 const Type *RetTy) const override;
270 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
271 const SmallVectorImpl<ISD::OutputArg> &Outs,
272 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
273 SelectionDAG &DAG) const override;
274 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
275
276 /// Determine which of the bits specified in Mask are known to be either
277 /// zero or one and return them in the KnownZero/KnownOne bitsets.
278 void computeKnownBitsForTargetNode(const SDValue Op,
279 KnownBits &Known,
280 const APInt &DemandedElts,
281 const SelectionDAG &DAG,
282 unsigned Depth = 0) const override;
283
284 /// Determine the number of bits in the operation that are sign bits.
285 unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
286 const APInt &DemandedElts,
287 const SelectionDAG &DAG,
288 unsigned Depth) const override;
289
290 bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(
291 SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
292 UndefPoisonKind Kind, unsigned Depth) const override;
293
294 ISD::NodeType getExtendForAtomicOps() const override {
295 return ISD::ANY_EXTEND;
296 }
297 ISD::NodeType getExtendForAtomicCmpSwapArg() const override {
298 return ISD::ZERO_EXTEND;
299 }
300
301 bool supportSwiftError() const override {
302 return true;
303 }
304
305 unsigned getStackProbeSize(const MachineFunction &MF) const;
306 bool hasAndNot(SDValue Y) const override;
307
308private:
309 const SystemZSubtarget &Subtarget;
310
311 // Implement LowerOperation for individual opcodes.
312 SDValue getVectorCmp(SelectionDAG &DAG, unsigned Opcode,
313 const SDLoc &DL, EVT VT,
314 SDValue CmpOp0, SDValue CmpOp1, SDValue Chain) const;
315 SDValue lowerVectorSETCC(SelectionDAG &DAG, const SDLoc &DL,
316 EVT VT, ISD::CondCode CC,
317 SDValue CmpOp0, SDValue CmpOp1,
318 SDValue Chain = SDValue(),
319 bool IsSignaling = false) const;
320 SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;
321 SDValue lowerSTRICT_FSETCC(SDValue Op, SelectionDAG &DAG,
322 bool IsSignaling) const;
323 SDValue lowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
324 SDValue lowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
325 SDValue lowerGlobalAddress(GlobalAddressSDNode *Node,
326 SelectionDAG &DAG) const;
327 SDValue lowerTLSGetOffset(GlobalAddressSDNode *Node,
328 SelectionDAG &DAG, unsigned Opcode,
329 SDValue GOTOffset) const;
330 SDValue lowerThreadPointer(const SDLoc &DL, SelectionDAG &DAG) const;
331 SDValue lowerGlobalTLSAddress(GlobalAddressSDNode *Node,
332 SelectionDAG &DAG) const;
333 SDValue lowerBlockAddress(BlockAddressSDNode *Node,
334 SelectionDAG &DAG) const;
335 SDValue lowerJumpTable(JumpTableSDNode *JT, SelectionDAG &DAG) const;
336 SDValue lowerConstantPool(ConstantPoolSDNode *CP, SelectionDAG &DAG) const;
337 SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
338 SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
339 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
340 SDValue lowerVASTART_ELF(SDValue Op, SelectionDAG &DAG) const;
341 SDValue lowerVASTART_XPLINK(SDValue Op, SelectionDAG &DAG) const;
342 SDValue lowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
343 SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
344 SDValue lowerDYNAMIC_STACKALLOC_ELF(SDValue Op, SelectionDAG &DAG) const;
345 SDValue lowerDYNAMIC_STACKALLOC_XPLINK(SDValue Op, SelectionDAG &DAG) const;
346 SDValue lowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const;
347 SDValue lowerMULH(SDValue Op, SelectionDAG &DAG, unsigned Opcode) const;
348 SDValue lowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
349 SDValue lowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
350 SDValue lowerSDIVREM(SDValue Op, SelectionDAG &DAG) const;
351 SDValue lowerUDIVREM(SDValue Op, SelectionDAG &DAG) const;
352 SDValue lowerXALUO(SDValue Op, SelectionDAG &DAG) const;
353 SDValue lowerUADDSUBO_CARRY(SDValue Op, SelectionDAG &DAG) const;
354 SDValue lowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
355 SDValue lowerOR(SDValue Op, SelectionDAG &DAG) const;
356 SDValue lowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
357 SDValue lowerVECREDUCE_ADD(SDValue Op, SelectionDAG &DAG) const;
358 SDValue lowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const;
359 SDValue lowerATOMIC_LOAD(SDValue Op, SelectionDAG &DAG) const;
360 SDValue lowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) const;
361 SDValue lowerATOMIC_LDST_I128(SDValue Op, SelectionDAG &DAG) const;
362 void lowerATOMIC_LOAD_OP(SDNode *N, SmallVectorImpl<SDValue> &Results,
363 SelectionDAG &DAG, unsigned Opcode) const;
364 SDValue lowerATOMIC_LOAD_SUB(SDValue Op, SelectionDAG &DAG) const;
365 SDValue lowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
366 SDValue lowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
367 SDValue lowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
368 SDValue lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
369 SDValue lowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
370 SDValue lowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
371 bool isVectorElementLoad(SDValue Op) const;
372 SDValue buildVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT,
373 SmallVectorImpl<SDValue> &Elems) const;
374 SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
375 SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
376 SDValue lowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
377 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
378 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
379 SDValue lowerSIGN_EXTEND_VECTOR_INREG(SDValue Op, SelectionDAG &DAG) const;
380 SDValue lowerZERO_EXTEND_VECTOR_INREG(SDValue Op, SelectionDAG &DAG) const;
381 SDValue lowerShift(SDValue Op, SelectionDAG &DAG, unsigned ByScalar) const;
382 SDValue lowerFSHL(SDValue Op, SelectionDAG &DAG) const;
383 SDValue lowerFSHR(SDValue Op, SelectionDAG &DAG) const;
384 SDValue lowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
385 SDValue lower_FP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
386 SDValue lower_INT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
387 SDValue lowerLoadF16(SDValue Op, SelectionDAG &DAG) const;
388 SDValue lowerStoreF16(SDValue Op, SelectionDAG &DAG) const;
389
390 SDValue lowerIS_FPCLASS(SDValue Op, SelectionDAG &DAG) const;
391 SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
392 SDValue lowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
393
394 bool canTreatAsByteVector(EVT VT) const;
395 SDValue combineExtract(const SDLoc &DL, EVT ElemVT, EVT VecVT, SDValue OrigOp,
396 unsigned Index, DAGCombinerInfo &DCI,
397 bool Force) const;
398 SDValue combineTruncateExtract(const SDLoc &DL, EVT TruncVT, SDValue Op,
399 DAGCombinerInfo &DCI) const;
400 SDValue combineZERO_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
401 SDValue combineSIGN_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
402 SDValue combineSIGN_EXTEND_INREG(SDNode *N, DAGCombinerInfo &DCI) const;
403 SDValue combineMERGE(SDNode *N, DAGCombinerInfo &DCI) const;
404 bool canLoadStoreByteSwapped(EVT VT) const;
405 SDValue combineLOAD(SDNode *N, DAGCombinerInfo &DCI) const;
406 SDValue combineSTORE(SDNode *N, DAGCombinerInfo &DCI) const;
407 SDValue combineVECTOR_SHUFFLE(SDNode *N, DAGCombinerInfo &DCI) const;
408 SDValue combineEXTRACT_VECTOR_ELT(SDNode *N, DAGCombinerInfo &DCI) const;
409 SDValue combineJOIN_DWORDS(SDNode *N, DAGCombinerInfo &DCI) const;
410 SDValue combineFP_ROUND(SDNode *N, DAGCombinerInfo &DCI) const;
411 SDValue combineFP_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
412 SDValue combineINT_TO_FP(SDNode *N, DAGCombinerInfo &DCI) const;
413 SDValue combineFCOPYSIGN(SDNode *N, DAGCombinerInfo &DCI) const;
414 SDValue combineBSWAP(SDNode *N, DAGCombinerInfo &DCI) const;
415 SDValue combineSETCC(SDNode *N, DAGCombinerInfo &DCI) const;
416 SDValue combineBR_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;
417 SDValue combineSELECT_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;
418 SDValue combineGET_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;
419 SDValue combineShiftToMulAddHigh(SDNode *N, DAGCombinerInfo &DCI) const;
420 SDValue combineMUL(SDNode *N, DAGCombinerInfo &DCI) const;
421 SDValue combineIntDIVREM(SDNode *N, DAGCombinerInfo &DCI) const;
422 SDValue combineINTRINSIC(SDNode *N, DAGCombinerInfo &DCI) const;
423
424 SDValue unwrapAddress(SDValue N) const override;
425
426 // Implement EmitInstrWithCustomInserter for individual operation types.
427 MachineBasicBlock *emitAdjCallStack(MachineInstr &MI,
428 MachineBasicBlock *BB) const;
429 MachineBasicBlock *emitSelect(MachineInstr &MI, MachineBasicBlock *BB) const;
430 MachineBasicBlock *emitCondStore(MachineInstr &MI, MachineBasicBlock *BB,
431 unsigned StoreOpcode, unsigned STOCOpcode,
432 bool Invert) const;
433 MachineBasicBlock *emitICmp128Hi(MachineInstr &MI, MachineBasicBlock *BB,
434 bool Unsigned) const;
435 MachineBasicBlock *emitAtomicLoadBinary(MachineInstr &MI,
436 MachineBasicBlock *BB,
437 unsigned BinOpcode,
438 bool Invert = false) const;
439 MachineBasicBlock *emitAtomicLoadMinMax(MachineInstr &MI,
440 MachineBasicBlock *MBB,
441 unsigned CompareOpcode,
442 unsigned KeepOldMask) const;
443 MachineBasicBlock *emitAtomicCmpSwapW(MachineInstr &MI,
444 MachineBasicBlock *BB) const;
445 MachineBasicBlock *emitMemMemWrapper(MachineInstr &MI, MachineBasicBlock *BB,
446 unsigned Opcode,
447 bool IsMemset = false) const;
448 MachineBasicBlock *emitMemmoveImm(MachineInstr &MI,
449 MachineBasicBlock *BB) const;
450 MachineBasicBlock *emitStringWrapper(MachineInstr &MI, MachineBasicBlock *BB,
451 unsigned Opcode) const;
452 MachineBasicBlock *emitTransactionBegin(MachineInstr &MI,
453 MachineBasicBlock *MBB,
454 unsigned Opcode, bool NoFloat) const;
455 MachineBasicBlock *emitLoadAndTestCmp0(MachineInstr &MI,
456 MachineBasicBlock *MBB,
457 unsigned Opcode) const;
458 MachineBasicBlock *emitProbedAlloca(MachineInstr &MI,
459 MachineBasicBlock *MBB) const;
460 MachineBasicBlock *emitStackGuardPseudo(MachineInstr &MI,
461 MachineBasicBlock *MBB,
462 unsigned PseudoOp) const;
463 SDValue getBackchainAddress(SDValue SP, SelectionDAG &DAG) const;
464
465 MachineMemOperand::Flags
466 getTargetMMOFlags(const Instruction &I) const override;
467
468private:
469 bool enableNarrowIntArgsVerification() const;
470 bool isInternal(const Function *Fn) const;
471 mutable std::map<const Function *, bool> IsInternalCache;
472 void verifyNarrowIntegerArgs_Call(CallLoweringInfo &CLI,
473 const SmallVectorImpl<ISD::OutputArg> &Outs,
474 const Function *F, SDValue Callee) const;
475 void verifyNarrowIntegerArgs_Ret(CallingConv::ID CallConv,
476 const SmallVectorImpl<ISD::OutputArg> &Outs,
477 const Function *F) const;
478 bool verifyNarrowIntegerArgs(bool C_ABI,
479 const SmallVectorImpl<ISD::OutputArg> &Outs,
480 const Function *FunHeader, bool IsRet) const;
481
482public:
483};
484
485struct SystemZVectorConstantInfo {
486private:
487 APInt IntBits; // The 128 bits as an integer.
488 APInt SplatBits; // Smallest splat value.
489 APInt SplatUndef; // Bits correspoding to undef operands of the BVN.
490 unsigned SplatBitSize = 0;
491 bool isFP128 = false;
492public:
493 unsigned Opcode = 0;
494 SmallVector<unsigned, 2> OpVals;
495 MVT VecVT;
496 SystemZVectorConstantInfo(APInt IntImm);
497 SystemZVectorConstantInfo(APFloat FPImm)
498 : SystemZVectorConstantInfo(FPImm.bitcastToAPInt()) {
499 isFP128 = (&FPImm.getSemantics() == &APFloat::IEEEquad());
500 }
501 SystemZVectorConstantInfo(BuildVectorSDNode *BVN);
502 bool isVectorConstantLegal(const SystemZSubtarget &Subtarget);
503};
504
505} // end namespace llvm
506
507#endif
508