<div dir="ltr"><div>Tom,</div><div><br></div><div> My current example is a global address; however, it could be any operand in theory. The arch allows for direct mem op support for ex instructions, so it could be any type of address or any type of imm or any type of register. </div><div><br></div><div> For example, we are using intrinsics for some instructions since LLVM does not support them. Table gen does not allow for matching to direct mem op because the intrinsics are calls, so registers are setup for the call parameters. So we end up with something like:</div><div><br></div><div> mov @a, r0</div><div> abs r0, r1</div><div><br></div><div>In our arch, we should be able to do 'abs @a, r1'. So since the intrinsics won't match properly in the tblgen we're looking at doing a peephole where we want to replace the operand 'r0' with @a and remove the 'mov @a, r0' instruction, so it would look like:</div><div><br></div><div> abs @a, r1</div><div><br></div><div>Thanks.</div><div><br></div><div>ps. We could add these operators to LLVM instead of using intrinsics but that also introduces a lot of dev cost and maintenance cost and some other technical issues, but then we could have the operators match in the tblgen. We are looking to avoid this, we thought a simple peephole would do the trick instead.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 16, 2015 at 9:57 AM, Tom Stellard <span dir="ltr"><<a href="mailto:tom@stellard.net" target="_blank">tom@stellard.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Mon, Jun 15, 2015 at 10:16:47PM -0400, Ryan Taylor wrote:<br>
> I have a MachineOperand that could be something other than a Reg: mem,<br>
> global address, imm, etc...<br>
><br>
> I want to replace a reg MachineOperand with this non-reg MachineOperand.<br>
><br>
> I've tried a few different things, but it doesn't seem like there is some<br>
> simple functionality to do this?<br>
><br>
> "RemoveOperand" and "addOperand" does not work.<br>
> There doesn't seem to be a valid "ChangeTo..." function for this.<br>
><br>
><br>
<br>
</span>What type of operand do you want to change it to? If there is no<br>
"ChangeTo..." function for the new type, I think the best thing to do<br>
would be to add a new "ChangeTo..." function to handle the new type.<br>
<br>
-Tom<br>
<span><br>
> What's the best way to do this without tearing down the instructions and<br>
> using BuildMI?<br>
><br>
> Thanks.<br>
<br>
</span>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank" rel="noreferrer">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank" rel="noreferrer">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
</blockquote></div><br></div>