GH-99005: More intrinsics (GH-100774)

* Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
This commit is contained in:
Mark Shannon 2023-01-06 14:47:57 +00:00 committed by GitHub
parent 659c2607f5
commit 78068126a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 151 additions and 204 deletions

View file

@ -1090,7 +1090,6 @@ stack_effect(int opcode, int oparg, int jump)
return -2;
/* Unary operators */
case UNARY_POSITIVE:
case UNARY_NEGATIVE:
case UNARY_NOT:
case UNARY_INVERT:
@ -1123,7 +1122,6 @@ stack_effect(int opcode, int oparg, int jump)
return -1;
case SETUP_ANNOTATIONS:
return 0;
case ASYNC_GEN_WRAP:
case YIELD_VALUE:
return 0;
case POP_BLOCK:
@ -1296,8 +1294,6 @@ stack_effect(int opcode, int oparg, int jump)
return 1;
case LOAD_ASSERTION_ERROR:
return 1;
case LIST_TO_TUPLE:
return 0;
case LIST_EXTEND:
case SET_UPDATE:
case DICT_MERGE:
@ -4122,8 +4118,6 @@ unaryop(unaryop_ty op)
return UNARY_INVERT;
case Not:
return UNARY_NOT;
case UAdd:
return UNARY_POSITIVE;
case USub:
return UNARY_NEGATIVE;
default:
@ -4191,7 +4185,7 @@ addop_binary(struct compiler *c, location loc, operator_ty binop,
static int
addop_yield(struct compiler *c, location loc) {
if (c->u->u_ste->ste_generator && c->u->u_ste->ste_coroutine) {
ADDOP(c, loc, ASYNC_GEN_WRAP);
ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_ASYNC_GEN_WRAP);
}
ADDOP_I(c, loc, YIELD_VALUE, 0);
ADDOP_I(c, loc, RESUME, 1);
@ -4358,7 +4352,7 @@ starunpack_helper(struct compiler *c, location loc,
ADDOP_LOAD_CONST_NEW(c, loc, folded);
ADDOP_I(c, loc, extend, 1);
if (tuple) {
ADDOP(c, loc, LIST_TO_TUPLE);
ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_LIST_TO_TUPLE);
}
}
return SUCCESS;
@ -4409,7 +4403,7 @@ starunpack_helper(struct compiler *c, location loc,
}
assert(sequence_built);
if (tuple) {
ADDOP(c, loc, LIST_TO_TUPLE);
ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_LIST_TO_TUPLE);
}
return SUCCESS;
}
@ -5784,7 +5778,12 @@ compiler_visit_expr1(struct compiler *c, expr_ty e)
break;
case UnaryOp_kind:
VISIT(c, expr, e->v.UnaryOp.operand);
ADDOP(c, loc, unaryop(e->v.UnaryOp.op));
if (e->v.UnaryOp.op == UAdd) {
ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_UNARY_POSITIVE);
}
else {
ADDOP(c, loc, unaryop(e->v.UnaryOp.op));
}
break;
case Lambda_kind:
return compiler_lambda(c, e);