Path: blob/main/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.h
35269 views
//===-- SystemZISelLowering.h - SystemZ DAG lowering interface --*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines the interfaces that SystemZ uses to lower LLVM code into a9// selection DAG.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZISELLOWERING_H14#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZISELLOWERING_H1516#include "SystemZ.h"17#include "SystemZInstrInfo.h"18#include "llvm/CodeGen/MachineBasicBlock.h"19#include "llvm/CodeGen/SelectionDAG.h"20#include "llvm/CodeGen/TargetLowering.h"21#include <optional>2223namespace llvm {24namespace SystemZISD {25enum NodeType : unsigned {26FIRST_NUMBER = ISD::BUILTIN_OP_END,2728// Return with a glue operand. Operand 0 is the chain operand.29RET_GLUE,3031// Calls a function. Operand 0 is the chain operand and operand 132// is the target address. The arguments start at operand 2.33// There is an optional glue operand at the end.34CALL,35SIBCALL,3637// TLS calls. Like regular calls, except operand 1 is the TLS symbol.38// (The call target is implicitly __tls_get_offset.)39TLS_GDCALL,40TLS_LDCALL,4142// Wraps a TargetGlobalAddress that should be loaded using PC-relative43// accesses (LARL). Operand 0 is the address.44PCREL_WRAPPER,4546// Used in cases where an offset is applied to a TargetGlobalAddress.47// Operand 0 is the full TargetGlobalAddress and operand 1 is a48// PCREL_WRAPPER for an anchor point. This is used so that we can49// cheaply refer to either the full address or the anchor point50// as a register base.51PCREL_OFFSET,5253// Integer comparisons. There are three operands: the two values54// to compare, and an integer of type SystemZICMP.55ICMP,5657// Floating-point comparisons. The two operands are the values to compare.58FCMP,5960// Test under mask. The first operand is ANDed with the second operand61// and the condition codes are set on the result. The third operand is62// a boolean that is true if the condition codes need to distinguish63// between CCMASK_TM_MIXED_MSB_0 and CCMASK_TM_MIXED_MSB_1 (which the64// register forms do but the memory forms don't).65TM,6667// Branches if a condition is true. Operand 0 is the chain operand;68// operand 1 is the 4-bit condition-code mask, with bit N in69// big-endian order meaning "branch if CC=N"; operand 2 is the70// target block and operand 3 is the flag operand.71BR_CCMASK,7273// Selects between operand 0 and operand 1. Operand 2 is the74// mask of condition-code values for which operand 0 should be75// chosen over operand 1; it has the same form as BR_CCMASK.76// Operand 3 is the flag operand.77SELECT_CCMASK,7879// Evaluates to the gap between the stack pointer and the80// base of the dynamically-allocatable area.81ADJDYNALLOC,8283// For allocating stack space when using stack clash protector.84// Allocation is performed by block, and each block is probed.85PROBED_ALLOCA,8687// Count number of bits set in operand 0 per byte.88POPCNT,8990// Wrappers around the ISD opcodes of the same name. The output is GR128.91// Input operands may be GR64 or GR32, depending on the instruction.92SMUL_LOHI,93UMUL_LOHI,94SDIVREM,95UDIVREM,9697// Add/subtract with overflow/carry. These have the same operands as98// the corresponding standard operations, except with the carry flag99// replaced by a condition code value.100SADDO, SSUBO, UADDO, USUBO, ADDCARRY, SUBCARRY,101102// Set the condition code from a boolean value in operand 0.103// Operand 1 is a mask of all condition-code values that may result of this104// operation, operand 2 is a mask of condition-code values that may result105// if the boolean is true.106// Note that this operation is always optimized away, we will never107// generate any code for it.108GET_CCMASK,109110// Use a series of MVCs to copy bytes from one memory location to another.111// The operands are:112// - the target address113// - the source address114// - the constant length115//116// This isn't a memory opcode because we'd need to attach two117// MachineMemOperands rather than one.118MVC,119120// Similar to MVC, but for logic operations (AND, OR, XOR).121NC,122OC,123XC,124125// Use CLC to compare two blocks of memory, with the same comments126// as for MVC.127CLC,128129// Use MVC to set a block of memory after storing the first byte.130MEMSET_MVC,131132// Use an MVST-based sequence to implement stpcpy().133STPCPY,134135// Use a CLST-based sequence to implement strcmp(). The two input operands136// are the addresses of the strings to compare.137STRCMP,138139// Use an SRST-based sequence to search a block of memory. The first140// operand is the end address, the second is the start, and the third141// is the character to search for. CC is set to 1 on success and 2142// on failure.143SEARCH_STRING,144145// Store the CC value in bits 29 and 28 of an integer.146IPM,147148// Transaction begin. The first operand is the chain, the second149// the TDB pointer, and the third the immediate control field.150// Returns CC value and chain.151TBEGIN,152TBEGIN_NOFLOAT,153154// Transaction end. Just the chain operand. Returns CC value and chain.155TEND,156157// Create a vector constant by filling byte N of the result with bit158// 15-N of the single operand.159BYTE_MASK,160161// Create a vector constant by replicating an element-sized RISBG-style mask.162// The first operand specifies the starting set bit and the second operand163// specifies the ending set bit. Both operands count from the MSB of the164// element.165ROTATE_MASK,166167// Replicate a GPR scalar value into all elements of a vector.168REPLICATE,169170// Create a vector from two i64 GPRs.171JOIN_DWORDS,172173// Replicate one element of a vector into all elements. The first operand174// is the vector and the second is the index of the element to replicate.175SPLAT,176177// Interleave elements from the high half of operand 0 and the high half178// of operand 1.179MERGE_HIGH,180181// Likewise for the low halves.182MERGE_LOW,183184// Concatenate the vectors in the first two operands, shift them left185// by the third operand, and take the first half of the result.186SHL_DOUBLE,187188// Take one element of the first v2i64 operand and the one element of189// the second v2i64 operand and concatenate them to form a v2i64 result.190// The third operand is a 4-bit value of the form 0A0B, where A and B191// are the element selectors for the first operand and second operands192// respectively.193PERMUTE_DWORDS,194195// Perform a general vector permute on vector operands 0 and 1.196// Each byte of operand 2 controls the corresponding byte of the result,197// in the same way as a byte-level VECTOR_SHUFFLE mask.198PERMUTE,199200// Pack vector operands 0 and 1 into a single vector with half-sized elements.201PACK,202203// Likewise, but saturate the result and set CC. PACKS_CC does signed204// saturation and PACKLS_CC does unsigned saturation.205PACKS_CC,206PACKLS_CC,207208// Unpack the first half of vector operand 0 into double-sized elements.209// UNPACK_HIGH sign-extends and UNPACKL_HIGH zero-extends.210UNPACK_HIGH,211UNPACKL_HIGH,212213// Likewise for the second half.214UNPACK_LOW,215UNPACKL_LOW,216217// Shift/rotate each element of vector operand 0 by the number of bits218// specified by scalar operand 1.219VSHL_BY_SCALAR,220VSRL_BY_SCALAR,221VSRA_BY_SCALAR,222VROTL_BY_SCALAR,223224// For each element of the output type, sum across all sub-elements of225// operand 0 belonging to the corresponding element, and add in the226// rightmost sub-element of the corresponding element of operand 1.227VSUM,228229// Compute carry/borrow indication for add/subtract.230VACC, VSCBI,231// Add/subtract with carry/borrow.232VAC, VSBI,233// Compute carry/borrow indication for add/subtract with carry/borrow.234VACCC, VSBCBI,235236// Compare integer vector operands 0 and 1 to produce the usual 0/-1237// vector result. VICMPE is for equality, VICMPH for "signed greater than"238// and VICMPHL for "unsigned greater than".239VICMPE,240VICMPH,241VICMPHL,242243// Likewise, but also set the condition codes on the result.244VICMPES,245VICMPHS,246VICMPHLS,247248// Compare floating-point vector operands 0 and 1 to produce the usual 0/-1249// vector result. VFCMPE is for "ordered and equal", VFCMPH for "ordered and250// greater than" and VFCMPHE for "ordered and greater than or equal to".251VFCMPE,252VFCMPH,253VFCMPHE,254255// Likewise, but also set the condition codes on the result.256VFCMPES,257VFCMPHS,258VFCMPHES,259260// Test floating-point data class for vectors.261VFTCI,262263// Extend the even f32 elements of vector operand 0 to produce a vector264// of f64 elements.265VEXTEND,266267// Round the f64 elements of vector operand 0 to f32s and store them in the268// even elements of the result.269VROUND,270271// AND the two vector operands together and set CC based on the result.272VTM,273274// i128 high integer comparisons.275SCMP128HI,276UCMP128HI,277278// String operations that set CC as a side-effect.279VFAE_CC,280VFAEZ_CC,281VFEE_CC,282VFEEZ_CC,283VFENE_CC,284VFENEZ_CC,285VISTR_CC,286VSTRC_CC,287VSTRCZ_CC,288VSTRS_CC,289VSTRSZ_CC,290291// Test Data Class.292//293// Operand 0: the value to test294// Operand 1: the bit mask295TDC,296297// z/OS XPLINK ADA Entry298// Wraps a TargetGlobalAddress that should be loaded from a function's299// AssociatedData Area (ADA). Tha ADA is passed to the function by the300// caller in the XPLink ABI defined register R5.301// Operand 0: the GlobalValue/External Symbol302// Operand 1: the ADA register303// Operand 2: the offset (0 for the first and 8 for the second element in the304// function descriptor)305ADA_ENTRY,306307// Strict variants of scalar floating-point comparisons.308// Quiet and signaling versions.309STRICT_FCMP = ISD::FIRST_TARGET_STRICTFP_OPCODE,310STRICT_FCMPS,311312// Strict variants of vector floating-point comparisons.313// Quiet and signaling versions.314STRICT_VFCMPE,315STRICT_VFCMPH,316STRICT_VFCMPHE,317STRICT_VFCMPES,318STRICT_VFCMPHS,319STRICT_VFCMPHES,320321// Strict variants of VEXTEND and VROUND.322STRICT_VEXTEND,323STRICT_VROUND,324325// Wrappers around the inner loop of an 8- or 16-bit ATOMIC_SWAP or326// ATOMIC_LOAD_<op>.327//328// Operand 0: the address of the containing 32-bit-aligned field329// Operand 1: the second operand of <op>, in the high bits of an i32330// for everything except ATOMIC_SWAPW331// Operand 2: how many bits to rotate the i32 left to bring the first332// operand into the high bits333// Operand 3: the negative of operand 2, for rotating the other way334// Operand 4: the width of the field in bits (8 or 16)335ATOMIC_SWAPW = ISD::FIRST_TARGET_MEMORY_OPCODE,336ATOMIC_LOADW_ADD,337ATOMIC_LOADW_SUB,338ATOMIC_LOADW_AND,339ATOMIC_LOADW_OR,340ATOMIC_LOADW_XOR,341ATOMIC_LOADW_NAND,342ATOMIC_LOADW_MIN,343ATOMIC_LOADW_MAX,344ATOMIC_LOADW_UMIN,345ATOMIC_LOADW_UMAX,346347// A wrapper around the inner loop of an ATOMIC_CMP_SWAP.348//349// Operand 0: the address of the containing 32-bit-aligned field350// Operand 1: the compare value, in the low bits of an i32351// Operand 2: the swap value, in the low bits of an i32352// Operand 3: how many bits to rotate the i32 left to bring the first353// operand into the high bits354// Operand 4: the negative of operand 2, for rotating the other way355// Operand 5: the width of the field in bits (8 or 16)356ATOMIC_CMP_SWAPW,357358// Atomic compare-and-swap returning CC value.359// Val, CC, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)360ATOMIC_CMP_SWAP,361362// 128-bit atomic load.363// Val, OUTCHAIN = ATOMIC_LOAD_128(INCHAIN, ptr)364ATOMIC_LOAD_128,365366// 128-bit atomic store.367// OUTCHAIN = ATOMIC_STORE_128(INCHAIN, val, ptr)368ATOMIC_STORE_128,369370// 128-bit atomic compare-and-swap.371// Val, CC, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)372ATOMIC_CMP_SWAP_128,373374// Byte swapping load/store. Same operands as regular load/store.375LRV, STRV,376377// Element swapping load/store. Same operands as regular load/store.378VLER, VSTER,379380// Use STORE CLOCK FAST to store current TOD clock value.381STCKF,382383// Prefetch from the second operand using the 4-bit control code in384// the first operand. The code is 1 for a load prefetch and 2 for385// a store prefetch.386PREFETCH387};388389// Return true if OPCODE is some kind of PC-relative address.390inline bool isPCREL(unsigned Opcode) {391return Opcode == PCREL_WRAPPER || Opcode == PCREL_OFFSET;392}393} // end namespace SystemZISD394395namespace SystemZICMP {396// Describes whether an integer comparison needs to be signed or unsigned,397// or whether either type is OK.398enum {399Any,400UnsignedOnly,401SignedOnly402};403} // end namespace SystemZICMP404405class SystemZSubtarget;406407class SystemZTargetLowering : public TargetLowering {408public:409explicit SystemZTargetLowering(const TargetMachine &TM,410const SystemZSubtarget &STI);411412bool useSoftFloat() const override;413414// Override TargetLowering.415MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {416return MVT::i32;417}418MVT getVectorIdxTy(const DataLayout &DL) const override {419// Only the lower 12 bits of an element index are used, so we don't420// want to clobber the upper 32 bits of a GPR unnecessarily.421return MVT::i32;422}423TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT)424const override {425// Widen subvectors to the full width rather than promoting integer426// elements. This is better because:427//428// (a) it means that we can handle the ABI for passing and returning429// sub-128 vectors without having to handle them as legal types.430//431// (b) we don't have instructions to extend on load and truncate on store,432// so promoting the integers is less efficient.433//434// (c) there are no multiplication instructions for the widest integer435// type (v2i64).436if (VT.getScalarSizeInBits() % 8 == 0)437return TypeWidenVector;438return TargetLoweringBase::getPreferredVectorAction(VT);439}440unsigned441getNumRegisters(LLVMContext &Context, EVT VT,442std::optional<MVT> RegisterVT) const override {443// i128 inline assembly operand.444if (VT == MVT::i128 && RegisterVT && *RegisterVT == MVT::Untyped)445return 1;446return TargetLowering::getNumRegisters(Context, VT);447}448MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC,449EVT VT) const override {450// 128-bit single-element vector types are passed like other vectors,451// not like their element type.452if (VT.isVector() && VT.getSizeInBits() == 128 &&453VT.getVectorNumElements() == 1)454return MVT::v16i8;455return TargetLowering::getRegisterTypeForCallingConv(Context, CC, VT);456}457bool isCheapToSpeculateCtlz(Type *) const override { return true; }458bool isCheapToSpeculateCttz(Type *) const override { return true; }459bool preferZeroCompareBranch() const override { return true; }460bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override {461ConstantInt* Mask = dyn_cast<ConstantInt>(AndI.getOperand(1));462return Mask && Mask->getValue().isIntN(16);463}464bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {465return VT.isScalarInteger();466}467EVT getSetCCResultType(const DataLayout &DL, LLVMContext &,468EVT) const override;469bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,470EVT VT) const override;471bool isFPImmLegal(const APFloat &Imm, EVT VT,472bool ForCodeSize) const override;473bool ShouldShrinkFPConstant(EVT VT) const override {474// Do not shrink 64-bit FP constpool entries since LDEB is slower than475// LD, and having the full constant in memory enables reg/mem opcodes.476return VT != MVT::f64;477}478bool hasInlineStackProbe(const MachineFunction &MF) const override;479AtomicExpansionKind shouldCastAtomicLoadInIR(LoadInst *LI) const override;480AtomicExpansionKind shouldCastAtomicStoreInIR(StoreInst *SI) const override;481AtomicExpansionKind482shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const override;483bool isLegalICmpImmediate(int64_t Imm) const override;484bool isLegalAddImmediate(int64_t Imm) const override;485bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,486unsigned AS,487Instruction *I = nullptr) const override;488bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, Align Alignment,489MachineMemOperand::Flags Flags,490unsigned *Fast) const override;491bool492findOptimalMemOpLowering(std::vector<EVT> &MemOps, unsigned Limit,493const MemOp &Op, unsigned DstAS, unsigned SrcAS,494const AttributeList &FuncAttributes) const override;495EVT getOptimalMemOpType(const MemOp &Op,496const AttributeList &FuncAttributes) const override;497bool isTruncateFree(Type *, Type *) const override;498bool isTruncateFree(EVT, EVT) const override;499500bool shouldFormOverflowOp(unsigned Opcode, EVT VT,501bool MathUsed) const override {502// Form add and sub with overflow intrinsics regardless of any extra503// users of the math result.504return VT == MVT::i32 || VT == MVT::i64;505}506507bool shouldConsiderGEPOffsetSplit() const override { return true; }508509bool shouldExpandCmpUsingSelects() const override { return true; }510511const char *getTargetNodeName(unsigned Opcode) const override;512std::pair<unsigned, const TargetRegisterClass *>513getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,514StringRef Constraint, MVT VT) const override;515TargetLowering::ConstraintType516getConstraintType(StringRef Constraint) const override;517TargetLowering::ConstraintWeight518getSingleConstraintMatchWeight(AsmOperandInfo &info,519const char *constraint) const override;520void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint,521std::vector<SDValue> &Ops,522SelectionDAG &DAG) const override;523524InlineAsm::ConstraintCode525getInlineAsmMemConstraint(StringRef ConstraintCode) const override {526if (ConstraintCode.size() == 1) {527switch(ConstraintCode[0]) {528default:529break;530case 'o':531return InlineAsm::ConstraintCode::o;532case 'Q':533return InlineAsm::ConstraintCode::Q;534case 'R':535return InlineAsm::ConstraintCode::R;536case 'S':537return InlineAsm::ConstraintCode::S;538case 'T':539return InlineAsm::ConstraintCode::T;540}541} else if (ConstraintCode.size() == 2 && ConstraintCode[0] == 'Z') {542switch (ConstraintCode[1]) {543default:544break;545case 'Q':546return InlineAsm::ConstraintCode::ZQ;547case 'R':548return InlineAsm::ConstraintCode::ZR;549case 'S':550return InlineAsm::ConstraintCode::ZS;551case 'T':552return InlineAsm::ConstraintCode::ZT;553}554}555return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);556}557558Register getRegisterByName(const char *RegName, LLT VT,559const MachineFunction &MF) const override;560561/// If a physical register, this returns the register that receives the562/// exception address on entry to an EH pad.563Register564getExceptionPointerRegister(const Constant *PersonalityFn) const override;565566/// If a physical register, this returns the register that receives the567/// exception typeid on entry to a landing pad.568Register569getExceptionSelectorRegister(const Constant *PersonalityFn) const override;570571/// Override to support customized stack guard loading.572bool useLoadStackGuardNode() const override {573return true;574}575void insertSSPDeclarations(Module &M) const override {576}577578MachineBasicBlock *579EmitInstrWithCustomInserter(MachineInstr &MI,580MachineBasicBlock *BB) const override;581SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;582void LowerOperationWrapper(SDNode *N, SmallVectorImpl<SDValue> &Results,583SelectionDAG &DAG) const override;584void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,585SelectionDAG &DAG) const override;586const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;587bool allowTruncateForTailCall(Type *, Type *) const override;588bool mayBeEmittedAsTailCall(const CallInst *CI) const override;589bool splitValueIntoRegisterParts(590SelectionDAG & DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,591unsigned NumParts, MVT PartVT, std::optional<CallingConv::ID> CC)592const override;593SDValue joinRegisterPartsIntoValue(594SelectionDAG & DAG, const SDLoc &DL, const SDValue *Parts,595unsigned NumParts, MVT PartVT, EVT ValueVT,596std::optional<CallingConv::ID> CC) const override;597SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,598bool isVarArg,599const SmallVectorImpl<ISD::InputArg> &Ins,600const SDLoc &DL, SelectionDAG &DAG,601SmallVectorImpl<SDValue> &InVals) const override;602SDValue LowerCall(CallLoweringInfo &CLI,603SmallVectorImpl<SDValue> &InVals) const override;604605std::pair<SDValue, SDValue>606makeExternalCall(SDValue Chain, SelectionDAG &DAG, const char *CalleeName,607EVT RetVT, ArrayRef<SDValue> Ops, CallingConv::ID CallConv,608bool IsSigned, SDLoc DL, bool DoesNotReturn,609bool IsReturnValueUsed) const;610611bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,612bool isVarArg,613const SmallVectorImpl<ISD::OutputArg> &Outs,614LLVMContext &Context) const override;615SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,616const SmallVectorImpl<ISD::OutputArg> &Outs,617const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,618SelectionDAG &DAG) const override;619SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;620621/// Determine which of the bits specified in Mask are known to be either622/// zero or one and return them in the KnownZero/KnownOne bitsets.623void computeKnownBitsForTargetNode(const SDValue Op,624KnownBits &Known,625const APInt &DemandedElts,626const SelectionDAG &DAG,627unsigned Depth = 0) const override;628629/// Determine the number of bits in the operation that are sign bits.630unsigned ComputeNumSignBitsForTargetNode(SDValue Op,631const APInt &DemandedElts,632const SelectionDAG &DAG,633unsigned Depth) const override;634635bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(636SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,637bool PoisonOnly, unsigned Depth) const override;638639ISD::NodeType getExtendForAtomicOps() const override {640return ISD::ANY_EXTEND;641}642ISD::NodeType getExtendForAtomicCmpSwapArg() const override {643return ISD::ZERO_EXTEND;644}645646bool supportSwiftError() const override {647return true;648}649650unsigned getStackProbeSize(const MachineFunction &MF) const;651652private:653const SystemZSubtarget &Subtarget;654655// Implement LowerOperation for individual opcodes.656SDValue getVectorCmp(SelectionDAG &DAG, unsigned Opcode,657const SDLoc &DL, EVT VT,658SDValue CmpOp0, SDValue CmpOp1, SDValue Chain) const;659SDValue lowerVectorSETCC(SelectionDAG &DAG, const SDLoc &DL,660EVT VT, ISD::CondCode CC,661SDValue CmpOp0, SDValue CmpOp1,662SDValue Chain = SDValue(),663bool IsSignaling = false) const;664SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;665SDValue lowerSTRICT_FSETCC(SDValue Op, SelectionDAG &DAG,666bool IsSignaling) const;667SDValue lowerBR_CC(SDValue Op, SelectionDAG &DAG) const;668SDValue lowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;669SDValue lowerGlobalAddress(GlobalAddressSDNode *Node,670SelectionDAG &DAG) const;671SDValue lowerTLSGetOffset(GlobalAddressSDNode *Node,672SelectionDAG &DAG, unsigned Opcode,673SDValue GOTOffset) const;674SDValue lowerThreadPointer(const SDLoc &DL, SelectionDAG &DAG) const;675SDValue lowerGlobalTLSAddress(GlobalAddressSDNode *Node,676SelectionDAG &DAG) const;677SDValue lowerBlockAddress(BlockAddressSDNode *Node,678SelectionDAG &DAG) const;679SDValue lowerJumpTable(JumpTableSDNode *JT, SelectionDAG &DAG) const;680SDValue lowerConstantPool(ConstantPoolSDNode *CP, SelectionDAG &DAG) const;681SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;682SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;683SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;684SDValue lowerVASTART_ELF(SDValue Op, SelectionDAG &DAG) const;685SDValue lowerVASTART_XPLINK(SDValue Op, SelectionDAG &DAG) const;686SDValue lowerVACOPY(SDValue Op, SelectionDAG &DAG) const;687SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;688SDValue lowerDYNAMIC_STACKALLOC_ELF(SDValue Op, SelectionDAG &DAG) const;689SDValue lowerDYNAMIC_STACKALLOC_XPLINK(SDValue Op, SelectionDAG &DAG) const;690SDValue lowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const;691SDValue lowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;692SDValue lowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;693SDValue lowerSDIVREM(SDValue Op, SelectionDAG &DAG) const;694SDValue lowerUDIVREM(SDValue Op, SelectionDAG &DAG) const;695SDValue lowerXALUO(SDValue Op, SelectionDAG &DAG) const;696SDValue lowerUADDSUBO_CARRY(SDValue Op, SelectionDAG &DAG) const;697SDValue lowerBITCAST(SDValue Op, SelectionDAG &DAG) const;698SDValue lowerOR(SDValue Op, SelectionDAG &DAG) const;699SDValue lowerCTPOP(SDValue Op, SelectionDAG &DAG) const;700SDValue lowerVECREDUCE_ADD(SDValue Op, SelectionDAG &DAG) const;701SDValue lowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const;702SDValue lowerATOMIC_LDST_I128(SDValue Op, SelectionDAG &DAG) const;703SDValue lowerATOMIC_LOAD_OP(SDValue Op, SelectionDAG &DAG,704unsigned Opcode) const;705SDValue lowerATOMIC_LOAD_SUB(SDValue Op, SelectionDAG &DAG) const;706SDValue lowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const;707SDValue lowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;708SDValue lowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;709SDValue lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;710SDValue lowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;711SDValue lowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;712bool isVectorElementLoad(SDValue Op) const;713SDValue buildVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT,714SmallVectorImpl<SDValue> &Elems) const;715SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;716SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;717SDValue lowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;718SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;719SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;720SDValue lowerSIGN_EXTEND_VECTOR_INREG(SDValue Op, SelectionDAG &DAG) const;721SDValue lowerZERO_EXTEND_VECTOR_INREG(SDValue Op, SelectionDAG &DAG) const;722SDValue lowerShift(SDValue Op, SelectionDAG &DAG, unsigned ByScalar) const;723SDValue lowerIS_FPCLASS(SDValue Op, SelectionDAG &DAG) const;724SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;725SDValue lowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;726727bool canTreatAsByteVector(EVT VT) const;728SDValue combineExtract(const SDLoc &DL, EVT ElemVT, EVT VecVT, SDValue OrigOp,729unsigned Index, DAGCombinerInfo &DCI,730bool Force) const;731SDValue combineTruncateExtract(const SDLoc &DL, EVT TruncVT, SDValue Op,732DAGCombinerInfo &DCI) const;733SDValue combineZERO_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;734SDValue combineSIGN_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;735SDValue combineSIGN_EXTEND_INREG(SDNode *N, DAGCombinerInfo &DCI) const;736SDValue combineMERGE(SDNode *N, DAGCombinerInfo &DCI) const;737bool canLoadStoreByteSwapped(EVT VT) const;738SDValue combineLOAD(SDNode *N, DAGCombinerInfo &DCI) const;739SDValue combineSTORE(SDNode *N, DAGCombinerInfo &DCI) const;740SDValue combineVECTOR_SHUFFLE(SDNode *N, DAGCombinerInfo &DCI) const;741SDValue combineEXTRACT_VECTOR_ELT(SDNode *N, DAGCombinerInfo &DCI) const;742SDValue combineJOIN_DWORDS(SDNode *N, DAGCombinerInfo &DCI) const;743SDValue combineFP_ROUND(SDNode *N, DAGCombinerInfo &DCI) const;744SDValue combineFP_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;745SDValue combineINT_TO_FP(SDNode *N, DAGCombinerInfo &DCI) const;746SDValue combineBSWAP(SDNode *N, DAGCombinerInfo &DCI) const;747SDValue combineBR_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;748SDValue combineSELECT_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;749SDValue combineGET_CCMASK(SDNode *N, DAGCombinerInfo &DCI) const;750SDValue combineIntDIVREM(SDNode *N, DAGCombinerInfo &DCI) const;751SDValue combineINTRINSIC(SDNode *N, DAGCombinerInfo &DCI) const;752753SDValue unwrapAddress(SDValue N) const override;754755// If the last instruction before MBBI in MBB was some form of COMPARE,756// try to replace it with a COMPARE AND BRANCH just before MBBI.757// CCMask and Target are the BRC-like operands for the branch.758// Return true if the change was made.759bool convertPrevCompareToBranch(MachineBasicBlock *MBB,760MachineBasicBlock::iterator MBBI,761unsigned CCMask,762MachineBasicBlock *Target) const;763764// Implement EmitInstrWithCustomInserter for individual operation types.765MachineBasicBlock *emitAdjCallStack(MachineInstr &MI,766MachineBasicBlock *BB) const;767MachineBasicBlock *emitSelect(MachineInstr &MI, MachineBasicBlock *BB) const;768MachineBasicBlock *emitCondStore(MachineInstr &MI, MachineBasicBlock *BB,769unsigned StoreOpcode, unsigned STOCOpcode,770bool Invert) const;771MachineBasicBlock *emitICmp128Hi(MachineInstr &MI, MachineBasicBlock *BB,772bool Unsigned) const;773MachineBasicBlock *emitPair128(MachineInstr &MI,774MachineBasicBlock *MBB) const;775MachineBasicBlock *emitExt128(MachineInstr &MI, MachineBasicBlock *MBB,776bool ClearEven) const;777MachineBasicBlock *emitAtomicLoadBinary(MachineInstr &MI,778MachineBasicBlock *BB,779unsigned BinOpcode,780bool Invert = false) const;781MachineBasicBlock *emitAtomicLoadMinMax(MachineInstr &MI,782MachineBasicBlock *MBB,783unsigned CompareOpcode,784unsigned KeepOldMask) const;785MachineBasicBlock *emitAtomicCmpSwapW(MachineInstr &MI,786MachineBasicBlock *BB) const;787MachineBasicBlock *emitMemMemWrapper(MachineInstr &MI, MachineBasicBlock *BB,788unsigned Opcode,789bool IsMemset = false) const;790MachineBasicBlock *emitStringWrapper(MachineInstr &MI, MachineBasicBlock *BB,791unsigned Opcode) const;792MachineBasicBlock *emitTransactionBegin(MachineInstr &MI,793MachineBasicBlock *MBB,794unsigned Opcode, bool NoFloat) const;795MachineBasicBlock *emitLoadAndTestCmp0(MachineInstr &MI,796MachineBasicBlock *MBB,797unsigned Opcode) const;798MachineBasicBlock *emitProbedAlloca(MachineInstr &MI,799MachineBasicBlock *MBB) const;800801SDValue getBackchainAddress(SDValue SP, SelectionDAG &DAG) const;802803MachineMemOperand::Flags804getTargetMMOFlags(const Instruction &I) const override;805const TargetRegisterClass *getRepRegClassFor(MVT VT) const override;806};807808struct SystemZVectorConstantInfo {809private:810APInt IntBits; // The 128 bits as an integer.811APInt SplatBits; // Smallest splat value.812APInt SplatUndef; // Bits correspoding to undef operands of the BVN.813unsigned SplatBitSize = 0;814bool isFP128 = false;815public:816unsigned Opcode = 0;817SmallVector<unsigned, 2> OpVals;818MVT VecVT;819SystemZVectorConstantInfo(APInt IntImm);820SystemZVectorConstantInfo(APFloat FPImm)821: SystemZVectorConstantInfo(FPImm.bitcastToAPInt()) {822isFP128 = (&FPImm.getSemantics() == &APFloat::IEEEquad());823}824SystemZVectorConstantInfo(BuildVectorSDNode *BVN);825bool isVectorConstantLegal(const SystemZSubtarget &Subtarget);826};827828} // end namespace llvm829830#endif831832833