In addition to creating extended asm
instructions within a function,
there is support for creating “top-level” assembler statements, outside
of any function.
Create a set of top-level asm statements, analogous to those created
by GCC’s “basic” asm
syntax in C at file scope.
For example, to create the equivalent of:
asm ("\t.pushsection .text\n" "\t.globl add_asm\n" "\t.type add_asm, @function\n" "add_asm:\n" "\tmovq %rdi, %rax\n" "\tadd %rsi, %rax\n" "\tret\n" "\t.popsection\n");
the following API calls could be used:
gcc_jit_context_add_top_level_asm (ctxt, NULL, "\t.pushsection .text\n" "\t.globl add_asm\n" "\t.type add_asm, @function\n" "add_asm:\n" "\tmovq %rdi, %rax\n" "\tadd %rsi, %rax\n" "\tret\n" "\t# some asm here\n" "\t.popsection\n");