Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit a5a1627

Browse files
committed
Handle copying from a register pair to a single
1 parent 1264868 commit a5a1627

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/Target/AVR/AVRInstrInfo.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ extern bool RA_InSpillerCode;
4545
AVRInstrInfo::AVRInstrInfo()
4646
: AVRGenInstrInfo(AVR::ADJCALLSTACKDOWN, AVR::ADJCALLSTACKUP), RI() {}
4747

48+
// FIXME: BEFORE MERGING: Is there a cleaner tablegen method of doing this?
49+
static unsigned highRegisterFromDREG(unsigned DReg) {
50+
switch (DReg) {
51+
case AVR::R31R30: return AVR::R31;
52+
case AVR::R29R28: return AVR::R29;
53+
case AVR::R27R26: return AVR::R27;
54+
case AVR::R25R24: return AVR::R25;
55+
case AVR::R23R22: return AVR::R23;
56+
case AVR::R21R20: return AVR::R21;
57+
case AVR::R19R18: return AVR::R19;
58+
case AVR::R17R16: return AVR::R17;
59+
case AVR::R15R14: return AVR::R15;
60+
case AVR::R13R12: return AVR::R13;
61+
case AVR::R11R10: return AVR::R11;
62+
case AVR::R9R8: return AVR::R9;
63+
case AVR::R7R6: return AVR::R7;
64+
case AVR::R5R4: return AVR::R5;
65+
case AVR::R3R2: return AVR::R3;
66+
case AVR::R1R0: return AVR::R1;
67+
default:
68+
llvm_unreachable("Did not copy from a DREG class register");
69+
}
70+
}
71+
4872
void AVRInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
4973
MachineBasicBlock::iterator MI, DebugLoc DL,
5074
unsigned DestReg, unsigned SrcReg,
@@ -55,6 +79,9 @@ void AVRInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
5579
Opc = AVR::MOVRdRr;
5680
} else if (AVR::DREGSRegClass.contains(DestReg, SrcReg)) {
5781
Opc = AVR::MOVWRdRr;
82+
} else if (AVR::DREGSRegClass.contains(SrcReg) && AVR::GPR8RegClass.contains(DestReg)) {
83+
Opc = AVR::MOVRdRr;
84+
SrcReg = highRegisterFromDREG(SrcReg);
5885
} else if (SrcReg == AVR::SP && AVR::DREGSRegClass.contains(DestReg)) {
5986
Opc = AVR::SPREAD;
6087
} else if (DestReg == AVR::SP && AVR::DREGSRegClass.contains(SrcReg)) {

0 commit comments

Comments
 (0)