[llvm] [RISCV][GISel] Minor refactoring of RISCVCallReturnHandler and RISCVIncomingValueHandler (PR #69757)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 20 12:44:45 PDT 2023
================
@@ -164,28 +164,39 @@ struct RISCVIncomingValueHandler : public CallLowering::IncomingValueHandler {
void assignValueToReg(Register ValVReg, Register PhysReg,
CCValAssign VA) override {
- // Copy argument received in physical register to desired VReg.
- MIRBuilder.getMBB().addLiveIn(PhysReg);
- MIRBuilder.buildCopy(ValVReg, PhysReg);
+ markPhysRegUsed(PhysReg);
+ IncomingValueHandler::assignValueToReg(ValVReg, PhysReg, VA);
}
+ /// How the physical register gets marked varies between formal
+ /// parameters (it's a basic-block live-in), and a call instruction
+ /// (it's an implicit-def of the BL).
+ virtual void markPhysRegUsed(MCRegister PhysReg) = 0;
+
private:
const RISCVSubtarget &Subtarget;
};
+struct RISCVFormalArgHandler : public RISCVIncomingValueHandler {
+ RISCVFormalArgHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI)
+ : RISCVIncomingValueHandler(B, MRI) {}
+
+ void markPhysRegUsed(MCRegister PhysReg) override {
+ MIRBuilder.getMRI()->addLiveIn(PhysReg);
----------------
preames wrote:
The switch to RISCVFormatArgHandler isn't quite nfc due to the addition of the getMRI()->getLiveIn line.
Not objecting, just making sure you're aware of it and it wasn't accidental.
https://github.com/llvm/llvm-project/pull/69757
More information about the llvm-commits
mailing list