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:
- Descriptions of
LeanGccJit.Core.ExtendedAsm
in this documentation. - Section "Using Assembly Language with libgccjit" from
libgccjit
’s documentation.
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.
Upcast an ExtendedAsm
to an Object
.
Set whether the ExtendedAsm
has side-effects,
equivalent to the volatile qualifier in C
’s extended asm syntax.
Set the equivalent of the inline
qualifier in C
’s extended asm syntax.
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.
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.
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.