32#include "llvm/IR/IntrinsicsXCore.h"
41#define DEBUG_TYPE "xcore-lower"
166 switch (
Op.getOpcode())
181 case ISD::SUB:
return ExpandADDSUB(
Op.getNode(), DAG);
189 return LowerATOMIC_FENCE(
Op, DAG);
200 switch (
N->getOpcode()) {
205 Results.push_back(ExpandADDSUB(
N, DAG));
221 return DAG.
getNode(XCoreISD::PCRelativeWrapper, dl, MVT::i32, GA);
226 return DAG.
getNode(XCoreISD::CPRelativeWrapper, dl, MVT::i32, GA);
228 return DAG.
getNode(XCoreISD::DPRelativeWrapper, dl, MVT::i32, GA);
240 unsigned ObjSize =
DL.getTypeAllocSize(ObjType);
253 int64_t FoldedOffset = std::max(
Offset & ~3, (int64_t)0);
255 GA = getGlobalAddressWrapper(GA, GV, DAG);
257 if (
Offset != FoldedOffset) {
282 return DAG.
getNode(XCoreISD::PCRelativeWrapper,
DL, PtrVT, Result);
291 EVT PtrVT =
Op.getValueType();
300 return DAG.
getNode(XCoreISD::CPRelativeWrapper, dl, MVT::i32, Res);
320 unsigned NumEntries = MJTI->
getJumpTables()[JTI].MBBs.size();
321 if (NumEntries <= 32) {
322 return DAG.
getNode(XCoreISD::BR_JT, dl, MVT::Other, Chain, TargetJT, Index);
324 assert((NumEntries >> 31) == 0);
327 return DAG.
getNode(XCoreISD::BR_JT32, dl, MVT::Other, Chain, TargetJT,
331SDValue XCoreTargetLowering::lowerLoadWordFromAlignedBasePlusOffset(
335 if ((
Offset & 0x3) == 0) {
336 return DAG.
getLoad(PtrVT,
DL, Chain,
Base, MachinePointerInfo());
340 int32_t LowOffset = HighOffset - 4;
342 if (GlobalAddressSDNode *GASD =
371 return Known.countMinTrailingZeros() >= 2;
379 "Unexpected extension type");
380 assert(
LD->getMemoryVT() == MVT::i32 &&
"Unexpected load EVT");
383 LD->getMemoryVT(), *
LD->getMemOperand()))
390 if (!
LD->isVolatile()) {
391 const GlobalValue *GV;
397 return lowerLoadWordFromAlignedBasePlusOffset(
DL, Chain, NewBasePtr,
404 return lowerLoadWordFromAlignedBasePlusOffset(
DL, Chain, NewBasePtr,
409 if (
LD->getAlign() ==
Align(2)) {
411 LD->getPointerInfo(), MVT::i16,
Align(2),
412 LD->getMemOperand()->getFlags());
417 LD->getPointerInfo().getWithOffset(2), MVT::i16,
418 Align(2),
LD->getMemOperand()->getFlags());
433 TargetLowering::CallLoweringInfo CLI(DAG);
434 CLI.setDebugLoc(
DL).setChain(Chain).setLibCallee(
440 std::pair<SDValue, SDValue> CallResult =
LowerCallTo(CLI);
441 SDValue Ops[] = { CallResult.first, CallResult.second };
448 assert(!
ST->isTruncatingStore() &&
"Unexpected store type");
449 assert(
ST->getMemoryVT() == MVT::i32 &&
"Unexpected store EVT");
452 ST->getMemoryVT(), *
ST->getMemOperand()))
460 if (
ST->getAlign() ==
Align(2)) {
466 MVT::i16,
Align(2),
ST->getMemOperand()->getFlags());
470 Chain, dl,
High, HighAddr,
ST->getPointerInfo().getWithOffset(2),
471 MVT::i16,
Align(2),
ST->getMemOperand()->getFlags());
481 TargetLowering::CallLoweringInfo CLI(DAG);
482 CLI.setDebugLoc(dl).setChain(Chain).setCallee(
488 std::pair<SDValue, SDValue> CallResult =
LowerCallTo(CLI);
489 return CallResult.second;
496 "Unexpected operand to lower!");
502 DAG.
getVTList(MVT::i32, MVT::i32), Zero, Zero,
513 "Unexpected operand to lower!");
533 SDValue &Addend1,
bool requireIntermediatesHaveOneUse)
550 if (requireIntermediatesHaveOneUse && !AddOp.hasOneUse())
554 if (requireIntermediatesHaveOneUse && !OtherOp.
hasOneUse())
562 if (AddOp.getOperand(0).getOpcode() ==
ISD::MUL) {
564 if (requireIntermediatesHaveOneUse && !AddOp.getOperand(0).hasOneUse())
572 if (AddOp.getOperand(1).getOpcode() ==
ISD::MUL) {
574 if (requireIntermediatesHaveOneUse && !AddOp.getOperand(1).hasOneUse())
590 if (
N->getOperand(0).getOpcode() ==
ISD::MUL) {
591 Mul =
N->getOperand(0);
593 }
else if (
N->getOperand(1).getOpcode() ==
ISD::MUL) {
594 Mul =
N->getOperand(1);
600 SDValue LL, RL, AddendL, AddendH;
616 DAG.
getVTList(MVT::i32, MVT::i32), AddendH,
621 if (LHSSB > 32 && RHSSB > 32) {
624 DAG.
getVTList(MVT::i32, MVT::i32), AddendH,
635 DAG.
getVTList(MVT::i32, MVT::i32), AddendH,
648 assert(
N->getValueType(0) == MVT::i64 &&
650 "Unknown operand to lower!");
653 if (
SDValue Result = TryExpandADDWithMul(
N, DAG))
673 unsigned Opcode = (
N->getOpcode() ==
ISD::ADD) ? XCoreISD::LADD :
692 SDNode *
Node =
Op.getNode();
693 EVT VT =
Node->getValueType(0);
700 DAG.
getLoad(PtrVT, dl, InChain, VAListPtr, MachinePointerInfo(SV));
707 MachinePointerInfo(SV));
709 return DAG.
getLoad(VT, dl, InChain, VAList, MachinePointerInfo());
719 XCoreFunctionInfo *XFI = MF.
getInfo<XCoreFunctionInfo>();
721 return DAG.
getStore(
Op.getOperand(0), dl, Addr,
Op.getOperand(1),
722 MachinePointerInfo());
732 if (
Op.getConstantOperandVal(0) > 0)
736 const TargetRegisterInfo *RegInfo = Subtarget.getRegisterInfo();
748 if (
Op.getConstantOperandVal(0) > 0)
752 XCoreFunctionInfo *XFI = MF.
getInfo<XCoreFunctionInfo>();
766 return DAG.
getNode(XCoreISD::FRAME_TO_ARGS_OFFSET, SDLoc(
Op), MVT::i32);
782 const TargetRegisterInfo *RegInfo = Subtarget.getRegisterInfo();
785 SDValue FrameToArgs = DAG.
getNode(XCoreISD::FRAME_TO_ARGS_OFFSET, dl,
792 unsigned StackReg = XCore::R2;
793 unsigned HandlerReg = XCore::R3;
802 return DAG.
getNode(XCoreISD::EH_RETURN, dl, MVT::Other, Chain,
810 return Op.getOperand(0);
840 MachinePointerInfo(TrmpAddr));
846 MachinePointerInfo(TrmpAddr, 4));
852 MachinePointerInfo(TrmpAddr, 8));
857 DAG.
getStore(Chain, dl, Nest, Addr, MachinePointerInfo(TrmpAddr, 12));
862 DAG.
getStore(Chain, dl, FPtr, Addr, MachinePointerInfo(TrmpAddr, 16));
870 unsigned IntNo =
Op.getConstantOperandVal(0);
872 case Intrinsic::xcore_crc8:
873 EVT VT =
Op.getValueType();
876 Op.getOperand(1),
Op.getOperand(2) ,
Op.getOperand(3));
894#define GET_CALLING_CONV_IMPL
895#include "XCoreGenCallingConv.inc"
926 return LowerCCCCallTo(Chain, Callee, CallConv, isVarArg, isTailCall,
927 Outs, OutVals, Ins, dl, DAG, InVals);
941 Chain = DAG.
getCopyFromReg(Chain, dl, VA.getLocReg(), VA.getValVT(),
947 ResultMemLocs.
push_back(std::make_pair(VA.getLocMemOffset(),
956 for (
unsigned i = 0, e = ResultMemLocs.
size(); i != e; ++i) {
957 int offset = ResultMemLocs[i].first;
958 unsigned index = ResultMemLocs[i].second;
962 InVals[index] =
load;
968 if (!MemOpChains.
empty())
978SDValue XCoreTargetLowering::LowerCCCCallTo(
992 CCInfo.AllocateStack(4,
Align(4));
994 CCInfo.AnalyzeCallOperands(Outs, CC_XCore);
1000 RetCCInfo.AllocateStack(CCInfo.getStackSize(),
Align(4));
1001 RetCCInfo.AnalyzeCallResult(Ins, RetCC_XCore);
1004 unsigned NumBytes = RetCCInfo.getStackSize();
1012 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
1013 CCValAssign &VA = ArgLocs[i];
1049 if (!MemOpChains.
empty())
1057 for (
const auto &[
Reg,
N] : RegsToPass) {
1074 SDVTList NodeTys = DAG.
getVTList(MVT::Other, MVT::Glue);
1076 Ops.push_back(Chain);
1077 Ops.push_back(Callee);
1081 for (
const auto &[
Reg,
N] : RegsToPass)
1085 Ops.push_back(InGlue);
1087 Chain = DAG.
getNode(XCoreISD::BL, dl, NodeTys,
Ops);
1104 struct ArgDataPair {
SDValue SDV; ISD::ArgFlagsTy
Flags; };
1108SDValue XCoreTargetLowering::LowerFormalArguments(
1118 return LowerCCCArguments(Chain, CallConv, isVarArg,
1119 Ins, dl, DAG, InVals);
1127SDValue XCoreTargetLowering::LowerCCCArguments(
1133 MachineRegisterInfo &RegInfo = MF.
getRegInfo();
1134 XCoreFunctionInfo *XFI = MF.
getInfo<XCoreFunctionInfo>();
1141 CCInfo.AnalyzeFormalArguments(Ins, CC_XCore);
1145 unsigned LRSaveSize = StackSlotSize;
1162 for (
unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
1164 CCValAssign &VA = ArgLocs[i];
1174 errs() <<
"LowerFormalArguments Unhandled argument type: "
1190 if (ObjSize > StackSlotSize) {
1191 errs() <<
"LowerFormalArguments Unhandled argument type: "
1205 const ArgDataPair ADP = { ArgIn, Ins[i].Flags };
1213 XCore::R0, XCore::R1, XCore::R2, XCore::R3
1215 XCoreFunctionInfo *XFI = MF.
getInfo<XCoreFunctionInfo>();
1216 unsigned FirstVAReg = CCInfo.getFirstUnallocated(ArgRegs);
1217 if (FirstVAReg < std::size(ArgRegs)) {
1221 for (
int i = std::size(ArgRegs) - 1; i >= (int)FirstVAReg; --i) {
1224 if (i == (
int)FirstVAReg) {
1227 offset -= StackSlotSize;
1247 if (!CFRegNode.
empty())
1254 for (
const ArgDataPair &ArgDI : ArgData) {
1255 if (ArgDI.Flags.isByVal() && ArgDI.Flags.getByValSize()) {
1256 unsigned Size = ArgDI.Flags.getByValSize();
1258 std::max(
Align(StackSlotSize), ArgDI.Flags.getNonZeroByValAlign());
1265 Alignment, Alignment,
false,
false,
nullptr, std::nullopt,
1266 MachinePointerInfo(), MachinePointerInfo()));
1273 if (!MemOps.
empty()) {
1285bool XCoreTargetLowering::
1291 CCState CCInfo(CallConv, isVarArg, MF, RVLocs,
Context);
1292 if (!CCInfo.CheckReturn(Outs, RetCC_XCore))
1294 if (CCInfo.getStackSize() != 0 && isVarArg)
1306 XCoreFunctionInfo *XFI =
1322 CCInfo.AnalyzeReturn(Outs, RetCC_XCore);
1328 RetOps.push_back(DAG.
getConstant(0, dl, MVT::i32));
1332 for (
unsigned i = 0, e = RVLocs.
size(); i != e; ++i) {
1333 CCValAssign &VA = RVLocs[i];
1344 int FI = MFI.CreateFixedObject(ObjSize,
Offset,
false);
1350 Chain, dl, OutVals[i], FIN,
1356 if (!MemOpChains.
empty())
1360 for (
unsigned i = 0, e = RVLocs.
size(); i != e; ++i) {
1361 CCValAssign &VA = RVLocs[i];
1377 RetOps.push_back(Glue);
1379 return DAG.
getNode(XCoreISD::RETSP, dl, MVT::Other, RetOps);
1391 assert((
MI.getOpcode() == XCore::SELECT_CC) &&
1392 "Unexpected instr type to insert");
1411 F->insert(It, copy0MBB);
1412 F->insert(It, sinkMBB);
1445 MI.eraseFromParent();
1454 DAGCombinerInfo &DCI)
const {
1457 switch (
N->getOpcode()) {
1460 switch (
N->getConstantOperandVal(1)) {
1461 case Intrinsic::xcore_outt:
1462 case Intrinsic::xcore_outct:
1463 case Intrinsic::xcore_chkct: {
1471 !DCI.isBeforeLegalizeOps());
1475 DCI.CommitTargetLoweringOpt(TLO);
1479 case Intrinsic::xcore_setpt: {
1486 TargetLowering::TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
1487 !DCI.isBeforeLegalizeOps());
1491 DCI.CommitTargetLoweringOpt(TLO);
1497 case XCoreISD::LADD: {
1520 if (N1C && N1C->
isZero() &&
N->hasNUsesOfValue(0, 1)) {
1524 if ((
Known.Zero & Mask) == Mask) {
1533 case XCoreISD::LSUB: {
1546 if ((
Known.Zero & Mask) == Mask) {
1557 if (N1C && N1C->
isZero() &&
N->hasNUsesOfValue(0, 1)) {
1561 if ((
Known.Zero & Mask) == Mask) {
1570 case XCoreISD::LMUL: {
1580 if ((N0C && !N1C) ||
1586 if (N1C && N1C->
isZero()) {
1588 if (
N->hasNUsesOfValue(0, 0)) {
1607 SDValue Mul0, Mul1, Addend0, Addend1;
1608 if (
N->getValueType(0) == MVT::i32 &&
1611 DAG.
getVTList(MVT::i32, MVT::i32), Mul0,
1612 Mul1, Addend0, Addend1);
1621 if (
N->getValueType(0) == MVT::i64 &&
1636 DAG.
getVTList(MVT::i32, MVT::i32), Mul0L, Mul1L,
1637 Addend0L, Addend1L);
1646 if (!DCI.isBeforeLegalize() ||
1649 *
ST->getMemOperand()) ||
1650 ST->isVolatile() ||
ST->isIndexed()) {
1655 unsigned StoreBits =
ST->getMemoryVT().getStoreSizeInBits();
1656 assert((StoreBits % 8) == 0 &&
1657 "Store size in bits must be a multiple of 8");
1661 if (
LD->hasNUsesOfValue(1, 0) &&
ST->getMemoryVT() ==
LD->getMemoryVT() &&
1662 LD->getAlign() == Alignment &&
1663 !
LD->isVolatile() && !
LD->isIndexed() &&
1666 return DAG.
getMemmove(Chain, dl,
ST->getBasePtr(),
LD->getBasePtr(),
1668 Alignment, Alignment,
false,
nullptr, isTail,
1669 ST->getPointerInfo(),
LD->getPointerInfo());
1678void XCoreTargetLowering::computeKnownBitsForTargetNode(
const SDValue Op,
1680 const APInt &DemandedElts,
1682 unsigned Depth)
const {
1684 switch (
Op.getOpcode()) {
1686 case XCoreISD::LADD:
1687 case XCoreISD::LSUB:
1688 if (
Op.getResNo() == 1) {
1691 Known.getBitWidth() - 1);
1696 unsigned IntNo =
Op.getConstantOperandVal(1);
1698 case Intrinsic::xcore_getts:
1703 case Intrinsic::xcore_int:
1704 case Intrinsic::xcore_inct:
1709 case Intrinsic::xcore_testct:
1714 case Intrinsic::xcore_testwct:
1731 return (val >= 0 && val <= 11);
1736 return (val%2 == 0 &&
isImmUs(val/2));
1741 return (val%4 == 0 &&
isImmUs(val/4));
1753 unsigned Size =
DL.getTypeAllocSize(Ty);
1762 if (AM.
Scale == 0) {
1770 if (AM.
Scale == 0) {
1777 if (AM.
Scale == 0) {
1789std::pair<unsigned, const TargetRegisterClass *>
1793 if (Constraint.
size() == 1) {
1794 switch (Constraint[0]) {
1797 return std::make_pair(0U, &XCore::GRRegsRegClass);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static SDValue LowerCallResult(SDValue Chain, SDValue InGlue, const SmallVectorImpl< CCValAssign > &RVLocs, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals)
LowerCallResult - Lower the result values of a call into the appropriate copies out of appropriate ph...
static bool isImmUs(int64_t val)
static bool isImmUs4(int64_t val)
static bool IsSmallObject(const GlobalValue *GV, const XCoreTargetLowering &XTL)
static bool isWordAligned(SDValue Value, SelectionDAG &DAG)
static bool isADDADDMUL(SDValue Op, SDValue &Mul0, SDValue &Mul1, SDValue &Addend0, SDValue &Addend1, bool requireIntermediatesHaveOneUse)
isADDADDMUL - Return whether Op is in a form that is equivalent to add(add(mul(x,y),...
static bool isImmUs2(int64_t val)
Class for arbitrary precision integers.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
LLVM Basic Block Representation.
CCValAssign - Represent assignment of one arg/retval to a location.
Register getLocReg() const
LocInfo getLocInfo() const
int64_t getLocMemOffset() const
static Constant * getPtrAdd(Constant *Ptr, Constant *Offset, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReduced=nullptr)
Create a getelementptr i8, ptr, offset constant expression.
MachineConstantPoolValue * getMachineCPVal() const
bool isMachineConstantPoolEntry() const
const Constant * getConstVal() const
uint64_t getZExtValue() const
A parsed version of the target data layout string in and methods for querying it.
LLVM_ABI IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space.
int64_t getOffset() const
const GlobalValue * getGlobal() const
bool hasLocalLinkage() const
LLVM_ABI StringRef getSection() const
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
Type * getValueType() const
This is an important class for using LLVM in a threaded context.
static auto integer_valuetypes()
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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
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.
LLVM_ABI int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
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 & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
@ EK_Inline
EK_Inline - Jump table entries are emitted inline at their point of use.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
const SDValue & getOperand(unsigned Num) const
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
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node, in exactly one operand.
LLVM_ABI bool reachesChainWithoutSideEffects(SDValue Dest, unsigned Depth=2) const
Return true if this operand (which must be a chain) reaches the specified operand without crossing an...
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
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)
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).
LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
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 getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned TargetFlags=0)
LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
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,...
LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT)
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
LLVM_ABI SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align DstAlign, Align SrcAlign, bool isVol, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=nullptr)
LLVM_ABI bool isBaseWithConstantOffset(SDValue Op) const
Return true if the specified operand is an ISD::ADD with a ConstantSDNode on the right-hand side,...
MachineFunction & getMachineFunction() const
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
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.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr size_t size() const
Get the string size.
TargetInstrInfo - Interface to description of machine instruction set.
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
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...
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
const TargetMachine & getTargetMachine() const
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.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
unsigned MaxStoresPerMemmove
Specify maximum number of store instructions per memmove call.
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass 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...
void setPrefFunctionAlignment(Align Alignment)
Set the target's preferred function alignment.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
@ ZeroOrOneBooleanContent
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
void setTargetDAGCombine(ArrayRef< ISD::NodeType > NTs)
Targets should invoke this method for each target independent node that they want to provide a custom...
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...
std::vector< ArgListEntry > ArgListTy
bool allowsMemoryAccessForAlignment(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
This function returns true if the memory access is aligned or if the target allows this specific unal...
unsigned MaxStoresPerMemcpy
Specify maximum number of store instructions per memcpy call.
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool ShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, TargetLoweringOpt &TLO) const
Check to see if the specified operand of the specified instruction is a constant integer.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth=0, bool AssumeSingleUse=false) const
Look at Op.
TargetLowering(const TargetLowering &)=delete
bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, SDValue &Chain) const
Check whether a given call node is in tail position within its function.
virtual bool isGAPlusOffset(SDNode *N, const GlobalValue *&GA, int64_t &Offset) const
Returns true (and the GlobalValue and the offset) if the node is a GlobalAddress + offset.
Primary interface to the complete machine description for the target machine.
CodeModel::Model getCodeModel() const
Returns the code model.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
@ VoidTyID
type with no size
bool isSized() const
Return true if it makes sense to take the size of this type.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
bool isFunctionTy() const
True if this is an instance of FunctionType.
LLVM Value Representation.
LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
static int stackSlotSize()
Stack slot size (4 bytes)
void setVarArgsFrameIndex(int off)
void setReturnStackOffset(unsigned value)
int getVarArgsFrameIndex() const
int createLRSpillSlot(MachineFunction &MF)
unsigned getReturnStackOffset() const
bool isZExtFree(SDValue Val, EVT VT2) const override
Return true if zero-extending the specific node Val to type VT2 is free (either because it's implicit...
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
isLegalAddressingMode - Return true if the addressing mode represented by AM is legal for this target...
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
LowerOperation - Provide custom lowering hooks for some operations.
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
ReplaceNodeResults - Replace the results of node with an illegal result type with new values built ou...
unsigned getJumpTableEncoding() const override
Return the entry encoding for a jump table in the current function.
XCoreTargetLowering(const TargetMachine &TM, const XCoreSubtarget &Subtarget)
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
@ 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...
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
@ FRAME_TO_ARGS_OFFSET
FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to first (possible) on-stack ar...
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ MEMBARRIER
MEMBARRIER - Compiler barrier only; generate a no-op.
@ ATOMIC_FENCE
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ INIT_TRAMPOLINE
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
@ EH_RETURN
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin,...
@ SIGN_EXTEND
Conversion operators.
@ BR_CC
BR_CC - Conditional branch.
@ BR_JT
BR_JT - Jumptable branch.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ 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.
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ 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.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ 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.
@ ADJUST_TRAMPOLINE
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static const unsigned CodeModelLargeSize
@ 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.
@ Store
The extracted value is stored (ExtractElement only).
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
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.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Mul
Product of integers.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
bool isInteger() const
Return true if this is an integer or a vector integer type.
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 represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...
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
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...