| 
									
										
										
										
											2023-03-31 18:17:59 +01:00
										 |  |  | #ifndef Py_INTERNAL_OPCODE_UTILS_H
 | 
					
						
							|  |  |  | #define Py_INTERNAL_OPCODE_UTILS_H
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef Py_BUILD_CORE
 | 
					
						
							|  |  |  | #  error "this header requires Py_BUILD_CORE define"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-23 18:39:00 +01:00
										 |  |  | #include "opcode_ids.h"
 | 
					
						
							| 
									
										
										
										
											2023-03-31 18:17:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define MAX_REAL_OPCODE 254
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define IS_WITHIN_OPCODE_RANGE(opcode) \
 | 
					
						
							|  |  |  |         (((opcode) >= 0 && (opcode) <= MAX_REAL_OPCODE) || \ | 
					
						
							| 
									
										
										
										
											2023-06-17 17:00:16 +01:00
										 |  |  |          IS_PSEUDO_INSTR(opcode)) | 
					
						
							| 
									
										
										
										
											2023-03-31 18:17:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define IS_BLOCK_PUSH_OPCODE(opcode) \
 | 
					
						
							|  |  |  |         ((opcode) == SETUP_FINALLY || \ | 
					
						
							|  |  |  |          (opcode) == SETUP_WITH || \ | 
					
						
							|  |  |  |          (opcode) == SETUP_CLEANUP) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define HAS_TARGET(opcode) \
 | 
					
						
							| 
									
										
										
										
											2023-06-15 00:14:22 +01:00
										 |  |  |         (OPCODE_HAS_JUMP(opcode) || IS_BLOCK_PUSH_OPCODE(opcode)) | 
					
						
							| 
									
										
										
										
											2023-03-31 18:17:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* opcodes that must be last in the basicblock */ | 
					
						
							|  |  |  | #define IS_TERMINATOR_OPCODE(opcode) \
 | 
					
						
							| 
									
										
										
										
											2023-06-15 00:14:22 +01:00
										 |  |  |         (OPCODE_HAS_JUMP(opcode) || IS_SCOPE_EXIT_OPCODE(opcode)) | 
					
						
							| 
									
										
										
										
											2023-03-31 18:17:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* opcodes which are not emitted in codegen stage, only by the assembler */ | 
					
						
							|  |  |  | #define IS_ASSEMBLER_OPCODE(opcode) \
 | 
					
						
							|  |  |  |         ((opcode) == JUMP_FORWARD || \ | 
					
						
							|  |  |  |          (opcode) == JUMP_BACKWARD || \ | 
					
						
							|  |  |  |          (opcode) == JUMP_BACKWARD_NO_INTERRUPT) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define IS_BACKWARDS_JUMP_OPCODE(opcode) \
 | 
					
						
							|  |  |  |         ((opcode) == JUMP_BACKWARD || \ | 
					
						
							|  |  |  |          (opcode) == JUMP_BACKWARD_NO_INTERRUPT) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define IS_UNCONDITIONAL_JUMP_OPCODE(opcode) \
 | 
					
						
							|  |  |  |         ((opcode) == JUMP || \ | 
					
						
							|  |  |  |          (opcode) == JUMP_NO_INTERRUPT || \ | 
					
						
							|  |  |  |          (opcode) == JUMP_FORWARD || \ | 
					
						
							|  |  |  |          (opcode) == JUMP_BACKWARD || \ | 
					
						
							|  |  |  |          (opcode) == JUMP_BACKWARD_NO_INTERRUPT) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-19 16:59:51 +00:00
										 |  |  | #define IS_CONDITIONAL_JUMP_OPCODE(opcode) \
 | 
					
						
							|  |  |  |         ((opcode) == POP_JUMP_IF_FALSE || \ | 
					
						
							|  |  |  |          (opcode) == POP_JUMP_IF_TRUE || \ | 
					
						
							|  |  |  |          (opcode) == POP_JUMP_IF_NONE || \ | 
					
						
							|  |  |  |          (opcode) == POP_JUMP_IF_NOT_NONE) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-31 18:17:59 +01:00
										 |  |  | #define IS_SCOPE_EXIT_OPCODE(opcode) \
 | 
					
						
							|  |  |  |         ((opcode) == RETURN_VALUE || \ | 
					
						
							|  |  |  |          (opcode) == RAISE_VARARGS || \ | 
					
						
							|  |  |  |          (opcode) == RERAISE) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-02 07:10:45 -07:00
										 |  |  | /* Flags used in the oparg for MAKE_FUNCTION */ | 
					
						
							|  |  |  | #define MAKE_FUNCTION_DEFAULTS    0x01
 | 
					
						
							|  |  |  | #define MAKE_FUNCTION_KWDEFAULTS  0x02
 | 
					
						
							|  |  |  | #define MAKE_FUNCTION_ANNOTATIONS 0x04
 | 
					
						
							|  |  |  | #define MAKE_FUNCTION_CLOSURE     0x08
 | 
					
						
							| 
									
										
										
										
											2024-06-11 07:06:49 -06:00
										 |  |  | #define MAKE_FUNCTION_ANNOTATE    0x10
 | 
					
						
							| 
									
										
										
										
											2023-06-02 07:10:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-21 20:46:39 -04:00
										 |  |  | /* Values used as the oparg for LOAD_COMMON_CONSTANT */ | 
					
						
							|  |  |  | #define CONSTANT_ASSERTIONERROR 0
 | 
					
						
							|  |  |  | #define CONSTANT_NOTIMPLEMENTEDERROR 1
 | 
					
						
							|  |  |  | #define NUM_COMMON_CONSTANTS 2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-26 16:30:18 +01:00
										 |  |  | /* Values used in the oparg for RESUME */ | 
					
						
							|  |  |  | #define RESUME_AT_FUNC_START 0
 | 
					
						
							|  |  |  | #define RESUME_AFTER_YIELD 1
 | 
					
						
							|  |  |  | #define RESUME_AFTER_YIELD_FROM 2
 | 
					
						
							|  |  |  | #define RESUME_AFTER_AWAIT 3
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-02 10:18:43 +00:00
										 |  |  | #define RESUME_OPARG_LOCATION_MASK 0x3
 | 
					
						
							|  |  |  | #define RESUME_OPARG_DEPTH1_MASK 0x4
 | 
					
						
							| 
									
										
										
										
											2023-03-31 18:17:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif /* !Py_INTERNAL_OPCODE_UTILS_H */
 |