38 #define DEBUG_TYPE "riscv-lower" 40 STATISTIC(NumTailCalls,
"Number of tail calls");
127 for (
auto CC : FPCCToExtend)
132 for (
auto Op : FPOpToExtend)
139 for (
auto CC : FPCCToExtend)
146 for (
auto Op : FPOpToExtend)
164 unsigned FunctionAlignment = Subtarget.
hasStdExtC() ? 1 : 2;
182 unsigned Intrinsic)
const {
234 return isInt<12>(Imm);
238 return isInt<12>(Imm);
249 return (SrcBits == 64 && DestBits == 32);
258 return (SrcBits == 64 && DestBits == 32);
263 if (
auto *
LD = dyn_cast<LoadSDNode>(Val)) {
264 EVT MemVT =
LD->getMemoryVT();
324 return lowerGlobalAddress(Op, DAG);
326 return lowerBlockAddress(Op, DAG);
328 return lowerConstantPool(Op, DAG);
330 return lowerSELECT(Op, DAG);
332 return lowerVASTART(Op, DAG);
334 return lowerFRAMEADDR(Op, DAG);
336 return lowerRETURNADDR(Op, DAG);
425 auto CC = cast<CondCodeSDNode>(CondV.
getOperand(2));
432 SDValue Ops[] = {LHS, RHS, TargetCC, TrueV, FalseV};
443 SDValue Ops[] = {CondV, Zero, SetNE, TrueV, FalseV};
470 int XLenInBytes = Subtarget.
getXLen() / 8;
475 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
477 int Offset = -(XLenInBytes * 2);
493 int XLenInBytes = Subtarget.
getXLen() / 8;
500 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
502 int Off = -XLenInBytes;
503 SDValue FrameAddr = lowerFRAMEADDR(Op, DAG);
552 assert(Subtarget.
getXLen() == 64 &&
"Combine should be 64-bit only");
558 cast<VTSDNode>(RHS->
getOperand(1))->getVT().getSizeInBits() <= 5))
596 assert(MI.
getOpcode() == RISCV::SplitF64Pseudo &&
"Unexpected instruction");
613 BuildMI(*BB, MI, DL, TII.
get(RISCV::LW), LoReg)
617 BuildMI(*BB, MI, DL, TII.
get(RISCV::LW), HiReg)
628 "Unexpected instruction");
664 case RISCV::Select_GPR_Using_CC_GPR:
665 case RISCV::Select_FPR32_Using_CC_GPR:
666 case RISCV::Select_FPR64_Using_CC_GPR:
668 case RISCV::BuildPairF64Pseudo:
670 case RISCV::SplitF64Pseudo:
759 RISCV::X10, RISCV::X11, RISCV::X12, RISCV::X13,
760 RISCV::X14, RISCV::X15, RISCV::X16, RISCV::X17
769 unsigned XLenInBytes = XLen / 8;
782 ValNo2, ValVT2, State.
AllocateStack(XLenInBytes, XLenInBytes), LocVT2,
794 ValNo2, ValVT2, State.
AllocateStack(XLenInBytes, XLenInBytes), LocVT2,
804 CCState &State,
bool IsFixed,
bool IsRet,
Type *OrigTy) {
806 assert(XLen == 32 || XLen == 64);
815 if (IsRet && ValNo > 1)
825 unsigned TwoXLenInBytes = (2 * XLen) / 8;
826 if (!IsFixed && ArgFlags.
getOrigAlign() == TwoXLenInBytes &&
839 "PendingLocs and PendingArgFlags out of sync");
842 if (XLen == 32 && ValVT ==
MVT::f64) {
844 "Can't lower f64 if it is split");
879 assert(PendingLocs.
size() == 2 &&
"Unexpected PendingLocs.size()");
885 PendingArgFlags.
clear();
892 unsigned StackOffset = Reg ? 0 : State.
AllocateStack(XLen / 8, XLen / 8);
896 if (!PendingLocs.
empty()) {
898 assert(PendingLocs.
size() > 2 &&
"Unexpected PendingLocs.size()");
900 for (
auto &It : PendingLocs) {
902 It.convertToReg(Reg);
904 It.convertToMem(StackOffset);
908 PendingArgFlags.
clear();
912 assert(LocVT == XLenVT &&
"Expected an XLenVT at this stage");
927 void RISCVTargetLowering::analyzeInputArgs(
930 unsigned NumArgs = Ins.
size();
933 for (
unsigned i = 0; i != NumArgs; ++i) {
934 MVT ArgVT = Ins[i].VT;
937 Type *ArgTy =
nullptr;
940 else if (Ins[i].isOrigArg())
944 ArgFlags, CCInfo,
true, IsRet, ArgTy)) {
946 <<
EVT(ArgVT).getEVTString() <<
'\n');
952 void RISCVTargetLowering::analyzeOutputArgs(
955 CallLoweringInfo *CLI)
const {
956 unsigned NumArgs = Outs.
size();
958 for (
unsigned i = 0; i != NumArgs; i++) {
959 MVT ArgVT = Outs[i].VT;
961 Type *OrigTy = CLI ? CLI->getArgs()[Outs[i].OrigArgIndex].Ty :
nullptr;
964 ArgFlags, CCInfo, Outs[i].IsFixed, IsRet, OrigTy)) {
966 <<
EVT(ArgVT).getEVTString() <<
"\n");
1047 ExtType, DL, LocVT, Chain, FIN,
1090 SDValue RISCVTargetLowering::LowerFormalArguments(
1109 "Functions with the interrupt attribute cannot have arguments!");
1114 if (!(Kind ==
"user" || Kind ==
"supervisor" || Kind ==
"machine"))
1116 "Function interrupt attribute argument not supported!");
1121 unsigned XLenInBytes = Subtarget.
getXLen() / 8;
1123 std::vector<SDValue> OutChains;
1128 analyzeInputArgs(MF, CCInfo, Ins,
false);
1130 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
1148 unsigned ArgIndex = Ins[i].OrigArgIndex;
1149 assert(Ins[i].PartOffset == 0);
1150 while (i + 1 != e && Ins[i + 1].OrigArgIndex == ArgIndex) {
1152 unsigned PartOffset = Ins[i + 1].PartOffset;
1175 int VaArgOffset, VarArgsSaveSize;
1179 if (ArgRegs.
size() == Idx) {
1181 VarArgsSaveSize = 0;
1183 VarArgsSaveSize = XLenInBytes * (ArgRegs.
size() - Idx);
1184 VaArgOffset = -VarArgsSaveSize;
1198 VarArgsSaveSize += XLenInBytes;
1203 for (
unsigned I = Idx;
I < ArgRegs.
size();
1204 ++
I, VaArgOffset += XLenInBytes) {
1212 cast<StoreSDNode>(Store.
getNode())
1214 ->setValue((
Value *)
nullptr);
1215 OutChains.push_back(Store);
1222 if (!OutChains.empty()) {
1223 OutChains.push_back(Chain);
1233 bool RISCVTargetLowering::IsEligibleForTailCallOptimization(
1237 auto &
Callee = CLI.Callee;
1238 auto CalleeCC = CLI.CallConv;
1239 auto IsVarArg = CLI.IsVarArg;
1240 auto &Outs = CLI.Outs;
1242 auto CallerCC = Caller.getCallingConv();
1245 if (Caller.getFnAttribute(
"disable-tail-calls").getValueAsString() ==
"true")
1253 if (Caller.hasFnAttribute(
"interrupt"))
1272 for (
auto &VA : ArgLocs)
1278 auto IsCallerStructRet = Caller.hasStructRetAttr();
1279 auto IsCalleeStructRet = Outs.
empty() ?
false : Outs[0].Flags.isSRet();
1280 if (IsCallerStructRet || IsCalleeStructRet)
1296 if (CalleeCC != CallerCC) {
1298 if (!TRI->regmaskSubsetEqual(CallerPreserved, CalleePreserved))
1305 for (
auto &
Arg : Outs)
1306 if (
Arg.Flags.isByVal())
1314 SDValue RISCVTargetLowering::LowerCall(CallLoweringInfo &CLI,
1323 bool &IsTailCall = CLI.IsTailCall;
1325 bool IsVarArg = CLI.IsVarArg;
1334 analyzeOutputArgs(MF, ArgCCInfo, Outs,
false, &CLI);
1338 IsTailCall = IsEligibleForTailCallOptimization(ArgCCInfo, CLI, MF,
1343 else if (CLI.CS && CLI.CS.isMustTailCall())
1345 "site marked musttail");
1348 unsigned NumBytes = ArgCCInfo.getNextStackOffset();
1352 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
1365 Chain = DAG.
getMemcpy(Chain, DL, FIPtr, Arg, SizeNode, Align,
1380 for (
unsigned i = 0, j = 0, e = ArgLocs.
size(); i != e; ++i) {
1382 SDValue ArgValue = OutVals[i];
1386 bool IsF64OnRV32DSoftABI =
1388 if (IsF64OnRV32DSoftABI && VA.
isRegLoc()) {
1395 RegsToPass.
push_back(std::make_pair(RegLo, Lo));
1397 if (RegLo == RISCV::X17) {
1407 unsigned RegHigh = RegLo + 1;
1408 RegsToPass.
push_back(std::make_pair(RegHigh, Hi));
1421 int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex();
1423 DAG.
getStore(Chain, DL, ArgValue, SpillSlot,
1427 unsigned ArgIndex = Outs[i].OrigArgIndex;
1428 assert(Outs[i].PartOffset == 0);
1429 while (i + 1 != e && Outs[i + 1].OrigArgIndex == ArgIndex) {
1430 SDValue PartValue = OutVals[i + 1];
1431 unsigned PartOffset = Outs[i + 1].PartOffset;
1435 DAG.
getStore(Chain, DL, PartValue, Address,
1439 ArgValue = SpillSlot;
1446 ArgValue = ByValArgs[j++];
1453 assert(!IsTailCall &&
"Tail call not allowed if stack is used " 1454 "for passing parameters");
1470 if (!MemOpChains.
empty())
1476 for (
auto &
Reg : RegsToPass) {
1497 for (
auto &
Reg : RegsToPass)
1504 assert(Mask &&
"Missing call preserved mask for calling convention");
1533 analyzeInputArgs(MF, RetCCInfo, Ins,
true);
1536 for (
auto &VA : RVLocs) {
1539 DAG.
getCopyFromReg(Chain, DL, VA.getLocReg(), VA.getLocVT(), Glue);
1545 assert(VA.getLocReg() ==
ArgGPRs[0] &&
"Unexpected reg assignment");
1562 bool RISCVTargetLowering::CanLowerReturn(
1566 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
1567 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
1568 MVT VT = Outs[i].VT;
1571 CCInfo,
true,
true,
nullptr))
1597 for (
unsigned i = 0, e = RVLocs.
size(); i < e; ++i) {
1610 unsigned RegHi = RegLo + 1;
1631 if (Glue.getNode()) {
1640 "Functions with the interrupt attribute must have void return type!");
1649 else if (Kind ==
"supervisor")
1665 return "RISCVISD::RET_FLAG";
1667 return "RISCVISD::URET_FLAG";
1669 return "RISCVISD::SRET_FLAG";
1671 return "RISCVISD::MRET_FLAG";
1673 return "RISCVISD::CALL";
1675 return "RISCVISD::SELECT_CC";
1677 return "RISCVISD::BuildPairF64";
1679 return "RISCVISD::SplitF64";
1681 return "RISCVISD::TAIL";
1686 std::pair<unsigned, const TargetRegisterClass *>
1692 if (Constraint.
size() == 1) {
1693 switch (Constraint[0]) {
1695 return std::make_pair(0U, &RISCV::GPRRegClass);
1723 RISCVTargetLowering::shouldExpandAtomicRMWInIR(
AtomicRMWInst *AI)
const {
1725 if (Size == 8 || Size == 16)
1754 Value *RISCVTargetLowering::emitMaskedAtomicRMWIntrinsic(
1776 {AlignedAddr, Incr,
Mask, SextShamt, Ordering});
1779 return Builder.
CreateCall(LrwOpScwLoop, {AlignedAddr, Incr,
Mask, Ordering});
1783 RISCVTargetLowering::shouldExpandAtomicCmpXchgInIR(
1786 if (Size == 8 || Size == 16)
1791 Value *RISCVTargetLowering::emitMaskedAtomicCmpXchgIntrinsic(
1794 Value *Ordering = Builder.
getInt32(static_cast<uint32_t>(Ord));
1799 {AlignedAddr, CmpVal, NewVal,
Mask, Ordering});
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)
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
uint64_t getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
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...
C - The default llvm calling convention, compatible with C.
const GlobalValue * getGlobal() const
*p = old <signed v ? old : v
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
void setMinimumJumpTableEntries(unsigned Val)
Indicate the minimum number of blocks to generate jump tables.
SDValue CombineTo(SDNode *N, ArrayRef< SDValue > To, bool AddTo=true)
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)
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.
This class represents lattice values for constants.
Type * getParamType(unsigned i) const
Parameter type accessors.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
void push_back(const T &Elt)
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
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.
MachineMemOperand::Flags flags
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...
This class represents a function call, abstracting a target machine's calling convention.
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
*p = old <unsigned v ? old : v
*p = old >unsigned v ? old : v
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.
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, MachineFunction &MF, unsigned Intrinsic) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
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
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
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...
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
*p = old >signed v ? old : v
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) ...
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
Value * getArgOperand(unsigned i) const
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.
bool isBeforeLegalize() const
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 DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Shift and rotation operations.
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.
BinOp getOperation() const
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.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
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...
Type * getType() const
All values are typed, get the type of this value.
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)
BinOp
This enumeration lists the possible modifications atomicrmw can make.
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()
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
virtual const TargetInstrInfo * getInstrInfo() const
void setMinCmpXchgSizeInBits(unsigned SizeInBits)
Sets the minimum cmpxchg or ll/sc size supported by the backend.
amdgpu Simplify well known AMD library false Value * Callee
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
Analysis containing CSE Info
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
Class to represent pointers.
unsigned getByValSize() const
unsigned getKillRegState(bool B)
bool isSExtCheaperThanZExt(EVT SrcVT, EVT DstVT) const override
Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension. ...
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'.
The memory access is volatile.
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...
void setTargetDAGCombine(ISD::NodeType NT)
Targets should invoke this method for each target independent node that they want to provide a custom...
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
Value * getCompareOperand()
const SDValue & getOperand(unsigned Num) const
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)...
static MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
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
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
This class contains a discriminated union of information about pointers in memory operands...
#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.
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.
static bool isVariableSDivUDivURem(SDValue Val)
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.
static SDValue convertValVTToLocVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
Byte Swap and Counting operators.
Type * getReturnType() const
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
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...
Represents one node in the SelectionDAG.
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...
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
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)
ANY_EXTEND - Used for integer types. The high bits are undefined.
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...
PointerUnion< const Value *, const PseudoSourceValue * > ptrVal
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)
static SDValue convertLocVTToValVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
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.
static bool isVariableShift(SDValue Val)
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
static Intrinsic::ID getIntrinsicForMaskedAtomicRMWBinOp32(AtomicRMWInst::BinOp BinOp)
static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
unsigned getOpcode() const
FSINCOS - Compute both fsin and fcos as a single operation.
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.
SDValue getValueType(EVT)
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 EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
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
Type * getElementType() const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
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...