Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:49

0001 #ifndef Py_INTERNAL_OPCODE_UTILS_H
0002 #define Py_INTERNAL_OPCODE_UTILS_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 #include "opcode_ids.h"
0012 
0013 #define MAX_REAL_OPCODE 254
0014 
0015 #define IS_WITHIN_OPCODE_RANGE(opcode) \
0016         (((opcode) >= 0 && (opcode) <= MAX_REAL_OPCODE) || \
0017          IS_PSEUDO_INSTR(opcode))
0018 
0019 #define IS_BLOCK_PUSH_OPCODE(opcode) \
0020         ((opcode) == SETUP_FINALLY || \
0021          (opcode) == SETUP_WITH || \
0022          (opcode) == SETUP_CLEANUP)
0023 
0024 #define HAS_TARGET(opcode) \
0025         (OPCODE_HAS_JUMP(opcode) || IS_BLOCK_PUSH_OPCODE(opcode))
0026 
0027 /* opcodes that must be last in the basicblock */
0028 #define IS_TERMINATOR_OPCODE(opcode) \
0029         (OPCODE_HAS_JUMP(opcode) || IS_SCOPE_EXIT_OPCODE(opcode))
0030 
0031 /* opcodes which are not emitted in codegen stage, only by the assembler */
0032 #define IS_ASSEMBLER_OPCODE(opcode) \
0033         ((opcode) == JUMP_FORWARD || \
0034          (opcode) == JUMP_BACKWARD || \
0035          (opcode) == JUMP_BACKWARD_NO_INTERRUPT)
0036 
0037 #define IS_BACKWARDS_JUMP_OPCODE(opcode) \
0038         ((opcode) == JUMP_BACKWARD || \
0039          (opcode) == JUMP_BACKWARD_NO_INTERRUPT)
0040 
0041 #define IS_UNCONDITIONAL_JUMP_OPCODE(opcode) \
0042         ((opcode) == JUMP || \
0043          (opcode) == JUMP_NO_INTERRUPT || \
0044          (opcode) == JUMP_FORWARD || \
0045          (opcode) == JUMP_BACKWARD || \
0046          (opcode) == JUMP_BACKWARD_NO_INTERRUPT)
0047 
0048 #define IS_SCOPE_EXIT_OPCODE(opcode) \
0049         ((opcode) == RETURN_VALUE || \
0050          (opcode) == RETURN_CONST || \
0051          (opcode) == RAISE_VARARGS || \
0052          (opcode) == RERAISE)
0053 
0054 
0055 /* Flags used in the oparg for MAKE_FUNCTION */
0056 #define MAKE_FUNCTION_DEFAULTS    0x01
0057 #define MAKE_FUNCTION_KWDEFAULTS  0x02
0058 #define MAKE_FUNCTION_ANNOTATIONS 0x04
0059 #define MAKE_FUNCTION_CLOSURE     0x08
0060 
0061 /* Values used in the oparg for RESUME */
0062 #define RESUME_AT_FUNC_START 0
0063 #define RESUME_AFTER_YIELD 1
0064 #define RESUME_AFTER_YIELD_FROM 2
0065 #define RESUME_AFTER_AWAIT 3
0066 
0067 #define RESUME_OPARG_LOCATION_MASK 0x3
0068 #define RESUME_OPARG_DEPTH1_MASK 0x4
0069 
0070 #ifdef __cplusplus
0071 }
0072 #endif
0073 #endif /* !Py_INTERNAL_OPCODE_UTILS_H */