[qfcc] Nuke PAS from orbit

And there was much rejoicing. I hated having to create that opcode.
This commit is contained in:
Bill Currie 2020-03-13 20:56:10 +09:00
parent de89f2f31f
commit d150210888
5 changed files with 8 additions and 43 deletions

View file

@ -226,7 +226,7 @@ do_op_float (int op, expr_t *e, expr_t *e1, expr_t *e2)
if (!valid_op (op, valid))
return error (e1, "invalid operator for float");
if (op == '=' || op == PAS) {
if (op == '=') {
if ((type = get_type (e1)) != &type_float) {
//FIXME optimize casting a constant
e->e.expr.e2 = e2 = cf_cast_expr (type, e2);
@ -355,7 +355,7 @@ do_op_double (int op, expr_t *e, expr_t *e1, expr_t *e2)
if (!valid_op (op, valid))
return error (e1, "invalid operator for double");
if (op == '=' || op == PAS) {
if (op == '=') {
if ((type = get_type (e1)) != &type_double) {
//FIXME optimize casting a constant
e->e.expr.e2 = e2 = cf_cast_expr (type, e2);
@ -616,7 +616,7 @@ static expr_t *
do_op_pointer (int op, expr_t *e, expr_t *e1, expr_t *e2)
{
type_t *type;
static int valid[] = {'=', PAS, '-', '&', 'M', '.', EQ, NE, 0};
static int valid[] = {'=', '-', '&', 'M', '.', EQ, NE, 0};
if (is_integral (type = get_type (e2)) && (op == '-' || op == '+')) {
// pointer arithmetic
@ -640,26 +640,13 @@ do_op_pointer (int op, expr_t *e, expr_t *e1, expr_t *e2)
e = binary_expr ('/', e, new_integer_expr (type_size (type)));
return e;
}
if (op == PAS && (type = get_type (e1)->t.fldptr.type) != get_type (e2)) {
// make sure auto-convertions happen
expr_t *tmp = new_temp_def_expr (type);
expr_t *ass = new_binary_expr ('=', tmp, e2);
tmp->file = e1->file;
ass->line = e2->line;
ass->file = e2->file;
ass = fold_constants (ass);
if (e->e.expr.e2 == tmp)
internal_error (e2, 0);
e->e.expr.e2 = ass->e.expr.e2;
}
if (op == EQ || op == NE) {
if (options.code.progsversion > PROG_ID_VERSION)
e->e.expr.type = &type_integer;
else
e->e.expr.type = &type_float;
}
if (op != PAS && op != '.' && op != '&' && op != 'M'
if (op != '.' && op != '&' && op != 'M'
&& extract_type (e1) != extract_type (e2))
return type_mismatch (e1, e2, op);
if ((op == '.' || op == '&') && get_type (e2) == &type_uinteger)

View file

@ -75,7 +75,6 @@ const char *
get_op_string (int op)
{
switch (op) {
case PAS: return ".=";
case OR: return "||";
case AND: return "&&";
case EQ: return "==";

View file

@ -245,7 +245,7 @@ convert_bool (expr_t *e, int block)
{
expr_t *b;
if (e->type == ex_expr && (e->e.expr.op == '=' || e->e.expr.op == PAS)) {
if (e->type == ex_expr && e->e.expr.op == '=') {
expr_t *src;
if (!e->paren && options.warnings.precedence)
warning (e, "suggest parentheses around assignment "

View file

@ -124,7 +124,7 @@ int yylex (void);
%nonassoc STORAGEX
%left COMMA
%right <op> '=' ASX PAS /* pointer assign */
%right <op> '=' ASX
%right '?' ':'
%left OR
%left AND

View file

@ -440,7 +440,6 @@ static const char *
convert_op (int op)
{
switch (op) {
case PAS: return ".=";
case OR: return "||";
case AND: return "&&";
case EQ: return "==";
@ -662,14 +661,12 @@ expr_assign_copy (sblock_t *sblock, expr_t *e, operand_t **op)
int need_ptr = 0;
operand_t *dummy;
if (src_expr->type == ex_expr
&& (src_expr->e.expr.op == '=' || src_expr->e.expr.op == PAS)) {
if (src_expr->type == ex_expr && src_expr->e.expr.op == '=') {
sblock = statement_subexpr (sblock, src_expr, &dummy);
}
// follow the assignment chain to find the actual source expression
// (can't take the address of an assignment)
while (src_expr->type == ex_expr
&& (src_expr->e.expr.op == '=' || src_expr->e.expr.op == PAS)) {
while (src_expr->type == ex_expr && src_expr->e.expr.op == '=') {
src_expr = src_expr->e.expr.e2;
}
if (src_expr->type == ex_nil) {
@ -743,22 +740,6 @@ expr_assign (sblock_t *sblock, expr_t *e, operand_t **op)
if (src == dst)
return sblock;
type = st_assign;
} else {
//FIXME this sucks. find a better way to handle both pointer
//dereferences and pointer assignements
sblock = statement_subexpr (sblock, src_expr, &src);
if (dst_expr->type == ex_expr
&& extract_type (dst_expr->e.expr.e1) == ev_pointer
&& !is_constant (dst_expr->e.expr.e1)) {
sblock = statement_subexpr (sblock, dst_expr->e.expr.e1, &dst);
sblock = statement_subexpr (sblock, dst_expr->e.expr.e2, &ofs);
} else {
sblock = statement_subexpr (sblock, dst_expr, &dst);
ofs = 0;
}
if (op)
*op = src;
type = st_ptrassign;
}
s = new_statement (type, opcode, e);
s->opa = src;
@ -1059,7 +1040,6 @@ expr_expr (sblock_t *sblock, expr_t *e, operand_t **op)
sblock = expr_call (sblock, e, op);
break;
case '=':
case PAS:
sblock = expr_assign (sblock, e, op);
break;
case 'm':
@ -1506,7 +1486,6 @@ statement_expr (sblock_t *sblock, expr_t *e)
sblock = statement_branch (sblock, e);
break;
case '=':
case PAS:
sblock = expr_assign (sblock, e, 0);
break;
case 'm':