[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).
This commit is contained in:
Bill Currie 2022-01-20 12:41:01 +09:00
parent 143030fec4
commit a4ebd6aa58
4 changed files with 15 additions and 18 deletions

View File

@ -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)",

View File

@ -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;

View File

@ -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 }},

View File

@ -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);