28#define DEBUG_TYPE "csky-isel-lowering"
32#define GET_CALLING_CONV_IMPL
33#include "CSKYGenCallingConv.inc"
90 if (!Subtarget.hasE2()) {
96 if (!Subtarget.hasE2()) {
103 if (!Subtarget.has2E3()) {
126 MVT AllVTy[] = {MVT::f32, MVT::f64};
128 for (
auto VT : AllVTy) {
133 for (
auto CC : FPCCToExtend)
135 for (
auto Op : FPOpToExpand)
168 switch (
Op.getOpcode()) {
172 return LowerGlobalAddress(
Op, DAG);
174 return LowerExternalSymbol(
Op, DAG);
176 return LowerGlobalTLSAddress(
Op, DAG);
178 return LowerJumpTable(
Op, DAG);
180 return LowerBlockAddress(
Op, DAG);
182 return LowerConstantPool(
Op, DAG);
184 return LowerVASTART(
Op, DAG);
186 return LowerFRAMEADDR(
Op, DAG);
188 return LowerRETURNADDR(
Op, DAG);
243 RC = &CSKY::GPRRegClass;
247 : &CSKY::FPR32RegClass;
251 : &CSKY::FPR64RegClass;
284 ExtType,
DL, LocVT, Chain, FIN,
328SDValue CSKYTargetLowering::LowerFormalArguments(
344 std::vector<SDValue> OutChains;
348 CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.
getContext());
350 CCInfo.AnalyzeFormalArguments(Ins, CCAssignFnForCall(CallConv, IsVarArg));
352 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
353 CCValAssign &VA = ArgLocs[i];
369 const unsigned XLenInBytes = 4;
370 const MVT XLenVT = MVT::i32;
373 unsigned Idx = CCInfo.getFirstUnallocated(ArgRegs);
376 MachineRegisterInfo &RegInfo = MF.
getRegInfo();
377 CSKYMachineFunctionInfo *CSKYFI = MF.
getInfo<CSKYMachineFunctionInfo>();
382 int VaArgOffset, VarArgsSaveSize;
386 if (ArgRegs.
size() == Idx) {
387 VaArgOffset = CCInfo.getStackSize();
390 VarArgsSaveSize = XLenInBytes * (ArgRegs.
size() - Idx);
391 VaArgOffset = -VarArgsSaveSize;
401 for (
unsigned I = Idx;
I < ArgRegs.
size();
402 ++
I, VaArgOffset += XLenInBytes) {
412 ->setValue((
Value *)
nullptr);
413 OutChains.push_back(Store);
420 if (!OutChains.empty()) {
421 OutChains.push_back(Chain);
428bool CSKYTargetLowering::CanLowerReturn(
431 const Type *RetTy)
const {
433 CCState CCInfo(CallConv, IsVarArg, MF, CSKYLocs,
Context);
434 return CCInfo.CheckReturn(Outs, CCAssignFnForReturn(CallConv, IsVarArg));
449 CCInfo.AnalyzeReturn(Outs, CCAssignFnForReturn(CallConv, IsVarArg));
455 for (
unsigned i = 0, e = CSKYLocs.
size(); i < e; ++i) {
457 CCValAssign &VA = CSKYLocs[i];
471 assert(RegLo < CSKY::R31 &&
"Invalid register pair");
476 RetOps.push_back(DAG.
getRegister(RegLo, MVT::i32));
479 RetOps.push_back(DAG.
getRegister(RegHi, MVT::i32));
495 RetOps.push_back(Glue);
500 return DAG.
getNode(CSKYISD::NIR,
DL, MVT::Other, RetOps);
502 return DAG.
getNode(CSKYISD::RET,
DL, MVT::Other, RetOps);
507SDValue CSKYTargetLowering::LowerCall(CallLoweringInfo &CLI,
509 SelectionDAG &DAG = CLI.DAG;
511 SmallVectorImpl<ISD::OutputArg> &Outs = CLI.Outs;
512 SmallVectorImpl<SDValue> &OutVals = CLI.OutVals;
513 SmallVectorImpl<ISD::InputArg> &Ins = CLI.Ins;
516 bool &IsTailCall = CLI.IsTailCall;
518 bool IsVarArg = CLI.IsVarArg;
520 MVT XLenVT = MVT::i32;
526 CCState ArgCCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.
getContext());
528 ArgCCInfo.AnalyzeCallOperands(Outs, CCAssignFnForCall(CallConv, IsVarArg));
536 else if (CLI.CB && CLI.CB->isMustTailCall())
538 "site marked musttail");
541 unsigned NumBytes = ArgCCInfo.getStackSize();
545 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
546 ISD::ArgFlagsTy
Flags = Outs[i].Flags;
547 if (!
Flags.isByVal())
552 Align Alignment =
Flags.getNonZeroByValAlign();
559 Chain = DAG.
getMemcpy(Chain,
DL, FIPtr, Arg, SizeNode, Alignment, Alignment,
561 false,
nullptr, IsTailCall,
562 MachinePointerInfo(), MachinePointerInfo());
573 for (
unsigned i = 0, j = 0, e = ArgLocs.
size(); i != e; ++i) {
574 CCValAssign &VA = ArgLocs[i];
576 ISD::ArgFlagsTy
Flags = Outs[i].Flags;
582 DAG.
getNode(CSKYISD::BITCAST_TO_LOHI,
DL,
583 DAG.
getVTList(MVT::i32, MVT::i32), ArgValue);
590 if (RegLo == CSKY::R3) {
597 DAG.
getStore(Chain,
DL,
Hi, StackPtr, MachinePointerInfo()));
600 assert(RegLo < CSKY::R31 &&
"Invalid register pair");
611 ArgValue = ByValArgs[
j++];
618 assert(!IsTailCall &&
"Tail call not allowed if stack is used "
619 "for passing parameters");
635 if (!MemOpChains.
empty())
641 for (
auto &
Reg : RegsToPass) {
648 bool IsRegCall =
false;
650 Ops.push_back(Chain);
653 const GlobalValue *GV = S->getGlobal();
658 Ops.push_back(getAddr<GlobalAddressSDNode, true>(S, DAG, IsLocal));
662 Ops.push_back(getTargetConstantPoolValue(
670 Ops.push_back(getAddr<ExternalSymbolSDNode, true>(S, DAG, IsLocal));
674 Ops.push_back(getTargetConstantPoolValue(
679 Ops.push_back(Callee);
684 for (
auto &
Reg : RegsToPass)
689 const TargetRegisterInfo *
TRI = Subtarget.getRegisterInfo();
690 const uint32_t *
Mask =
TRI->getCallPreservedMask(MF, CallConv);
691 assert(Mask &&
"Missing call preserved mask for calling convention");
700 SDVTList NodeTys = DAG.
getVTList(MVT::Other, MVT::Glue);
704 return DAG.
getNode(IsRegCall ? CSKYISD::TAILReg : CSKYISD::TAIL,
DL,
708 Chain = DAG.
getNode(IsRegCall ? CSKYISD::CALLReg : CSKYISD::CALL,
DL, NodeTys,
719 CCState RetCCInfo(CallConv, IsVarArg, MF, CSKYLocs, *DAG.
getContext());
720 RetCCInfo.AnalyzeCallResult(Ins, CCAssignFnForReturn(CallConv, IsVarArg));
723 for (
auto &VA : CSKYLocs) {
740 RetValue, RetValue2);
752 bool IsVarArg)
const {
753 if (IsVarArg || !Subtarget.useHardFloatABI())
754 return RetCC_CSKY_ABIV2_SOFT;
756 return RetCC_CSKY_ABIV2_FP;
760 bool IsVarArg)
const {
761 if (IsVarArg || !Subtarget.useHardFloatABI())
762 return CC_CSKY_ABIV2_SOFT;
764 return CC_CSKY_ABIV2_FP;
780 assert(0 &&
"unknown CSKYII Modifier");
787 unsigned Flags)
const {
795CSKYTargetLowering::getConstraintType(
StringRef Constraint)
const {
796 if (Constraint.
size() == 1) {
797 switch (Constraint[0]) {
816std::pair<unsigned, const TargetRegisterClass *>
820 if (Constraint.
size() == 1) {
821 switch (Constraint[0]) {
823 return std::make_pair(0U, &CSKY::GPRRegClass);
825 return std::make_pair(0U, &CSKY::mGPRRegClass);
827 return std::make_pair(0U, &CSKY::sGPRRegClass);
829 return std::make_pair(CSKY::R14, &CSKY::GPRRegClass);
831 return std::make_pair(CSKY::C, &CSKY::CARRYRegClass);
833 if ((Subtarget.hasFPUv2SingleFloat() ||
834 Subtarget.hasFPUv3SingleFloat()) &&
836 return std::make_pair(0U, &CSKY::sFPR32RegClass);
837 if ((Subtarget.hasFPUv2DoubleFloat() ||
838 Subtarget.hasFPUv3DoubleFloat()) &&
840 return std::make_pair(0U, &CSKY::sFPR64RegClass);
843 if (Subtarget.hasFPUv2SingleFloat() && VT == MVT::f32)
844 return std::make_pair(0U, &CSKY::sFPR32RegClass);
845 if (Subtarget.hasFPUv3SingleFloat() && VT == MVT::f32)
846 return std::make_pair(0U, &CSKY::FPR32RegClass);
847 if (Subtarget.hasFPUv2DoubleFloat() && VT == MVT::f64)
848 return std::make_pair(0U, &CSKY::sFPR64RegClass);
849 if (Subtarget.hasFPUv3DoubleFloat() && VT == MVT::f64)
850 return std::make_pair(0U, &CSKY::FPR64RegClass);
857 if (Constraint ==
"{c}")
858 return std::make_pair(CSKY::C, &CSKY::CARRYRegClass);
864 unsigned XRegFromAlias = StringSwitch<unsigned>(Constraint.
lower())
865 .Case(
"{a0}", CSKY::R0)
866 .Case(
"{a1}", CSKY::R1)
867 .Case(
"{a2}", CSKY::R2)
868 .Case(
"{a3}", CSKY::R3)
869 .Case(
"{l0}", CSKY::R4)
870 .Case(
"{l1}", CSKY::R5)
871 .Case(
"{l2}", CSKY::R6)
872 .Case(
"{l3}", CSKY::R7)
873 .Case(
"{l4}", CSKY::R8)
874 .Case(
"{l5}", CSKY::R9)
875 .Case(
"{l6}", CSKY::R10)
876 .Case(
"{l7}", CSKY::R11)
877 .Case(
"{t0}", CSKY::R12)
878 .Case(
"{t1}", CSKY::R13)
879 .Case(
"{sp}", CSKY::R14)
880 .Case(
"{lr}", CSKY::R15)
881 .Case(
"{l8}", CSKY::R16)
882 .Case(
"{l9}", CSKY::R17)
883 .Case(
"{t2}", CSKY::R18)
884 .Case(
"{t3}", CSKY::R19)
885 .Case(
"{t4}", CSKY::R20)
886 .Case(
"{t5}", CSKY::R21)
887 .Case(
"{t6}", CSKY::R22)
888 .Cases({
"{t7}",
"{fp}"}, CSKY::R23)
889 .Cases({
"{t8}",
"{top}"}, CSKY::R24)
890 .Cases({
"{t9}",
"{bsp}"}, CSKY::R25)
891 .Case(
"{r26}", CSKY::R26)
892 .Case(
"{r27}", CSKY::R27)
893 .Cases({
"{gb}",
"{rgb}",
"{rdb}"}, CSKY::R28)
894 .Cases({
"{tb}",
"{rtb}"}, CSKY::R29)
895 .Case(
"{svbr}", CSKY::R30)
896 .Case(
"{tls}", CSKY::R31)
897 .Default(CSKY::NoRegister);
899 if (XRegFromAlias != CSKY::NoRegister)
900 return std::make_pair(XRegFromAlias, &CSKY::GPRRegClass);
909 if (Subtarget.useHardFloat()) {
910 unsigned FReg = StringSwitch<unsigned>(Constraint.
lower())
911 .Cases({
"{fr0}",
"{vr0}"}, CSKY::F0_32)
912 .Cases({
"{fr1}",
"{vr1}"}, CSKY::F1_32)
913 .Cases({
"{fr2}",
"{vr2}"}, CSKY::F2_32)
914 .Cases({
"{fr3}",
"{vr3}"}, CSKY::F3_32)
915 .Cases({
"{fr4}",
"{vr4}"}, CSKY::F4_32)
916 .Cases({
"{fr5}",
"{vr5}"}, CSKY::F5_32)
917 .Cases({
"{fr6}",
"{vr6}"}, CSKY::F6_32)
918 .Cases({
"{fr7}",
"{vr7}"}, CSKY::F7_32)
919 .Cases({
"{fr8}",
"{vr8}"}, CSKY::F8_32)
920 .Cases({
"{fr9}",
"{vr9}"}, CSKY::F9_32)
921 .Cases({
"{fr10}",
"{vr10}"}, CSKY::F10_32)
922 .Cases({
"{fr11}",
"{vr11}"}, CSKY::F11_32)
923 .Cases({
"{fr12}",
"{vr12}"}, CSKY::F12_32)
924 .Cases({
"{fr13}",
"{vr13}"}, CSKY::F13_32)
925 .Cases({
"{fr14}",
"{vr14}"}, CSKY::F14_32)
926 .Cases({
"{fr15}",
"{vr15}"}, CSKY::F15_32)
927 .Cases({
"{fr16}",
"{vr16}"}, CSKY::F16_32)
928 .Cases({
"{fr17}",
"{vr17}"}, CSKY::F17_32)
929 .Cases({
"{fr18}",
"{vr18}"}, CSKY::F18_32)
930 .Cases({
"{fr19}",
"{vr19}"}, CSKY::F19_32)
931 .Cases({
"{fr20}",
"{vr20}"}, CSKY::F20_32)
932 .Cases({
"{fr21}",
"{vr21}"}, CSKY::F21_32)
933 .Cases({
"{fr22}",
"{vr22}"}, CSKY::F22_32)
934 .Cases({
"{fr23}",
"{vr23}"}, CSKY::F23_32)
935 .Cases({
"{fr24}",
"{vr24}"}, CSKY::F24_32)
936 .Cases({
"{fr25}",
"{vr25}"}, CSKY::F25_32)
937 .Cases({
"{fr26}",
"{vr26}"}, CSKY::F26_32)
938 .Cases({
"{fr27}",
"{vr27}"}, CSKY::F27_32)
939 .Cases({
"{fr28}",
"{vr28}"}, CSKY::F28_32)
940 .Cases({
"{fr29}",
"{vr29}"}, CSKY::F29_32)
941 .Cases({
"{fr30}",
"{vr30}"}, CSKY::F30_32)
942 .Cases({
"{fr31}",
"{vr31}"}, CSKY::F31_32)
944 if (FReg != CSKY::NoRegister) {
945 assert(CSKY::F0_32 <= FReg && FReg <= CSKY::F31_32 &&
"Unknown fp-reg");
946 unsigned RegNo = FReg - CSKY::F0_32;
947 unsigned DReg = CSKY::F0_64 + RegNo;
949 if (Subtarget.hasFPUv2DoubleFloat())
950 return std::make_pair(DReg, &CSKY::sFPR64RegClass);
951 else if (Subtarget.hasFPUv3DoubleFloat())
952 return std::make_pair(DReg, &CSKY::FPR64RegClass);
953 else if (Subtarget.hasFPUv2SingleFloat())
954 return std::make_pair(FReg, &CSKY::sFPR32RegClass);
955 else if (Subtarget.hasFPUv3SingleFloat())
956 return std::make_pair(FReg, &CSKY::FPR32RegClass);
985 F->insert(It, copyMBB);
986 F->insert(It, sinkMBB);
1021 MI.eraseFromParent();
1029 switch (
MI.getOpcode()) {
1034 if (Subtarget.hasE2())
1048 unsigned Flags)
const {
1049 CSKYConstantPoolValue *CPV =
1059 unsigned Flags)
const {
1060 CSKYConstantPoolValue *CPV =
1069 unsigned Flags)
const {
1080 unsigned Flags)
const {
1090 unsigned Flags)
const {
1096 unsigned Flags)
const {
1102 unsigned Flags)
const {
1108 unsigned Flags)
const {
1115 unsigned Flags)
const {
1118 N->getOffset(), Flags);
1124 EVT Ty =
Op.getValueType();
1126 int64_t
Offset =
N->getOffset();
1128 const GlobalValue *GV =
N->getGlobal();
1130 SDValue Addr = getAddr<GlobalAddressSDNode, false>(
N, DAG, IsLocal);
1146 return getAddr(
N, DAG,
false);
1153 return getAddr<JumpTableSDNode, false>(
N, DAG);
1160 return getAddr(
N, DAG);
1165 assert(!Subtarget.hasE2());
1168 return getAddr(
N, DAG);
1173 CSKYMachineFunctionInfo *FuncInfo = MF.
getInfo<CSKYMachineFunctionInfo>();
1183 MachinePointerInfo(SV));
1188 const CSKYRegisterInfo &RI = *Subtarget.getRegisterInfo();
1193 EVT VT =
Op.getValueType();
1195 unsigned Depth =
Op.getConstantOperandVal(0);
1200 MachinePointerInfo());
1206 const CSKYRegisterInfo &RI = *Subtarget.getRegisterInfo();
1211 EVT VT =
Op.getValueType();
1213 unsigned Depth =
Op.getConstantOperandVal(0);
1215 SDValue FrameAddr = LowerFRAMEADDR(
Op, DAG);
1219 MachinePointerInfo());
1227Register CSKYTargetLowering::getExceptionPointerRegister(
1228 const Constant *PersonalityFn)
const {
1232Register CSKYTargetLowering::getExceptionSelectorRegister(
1233 const Constant *PersonalityFn)
const {
1240 EVT Ty =
Op.getValueType();
1242 int64_t
Offset =
N->getOffset();
1243 MVT XLenVT = MVT::i32;
1249 Addr = getStaticTLSAddr(
N, DAG,
false);
1252 Addr = getStaticTLSAddr(
N, DAG,
true);
1256 Addr = getDynamicTLSAddr(
N, DAG);
1272 bool UseGOT)
const {
1274 CSKYMachineFunctionInfo *CFI = MF.
getInfo<CSKYMachineFunctionInfo>();
1282 bool AddCurrentAddr = UseGOT ?
true :
false;
1283 unsigned char PCAjust = UseGOT ? 4 : 0;
1285 CSKYConstantPoolValue *CPV =
1287 Flag, AddCurrentAddr, CSKYPCLabelIndex);
1298 MachinePointerInfo(
N->getGlobal()));
1311 CSKYMachineFunctionInfo *CFI = MF.
getInfo<CSKYMachineFunctionInfo>();
1319 CSKYConstantPoolValue *CPV =
1333 Args.emplace_back(Load, CallTy);
1336 TargetLowering::CallLoweringInfo CLI(DAG);
1357 const APInt &
Imm = ConstNode->getAPIntValue();
1359 if ((Imm + 1).isPowerOf2() || (Imm - 1).isPowerOf2() ||
1360 (1 - Imm).isPowerOf2())
1365 if (!Subtarget.hasE2() && (-1 - Imm).isPowerOf2())
1369 if (
Imm.ugt(0xffff) && ((Imm - 2).isPowerOf2() || (Imm - 4).isPowerOf2()) &&
1372 if (
Imm.ugt(0xffff) && (Imm - 8).isPowerOf2() && Subtarget.has2E3())
1379bool CSKYTargetLowering::isCheapToSpeculateCttz(
Type *Ty)
const {
1380 return Subtarget.has2E3();
1383bool CSKYTargetLowering::isCheapToSpeculateCtlz(
Type *Ty)
const {
1384 return Subtarget.hasE2();
static const MCPhysReg GPRArgRegs[]
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static SDValue unpack64(SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
static SDValue convertValVTToLocVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
static CSKYCP::CSKYCPModifier getModifier(unsigned Flags)
static SDValue unpackFromMemLoc(SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
static SDValue convertLocVTToValVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
static MachineBasicBlock * emitSelectPseudo(MachineInstr &MI, MachineBasicBlock *BB, unsigned Opcode)
static SDValue unpackFromRegLoc(const CSKYSubtarget &Subtarget, SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
Promote Memory to Register
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
size_t size() const
Get the array size.
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 CSKYConstantPoolConstant * Create(const Constant *C, CSKYCP::CSKYCPKind Kind, unsigned PCAdjust, CSKYCP::CSKYCPModifier Modifier, bool AddCurrentAddress, unsigned ID=0)
static CSKYConstantPoolJT * Create(Type *Ty, int JTI, unsigned PCAdj, CSKYCP::CSKYCPModifier Modifier)
static CSKYConstantPoolSymbol * Create(Type *Ty, const char *S, unsigned PCAdjust, CSKYCP::CSKYCPModifier Modifier)
unsigned createPICLabelUId()
int getVarArgsFrameIndex()
void setVarArgsFrameIndex(int v)
void setVarArgsSaveSize(int Size)
Register getFrameRegister(const MachineFunction &MF) const override
bool hasFPUv2SingleFloat() const
bool hasFPUv3SingleFloat() const
const CSKYRegisterInfo * getRegisterInfo() const override
bool hasFPUv2DoubleFloat() const
bool useHardFloat() const
bool hasFPUv3DoubleFloat() const
CSKYTargetLowering(const TargetMachine &TM, const CSKYSubtarget &STI)
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
Return the ValueType of the result of SETCC operations.
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...
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
unsigned getPointerSizeInBits(unsigned AS=0) const
The size in bits of the pointer representation in a given address space.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
This is an important class for using LLVM in a threaded context.
static MVT getIntegerVT(unsigned BitWidth)
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
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.
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.
void setFrameAddressIsTaken(bool T)
void setHasTailCall(bool V=true)
void setReturnAddressIsTaken(bool s)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
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 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.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
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 representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
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
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
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 AAMDNodes &AAInfo=AAMDNodes())
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 SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s),...
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands,...
void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge)
Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
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)
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 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 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
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 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.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
MachineFunction & getMachineFunction() const
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI SDValue getRegisterMask(const uint32_t *RegMask)
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)
Represent a constant reference to a string, i.e.
constexpr size_t size() const
Get the string size.
LLVM_ABI std::string lower() const
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...
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
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.
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 setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
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...
std::vector< ArgListEntry > ArgListTy
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.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
bool isPositionIndependent() const
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
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 shouldAssumeDSOLocal(const GlobalValue *GV) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
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.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ 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.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ ATOMIC_FENCE
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
@ 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...
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ BR_CC
BR_CC - Conditional branch.
@ BR_JT
BR_JT - Jumptable branch.
@ 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...
@ 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.
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ 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.
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Flag
These should be considered private to the implementation of the MCInstrDesc class.
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.
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.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
@ Default
The result value is uniform if and only if all operands are uniform.
MCRegisterClass TargetRegisterClass
This struct is a compact representation of a valid (non-zero power of two) alignment.
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
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 isVector() const
Return true if this is a vector value type.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.