a64
Functions
Section titled “Functions”| Return | Name | Description |
|---|---|---|
void |
unary_operation |
Determine the appropriate a64 instruction for the unary operation. |
asmjit::InstId |
get_binary_arithmetic_inst |
Determine the appropriate a64 arithmetic instruction given the operation and working type. |
void |
integer_div_mod |
Perform integer division or modulo/remainder operations. |
void |
binary_compare |
Perform the appropriate binary comparison. |
asmjit::Reg |
cast_register |
Convert a register of one type to another. |
asmjit::Reg |
load_constant |
Emit the correct a64 load instruction for a scalar of the specified type. |
asmjit::InstId |
get_move_inst |
Emit the correct a64 move instruction for the specified type. |
void |
emit_load |
Emit the correct A64 instruction to load a value from memory into a register. |
void |
emit_store |
Emit the correct A64 instruction to store a value from a register into memory. |
void |
scaled_address_array |
Advance the pointer for the underlying data of an NCArray* or SOArray* and index into it using a64 scaled hardware addressing. |
void |
advance_ncoffsets_pointer_axis |
Advance the pointer for the underlying data of an NCArray*. |
void |
advance_ncoffsets_strided_axis |
Advance the pointer for the underlying data of an NCArray*. |
void |
advance_soarray_axis |
Advance the pointer for the underlying data of an SOArray*. |
unary_operation
Section titled “unary_operation”void unary_operation(asmjit::a64::Compiler & cc, OpCode op, asmjit::TypeId type_id, asmjit::Reg & operand, asmjit::Reg & res)Determine the appropriate a64 instruction for the unary operation.
This function will incorporate the correct a64 instruction to perform the unary operation considering signed/unsignededness, width, and floating-point/integer type of the operand.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler building the function. |
op |
[OpCode](api-ncarray.md#opcode) |
The OpCode for the unary operation. |
type_id |
asmjit::TypeId |
The asmjit type being operated on (kUInt8, kFloat32, etc.). |
operand |
asmjit::Reg & |
The register for the unary operand. |
res |
asmjit::Reg & |
The register for the result. |
get_binary_arithmetic_inst
Section titled “get_binary_arithmetic_inst”asmjit::InstId get_binary_arithmetic_inst(OpCode op, asmjit::TypeId type_id)Determine the appropriate a64 arithmetic instruction given the operation and working type.
This function will provide the correct instruction to emit given the type under consideration. This accounts for signed/unsigned, width, and floating-point/integer differences.
Returns
Section titled “Returns”instr The correct arithmetic instruction to incorporate into the function.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
op |
[OpCode](api-ncarray.md#opcode) |
The OpCode to emit an instruction for (ADD, SUB, etc.) |
type_id |
asmjit::TypeId |
The asmjit type being operated on (kUInt8, kFloat32, etc.). |
integer_div_mod
Section titled “integer_div_mod”void integer_div_mod(asmjit::a64::Compiler & cc, OpCode op, asmjit::TypeId type_id, asmjit::Reg & left, asmjit::Reg & right, asmjit::Reg & res)Perform integer division or modulo/remainder operations.
For a64 these are calculated simultaneously, but must be calculated in specific registers. Additionally, since the rest of the compiler setup has been setup using virtual register allocation via the Compiler class, the collisions between those virtual allocations and the references to the specific physical registers must be handled. This function does this for all widths of integers, and signed/ unsigned handling.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler building the function. |
op |
[OpCode](api-ncarray.md#opcode) |
The DIV or MOD OpCode to place the result of in res. |
type_id |
asmjit::TypeId |
The asmjit type being operated on (one of the integer types). |
left |
asmjit::Reg & |
The register for the left-side operand. |
right |
asmjit::Reg & |
The register for the right-side operand. |
res |
asmjit::Reg & |
The register for the result. |
binary_compare
Section titled “binary_compare”void binary_compare(asmjit::a64::Compiler & cc, OpCode op, asmjit::TypeId type_id, asmjit::Reg & left, asmjit::Reg & right, asmjit::Reg & res)Perform the appropriate binary comparison.
This function will emit the correct set of instructions accounting for signed or unsigned values, different widths, and integer/floating-point differences.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler building the function. |
op |
[OpCode](api-ncarray.md#opcode) |
The OpCode to emit an instruction for (ADD, SUB, etc.) |
type_id |
asmjit::TypeId |
The asmjit type being operated on (kUInt8, kFloat32, etc.). |
left |
asmjit::Reg & |
The register for the left-side operand. |
right |
asmjit::Reg & |
The register for the right-side operand. |
res |
asmjit::Reg & |
The register for the result. |
cast_register
Section titled “cast_register”asmjit::Reg cast_register(asmjit::a64::Compiler & cc, asmjit::Reg src, asmjit::TypeId src_type, asmjit::TypeId dest_type)Convert a register of one type to another.
Returns
Section titled “Returns”casted The casted register
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler building the function. |
src |
asmjit::Reg |
The register for the input source to be cast. |
src_type |
asmjit::TypeId |
The asmjit type of the source register. |
dest_type |
asmjit::TypeId |
The asmjit type of the requested destination register. |
load_constant
Section titled “load_constant”asmjit::Reg load_constant(asmjit::a64::Compiler & cc, Scalar scalar, asmjit::TypeId type_id)Emit the correct a64 load instruction for a scalar of the specified type.
This function will provide the correct instruction to emit given the type under consideration. This accounts for signed/unsigned, width, and floating-point/integer differences.
Returns
Section titled “Returns”reg The virtual register with the correct load instruction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler building the function. |
scalar |
[Scalar](api-ncarray.md#scalar) |
The scalar to load. |
type_id |
asmjit::TypeId |
The asmjit type being operated on (kUInt8, kFloat32, etc.). |
get_move_inst
Section titled “get_move_inst”asmjit::InstId get_move_inst(asmjit::TypeId type_id)Emit the correct a64 move instruction for the specified type.
This function will provide the correct instruction to emit for integers, or floating point types of different precision.
Returns
Section titled “Returns”inst The a64 move instruction appropriate for the operand type.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
type_id |
asmjit::TypeId |
The asmjit type being operated on (kUInt8, kFloat32, etc.). |
emit_load
Section titled “emit_load”void emit_load(asmjit::a64::Compiler & cc, asmjit::Reg & dest, const asmjit::a64::Mem & src)Emit the correct A64 instruction to load a value from memory into a register.
This function will perform the correct conversion to general purpose or vector register of the destination register as necessary.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler constructing the code. |
dest |
asmjit::Reg & |
The virtual register that is the destination for the load. |
src |
const asmjit::a64::Mem & |
The memory location that is the source of the load. |
emit_store
Section titled “emit_store”void emit_store(asmjit::a64::Compiler & cc, const asmjit::a64::Mem & dest, asmjit::Reg & src)Emit the correct A64 instruction to store a value from a register into memory.
This function will perform the correct conversion to general purpose or vector register of the source register as necessary.
(NOTE: The fact that the asmjit mem location dest is const does not mean that it cannot be stored to.)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler constructing the code. |
dest |
const asmjit::a64::Mem & |
The memory location that is the destination of the store. |
src |
asmjit::Reg & |
The virtual register that is the source of the store. |
scaled_address_array
Section titled “scaled_address_array”void scaled_address_array(asmjit::a64::Compiler & cc, asmjit::a64::Gp & addr, asmjit::a64::Gp & index, asmjit::Reg & value, ssize_t dim, const SOArrayPolicy & arr_layout, asmjit::TypeId type_id, bool addr_is_sink = false, bool expr_is_soarr = false)Advance the pointer for the underlying data of an NCArray* or SOArray* and index into it using a64 scaled hardware addressing.
This function takes two registers, allowing the caller to determine whether the value of the non-array register should get stored in the array, or whether the value from the array gets stored in the non-array register.
The function will deal with correct dereferencing and offset handling for both SOArrayPolicy and NCOffsetsPolicy type arrays. The scaled addressing makes use of an a64 feature reducing instruction count when addressing a pointer using the form [base + index * scale] and the scale multiplier is 1, 2, 4 or 8. This is only applied for those cases, and for the non-pointer axis case. In all other cases, the full set of multiply/add instructions are used as a fallback.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler constructing the code. |
addr |
asmjit::a64::Gp & |
The address pointer for the array. |
index |
asmjit::a64::Gp & |
The index (linearized) for the element to index from the array. |
value |
asmjit::Reg & |
The additional register to either store into the array, or hold the value from the array. |
dim |
ssize_t |
The dimension of the array being accessed (for stride, offset lookup, etc.) |
arr_layout |
const [SOArrayPolicy](api-ncarray-SOArrayPolicy.md#soarraypolicy) & |
The array’s layout. |
type_id |
asmjit::TypeId |
The array’s data type (in the asmjit type system). |
addr_is_sink |
bool |
If true, after correct addressing, store value into addr. If false, after addressing, store addr into value. |
expr_is_soarr |
bool |
As layout is always passed as [SOArrayPolicy](api-ncarray-SOArrayPolicy.md#soarraypolicy), if false, convert to [NCOffsetsPolicy](api-ncarray-NCOffsetsPolicy.md#ncoffsetspolicy). |
advance_ncoffsets_pointer_axis
Section titled “advance_ncoffsets_pointer_axis”void advance_ncoffsets_pointer_axis(asmjit::a64::Compiler & cc, asmjit::a64::Gp & addr, asmjit::a64::Gp & index, ssize_t offset)Advance the pointer for the underlying data of an NCArray*.
This function expects the pointer to have already been advanced along the prior dimensions. It will advance it further for the current axis, using the provided index, stride and offset.
This function moves along a POINTER axis of an NCArray*. This must be checked by the caller. For pointer axes, use the advance_ncoffsets_strided_axis function.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler constructing the code. |
addr |
asmjit::a64::Gp & |
The address pointer for the array. |
index |
asmjit::a64::Gp & |
The index (linearized) for the element to index from the array. |
offset |
ssize_t |
The offset for the pointer axis. Should be >= 0. This is not checked. |
advance_ncoffsets_strided_axis
Section titled “advance_ncoffsets_strided_axis”void advance_ncoffsets_strided_axis(asmjit::a64::Compiler & cc, asmjit::a64::Gp & addr, asmjit::a64::Gp & index, ssize_t stride, ssize_t offset)Advance the pointer for the underlying data of an NCArray*.
This function expects the pointer to have already been advanced along the prior dimensions. It will advance it further for the current axis, using the provided index, stride and offset.
This function moves along a NON-pointer axis of an NCArray*. This must be checked by the caller. For pointer axes, use the advance_ncoffsets_pointer_axis function.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler constructing the code. |
addr |
asmjit::a64::Gp & |
The address pointer for the array. |
index |
asmjit::a64::Gp & |
The index (linearized) for the element to index from the array. |
stride |
ssize_t |
The stride for the selected axis. |
offset |
ssize_t |
The offset for the non-pointer axis. |
advance_soarray_axis
Section titled “advance_soarray_axis”void advance_soarray_axis(asmjit::a64::Compiler & cc, asmjit::a64::Gp & addr, asmjit::a64::Gp & index, ssize_t stride, ssize_t suboffset)Advance the pointer for the underlying data of an SOArray*.
This function expects the pointer to have already been advanced along the prior dimensions. It will advance it further for the current axis, using the provided index, stride and suboffset.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cc |
asmjit::a64::Compiler & |
The compiler constructing the code. |
addr |
asmjit::a64::Gp & |
The address pointer for the array. |
index |
asmjit::a64::Gp & |
The index for the element to index from the array. |
stride |
ssize_t |
The stride for the current axis. |