Path: blob/main/contrib/llvm-project/llvm/lib/Target/Sparc/SparcISelLowering.h
35267 views
//===-- SparcISelLowering.h - Sparc 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 Sparc uses to lower LLVM code into a9// selection DAG.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H14#define LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H1516#include "Sparc.h"17#include "llvm/CodeGen/TargetLowering.h"1819namespace llvm {20class SparcSubtarget;2122namespace SPISD {23enum NodeType : unsigned {24FIRST_NUMBER = ISD::BUILTIN_OP_END,25CMPICC, // Compare two GPR operands, set icc+xcc.26CMPFCC, // Compare two FP operands, set fcc.27CMPFCC_V9, // Compare two FP operands, set fcc (v9 variant).28BRICC, // Branch to dest on icc condition29BPICC, // Branch to dest on icc condition, with prediction (64-bit only).30BPXCC, // Branch to dest on xcc condition, with prediction (64-bit only).31BRFCC, // Branch to dest on fcc condition32BRFCC_V9, // Branch to dest on fcc condition (v9 variant).33BR_REG, // Branch to dest using the comparison of a register with zero.34SELECT_ICC, // Select between two values using the current ICC flags.35SELECT_XCC, // Select between two values using the current XCC flags.36SELECT_FCC, // Select between two values using the current FCC flags.37SELECT_REG, // Select between two values using the comparison of a register38// with zero.3940Hi,41Lo, // Hi/Lo operations, typically on a global address.4243FTOI, // FP to Int within a FP register.44ITOF, // Int to FP within a FP register.45FTOX, // FP to Int64 within a FP register.46XTOF, // Int64 to FP within a FP register.4748CALL, // A call instruction.49RET_GLUE, // Return with a glue operand.50GLOBAL_BASE_REG, // Global base reg for PIC.51FLUSHW, // FLUSH register windows to stack.5253TAIL_CALL, // Tail call5455TLS_ADD, // For Thread Local Storage (TLS).56TLS_LD,57TLS_CALL,5859LOAD_GDOP, // Load operation w/ gdop relocation.60};61}6263class SparcTargetLowering : public TargetLowering {64const SparcSubtarget *Subtarget;65public:66SparcTargetLowering(const TargetMachine &TM, const SparcSubtarget &STI);67SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;6869bool useSoftFloat() const override;7071/// computeKnownBitsForTargetNode - Determine which of the bits specified72/// in Mask are known to be either zero or one and return them in the73/// KnownZero/KnownOne bitsets.74void computeKnownBitsForTargetNode(const SDValue Op,75KnownBits &Known,76const APInt &DemandedElts,77const SelectionDAG &DAG,78unsigned Depth = 0) const override;7980MachineBasicBlock *81EmitInstrWithCustomInserter(MachineInstr &MI,82MachineBasicBlock *MBB) const override;8384const char *getTargetNodeName(unsigned Opcode) const override;8586ConstraintType getConstraintType(StringRef Constraint) const override;87ConstraintWeight88getSingleConstraintMatchWeight(AsmOperandInfo &info,89const char *constraint) const override;90void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint,91std::vector<SDValue> &Ops,92SelectionDAG &DAG) const override;9394std::pair<unsigned, const TargetRegisterClass *>95getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,96StringRef Constraint, MVT VT) const override;9798bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;99MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {100return MVT::i32;101}102103Register getRegisterByName(const char* RegName, LLT VT,104const MachineFunction &MF) const override;105106/// If a physical register, this returns the register that receives the107/// exception address on entry to an EH pad.108Register109getExceptionPointerRegister(const Constant *PersonalityFn) const override {110return SP::I0;111}112113/// If a physical register, this returns the register that receives the114/// exception typeid on entry to a landing pad.115Register116getExceptionSelectorRegister(const Constant *PersonalityFn) const override {117return SP::I1;118}119120/// Override to support customized stack guard loading.121bool useLoadStackGuardNode() const override;122void insertSSPDeclarations(Module &M) const override;123124/// getSetCCResultType - Return the ISD::SETCC ValueType125EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,126EVT VT) const override;127128SDValue129LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,130const SmallVectorImpl<ISD::InputArg> &Ins,131const SDLoc &dl, SelectionDAG &DAG,132SmallVectorImpl<SDValue> &InVals) const override;133SDValue LowerFormalArguments_32(SDValue Chain, CallingConv::ID CallConv,134bool isVarArg,135const SmallVectorImpl<ISD::InputArg> &Ins,136const SDLoc &dl, SelectionDAG &DAG,137SmallVectorImpl<SDValue> &InVals) const;138SDValue LowerFormalArguments_64(SDValue Chain, CallingConv::ID CallConv,139bool isVarArg,140const SmallVectorImpl<ISD::InputArg> &Ins,141const SDLoc &dl, SelectionDAG &DAG,142SmallVectorImpl<SDValue> &InVals) const;143144SDValue145LowerCall(TargetLowering::CallLoweringInfo &CLI,146SmallVectorImpl<SDValue> &InVals) const override;147SDValue LowerCall_32(TargetLowering::CallLoweringInfo &CLI,148SmallVectorImpl<SDValue> &InVals) const;149SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI,150SmallVectorImpl<SDValue> &InVals) const;151152bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,153bool isVarArg,154const SmallVectorImpl<ISD::OutputArg> &Outs,155LLVMContext &Context) const override;156157SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,158const SmallVectorImpl<ISD::OutputArg> &Outs,159const SmallVectorImpl<SDValue> &OutVals,160const SDLoc &dl, SelectionDAG &DAG) const override;161SDValue LowerReturn_32(SDValue Chain, CallingConv::ID CallConv,162bool IsVarArg,163const SmallVectorImpl<ISD::OutputArg> &Outs,164const SmallVectorImpl<SDValue> &OutVals,165const SDLoc &DL, SelectionDAG &DAG) const;166SDValue LowerReturn_64(SDValue Chain, CallingConv::ID CallConv,167bool IsVarArg,168const SmallVectorImpl<ISD::OutputArg> &Outs,169const SmallVectorImpl<SDValue> &OutVals,170const SDLoc &DL, SelectionDAG &DAG) const;171172SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;173SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;174SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;175SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;176177SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const;178SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF,179SelectionDAG &DAG) const;180SDValue makeAddress(SDValue Op, SelectionDAG &DAG) const;181182SDValue LowerF128_LibCallArg(SDValue Chain, ArgListTy &Args, SDValue Arg,183const SDLoc &DL, SelectionDAG &DAG) const;184SDValue LowerF128Op(SDValue Op, SelectionDAG &DAG,185const char *LibFuncName,186unsigned numArgs) const;187SDValue LowerF128Compare(SDValue LHS, SDValue RHS, unsigned &SPCC,188const SDLoc &DL, SelectionDAG &DAG) const;189190SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;191192SDValue PerformBITCASTCombine(SDNode *N, DAGCombinerInfo &DCI) const;193194SDValue bitcastConstantFPToInt(ConstantFPSDNode *C, const SDLoc &DL,195SelectionDAG &DAG) const;196197SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;198199bool IsEligibleForTailCallOptimization(CCState &CCInfo,200CallLoweringInfo &CLI,201MachineFunction &MF) const;202203bool ShouldShrinkFPConstant(EVT VT) const override {204// Do not shrink FP constpool if VT == MVT::f128.205// (ldd, call _Q_fdtoq) is more expensive than two ldds.206return VT != MVT::f128;207}208209bool shouldInsertFencesForAtomic(const Instruction *I) const override {210// FIXME: We insert fences for each atomics and generate211// sub-optimal code for PSO/TSO. (Approximately nobody uses any212// mode but TSO, which makes this even more silly)213return true;214}215216AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;217218void ReplaceNodeResults(SDNode *N,219SmallVectorImpl<SDValue>& Results,220SelectionDAG &DAG) const override;221222MachineBasicBlock *expandSelectCC(MachineInstr &MI, MachineBasicBlock *BB,223unsigned BROpcode) const;224225void AdjustInstrPostInstrSelection(MachineInstr &MI,226SDNode *Node) const override;227};228} // end namespace llvm229230#endif // LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H231232233