Hi,<div><br></div><div> While working some more on the backend, I've added callee register saving and have come across something odd (I assume its because i've not implemented something), this is with optimisations which makes it even more odd :<br>
<br>      MOV.L   [R7+ 12], R1            ; 4-byte Folded Spill</div><div>      MOV.L   [R7+ 8], R2             ; 4-byte Folded Spill</div><div>      ADD.L   R0,R0 + R1</div><div>      ADD.L   R0,R0 + #7</div><div>      SUB.L   R0,R0 - R2</div>
<div>      MOV.L   R2, [R7+ 8]             ; 4-byte Folded Reload</div><div>      MOV.L   R1, [R7+ 12]            ; 4-byte Folded Reload</div><div><br></div><div> I've isolated the epilogue and prologue away from the function (they don't make use of R1 or R2, Calling convention states R0-R3 are used as inputs to a function. R1-R4 are marked as calleesaved. From the above code I cannot see any reason why R1 & R2 are being spilled, I assume the fault lies in my tablegen definitions (relevant ones reproduced below) :</div>
<div><br></div><div><div>let isCommutable=1 in</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>def ADD32rrr : M819Inst<(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),"ADD.L\t{$dst,$src1 + $src2}",[(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;</div>
<div>}</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>def ADD32rri : M819Inst<(outs GR32:$dst),(ins GR32:$src1, i32imm:$src2),"ADD.L\t{$dst,$src1 + $src2}",[(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>def SUB32rrr : M819Inst<(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),"SUB.L\t{$dst,$src1 - $src2}",[(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>def MOV32rm : M819Inst<(outs GR32:$dst), (ins memsrc:$src),"MOV.L\t{$dst, [$src]}",[(set GR32:$dst,(load addr:$src))]>;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>def MOV32mr : M819Inst<(outs), (ins memdst:$dst, GR32:$src),"MOV.L\t{[$dst], $src}",[(store GR32:$src, addr:$dst)]>;</div></div>
<div><br></div><div><br></div><div> Am I misunderstanding something here?</div><div><br></div><div><br></div><div><br></div><div> Lee</div>