codekingpro/portable-devtools
115k
1#ifndef Py_INTERNAL_OPCODE_UTILS_H2#define Py_INTERNAL_OPCODE_UTILS_H3#ifdef __cplusplus4extern "C" {5#endif6 7#ifndef Py_BUILD_CORE8# error "this header requires Py_BUILD_CORE define"9#endif10 11#define MAX_REAL_OPCODE 25412 13#define IS_WITHIN_OPCODE_RANGE(opcode) \14 (((opcode) >= 0 && (opcode) <= MAX_REAL_OPCODE) || \15 IS_PSEUDO_INSTR(opcode))16 17#define IS_BLOCK_PUSH_OPCODE(opcode) \18 ((opcode) == SETUP_FINALLY || \19 (opcode) == SETUP_WITH || \20 (opcode) == SETUP_CLEANUP)21 22#define HAS_TARGET(opcode) \23 (OPCODE_HAS_JUMP(opcode) || IS_BLOCK_PUSH_OPCODE(opcode))24 25/* opcodes that must be last in the basicblock */26#define IS_TERMINATOR_OPCODE(opcode) \27 (OPCODE_HAS_JUMP(opcode) || IS_SCOPE_EXIT_OPCODE(opcode))28 29/* opcodes which are not emitted in codegen stage, only by the assembler */30#define IS_ASSEMBLER_OPCODE(opcode) \31 ((opcode) == JUMP_FORWARD || \32 (opcode) == JUMP_BACKWARD || \33 (opcode) == JUMP_BACKWARD_NO_INTERRUPT)34 35#define IS_BACKWARDS_JUMP_OPCODE(opcode) \36 ((opcode) == JUMP_BACKWARD || \37 (opcode) == JUMP_BACKWARD_NO_INTERRUPT)38 39#define IS_UNCONDITIONAL_JUMP_OPCODE(opcode) \40 ((opcode) == JUMP || \41 (opcode) == JUMP_NO_INTERRUPT || \42 (opcode) == JUMP_FORWARD || \43 (opcode) == JUMP_BACKWARD || \44 (opcode) == JUMP_BACKWARD_NO_INTERRUPT)45 46#define IS_CONDITIONAL_JUMP_OPCODE(opcode) \47 ((opcode) == POP_JUMP_IF_FALSE || \48 (opcode) == POP_JUMP_IF_TRUE || \49 (opcode) == POP_JUMP_IF_NONE || \50 (opcode) == POP_JUMP_IF_NOT_NONE)51 52#define IS_SCOPE_EXIT_OPCODE(opcode) \53 ((opcode) == RETURN_VALUE || \54 (opcode) == RAISE_VARARGS || \55 (opcode) == RERAISE)56 57#define IS_RETURN_OPCODE(opcode) \58 (opcode == RETURN_VALUE)59#define IS_RAISE_OPCODE(opcode) \60 (opcode == RAISE_VARARGS || opcode == RERAISE)61 62 63/* Flags used in the oparg for MAKE_FUNCTION */64#define MAKE_FUNCTION_DEFAULTS 0x0165#define MAKE_FUNCTION_KWDEFAULTS 0x0266#define MAKE_FUNCTION_ANNOTATIONS 0x0467#define MAKE_FUNCTION_CLOSURE 0x0868#define MAKE_FUNCTION_ANNOTATE 0x1069 70/* Values used as the oparg for LOAD_COMMON_CONSTANT */71#define CONSTANT_ASSERTIONERROR 072#define CONSTANT_NOTIMPLEMENTEDERROR 173#define CONSTANT_BUILTIN_TUPLE 274#define CONSTANT_BUILTIN_ALL 375#define CONSTANT_BUILTIN_ANY 476#define NUM_COMMON_CONSTANTS 577 78/* Values used in the oparg for RESUME */79#define RESUME_AT_FUNC_START 080#define RESUME_AFTER_YIELD 181#define RESUME_AFTER_YIELD_FROM 282#define RESUME_AFTER_AWAIT 383 84#define RESUME_OPARG_LOCATION_MASK 0x385#define RESUME_OPARG_DEPTH1_MASK 0x486 87#ifdef __cplusplus88}89#endif90#endif /* !Py_INTERNAL_OPCODE_UTILS_H */91 