Skip to content

x86

Return Name Description
void unary_operation Determine the appropriate x86 instruction for the unary operation.
asmjit::InstId get_binary_arithmetic_inst Determine the appropriate x86 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 x86 load instruction for a scalar of the specified type.
asmjit::InstId get_move_inst Emit the correct x86 move instruction for the specified type.
void scaled_address_array Advance the pointer for the underlying data of an NCArray* or SOArray* and index into it using x86 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*.

void unary_operation(asmjit::x86::Compiler & cc, OpCode op, asmjit::TypeId type_id, asmjit::Reg & operand, asmjit::Reg & res)

Determine the appropriate x86 instruction for the unary operation.

This function will incorporate the correct x86 instruction to perform the unary operation considering signed/unsignededness, width, and floating-point/integer type of the operand.

  • cc The compiler building the function.

  • op The OpCode for the unary operation.

  • type_id The asmjit type being operated on (kUInt8, kFloat32, etc.).

  • operand The register for the unary operand.

  • res The register for the result.


asmjit::InstId get_binary_arithmetic_inst(OpCode op, asmjit::TypeId type_id)

Determine the appropriate x86 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.

  • op The OpCode to emit an instruction for (ADD, SUB, etc.)

  • type_id The asmjit type being operated on (kUInt8, kFloat32, etc.).

instr The correct arithmetic instruction to incorporate into the function.


void integer_div_mod(asmjit::x86::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 x86 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.

  • cc The compiler building the function.

  • op The DIV or MOD OpCode to place the result of in res.

  • type_id The asmjit type being operated on (one of the integer types).

  • left The register for the left-side operand.

  • right The register for the right-side operand.

  • res The register for the result.


void binary_compare(asmjit::x86::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.

  • cc The compiler building the function.

  • op The OpCode to emit an instruction for (ADD, SUB, etc.)

  • type_id The asmjit type being operated on (kUInt8, kFloat32, etc.).

  • left The register for the left-side operand.

  • right The register for the right-side operand.

  • res The register for the result.


asmjit::Reg cast_register(asmjit::x86::Compiler & cc, asmjit::Reg src, asmjit::TypeId src_type, asmjit::TypeId dest_type)

Convert a register of one type to another.

  • cc The compiler building the function.

  • src The register for the input source to be cast.

  • src_type The asmjit type of the source register.

  • dest_type The asmjit type of the requested destination register.

casted The casted register


asmjit::Reg load_constant(asmjit::x86::Compiler & cc, Scalar scalar, asmjit::TypeId type_id)

Emit the correct x86 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.

  • cc The compiler building the function.

  • scalar The scalar to load.

  • type_id The asmjit type being operated on (kUInt8, kFloat32, etc.).

reg The virtual register with the correct load instruction.


asmjit::InstId get_move_inst(asmjit::TypeId type_id)

Emit the correct x86 move instruction for the specified type.

This function will provide the correct instruction to emit for integers, or floating point types of different precision.

  • type_id The asmjit type being operated on (kUInt8, kFloat32, etc.).

inst The x86 move instruction appropriate for the operand type.


void scaled_address_array(asmjit::x86::Compiler & cc, asmjit::x86::Gp & addr, asmjit::x86::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 x86 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 x86 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.

  • cc The compiler constructing the code.

  • addr The address pointer for the array.

  • index The index (linearized) for the element to index from the array.

  • value The additional register to either store into the array, or hold the value from the array.

  • dim The dimension of the array being accessed (for stride, offset lookup, etc.)

  • arr_layout The array’s layout.

  • type_id The array’s data type (in the asmjit type system).

  • addr_is_sink If true, after correct addressing, store value into addr. If false, after addressing, store addr into value.

  • expr_is_soarr As layout is always passed as [SOArrayPolicy](api-ncarray-SOArrayPolicy.md#soarraypolicy), if false, convert to [NCOffsetsPolicy](api-ncarray-NCOffsetsPolicy.md#ncoffsetspolicy).


void advance_ncoffsets_pointer_axis(asmjit::x86::Compiler & cc, asmjit::x86::Gp & addr, asmjit::x86::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.

  • cc The compiler constructing the code.

  • addr The address pointer for the array.

  • index The index (linearized) for the element to index from the array.

  • offset The offset for the pointer axis. Should be >= 0. This is not checked.


void advance_ncoffsets_strided_axis(asmjit::x86::Compiler & cc, asmjit::x86::Gp & addr, asmjit::x86::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.

  • cc The compiler constructing the code.

  • addr The address pointer for the array.

  • index The index (linearized) for the element to index from the array.

  • stride The stride for the selected axis.

  • offset The offset for the non-pointer axis.


void advance_soarray_axis(asmjit::x86::Compiler & cc, asmjit::x86::Gp & addr, asmjit::x86::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.

  • cc The compiler constructing the code.

  • addr The address pointer for the array.

  • index The index for the element to index from the array.

  • stride The stride for the current axis.

  • offset The suboffset for the current axis.