From 5018f5147ce819543387750a7570e0e3ebf2c5eb Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 19 Nov 2012 12:28:41 +0900 Subject: [PATCH] Use operand types rather than def types to select opcodes. With temp types changing and temps being reused within the one instruction, the def type is no longer usable for selecting the opcode. However, the operand types are stable and more correct. --- tools/qfcc/include/opcodes.h | 6 +++--- tools/qfcc/source/emit.c | 2 +- tools/qfcc/source/opcodes.c | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/qfcc/include/opcodes.h b/tools/qfcc/include/opcodes.h index 9a9b3289c..779370340 100644 --- a/tools/qfcc/include/opcodes.h +++ b/tools/qfcc/include/opcodes.h @@ -46,10 +46,10 @@ extern struct opcode_s *op_goto; extern struct opcode_s *op_jump; extern struct opcode_s *op_jumpb; -struct def_s; +struct operand_s; -struct opcode_s *opcode_find (const char *name, struct def_s *def_a, - struct def_s *def_b, struct def_s *def_c); +struct opcode_s *opcode_find (const char *name, struct operand_s *op_a, + struct operand_s *op_b, struct operand_s *op_c); void opcode_init (void); #endif//__opcodes_h diff --git a/tools/qfcc/source/emit.c b/tools/qfcc/source/emit.c index 8d69ba3f0..4b6749068 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -198,7 +198,7 @@ emit_statement (statement_t *statement) use_tempop (statement->opb, statement->expr); def_c = get_operand_def (statement->expr, statement->opc); use_tempop (statement->opc, statement->expr); - op = opcode_find (opcode, def_a, def_b, def_c); + op = opcode_find (opcode, statement->opa, statement->opb, statement->opc); if (!op) { print_expr (statement->expr); diff --git a/tools/qfcc/source/opcodes.c b/tools/qfcc/source/opcodes.c index 3eb9ac44e..0dee8a38d 100644 --- a/tools/qfcc/source/opcodes.c +++ b/tools/qfcc/source/opcodes.c @@ -41,10 +41,10 @@ #include -#include "def.h" #include "opcodes.h" #include "options.h" #include "qfcc.h" +#include "statements.h" #include "type.h" hashtab_t *opcode_type_table; @@ -92,7 +92,8 @@ check_operand_type (etype_t ot1, etype_t ot2) } opcode_t * -opcode_find (const char *name, def_t *def_a, def_t *def_b, def_t *def_c) +opcode_find (const char *name, operand_t *op_a, operand_t *op_b, + operand_t *op_c) { opcode_t search_op; opcode_t *op; @@ -101,9 +102,9 @@ opcode_find (const char *name, def_t *def_a, def_t *def_b, def_t *def_c) int i; search_op.name = name; - search_op.type_a = def_a ? def_a->type->type : ev_invalid; - search_op.type_b = def_b ? def_b->type->type : ev_invalid; - search_op.type_c = def_c ? def_c->type->type : ev_invalid; + search_op.type_a = op_a ? op_a->type : ev_invalid; + search_op.type_b = op_b ? op_b->type : ev_invalid; + search_op.type_c = op_c ? op_c->type : ev_invalid; op = Hash_FindElement (opcode_type_table, &search_op); if (op) return op;