forked from OSchip/llvm-project
[RISCV] Implement isLoadFromStackSlot and isStoreToStackSlot
This causes some slight shuffling but no meaningful codegen differences on the corpus I used for testing, but it has a larger impact when combined with e.g. rematerialisation. Regardless, it makes sense to report as accurate target-specific information as possible. llvm-svn: 330949
This commit is contained in:
parent
7dd437710e
commit
fda6037e98
|
@ -32,6 +32,55 @@ using namespace llvm;
|
|||
RISCVInstrInfo::RISCVInstrInfo()
|
||||
: RISCVGenInstrInfo(RISCV::ADJCALLSTACKDOWN, RISCV::ADJCALLSTACKUP) {}
|
||||
|
||||
unsigned RISCVInstrInfo::isLoadFromStackSlot(const MachineInstr &MI,
|
||||
int &FrameIndex) const {
|
||||
switch (MI.getOpcode()) {
|
||||
default:
|
||||
return 0;
|
||||
case RISCV::LB:
|
||||
case RISCV::LBU:
|
||||
case RISCV::LH:
|
||||
case RISCV::LHU:
|
||||
case RISCV::LW:
|
||||
case RISCV::FLW:
|
||||
case RISCV::LWU:
|
||||
case RISCV::LD:
|
||||
case RISCV::FLD:
|
||||
break;
|
||||
}
|
||||
|
||||
if (MI.getOperand(1).isFI() && MI.getOperand(2).isImm() &&
|
||||
MI.getOperand(2).getImm() == 0) {
|
||||
FrameIndex = MI.getOperand(1).getIndex();
|
||||
return MI.getOperand(0).getReg();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned RISCVInstrInfo::isStoreToStackSlot(const MachineInstr &MI,
|
||||
int &FrameIndex) const {
|
||||
switch (MI.getOpcode()) {
|
||||
default:
|
||||
return 0;
|
||||
case RISCV::SB:
|
||||
case RISCV::SH:
|
||||
case RISCV::SW:
|
||||
case RISCV::FSW:
|
||||
case RISCV::SD:
|
||||
case RISCV::FSD:
|
||||
break;
|
||||
}
|
||||
|
||||
if (MI.getOperand(0).isFI() && MI.getOperand(1).isImm() &&
|
||||
MI.getOperand(1).getImm() == 0) {
|
||||
FrameIndex = MI.getOperand(0).getIndex();
|
||||
return MI.getOperand(2).getReg();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RISCVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator MBBI,
|
||||
const DebugLoc &DL, unsigned DstReg,
|
||||
|
|
|
@ -27,6 +27,11 @@ class RISCVInstrInfo : public RISCVGenInstrInfo {
|
|||
public:
|
||||
RISCVInstrInfo();
|
||||
|
||||
unsigned isLoadFromStackSlot(const MachineInstr &MI,
|
||||
int &FrameIndex) const override;
|
||||
unsigned isStoreToStackSlot(const MachineInstr &MI,
|
||||
int &FrameIndex) const override;
|
||||
|
||||
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
|
||||
const DebugLoc &DL, unsigned DstReg, unsigned SrcReg,
|
||||
bool KillSrc) const override;
|
||||
|
|
Loading…
Reference in New Issue