Hello!<br><br>I'm working on a new back-end and have hit a bit of a snag. I'm working on getting selectcc working and have followed the MSP430 model of emitting a custom CMP and SELECT_CC node and matching that with a pseudo-instruction that has useCustomEmitter=1. However, my output ends up very wrong, despite the Machine code being initially correct:<br>
<br># Machine code for function func:<br>Function Live Ins: %R0 in reg%16384, %R1 in reg%16385, %R2 in reg%16386, %R3 in reg%16387<br>Function Live Outs: %R0<br><br>BB#0: derived from LLVM BB %entry<br> Live Ins: %R0 %R1 %R2 %R3<br>
%reg16387<def> = COPY %R3; IntRegs:%reg16387<br> %reg16386<def> = COPY %R2; IntRegs:%reg16386<br> %reg16385<def> = COPY %R1; IntRegs:%reg16385<br> %reg16384<def> = COPY %R0; IntRegs:%reg16384<br>
%reg16390<def> = MOVE %reg16386; IntRegs:%reg16390,16386<br> %reg16388<def> = CMPrr %reg16384, %reg16385, %CFR<imp-def,dead>; IntRegs:%reg16388,16384,16385<br> SKIPCOND 1, %CFR<imp-use><br>
Successors according to CFG: BB#2 BB#1<br><br>BB#1: derived from LLVM BB %entry<br> Predecessors according to CFG: BB#0<br> %reg16391<def> = MOVE %reg16387; IntRegs:%reg16391,16387<br> Successors according to CFG: BB#2<br>
<br>BB#2: derived from LLVM BB %entry<br> Predecessors according to CFG: BB#0 BB#1<br> %reg16389<def> = PHI %reg16390, <BB#0>, %reg16391, <BB#1>; IntRegs:%reg16389,16390,16391<br> %R0<def> = COPY %reg16389; IntRegs:%reg16389<br>
RET<br><br># End machine code for function func.<br><br><br>-print-before-all indicates that the machines code sinking pass is wrecking this, because after that the machine code becomes:<br><br><br># Machine code for function func:<br>
Function Live Ins: %R0 in reg%16384, %R1 in reg%16385, %R2 in reg%16386, %R3 in reg%16387<br>Function Live Outs: %R0<br><br>BB#0: derived from LLVM BB %entry<br> Live Ins: %R0 %R1 %R2 %R3<br> %reg16387<def> = COPY %R3; IntRegs:%reg16387<br>
%reg16386<def> = COPY %R2; IntRegs:%reg16386<br> %reg16385<def> = COPY %R1; IntRegs:%reg16385<br> %reg16384<def> = COPY %R0; IntRegs:%reg16384<br> %reg16390<def> = MOVE %reg16386; IntRegs:%reg16390,16386<br>
SKIPCOND 1, %CFR<imp-use><br> Successors according to CFG: BB#2 BB#1<br><br>BB#1: derived from LLVM BB %entry<br> Predecessors according to CFG: BB#0<br> %reg16391<def> = MOVE %reg16387; IntRegs:%reg16391,16387<br>
Successors according to CFG: BB#2<br><br>BB#2: derived from LLVM BB %entry<br> Predecessors according to CFG: BB#0 BB#1<br> %reg16389<def> = PHI %reg16390, <BB#0>, %reg16391, <BB#1>; IntRegs:%reg16389,16390,16391<br>
%reg16388<def> = CMPrr %reg16384, %reg16385, %CFR<imp-def,dead>; IntRegs:%reg16388,16384,16385<br> %R0<def> = COPY %reg16389; IntRegs:%reg16389<br> RET<br><br># End machine code for function func.<br>
<br>The CMPrr instruction is moved down to after the PHI node. My guess is that the 'dead' in CFR<imp-def,dead> is to blame, but I can't see what I'm doing differently from MSP430/sparc that makes this not work. Any help GREATLY appreciated!<br>
<br>//Per<br>