Skip to content

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 LocalOpcode trait. Different groups of LocalOpcodes 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 PhantomDiscriminant values.

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 ExtensionLocalOpcodeISA Instruction
SystemSystemOpcode::TERMINATETERMINATE
SystemSystemOpcode::PHANTOMPHANTOM
SystemPublishOpcode::PUBLISHPUBLISH

Phantom Sub-Instructions

VM ExtensionPhantomDiscriminantISA Phantom Sub-Instruction
SystemSysPhantom::NopNOP
SystemSysPhantom::DebugPanicDEBUG_PANIC
SystemSysPhantom::CtStartCT_START
SystemSysPhantom::CtEndCT_END

RV32IM Extension

Instructions

VM ExtensionLocalOpcodeISA Instruction
RV32IMBaseAluOpcode::ADDADD_RV32
RV32IMBaseAluOpcode::SUBSUB_RV32
RV32IMBaseAluOpcode::XORXOR_RV32
RV32IMBaseAluOpcode::OROR_RV32
RV32IMBaseAluOpcode::ANDAND_RV32
RV32IMShiftOpcode::SLLSLL_RV32
RV32IMShiftOpcode::SRLSRL_RV32
RV32IMShiftOpcode::SRASRA_RV32
RV32IMLessThanOpcode::SLTSLT_RV32
RV32IMLessThanOpcode::SLTUSLTU_RV32
RV32IMRv32LoadStoreOpcode::LOADBLOADB_RV32
RV32IMRv32LoadStoreOpcode::LOADHLOADH_RV32
RV32IMRv32LoadStoreOpcode::LOADWLOADW_RV32
RV32IMRv32LoadStoreOpcode::LOADBULOADBU_RV32
RV32IMRv32LoadStoreOpcode::LOADHULOADHU_RV32
RV32IMRv32LoadStoreOpcode::STOREBSTOREB_RV32
RV32IMRv32LoadStoreOpcode::STOREHSTOREH_RV32
RV32IMRv32LoadStoreOpcode::STOREWSTOREW_RV32
RV32IMBranchEqualOpcode::BEQBEQ_RV32
RV32IMBranchEqualOpcode::BNEBNE_RV32
RV32IMBranchLessThanOpcode::BLTBLT_RV32
RV32IMBranchLessThanOpcode::BGEBGE_RV32
RV32IMBranchLessThanOpcode::BLTUBLTU_RV32
RV32IMBranchLessThanOpcode::BGEUBGEU_RV32
RV32IMRv32JalLuiOpcode::JALJAL_RV32
RV32IMRv32JalrOpcode::JALRJALR_RV32
RV32IMRv32JalLuiOpcode::LUILUI_RV32
RV32IMRv32AuipcOpcode::AUIPCAUIPC_RV32
RV32IMMulOpcode::MULMUL_RV32
RV32IMMulHOpcode::MULHMULH_RV32
RV32IMMulHOpcode::MULHSUMULHSU_RV32
RV32IMMulHOpcode::MULHUMULHU_RV32
RV32IMDivRemOpcode::DIVDIV_RV32
RV32IMDivRemOpcode::DIVUDIVU_RV32
RV32IMDivRemOpcode::REMREM_RV32
RV32IMDivRemOpcode::REMUREMU_RV32
RV32IMRv32HintStoreOpcode::HINT_STOREWHINT_STOREW_RV32
RV32IMRv32HintStoreOpcode::HINT_BUFFERHINT_BUFFER_RV32
RV32IMPseudo-instruction for STOREW_RV32REVEAL_RV32
RV32IMPseudo-instruction for STOREW_RV32NATIVE_STOREW

Phantom Sub-Instructions

VM ExtensionPhantomDiscriminantISA Phantom Sub-Instruction
RV32IMRv32Phantom::HintInputRv32HintInput
RV32IMRv32Phantom::PrintStrRv32PrintStr
RV32IMRv32Phantom::HintRandomRv32HintRandom
RV32IMRv32Phantom::HintLoadByKeyRv32HintLoadByKey

Native Extension

Instructions

VM ExtensionLocalOpcodeISA Instruction
NativeNativeLoadStoreOpcode::LOADWLOADW
NativeNativeLoadStoreOpcode::STOREWSTOREW
NativeNativeLoadStore4Opcode::LOADW4LOADW4
NativeNativeLoadStore4Opcode::STOREW4STOREW4
NativeNativeJalOpcode::JALJAL
NativeNativeRangeCheckOpcode::RANGE_CHECKRANGE_CHECK
NativeNativeBranchEqualOpcode::BEQBEQ
NativeNativeBranchEqualOpcode::BNEBNE
NativeNativeLoadStoreOpcode::HINT_STOREWHINT_STOREW
NativeNativeLoadStore4Opcode::HINT_STOREW4HINT_STOREW4
NativeCastfOpcode::CASTFCASTF
NativeFieldArithmeticOpcode::ADDADDF
NativeFieldArithmeticOpcode::SUBSUBF
NativeFieldArithmeticOpcode::MULMULF
NativeFieldArithmeticOpcode::DIVDIVF
NativeFieldExtensionOpcode::FE4ADDFE4ADD
NativeFieldExtensionOpcode::FE4SUBFE4SUB
NativeFieldExtensionOpcode::BBE4MULBBE4MUL
NativeFieldExtensionOpcode::BBE4DIVBBE4DIV
NativePoseidon2Opcode::COMP_POS2COMP_POS2
NativePoseidon2Opcode::PERM_POS2PERM_POS2
NativeVerifyBatchOpcode::VERIFY_BATCHVERIFY_BATCH
NativeFriOpcode::FRI_REDUCED_OPENINGFRI_REDUCED_OPENING

Phantom Sub-Instructions

VM ExtensionPhantomDiscriminantISA Phantom Sub-Instruction
NativeNativePhantom::PrintNativePrint
NativeNativePhantom::HintInputNativeHintInput
NativeNativePhantom::HintBitsNativeHintBits
NativeNativePhantom::HintLoadNativeHintLoad

Keccak Extension

Instructions

VM ExtensionLocalOpcodeISA Instruction
KeccakRv32KeccakOpcode::KECCAK256KECCAK256_RV32

SHA2-256 Extension

Instructions

VM ExtensionLocalOpcodeISA Instruction
SHA2-256Rv32Sha256Opcode::SHA256SHA256_RV32

BigInt Extension

Instructions

VM ExtensionLocalOpcodeISA Instruction
BigIntRv32BaseAlu256Opcode::ADD256ADD256_RV32
BigIntRv32BaseAlu256Opcode::SUB256SUB256_RV32
BigIntRv32BaseAlu256Opcode::XOR256XOR256_RV32
BigIntRv32BaseAlu256Opcode::OR256OR256_RV32
BigIntRv32BaseAlu256Opcode::AND256AND256_RV32
BigIntRv32Shift256Opcode::SLL256SLL256_RV32
BigIntRv32Shift256Opcode::SRL256SRL256_RV32
BigIntRv32Shift256Opcode::SRA256SRA256_RV32
BigIntRv32LessThan256Opcode::SLT256SLT256_RV32
BigIntRv32LessThan256Opcode::SLTU256SLTU256_RV32
BigIntRv32BranchEqual256Opcode::BEQ256BEQ256_RV32
BigIntRv32BranchEqual256Opcode::BNE256BNE256_RV32
BigIntRv32BranchLessThan256Opcode::BLT256BLT256_RV32
BigIntRv32BranchLessThan256Opcode::BGE256BGE256_RV32
BigIntRv32BranchLessThan256Opcode::BLTU256BLTU256_RV32
BigIntRv32BranchLessThan256Opcode::BGEU256BGEU256_RV32
BigIntRv32Mul256Opcode::MUL256MUL256_RV32

Algebra Extension

Instructions

VM ExtensionLocalOpcodeISA Instruction
AlgebraRv32ModularArithmeticOpcode::ADDADDMOD_RV32<N>
AlgebraRv32ModularArithmeticOpcode::SUBSUBMOD_RV32<N>
AlgebraRv32ModularArithmeticOpcode::SETUP_ADDSUBSETUP_ADDSUBMOD_RV32<N>
AlgebraRv32ModularArithmeticOpcode::MULMULMOD_RV32<N>
AlgebraRv32ModularArithmeticOpcode::DIVDIVMOD_RV32<N>
AlgebraRv32ModularArithmeticOpcode::SETUP_MULDIVSETUP_MULDIVMOD_RV32<N>
AlgebraRv32ModularArithmeticOpcode::IS_EQISEQMOD_RV32<N>
AlgebraRv32ModularArithmeticOpcode::SETUP_ISEQSETUP_ISEQMOD_RV32<N>
AlgebraFp2Opcode::ADDADD<Fp2>
AlgebraFp2Opcode::SUBSUB<Fp2>
AlgebraFp2Opcode::SETUP_ADDSUBSETUP_ADDSUB<Fp2>
AlgebraFp2Opcode::MULMUL<Fp2>
AlgebraFp2Opcode::DIVDIV<Fp2>
AlgebraFp2Opcode::SETUP_MULDIVSETUP_MULDIV<Fp2>

Elliptic Curve Extension

Instructions

VM ExtensionLocalOpcodeISA Instruction
Elliptic CurveRv32WeierstrassOpcode::EC_ADD_NEEC_ADD_NE<C>
Elliptic CurveRv32WeierstrassOpcode::SETUP_EC_ADD_NESETUP_EC_ADD_NE<C>
Elliptic CurveRv32WeierstrassOpcode::EC_DOUBLEEC_DOUBLE<C>
Elliptic CurveRv32WeierstrassOpcode::SETUP_EC_DOUBLESETUP_EC_DOUBLE<C>

Phantom Sub-Instructions

VM ExtensionPhantomDiscriminantISA Phantom Sub-Instruction
Elliptic CurveEccPhantom::HintDecompressHintDecompress

Pairing Extension

Instructions

Phantom Sub-Instructions

VM ExtensionPhantomDiscriminantISA Phantom Sub-Instruction
PairingPairingPhantom::HintDecompressHintDecompress