mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-26 06:14:42 +00:00
Extract a function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179086 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fa335e4060
commit
1b133a478b
@ -148,6 +148,16 @@ static bool CC_Sparc64_Half(unsigned &ValNo, MVT &ValVT,
|
|||||||
|
|
||||||
#include "SparcGenCallingConv.inc"
|
#include "SparcGenCallingConv.inc"
|
||||||
|
|
||||||
|
// The calling conventions in SparcCallingConv.td are described in terms of the
|
||||||
|
// callee's register window. This function translates registers to the
|
||||||
|
// corresponding caller window %o register.
|
||||||
|
static unsigned toCallerWindow(unsigned Reg) {
|
||||||
|
assert(SP::I0 + 7 == SP::I7 && SP::O0 + 7 == SP::O7 && "Unexpected enum");
|
||||||
|
if (Reg >= SP::I0 && Reg <= SP::I7)
|
||||||
|
return Reg - SP::I0 + SP::O0;
|
||||||
|
return Reg;
|
||||||
|
}
|
||||||
|
|
||||||
SDValue
|
SDValue
|
||||||
SparcTargetLowering::LowerReturn(SDValue Chain,
|
SparcTargetLowering::LowerReturn(SDValue Chain,
|
||||||
CallingConv::ID CallConv, bool IsVarArg,
|
CallingConv::ID CallConv, bool IsVarArg,
|
||||||
@ -805,11 +815,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
|
|||||||
// stuck together.
|
// stuck together.
|
||||||
SDValue InFlag;
|
SDValue InFlag;
|
||||||
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
||||||
unsigned Reg = RegsToPass[i].first;
|
unsigned Reg = toCallerWindow(RegsToPass[i].first);
|
||||||
// Remap I0->I7 -> O0->O7.
|
|
||||||
if (Reg >= SP::I0 && Reg <= SP::I7)
|
|
||||||
Reg = Reg-SP::I0+SP::O0;
|
|
||||||
|
|
||||||
Chain = DAG.getCopyToReg(Chain, dl, Reg, RegsToPass[i].second, InFlag);
|
Chain = DAG.getCopyToReg(Chain, dl, Reg, RegsToPass[i].second, InFlag);
|
||||||
InFlag = Chain.getValue(1);
|
InFlag = Chain.getValue(1);
|
||||||
}
|
}
|
||||||
@ -831,13 +837,9 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
|
|||||||
Ops.push_back(Callee);
|
Ops.push_back(Callee);
|
||||||
if (hasStructRetAttr)
|
if (hasStructRetAttr)
|
||||||
Ops.push_back(DAG.getTargetConstant(SRetArgSize, MVT::i32));
|
Ops.push_back(DAG.getTargetConstant(SRetArgSize, MVT::i32));
|
||||||
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
|
||||||
unsigned Reg = RegsToPass[i].first;
|
Ops.push_back(DAG.getRegister(toCallerWindow(RegsToPass[i].first),
|
||||||
if (Reg >= SP::I0 && Reg <= SP::I7)
|
RegsToPass[i].second.getValueType()));
|
||||||
Reg = Reg-SP::I0+SP::O0;
|
|
||||||
|
|
||||||
Ops.push_back(DAG.getRegister(Reg, RegsToPass[i].second.getValueType()));
|
|
||||||
}
|
|
||||||
if (InFlag.getNode())
|
if (InFlag.getNode())
|
||||||
Ops.push_back(InFlag);
|
Ops.push_back(InFlag);
|
||||||
|
|
||||||
@ -857,13 +859,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
|
|||||||
|
|
||||||
// Copy all of the result registers out of their specified physreg.
|
// Copy all of the result registers out of their specified physreg.
|
||||||
for (unsigned i = 0; i != RVLocs.size(); ++i) {
|
for (unsigned i = 0; i != RVLocs.size(); ++i) {
|
||||||
unsigned Reg = RVLocs[i].getLocReg();
|
Chain = DAG.getCopyFromReg(Chain, dl, toCallerWindow(RVLocs[i].getLocReg()),
|
||||||
|
|
||||||
// Remap I0->I7 -> O0->O7.
|
|
||||||
if (Reg >= SP::I0 && Reg <= SP::I7)
|
|
||||||
Reg = Reg-SP::I0+SP::O0;
|
|
||||||
|
|
||||||
Chain = DAG.getCopyFromReg(Chain, dl, Reg,
|
|
||||||
RVLocs[i].getValVT(), InFlag).getValue(1);
|
RVLocs[i].getValVT(), InFlag).getValue(1);
|
||||||
InFlag = Chain.getValue(2);
|
InFlag = Chain.getValue(2);
|
||||||
InVals.push_back(Chain.getValue(0));
|
InVals.push_back(Chain.getValue(0));
|
||||||
@ -976,13 +972,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RegsToPass.push_back(std::make_pair(toCallerWindow(VA.getLocReg()), Arg));
|
||||||
// The argument registers are described in term of the callee's register
|
|
||||||
// window, so translate I0-I7 -> O0-O7.
|
|
||||||
unsigned Reg = VA.getLocReg();
|
|
||||||
if (Reg >= SP::I0 && Reg <= SP::I7)
|
|
||||||
Reg = Reg - SP::I0 + SP::O0;
|
|
||||||
RegsToPass.push_back(std::make_pair(Reg, Arg));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1061,11 +1051,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
|
|||||||
// Copy all of the result registers out of their specified physreg.
|
// Copy all of the result registers out of their specified physreg.
|
||||||
for (unsigned i = 0; i != RVLocs.size(); ++i) {
|
for (unsigned i = 0; i != RVLocs.size(); ++i) {
|
||||||
CCValAssign &VA = RVLocs[i];
|
CCValAssign &VA = RVLocs[i];
|
||||||
unsigned Reg = VA.getLocReg();
|
unsigned Reg = toCallerWindow(VA.getLocReg());
|
||||||
|
|
||||||
// Remap I0-I7 -> O0-O7.
|
|
||||||
if (Reg >= SP::I0 && Reg <= SP::I7)
|
|
||||||
Reg = Reg - SP::I0 + SP::O0;
|
|
||||||
|
|
||||||
// When returning 'inreg {i32, i32 }', two consecutive i32 arguments can
|
// When returning 'inreg {i32, i32 }', two consecutive i32 arguments can
|
||||||
// reside in the same register in the high and low bits. Reuse the
|
// reside in the same register in the high and low bits. Reuse the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user