Module: Flux::OpcodeRegistry

Included in:
Disassembler, FluxVM
Defined in:
lib/superinstance/flux-runtime/opcode.rb

Overview

Opcode registry mapping opcode byte values to method names and providing all core opcode implementations

Constant Summary collapse

OPCODE_CLASSES =
{
  # Control Flow (0x00-0x0F)
  0x00 => :Halt,
  0x01 => :Nop,
  0x02 => :Ret,
  0x03 => :Jump,
  0x04 => :JumpIf,
  0x05 => :JumpIfNot,
  0x06 => :Call,
  0x07 => :CallIndirect,
  0x08 => :Yield,
  0x09 => :Panic,
  0x0A => :Unreachable,

  # Stack Operations (0x10-0x1F)
  0x10 => :Push,
  0x11 => :Pop,
  0x12 => :Dup,
  0x13 => :Swap,

  # Integer Arithmetic (0x20-0x3F)
  0x20 => :IMov,
  0x21 => :IAdd,
  0x22 => :ISub,
  0x23 => :IMul,
  0x24 => :IDiv,
  0x25 => :IMod,
  0x26 => :INeg,
  0x27 => :IAbs,
  0x28 => :IInc,
  0x29 => :IDec,
  0x2A => :IMin,
  0x2B => :IMax,
  0x2C => :IAnd,
  0x2D => :IOr,
  0x2E => :IXor,
  0x2F => :IShl,
  0x30 => :IShr,
  0x31 => :INot,
  0x32 => :ICmpEq,
  0x33 => :ICmpNe,
  0x34 => :ICmpLt,
  0x35 => :ICmpLe,
  0x36 => :ICmpGt,
  0x37 => :ICmpGe,

  # Float Arithmetic (0x40-0x5F)
  0x40 => :FMov,
  0x41 => :FAdd,
  0x42 => :FSub,
  0x43 => :FMul,
  0x44 => :FDiv,
  0x45 => :FMod,
  0x46 => :FNeg,
  0x47 => :FAbs,
  0x48 => :FSqrt,
  0x49 => :FFloor,
  0x4A => :FCeil,
  0x4B => :FRound,
  0x4C => :FMin,
  0x4D => :FMax,
  0x4E => :FSin,
  0x4F => :FCos,
  0x50 => :FExp,
  0x51 => :FLog,
  0x52 => :FClamp,
  0x53 => :FLerp,
  0x54 => :FCmpEq,
  0x55 => :FCmpNe,
  0x56 => :FCmpLt,
  0x57 => :FCmpLe,
  0x58 => :FCmpGt,
  0x59 => :FCmpGe,

  # Conversions (0x60-0x6F)
  0x60 => :IToF,
  0x61 => :FToI,
  0x62 => :BToI,
  0x63 => :IToB,

  # Memory Operations (0x70-0x7F)
  0x70 => :Load8,
  0x71 => :Load16,
  0x72 => :Load32,
  0x73 => :Load64,
  0x74 => :Store8,
  0x75 => :Store16,
  0x76 => :Store32,
  0x77 => :Store64,
  0x78 => :LoadAddr,
  0x79 => :StackAlloc,

  # Agent-to-Agent Communication (0x80-0x8F)
  0x80 => :ASend,
  0x81 => :ARecv,
  0x82 => :AAsk,
  0x83 => :ATell,
  0x84 => :ADelegate,
  0x85 => :ABroadcast,
  0x86 => :ASubscribe,
  0x87 => :AWait,
  0x88 => :ATrust,
  0x89 => :AVerify,

  # Type/Meta Operations (0x90-0x9F)
  0x90 => :Cast,
  0x91 => :SizeOf,
  0x92 => :TypeOf,

  # Bitwise Operations (0xA0-0xAF)
  0xA0 => :BAnd,
  0xA1 => :BOr,
  0xA2 => :BXor,
  0xA3 => :BShl,
  0xA4 => :BShr,
  0xA5 => :BNot,

  # Vector/SIMD Operations (0xB0-0xBF)
  0xB0 => :VLoad,
  0xB1 => :VStore,
  0xB2 => :VAdd,
  0xB3 => :VMul,
  0xB4 => :VDot
}.freeze
OPCODE_NAMES =
OPCODE_CLASSES.transform_values(&:to_s).freeze

Class Method Summary collapse

Class Method Details

.opcode_name(opcode_byte) ⇒ Object

Get opcode name from byte



137
138
139
# File 'lib/superinstance/flux-runtime/opcode.rb', line 137

def self.opcode_name(opcode_byte)
  OPCODE_NAMES[opcode_byte] || "Unknown_0x#{opcode_byte.to_s(16).upcase}"
end