44 cl::desc(
"Control jump table emission on Hexagon target"));
47 class HexagonCCState :
public CCState {
48 int NumNamedVarArgParams;
54 :
CCState(CC, isVarArg, MF, TM, locs, C),
55 NumNamedVarArgParams(NumNamedVarArgParams) {}
57 int getNumNamedVarArgParams()
const {
return NumNamedVarArgParams; }
96 HexagonCCState &HState =
static_cast<HexagonCCState &
>(State);
99 assert((HState.getNumNamedVarArgParams() > 0) &&
100 "NumNamedVarArgParams is not bigger than zero.");
102 if ((
int)ValNo < HState.getNumNamedVarArgParams()) {
104 return CC_Hexagon(ValNo, ValVT, LocVT, LocInfo, ArgFlags, State);
113 "ByValSize must be bigger than 8 bytes");
123 else if (ArgFlags.
isZExt())
150 "ByValSize must be bigger than 8 bytes");
161 else if (ArgFlags.
isZExt())
168 if (!
CC_Hexagon32(ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))
173 if (!
CC_Hexagon64(ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))
185 static const uint16_t RegList[] = {
208 static const uint16_t RegList1[] = {
209 Hexagon::D1, Hexagon::D2
211 static const uint16_t RegList2[] = {
212 Hexagon::R1, Hexagon::R3
236 else if (ArgFlags.
isZExt())
333 for (
unsigned i = 0; i != RVLocs.
size(); ++i) {
350 &RetOps[0], RetOps.
size());
380 for (
unsigned i = 0; i != RVLocs.
size(); ++i) {
382 RVLocs[i].getLocReg(),
383 RVLocs[i].getValVT(), InFlag).
getValue(1);
407 bool IsStructRet = (Outs.
empty()) ?
false : Outs[0].
Flags.isSRet();
410 int NumNamedVarArgParams = -1;
415 if ((CalleeFn = dyn_cast<Function>(GA->getGlobal())))
431 NumNamedVarArgParams);
433 if (NumNamedVarArgParams > 0)
440 bool StructAttrFlag =
443 isVarArg, IsStructRet,
445 Outs, OutVals, Ins, DAG);
446 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i){
454 DEBUG(
dbgs () <<
"Eligible for Tail Call\n");
457 "Argument must be passed on stack. Not eligible for Tail Call\n");
461 unsigned NumBytes = CCInfo.getNextStackOffset();
470 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
522 if (!MemOpChains.
empty()) {
538 for (
unsigned i = 0, e = RegsToPass.
size(); i != e; ++i) {
539 Chain = DAG.
getCopyToReg(Chain, dl, RegsToPass[i].first,
540 RegsToPass[i].second, InFlag);
556 for (
unsigned i = 0, e = RegsToPass.
size(); i != e; ++i) {
557 Chain = DAG.
getCopyToReg(Chain, dl, RegsToPass[i].first,
558 RegsToPass[i].second, InFlag);
568 const char *MemcpyName =
569 "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes";
576 dyn_cast<ExternalSymbolSDNode>(Callee)) {
588 for (
unsigned i = 0, e = RegsToPass.
size(); i != e; ++i) {
590 RegsToPass[i].second.getValueType()));
610 return LowerCallResult(Chain, InFlag, CallConv, isVarArg, Ins, dl, DAG,
611 InVals, OutVals, Callee);
626 return (isa<ConstantSDNode>(Offset));
642 if (ShiftAmount > 0) {
644 v = v >> ShiftAmount;
646 return (v <= 7) && (v >= -8) && (m == 0);
663 VT =
LD->getMemoryVT();
666 VT =
ST->getMemoryVT();
667 if (
ST->getValue().getValueType() ==
MVT::i64 &&
ST->isTruncatingStore()) {
699 for (
unsigned i = InlineAsm::Op_FirstOperand; i != NumOps;) {
703 cast<ConstantSDNode>(Node->
getOperand(i))->getZExtValue();
709 case InlineAsm::Kind_RegDef:
710 case InlineAsm::Kind_RegUse:
711 case InlineAsm::Kind_Imm:
712 case InlineAsm::Kind_Clobber:
713 case InlineAsm::Kind_Mem: {
714 for (; NumVals; --NumVals, ++i) {}
717 case InlineAsm::Kind_RegDefEarlyClobber: {
718 for (; NumVals; --NumVals, ++i) {
755 const std::vector<MachineJumpTableEntry> &JTE = MJTI->
getJumpTables();
756 const std::vector<MachineBasicBlock*> &JTBBs = JTE[JTI].MBBs;
757 for (
unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
819 SDValue Ops[2] = { ArgAdjust, CopyChain };
856 for (
unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
860 unsigned StackLocation;
884 assert (0 &&
"ByValSize must be bigger than 8 bytes");
926 CCInfo.getNextStackOffset(),
986 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
1008 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
1014 false,
false,
false, 0);
1028 const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
1029 int64_t Offset = cast<GlobalAddressSDNode>(Op)->getOffset();
1044 const BlockAddress *BA = cast<BlockAddressSDNode>(Op)->getBlockAddress();
1545 unsigned OffsetReg = Hexagon::R28;
1552 Chain = DAG.
getCopyToReg(Chain, dl, OffsetReg, Offset);
1611 std::pair<unsigned, const TargetRegisterClass*>
1613 std::string &Constraint,
1615 if (Constraint.size() == 1) {
1616 switch (Constraint[0]) {
1625 return std::make_pair(0U, &Hexagon::IntRegsRegClass);
1628 return std::make_pair(0U, &Hexagon::DoubleRegsRegClass);
1660 int Scale = AM.
Scale;
1661 if (Scale < 0) Scale = -Scale;
1676 return Imm >= -512 && Imm <= 511;
1686 bool isCalleeStructRet,
1687 bool isCallerStructRet,
1694 bool CCMatch = CallerCC == CalleeCC;
1702 if (!(dyn_cast<GlobalAddressSDNode>(Callee))
1703 && !(dyn_cast<ExternalSymbolSDNode>(Callee))) {
1717 if (isCalleeStructRet || isCallerStructRet)
static bool Is_PostInc_S4_Offset(SDNode *S, int ShiftAmount)
void setFrameAddressIsTaken(bool T)
bool IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM, SectionKind Kind) const
virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
void push_back(const T &Elt)
const MachineFunction * getParent() const
SDValue getConstant(uint64_t Val, EVT VT, bool isTarget=false)
SDValue getValue(unsigned R) const
LLVMContext * getContext() const
SDValue getCopyToReg(SDValue Chain, SDLoc dl, unsigned Reg, SDValue N)
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, SDLoc DL)
LocInfo getLocInfo() const
void setHasEHReturn(bool H=true)
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const
unsigned getNumParams() const
const TargetMachine & getTargetMachine() const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
virtual bool isLegalICmpImmediate(int64_t Imm) const
void addLiveIn(unsigned Reg, unsigned vreg=0)
SDValue LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals, const SmallVectorImpl< SDValue > &OutVals, SDValue Callee) const
static cl::opt< bool > EmitJumpTables("hexagon-emit-jump-tables", cl::init(true), cl::Hidden, cl::desc("Control jump table emission on Hexagon target"))
unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC)
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
unsigned getOpcode() const
unsigned getByValSize() const
static bool RetCC_Hexagon64(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
Hexagon target-specific information for each MachineFunction.
unsigned getNumOperands() const
const SDValue & getOperand(unsigned Num) const
const Function * getFunction() const
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const
CallingConv::ID getCallingConv() const
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
unsigned getStackRegister() const
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, bool isVolatile, bool isNonTemporal, bool isInvariant, unsigned Alignment, const MDNode *TBAAInfo=0, const MDNode *Ranges=0)
const std::vector< MachineJumpTableEntry > & getJumpTables() const
bool isSEXTLoad(const SDNode *N)
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, bool isVolatile, bool isNonTemporal, unsigned Alignment, const MDNode *TBAAInfo=0)
#define llvm_unreachable(msg)
EVT getValueType(unsigned ResNo) const
MachineFunction & getMachineFunction() const
SDValue getTargetGlobalAddress(const GlobalValue *GV, SDLoc DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
void addLoc(const CCValAssign &V)
void setCondCodeAction(ISD::CondCode CC, MVT VT, LegalizeAction Action)
virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const
#define Hexagon_PointerSize
Abstract Stack Frame Information.
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
SDVTList getVTList(EVT VT)
virtual MVT getPointerTy(uint32_t=0) const
virtual bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const
ID
LLVM Calling Convention Representation.
HexagonTargetMachine & TM
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const
SmallVector< ISD::InputArg, 32 > Ins
SDValue getCALLSEQ_START(SDValue Chain, SDValue Op, SDLoc DL)
unsigned getLocReg() const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
bool hasStructRetAttr() const
Determine if the function returns a structure through first pointer argument.
Simple integer binary arithmetic operators.
static bool CC_Hexagon32(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
SmallVector< ISD::OutputArg, 32 > Outs
const MachineJumpTableInfo * getJumpTableInfo() const
MachineConstantPoolValue * getMachineCPVal() const
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const
SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const
const BasicBlock * getBasicBlock() const
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
const TargetLoweringObjectFile & getObjFileLowering() const
SDNode * getNode() const
get the SDNode which holds the desired result
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
initializer< Ty > init(const Ty &Val)
bool isMachineConstantPoolEntry() const
const SDValue & getOperand(unsigned i) const
virtual const char * getTargetNodeName(unsigned Opcode) const
This method returns the name of a target specific DAG node.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
virtual SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const
Simple binary floating point operators.
static BlockAddress * get(Function *F, BasicBlock *BB)
get - Return a BlockAddress for the specified function and basic block.
static bool getIndexedAddressParts(SDNode *Ptr, EVT VT, bool isSEXTLoad, SDValue &Base, SDValue &Offset, bool &isInc, SelectionDAG &DAG)
static bool CC_Hexagon(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
const Constant * getConstVal() const
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const
static unsigned getNumOperandRegisters(unsigned Flag)
SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT)
SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const
unsigned getOpcode() const
static unsigned getKind(unsigned Flags)
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const
unsigned getRARegister() const
unsigned MaxStoresPerMemmove
Specify maximum bytes of store instructions per memmove call.
Bit counting operators with an undefined result for zero inputs.
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const
unsigned getStackPointerRegisterToSaveRestore() const
virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const
bool isSubtargetV2() const
SDValue getMemcpy(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
unsigned getByValAlign() const
void setLoadExtAction(unsigned ExtType, MVT VT, LegalizeAction Action)
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags=0)
#define HEXAGON_LRFP_SIZE
virtual const HexagonRegisterInfo * getRegisterInfo() const
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const
void setExceptionPointerRegister(unsigned R)
static SDValue CreateCopyOfByValArgument(SDValue Src, SDValue Dst, SDValue Chain, ISD::ArgFlagsTy Flags, SelectionDAG &DAG, SDLoc dl)
void addAllocaAdjustInst(MachineInstr *MI)
SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const
CCValAssign - Represent assignment of one arg/retval to a location.
SDValue getIntPtrConstant(uint64_t Val, bool isTarget=false)
Byte Swap and Counting operators.
MachineFrameInfo * getFrameInfo()
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
bool hasClobberLR() const
void setMinimumJumpTableEntries(int Val)
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const
void setIndexedLoadAction(unsigned IdxMode, MVT VT, LegalizeAction Action)
void computeRegisterProperties()
void setExceptionSelectorRegister(unsigned R)
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const
virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base, SDValue &Offset, ISD::MemIndexedMode &AM, SelectionDAG &DAG) const
void setMinFunctionAlignment(unsigned Align)
Set the target's minimum function alignment (in log2(bytes))
int64_t getSExtValue() const
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
void setPrefLoopAlignment(unsigned Align)
ZERO_EXTEND - Used for integer types, zeroing the new bits.
void setHasAddressTaken()
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT)
ANY_EXTEND - Used for integer types. The high bits are undefined.
virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *BB) const
unsigned getFrameRegister(const MachineFunction &MF) const
virtual const HexagonSubtarget * getSubtargetImpl() const
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
void setVarArgsFrameIndex(int v)
SmallVector< SDValue, 32 > OutVals
bool IsEligibleForTailCallOptimization(SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet, bool isCallerStructRet, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SmallVectorImpl< ISD::InputArg > &Ins, SelectionDAG &DAG) const
SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const
MachineRegisterInfo & getRegInfo()
int getVarArgsFrameIndex()
unsigned getStoreSizeInBits() const
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
static bool RetCC_Hexagon(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
unsigned getSizeInBits() const
getSizeInBits - Return the size of the specified value type in bits.
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
FunctionType * getFunctionType() const
void setStackPointerRegisterToSaveRestore(unsigned R)
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
static bool CC_Hexagon_VarArg(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
static bool CC_Hexagon64(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
void setLibcallName(RTLIB::Libcall Call, const char *Name)
Rename the default libcall routine name for the specified libcall.
static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, SDLoc dl, SelectionDAG &DAG) const
unsigned getPrimitiveSizeInBits() const
FSINCOS - Compute both fsin and fcos as a single operation.
unsigned MaxStoresPerMemcpy
Specify maximum bytes of store instructions per memcpy call.
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
HexagonSubtarget & Subtarget
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
void setReturnAddressIsTaken(bool s)
unsigned getAlignment() const
HexagonTargetLowering(HexagonTargetMachine &targetmachine)
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
LLVM Value Representation.
SDValue getRegister(unsigned Reg, EVT VT)
static bool RetCC_Hexagon32(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, SDLoc dl)
getMergeValues - Create a MERGE_VALUES node from the given operands.
unsigned getLocMemOffset() const
unsigned getRARegister() const
This method should return the register where the return address can be found.
SDValue getEntryNode() const
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable)
TRUNCATE - Completely drop the high bits.
SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const
unsigned AllocateReg(unsigned Reg)
unsigned AllocateStack(unsigned Size, unsigned Align)
void setHasClobberLR(bool v)
void setIndexedStoreAction(unsigned IdxMode, MVT VT, LegalizeAction Action)