OpenVM Instruction Mapping
In this document, we provide a mapping between the representation of instructions in the OpenVM codebase and the instructions in the ISA specification.
- Instructions in OpenVM implement the
LocalOpcodetrait. Different groups ofLocalOpcodes from different VM extensions may be combined to form a set of instructions for a customized VM using several extensions. - The PHANTOM instruction may be extended in each VM extension by adding new sub-instructions with different
PhantomDiscriminantvalues.
In the tables below, we provide the mapping between the LocalOpcode and PhantomDiscriminant and instructions and phantom sub-instructions in the ISA specification.
System Instructions
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| System | SystemOpcode::TERMINATE | TERMINATE |
| System | SystemOpcode::PHANTOM | PHANTOM |
Phantom Sub-Instructions
| VM Extension | PhantomDiscriminant | ISA Phantom Sub-Instruction |
|---|---|---|
| System | SysPhantom::Nop | Nop |
| System | SysPhantom::DebugPanic | DebugPanic |
| System | SysPhantom::CtStart | CtStart |
| System | SysPhantom::CtEnd | CtEnd |
RV32IM Extension
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| RV32IM | BaseAluOpcode::ADD | ADD_RV32 |
| RV32IM | BaseAluOpcode::SUB | SUB_RV32 |
| RV32IM | BaseAluOpcode::XOR | XOR_RV32 |
| RV32IM | BaseAluOpcode::OR | OR_RV32 |
| RV32IM | BaseAluOpcode::AND | AND_RV32 |
| RV32IM | ShiftOpcode::SLL | SLL_RV32 |
| RV32IM | ShiftOpcode::SRL | SRL_RV32 |
| RV32IM | ShiftOpcode::SRA | SRA_RV32 |
| RV32IM | LessThanOpcode::SLT | SLT_RV32 |
| RV32IM | LessThanOpcode::SLTU | SLTU_RV32 |
| RV32IM | Rv32LoadStoreOpcode::LOADB | LOADB_RV32 |
| RV32IM | Rv32LoadStoreOpcode::LOADH | LOADH_RV32 |
| RV32IM | Rv32LoadStoreOpcode::LOADW | LOADW_RV32 |
| RV32IM | Rv32LoadStoreOpcode::LOADBU | LOADBU_RV32 |
| RV32IM | Rv32LoadStoreOpcode::LOADHU | LOADHU_RV32 |
| RV32IM | Rv32LoadStoreOpcode::STOREB | STOREB_RV32 |
| RV32IM | Rv32LoadStoreOpcode::STOREH | STOREH_RV32 |
| RV32IM | Rv32LoadStoreOpcode::STOREW | STOREW_RV32 |
| RV32IM | BranchEqualOpcode::BEQ | BEQ_RV32 |
| RV32IM | BranchEqualOpcode::BNE | BNE_RV32 |
| RV32IM | BranchLessThanOpcode::BLT | BLT_RV32 |
| RV32IM | BranchLessThanOpcode::BGE | BGE_RV32 |
| RV32IM | BranchLessThanOpcode::BLTU | BLTU_RV32 |
| RV32IM | BranchLessThanOpcode::BGEU | BGEU_RV32 |
| RV32IM | Rv32JalLuiOpcode::JAL | JAL_RV32 |
| RV32IM | Rv32JalrOpcode::JALR | JALR_RV32 |
| RV32IM | Rv32JalLuiOpcode::LUI | LUI_RV32 |
| RV32IM | Rv32AuipcOpcode::AUIPC | AUIPC_RV32 |
| RV32IM | MulOpcode::MUL | MUL_RV32 |
| RV32IM | MulHOpcode::MULH | MULH_RV32 |
| RV32IM | MulHOpcode::MULHSU | MULHSU_RV32 |
| RV32IM | MulHOpcode::MULHU | MULHU_RV32 |
| RV32IM | DivRemOpcode::DIV | DIV_RV32 |
| RV32IM | DivRemOpcode::DIVU | DIVU_RV32 |
| RV32IM | DivRemOpcode::REM | REM_RV32 |
| RV32IM | DivRemOpcode::REMU | REMU_RV32 |
| RV32IM | Rv32HintStoreOpcode::HINT_STOREW | HINT_STOREW_RV32 |
| RV32IM | Rv32HintStoreOpcode::HINT_BUFFER | HINT_BUFFER_RV32 |
| RV32IM | Pseudo-instruction for STOREW_RV32 | REVEAL_RV32 |
Phantom Sub-Instructions
| VM Extension | PhantomDiscriminant | ISA Phantom Sub-Instruction |
|---|---|---|
| RV32IM | Rv32Phantom::HintInput | Rv32HintInput |
| RV32IM | Rv32Phantom::PrintStr | Rv32PrintStr |
| RV32IM | Rv32Phantom::HintRandom | Rv32HintRandom |
Deferral Extension
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| Deferral | DeferralOpcode::CALL | CALL_RV32 |
| Deferral | DeferralOpcode::OUTPUT | OUTPUT_RV32 |
Keccak Extension
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| Keccak | XorinOpcode::XORIN | XORIN_RV32 |
| Keccak | KeccakfOpcode::KECCAKF | KECCAKF_RV32 |
SHA-2 Extension
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| SHA-2 | Rv32Sha2Opcode::SHA256 | SHA256_UPDATE_RV32 |
| SHA-2 | Rv32Sha2Opcode::SHA512 | SHA512_UPDATE_RV32 |
BigInt Extension
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| BigInt | Rv32BaseAlu256Opcode(BaseAluOpcode::ADD) | ADD256_RV32 |
| BigInt | Rv32BaseAlu256Opcode(BaseAluOpcode::SUB) | SUB256_RV32 |
| BigInt | Rv32BaseAlu256Opcode(BaseAluOpcode::XOR) | XOR256_RV32 |
| BigInt | Rv32BaseAlu256Opcode(BaseAluOpcode::OR) | OR256_RV32 |
| BigInt | Rv32BaseAlu256Opcode(BaseAluOpcode::AND) | AND256_RV32 |
| BigInt | Rv32Shift256Opcode(ShiftOpcode::SLL) | SLL256_RV32 |
| BigInt | Rv32Shift256Opcode(ShiftOpcode::SRL) | SRL256_RV32 |
| BigInt | Rv32Shift256Opcode(ShiftOpcode::SRA) | SRA256_RV32 |
| BigInt | Rv32LessThan256Opcode(LessThanOpcode::SLT) | SLT256_RV32 |
| BigInt | Rv32LessThan256Opcode(LessThanOpcode::SLTU) | SLTU256_RV32 |
| BigInt | Rv32BranchEqual256Opcode(BranchEqualOpcode::BEQ) | BEQ256_RV32 |
| BigInt | Rv32BranchEqual256Opcode(BranchEqualOpcode::BNE) | BNE256_RV32 |
| BigInt | Rv32BranchLessThan256Opcode(BranchLessThanOpcode::BLT) | BLT256_RV32 |
| BigInt | Rv32BranchLessThan256Opcode(BranchLessThanOpcode::BGE) | BGE256_RV32 |
| BigInt | Rv32BranchLessThan256Opcode(BranchLessThanOpcode::BLTU) | BLTU256_RV32 |
| BigInt | Rv32BranchLessThan256Opcode(BranchLessThanOpcode::BGEU) | BGEU256_RV32 |
| BigInt | Rv32Mul256Opcode(MulOpcode::MUL) | MUL256_RV32 |
Algebra Extension
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| Algebra | Rv32ModularArithmeticOpcode::ADD | ADDMOD_RV32<N> |
| Algebra | Rv32ModularArithmeticOpcode::SUB | SUBMOD_RV32<N> |
| Algebra | Rv32ModularArithmeticOpcode::SETUP_ADDSUB | SETUP_ADDSUBMOD_RV32<N> |
| Algebra | Rv32ModularArithmeticOpcode::MUL | MULMOD_RV32<N> |
| Algebra | Rv32ModularArithmeticOpcode::DIV | DIVMOD_RV32<N> |
| Algebra | Rv32ModularArithmeticOpcode::SETUP_MULDIV | SETUP_MULDIVMOD_RV32<N> |
| Algebra | Rv32ModularArithmeticOpcode::IS_EQ | ISEQMOD_RV32<N> |
| Algebra | Rv32ModularArithmeticOpcode::SETUP_ISEQ | SETUP_ISEQMOD_RV32<N> |
| Algebra | Fp2Opcode::ADD | ADD_RV32<Fp2> |
| Algebra | Fp2Opcode::SUB | SUB_RV32<Fp2> |
| Algebra | Fp2Opcode::SETUP_ADDSUB | SETUP_ADDSUB_RV32<Fp2> |
| Algebra | Fp2Opcode::MUL | MUL_RV32<Fp2> |
| Algebra | Fp2Opcode::DIV | DIV_RV32<Fp2> |
| Algebra | Fp2Opcode::SETUP_MULDIV | SETUP_MULDIV_RV32<Fp2> |
Phantom Sub-Instructions
| VM Extension | PhantomDiscriminant | ISA Phantom Sub-Instruction |
|---|---|---|
| Algebra | ModularPhantom::HintNonQr | HintNonQr<N> |
| Algebra | ModularPhantom::HintSqrt | HintSqrt<N> |
Elliptic Curve Extension
Instructions
| VM Extension | LocalOpcode | ISA Instruction |
|---|---|---|
| Elliptic Curve | Rv32WeierstrassOpcode::EC_ADD_NE | EC_ADD_NE_RV32<C> |
| Elliptic Curve | Rv32WeierstrassOpcode::SETUP_EC_ADD_NE | SETUP_EC_ADD_NE_RV32<C> |
| Elliptic Curve | Rv32WeierstrassOpcode::EC_DOUBLE | EC_DOUBLE_RV32<C> |
| Elliptic Curve | Rv32WeierstrassOpcode::SETUP_EC_DOUBLE | SETUP_EC_DOUBLE_RV32<C> |
Pairing Extension
Phantom Sub-Instructions
| VM Extension | PhantomDiscriminant | ISA Phantom Sub-Instruction |
|---|---|---|
| Pairing | PairingPhantom::HintFinalExp | HintFinalExp |