AsmJit
Low-Latency Machine Code Generation
Function frame.
Function frame is used directly by prolog and epilog insertion (PEI) utils. It provides information necessary to insert a proper and ABI conforming prolog and epilog. Function frame calculation is based on CallConv
and other function attributes.
Function frame provides a way to tell prolog/epilog inserter to use AVX instructions instead of SSE. Use setAvxEnabled()
and setAvx512Enabled()
to enable AVX and/or AVX-512, respectively. Enabling AVX-512 is mostly for Compiler as it would use 32 SIMD registers instead of 16 when enabled.
Various properties can contribute to the size and structure of the function frame. The function frame in most cases won't use all of the properties illustrated (for example Spill Zone and Red Zone are never used together).
Creates a default constructed function frame, which has initialized all members to their default values.
Creates a copy of other
function frame.
Initializes the function frame based on func
detail.
Resets the function frame into its default constructed state.
Copy assignment - function frame is copy assignable.
Returns the target architecture of the function frame.
Returns function frame attributes, see Attributes
.
Checks whether the FuncFame contains an attribute attr
.
Adds attributes attrs
to the FuncFrame.
Clears attributes attrs
from the FrameFrame.
Tests whether the function has variable number of arguments.
Sets the variable arguments flag.
Resets variable arguments flag.
Tests whether the function preserves frame pointer (EBP|ESP on X86).
Enables preserved frame pointer.
Disables preserved frame pointer.
Tests whether the function calls other functions.
Sets FuncAttributes::kHasFuncCalls
to true.
Sets FuncAttributes::kHasFuncCalls
to false.
Tests whether the function uses indirect branch protection, see FuncAttributes::kIndirectBranchProtection.
Enabled indirect branch protection (sets FuncAttributes::kIndirectBranchProtection
attribute to true).
Disables indirect branch protection (sets FuncAttributes::kIndirectBranchProtection
attribute to false).
Tests whether the function has AVX enabled.
Enables AVX use.
Disables AVX use.
Tests whether the function has AVX-512 enabled.
Enables AVX-512 use.
Disables AVX-512 use.
Tests whether the function has MMX cleanup - 'emms' instruction in epilog.
Enables MMX cleanup.
Disables MMX cleanup.
Tests whether the function has AVX cleanup - 'vzeroupper' instruction in epilog.
Enables AVX cleanup.
Disables AVX cleanup.
Tests whether the function uses call stack.
Tests whether the function uses local stack.
Tests whether vector registers can be saved and restored by using aligned reads and writes.
Tests whether the function has to align stack dynamically.
Tests whether the calling convention specifies 'RedZone'.
Tests whether the calling convention specifies 'SpillZone'.
Returns the size of 'RedZone'.
Returns the size of 'SpillZone'.
Resets the size of red zone, which would disable it entirely.
Returns natural stack alignment (guaranteed stack alignment upon entry).
Returns natural stack alignment (guaranteed stack alignment upon entry).
Tests whether the callee must adjust SP before returning (X86-STDCALL only)
Returns home many bytes of the stack the callee must adjust before returning (X86-STDCALL only)
Returns call stack alignment.
Returns local stack alignment.
Returns final stack alignment (the maximum value of call, local, and natural stack alignments).
Sets call stack alignment.
Sets local stack alignment.
Combines call stack alignment with alignment
, updating it to the greater value.
Combines local stack alignment with alignment
, updating it to the greater value.
Returns call stack size.
Returns local stack size.
Sets call stack size.
Sets local stack size.
Combines call stack size with size
, updating it to the greater value.
Combines local stack size with size
, updating it to the greater value.
Returns final stack size (only valid after the FuncFrame is finalized).
Returns an offset to access the local stack (non-zero only if call stack is used).
Tests whether the function prolog/epilog requires a memory slot for storing unaligned SP.
Returns a memory offset used to store DA (dynamic alignment) slot (relative to SP).
Returns mask of registers of the given register group
that are modified by the function.
The engine would then calculate which registers must be saved & restored by the function by using the data provided by the calling convention.
Sets which registers (as a mask) are modified by the function.
addDirtyRegs()
to modify the existing register mask. Adds which registers (as a mask) are modified by the function.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
A helper function to set all registers from all register groups dirty.
A helper function to set all registers from the given register group
dirty.
Returns a calculated mask of registers of the given group
that will be saved and restored in the function's prolog and epilog, respectively.
The register mask is calculated from both dirtyRegs
(provided by user) and preservedMask
(provided by the calling convention).
Returns the mask of preserved registers of the given register group
.
Preserved registers are those that must survive the function call unmodified. The function can only modify preserved registers it they are saved and restored in function's prolog and epilog, respectively.
Returns the size of a save-restore are for the required register group
.
Returns stack size required to save/restore registers via push/pop.
Returns an offset to the stack where registers are saved via push/pop.
Returns stack size required to save/restore extra registers that don't use push/pop/.
Returns an offset to the stack where extra registers are saved.
Tests whether the functions contains stack adjustment.
Returns function's stack adjustment used in function's prolog and epilog.
If the returned value is zero it means that the stack is not adjusted. This can mean both that the stack is not used and/or the stack is only adjusted by instructions that pust/pop registers into/from stack.
Function attributes.
Target architecture.
SP register ID (to access call stack and local stack).
SA register ID (to access stack arguments).
Red zone size (copied from CallConv).
Spill zone size (copied from CallConv).
Natural stack alignment (copied from CallConv).
Minimum stack alignment to turn on dynamic alignment.
Call stack alignment.
Local stack alignment.
Final stack alignment.
Adjustment of the stack before returning (X86-STDCALL).
Call stack size.
Local stack size.
Final stack size (sum of call stack and local stack).
Local stack offset (non-zero only if call stack is used).
Offset relative to SP that contains previous SP (before alignment).
Offset of the first stack argument relative to SP.
Offset of the first stack argument relative to SA (_saRegId or FP).
Local stack adjustment in prolog/epilog.
Registers that are dirty.
Registers that must be preserved (copied from CallConv).
Size to save/restore per register group.
Alignment of save/restore area per register group.
Stack size required to save registers with push/pop.
Stack size required to save extra registers that cannot use push/pop.
Offset where registers saved/restored via push/pop are stored.
Offset where extra registers that cannot use push/pop are stored.