38 #define DEBUG_TYPE "riscv-lower" 40 STATISTIC(NumTailCalls,
"Number of tail calls");
117 for (
auto CC : FPCCToExtend)
127 for (
auto CC : FPCCToExtend)
148 unsigned FunctionAlignment = Subtarget.
hasStdExtC() ? 1 : 2;
190 return isInt<12>(Imm);
194 return isInt<12>(Imm);
205 return (SrcBits == 64 && DestBits == 32);
214 return (SrcBits == 64 && DestBits == 32);
219 if (
auto *
LD = dyn_cast<LoadSDNode>(Val)) {
220 EVT MemVT =
LD->getMemoryVT();
276 return lowerGlobalAddress(Op, DAG);
278 return lowerBlockAddress(Op, DAG);
280 return lowerConstantPool(Op, DAG);
282 return lowerSELECT(Op, DAG);
284 return lowerVASTART(Op, DAG);
286 return LowerFRAMEADDR(Op, DAG);
288 return LowerRETURNADDR(Op, DAG);
397 auto CC = cast<CondCodeSDNode>(CondV.
getOperand(2));
404 SDValue Ops[] = {LHS, RHS, TargetCC, TrueV, FalseV};
415 SDValue Ops[] = {CondV, Zero, SetNE, TrueV, FalseV};
442 int XLenInBytes = Subtarget.
getXLen() / 8;
447 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
449 int Offset = -(XLenInBytes * 2);
465 int XLenInBytes = Subtarget.
getXLen() / 8;
472 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
474 int Off = -XLenInBytes;
475 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
490 assert(MI.
getOpcode() == RISCV::SplitF64Pseudo &&
"Unexpected instruction");
507 BuildMI(*BB, MI, DL, TII.
get(RISCV::LW), LoReg)
511 BuildMI(*BB, MI, DL, TII.
get(RISCV::LW), HiReg)
522 "Unexpected instruction");
558 case RISCV::Select_GPR_Using_CC_GPR:
559 case RISCV::Select_FPR32_Using_CC_GPR:
560 case RISCV::Select_FPR64_Using_CC_GPR:
562 case RISCV::BuildPairF64Pseudo:
564 case RISCV::SplitF64Pseudo:
653 RISCV::X10, RISCV::X11, RISCV::X12, RISCV::X13,
654 RISCV::X14, RISCV::X15, RISCV::X16, RISCV::X17
663 unsigned XLenInBytes = XLen / 8;
676 ValNo2, ValVT2, State.
AllocateStack(XLenInBytes, XLenInBytes), LocVT2,
688 ValNo2, ValVT2, State.
AllocateStack(XLenInBytes, XLenInBytes), LocVT2,
698 CCState &State,
bool IsFixed,
bool IsRet,
Type *OrigTy) {
700 assert(XLen == 32 || XLen == 64);
709 if (IsRet && ValNo > 1)
719 unsigned TwoXLenInBytes = (2 * XLen) / 8;
720 if (!IsFixed && ArgFlags.
getOrigAlign() == TwoXLenInBytes &&
733 "PendingLocs and PendingArgFlags out of sync");
736 if (XLen == 32 && ValVT ==
MVT::f64) {
738 "Can't lower f64 if it is split");
773 assert(PendingLocs.
size() == 2 &&
"Unexpected PendingLocs.size()");
779 PendingArgFlags.
clear();
786 unsigned StackOffset = Reg ? 0 : State.
AllocateStack(XLen / 8, XLen / 8);
790 if (!PendingLocs.
empty()) {
792 assert(PendingLocs.
size() > 2 &&
"Unexpected PendingLocs.size()");
794 for (
auto &It : PendingLocs) {
796 It.convertToReg(Reg);
798 It.convertToMem(StackOffset);
802 PendingArgFlags.
clear();
806 assert(LocVT == XLenVT &&
"Expected an XLenVT at this stage");
817 void RISCVTargetLowering::analyzeInputArgs(
820 unsigned NumArgs = Ins.
size();
823 for (
unsigned i = 0; i != NumArgs; ++i) {
824 MVT ArgVT = Ins[i].VT;
827 Type *ArgTy =
nullptr;
830 else if (Ins[i].isOrigArg())
834 ArgFlags, CCInfo,
true, IsRet, ArgTy)) {
836 <<
EVT(ArgVT).getEVTString() <<
'\n');
842 void RISCVTargetLowering::analyzeOutputArgs(
845 CallLoweringInfo *CLI)
const {
846 unsigned NumArgs = Outs.
size();
848 for (
unsigned i = 0; i != NumArgs; i++) {
849 MVT ArgVT = Outs[i].VT;
851 Type *OrigTy = CLI ? CLI->getArgs()[Outs[i].OrigArgIndex].Ty :
nullptr;
854 ArgFlags, CCInfo, Outs[i].IsFixed, IsRet, OrigTy)) {
856 <<
EVT(ArgVT).getEVTString() <<
"\n");
913 ExtType, DL, LocVT, Chain, FIN,
956 SDValue RISCVTargetLowering::LowerFormalArguments(
975 "Functions with the interrupt attribute cannot have arguments!");
980 if (!(Kind ==
"user" || Kind ==
"supervisor" || Kind ==
"machine"))
982 "Function interrupt attribute argument not supported!");
987 unsigned XLenInBytes = Subtarget.
getXLen() / 8;
989 std::vector<SDValue> OutChains;
994 analyzeInputArgs(MF, CCInfo, Ins,
false);
996 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
1015 unsigned ArgIndex = Ins[i].OrigArgIndex;
1016 assert(Ins[i].PartOffset == 0);
1017 while (i + 1 != e && Ins[i + 1].OrigArgIndex == ArgIndex) {
1019 unsigned PartOffset = Ins[i + 1].PartOffset;
1042 int VaArgOffset, VarArgsSaveSize;
1046 if (ArgRegs.
size() == Idx) {
1048 VarArgsSaveSize = 0;
1050 VarArgsSaveSize = XLenInBytes * (ArgRegs.
size() - Idx);
1051 VaArgOffset = -VarArgsSaveSize;
1065 VarArgsSaveSize += XLenInBytes;
1070 for (
unsigned I = Idx;
I < ArgRegs.
size();
1071 ++
I, VaArgOffset += XLenInBytes) {
1079 cast<StoreSDNode>(Store.
getNode())
1081 ->setValue((
Value *)
nullptr);
1082 OutChains.push_back(Store);
1089 if (!OutChains.empty()) {
1090 OutChains.push_back(Chain);
1100 bool RISCVTargetLowering::IsEligibleForTailCallOptimization(
1104 auto &
Callee = CLI.Callee;
1105 auto CalleeCC = CLI.CallConv;
1106 auto IsVarArg = CLI.IsVarArg;
1107 auto &Outs = CLI.Outs;
1112 if (Caller.getFnAttribute(
"disable-tail-calls").getValueAsString() ==
"true")
1120 if (Caller.hasFnAttribute(
"interrupt"))
1139 for (
auto &VA : ArgLocs)
1145 auto IsCallerStructRet = Caller.hasStructRetAttr();
1146 auto IsCalleeStructRet = Outs.
empty() ?
false : Outs[0].Flags.isSRet();
1147 if (IsCallerStructRet || IsCalleeStructRet)
1163 if (CalleeCC != CallerCC) {
1165 if (!TRI->regmaskSubsetEqual(CallerPreserved, CalleePreserved))
1172 for (
auto &
Arg : Outs)
1173 if (
Arg.Flags.isByVal())
1181 SDValue RISCVTargetLowering::LowerCall(CallLoweringInfo &CLI,
1190 bool &IsTailCall = CLI.IsTailCall;
1192 bool IsVarArg = CLI.IsVarArg;
1201 analyzeOutputArgs(MF, ArgCCInfo, Outs,
false, &CLI);
1205 IsTailCall = IsEligibleForTailCallOptimization(ArgCCInfo, CLI, MF,
1210 else if (CLI.CS && CLI.CS.isMustTailCall())
1212 "site marked musttail");
1215 unsigned NumBytes = ArgCCInfo.getNextStackOffset();
1219 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
1232 Chain = DAG.
getMemcpy(Chain, DL, FIPtr, Arg, SizeNode, Align,
1247 for (
unsigned i = 0, j = 0, e = ArgLocs.
size(); i != e; ++i) {
1249 SDValue ArgValue = OutVals[i];
1253 bool IsF64OnRV32DSoftABI =
1255 if (IsF64OnRV32DSoftABI && VA.
isRegLoc()) {
1262 RegsToPass.
push_back(std::make_pair(RegLo, Lo));
1264 if (RegLo == RISCV::X17) {
1274 unsigned RegHigh = RegLo + 1;
1275 RegsToPass.
push_back(std::make_pair(RegHigh, Hi));
1294 int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex();
1296 DAG.
getStore(Chain, DL, ArgValue, SpillSlot,
1300 unsigned ArgIndex = Outs[i].OrigArgIndex;
1301 assert(Outs[i].PartOffset == 0);
1302 while (i + 1 != e && Outs[i + 1].OrigArgIndex == ArgIndex) {
1303 SDValue PartValue = OutVals[i + 1];
1304 unsigned PartOffset = Outs[i + 1].PartOffset;
1308 DAG.
getStore(Chain, DL, PartValue, Address,
1312 ArgValue = SpillSlot;
1321 ArgValue = ByValArgs[j++];
1328 assert(!IsTailCall &&
"Tail call not allowed if stack is used " 1329 "for passing parameters");
1345 if (!MemOpChains.
empty())
1351 for (
auto &
Reg : RegsToPass) {
1372 for (
auto &
Reg : RegsToPass)
1379 assert(Mask &&
"Missing call preserved mask for calling convention");
1408 analyzeInputArgs(MF, RetCCInfo, Ins,
true);
1411 for (
auto &VA : RVLocs) {
1414 DAG.
getCopyFromReg(Chain, DL, VA.getLocReg(), VA.getLocVT(), Glue);
1419 assert(VA.getLocReg() ==
ArgGPRs[0] &&
"Unexpected reg assignment");
1428 switch (VA.getLocInfo()) {
1444 bool RISCVTargetLowering::CanLowerReturn(
1448 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
1449 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
1450 MVT VT = Outs[i].VT;
1453 CCInfo,
true,
true,
nullptr))
1495 for (
unsigned i = 0, e = RVLocs.
size(); i < e; ++i) {
1508 unsigned RegHi = RegLo + 1;
1529 if (Glue.getNode()) {
1538 "Functions with the interrupt attribute must have void return type!");
1547 else if (Kind ==
"supervisor")
1563 return "RISCVISD::RET_FLAG";
1565 return "RISCVISD::URET_FLAG";
1567 return "RISCVISD::SRET_FLAG";
1569 return "RISCVISD::MRET_FLAG";
1571 return "RISCVISD::CALL";
1573 return "RISCVISD::SELECT_CC";
1575 return "RISCVISD::BuildPairF64";
1577 return "RISCVISD::SplitF64";
1579 return "RISCVISD::TAIL";
1584 std::pair<unsigned, const TargetRegisterClass *>
1590 if (Constraint.
size() == 1) {
1591 switch (Constraint[0]) {
1593 return std::make_pair(0U, &RISCV::GPRRegClass);
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
void setFrameAddressIsTaken(bool T)
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set, or Regs.size() if they are all allocated.
static MVT getIntegerVT(unsigned BitWidth)
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static CCValAssign getPending(unsigned ValNo, MVT ValVT, MVT LocVT, LocInfo HTP, unsigned ExtraInfo=0)
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
EVT getValueType() const
Return the ValueType of the referenced return value.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
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...
const GlobalValue * getGlobal() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void setMinimumJumpTableEntries(unsigned Val)
Indicate the minimum number of blocks to generate jump tables.
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)...
static SDValue unpackFromMemLoc(SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
C - The default llvm calling convention, compatible with C.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
BR_CC - Conditional branch.
Compute iterated dominance frontiers using a linear time algorithm.
Type * getParamType(unsigned i) const
Parameter type accessors.
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
unsigned getReg() const
getReg - Returns the register number.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
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...
const RISCVRegisterInfo * getRegisterInfo() const override
unsigned getValNo() const
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
static unsigned getBranchOpcodeForIntCondCode(ISD::CondCode CC)
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
void setVarArgsFrameIndex(int Index)
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
bool isInteger() const
Return true if this is an integer or a vector integer type.
bool hasExternalWeakLinkage() const
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
Return the ValueType of the result of SETCC operations.
int CreateStackObject(uint64_t Size, unsigned 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...
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
The address of a basic block.
A description of a memory reference used in the backend.
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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), MachineInstr opcode, and operands.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
void addLoc(const CCValAssign &V)
bool isIntegerTy() const
True if this is an instance of IntegerType.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static MachineBasicBlock * emitSplitF64Pseudo(MachineInstr &MI, MachineBasicBlock *BB)
void setCondCodeAction(ISD::CondCode CC, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
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...
const DataLayout & getDataLayout() const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
const BlockAddress * getBlockAddress() const
LocInfo getLocInfo() const
static SDValue unpackF64OnRV32DSoftABI(SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
AtomicOrdering
Atomic ordering for LLVM's memory model.
STACKSAVE - STACKSAVE has one operand, an input chain.
Class to represent function types.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
MachineFunction & getMachineFunction() const
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose...
SDValue getRegisterMask(const uint32_t *RegMask)
SmallVectorImpl< CCValAssign > & getPendingLocs()
bool isTruncateFree(Type *SrcTy, Type *DstTy) const override
Return true if it's free to truncate a value of type FromTy to type ToTy.
Simple integer binary arithmetic operators.
static MachineBasicBlock * emitBuildPairF64Pseudo(MachineInstr &MI, MachineBasicBlock *BB)
SmallVectorImpl< ISD::ArgFlagsTy > & getPendingArgFlags()
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
virtual const TargetInstrInfo * getInstrInfo() const
amdgpu Simplify well known AMD library false Value * Callee
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
const char * getSymbol() const
unsigned getByValSize() const
unsigned getKillRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
TargetInstrInfo - Interface to description of machine instruction set.
static void normaliseSetCC(SDValue &LHS, SDValue &RHS, ISD::CondCode &CC)
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
bool isVoidTy() const
Return true if this is 'void'.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const
Return a mask of call-preserved registers for the given calling convention on the current function...
Type * getReturnType() const
Returns the type of the ret val.
int64_t getOffset() const
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...
LLVM Basic Block Representation.
unsigned getOrigAlign() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
This is an important base class in LLVM.
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
Instruction * emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst, AtomicOrdering Ord) const override
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
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 ...
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
bool isAcquireOrStronger(AtomicOrdering ao)
unsigned getLargestLegalIntTypeSizeInBits() const
Returns the size of largest legal integer type size, or 0 if none are set.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setPrefFunctionAlignment(unsigned Align)
Set the target's preferred function alignment.
self_iterator getIterator()
CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y)...
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
const MachineInstrBuilder & addFrameIndex(int Idx) 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...
unsigned getAlignment() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool isPositionIndependent() const
This class contains a discriminated union of information about pointers in memory operands...
Fast - This calling convention attempts to make calls as fast as possible (e.g.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, 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...
SDValue CreateStackTemporary(EVT VT, unsigned minAlign=1)
Create a stack temporary, suitable for holding the specified value type.
The memory access writes data.
unsigned getFrameRegister(const MachineFunction &MF) const override
bool isReleaseOrStronger(AtomicOrdering ao)
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
TokenFactor - This node takes multiple tokens as input and produces a single token result...
static const MCPhysReg ArgGPRs[]
Iterator for intrusive lists based on ilist_node.
CCState - This class holds information needed while lowering arguments and return values...
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
CCValAssign - Represent assignment of one arg/retval to a location.
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Instruction * emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst, AtomicOrdering Ord) const override
Inserts in the IR a target-specific intrinsic specifying a fence.
Byte Swap and Counting operators.
Type * getReturnType() const
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const Constant * getConstVal() const
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
bool isLegalAddImmediate(int64_t Imm) const override
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
unsigned getByValAlign() const
Select(COND, TRUEVAL, FALSEVAL).
void setMinFunctionAlignment(unsigned Align)
Set the target's minimum function alignment (in log2(bytes))
RISCVTargetLowering(const TargetMachine &TM, const RISCVSubtarget &STI)
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Store the specified register of the given register class to the specified stack frame index...
amdgpu Simplify well known AMD library false Value Value * Arg
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
BR_JT - Jumptable branch.
Representation of each machine instruction.
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the source.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
bool isVector() const
Return true if this is a vector value type.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
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 '...
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getLocMemOffset() const
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
LLVM_NODISCARD bool empty() const
StringRef getValueAsString() const
Return the attribute's value as a string.
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
static bool CC_RISCV(const DataLayout &DL, unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State, bool IsFixed, bool IsRet, Type *OrigTy)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
int64_t getOffset() const
static bool CC_RISCVAssign2XLen(unsigned XLen, CCState &State, CCValAssign VA1, ISD::ArgFlagsTy ArgFlags1, unsigned ValNo2, MVT ValVT2, MVT LocVT2, ISD::ArgFlagsTy ArgFlags2)
bool isLegalICmpImmediate(int64_t Imm) const override
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
unsigned getOpcode() const
SDValue getValue(unsigned R) const
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
void setReturnAddressIsTaken(bool s)
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
SDValue getRegister(unsigned Reg, EVT VT)
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void setVarArgsSaveSize(int Size)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Primary interface to the complete machine description for the target machine.
int getVarArgsFrameIndex() const
StringRef - Represent a constant reference to a string, i.e.
SetCC operator - This evaluates to a true value iff the condition is true.
const SDValue & getOperand(unsigned i) const
bool verifyReturnAddressArgumentIsConstant(SDValue Op, SelectionDAG &DAG) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
unsigned getLocReg() const
unsigned AllocateReg(unsigned Reg)
AllocateReg - Attempt to allocate one register.
const MachineOperand & getOperand(unsigned i) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
static SDValue packIntoRegLoc(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
unsigned AllocateStack(unsigned Size, unsigned Align)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
Function Alias Analysis false
static SDValue unpackFromRegLoc(SelectionDAG &DAG, SDValue Chain, const CCValAssign &VA, const SDLoc &DL)
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Load the specified register of the given register class from the specified stack frame index...
LLVMContext * getContext() const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary...