<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/6/26 Marcelo Sousa <span dir="ltr"><<a href="mailto:marceloabsousa@gmail.com" target="_blank">marceloabsousa@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div>Hello,<br><br></div><div>In the following code snippet:<br>%tmp49 = call i64 asm "movq %gs:${1:P},$0", "=r,im,,~{fpsr},~{flags}"(i64* @kernel_stack) #6, !dbg !6625, !srcloc !5841<br>


<br></div><div>I would expect for the inline asm call to receive two arguments because of the ${1:P} corresponding to a %P1 that will append the $1 to %%gs:.<br></div><div>Can someone explain why there is only one argument in this call? <br>
</div></div></blockquote><div><br></div><div>$0 is an output register, so it's just put into the return value of the call.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>

<br></div><div>Moreover, is there any documentation on the constraints that LLVM/clang generates? I'm not entirely sure that they are just a "copy/past" from the asm at the C level, since ~{dirflag}, ~{fpsr} seem to be generated.<br>
</div></div></blockquote><div><br></div><div>LangRef has a basic description of the syntax. Stuff like which registers you're supposed to clobber isn't really well documented, sorry. <br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Finally, how do you deal with inline asm that have multiple outputs</div></div></blockquote><div><br></div><div>IIRC the first output is returned, other values are returned indirectly.  That said, the easiest way to answer this sort of question is just to look at clang's output.<br>
</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>and what's the mechanism used by JIT to support inline asm?<br><br></div></div></blockquote><div>

LLVM has a builtin assembler we can use to emit both object files on disk and JIT'ed functions in memory.  (Actually, there are two versions of the JIT at the moment, but you probably don't need to worry about that.)<br>

<br></div><div>-Eli <br></div></div><br></div></div>