make rel_def_op work properly

This commit is contained in:
Bill Currie 2003-08-22 19:48:14 +00:00
parent e9ca03416a
commit b38486d405
9 changed files with 23 additions and 11 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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++) {

View file

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

View file

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

View file

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