diff --git a/tools/qfcc/include/opcodes.h b/tools/qfcc/include/opcodes.h index 077d26e1e..d8aa393ea 100644 --- a/tools/qfcc/include/opcodes.h +++ b/tools/qfcc/include/opcodes.h @@ -31,13 +31,14 @@ #ifndef __opcodes_h #define __opcodes_h +#include "QF/pr_comp.h" + +typedef struct instruction_s instruction_t; + struct operand_s; - -extern struct v6p_opcode_s *opcode_map; - -struct v6p_opcode_s *opcode_find (const char *name, struct operand_s *op_a, - struct operand_s *op_b, - struct operand_s *op_c); +pr_ushort_t opcode_get (instruction_t *inst); +instruction_t *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 48e89b422..10c7054f9 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -185,7 +185,7 @@ emit_statement (statement_t *statement) { const char *opcode = statement->opcode; def_t *def_a, *def_b, *def_c; - v6p_opcode_t *op; + instruction_t *inst; dstatement_t *s; def_a = get_operand_def (statement->expr, statement->opa); @@ -194,9 +194,9 @@ 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, statement->opa, statement->opb, statement->opc); + inst = opcode_find (opcode, statement->opa, statement->opb, statement->opc); - if (!op) { + if (!inst) { print_expr (statement->expr); print_statement (statement); internal_error (statement->expr, "ice ice baby"); @@ -213,7 +213,7 @@ emit_statement (statement_t *statement) } } s = codespace_newstatement (pr.code); - s->op = op - opcode_map; + s->op = opcode_get (inst); s->a = def_a ? def_a->offset : 0; s->b = def_b ? def_b->offset : 0; s->c = def_c ? def_c->offset : 0; diff --git a/tools/qfcc/source/opcodes.c b/tools/qfcc/source/opcodes.c index 8ad5358d9..7060aa35d 100644 --- a/tools/qfcc/source/opcodes.c +++ b/tools/qfcc/source/opcodes.c @@ -47,9 +47,9 @@ #include "tools/qfcc/include/statements.h" #include "tools/qfcc/include/type.h" -hashtab_t *opcode_type_table; -hashtab_t *opcode_void_table; -v6p_opcode_t *opcode_map; +static hashtab_t *opcode_type_table; +static hashtab_t *opcode_void_table; +static v6p_opcode_t *opcode_map; #define ROTL(x,n) ((((unsigned)(x))<<(n))|((unsigned)(x))>>(32-n)) @@ -92,7 +92,13 @@ check_operand_type (etype_t ot1, etype_t ot2) return 0; } -v6p_opcode_t * +pr_ushort_t +opcode_get (instruction_t *op) +{ + return (v6p_opcode_t *) op - opcode_map; +} + +instruction_t * opcode_find (const char *name, operand_t *op_a, operand_t *op_b, operand_t *op_c) { @@ -108,10 +114,10 @@ opcode_find (const char *name, operand_t *op_a, operand_t *op_b, search_op.type_c = op_c ? low_level_type (op_c->type) : ev_invalid; op = Hash_FindElement (opcode_type_table, &search_op); if (op) - return op; + return (instruction_t *) op; op_list = Hash_FindList (opcode_void_table, name); if (!op_list) - return op; + return (instruction_t *) op; for (i = 0; !op && op_list[i]; i++) { sop = op_list[i]; if (check_operand_type (sop->type_a, search_op.type_a) @@ -120,7 +126,7 @@ opcode_find (const char *name, operand_t *op_a, operand_t *op_b, op = sop; } free (op_list); - return op; + return (instruction_t *) op; } void