Documentation

LeanGccJit.Core.Asm

libgccjit has some support for directly embedding assembler instructions.

This is based on GCC’s support for inline asm in C code, and the following assumes a familiarity with that functionality. See How to Use Inline Assembly Language in C Code in GCC’s documentation, the "Extended Asm" section in particular.

Please see also:

@[extern lean_gcc_jit_block_add_extended_asm]

Create an ExtendedAsm for an extended asm statement with no control flow (i.e. without the goto qualifier). The parameter asmTemplate corresponds to the AssemblerTemplate within C’s extended asm syntax.

@[extern lean_gcc_jit_extended_asm_as_object]

Upcast an ExtendedAsm to an Object.

@[extern lean_gcc_jit_extended_asm_set_volatile_flag]

Set whether the ExtendedAsm has side-effects, equivalent to the volatile qualifier in C’s extended asm syntax.

@[extern lean_gcc_jit_extended_asm_set_inline_flag]

Set the equivalent of the inline qualifier in C’s extended asm syntax.

@[extern lean_gcc_jit_extended_asm_add_output_operand]

Add an output operand to the extended asm statement. See the "Output Operands" section of the documentation of the C syntax.

symbolicName corresponds to the asmSymbolicName component of C’s extended asm syntax. It is optional. If value is provided, it specifies the symbolic name for the operand.

constraint corresponds to the constraint component of C’s extended asm syntax.

dest corresponds to the cvariablename component of C's extended asm syntax.

-- Example with a NULL symbolic name, the equivalent of:
--   : "=r" (dst)
extAsm.addOutputOperand none "=r" dst
-- Example with a symbolic name ("aIndex"), the equivalent of:
--   : [aIndex] "=r" (index)
extAsm.addOutputOperand "aIndex" "=r" index

This function can’t be called on an asm goto as such instructions can’t have outputs; see the "Goto Labels" section of GCC’s "Extended Asm" documentation.

@[extern lean_gcc_jit_extended_asm_add_input_operand]

Add an input operand to the extended asm statement. See the "Input Operands" section of the documentation of the C syntax.

symbolicName corresponds to the asmSymbolicName component of C’s extended asm syntax. It is optional. If value is provided, it specifies the symbolic name for the operand.

constraint corresponds to the constraint component of C’s extended asm syntax.

src corresponds to the cexpression component of C's extended asm syntax.

@[extern lean_gcc_jit_extended_asm_add_clobber]

Add victim to the list of registers clobbered by the extended asm statement. See the "Clobbers and Scratch Registers" section of the documentation of the C syntax.

Statements with multiple clobbers will require multiple calls, one per clobber.