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”-
ccThe compiler building the function. -
opThe OpCode for the unary operation. -
type_idThe asmjit type being operated on (kUInt8, kFloat32, etc.). -
operandThe register for the unary operand. -
resThe 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.
Parameters
Section titled “Parameters”-
opThe OpCode to emit an instruction for (ADD, SUB, etc.) -
type_idThe asmjit type being operated on (kUInt8, kFloat32, etc.).
Returns
Section titled “Returns”instr The correct arithmetic instruction to incorporate into the function.
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”-
ccThe compiler building the function. -
opThe DIV or MOD OpCode to place the result of in res. -
type_idThe asmjit type being operated on (one of the integer types). -
leftThe register for the left-side operand. -
rightThe register for the right-side operand. -
resThe 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”-
ccThe compiler building the function. -
opThe OpCode to emit an instruction for (ADD, SUB, etc.) -
type_idThe asmjit type being operated on (kUInt8, kFloat32, etc.). -
leftThe register for the left-side operand. -
rightThe register for the right-side operand. -
resThe 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.
Parameters
Section titled “Parameters”-
ccThe compiler building the function. -
srcThe register for the input source to be cast. -
src_typeThe asmjit type of the source register. -
dest_typeThe asmjit type of the requested destination register.
Returns
Section titled “Returns”casted The casted 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.
Parameters
Section titled “Parameters”-
ccThe compiler building the function. -
scalarThe scalar to load. -
type_idThe asmjit type being operated on (kUInt8, kFloat32, etc.).
Returns
Section titled “Returns”reg The virtual register with the correct load instruction.
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.
Parameters
Section titled “Parameters”type_idThe asmjit type being operated on (kUInt8, kFloat32, etc.).
Returns
Section titled “Returns”inst The a64 move instruction appropriate for the operand type.
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”-
ccThe compiler constructing the code. -
destThe virtual register that is the destination for the load. -
srcThe 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”-
ccThe compiler constructing the code. -
destThe memory location that is the destination of the store. -
srcThe 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”-
ccThe compiler constructing the code. -
addrThe address pointer for the array. -
indexThe index (linearized) for the element to index from the array. -
valueThe additional register to either store into the array, or hold the value from the array. -
dimThe dimension of the array being accessed (for stride, offset lookup, etc.) -
arr_layoutThe array’s layout. -
type_idThe array’s data type (in the asmjit type system). -
addr_is_sinkIf true, after correct addressing, storevalueinto addr. If false, after addressing, storeaddrintovalue. -
expr_is_soarrAs 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”-
ccThe compiler constructing the code. -
addrThe address pointer for the array. -
indexThe index (linearized) for the element to index from the array. -
offsetThe 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”-
ccThe compiler constructing the code. -
addrThe address pointer for the array. -
indexThe index (linearized) for the element to index from the array. -
strideThe stride for the selected axis. -
offsetThe 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”-
ccThe compiler constructing the code. -
addrThe address pointer for the array. -
indexThe index for the element to index from the array. -
strideThe stride for the current axis. -
offsetThe suboffset for the current axis.