mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-20 07:50:45 +00:00
[qfcc] Hide details about instruction type
At this stage, I doubt emit.c will need to know the details of the target (v6, v6p, ruamoko) since the instruction formats are identical, just different meanings for the opcode itself.
This commit is contained in:
parent
d9ccf3a394
commit
7e303a1151
3 changed files with 24 additions and 17 deletions
|
@ -31,13 +31,14 @@
|
||||||
#ifndef __opcodes_h
|
#ifndef __opcodes_h
|
||||||
#define __opcodes_h
|
#define __opcodes_h
|
||||||
|
|
||||||
|
#include "QF/pr_comp.h"
|
||||||
|
|
||||||
|
typedef struct instruction_s instruction_t;
|
||||||
|
|
||||||
struct operand_s;
|
struct operand_s;
|
||||||
|
pr_ushort_t opcode_get (instruction_t *inst);
|
||||||
extern struct v6p_opcode_s *opcode_map;
|
instruction_t *opcode_find (const char *name, struct operand_s *op_a,
|
||||||
|
struct operand_s *op_b, struct operand_s *op_c);
|
||||||
struct v6p_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);
|
void opcode_init (void);
|
||||||
|
|
||||||
#endif//__opcodes_h
|
#endif//__opcodes_h
|
||||||
|
|
|
@ -185,7 +185,7 @@ emit_statement (statement_t *statement)
|
||||||
{
|
{
|
||||||
const char *opcode = statement->opcode;
|
const char *opcode = statement->opcode;
|
||||||
def_t *def_a, *def_b, *def_c;
|
def_t *def_a, *def_b, *def_c;
|
||||||
v6p_opcode_t *op;
|
instruction_t *inst;
|
||||||
dstatement_t *s;
|
dstatement_t *s;
|
||||||
|
|
||||||
def_a = get_operand_def (statement->expr, statement->opa);
|
def_a = get_operand_def (statement->expr, statement->opa);
|
||||||
|
@ -194,9 +194,9 @@ emit_statement (statement_t *statement)
|
||||||
use_tempop (statement->opb, statement->expr);
|
use_tempop (statement->opb, statement->expr);
|
||||||
def_c = get_operand_def (statement->expr, statement->opc);
|
def_c = get_operand_def (statement->expr, statement->opc);
|
||||||
use_tempop (statement->opc, statement->expr);
|
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_expr (statement->expr);
|
||||||
print_statement (statement);
|
print_statement (statement);
|
||||||
internal_error (statement->expr, "ice ice baby");
|
internal_error (statement->expr, "ice ice baby");
|
||||||
|
@ -213,7 +213,7 @@ emit_statement (statement_t *statement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s = codespace_newstatement (pr.code);
|
s = codespace_newstatement (pr.code);
|
||||||
s->op = op - opcode_map;
|
s->op = opcode_get (inst);
|
||||||
s->a = def_a ? def_a->offset : 0;
|
s->a = def_a ? def_a->offset : 0;
|
||||||
s->b = def_b ? def_b->offset : 0;
|
s->b = def_b ? def_b->offset : 0;
|
||||||
s->c = def_c ? def_c->offset : 0;
|
s->c = def_c ? def_c->offset : 0;
|
||||||
|
|
|
@ -47,9 +47,9 @@
|
||||||
#include "tools/qfcc/include/statements.h"
|
#include "tools/qfcc/include/statements.h"
|
||||||
#include "tools/qfcc/include/type.h"
|
#include "tools/qfcc/include/type.h"
|
||||||
|
|
||||||
hashtab_t *opcode_type_table;
|
static hashtab_t *opcode_type_table;
|
||||||
hashtab_t *opcode_void_table;
|
static hashtab_t *opcode_void_table;
|
||||||
v6p_opcode_t *opcode_map;
|
static v6p_opcode_t *opcode_map;
|
||||||
|
|
||||||
#define ROTL(x,n) ((((unsigned)(x))<<(n))|((unsigned)(x))>>(32-n))
|
#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;
|
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,
|
opcode_find (const char *name, operand_t *op_a, operand_t *op_b,
|
||||||
operand_t *op_c)
|
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;
|
search_op.type_c = op_c ? low_level_type (op_c->type) : ev_invalid;
|
||||||
op = Hash_FindElement (opcode_type_table, &search_op);
|
op = Hash_FindElement (opcode_type_table, &search_op);
|
||||||
if (op)
|
if (op)
|
||||||
return op;
|
return (instruction_t *) op;
|
||||||
op_list = Hash_FindList (opcode_void_table, name);
|
op_list = Hash_FindList (opcode_void_table, name);
|
||||||
if (!op_list)
|
if (!op_list)
|
||||||
return op;
|
return (instruction_t *) op;
|
||||||
for (i = 0; !op && op_list[i]; i++) {
|
for (i = 0; !op && op_list[i]; i++) {
|
||||||
sop = op_list[i];
|
sop = op_list[i];
|
||||||
if (check_operand_type (sop->type_a, search_op.type_a)
|
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;
|
op = sop;
|
||||||
}
|
}
|
||||||
free (op_list);
|
free (op_list);
|
||||||
return op;
|
return (instruction_t *) op;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue