Instruction 3.14 by youknowone · Pull Request #6805 · RustPython/RustPython

/// Currently aligned with CPython 3.14. /// /// ## See also /// - [CPython opcode IDs](https://github.com/python/cpython/blob/627894459a84be3488a1789919679c997056a03c/Include/opcode_ids.h) /// - [CPython opcode IDs](https://github.com/python/cpython/blob/v3.14.2/Include/opcode_ids.h) #[derive(Clone, Copy, Debug)] #[repr(u8)] pub enum Instruction { // ==================== No-argument instructions (opcode < 44) ==================== Cache = 0, // Placeholder BeforeAsyncWith = 1, BeforeWith = 2, // No-argument instructions (opcode < HAVE_ARGUMENT=44) Cache = 0, // Placeholder BinarySlice = 1, // Placeholder BuildTemplate = 2, BinaryOpInplaceAddUnicode = 3, // Placeholder BinarySlice = 4, // Placeholder BinarySubscr = 5, CheckEgMatch = 6, CheckExcMatch = 7, CleanupThrow = 8, DeleteSubscr = 9, EndAsyncFor = 10, EndFor = 11, // Placeholder EndSend = 12, ExitInitCheck = 13, // Placeholder FormatSimple = 14, FormatWithSpec = 15, GetAIter = 16, CallFunctionEx = 4, CheckEgMatch = 5, CheckExcMatch = 6, CleanupThrow = 7, DeleteSubscr = 8, EndFor = 9, // Placeholder EndSend = 10, ExitInitCheck = 11, // Placeholder FormatSimple = 12, FormatWithSpec = 13, GetAIter = 14, GetANext = 15, GetIter = 16, Reserved = 17, GetANext = 18, GetIter = 19, GetLen = 20, GetYieldFromIter = 21, InterpreterExit = 22, // Placeholder LoadAssertionError = 23, // Placeholder LoadBuildClass = 24, LoadLocals = 25, // Placeholder MakeFunction = 26, MatchKeys = 27, MatchMapping = 28, MatchSequence = 29, Nop = 30, PopExcept = 31, PopTop = 32, PushExcInfo = 33, PushNull = 34, ReturnGenerator = 35, // Placeholder ReturnValue = 36, SetupAnnotations = 37, StoreSlice = 38, // Placeholder StoreSubscr = 39, ToBool = 40, UnaryInvert = 41, UnaryNegative = 42, UnaryNot = 43, WithExceptStart = 44, // ==================== With-argument instructions (opcode > 44) ==================== GetLen = 18, GetYieldFromIter = 19, InterpreterExit = 20, // Placeholder LoadBuildClass = 21, LoadLocals = 22, // Placeholder MakeFunction = 23, MatchKeys = 24, MatchMapping = 25, MatchSequence = 26, Nop = 27, NotTaken = 28, // Placeholder PopExcept = 29, PopIter = 30, // Placeholder PopTop = 31, PushExcInfo = 32, PushNull = 33, ReturnGenerator = 34, // Placeholder ReturnValue = 35, SetupAnnotations = 36, StoreSlice = 37, // Placeholder StoreSubscr = 38, ToBool = 39, UnaryInvert = 40, UnaryNegative = 41, UnaryNot = 42, WithExceptStart = 43, // CPython 3.14 opcodes with arguments (44-120) BinaryOp { op: Arg<BinaryOperator>, } = 44, /// Build an Interpolation from value, expression string, and optional format_spec on stack. /// /// oparg encoding: (conversion << 2) | has_format_spec /// - has_format_spec (bit 0): if 1, format_spec is on stack /// - conversion (bits 2+): 0=None, 1=Str, 2=Repr, 3=Ascii /// /// Stack: [value, expression_str, format_spec?] -> [interpolation] BuildInterpolation { oparg: Arg<u32>, } = 45, BuildConstKeyMap { size: Arg<u32>, } = 46, // Placeholder BuildList { size: Arg<u32>, } = 47, } = 46, BuildMap { size: Arg<u32>, } = 48, } = 47, BuildSet { size: Arg<u32>, } = 49, } = 48, BuildSlice { argc: Arg<BuildSliceArgCount>, } = 50, } = 49, BuildString { size: Arg<u32>, } = 51, } = 50, BuildTuple { size: Arg<u32>, } = 52, } = 51, Call { nargs: Arg<u32>, } = 53, CallFunctionEx = 54, } = 52, CallIntrinsic1 { func: Arg<IntrinsicFunction1>, } = 55, } = 53, CallIntrinsic2 { func: Arg<IntrinsicFunction2>, } = 56, } = 54, CallKw { nargs: Arg<u32>, } = 57, } = 55, CompareOp { op: Arg<ComparisonOperator>, } = 58, ContainsOp(Arg<Invert>) = 59, } = 56, ContainsOp(Arg<Invert>) = 57, ConvertValue { oparg: Arg<ConvertValueOparg>, } = 60, } = 58, Copy { index: Arg<u32>, } = 61, } = 59, CopyFreeVars { count: Arg<u32>, } = 62, // Placeholder } = 60, // Placeholder DeleteAttr { idx: Arg<NameIdx>, } = 63, DeleteDeref(Arg<NameIdx>) = 64, DeleteFast(Arg<NameIdx>) = 65, DeleteGlobal(Arg<NameIdx>) = 66, DeleteName(Arg<NameIdx>) = 67, } = 61, DeleteDeref(Arg<NameIdx>) = 62, DeleteFast(Arg<NameIdx>) = 63, DeleteGlobal(Arg<NameIdx>) = 64, DeleteName(Arg<NameIdx>) = 65, DictMerge { index: Arg<u32>, } = 68, // Placeholder } = 66, DictUpdate { index: Arg<u32>, } = 69, EnterExecutor = 70, // Placeholder ExtendedArg = 71, } = 67, EndAsyncFor = 68, ExtendedArg = 69, ForIter { target: Arg<Label>, } = 72, GetAwaitable = 73, // TODO: Make this instruction to hold an oparg } = 70, GetAwaitable = 71, // TODO: Make this instruction to hold an oparg ImportFrom { idx: Arg<NameIdx>, } = 74, } = 72, ImportName { idx: Arg<NameIdx>, } = 75, IsOp(Arg<Invert>) = 76, } = 73, IsOp(Arg<Invert>) = 74, JumpBackward { target: Arg<Label>, } = 77, } = 75, JumpBackwardNoInterrupt { target: Arg<Label>, } = 78, // Placeholder } = 76, // Placeholder JumpForward { target: Arg<Label>, } = 79, } = 77, ListAppend { i: Arg<u32>, } = 80, } = 78, ListExtend { i: Arg<u32>, } = 81, // Placeholder } = 79, LoadAttr { idx: Arg<NameIdx>, } = 82, } = 80, LoadCommonConstant { idx: Arg<u32>, } = 81, // Placeholder LoadConst { idx: Arg<u32>, } = 83, LoadDeref(Arg<NameIdx>) = 84, LoadFast(Arg<NameIdx>) = 85, LoadFastAndClear(Arg<NameIdx>) = 86, LoadFastCheck(Arg<NameIdx>) = 87, // Placeholder } = 82, LoadDeref(Arg<NameIdx>) = 83, LoadFast(Arg<NameIdx>) = 84, LoadFastAndClear(Arg<NameIdx>) = 85, LoadFastBorrow(Arg<NameIdx>) = 86, // Placeholder LoadFastBorrowLoadFastBorrow { arg: Arg<u32>, } = 87, // Placeholder LoadFastCheck(Arg<NameIdx>) = 88, // Placeholder LoadFastLoadFast { arg: Arg<u32>, } = 88, // Placeholder LoadFromDictOrDeref(Arg<NameIdx>) = 89, LoadFromDictOrGlobals(Arg<NameIdx>) = 90, // Placeholder LoadGlobal(Arg<NameIdx>) = 91, LoadName(Arg<NameIdx>) = 92, } = 89, // Placeholder LoadFromDictOrDeref(Arg<NameIdx>) = 90, LoadFromDictOrGlobals(Arg<NameIdx>) = 91, // Placeholder LoadGlobal(Arg<NameIdx>) = 92, LoadName(Arg<NameIdx>) = 93, LoadSmallInt { idx: Arg<u32>, } = 94, // Placeholder LoadSpecial { arg: Arg<u32>, } = 95, // Placeholder LoadSuperAttr { arg: Arg<u32>, } = 93, MakeCell(Arg<NameIdx>) = 94, // Placeholder } = 96,