Skip to content

Commit 61bbcce

Browse files
committed
Do not rely on the enum values of argument registers A0-A3 being consecutive.
Define function getNextIntArgReg, which takes a register as a parameter and returns the next O32 argument integer register. Use this function when double precision floating point arguments are passed in two integer registers. llvm-svn: 140363
1 parent 87df91b commit 61bbcce

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,12 @@ static const unsigned O32IntRegs[] = {
17961796
Mips::A0, Mips::A1, Mips::A2, Mips::A3
17971797
};
17981798

1799+
// Return next O32 integer argument register.
1800+
static unsigned getNextIntArgReg(unsigned Reg) {
1801+
assert((Reg == Mips::A0) || (Reg == Mips::A2));
1802+
return (Reg == Mips::A0) ? Mips::A1 : Mips::A3;
1803+
}
1804+
17991805
// Write ByVal Arg to arg registers and stack.
18001806
static void
18011807
WriteByValArg(SDValue& ByValChain, SDValue Chain, DebugLoc dl,
@@ -1988,8 +1994,10 @@ MipsTargetLowering::LowerCall(SDValue InChain, SDValue Callee,
19881994
Arg, DAG.getConstant(1, MVT::i32));
19891995
if (!Subtarget->isLittle())
19901996
std::swap(Lo, Hi);
1991-
RegsToPass.push_back(std::make_pair(VA.getLocReg(), Lo));
1992-
RegsToPass.push_back(std::make_pair(VA.getLocReg()+1, Hi));
1997+
unsigned LocRegLo = VA.getLocReg();
1998+
unsigned LocRegHigh = getNextIntArgReg(LocRegLo);
1999+
RegsToPass.push_back(std::make_pair(LocRegLo, Lo));
2000+
RegsToPass.push_back(std::make_pair(LocRegHigh, Hi));
19932001
continue;
19942002
}
19952003
}
@@ -2281,7 +2289,7 @@ MipsTargetLowering::LowerFormalArguments(SDValue Chain,
22812289
ArgValue = DAG.getNode(ISD::BITCAST, dl, MVT::f32, ArgValue);
22822290
if (RegVT == MVT::i32 && VA.getValVT() == MVT::f64) {
22832291
unsigned Reg2 = AddLiveIn(DAG.getMachineFunction(),
2284-
VA.getLocReg()+1, RC);
2292+
getNextIntArgReg(ArgReg), RC);
22852293
SDValue ArgValue2 = DAG.getCopyFromReg(Chain, dl, Reg2, RegVT);
22862294
if (!Subtarget->isLittle())
22872295
std::swap(ArgValue, ArgValue2);

0 commit comments

Comments
 (0)