gh-102738: remove from cases generator the code related to register instructions (#102739)
This commit is contained in:
parent
0a22aa0528
commit
675b97a6ab
@ -707,12 +707,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum Direction { DIR_NONE, DIR_READ, DIR_WRITE };
|
|
||||||
enum InstructionFormat { INSTR_FMT_IB, INSTR_FMT_IBC, INSTR_FMT_IBC0, INSTR_FMT_IBC000, INSTR_FMT_IBC00000000, INSTR_FMT_IBIB, INSTR_FMT_IX, INSTR_FMT_IXC, INSTR_FMT_IXC000 };
|
enum InstructionFormat { INSTR_FMT_IB, INSTR_FMT_IBC, INSTR_FMT_IBC0, INSTR_FMT_IBC000, INSTR_FMT_IBC00000000, INSTR_FMT_IBIB, INSTR_FMT_IX, INSTR_FMT_IXC, INSTR_FMT_IXC000 };
|
||||||
struct opcode_metadata {
|
struct opcode_metadata {
|
||||||
enum Direction dir_op1;
|
|
||||||
enum Direction dir_op2;
|
|
||||||
enum Direction dir_op3;
|
|
||||||
bool valid_entry;
|
bool valid_entry;
|
||||||
enum InstructionFormat instr_format;
|
enum InstructionFormat instr_format;
|
||||||
};
|
};
|
||||||
@ -721,175 +717,175 @@ struct opcode_metadata {
|
|||||||
extern const struct opcode_metadata _PyOpcode_opcode_metadata[256];
|
extern const struct opcode_metadata _PyOpcode_opcode_metadata[256];
|
||||||
#else
|
#else
|
||||||
const struct opcode_metadata _PyOpcode_opcode_metadata[256] = {
|
const struct opcode_metadata _PyOpcode_opcode_metadata[256] = {
|
||||||
[NOP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[NOP] = { true, INSTR_FMT_IX },
|
||||||
[RESUME] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[RESUME] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_CLOSURE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LOAD_CLOSURE] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_FAST_CHECK] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LOAD_FAST_CHECK] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LOAD_FAST] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_CONST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LOAD_CONST] = { true, INSTR_FMT_IB },
|
||||||
[STORE_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[STORE_FAST] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_FAST__LOAD_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBIB },
|
[LOAD_FAST__LOAD_FAST] = { true, INSTR_FMT_IBIB },
|
||||||
[LOAD_FAST__LOAD_CONST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBIB },
|
[LOAD_FAST__LOAD_CONST] = { true, INSTR_FMT_IBIB },
|
||||||
[STORE_FAST__LOAD_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBIB },
|
[STORE_FAST__LOAD_FAST] = { true, INSTR_FMT_IBIB },
|
||||||
[STORE_FAST__STORE_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBIB },
|
[STORE_FAST__STORE_FAST] = { true, INSTR_FMT_IBIB },
|
||||||
[LOAD_CONST__LOAD_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBIB },
|
[LOAD_CONST__LOAD_FAST] = { true, INSTR_FMT_IBIB },
|
||||||
[POP_TOP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[POP_TOP] = { true, INSTR_FMT_IX },
|
||||||
[PUSH_NULL] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[PUSH_NULL] = { true, INSTR_FMT_IX },
|
||||||
[END_FOR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[END_FOR] = { true, INSTR_FMT_IB },
|
||||||
[UNARY_NEGATIVE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[UNARY_NEGATIVE] = { true, INSTR_FMT_IX },
|
||||||
[UNARY_NOT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[UNARY_NOT] = { true, INSTR_FMT_IX },
|
||||||
[UNARY_INVERT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[UNARY_INVERT] = { true, INSTR_FMT_IX },
|
||||||
[BINARY_OP_MULTIPLY_INT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[BINARY_OP_MULTIPLY_INT] = { true, INSTR_FMT_IXC },
|
||||||
[BINARY_OP_MULTIPLY_FLOAT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[BINARY_OP_MULTIPLY_FLOAT] = { true, INSTR_FMT_IXC },
|
||||||
[BINARY_OP_SUBTRACT_INT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[BINARY_OP_SUBTRACT_INT] = { true, INSTR_FMT_IXC },
|
||||||
[BINARY_OP_SUBTRACT_FLOAT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[BINARY_OP_SUBTRACT_FLOAT] = { true, INSTR_FMT_IXC },
|
||||||
[BINARY_OP_ADD_UNICODE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[BINARY_OP_ADD_UNICODE] = { true, INSTR_FMT_IXC },
|
||||||
[BINARY_OP_INPLACE_ADD_UNICODE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[BINARY_OP_INPLACE_ADD_UNICODE] = { true, INSTR_FMT_IX },
|
||||||
[BINARY_OP_ADD_FLOAT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[BINARY_OP_ADD_FLOAT] = { true, INSTR_FMT_IXC },
|
||||||
[BINARY_OP_ADD_INT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[BINARY_OP_ADD_INT] = { true, INSTR_FMT_IXC },
|
||||||
[BINARY_SUBSCR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC000 },
|
[BINARY_SUBSCR] = { true, INSTR_FMT_IXC000 },
|
||||||
[BINARY_SLICE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[BINARY_SLICE] = { true, INSTR_FMT_IX },
|
||||||
[STORE_SLICE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[STORE_SLICE] = { true, INSTR_FMT_IX },
|
||||||
[BINARY_SUBSCR_LIST_INT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC000 },
|
[BINARY_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC000 },
|
||||||
[BINARY_SUBSCR_TUPLE_INT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC000 },
|
[BINARY_SUBSCR_TUPLE_INT] = { true, INSTR_FMT_IXC000 },
|
||||||
[BINARY_SUBSCR_DICT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC000 },
|
[BINARY_SUBSCR_DICT] = { true, INSTR_FMT_IXC000 },
|
||||||
[BINARY_SUBSCR_GETITEM] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC000 },
|
[BINARY_SUBSCR_GETITEM] = { true, INSTR_FMT_IXC000 },
|
||||||
[LIST_APPEND] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LIST_APPEND] = { true, INSTR_FMT_IB },
|
||||||
[SET_ADD] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[SET_ADD] = { true, INSTR_FMT_IB },
|
||||||
[STORE_SUBSCR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[STORE_SUBSCR] = { true, INSTR_FMT_IXC },
|
||||||
[STORE_SUBSCR_LIST_INT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[STORE_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC },
|
||||||
[STORE_SUBSCR_DICT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC },
|
[STORE_SUBSCR_DICT] = { true, INSTR_FMT_IXC },
|
||||||
[DELETE_SUBSCR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[DELETE_SUBSCR] = { true, INSTR_FMT_IX },
|
||||||
[CALL_INTRINSIC_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[CALL_INTRINSIC_1] = { true, INSTR_FMT_IB },
|
||||||
[CALL_INTRINSIC_2] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[CALL_INTRINSIC_2] = { true, INSTR_FMT_IB },
|
||||||
[RAISE_VARARGS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[RAISE_VARARGS] = { true, INSTR_FMT_IB },
|
||||||
[INTERPRETER_EXIT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[INTERPRETER_EXIT] = { true, INSTR_FMT_IX },
|
||||||
[RETURN_VALUE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[RETURN_VALUE] = { true, INSTR_FMT_IX },
|
||||||
[RETURN_CONST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[RETURN_CONST] = { true, INSTR_FMT_IB },
|
||||||
[GET_AITER] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[GET_AITER] = { true, INSTR_FMT_IX },
|
||||||
[GET_ANEXT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[GET_ANEXT] = { true, INSTR_FMT_IX },
|
||||||
[GET_AWAITABLE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[GET_AWAITABLE] = { true, INSTR_FMT_IB },
|
||||||
[SEND] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[SEND] = { true, INSTR_FMT_IBC },
|
||||||
[SEND_GEN] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[SEND_GEN] = { true, INSTR_FMT_IBC },
|
||||||
[YIELD_VALUE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[YIELD_VALUE] = { true, INSTR_FMT_IX },
|
||||||
[POP_EXCEPT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[POP_EXCEPT] = { true, INSTR_FMT_IX },
|
||||||
[RERAISE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[RERAISE] = { true, INSTR_FMT_IB },
|
||||||
[END_ASYNC_FOR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[END_ASYNC_FOR] = { true, INSTR_FMT_IX },
|
||||||
[CLEANUP_THROW] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[CLEANUP_THROW] = { true, INSTR_FMT_IX },
|
||||||
[LOAD_ASSERTION_ERROR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[LOAD_ASSERTION_ERROR] = { true, INSTR_FMT_IX },
|
||||||
[LOAD_BUILD_CLASS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[LOAD_BUILD_CLASS] = { true, INSTR_FMT_IX },
|
||||||
[STORE_NAME] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[STORE_NAME] = { true, INSTR_FMT_IB },
|
||||||
[DELETE_NAME] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[DELETE_NAME] = { true, INSTR_FMT_IB },
|
||||||
[UNPACK_SEQUENCE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[UNPACK_SEQUENCE] = { true, INSTR_FMT_IBC },
|
||||||
[UNPACK_SEQUENCE_TWO_TUPLE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[UNPACK_SEQUENCE_TWO_TUPLE] = { true, INSTR_FMT_IBC },
|
||||||
[UNPACK_SEQUENCE_TUPLE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[UNPACK_SEQUENCE_TUPLE] = { true, INSTR_FMT_IBC },
|
||||||
[UNPACK_SEQUENCE_LIST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[UNPACK_SEQUENCE_LIST] = { true, INSTR_FMT_IBC },
|
||||||
[UNPACK_EX] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[UNPACK_EX] = { true, INSTR_FMT_IB },
|
||||||
[STORE_ATTR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[STORE_ATTR] = { true, INSTR_FMT_IBC000 },
|
||||||
[DELETE_ATTR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[DELETE_ATTR] = { true, INSTR_FMT_IB },
|
||||||
[STORE_GLOBAL] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[STORE_GLOBAL] = { true, INSTR_FMT_IB },
|
||||||
[DELETE_GLOBAL] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[DELETE_GLOBAL] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_NAME] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LOAD_NAME] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_GLOBAL] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 },
|
||||||
[LOAD_GLOBAL_MODULE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 },
|
||||||
[LOAD_GLOBAL_BUILTIN] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000 },
|
||||||
[DELETE_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[DELETE_FAST] = { true, INSTR_FMT_IB },
|
||||||
[MAKE_CELL] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[MAKE_CELL] = { true, INSTR_FMT_IB },
|
||||||
[DELETE_DEREF] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[DELETE_DEREF] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_CLASSDEREF] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LOAD_CLASSDEREF] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_DEREF] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LOAD_DEREF] = { true, INSTR_FMT_IB },
|
||||||
[STORE_DEREF] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[STORE_DEREF] = { true, INSTR_FMT_IB },
|
||||||
[COPY_FREE_VARS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[COPY_FREE_VARS] = { true, INSTR_FMT_IB },
|
||||||
[BUILD_STRING] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[BUILD_STRING] = { true, INSTR_FMT_IB },
|
||||||
[BUILD_TUPLE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[BUILD_TUPLE] = { true, INSTR_FMT_IB },
|
||||||
[BUILD_LIST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[BUILD_LIST] = { true, INSTR_FMT_IB },
|
||||||
[LIST_EXTEND] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[LIST_EXTEND] = { true, INSTR_FMT_IB },
|
||||||
[SET_UPDATE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[SET_UPDATE] = { true, INSTR_FMT_IB },
|
||||||
[BUILD_SET] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[BUILD_SET] = { true, INSTR_FMT_IB },
|
||||||
[BUILD_MAP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[BUILD_MAP] = { true, INSTR_FMT_IB },
|
||||||
[SETUP_ANNOTATIONS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[SETUP_ANNOTATIONS] = { true, INSTR_FMT_IX },
|
||||||
[BUILD_CONST_KEY_MAP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[BUILD_CONST_KEY_MAP] = { true, INSTR_FMT_IB },
|
||||||
[DICT_UPDATE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[DICT_UPDATE] = { true, INSTR_FMT_IB },
|
||||||
[DICT_MERGE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[DICT_MERGE] = { true, INSTR_FMT_IB },
|
||||||
[MAP_ADD] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[MAP_ADD] = { true, INSTR_FMT_IB },
|
||||||
[LOAD_ATTR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_INSTANCE_VALUE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_MODULE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_MODULE] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_WITH_HINT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_SLOT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_SLOT] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_CLASS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_CLASS] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_PROPERTY] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_PROPERTY] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[STORE_ATTR_INSTANCE_VALUE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC000 },
|
[STORE_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IXC000 },
|
||||||
[STORE_ATTR_WITH_HINT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[STORE_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC000 },
|
||||||
[STORE_ATTR_SLOT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IXC000 },
|
[STORE_ATTR_SLOT] = { true, INSTR_FMT_IXC000 },
|
||||||
[COMPARE_OP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[COMPARE_OP] = { true, INSTR_FMT_IBC },
|
||||||
[COMPARE_AND_BRANCH] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC0 },
|
[COMPARE_AND_BRANCH] = { true, INSTR_FMT_IBC0 },
|
||||||
[COMPARE_AND_BRANCH_FLOAT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC0 },
|
[COMPARE_AND_BRANCH_FLOAT] = { true, INSTR_FMT_IBC0 },
|
||||||
[COMPARE_AND_BRANCH_INT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC0 },
|
[COMPARE_AND_BRANCH_INT] = { true, INSTR_FMT_IBC0 },
|
||||||
[COMPARE_AND_BRANCH_STR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC0 },
|
[COMPARE_AND_BRANCH_STR] = { true, INSTR_FMT_IBC0 },
|
||||||
[IS_OP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[IS_OP] = { true, INSTR_FMT_IB },
|
||||||
[CONTAINS_OP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[CONTAINS_OP] = { true, INSTR_FMT_IB },
|
||||||
[CHECK_EG_MATCH] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[CHECK_EG_MATCH] = { true, INSTR_FMT_IX },
|
||||||
[CHECK_EXC_MATCH] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[CHECK_EXC_MATCH] = { true, INSTR_FMT_IX },
|
||||||
[IMPORT_NAME] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[IMPORT_NAME] = { true, INSTR_FMT_IB },
|
||||||
[IMPORT_FROM] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[IMPORT_FROM] = { true, INSTR_FMT_IB },
|
||||||
[JUMP_FORWARD] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[JUMP_FORWARD] = { true, INSTR_FMT_IB },
|
||||||
[JUMP_BACKWARD] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[JUMP_BACKWARD] = { true, INSTR_FMT_IB },
|
||||||
[POP_JUMP_IF_FALSE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[POP_JUMP_IF_FALSE] = { true, INSTR_FMT_IB },
|
||||||
[POP_JUMP_IF_TRUE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[POP_JUMP_IF_TRUE] = { true, INSTR_FMT_IB },
|
||||||
[POP_JUMP_IF_NOT_NONE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[POP_JUMP_IF_NOT_NONE] = { true, INSTR_FMT_IB },
|
||||||
[POP_JUMP_IF_NONE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[POP_JUMP_IF_NONE] = { true, INSTR_FMT_IB },
|
||||||
[JUMP_IF_FALSE_OR_POP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[JUMP_IF_FALSE_OR_POP] = { true, INSTR_FMT_IB },
|
||||||
[JUMP_IF_TRUE_OR_POP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[JUMP_IF_TRUE_OR_POP] = { true, INSTR_FMT_IB },
|
||||||
[JUMP_BACKWARD_NO_INTERRUPT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[JUMP_BACKWARD_NO_INTERRUPT] = { true, INSTR_FMT_IB },
|
||||||
[GET_LEN] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[GET_LEN] = { true, INSTR_FMT_IX },
|
||||||
[MATCH_CLASS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[MATCH_CLASS] = { true, INSTR_FMT_IB },
|
||||||
[MATCH_MAPPING] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[MATCH_MAPPING] = { true, INSTR_FMT_IX },
|
||||||
[MATCH_SEQUENCE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[MATCH_SEQUENCE] = { true, INSTR_FMT_IX },
|
||||||
[MATCH_KEYS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[MATCH_KEYS] = { true, INSTR_FMT_IX },
|
||||||
[GET_ITER] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[GET_ITER] = { true, INSTR_FMT_IX },
|
||||||
[GET_YIELD_FROM_ITER] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[GET_YIELD_FROM_ITER] = { true, INSTR_FMT_IX },
|
||||||
[FOR_ITER] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[FOR_ITER] = { true, INSTR_FMT_IBC },
|
||||||
[FOR_ITER_LIST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[FOR_ITER_LIST] = { true, INSTR_FMT_IBC },
|
||||||
[FOR_ITER_TUPLE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[FOR_ITER_TUPLE] = { true, INSTR_FMT_IBC },
|
||||||
[FOR_ITER_RANGE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[FOR_ITER_RANGE] = { true, INSTR_FMT_IBC },
|
||||||
[FOR_ITER_GEN] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[FOR_ITER_GEN] = { true, INSTR_FMT_IBC },
|
||||||
[BEFORE_ASYNC_WITH] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[BEFORE_ASYNC_WITH] = { true, INSTR_FMT_IX },
|
||||||
[BEFORE_WITH] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[BEFORE_WITH] = { true, INSTR_FMT_IX },
|
||||||
[WITH_EXCEPT_START] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[WITH_EXCEPT_START] = { true, INSTR_FMT_IX },
|
||||||
[PUSH_EXC_INFO] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[PUSH_EXC_INFO] = { true, INSTR_FMT_IX },
|
||||||
[LOAD_ATTR_METHOD_WITH_VALUES] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_METHOD_WITH_VALUES] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_METHOD_NO_DICT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_METHOD_NO_DICT] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[LOAD_ATTR_METHOD_LAZY_DICT] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC00000000 },
|
[LOAD_ATTR_METHOD_LAZY_DICT] = { true, INSTR_FMT_IBC00000000 },
|
||||||
[KW_NAMES] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[KW_NAMES] = { true, INSTR_FMT_IB },
|
||||||
[CALL] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_BOUND_METHOD_EXACT_ARGS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_BOUND_METHOD_EXACT_ARGS] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_PY_EXACT_ARGS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_PY_EXACT_ARGS] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_PY_WITH_DEFAULTS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_PY_WITH_DEFAULTS] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_TYPE_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_TYPE_1] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_STR_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_STR_1] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_TUPLE_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_TUPLE_1] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_BUILTIN_CLASS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_BUILTIN_O] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_BUILTIN_O] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_BUILTIN_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_BUILTIN_FAST] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_BUILTIN_FAST_WITH_KEYWORDS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_LEN] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_LEN] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_ISINSTANCE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_ISINSTANCE] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_LIST_APPEND] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_LIST_APPEND] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_METHOD_DESCRIPTOR_O] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
|
[CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC000 },
|
||||||
[CALL_FUNCTION_EX] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[CALL_FUNCTION_EX] = { true, INSTR_FMT_IB },
|
||||||
[MAKE_FUNCTION] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[MAKE_FUNCTION] = { true, INSTR_FMT_IB },
|
||||||
[RETURN_GENERATOR] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[RETURN_GENERATOR] = { true, INSTR_FMT_IX },
|
||||||
[BUILD_SLICE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[BUILD_SLICE] = { true, INSTR_FMT_IB },
|
||||||
[FORMAT_VALUE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[FORMAT_VALUE] = { true, INSTR_FMT_IB },
|
||||||
[COPY] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[COPY] = { true, INSTR_FMT_IB },
|
||||||
[BINARY_OP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC },
|
[BINARY_OP] = { true, INSTR_FMT_IBC },
|
||||||
[SWAP] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[SWAP] = { true, INSTR_FMT_IB },
|
||||||
[EXTENDED_ARG] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
|
[EXTENDED_ARG] = { true, INSTR_FMT_IB },
|
||||||
[CACHE] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IX },
|
[CACHE] = { true, INSTR_FMT_IX },
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -229,7 +229,6 @@ class Instruction:
|
|||||||
|
|
||||||
# Parts of the underlying instruction definition
|
# Parts of the underlying instruction definition
|
||||||
inst: parser.InstDef
|
inst: parser.InstDef
|
||||||
register: bool
|
|
||||||
kind: typing.Literal["inst", "op", "legacy"] # Legacy means no (input -- output)
|
kind: typing.Literal["inst", "op", "legacy"] # Legacy means no (input -- output)
|
||||||
name: str
|
name: str
|
||||||
block: parser.Block
|
block: parser.Block
|
||||||
@ -246,17 +245,12 @@ class Instruction:
|
|||||||
unmoved_names: frozenset[str]
|
unmoved_names: frozenset[str]
|
||||||
instr_fmt: str
|
instr_fmt: str
|
||||||
|
|
||||||
# Parallel to input_effects; set later
|
|
||||||
input_registers: list[str] = dataclasses.field(repr=False)
|
|
||||||
output_registers: list[str] = dataclasses.field(repr=False)
|
|
||||||
|
|
||||||
# Set later
|
# Set later
|
||||||
family: parser.Family | None = None
|
family: parser.Family | None = None
|
||||||
predicted: bool = False
|
predicted: bool = False
|
||||||
|
|
||||||
def __init__(self, inst: parser.InstDef):
|
def __init__(self, inst: parser.InstDef):
|
||||||
self.inst = inst
|
self.inst = inst
|
||||||
self.register = inst.register
|
|
||||||
self.kind = inst.kind
|
self.kind = inst.kind
|
||||||
self.name = inst.name
|
self.name = inst.name
|
||||||
self.block = inst.block
|
self.block = inst.block
|
||||||
@ -278,15 +272,10 @@ class Instruction:
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
self.unmoved_names = frozenset(unmoved_names)
|
self.unmoved_names = frozenset(unmoved_names)
|
||||||
if self.register:
|
if variable_used(inst, "oparg"):
|
||||||
num_regs = len(self.input_effects) + len(self.output_effects)
|
fmt = "IB"
|
||||||
num_dummies = (num_regs // 2) * 2 + 1 - num_regs
|
|
||||||
fmt = "I" + "B" * num_regs + "X" * num_dummies
|
|
||||||
else:
|
else:
|
||||||
if variable_used(inst, "oparg"):
|
fmt = "IX"
|
||||||
fmt = "IB"
|
|
||||||
else:
|
|
||||||
fmt = "IX"
|
|
||||||
cache = "C"
|
cache = "C"
|
||||||
for ce in self.cache_effects:
|
for ce in self.cache_effects:
|
||||||
for _ in range(ce.size):
|
for _ in range(ce.size):
|
||||||
@ -294,20 +283,6 @@ class Instruction:
|
|||||||
cache = "0"
|
cache = "0"
|
||||||
self.instr_fmt = fmt
|
self.instr_fmt = fmt
|
||||||
|
|
||||||
def analyze_registers(self, a: "Analyzer") -> None:
|
|
||||||
regs = iter(("REG(oparg1)", "REG(oparg2)", "REG(oparg3)"))
|
|
||||||
try:
|
|
||||||
self.input_registers = [
|
|
||||||
next(regs) for ieff in self.input_effects if ieff.name != UNUSED
|
|
||||||
]
|
|
||||||
self.output_registers = [
|
|
||||||
next(regs) for oeff in self.output_effects if oeff.name != UNUSED
|
|
||||||
]
|
|
||||||
except StopIteration: # Running out of registers
|
|
||||||
a.error(
|
|
||||||
f"Instruction {self.name} has too many register effects", node=self.inst
|
|
||||||
)
|
|
||||||
|
|
||||||
def write(self, out: Formatter) -> None:
|
def write(self, out: Formatter) -> None:
|
||||||
"""Write one instruction, sans prologue and epilogue."""
|
"""Write one instruction, sans prologue and epilogue."""
|
||||||
# Write a static assertion that a family's cache size is correct
|
# Write a static assertion that a family's cache size is correct
|
||||||
@ -319,25 +294,19 @@ class Instruction:
|
|||||||
f'{self.cache_offset}, "incorrect cache size");'
|
f'{self.cache_offset}, "incorrect cache size");'
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.register:
|
# Write input stack effect variable declarations and initializations
|
||||||
# Write input stack effect variable declarations and initializations
|
ieffects = list(reversed(self.input_effects))
|
||||||
ieffects = list(reversed(self.input_effects))
|
for i, ieffect in enumerate(ieffects):
|
||||||
for i, ieffect in enumerate(ieffects):
|
isize = string_effect_size(
|
||||||
isize = string_effect_size(
|
list_effect_size([ieff for ieff in ieffects[: i + 1]])
|
||||||
list_effect_size([ieff for ieff in ieffects[: i + 1]])
|
)
|
||||||
)
|
if ieffect.size:
|
||||||
if ieffect.size:
|
src = StackEffect(f"(stack_pointer - {maybe_parenthesize(isize)})", "PyObject **")
|
||||||
src = StackEffect(f"(stack_pointer - {maybe_parenthesize(isize)})", "PyObject **")
|
elif ieffect.cond:
|
||||||
elif ieffect.cond:
|
src = StackEffect(f"({ieffect.cond}) ? stack_pointer[-{maybe_parenthesize(isize)}] : NULL", "")
|
||||||
src = StackEffect(f"({ieffect.cond}) ? stack_pointer[-{maybe_parenthesize(isize)}] : NULL", "")
|
else:
|
||||||
else:
|
src = StackEffect(f"stack_pointer[-{maybe_parenthesize(isize)}]", "")
|
||||||
src = StackEffect(f"stack_pointer[-{maybe_parenthesize(isize)}]", "")
|
out.declare(ieffect, src)
|
||||||
out.declare(ieffect, src)
|
|
||||||
else:
|
|
||||||
# Write input register variable declarations and initializations
|
|
||||||
for ieffect, reg in zip(self.input_effects, self.input_registers):
|
|
||||||
src = StackEffect(reg, "")
|
|
||||||
out.declare(ieffect, src)
|
|
||||||
|
|
||||||
# Write output stack effect variable declarations
|
# Write output stack effect variable declarations
|
||||||
isize = string_effect_size(list_effect_size(self.input_effects))
|
isize = string_effect_size(list_effect_size(self.input_effects))
|
||||||
@ -367,32 +336,26 @@ class Instruction:
|
|||||||
if self.always_exits:
|
if self.always_exits:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.register:
|
# Write net stack growth/shrinkage
|
||||||
# Write net stack growth/shrinkage
|
out.stack_adjust(
|
||||||
out.stack_adjust(
|
0,
|
||||||
0,
|
[ieff for ieff in self.input_effects],
|
||||||
[ieff for ieff in self.input_effects],
|
[oeff for oeff in self.output_effects],
|
||||||
[oeff for oeff in self.output_effects],
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# Write output stack effect assignments
|
# Write output stack effect assignments
|
||||||
oeffects = list(reversed(self.output_effects))
|
oeffects = list(reversed(self.output_effects))
|
||||||
for i, oeffect in enumerate(oeffects):
|
for i, oeffect in enumerate(oeffects):
|
||||||
if oeffect.name in self.unmoved_names:
|
if oeffect.name in self.unmoved_names:
|
||||||
continue
|
continue
|
||||||
osize = string_effect_size(
|
osize = string_effect_size(
|
||||||
list_effect_size([oeff for oeff in oeffects[: i + 1]])
|
list_effect_size([oeff for oeff in oeffects[: i + 1]])
|
||||||
)
|
)
|
||||||
if oeffect.size:
|
if oeffect.size:
|
||||||
dst = StackEffect(f"stack_pointer - {maybe_parenthesize(osize)}", "PyObject **")
|
dst = StackEffect(f"stack_pointer - {maybe_parenthesize(osize)}", "PyObject **")
|
||||||
else:
|
else:
|
||||||
dst = StackEffect(f"stack_pointer[-{maybe_parenthesize(osize)}]", "")
|
dst = StackEffect(f"stack_pointer[-{maybe_parenthesize(osize)}]", "")
|
||||||
out.assign(dst, oeffect)
|
out.assign(dst, oeffect)
|
||||||
else:
|
|
||||||
# Write output register assignments
|
|
||||||
for oeffect, reg in zip(self.output_effects, self.output_registers):
|
|
||||||
dst = StackEffect(reg, "")
|
|
||||||
out.assign(dst, oeffect)
|
|
||||||
|
|
||||||
# Write cache effect
|
# Write cache effect
|
||||||
if self.cache_offset:
|
if self.cache_offset:
|
||||||
@ -438,19 +401,17 @@ class Instruction:
|
|||||||
# ERROR_IF() must pop the inputs from the stack.
|
# ERROR_IF() must pop the inputs from the stack.
|
||||||
# The code block is responsible for DECREF()ing them.
|
# The code block is responsible for DECREF()ing them.
|
||||||
# NOTE: If the label doesn't exist, just add it to ceval.c.
|
# NOTE: If the label doesn't exist, just add it to ceval.c.
|
||||||
if not self.register:
|
|
||||||
# Don't pop common input/output effects at the bottom!
|
# Don't pop common input/output effects at the bottom!
|
||||||
# These aren't DECREF'ed so they can stay.
|
# These aren't DECREF'ed so they can stay.
|
||||||
ieffs = list(self.input_effects)
|
ieffs = list(self.input_effects)
|
||||||
oeffs = list(self.output_effects)
|
oeffs = list(self.output_effects)
|
||||||
while ieffs and oeffs and ieffs[0] == oeffs[0]:
|
while ieffs and oeffs and ieffs[0] == oeffs[0]:
|
||||||
ieffs.pop(0)
|
ieffs.pop(0)
|
||||||
oeffs.pop(0)
|
oeffs.pop(0)
|
||||||
ninputs, symbolic = list_effect_size(ieffs)
|
ninputs, symbolic = list_effect_size(ieffs)
|
||||||
if ninputs:
|
if ninputs:
|
||||||
label = f"pop_{ninputs}_{label}"
|
label = f"pop_{ninputs}_{label}"
|
||||||
else:
|
|
||||||
symbolic = ""
|
|
||||||
if symbolic:
|
if symbolic:
|
||||||
out.write_raw(
|
out.write_raw(
|
||||||
f"{space}if ({cond}) {{ STACK_SHRINK({symbolic}); goto {label}; }}\n"
|
f"{space}if ({cond}) {{ STACK_SHRINK({symbolic}); goto {label}; }}\n"
|
||||||
@ -458,21 +419,20 @@ class Instruction:
|
|||||||
else:
|
else:
|
||||||
out.write_raw(f"{space}if ({cond}) goto {label};\n")
|
out.write_raw(f"{space}if ({cond}) goto {label};\n")
|
||||||
elif m := re.match(r"(\s*)DECREF_INPUTS\(\);\s*(?://.*)?$", line):
|
elif m := re.match(r"(\s*)DECREF_INPUTS\(\);\s*(?://.*)?$", line):
|
||||||
if not self.register:
|
out.reset_lineno()
|
||||||
out.reset_lineno()
|
space = extra + m.group(1)
|
||||||
space = extra + m.group(1)
|
for ieff in self.input_effects:
|
||||||
for ieff in self.input_effects:
|
if ieff.name in names_to_skip:
|
||||||
if ieff.name in names_to_skip:
|
continue
|
||||||
continue
|
if ieff.size:
|
||||||
if ieff.size:
|
out.write_raw(
|
||||||
out.write_raw(
|
f"{space}for (int _i = {ieff.size}; --_i >= 0;) {{\n"
|
||||||
f"{space}for (int _i = {ieff.size}; --_i >= 0;) {{\n"
|
)
|
||||||
)
|
out.write_raw(f"{space} Py_DECREF({ieff.name}[_i]);\n")
|
||||||
out.write_raw(f"{space} Py_DECREF({ieff.name}[_i]);\n")
|
out.write_raw(f"{space}}}\n")
|
||||||
out.write_raw(f"{space}}}\n")
|
else:
|
||||||
else:
|
decref = "XDECREF" if ieff.cond else "DECREF"
|
||||||
decref = "XDECREF" if ieff.cond else "DECREF"
|
out.write_raw(f"{space}Py_{decref}({ieff.name});\n")
|
||||||
out.write_raw(f"{space}Py_{decref}({ieff.name});\n")
|
|
||||||
else:
|
else:
|
||||||
out.write_raw(extra + line)
|
out.write_raw(extra + line)
|
||||||
out.reset_lineno()
|
out.reset_lineno()
|
||||||
@ -672,7 +632,6 @@ class Analyzer:
|
|||||||
Raises SystemExit if there is an error.
|
Raises SystemExit if there is an error.
|
||||||
"""
|
"""
|
||||||
self.find_predictions()
|
self.find_predictions()
|
||||||
self.analyze_register_instrs()
|
|
||||||
self.analyze_supers_and_macros()
|
self.analyze_supers_and_macros()
|
||||||
self.map_families()
|
self.map_families()
|
||||||
self.check_families()
|
self.check_families()
|
||||||
@ -782,11 +741,6 @@ class Analyzer:
|
|||||||
assert False, f"Unknown instruction {name!r}"
|
assert False, f"Unknown instruction {name!r}"
|
||||||
return cache, input, output
|
return cache, input, output
|
||||||
|
|
||||||
def analyze_register_instrs(self) -> None:
|
|
||||||
for instr in self.instrs.values():
|
|
||||||
if instr.register:
|
|
||||||
instr.analyze_registers(self)
|
|
||||||
|
|
||||||
def analyze_supers_and_macros(self) -> None:
|
def analyze_supers_and_macros(self) -> None:
|
||||||
"""Analyze each super- and macro instruction."""
|
"""Analyze each super- and macro instruction."""
|
||||||
self.super_instrs = {}
|
self.super_instrs = {}
|
||||||
@ -816,7 +770,7 @@ class Analyzer:
|
|||||||
stack, initial_sp = self.stack_analysis(components)
|
stack, initial_sp = self.stack_analysis(components)
|
||||||
sp = initial_sp
|
sp = initial_sp
|
||||||
parts: list[Component | parser.CacheEffect] = []
|
parts: list[Component | parser.CacheEffect] = []
|
||||||
format = "IB" # Macros don't support register instructions yet
|
format = "IB"
|
||||||
cache = "C"
|
cache = "C"
|
||||||
for component in components:
|
for component in components:
|
||||||
match component:
|
match component:
|
||||||
@ -1034,13 +988,9 @@ class Analyzer:
|
|||||||
self.write_stack_effect_functions()
|
self.write_stack_effect_functions()
|
||||||
|
|
||||||
# Write type definitions
|
# Write type definitions
|
||||||
self.out.emit("enum Direction { DIR_NONE, DIR_READ, DIR_WRITE };")
|
|
||||||
self.out.emit(f"enum InstructionFormat {{ {', '.join(format_enums)} }};")
|
self.out.emit(f"enum InstructionFormat {{ {', '.join(format_enums)} }};")
|
||||||
self.out.emit("struct opcode_metadata {")
|
self.out.emit("struct opcode_metadata {")
|
||||||
with self.out.indent():
|
with self.out.indent():
|
||||||
self.out.emit("enum Direction dir_op1;")
|
|
||||||
self.out.emit("enum Direction dir_op2;")
|
|
||||||
self.out.emit("enum Direction dir_op3;")
|
|
||||||
self.out.emit("bool valid_entry;")
|
self.out.emit("bool valid_entry;")
|
||||||
self.out.emit("enum InstructionFormat instr_format;")
|
self.out.emit("enum InstructionFormat instr_format;")
|
||||||
self.out.emit("};")
|
self.out.emit("};")
|
||||||
@ -1073,32 +1023,20 @@ class Analyzer:
|
|||||||
|
|
||||||
def write_metadata_for_inst(self, instr: Instruction) -> None:
|
def write_metadata_for_inst(self, instr: Instruction) -> None:
|
||||||
"""Write metadata for a single instruction."""
|
"""Write metadata for a single instruction."""
|
||||||
dir_op1 = dir_op2 = dir_op3 = "DIR_NONE"
|
|
||||||
if instr.kind == "legacy":
|
|
||||||
assert not instr.register
|
|
||||||
else:
|
|
||||||
if instr.register:
|
|
||||||
directions: list[str] = []
|
|
||||||
directions.extend("DIR_READ" for _ in instr.input_effects)
|
|
||||||
directions.extend("DIR_WRITE" for _ in instr.output_effects)
|
|
||||||
directions.extend("DIR_NONE" for _ in range(3))
|
|
||||||
dir_op1, dir_op2, dir_op3 = directions[:3]
|
|
||||||
self.out.emit(
|
self.out.emit(
|
||||||
f" [{instr.name}] = {{ {dir_op1}, {dir_op2}, {dir_op3}, true, {INSTR_FMT_PREFIX}{instr.instr_fmt} }},"
|
f" [{instr.name}] = {{ true, {INSTR_FMT_PREFIX}{instr.instr_fmt} }},"
|
||||||
)
|
)
|
||||||
|
|
||||||
def write_metadata_for_super(self, sup: SuperInstruction) -> None:
|
def write_metadata_for_super(self, sup: SuperInstruction) -> None:
|
||||||
"""Write metadata for a super-instruction."""
|
"""Write metadata for a super-instruction."""
|
||||||
dir_op1 = dir_op2 = dir_op3 = "DIR_NONE"
|
|
||||||
self.out.emit(
|
self.out.emit(
|
||||||
f" [{sup.name}] = {{ {dir_op1}, {dir_op2}, {dir_op3}, true, {INSTR_FMT_PREFIX}{sup.instr_fmt} }},"
|
f" [{sup.name}] = {{ true, {INSTR_FMT_PREFIX}{sup.instr_fmt} }},"
|
||||||
)
|
)
|
||||||
|
|
||||||
def write_metadata_for_macro(self, mac: MacroInstruction) -> None:
|
def write_metadata_for_macro(self, mac: MacroInstruction) -> None:
|
||||||
"""Write metadata for a macro-instruction."""
|
"""Write metadata for a macro-instruction."""
|
||||||
dir_op1 = dir_op2 = dir_op3 = "DIR_NONE"
|
|
||||||
self.out.emit(
|
self.out.emit(
|
||||||
f" [{mac.name}] = {{ {dir_op1}, {dir_op2}, {dir_op3}, true, {INSTR_FMT_PREFIX}{mac.instr_fmt} }},"
|
f" [{mac.name}] = {{ true, {INSTR_FMT_PREFIX}{mac.instr_fmt} }},"
|
||||||
)
|
)
|
||||||
|
|
||||||
def write_instructions(self) -> None:
|
def write_instructions(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user