<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 3, 2017 at 6:19 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">2017-08-03 8:58 GMT-07:00 Johan Engelen via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>>:<br>
> The error is gone after removing (or reducing) the alignment of `%a`. This<br>
> makes me believe that our inline asm syntax is correct to add an offset to a<br>
> pointer: " 4+$0 ".<br>
<br>
</span>The AT&T syntax for a displaced address doesn't have the '+'; it's<br>
just "4(%rsp)" so you should change the IR to "4$0".<br>
<br>
LLVM appears to be optimizing the addressing mode, and the optimizer<br>
is being more lenient on this detail so you're getting lucky when the<br>
+4 can be combined with an existing %rsp offset.</blockquote><div><br></div><div>Things break down when part of the offset is a linktime constant:</div><div><br></div><div>```</div><div><div><font face="monospace, monospace">source_filename = "asanasm.d"</font></div><div><font face="monospace, monospace">target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"</font></div><div><font face="monospace, monospace">target triple = "x86_64-pc-windows-msvc"</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">@globVar = global [2 x i32] [i32 66051, i32 66051]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">define void @_D7asanasm8offconstFZv() {</font></div><div><font face="monospace, monospace">  call void asm sideeffect "movdqa 4$0, %xmm7", "*m,~{xmm7}"([2 x i32]* @globVar)</font></div><div><font face="monospace, monospace">  ret void</font></div><div><font face="monospace, monospace">}</font></div></div><div>```</div><div><br></div><div>results in:</div><div><div><font face="monospace, monospace"><inline asm>:1:10: error: unexpected token in argument list</font></div><div><font face="monospace, monospace">        movdqa 4globVar(%rip), %xmm7</font></div></div><div><br></div><div>So in that case, I do have to add the '+' to make it work ("4+$0").</div><div><br></div><div>So depending on the pointer argument, I need to write a + or without +, complicating automatic codegen.</div><div><br></div><div>Thanks for the help,</div><div>  Johan</div><div><br></div></div><br></div></div>