From a4ebd6aa58ed28584631ee7ba3da00d6d92693e1 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 20 Jan 2022 12:41:01 +0900 Subject: [PATCH] [gamecode] Fix a few missed opcode renames if and ifnot became ifnz and ifz, and return_v lost its tail (it was always redundant, except in dags, and that's fixed with a pointer check). --- libs/gamecode/pr_v6p_opcode.c | 6 +++--- tools/qfcc/source/dags.c | 2 +- tools/qfcc/source/opcodes.c | 4 ++-- tools/qfcc/source/statements.c | 21 +++++++++------------ 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/libs/gamecode/pr_v6p_opcode.c b/libs/gamecode/pr_v6p_opcode.c index 20f717154..e9b3a0b7a 100644 --- a/libs/gamecode/pr_v6p_opcode.c +++ b/libs/gamecode/pr_v6p_opcode.c @@ -756,7 +756,7 @@ VISIBLE const v6p_opcode_t pr_v6p_opcodes[] = { "%Ra", }, - [OP_RETURN_V_v6p] = {"return_v", "return", + [OP_RETURN_V_v6p] = {"return", "return", ev_invalid, ev_invalid, ev_invalid, PROG_V6P_VERSION, "", @@ -803,12 +803,12 @@ VISIBLE const v6p_opcode_t pr_v6p_opcodes[] = { "%Ga, %gc", }, - [OP_IF_v6p] = {"if", "if", + [OP_IF_v6p] = {"ifnz", "if", ev_int, ev_short, ev_invalid, PROG_ID_VERSION, "%Ga branch %sb (%Ob)", }, - [OP_IFNOT_v6p] = {"ifnot", "ifnot", + [OP_IFNOT_v6p] = {"ifz", "ifnot", ev_int, ev_short, ev_invalid, PROG_ID_VERSION, "%Ga branch %sb (%Ob)", diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index 3040c5425..bdfd4ab7d 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -457,7 +457,7 @@ dagnode_set_edges (dag_t *dag, dagnode_t *n) first_param = 2; } else if (!strncmp (n->label->opcode, "call", 4)) { num_params = n->label->opcode + 5; - } else if (!strcmp (n->label->opcode, "return")) { + } else if (!strcmp (n->label->opcode, "return") && n->children[0]) { daglabel_t *label = n->children[0]->label; if (!label->op) { set_iter_t *lab_i; diff --git a/tools/qfcc/source/opcodes.c b/tools/qfcc/source/opcodes.c index d0f11684b..f0cc4e358 100644 --- a/tools/qfcc/source/opcodes.c +++ b/tools/qfcc/source/opcodes.c @@ -60,8 +60,8 @@ static v6p_uint_opcode_t v6p_uint_opcodes[] = { {OP_STOREP_I_v6p, {"store", "storep.i", ev_uint, ev_ptr, ev_invalid }}, {OP_STOREB_I_v6p, {"store", "storeb.i", ev_uint, ev_ptr, ev_int }}, {OP_STOREBI_I_v6p, {"store", "storebi.i",ev_uint, ev_ptr, ev_short }}, - {OP_IF_v6p, {"if", "if", ev_uint, ev_short, ev_invalid }}, - {OP_IFNOT_v6p, {"ifnot", "ifnot", ev_uint, ev_short, ev_invalid }}, + {OP_IF_v6p, {"ifnz", "if", ev_uint, ev_short, ev_invalid }}, + {OP_IFNOT_v6p, {"ifz", "ifnot", ev_uint, ev_short, ev_invalid }}, {OP_ADD_I_v6p, {"add", "add.i", ev_uint, ev_uint, ev_uint }}, {OP_SUB_I_v6p, {"sub", "sub.i", ev_uint, ev_uint, ev_uint }}, {OP_MUL_I_v6p, {"mul", "mul.i", ev_uint, ev_uint, ev_uint }}, diff --git a/tools/qfcc/source/statements.c b/tools/qfcc/source/statements.c index bc7013f91..48257be54 100644 --- a/tools/qfcc/source/statements.c +++ b/tools/qfcc/source/statements.c @@ -687,10 +687,10 @@ statement_get_targetlist (statement_t *s) static void invert_conditional (statement_t *s) { - if (!strcmp (s->opcode, "if")) - s->opcode = "ifnot"; - else if (!strcmp (s->opcode, "ifnot")) - s->opcode = "if"; + if (!strcmp (s->opcode, "ifnz")) + s->opcode = "ifz"; + else if (!strcmp (s->opcode, "ifz")) + s->opcode = "ifnz"; else if (!strcmp (s->opcode, "ifbe")) s->opcode = "ifa"; else if (!strcmp (s->opcode, "ifb")) @@ -931,7 +931,7 @@ dereference_dst: // dst_expr is a dereferenced pointer, so need to un-dereference it // to get the pointer and switch to storep instructions. dst_expr = expr_file_line (address_expr (dst_expr, 0, 0), e); - opcode = "store";// FIXME find a nicer representation (lose strings?) + opcode = "store"; if (dst_expr->type == ex_address && dst_expr->e.address.offset && !is_const_ptr (dst_expr->e.address.lvalue)) { sblock = statement_subexpr (sblock, @@ -1059,11 +1059,11 @@ static sblock_t * statement_branch (sblock_t *sblock, expr_t *e) { static const char *opcodes[] = { - "ifnot", + "ifz", "ifb", "ifa", 0, // special handling - "if", + "ifnz", "ifae", "ifbe", 0, // not used here @@ -1104,9 +1104,7 @@ statement_return (sblock_t *sblock, expr_t *e) debug (e, "RETURN"); opcode = "return"; if (!e->e.retrn.ret_val) { - if (options.code.progsversion != PROG_ID_VERSION) { - opcode = "return_v"; - } else { + if (options.code.progsversion == PROG_ID_VERSION) { e->e.retrn.ret_val = new_float_expr (0); } } @@ -2115,9 +2113,8 @@ check_final_block (sblock_t *sblock) sblock->next = new_sblock (); sblock = sblock->next; } - s = new_statement (st_func, "return_v", 0); + s = new_statement (st_func, "return", 0); if (options.traditional || options.code.progsversion == PROG_ID_VERSION) { - s->opcode = save_string ("return"); s->opa = return_operand (&type_void, 0); } sblock_add_statement (sblock, s);