32 #define DEBUG_TYPE "arc-lower" 146 return "ARCISD::CMOV";
148 return "ARCISD::CMP";
150 return "ARCISD::BRcc";
152 return "ARCISD::RET";
154 return "ARCISD::GAWRAPPER";
182 "Unhandled target sign_extend_inreg.");
184 unsigned Width = cast<VTSDNode>(Op.
getOperand(1))->getVT().getSizeInBits();
185 if (Width == 16 || Width == 8)
211 auto *
N = cast<JumpTableSDNode>(
Op);
216 #include "ARCGenCallingConv.inc" 249 RetCCInfo.AnalyzeCallResult(Ins, RetCC_ARC);
252 unsigned NumBytes = RetCCInfo.getNextStackOffset();
262 for (
unsigned i = 0,
e = ArgLocs.
size(); i !=
e; ++i) {
306 if (!MemOpChains.
empty())
314 for (
unsigned i = 0,
e = RegsToPass.
size(); i !=
e; ++i) {
316 RegsToPass[i].
second, Glue);
323 bool IsDirect =
true;
324 if (
auto *
G = dyn_cast<GlobalAddressSDNode>(Callee))
326 else if (
auto *
E = dyn_cast<ExternalSymbolSDNode>(Callee))
339 for (
unsigned i = 0,
e = RegsToPass.
size(); i !=
e; ++i)
341 RegsToPass[i].second.getValueType()));
347 assert(Mask &&
"Missing call preserved mask for calling convention");
376 for (
unsigned i = 0,
e = RVLocs.
size(); i !=
e; ++i) {
397 for (
unsigned i = 0,
e = ResultMemLocs.
size(); i !=
e; ++i) {
398 int Offset = ResultMemLocs[i].first;
399 unsigned Index = ResultMemLocs[i].second;
411 if (!MemOpChains.
empty())
431 SDValue ARCTargetLowering::LowerFormalArguments(
440 return LowerCallArguments(Chain, CallConv, IsVarArg, Ins, dl, DAG, InVals);
446 SDValue ARCTargetLowering::LowerCallArguments(
462 unsigned StackSlotSize = 4;
465 AFI->setReturnStackOffset(CCInfo.getNextStackOffset());
479 for (
unsigned i = 0,
e = ArgLocs.size(); i !=
e; ++i) {
488 LLVM_DEBUG(
errs() <<
"LowerFormalArguments Unhandled argument type: " 503 assert((ObjSize <= StackSlotSize) &&
"Unhandled argument");
514 const ArgDataPair ADP = {ArgIn, Ins[i].Flags};
524 unsigned FirstVAReg = CCInfo.getFirstUnallocated(ArgRegs);
533 CCInfo.getNextStackOffset(),
true);
534 AFI->setVarArgsFrameIndex(VarFI);
556 if (!CFRegNode.
empty())
563 for (
const auto &ArgDI : ArgData) {
564 if (ArgDI.Flags.isByVal() && ArgDI.Flags.getByValSize()) {
565 unsigned Size = ArgDI.Flags.getByValSize();
566 unsigned Align =
std::max(StackSlotSize, ArgDI.Flags.getByValAlign());
580 if (!MemOps.
empty()) {
592 bool ARCTargetLowering::CanLowerReturn(
596 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
625 CCInfo.AnalyzeReturn(Outs, RetCC_ARC);
631 for (
unsigned i = 0,
e = RVLocs.
size(); i !=
e; ++i) {
643 int FI = MFI.CreateFixedObject(ObjSize, Offset,
false);
649 Chain, dl, OutVals[i], FIN,
655 if (!MemOpChains.
empty())
659 for (
unsigned i = 0,
e = RVLocs.
size(); i !=
e; ++i) {
687 DAGCombinerInfo &DCI)
const {
701 return AM.
Scale == 0;
705 bool ARCTargetLowering::mayBeEmittedAsTailCall(
const CallInst *CI)
const {
718 "Only support lowering frame addr of current frame.");
750 return LowerGlobalAddress(Op, DAG);
752 return LowerFRAMEADDR(Op, DAG);
754 return LowerSELECT_CC(Op, DAG);
756 return LowerBR_CC(Op, DAG);
758 return LowerSIGN_EXTEND_INREG(Op, DAG);
760 return LowerJumpTable(Op, DAG);
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
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)
ARCFunctionInfo - This class is derived from MachineFunction private ARC target-specific information ...
BUILTIN_OP_END - This must be the last enum value in this list.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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...
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
const GlobalValue * getGlobal() const
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd)...
LLVM_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.
Register getLocReg() const
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
void push_back(const T &Elt)
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
ARCTargetLowering(const TargetMachine &TM, const ARCSubtarget &Subtarget)
This class represents a function call, abstracting a target machine's calling convention.
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
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...
C - The default llvm calling convention, compatible with C.
unsigned const TargetRegisterInfo * TRI
static SDValue lowerCallResult(SDValue Chain, SDValue InFlag, const SmallVectorImpl< CCValAssign > &RVLocs, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals)
Lower the result values of a call into the appropriate copies out of physical registers / memory loca...
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
Provide custom lowering hooks for some operations.
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
Shift and rotation operations.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
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...
LocInfo getLocInfo() const
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.
SmallVector< ISD::InputArg, 32 > Ins
STACKSAVE - STACKSAVE has one operand, an input chain.
const ARCRegisterInfo * getRegisterInfo() const override
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)
Simple integer binary arithmetic operators.
SmallVector< ISD::OutputArg, 32 > Outs
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
UNDEF - An undefined node.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
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...
int64_t getOffset() const
static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG)
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
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...
Register getFrameRegister(const MachineFunction &MF) const override
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
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...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This structure contains all information that is necessary for lowering calls.
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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...
TokenFactor - This node takes multiple tokens as input and produces a single token result...
const TargetLowering & getTargetLoweringInfo() const
CCState - This class holds information needed while lowering arguments and return values...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
Align max(MaybeAlign Lhs, Align Rhs)
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.
BRCOND - Conditional branch.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
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 char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
static ARCCC::CondCode ISDCCtoARCCC(ISD::CondCode isdCC)
amdgpu Simplify well known AMD library false FunctionCallee Callee
ZERO_EXTEND - Used for integer types, zeroing the new bits.
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
ANY_EXTEND - Used for integer types. The high bits are undefined.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
BR_JT - Jumptable branch.
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.
SmallVector< SDValue, 32 > OutVals
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
unsigned AllocateStack(unsigned Size, unsigned Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
Bitwise operators - logical and, logical or, logical xor.
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
LLVM_NODISCARD bool empty() const
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
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())
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
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 setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
LLVM Value Representation.
SDValue getRegister(unsigned Reg, EVT VT)
Fast - This calling convention attempts to make calls as fast as possible (e.g.
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.
Primary interface to the complete machine description for the target machine.
const SDValue & getOperand(unsigned i) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
LLVMContext * getContext() const
Wrapper class representing virtual and physical registers.
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...