@@ -45,6 +45,30 @@ extern bool RA_InSpillerCode;
45
45
AVRInstrInfo::AVRInstrInfo ()
46
46
: AVRGenInstrInfo(AVR::ADJCALLSTACKDOWN, AVR::ADJCALLSTACKUP), RI() {}
47
47
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
+
48
72
void AVRInstrInfo::copyPhysReg (MachineBasicBlock &MBB,
49
73
MachineBasicBlock::iterator MI, DebugLoc DL,
50
74
unsigned DestReg, unsigned SrcReg,
@@ -55,6 +79,9 @@ void AVRInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
55
79
Opc = AVR::MOVRdRr;
56
80
} else if (AVR::DREGSRegClass.contains (DestReg, SrcReg)) {
57
81
Opc = AVR::MOVWRdRr;
82
+ } else if (AVR::DREGSRegClass.contains (SrcReg) && AVR::GPR8RegClass.contains (DestReg)) {
83
+ Opc = AVR::MOVRdRr;
84
+ SrcReg = highRegisterFromDREG (SrcReg);
58
85
} else if (SrcReg == AVR::SP && AVR::DREGSRegClass.contains (DestReg)) {
59
86
Opc = AVR::SPREAD;
60
87
} else if (DestReg == AVR::SP && AVR::DREGSRegClass.contains (SrcReg)) {
0 commit comments