Skip to content

Commit 940e862

Browse files
committed
[NFC][M68k] Refactor away MOV8dc and MOV8cd
This obsoletes the FIXME in #85686, but it doesn't address the issue where moves from CCR will still be emitted on 68000. However, all such moves will now be emitted as physreg copies, and the issue can thus be handled there in a followup change.
1 parent a27bb38 commit 940e862

File tree

4 files changed

+12
-48
lines changed

4 files changed

+12
-48
lines changed

llvm/lib/Target/M68k/M68kExpandPseudo.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ bool M68kExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
187187
return TII->ExpandMOVSZX_RM(MIB, false, TII->get(M68k::MOV16dq), MVT::i32,
188188
MVT::i16);
189189

190-
case M68k::MOV8cd:
191-
return TII->ExpandCCR(MIB, /*IsToCCR=*/true);
192-
case M68k::MOV8dc:
193-
return TII->ExpandCCR(MIB, /*IsToCCR=*/false);
194-
195190
case M68k::MOVM16jm_P:
196191
return TII->ExpandMOVEM(MIB, TII->get(M68k::MOVM16jm), /*IsRM=*/false);
197192
case M68k::MOVM32jm_P:

llvm/lib/Target/M68k/M68kInstrData.td

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,6 @@ def MOVM32mp_P : MxMOVEM_RM_Pseudo<MxType32r, MxType32.POp>;
357357

358358
//===----------------------------------------------------------------------===//
359359
// MOVE to/from SR/CCR
360-
//
361-
// A special care must be taken working with to/from CCR since it is basically
362-
// word-size SR register truncated for user mode thus it only supports word-size
363-
// instructions. Plus the original M68000 does not support moves from CCR. So in
364-
// order to use CCR effectively one MUST use proper byte-size pseudo instructi-
365-
// ons that will be resolved sometime after RA pass.
366360
//===----------------------------------------------------------------------===//
367361

368362
/// Move to CCR
@@ -394,7 +388,6 @@ foreach AM = MxMoveSupportedAMs in {
394388

395389
// Only data register is allowed.
396390
def MOV16cd : MxMoveToCCR<MxOp16AddrMode_d.Op, MxMoveSrcOpEnc_d>;
397-
def MOV8cd : MxMoveToCCRPseudo<MxOp8AddrMode_d.Op>;
398391

399392
/// Move from CCR
400393
/// --------------------------------------------------
@@ -436,7 +429,6 @@ foreach AM = MxMoveSupportedAMs in {
436429

437430
// Only data register is allowed.
438431
def MOV16dc : MxMoveFromCCR_R;
439-
def MOV8dc : MxMoveFromCCR_RPseudo<MxOp8AddrMode_d.Op>;
440432

441433
/// Move to SR
442434
/// --------------------------------------------------

llvm/lib/Target/M68k/M68kInstrInfo.cpp

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -572,24 +572,6 @@ bool M68kInstrInfo::ExpandPUSH_POP(MachineInstrBuilder &MIB,
572572
return true;
573573
}
574574

575-
bool M68kInstrInfo::ExpandCCR(MachineInstrBuilder &MIB, bool IsToCCR) const {
576-
if (MIB->getOpcode() == M68k::MOV8cd) {
577-
// Promote used register to the next class
578-
MachineOperand &Opd = MIB->getOperand(1);
579-
Opd.setReg(getRegisterInfo().getMatchingSuperReg(
580-
Opd.getReg(), M68k::MxSubRegIndex8Lo, &M68k::DR16RegClass));
581-
}
582-
583-
// Replace the pseudo instruction with the real one
584-
if (IsToCCR)
585-
MIB->setDesc(get(M68k::MOV16cd));
586-
else
587-
// FIXME M68010 or later is required
588-
MIB->setDesc(get(M68k::MOV16dc));
589-
590-
return true;
591-
}
592-
593575
bool M68kInstrInfo::ExpandMOVEM(MachineInstrBuilder &MIB,
594576
const MCInstrDesc &Desc, bool IsRM) const {
595577
int Reg = 0, Offset = 0, Base = 0;
@@ -752,29 +734,27 @@ void M68kInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
752734
bool ToSR = DstReg == M68k::SR;
753735

754736
if (FromCCR) {
755-
if (M68k::DR8RegClass.contains(DstReg)) {
756-
Opc = M68k::MOV8dc;
757-
} else if (M68k::DR16RegClass.contains(DstReg)) {
758-
Opc = M68k::MOV16dc;
759-
} else if (M68k::DR32RegClass.contains(DstReg)) {
760-
Opc = M68k::MOV16dc;
761-
} else {
737+
Opc = M68k::MOV16dc;
738+
if (!M68k::DR8RegClass.contains(DstReg) &&
739+
!M68k::DR16RegClass.contains(DstReg) &&
740+
!M68k::DR32RegClass.contains(DstReg)) {
762741
LLVM_DEBUG(dbgs() << "Cannot copy CCR to " << RI.getName(DstReg) << '\n');
763742
llvm_unreachable("Invalid register for MOVE from CCR");
764743
}
765744
} else if (ToCCR) {
745+
Opc = M68k::MOV16cd;
766746
if (M68k::DR8RegClass.contains(SrcReg)) {
767-
Opc = M68k::MOV8cd;
768-
} else if (M68k::DR16RegClass.contains(SrcReg)) {
769-
Opc = M68k::MOV16cd;
770-
} else if (M68k::DR32RegClass.contains(SrcReg)) {
771-
Opc = M68k::MOV16cd;
772-
} else {
747+
// Promote used register to the next class
748+
SrcReg = getRegisterInfo().getMatchingSuperReg(
749+
SrcReg, M68k::MxSubRegIndex8Lo, &M68k::DR16RegClass);
750+
} else if (!M68k::DR16RegClass.contains(SrcReg) &&
751+
!M68k::DR32RegClass.contains(SrcReg)) {
773752
LLVM_DEBUG(dbgs() << "Cannot copy " << RI.getName(SrcReg) << " to CCR\n");
774753
llvm_unreachable("Invalid register for MOVE to CCR");
775754
}
776-
} else if (FromSR || ToSR)
755+
} else if (FromSR || ToSR) {
777756
llvm_unreachable("Cannot emit SR copy instruction");
757+
}
778758

779759
if (Opc) {
780760
BuildMI(MBB, MI, DL, get(Opc), DstReg)

llvm/lib/Target/M68k/M68kInstrInfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,6 @@ class M68kInstrInfo : public M68kGenInstrInfo {
318318
bool ExpandPUSH_POP(MachineInstrBuilder &MIB, const MCInstrDesc &Desc,
319319
bool IsPush) const;
320320

321-
/// Moves to/from CCR
322-
bool ExpandCCR(MachineInstrBuilder &MIB, bool IsToCCR) const;
323-
324321
/// Expand all MOVEM pseudos into real MOVEMs
325322
bool ExpandMOVEM(MachineInstrBuilder &MIB, const MCInstrDesc &Desc,
326323
bool IsRM) const;

0 commit comments

Comments
 (0)