36#define DEBUG_TYPE "xtensa-lower"
50 if (
Reg >= Xtensa::A2 &&
Reg <= Xtensa::A7)
51 return Reg - Xtensa::A2 + Xtensa::A10;
62 if (Subtarget.hasSingleFloat()) {
66 if (Subtarget.hasBoolean()) {
122 if (Subtarget.hasSingleFloat()) {
138 if (Subtarget.hasMul32())
143 if (Subtarget.hasMul32High()) {
154 if (Subtarget.hasDiv32()) {
199 for (
unsigned I = MVT::FIRST_FP_VALUETYPE;
I <= MVT::LAST_FP_VALUETYPE; ++
I) {
202 if (VT.
getSizeInBits() == 32 && Subtarget.hasSingleFloat()) {
231 if (Subtarget.hasSingleFloat()) {
261 if (Subtarget.hasS32C1I()) {
264 }
else if (Subtarget.hasForcedAtomics()) {
292 bool ForCodeSize)
const {
301 if (Constraint.
size() == 1) {
302 switch (Constraint[0]) {
317 Value *CallOperandVal = Info.CallOperandVal;
326 switch (*Constraint) {
331 if (Ty->isIntegerTy())
335 if (Ty->isFloatingPointTy())
342std::pair<unsigned, const TargetRegisterClass *>
345 if (Constraint.
size() == 1) {
347 switch (Constraint[0]) {
351 return std::make_pair(0U, &Xtensa::ARRegClass);
353 if (Subtarget.hasSingleFloat())
354 return std::make_pair(0U, &Xtensa::FPRRegClass);
366 if (Constraint.
size() > 1)
376#define GET_CALLING_CONV_IMPL
377#include "XtensaGenCallingConv.inc"
380 Xtensa::A5, Xtensa::A6, Xtensa::A7};
392 if (ByValAlign <
Align(4)) {
393 ByValAlign =
Align(4);
395 unsigned Offset = State.AllocateStack(ByValSize, ByValAlign);
399 while (State.AllocateReg(
IntRegs))
405 if (LocVT == MVT::i8 || LocVT == MVT::i16) {
409 else if (ArgFlags.
isZExt())
418 bool needs64BitAlign = (ValVT == MVT::i32 && OrigAlign ==
Align(8));
419 bool needs128BitAlign = (ValVT == MVT::i32 && OrigAlign ==
Align(16));
421 if (ValVT == MVT::i32) {
430 if (needs128BitAlign && (
Register != Xtensa::A2))
434 }
else if (ValVT == MVT::f64) {
467 bool IsVarArg)
const {
480 std::vector<SDValue> OutChains;
489 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
495 if (RegVT != MVT::i32)
501 MCRegister FrameReg = Subtarget.getRegisterInfo()->getFrameRegister(MF);
505 if (Subtarget.isWindowedABI() && (VA.
getLocReg() == FrameReg)) {
506 Reg = MF.
addLiveIn(Xtensa::A8, &Xtensa::ARRegClass);
524 ArgValue = DAG.
getNode(Opcode,
DL, RegVT, ArgValue,
542 if (Ins[VA.
getValNo()].Flags.isByVal()) {
551 ValVT,
DL, Chain, FIN,
559 unsigned ArgRegsNum = std::size(
IntRegs);
564 MVT RegTy = MVT::i32;
575 int VaArgOffset, VarArgsSaveSize;
579 if (ArgRegsNum == Idx) {
583 VarArgsSaveSize =
RegSize * (ArgRegsNum - Idx);
584 VaArgOffset = -VarArgsSaveSize;
593 for (
unsigned I = Idx;
I < ArgRegsNum; ++
I, VaArgOffset +=
RegSize) {
594 const Register Reg = RegInfo.createVirtualRegister(RC);
602 OutChains.push_back(
Store);
609 if (!OutChains.empty()) {
610 OutChains.push_back(Chain);
642 CCAssignFn *CC = CCAssignFnForCall(CallConv, IsVarArg);
650 unsigned NextStackOffset =
alignTo(NumBytes, StackAlignment);
655 std::deque<std::pair<unsigned, SDValue>> RegsToPass;
658 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
666 else if (Flags.isByVal()) {
668 assert(Flags.getByValSize() &&
669 "ByVal args of size 0 should have been ignored by front-end.");
671 "Do not tail-call optimize if there is a byval argument.");
673 if (!StackPtr.getNode())
679 Align Alignment = Flags.getNonZeroByValAlign();
681 Chain,
DL,
Address, ArgValue, SizeNode, Alignment, Alignment,
691 if (!StackPtr.getNode())
704 if (!MemOpChains.
empty())
709 for (
unsigned I = 0, E = RegsToPass.size();
I != E; ++
I) {
710 unsigned Reg = RegsToPass[
I].first;
711 if (Subtarget.isWindowedABI())
717 unsigned char TF = 0;
722 name = E->getSymbol();
723 TF = E->getTargetFlags();
745 SDValue CPWrap = getAddrPCRel(CPAddr, DAG);
753 Ops.push_back(Chain);
754 Ops.push_back(Callee);
758 const uint32_t *Mask =
TRI->getCallPreservedMask(MF, CallConv);
759 assert(Mask &&
"Missing call preserved mask for calling convention");
764 for (
unsigned I = 0, E = RegsToPass.size();
I != E; ++
I) {
765 unsigned Reg = RegsToPass[
I].first;
766 if (Subtarget.isWindowedABI())
768 Ops.push_back(DAG.
getRegister(Reg, RegsToPass[
I].second.getValueType()));
776 Chain = DAG.
getNode(Subtarget.isWindowedABI() ? XtensaISD::CALLW8
793 for (
unsigned I = 0, E = RetLocs.
size();
I != E; ++
I) {
810 const Type *RetTy)
const {
812 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
832 return DAG.
getNode(Subtarget.isWindowedABI() ? XtensaISD::RETW
834 DL, MVT::Other, Chain);
839 for (
unsigned I = 0, E = RetLocs.
size();
I != E; ++
I) {
858 return DAG.
getNode(Subtarget.isWindowedABI() ? XtensaISD::RETW
860 DL, MVT::Other, RetOps);
893 return std::make_pair(Xtensa::BF, Xtensa::OEQ_S);
895 return std::make_pair(Xtensa::BT, Xtensa::UN_S);
897 return std::make_pair(Xtensa::BF, Xtensa::UN_S);
899 return std::make_pair(Xtensa::BT, Xtensa::UEQ_S);
901 return std::make_pair(Xtensa::BT, Xtensa::ULE_S);
903 return std::make_pair(Xtensa::BT, Xtensa::ULT_S);
906 return std::make_pair(Xtensa::BT, Xtensa::OEQ_S);
908 return std::make_pair(Xtensa::BF, Xtensa::OEQ_S);
911 return std::make_pair(Xtensa::BT, Xtensa::OLE_S);
914 return std::make_pair(Xtensa::BT, Xtensa::OLT_S);
916 return std::make_pair(Xtensa::BF, Xtensa::OLT_S);
918 return std::make_pair(Xtensa::BF, Xtensa::OLE_S);
920 return std::make_pair(Xtensa::BF, Xtensa::ULE_S);
922 return std::make_pair(Xtensa::BF, Xtensa::ULT_S);
924 return std::make_pair(Xtensa::BF, Xtensa::UEQ_S);
926 return std::make_pair(Xtensa::BF, Xtensa::OLE_S);
928 return std::make_pair(Xtensa::BF, Xtensa::OLT_S);
937 EVT Ty =
Op.getValueType();
938 SDValue
LHS =
Op.getOperand(0);
939 SDValue
RHS =
Op.getOperand(1);
940 SDValue TrueValue =
Op.getOperand(2);
941 SDValue FalseValue =
Op.getOperand(3);
944 if (
LHS.getValueType() == MVT::i32) {
948 SDValue Res = DAG.
getNode(XtensaISD::SELECT_CC,
DL, Ty,
LHS,
RHS, TrueValue,
949 FalseValue, TargetCC,
Op->getFlags());
953 "We expect MVT::f32 type of the LHS Operand in SELECT_CC");
959 return DAG.
getNode(XtensaISD::SELECT_CC_FP,
DL, Ty,
960 {
LHS,
RHS, TrueValue, FalseValue, TargetCC, TargetBC},
971 if (
Op.getConstantOperandVal(0) != 0)
976 EVT VT =
Op.getValueType();
991 if (
Op.getValueType() == MVT::i32) {
996 SDNode &OpNode = *
Op.getNode();
1014 auto PtrVT =
Op.getValueType();
1015 const GlobalValue *GV =
G->getGlobal();
1018 SDValue CPWrap = getAddrPCRel(CPAddr, DAG);
1029 EVT PtrVT =
Op.getValueType();
1030 const GlobalValue *GV =
G->getGlobal();
1037 if (!Subtarget.hasTHREADPTR()) {
1047 XtensaMachineFunctionInfo *XtensaFI =
1048 MF.
getInfo<XtensaMachineFunctionInfo>();
1058 SDValue CPWrap = getAddrPCRel(CPAddr, DAG);
1063 SDValue TPRegister = DAG.
getRegister(Xtensa::THREADPTR, MVT::i32);
1064 SDValue ThreadPointer =
1065 DAG.
getNode(XtensaISD::RUR,
DL, MVT::i32, TPRegister);
1072 "only local-exec and initial-exec TLS mode supported",
DL.getDebugLoc()));
1082 EVT PtrVT =
Op.getValueType();
1084 XtensaMachineFunctionInfo *XtensaFI = MF.
getInfo<XtensaMachineFunctionInfo>();
1087 XtensaConstantPoolValue *CPV =
1090 SDValue CPWrap = getAddrPCRel(CPAddr, DAG);
1098 SDValue Chain =
Op.getOperand(0);
1099 SDValue
Table =
Op.getOperand(1);
1100 SDValue
Index =
Op.getOperand(2);
1107 EVT PtrVT =
Table.getValueType();
1121 return DAG.
getNode(XtensaISD::BR_JT,
DL, MVT::Other,
LD.getValue(1), LD,
1128 EVT PtrVT =
Op.getValueType();
1132 XtensaConstantPoolValue *CPV =
1147 EVT Ty =
Op.getValueType();
1148 return DAG.
getNode(XtensaISD::PCREL_WRAPPER,
DL, Ty,
Op);
1153 EVT PtrVT =
Op.getValueType();
1164 return getAddrPCRel(Result, DAG);
1175 SDValue Chain =
Op.getOperand(0);
1176 SDValue NewSP =
Op.getOperand(1);
1178 if (Subtarget.isWindowedABI()) {
1179 return DAG.
getNode(XtensaISD::MOVSP, SDLoc(
Op), MVT::Other, Chain, NewSP);
1192 if (
Op.getConstantOperandVal(0) != 0)
1198 EVT VT =
Op.getValueType();
1201 MCRegister FrameRegister = Subtarget.getRegisterInfo()->getFrameRegister(MF);
1209 SDValue Chain =
Op.getOperand(0);
1210 SDValue
Size =
Op.getOperand(1);
1211 EVT VT =
Size->getValueType(0);
1220 MCRegister
SPReg = Xtensa::SP;
1223 if (Subtarget.isWindowedABI()) {
1224 Chain = DAG.
getNode(XtensaISD::MOVSP, SDLoc(
Op), MVT::Other,
SP.getValue(1),
1233 SDValue
Ops[2] = {NewVal, Chain};
1240 XtensaMachineFunctionInfo *XtensaFI = MF.
getInfo<XtensaMachineFunctionInfo>();
1241 SDValue Chain =
Op.getOperand(0);
1242 SDValue Addr =
Op.getOperand(1);
1253 SDValue StackOffsetFI =
1276 SDValue StoreStackPtr =
1277 DAG.
getStore(Chain,
DL, StackPtr, Addr, MachinePointerInfo(SV));
1284 SDValue StoreRegPtr = DAG.
getStore(StoreStackPtr,
DL, FrameIndex, NextPtr,
1285 MachinePointerInfo(SV, NextOffset));
1286 NextOffset += FrameOffset;
1290 return DAG.
getStore(StoreRegPtr,
DL, VAIndex, NextPtr,
1291 MachinePointerInfo(SV, NextOffset));
1296 constexpr unsigned VAListSize = 3 * 4;
1297 SDValue Chain =
Op.getOperand(0);
1298 SDValue DstPtr =
Op.getOperand(1);
1299 SDValue SrcPtr =
Op.getOperand(2);
1308 nullptr, std::nullopt, MachinePointerInfo(DstSV),
1309 MachinePointerInfo(SrcSV));
1313 SDNode *
Node =
Op.getNode();
1314 EVT VT =
Node->getValueType(0);
1316 EVT PtrVT =
Op.getValueType();
1317 SDValue InChain =
Node->getOperand(0);
1318 SDValue VAListPtr =
Node->getOperand(1);
1323 unsigned ArgAlignInBytes = ArgAlignment.
value();
1329 DAG.
getLoad(MVT::i32,
DL, InChain, VAListPtr, MachinePointerInfo());
1336 DAG.
getLoad(MVT::i32,
DL, InChain, VARegPtr, MachinePointerInfo());
1340 SDValue VarArgIndexPtr =
1343 DAG.
getLoad(MVT::i32,
DL, InChain, VarArgIndexPtr, MachinePointerInfo());
1346 SDValue OrigIndex = VAIndex;
1348 if (ArgAlignInBytes > 4) {
1359 SDValue CC = DAG.
getSetCC(
DL, MVT::i32, OrigIndex,
1376 SDValue VAIndexStore = DAG.
getStore(InChain,
DL, VAIndex, VarArgIndexPtr,
1377 MachinePointerInfo(SV));
1378 InChain = VAIndexStore;
1385 return DAG.
getLoad(VT,
DL, InChain, Addr, MachinePointerInfo());
1392 SDValue
Lo =
Op.getOperand(0),
Hi =
Op.getOperand(1);
1393 SDValue Shamt =
Op.getOperand(2);
1403 SDValue ShamtMinusRegisterSize =
1407 SDValue HiTrue = DAG.
getNode(XtensaISD::SRCL,
DL, VT,
Hi,
Lo, Shamt);
1422 SDValue
Lo =
Op.getOperand(0),
Hi =
Op.getOperand(1);
1423 SDValue Shamt =
Op.getOperand(2);
1444 SDValue RegisterSizeMinus1 = DAG.
getConstant(32 - 1,
DL, VT);
1445 SDValue ShamtMinusRegisterSize =
1448 SDValue LoTrue = DAG.
getNode(XtensaISD::SRCR,
DL, VT,
Hi,
Lo, Shamt);
1449 SDValue HiTrue = DAG.
getNode(ShiftRightOp,
DL, VT,
Hi, Shamt);
1452 DAG.
getNode(ShiftRightOp,
DL, VT,
Hi, ShamtMinusRegisterSize);
1456 HiFalse = DAG.
getNode(ShiftRightOp,
DL, VT,
Hi, RegisterSizeMinus1);
1476 unsigned EltSizeInBits;
1483 Imm = ConstNode->getAPIntValue();
1491 if (EltSizeInBits > 32)
1495 if (
Imm.isPowerOf2() &&
Imm.isIntN(5))
1503 switch (
Op.getOpcode()) {
1505 return LowerBR_JT(
Op, DAG);
1507 return LowerImmediate(
Op, DAG);
1509 return LowerRETURNADDR(
Op, DAG);
1511 return LowerGlobalAddress(
Op, DAG);
1513 return LowerGlobalTLSAddress(
Op, DAG);
1515 return LowerBlockAddress(
Op, DAG);
1517 return LowerJumpTable(
Op, DAG);
1519 return LowerCTPOP(
Op, DAG);
1521 return LowerConstantPool(
Op, DAG);
1523 return LowerSELECT_CC(
Op, DAG);
1525 return LowerSTACKSAVE(
Op, DAG);
1527 return LowerSTACKRESTORE(
Op, DAG);
1529 return LowerFRAMEADDR(
Op, DAG);
1531 return LowerDYNAMIC_STACKALLOC(
Op, DAG);
1533 return LowerVASTART(
Op, DAG);
1535 return LowerVAARG(
Op, DAG);
1537 return LowerVACOPY(
Op, DAG);
1539 return LowerShiftLeftParts(
Op, DAG);
1541 return LowerShiftRightParts(
Op, DAG,
true);
1543 return LowerShiftRightParts(
Op, DAG,
false);
1588 F->insert(It, CopyMBB);
1589 F->insert(It, SinkMBB);
1596 MBB->addSuccessor(CopyMBB);
1597 MBB->addSuccessor(SinkMBB);
1599 if (
MI.getOpcode() == Xtensa::SELECT_CC_FP_FP ||
1600 MI.getOpcode() == Xtensa::SELECT_CC_FP_INT) {
1601 unsigned CmpKind =
MI.getOperand(5).getImm();
1602 unsigned BrKind =
MI.getOperand(6).getImm();
1612 unsigned BrKind =
MI.getOperand(5).getImm();
1626 MI.getOperand(0).getReg())
1632 MI.eraseFromParent();
1641 switch (
MI.getOpcode()) {
1642 case Xtensa::BRCC_FP: {
1647 unsigned BrKind = 0;
1648 unsigned CmpKind = 0;
1660 MI.eraseFromParent();
1663 case Xtensa::SELECT_CC_FP_FP:
1664 case Xtensa::SELECT_CC_FP_INT:
1665 case Xtensa::SELECT_CC_INT_FP:
1666 case Xtensa::SELECT:
1667 return emitSelectCC(
MI,
MBB);
1671 case Xtensa::S32I_N:
1680 case Xtensa::L32I_N:
1684 case Xtensa::LSXP: {
1688 if (
MI.memoperands_empty() || (*
MI.memoperands_begin())->isVolatile()) {
1693 case Xtensa::MOVSP_P: {
1698 MI.eraseFromParent();
1702 case Xtensa::ATOMIC_CMP_SWAP_32_P: {
1716 MI.eraseFromParent();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static constexpr MCPhysReg SPReg
const SmallVectorImpl< MachineOperand > & Cond
SI optimize exec mask operations pre RA
static const MCPhysReg IntRegs[32]
static unsigned toCallerWindow(unsigned Reg)
static bool isLongCall(const char *str)
static unsigned toCallerWindow(unsigned Reg)
static std::pair< unsigned, unsigned > getFPBranchKind(ISD::CondCode Cond)
static unsigned getBranchOpcode(ISD::CondCode Cond)
static bool CC_Xtensa_Custom(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
Class for arbitrary precision integers.
int64_t getSExtValue() const
Get sign extended value.
an instruction that atomically reads a memory location, combines it with another value,...
LLVM Basic Block Representation.
CCState - This class holds information needed while lowering arguments and return values.
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set,...
LLVM_ABI void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
LLVM_ABI bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
LLVM_ABI void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
LLVM_ABI void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
uint64_t getStackSize() const
Returns the size of the currently allocated portion of the stack.
LLVM_ABI void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
CCValAssign - Represent assignment of one arg/retval to a location.
Register getLocReg() const
LocInfo getLocInfo() const
static CCValAssign getReg(unsigned ValNo, MVT ValVT, MCRegister Reg, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP, bool IsCustom=false)
int64_t getLocMemOffset() const
unsigned getValNo() const
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
bool isMachineConstantPoolEntry() const
const Constant * getConstVal() const
const APInt & getAPIntValue() const
This is an important base class in LLVM.
LLVM_ABI Align getABITypeAlign(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
LLVM_ABI TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
LinkageTypes getLinkage() const
static bool isPrivateLinkage(LinkageTypes Linkage)
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Wrapper class representing physical registers. Should be passed by value.
static auto integer_valuetypes()
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
static auto fp_valuetypes()
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
LLVM_ABI int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
void setFrameAddressIsTaken(bool T)
void setReturnAddressIsTaken(bool s)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
LLVM_ABI unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
MachineOperand class - Representation of each machine instruction operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool hasOneUse() const
Return true if there is exactly one use of this node.
user_iterator user_begin() const
Provide iteration support to walk over all users of an SDNode.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offs=0, bool isT=false, unsigned TargetFlags=0)
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false, SDNodeFlags Flags={})
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
LLVM_ABI SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align DstAlign, Align SrcAlign, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=nullptr)
const TargetLowering & getTargetLoweringInfo() const
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd).
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
const DataLayout & getDataLayout() const
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
const TargetMachine & getTarget() const
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
MachineFunction & getMachineFunction() const
SDValue getPOISON(EVT VT)
Return a POISON node. POISON does not have a useful SDLoc.
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI SDValue getRegisterMask(const uint32_t *RegMask)
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
SDValue getTargetConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
constexpr size_t size() const
Get the string size.
Information about stack frame layout on the target.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
const TargetMachine & getTargetMachine() const
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
FPImmAction
How the legalizer should materialize a floating-point immediate.
@ ConstantPool
Load the immediate from the constant pool.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
@ ZeroOrOneBooleanContent
void setMinCmpXchgSizeInBits(unsigned SizeInBits)
Sets the minimum cmpxchg or ll/sc size supported by the backend.
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
void setCondCodeAction(ArrayRef< ISD::CondCode > CCs, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, SelectionDAG &DAG) const
Lower TLS global address SDNode for target independent emulated TLS model.
SDValue expandCTPOP(SDNode *N, SelectionDAG &DAG) const
Expand CTPOP nodes.
bool isPositionIndependent() const
virtual ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const
Examine constraint string and operand type and determine a weight value.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
TargetLowering(const TargetLowering &)=delete
virtual void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
Primary interface to the complete machine description for the target machine.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
static XtensaConstantPoolConstant * Create(const Constant *C, unsigned ID, XtensaCP::XtensaCPKind Kind)
static XtensaConstantPoolJumpTable * Create(LLVMContext &C, unsigned Idx)
static XtensaConstantPoolSymbol * Create(LLVMContext &C, const char *S, unsigned ID, bool PrivLinkage, XtensaCP::XtensaCPModifier Modifier=XtensaCP::no_modifier)
XtensaConstantPoolValue - Xtensa specific constantpool value.
unsigned createCPLabelId()
int getVarArgsInRegsFrameIndex() const
void setVarArgsFirstGPR(unsigned GPR)
void setSaveFrameRegister()
int getVarArgsOnStackFrameIndex() const
unsigned getVarArgsFirstGPR() const
void setVarArgsInRegsFrameIndex(int FI)
void setVarArgsOnStackFrameIndex(int FI)
const XtensaInstrInfo * getInstrInfo() const override
const XtensaRegisterInfo * getRegisterInfo() const override
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...
TargetLowering::ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &Info, const char *Constraint) const override
Examine constraint string and operand type and determine a weight value.
AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
Register getExceptionSelectorRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
FPImmAction getFPImmAction(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns how the legalizer should materialize the specified FP immediate.
TargetLowering::ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
bool decomposeMulByConstant(LLVMContext &Context, EVT VT, SDValue C) const override
Return true if it is profitable to transform an integer multiplication-by-constant into simpler opera...
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
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,...
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
XtensaTargetLowering(const TargetMachine &TM, const XtensaSubtarget &STI)
Register getExceptionPointerRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
Lower the specified operand into the Ops vector.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
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,...
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Return the register type for a given MVT.
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...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ STACKRESTORE
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain.
@ STACKSAVE
STACKSAVE - STACKSAVE has one operand, an input chain.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ BSWAP
Byte Swap and Counting operators.
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
@ ADD
Simple integer binary arithmetic operators.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ FADD
Simple binary floating point operators.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BR_CC
BR_CC - Conditional branch.
@ BR_JT
BR_JT - Jumptable branch.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ VACOPY
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer,...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ DEBUGTRAP
DEBUGTRAP - Trap intended to get the attention of a debugger.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
LLVM_ABI bool isConstantSplatVector(const SDNode *N, APInt &SplatValue)
Node predicates.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Kill
The last use of a register.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
@ Store
The extracted value is stored (ExtractElement only).
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
constexpr bool isShiftedInt(int64_t x)
Checks if a signed integer is an N bit number shifted left by S.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
MCRegisterClass TargetRegisterClass
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
uint64_t getScalarSizeInBits() const
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
Align getNonZeroOrigAlign() const
unsigned getByValSize() const
Align getNonZeroByValAlign() const
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getJumpTable(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a jump table entry.
static LLVM_ABI MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
This contains information for each constraint that we are lowering.
This structure contains all information that is necessary for lowering calls.
SmallVector< ISD::InputArg, 32 > Ins
SmallVector< ISD::OutputArg, 32 > Outs
SmallVector< SDValue, 32 > OutVals