From b38486d4051f832b283cc18711835dfe6b6cf843 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 22 Aug 2003 19:48:14 +0000 Subject: [PATCH] make rel_def_op work properly --- tools/qfcc/include/expr.h | 2 +- tools/qfcc/include/reloc.h | 2 ++ tools/qfcc/source/emit.c | 2 +- tools/qfcc/source/expr.c | 4 ++-- tools/qfcc/source/linker.c | 2 +- tools/qfcc/source/obj_file.c | 3 ++- tools/qfcc/source/qfodump.c | 4 ++++ tools/qfcc/source/reloc.c | 9 +++++++++ tools/qfcc/source/switch.c | 6 +----- 9 files changed, 23 insertions(+), 11 deletions(-) diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index 0ec156f60..9fc43ca49 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -119,7 +119,7 @@ typedef struct expr_s { } expr_t; extern etype_t qc_types[]; -extern struct type_s *types[]; +extern struct type_s *ev_types[]; extern expr_type expr_types[]; extern expr_t *local_expr; diff --git a/tools/qfcc/include/reloc.h b/tools/qfcc/include/reloc.h index be6d5e622..f20ade707 100644 --- a/tools/qfcc/include/reloc.h +++ b/tools/qfcc/include/reloc.h @@ -53,6 +53,7 @@ typedef enum { typedef struct reloc_s { struct reloc_s *next; + struct ex_label_s *label; int ofs; reloc_type type; int line; @@ -70,5 +71,6 @@ void reloc_def_def_ofs (struct def_s *def, int ofs); void reloc_def_func (struct function_s *func, int ofs); void reloc_def_string (int ofs); void reloc_def_field (struct def_s *def, int ofs); +void reloc_def_op (struct ex_label_s *label, int ofs); #endif//__reloc_h diff --git a/tools/qfcc/source/emit.c b/tools/qfcc/source/emit.c index bda1a7d71..0613ab4c1 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -150,7 +150,7 @@ emit_statement (expr_t *e, opcode_t *op, def_t *var_a, def_t *var_b, ret = var_a; } else { // allocate result space if (!var_c) { - var_c = get_tempdef (types[op->type_c], current_scope); + var_c = get_tempdef (ev_types[op->type_c], current_scope); var_c->users += 2; } statement->c = var_c->ofs; diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 01ba3e570..c060c738f 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -90,7 +90,7 @@ etype_t qc_types[] = { ev_short, // ex_short }; -type_t *types[] = { +type_t *ev_types[] = { &type_void, &type_string, &type_float, @@ -209,7 +209,7 @@ get_type (expr_t *e) case ex_quaternion: case ex_uinteger: case ex_short: - return types[qc_types[e->type]]; + return ev_types[qc_types[e->type]]; } return 0; } diff --git a/tools/qfcc/source/linker.c b/tools/qfcc/source/linker.c index 0ddb945d8..f3f0b5128 100644 --- a/tools/qfcc/source/linker.c +++ b/tools/qfcc/source/linker.c @@ -299,7 +299,7 @@ process_def (qfo_def_t *def) size * sizeof (pr_type_t)); for (i = 0; i < relocs.num_relocs; i++) { qfo_reloc_t *reloc = relocs.relocs + i; - if (reloc->type >= rel_def_op + if (reloc->type >= rel_def_def && reloc->type <= rel_def_field) if (reloc->ofs == def->ofs) reloc->ofs = d->ofs; diff --git a/tools/qfcc/source/obj_file.c b/tools/qfcc/source/obj_file.c index 2d3b875f8..ac88bc80d 100644 --- a/tools/qfcc/source/obj_file.c +++ b/tools/qfcc/source/obj_file.c @@ -49,6 +49,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include "debug.h" #include "def.h" #include "emit.h" +#include "expr.h" #include "function.h" #include "immediate.h" #include "obj_file.h" @@ -222,7 +223,7 @@ setup_data (void) } for (r = pr.relocs; r; r = r->next) if (r->type == rel_def_op) - write_one_reloc (r, &reloc, G_INT (r->ofs)); + write_one_reloc (r, &reloc, r->label->ofs); else write_one_reloc (r, &reloc, 0); for (st = pr.code->code; st - pr.code->code < pr.code->size; st++) { diff --git a/tools/qfcc/source/qfodump.c b/tools/qfcc/source/qfodump.c index b98c8242a..2ff8e58a4 100644 --- a/tools/qfcc/source/qfodump.c +++ b/tools/qfcc/source/qfodump.c @@ -145,6 +145,10 @@ const char *reloc_names[] = { "def_func", "def_string", "def_field", + "op_a_def_ofs", + "op_b_def_ofs", + "op_c_def_ofs", + "def_def_ofs", }; static void diff --git a/tools/qfcc/source/reloc.c b/tools/qfcc/source/reloc.c index 7dd410473..ad69fe443 100644 --- a/tools/qfcc/source/reloc.c +++ b/tools/qfcc/source/reloc.c @@ -211,3 +211,12 @@ reloc_def_field (def_t *def, int ofs) ref->next = def->refs; def->refs = ref; } + +void +reloc_def_op (ex_label_t *label, int ofs) +{ + reloc_t *ref = new_reloc (ofs, rel_def_op); + ref->next = pr.relocs; + ref->label = label; + pr.relocs = ref; +} diff --git a/tools/qfcc/source/switch.c b/tools/qfcc/source/switch.c index 1ac5c8ada..f4db402b2 100644 --- a/tools/qfcc/source/switch.c +++ b/tools/qfcc/source/switch.c @@ -324,11 +324,7 @@ build_switch (expr_t *sw, case_node_t *tree, int op, expr_t *sw_val, build_switch (sw, tree->right, op, sw_val, temp, default_label); } for (i = 0; i <= high - low; i++) { - reloc_t *ref; - - ref = new_reloc (def->ofs + i, rel_def_op); - ref->next = tree->labels[i]->e.label.refs; - tree->labels[i]->e.label.refs = ref; + reloc_def_op (&tree->labels[i]->e.label, def->ofs + i); } } }