Skip to content

Commit

Permalink
[m88k] Handle G_FRAME_INDEX in .td file
Browse files Browse the repository at this point in the history
Uses the new TableGen construct to move this lowering to the
target description.
  • Loading branch information
redstar committed Apr 30, 2024
1 parent c282a74 commit 7eaee03
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
14 changes: 0 additions & 14 deletions llvm/lib/Target/M88k/GISel/M88kInstructionSelector.cpp
Expand Up @@ -110,8 +110,6 @@ class M88kInstructionSelector : public InstructionSelector {
ComplexRendererFns selectAddrRegScaled(MachineOperand &Root) const;
#endif

bool selectFrameIndex(MachineInstr &I, MachineBasicBlock &MBB,
MachineRegisterInfo &MRI) const;
bool selectVaStart(MachineInstr &I, MachineBasicBlock &MBB,
MachineRegisterInfo &MRI) const;
bool selectGlobalValue(MachineInstr &I, MachineBasicBlock &MBB,
Expand Down Expand Up @@ -465,16 +463,6 @@ M88kInstructionSelector::selectAddrRegScaled(MachineOperand &Root) const {
}
#endif

bool M88kInstructionSelector::selectFrameIndex(MachineInstr &I,
MachineBasicBlock &MBB,
MachineRegisterInfo &MRI) const {
assert(I.getOpcode() == TargetOpcode::G_FRAME_INDEX && "Unexpected G code");

I.setDesc(TII.get(M88k::ADDri));
I.addOperand(MachineOperand::CreateImm(0));
return constrainSelectedInstRegOperands(I, MRI, TII, TRI, RBI);
}

bool M88kInstructionSelector::selectVaStart(MachineInstr &I,
MachineBasicBlock &MBB,
MachineRegisterInfo &MRI) const {
Expand Down Expand Up @@ -1323,8 +1311,6 @@ bool M88kInstructionSelector::select(MachineInstr &I) {
return selectGlobalValue(I, MBB, MRI);
case TargetOpcode::G_PTRMASK:
return selectPtrMask(I, MBB, MRI);
case TargetOpcode::G_FRAME_INDEX:
return selectFrameIndex(I, MBB, MRI);
case TargetOpcode::G_VASTART:
return selectVaStart(I, MBB, MRI);
case TargetOpcode::G_SEXT_INREG:
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/M88k/M88kInstrInfo.td
Expand Up @@ -466,6 +466,8 @@ def : Pat<(ptradd GPROpnd:$rs1, uimm16:$imm),
def : Pat<(ptradd GPROpnd:$rs1, GPROpnd:$rs2),
(ADDUrr GPROpnd:$rs1, GPROpnd:$rs2)>;

def : Pat<(p0 frameindex:$fi), (ADDri tframeindex:$fi, 0)>;

// ---------------------------------------------------------------------------//
// Materialize immediates & constants.
// ---------------------------------------------------------------------------//
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/M88k/vararg.ll
Expand Up @@ -25,8 +25,7 @@ define i32 @sum(i32 noundef %num_args, ...) {
; CHECK-NEXT: st %r3, %r2, 0
; CHECK-NEXT: add %r3, %r31, 56
; CHECK-NEXT: st %r3, %r2, 4
; CHECK-NEXT: add %r3, %r31, 24
; CHECK-NEXT: st %r3, %r2, 8
; CHECK-NEXT: st %r10, %r2, 8
; CHECK-NEXT: ld %r2, %r31, 16
; CHECK-NEXT: addu %r31, %r31, 56
; CHECK-NEXT: jmp %r1
Expand Down

0 comments on commit 7eaee03

Please sign in to comment.