Instruction DB

Instruction database (introspection, read/write, validation, ...).

Overview

AsmJit provides a public instruction database that can be used to query information about a complete instruction. The instruction database requires the knowledge of the following:

  • BaseInst - Base instruction that contains instruction id, options, and a possible extra-register that represents either REP prefix counter or AVX-512 selector (mask).
  • Operand - Represents operands of an instruction.

Each instruction can be then queried for the following information:

  • InstRWInfo - Read/write information of instruction and its oprands.
  • OpRWInfo - Read/write information of a single operand, part of InstRWInfo data structure.
  • BaseFeatures - CPU features required to execute the instruction.

In addition to query functionality AsmJit is also able to validate whether an instruction and its operands are valid. This is useful for making sure that what user tries to emit is correct and it can be also used by other projects that parse user input, like AsmTK project.

Query API

The instruction query API is provided by InstAPI namespace. The following queries are possible:

  • InstAPI::queryRWInfo() - queries read/write information of the given instruction and its operands. Includes also CPU flags read/written.
  • InstAPI::queryFeatures() - queries CPU features that are required to execute the given instruction. A full instruction with operands must be given as some architectures like X86 may require different features for the same instruction based on its operands.
  • asmjit_test_x86_instinfo.cpp can be also used as a reference about accessing instruction information.

Validation API

The instruction validation API is provided by InstAPI namespace in the similar fashion like the Query API, however, validation can also be turned on at BaseEmitter level. The following is possible:

Namespaces

Classes