<p dir="ltr">He's trying to load the memory address of the pointer. The (add r, (load addr)) is what we use for direct memory.</p>
<p dir="ltr">I think you'll probably have to do a post iSel MI pass. </p>
<div class="gmail_extra"><br><div class="gmail_quote">On Oct 12, 2016 17:22, "Alex Bradley via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr"><br>
> You probably want to look at the x86 backend; it has a lot of instructions which involve both computation and memory.  Take the following IR, a variant of your example:<br>
><br>
> define void @foo(i32 *%a, i32 *%b, i32 *%c) {<br>
> entry:<br>
>   %0 = load i32, i32* %a, align 4<br>
>   %1 = load i32, i32* %b, align 4<br>
><br>
>   %add = add nsw i32 %1, %0<br>
>   store i32 %add, i32* %c, align 4<br>
>   ret void<br>
> }<br>
><br>
> The x86 backend generates the following:<br>
><br>
>         movl    (%rsi), %eax<br>
>         addl    (%rdi), %eax<br>
>         movl    %eax, (%rdx)<br>
>         retq<br>
><br>
> Note in particular the memory operand embedded into the addition.<br>
><br>
> The way the LLVM x86 backend models this is just to pattern match it during instruction selection: it matches a pattern like  (add r, (load addr)) to a single instruction.</p>
<p dir="ltr">Thanks Eli. I will have a look into it. However, the above x86 code loads the content of the memory location into eax register and adds that register with another memory location. </p>
<p dir="ltr">My target loads the address of the memory locations in the registers for both the operands and then uses add operation on the registers in an indirect way. How do I specify that in .td files so that it matches in ISelDAGToDAG select() function? Any small example?</p>
<p dir="ltr">Thanks for example code :)</p>
<p dir="ltr">Regards,<br>
Alex<br></p>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div></div>