<div dir="ltr">I don't know much about ARM. But it looks like tADDi8 is a Thumb instruction and it can only use R0-R7.<div><br></div><div>tPUSH probably as a similar issue. But it's also a store instruction and doesn't produce a register output. So you should use the form of BuildMI that doesn't take a register as its last argument.<br><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 14, 2019 at 11:17 AM Jie Zhou via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I’m trying to insert some add/sub and push/pop instructions in a MachineFunction pass for ARMv7-M. However, I encountered something weird.<br>
For an add, when I use <br>
<br>
BuildMI(….., TII->get(ARM::tADDi8), reg).addReg(reg).addReg(reg).addImm(imm).<br>
<br>
if reg is R0 - R7, everything is fine: I would get something like<br>
<br>
adds r1, 4<br>
<br>
But if I use R8 - R12 as the reg in the BuildMI, I wouldn’t get the correct register in the assembly code. For example, when I pass R8 to it, I would get <br>
<br>
adds r0, 4<br>
<br>
rather than<br>
<br>
adds r8, 4.<br>
<br>
Similar problems happen to push and pop instructions. I can create a push/pop if the register list only contains registers R0 - R7, but<br>
for registers whose number are greater than R7, the generated asm code doesn’t have it. For example, <br>
<br>
BuildMI(……, TII->get(ARM::tPUSH), R8)…..<br>
<br>
would give me <br>
<br>
push {}<br>
<br>
Is this a bug in the LLVM ARM code generator? Or is there a reason why we cannot use big-number registers for add/sub and push/pop? <br>
<br>
Thanks,<br>
- Jie<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>