LLVM 23.0.0git
SystemZISelLowering.h
Go to the documentation of this file.
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"
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 {
34};
35} // end namespace SystemZICMP
36
37class SystemZSubtarget;
38
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 }
56 const override {
57 // Widen subvectors to the full width rather than promoting integer
58 // elements. This is better because:
59 //
60 // (a) it means that we can handle the ABI for passing and returning
61 // sub-128 vectors without having to handle them as legal types.
62 //
63 // (b) we don't have instructions to extend on load and truncate on store,
64 // so promoting the integers is less efficient.
65 //
66 // (c) there are no multiplication instructions for the widest integer
67 // type (v2i64).
68
69 // Expand (narrow) f16 vectors during type legalization to avoid
70 // operations for all elements as with expansion after widening.
71 if (VT.getScalarType() == MVT::f16)
74 if (VT.getScalarSizeInBits() % 8 == 0)
75 return TypeWidenVector;
77 }
78 unsigned
80 std::optional<MVT> RegisterVT) const override {
81 // i128 inline assembly operand.
82 if (VT == MVT::i128 && RegisterVT && *RegisterVT == MVT::Untyped)
83 return 1;
84 return TargetLowering::getNumRegisters(Context, VT);
85 }
86 unsigned
88 EVT VT, EVT &IntermediateVT,
89 unsigned &NumIntermediates,
90 MVT &RegisterVT) const override;
92 EVT VT) const override;
95 EVT VT) const override;
96 bool isCheapToSpeculateCtlz(Type *) const override { return true; }
97 bool isCheapToSpeculateCttz(Type *) const override { return true; }
98 bool preferZeroCompareBranch() const override { return true; }
99 bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override {
101 return Mask && Mask->getValue().isIntN(16);
102 }
103 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
104 return VT.isScalarInteger();
105 }
107 EVT) const override;
109 EVT VT) const override;
110 bool isFPImmLegal(const APFloat &Imm, EVT VT,
111 bool ForCodeSize) const override;
112 bool ShouldShrinkFPConstant(EVT VT) const override {
113 // Do not shrink 64-bit FP constpool entries since LDEB is slower than
114 // LD, and having the full constant in memory enables reg/mem opcodes.
115 return VT != MVT::f64;
116 }
118 MachineBasicBlock *MBB) const;
119
121 MachineBasicBlock *MBB) const;
122
123 bool hasInlineStackProbe(const MachineFunction &MF) const override;
127 shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const override;
128 bool isLegalICmpImmediate(int64_t Imm) const override;
129 bool isLegalAddImmediate(int64_t Imm) const override;
130 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
131 unsigned AS,
132 Instruction *I = nullptr) const override;
133 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, Align Alignment,
135 unsigned *Fast) const override;
136 bool findOptimalMemOpLowering(LLVMContext &Context, std::vector<EVT> &MemOps,
137 unsigned Limit, const MemOp &Op, unsigned DstAS,
138 unsigned SrcAS,
139 const AttributeList &FuncAttributes,
140 EVT *LargestVT = nullptr) const override;
141 EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op,
142 const AttributeList &FuncAttributes) const override;
143 bool isTruncateFree(Type *, Type *) const override;
144 bool isTruncateFree(EVT, EVT) const override;
145
146 bool shouldFormOverflowOp(unsigned Opcode, EVT VT,
147 bool MathUsed) const override {
148 // Form add and sub with overflow intrinsics regardless of any extra
149 // users of the math result.
150 return VT == MVT::i32 || VT == MVT::i64 || VT == MVT::i128;
151 }
152
153 bool shouldConsiderGEPOffsetSplit() const override { return true; }
154
155 bool preferSelectsOverBooleanArithmetic(EVT VT) const override {
156 return true;
157 }
158
159 // This function currently returns cost for srl/ipm/cc sequence for merging.
160 CondMergingParams
162 const Value *Rhs,
163 const Function *F) const override;
164
165 // Handle Lowering flag assembly outputs.
167 const SDLoc &DL,
168 const AsmOperandInfo &Constraint,
169 SelectionDAG &DAG) const override;
170
171 std::pair<unsigned, const TargetRegisterClass *>
173 StringRef Constraint, MVT VT) const override;
175 getConstraintType(StringRef Constraint) const override;
177 getSingleConstraintMatchWeight(AsmOperandInfo &info,
178 const char *constraint) const override;
180 std::vector<SDValue> &Ops,
181 SelectionDAG &DAG) const override;
182
184 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
185 if (ConstraintCode.size() == 1) {
186 switch(ConstraintCode[0]) {
187 default:
188 break;
189 case 'o':
191 case 'Q':
193 case 'R':
195 case 'S':
197 case 'T':
199 }
200 } else if (ConstraintCode.size() == 2 && ConstraintCode[0] == 'Z') {
201 switch (ConstraintCode[1]) {
202 default:
203 break;
204 case 'Q':
206 case 'R':
208 case 'S':
210 case 'T':
212 }
213 }
214 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
215 }
216
217 Register getRegisterByName(const char *RegName, LLT VT,
218 const MachineFunction &MF) const override;
219
220 /// If a physical register, this returns the register that receives the
221 /// exception address on entry to an EH pad.
223 getExceptionPointerRegister(const Constant *PersonalityFn) const override;
224
225 /// If a physical register, this returns the register that receives the
226 /// exception typeid on entry to a landing pad.
228 getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
229
230 /// Override to support customized stack guard loading.
231 bool useLoadStackGuardNode(const Module &M) const override { return true; }
232 /// Insert SSP declaration if global stack protector is used.
233 void
235 const LibcallLoweringInfo &Libcalls) const override;
238 MachineBasicBlock *BB) const override;
239 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
241 SelectionDAG &DAG) const override;
243 SelectionDAG &DAG) const override;
244 const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;
245 bool allowTruncateForTailCall(Type *, Type *) const override;
246 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
248 SelectionDAG & DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
249 unsigned NumParts, MVT PartVT, std::optional<CallingConv::ID> CC)
250 const override;
252 SelectionDAG & DAG, const SDLoc &DL, const SDValue *Parts,
253 unsigned NumParts, MVT PartVT, EVT ValueVT,
254 std::optional<CallingConv::ID> CC) const override;
256 bool isVarArg,
258 const SDLoc &DL, SelectionDAG &DAG,
259 SmallVectorImpl<SDValue> &InVals) const override;
260 SDValue LowerCall(CallLoweringInfo &CLI,
261 SmallVectorImpl<SDValue> &InVals) const override;
262
263 std::pair<SDValue, SDValue>
264 makeExternalCall(SDValue Chain, SelectionDAG &DAG, const char *CalleeName,
265 EVT RetVT, ArrayRef<SDValue> Ops, CallingConv::ID CallConv,
266 bool IsSigned, SDLoc DL, bool DoesNotReturn,
267 bool IsReturnValueUsed) const;
268
269 SDValue useLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, MVT VT, SDValue Arg,
270 SDLoc DL, SDValue Chain, bool IsStrict) const;
271
273 bool isVarArg,
275 LLVMContext &Context,
276 const Type *RetTy) const override;
277 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
279 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
280 SelectionDAG &DAG) const override;
281 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
282
283 /// Determine which of the bits specified in Mask are known to be either
284 /// zero or one and return them in the KnownZero/KnownOne bitsets.
287 const APInt &DemandedElts,
288 const SelectionDAG &DAG,
289 unsigned Depth = 0) const override;
290
291 /// Determine the number of bits in the operation that are sign bits.
293 const APInt &DemandedElts,
294 const SelectionDAG &DAG,
295 unsigned Depth) const override;
296
298 SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
299 UndefPoisonKind Kind, unsigned Depth) const override;
300
302 return ISD::ANY_EXTEND;
303 }
305 return ISD::ZERO_EXTEND;
306 }
307
308 bool supportSwiftError() const override {
309 return true;
310 }
311
312 unsigned getStackProbeSize(const MachineFunction &MF) const;
313 bool hasAndNot(SDValue Y) const override;
314
315private:
316 const SystemZSubtarget &Subtarget;
317
318 // Implement LowerOperation for individual opcodes.
319 SDValue getVectorCmp(SelectionDAG &DAG, unsigned Opcode,
320 const SDLoc &DL, EVT VT,
321 SDValue CmpOp0, SDValue CmpOp1, SDValue Chain) const;
322 SDValue lowerVectorSETCC(SelectionDAG &DAG, const SDLoc &DL,
323 EVT VT, ISD::CondCode CC,
324 SDValue CmpOp0, SDValue CmpOp1,
325 SDValue Chain = SDValue(),
326 bool IsSignaling = false) const;
327 SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;
328 SDValue lowerSTRICT_FSETCC(SDValue Op, SelectionDAG &DAG,
329 bool IsSignaling) const;
330 SDValue lowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
331 SDValue lowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
332 SDValue lowerGlobalAddress(GlobalAddressSDNode *Node,
333 SelectionDAG &DAG) const;
334 SDValue lowerTLSGetOffset(GlobalAddressSDNode *Node,
335 SelectionDAG &DAG, unsigned Opcode,
336 SDValue GOTOffset) const;
337 SDValue lowerThreadPointer(const SDLoc &DL, SelectionDAG &DAG) const;
338 SDValue lowerGlobalTLSAddress(GlobalAddressSDNode *Node,
339 SelectionDAG &DAG) const;
340 SDValue lowerBlockAddress(BlockAddressSDNode *Node,
341 SelectionDAG &DAG) const;
342 SDValue lowerJumpTable(JumpTableSDNode *JT, SelectionDAG &DAG) const;
343 SDValue lowerConstantPool(ConstantPoolSDNode *CP, SelectionDAG &DAG) const;
346 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
347 SDValue lowerVASTART_ELF(SDValue Op, SelectionDAG &DAG) const;
348 SDValue lowerVASTART_XPLINK(SDValue Op, SelectionDAG &DAG) const;
349 SDValue lowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
350 SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
351 SDValue lowerDYNAMIC_STACKALLOC_ELF(SDValue Op, SelectionDAG &DAG) const;
352 SDValue lowerDYNAMIC_STACKALLOC_XPLINK(SDValue Op, SelectionDAG &DAG) const;
353 SDValue lowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const;
354 SDValue lowerMULH(SDValue Op, SelectionDAG &DAG, unsigned Opcode) const;
355 SDValue lowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
356 SDValue lowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
357 SDValue lowerSDIVREM(SDValue Op, SelectionDAG &DAG) const;
358 SDValue lowerUDIVREM(SDValue Op, SelectionDAG &DAG) const;
359 SDValue lowerXALUO(SDValue Op, SelectionDAG &DAG) const;
360 SDValue lowerUADDSUBO_CARRY(SDValue Op, SelectionDAG &DAG) const;
361 SDValue lowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
362 SDValue lowerOR(SDValue Op, SelectionDAG &DAG) const;
363 SDValue lowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
364 SDValue lowerVECREDUCE_ADD(SDValue Op, SelectionDAG &DAG) const;
365 SDValue lowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const;
366 SDValue lowerATOMIC_LOAD(SDValue Op, SelectionDAG &DAG) const;
367 SDValue lowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) const;
368 SDValue lowerATOMIC_LDST_I128(SDValue Op, SelectionDAG &DAG) const;
369 SDValue lowerATOMIC_LOAD_OP(SDValue Op, SelectionDAG &DAG,
370 unsigned Opcode) const;
371 SDValue lowerATOMIC_LOAD_SUB(SDValue Op, SelectionDAG &DAG) const;
372 SDValue lowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;
373 SDValue lowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
374 SDValue lowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
375 SDValue lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
376 SDValue lowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
377 SDValue lowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
378 bool isVectorElementLoad(SDValue Op) const;
379 SDValue buildVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT,
380 SmallVectorImpl<SDValue> &Elems) const;
383 SDValue lowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
384 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
385 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
386 SDValue lowerSIGN_EXTEND_VECTOR_INREG(SDValue Op, SelectionDAG &DAG) const;
387 SDValue lowerZERO_EXTEND_VECTOR_INREG(SDValue Op, SelectionDAG &DAG) const;
388 SDValue lowerShift(SDValue Op, SelectionDAG &DAG, unsigned ByScalar) const;
389 SDValue lowerFSHL(SDValue Op, SelectionDAG &DAG) const;
390 SDValue lowerFSHR(SDValue Op, SelectionDAG &DAG) const;
391 SDValue lowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
392 SDValue lower_FP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
393 SDValue lower_INT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
394 SDValue lowerLoadF16(SDValue Op, SelectionDAG &DAG) const;
395 SDValue lowerStoreF16(SDValue Op, SelectionDAG &DAG) const;
396
397 SDValue lowerIS_FPCLASS(SDValue Op, SelectionDAG &DAG) const;
398 SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
399 SDValue lowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
400
401 bool canTreatAsByteVector(EVT VT) const;
402 SDValue combineExtract(const SDLoc &DL, EVT ElemVT, EVT VecVT, SDValue OrigOp,
403 unsigned Index, DAGCombinerInfo &DCI,
404 bool Force) const;
405 SDValue combineTruncateExtract(const SDLoc &DL, EVT TruncVT, SDValue Op,
406 DAGCombinerInfo &DCI) const;
407 SDValue combineZERO_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
408 SDValue combineSIGN_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
409 SDValue combineSIGN_EXTEND_INREG(SDNode *N, DAGCombinerInfo &DCI) const;
410 SDValue combineMERGE(SDNode *N, DAGCombinerInfo &DCI) const;
411 bool canLoadStoreByteSwapped(EVT VT) const;
412 SDValue combineLOAD(SDNode *N, DAGCombinerInfo &DCI) const;
413 SDValue combineSTORE(SDNode *N, DAGCombinerInfo &DCI) const;
414 SDValue combineVECTOR_SHUFFLE(SDNode *N, DAGCombinerInfo &DCI) const;
415 SDValue combineEXTRACT_VECTOR_ELT(SDNode *N, DAGCombinerInfo &DCI) const;
416 SDValue combineJOIN_DWORDS(SDNode *N, DAGCombinerInfo &DCI) const;
417 SDValue combineFP_ROUND(SDNode *N, DAGCombinerInfo &DCI) const;
418 SDValue combineFP_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
419 SDValue combineINT_TO_FP(SDNode *N, DAGCombinerInfo &DCI) const;
420 SDValue combineFCOPYSIGN(SDNode *N, DAGCombinerInfo &DCI) const;
421 SDValue combineBSWAP(SDNode *N, DAGCombinerInfo &DCI) const;
422 SDValue combineSETCC(SDNode *N, DAGCombinerInfo &DCI) const;
423 SDValue combineBR_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;
424 SDValue combineSELECT_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;
425 SDValue combineGET_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;
426 SDValue combineShiftToMulAddHigh(SDNode *N, DAGCombinerInfo &DCI) const;
427 SDValue combineMUL(SDNode *N, DAGCombinerInfo &DCI) const;
428 SDValue combineIntDIVREM(SDNode *N, DAGCombinerInfo &DCI) const;
429 SDValue combineINTRINSIC(SDNode *N, DAGCombinerInfo &DCI) const;
430
431 SDValue unwrapAddress(SDValue N) const override;
432
433 // If the last instruction before MBBI in MBB was some form of COMPARE,
434 // try to replace it with a COMPARE AND BRANCH just before MBBI.
435 // CCMask and Target are the BRC-like operands for the branch.
436 // Return true if the change was made.
437 bool convertPrevCompareToBranch(MachineBasicBlock *MBB,
439 unsigned CCMask,
441
442 // Implement EmitInstrWithCustomInserter for individual operation types.
443 MachineBasicBlock *emitAdjCallStack(MachineInstr &MI,
444 MachineBasicBlock *BB) const;
447 unsigned StoreOpcode, unsigned STOCOpcode,
448 bool Invert) const;
450 bool Unsigned) const;
451 MachineBasicBlock *emitPair128(MachineInstr &MI,
452 MachineBasicBlock *MBB) const;
454 bool ClearEven) const;
455 MachineBasicBlock *emitAtomicLoadBinary(MachineInstr &MI,
457 unsigned BinOpcode,
458 bool Invert = false) const;
459 MachineBasicBlock *emitAtomicLoadMinMax(MachineInstr &MI,
461 unsigned CompareOpcode,
462 unsigned KeepOldMask) const;
463 MachineBasicBlock *emitAtomicCmpSwapW(MachineInstr &MI,
464 MachineBasicBlock *BB) const;
465 MachineBasicBlock *emitMemMemWrapper(MachineInstr &MI, MachineBasicBlock *BB,
466 unsigned Opcode,
467 bool IsMemset = false) const;
468 MachineBasicBlock *emitStringWrapper(MachineInstr &MI, MachineBasicBlock *BB,
469 unsigned Opcode) const;
470 MachineBasicBlock *emitTransactionBegin(MachineInstr &MI,
472 unsigned Opcode, bool NoFloat) const;
473 MachineBasicBlock *emitLoadAndTestCmp0(MachineInstr &MI,
475 unsigned Opcode) const;
476 MachineBasicBlock *emitProbedAlloca(MachineInstr &MI,
477 MachineBasicBlock *MBB) const;
478 MachineBasicBlock *emitStackGuardPseudo(MachineInstr &MI,
480 unsigned PseudoOp) const;
481 SDValue getBackchainAddress(SDValue SP, SelectionDAG &DAG) const;
482
484 getTargetMMOFlags(const Instruction &I) const override;
485 const TargetRegisterClass *getRepRegClassFor(MVT VT) const override;
486
487private:
488 bool isInternal(const Function *Fn) const;
489 mutable std::map<const Function *, bool> IsInternalCache;
490 void verifyNarrowIntegerArgs_Call(const SmallVectorImpl<ISD::OutputArg> &Outs,
491 const Function *F, SDValue Callee) const;
492 void verifyNarrowIntegerArgs_Ret(const SmallVectorImpl<ISD::OutputArg> &Outs,
493 const Function *F) const;
494 bool
495 verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs) const;
496
497public:
498};
499
501private:
502 APInt IntBits; // The 128 bits as an integer.
503 APInt SplatBits; // Smallest splat value.
504 APInt SplatUndef; // Bits correspoding to undef operands of the BVN.
505 unsigned SplatBitSize = 0;
506 bool isFP128 = false;
507public:
508 unsigned Opcode = 0;
513 : SystemZVectorConstantInfo(FPImm.bitcastToAPInt()) {
514 isFP128 = (&FPImm.getSemantics() == &APFloat::IEEEquad());
515 }
517 bool isVectorConstantLegal(const SystemZSubtarget &Subtarget);
518};
519
520} // end namespace llvm
521
522#endif
return SDValue()
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Function Alias Analysis Results
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define RegName(no)
lazy value info
static SDValue combineFP_ROUND(SDValue N, const SDLoc &DL, SelectionDAG &DAG, const LoongArchSubtarget &Subtarget)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
static SDValue combineLOAD(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &STI)
static SDValue combineSTORE(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &STI)
static MachineBasicBlock * emitSelect(MachineInstr &MI, MachineBasicBlock *BB, const TargetInstrInfo *TII, const PPCSubtarget &Subtarget)
Emit SELECT instruction, using ISEL if available, otherwise use branch-based control flow.
static SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG, const RISCVSubtarget &Subtarget)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
static SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const VETargetLowering &TLI, const VESubtarget *Subtarget)
static SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const VETargetLowering &TLI, const VESubtarget *Subtarget)
static SDValue combineFP_EXTEND(SDNode *N, SelectionDAG &DAG, TargetLowering::DAGCombinerInfo &DCI, const X86Subtarget &Subtarget)
static SDValue lowerVECTOR_SHUFFLE(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
Top-level lowering for x86 vector shuffles.
static const fltSemantics & IEEEquad()
Definition APFloat.h:299
const fltSemantics & getSemantics() const
Definition APFloat.h:1573
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
an instruction that atomically reads a memory location, combines it with another value,...
A "pseudo-class" with methods for operating on BUILD_VECTORs.
This class represents a function call, abstracting a target machine's calling convention.
This is the shared class of boolean and integer constants.
Definition Constants.h:87
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
constexpr bool isScalar() const
Exactly one element.
Definition TypeSize.h:320
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Tracks which library functions to use for a particular subtarget.
An instruction for reading from memory.
Machine Value Type.
uint64_t getScalarSizeInBits() const
ElementCount getVectorElementCount() const
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
Flags
Flags values. These may be or'd together.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
bool shouldFormOverflowOp(unsigned Opcode, EVT VT, bool MathUsed) const override
Try to convert math with an overflow comparison into the corresponding DAG node operation.
Register getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override
Return if the target supports combining a chain like:
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op, const AttributeList &FuncAttributes) const override
Returns the target specific optimal type for load and store operations as a result of memset,...
ISD::NodeType getExtendForAtomicOps() const override
Returns how the platform's atomic operations are extended (ZERO_EXTEND, SIGN_EXTEND,...
bool useLoadStackGuardNode(const Module &M) const override
Override to support customized stack guard loading.
bool hasInlineStackProbe(const MachineFunction &MF) const override
Returns true if stack probing through inline assembly is requested.
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
bool convertSetCCLogicToBitwiseLogic(EVT VT) const override
Use bitwise logic to make pairs of compares more efficient.
MachineBasicBlock * emitEHSjLjSetJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
AtomicExpansionKind shouldCastAtomicLoadInIR(LoadInst *LI) const override
Returns how the given (atomic) load should be cast by the IR-level AtomicExpand pass.
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &, EVT) const override
Return the ValueType of the result of SETCC operations.
bool allowTruncateForTailCall(Type *, Type *) const override
Return true if a truncation from FromTy to ToTy is permitted when deciding whether a call is in tail ...
SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Flag, const SDLoc &DL, const AsmOperandInfo &Constraint, SelectionDAG &DAG) const override
bool preferSelectsOverBooleanArithmetic(EVT VT) const override
Should we prefer selects to doing arithmetic on boolean types.
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array,...
bool preferZeroCompareBranch() const override
Return true if the heuristic to prefer icmp eq zero should be used in code gen prepare.
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
MachineBasicBlock * emitEHSjLjLongJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context, const Type *RetTy) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
std::pair< SDValue, SDValue > makeExternalCall(SDValue Chain, SelectionDAG &DAG, const char *CalleeName, EVT RetVT, ArrayRef< SDValue > Ops, CallingConv::ID CallConv, bool IsSigned, SDLoc DL, bool DoesNotReturn, bool IsReturnValueUsed) const
bool shouldConsiderGEPOffsetSplit() const override
void insertSSPDeclarations(Module &M, const LibcallLoweringInfo &Libcalls) const override
Insert SSP declaration if global stack protector is used.
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
bool mayBeEmittedAsTailCall(const CallInst *CI) const override
Return true if the target may be able emit the call instruction as a tail call.
bool splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, std::optional< CallingConv::ID > CC) const override
Target-specific splitting of values into parts that fit a register storing a legal type.
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain targets require unusual breakdowns of certain types.
bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, unsigned Depth) const override
Return true if this function can prove that Op is never poison and, Kind can be used to track poison ...
SystemZTargetLowering(const TargetMachine &TM, const SystemZSubtarget &STI)
bool isCheapToSpeculateCtlz(Type *) const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT VT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
bool isLegalICmpImmediate(int64_t Imm) const override
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
TargetLowering::ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const override
Examine constraint string and operand type and determine a weight value.
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const override
Determine if the target supports unaligned memory accesses.
const MCPhysReg * getScratchRegisters(CallingConv::ID CC) const override
Returns a 0 terminated array of registers that can be safely used as scratch registers.
TargetLowering::ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
bool ShouldShrinkFPConstant(EVT VT) const override
If true, then instruction selection should seek to shrink the FP constant of the specified type to a ...
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
Register getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
SDValue joinRegisterPartsIntoValue(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, std::optional< CallingConv::ID > CC) const override
Target-specific combining of register parts into its original value.
unsigned getNumRegisters(LLVMContext &Context, EVT VT, std::optional< MVT > RegisterVT) const override
Return the number of registers that this ValueType will eventually require.
bool isTruncateFree(Type *, Type *) const override
Return true if it's free to truncate a value of type FromTy to type ToTy.
SDValue useLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, MVT VT, SDValue Arg, SDLoc DL, SDValue Chain, bool IsStrict) const
unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth) const override
Determine the number of bits in the operation that are sign bits.
ISD::NodeType getExtendForAtomicCmpSwapArg() const override
Returns how the platform's atomic compare and swap expects its comparison value to be extended (ZERO_...
void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked by the type legalizer to legalize nodes with an illegal operand type but leg...
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
InlineAsm::ConstraintCode getInlineAsmMemConstraint(StringRef ConstraintCode) const override
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
bool isLegalAddImmediate(int64_t Imm) const override
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
CondMergingParams getJumpConditionMergingParams(Instruction::BinaryOps Opc, const Value *Lhs, const Value *Rhs, const Function *F) const override
bool isCheapToSpeculateCttz(Type *) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
bool findOptimalMemOpLowering(LLVMContext &Context, std::vector< EVT > &MemOps, unsigned Limit, const MemOp &Op, unsigned DstAS, unsigned SrcAS, const AttributeList &FuncAttributes, EVT *LargestVT=nullptr) const override
Determines the optimal series of memory ops to replace the memset / memcpy.
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
Lower the specified operand into the Ops vector.
unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const override
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override
Return the type to use for a scalar shift opcode, given the shifted amount type.
AtomicExpansionKind shouldCastAtomicStoreInIR(StoreInst *SI) const override
Returns how the given (atomic) store should be cast by the IR-level AtomicExpand pass into.
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
bool hasAndNot(SDValue Y) const override
Return true if the target has a bitwise and-not operation: X = ~A & B This can be used to simplify se...
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array,...
TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const override
Return the preferred vector type legalization action.
void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
unsigned getStackProbeSize(const MachineFunction &MF) const
unsigned getVectorIdxWidth(const DataLayout &DL) const override
Returns the type to be used for the index operand vector operations.
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
virtual unsigned getNumRegisters(LLVMContext &Context, EVT VT, std::optional< MVT > RegisterVT=std::nullopt) const
Return the number of registers that this ValueType will eventually require.
virtual TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const
Return the preferred vector type legalization action.
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
virtual InlineAsm::ConstraintCode getInlineAsmMemConstraint(StringRef ConstraintCode) const
TargetLowering(const TargetLowering &)=delete
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
Value * getOperand(unsigned i) const
Definition User.h:207
LLVM Value Representation.
Definition Value.h:75
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ Fast
Attempts to make calls as fast as possible (e.g.
Definition CallingConv.h:41
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition ISDOpcodes.h:41
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition ISDOpcodes.h:863
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Definition ISDOpcodes.h:860
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
This is an optimization pass for GlobalISel generic memory operations.
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
DWARFExpression::Operation Op
UndefPoisonKind
Enumeration to track whether we are interested in Undef, Poison, or both.
Definition UndefPoison.h:20
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Extended Value Type.
Definition ValueTypes.h:35
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
Definition ValueTypes.h:165
SmallVector< unsigned, 2 > OpVals
bool isVectorConstantLegal(const SystemZSubtarget &Subtarget)