llvm, new language and inline assembly.

Hello,

I am creating a very small language which needs inline assembly, with llvm as a compiler framework.

On x86, I am interested in the "out","in","mfence","lfence".. and other specific sse operations.

How may I tell llvm about them in my language?

-> I read that "module asm" should be my companion but I am not sure how it works (the doc about it, is only a few lines of not so complete information. What is the syntax when the final register the value comes from or goes in doesn't matter? so no explicit %%rax or %%rdx but rather something like %%r?x; here the question mark let the compiler to choose the best register for the value);

I need the same functionalities as "asm" in C but in my language basically.

Thanks
--е║
Alex

-> I read that "module asm" should be my companion but I am not sure how it works (the doc about it, is only a few lines of not so complete information.

The documentation is unfortunately lacking. But you almost certainly
don't want module-level inline asm; you probably want a "%res = call
TYPE asm ..." type thing instead.

What is the syntax when the final register the value comes from or goes in doesn't matter? so no explicit %%rax or %%rdx but rather something like %%r?x; here the question mark let the compiler to choose the best register for the value);

Our inline asm is based heavily on GCC style syntax. The main change
is that a "%N" or "%[whatever]" argument to reference an in/out value
becomes $N. Operand modifiers are written "${N:mod}" rather than
"%modN".

The best way to get familiar with it is probably to write what you
want in GCC asm and run "clang -S -o- -emit-llvm" to see what IR gets
produced.

Cheers.

Tim.

Will do that Tim,

Thanks a lot :slight_smile:

--е║
Alex