Inline asm call argument mismatch?

Hello,

In the following code snippet:
%tmp49 = call i64 asm “movq %gs:${1:P},$0”, “=r,im,~{fpsr},~{flags}”(i64* @kernel_stack) #6, !dbg !6625, !srcloc !5841

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:.

Can someone explain why there is only one argument in this call?

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.

Finally, how do you deal with inline asm that have multiple outputs and what’s the mechanism used by JIT to support inline asm?

Regards,
Marcelo

Hello,

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

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:.
Can someone explain why there is only one argument in this call?

$0 is an output register, so it's just put into the return value of the
call.

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.

LangRef has a basic description of the syntax. Stuff like which registers
you're supposed to clobber isn't really well documented, sorry.

Finally, how do you deal with inline asm that have multiple outputs

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.

and what's the mechanism used by JIT to support inline asm?

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.)

-Eli