[RISCV][NFC] Combine the control flow for different RetOp of interrupt function

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D104838
This commit is contained in:
Jim Lin 2021-06-26 17:28:01 +08:00
parent c8f3f46c69
commit 779d2b0a42
1 changed files with 2 additions and 4 deletions

View File

@ -8029,6 +8029,7 @@ RISCVTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
RetOps.push_back(Glue); RetOps.push_back(Glue);
} }
unsigned RetOpc = RISCVISD::RET_FLAG;
// Interrupt service routines use different return instructions. // Interrupt service routines use different return instructions.
const Function &Func = DAG.getMachineFunction().getFunction(); const Function &Func = DAG.getMachineFunction().getFunction();
if (Func.hasFnAttribute("interrupt")) { if (Func.hasFnAttribute("interrupt")) {
@ -8040,18 +8041,15 @@ RISCVTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
StringRef Kind = StringRef Kind =
MF.getFunction().getFnAttribute("interrupt").getValueAsString(); MF.getFunction().getFnAttribute("interrupt").getValueAsString();
unsigned RetOpc;
if (Kind == "user") if (Kind == "user")
RetOpc = RISCVISD::URET_FLAG; RetOpc = RISCVISD::URET_FLAG;
else if (Kind == "supervisor") else if (Kind == "supervisor")
RetOpc = RISCVISD::SRET_FLAG; RetOpc = RISCVISD::SRET_FLAG;
else else
RetOpc = RISCVISD::MRET_FLAG; RetOpc = RISCVISD::MRET_FLAG;
return DAG.getNode(RetOpc, DL, MVT::Other, RetOps);
} }
return DAG.getNode(RISCVISD::RET_FLAG, DL, MVT::Other, RetOps); return DAG.getNode(RetOpc, DL, MVT::Other, RetOps);
} }
void RISCVTargetLowering::validateCCReservedRegs( void RISCVTargetLowering::validateCCReservedRegs(