fixing the messup of MUL_FV and _VF being swapped - getting rid of additions that really have no place here (YET) (matrix/quaternion types)

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-12 11:34:41 +02:00
parent 647582aeb4
commit 7e3edea621
4 changed files with 5 additions and 95 deletions

2
ast.h
View file

@ -133,8 +133,6 @@ struct ast_value_s
const char *vstring;
int ventity;
ast_function *vfunc;
quaternion vquat;
matrix vmat;
} constval;
ir_value *ir_v;

48
gmqcc.h
View file

@ -279,8 +279,6 @@ enum {
TYPE_FUNCTION ,
TYPE_POINTER ,
TYPE_INTEGER ,
TYPE_QUATERNION ,
TYPE_MATRIX ,
TYPE_VARIANT ,
TYPE_COUNT
@ -400,8 +398,8 @@ enum {
INSTR_DONE,
INSTR_MUL_F,
INSTR_MUL_V,
INSTR_MUL_VF,
INSTR_MUL_FV,
INSTR_MUL_VF,
INSTR_DIV_F,
INSTR_ADD_F,
INSTR_ADD_V,
@ -464,23 +462,6 @@ enum {
INSTR_BITAND,
INSTR_BITOR,
/* warning: will be reordered */
INSTR_MUL_Q,
INSTR_MUL_QF,
INSTR_MUL_M,
INSTR_MUL_MF,
INSTR_EQ_Q,
INSTR_EQ_M,
INSTR_NE_Q,
INSTR_NE_M,
INSTR_LOAD_Q,
INSTR_LOAD_M,
INSTR_STORE_Q,
INSTR_STORE_M,
INSTR_STOREP_Q,
INSTR_STOREP_M,
INSTR_INV_Q,
INSTR_INV_M,
/*
* Virtual instructions used by the assembler
* keep at the end but before virtual instructions
@ -540,8 +521,8 @@ static const struct {
{ "DONE" , 1, 4 },
{ "MUL_F" , 3, 5 },
{ "MUL_V" , 3, 5 },
{ "MUL_VF" , 3, 6 },
{ "MUL_FV" , 3, 6 },
{ "MUL_VF" , 3, 6 },
{ "DIV" , 0, 3 },
{ "ADD_F" , 3, 5 },
{ "ADD_V" , 3, 5 },
@ -604,23 +585,6 @@ static const struct {
{ "BITAND" , 0, 6 },
{ "BITOR" , 0, 5 },
{ "MUL_Q" , 3, 5 },
{ "MUL_QF" , 3, 6 },
{ "MUL_M" , 3, 5 },
{ "MUL_MF" , 3, 6 },
{ "EQ_Q" , 0, 4 },
{ "EQ_M" , 0, 4 },
{ "NE_Q" , 0, 4 },
{ "NE_M" , 0, 4 },
{ "FIELD_Q" , 0, 7 },
{ "FIELD_M" , 0, 7 },
{ "STORE_Q" , 0, 7 },
{ "STORE_M" , 0, 7 },
{ "STOREP_Q" , 0, 8 },
{ "STOREP_M" , 0, 8 },
{ "INV_Q" , 0, 5 },
{ "INV_M" , 0, 5 },
{ "END" , 0, 3 } /* virtual assembler instruction */
};
@ -812,14 +776,6 @@ typedef struct {
float x, y, z;
} vector;
typedef float matrix[4][4]; /* OpenGL layout */
typedef float quaternion[4]; /* order: x, y, z, w */
#define MATRIX(axis, elem) ((4*(axis)) + (elem))
#define QUAT_X 0
#define QUAT_Y 1
#define QUAT_Z 2
#define QUAT_W 3
/*
* A shallow copy of a lex_file to remember where which ast node
* came from.

46
ir.c
View file

@ -41,8 +41,6 @@ const char *type_name[TYPE_COUNT] = {
#if 0
"integer",
#endif
"quaternion",
"matrix",
"variant"
};
@ -58,9 +56,7 @@ size_t type_sizeof[TYPE_COUNT] = {
#if 0
1, /* TYPE_INTEGER */
#endif
4, /* TYPE_QUATERNION */
16, /* TYPE_MATRIX */
16, /* TYPE_VARIANT */
3, /* TYPE_VARIANT */
};
uint16_t type_store_instr[TYPE_COUNT] = {
@ -75,10 +71,8 @@ uint16_t type_store_instr[TYPE_COUNT] = {
#if 0
INSTR_STORE_I, /* integer type */
#endif
INSTR_STORE_Q,
INSTR_STORE_M,
INSTR_STORE_M, /* variant, should never be accessed */
INSTR_STORE_V, /* variant, should never be accessed */
};
uint16_t type_storep_instr[TYPE_COUNT] = {
@ -93,10 +87,8 @@ uint16_t type_storep_instr[TYPE_COUNT] = {
#if 0
INSTR_STOREP_ENT, /* integer type */
#endif
INSTR_STOREP_Q,
INSTR_STOREP_M,
INSTR_STOREP_M, /* variant, should never be accessed */
INSTR_STOREP_V, /* variant, should never be accessed */
};
MEM_VEC_FUNCTIONS(ir_value_vector, ir_value*, v)
@ -694,24 +686,6 @@ bool ir_value_set_vector(ir_value *self, vector v)
return true;
}
bool ir_value_set_quaternion(ir_value *self, quaternion v)
{
if (self->vtype != TYPE_QUATERNION)
return false;
memcpy(&self->constval.vquat, v, sizeof(self->constval.vquat));
self->isconst = true;
return true;
}
bool ir_value_set_matrix(ir_value *self, matrix v)
{
if (self->vtype != TYPE_MATRIX)
return false;
memcpy(&self->constval.vmat, v, sizeof(self->constval.vmat));
self->isconst = true;
return true;
}
bool ir_value_set_field(ir_value *self, ir_value *fld)
{
if (self->vtype != TYPE_FIELD)
@ -1432,8 +1406,6 @@ ir_value* ir_block_create_load_from_ent(ir_block *self, const char *label, ir_va
case TYPE_POINTER: op = INSTR_LOAD_I; break;
case TYPE_INTEGER: op = INSTR_LOAD_I; break;
#endif
case TYPE_QUATERNION: op = INSTR_LOAD_Q; break;
case TYPE_MATRIX: op = INSTR_LOAD_M; break;
default:
return NULL;
}
@ -1537,22 +1509,12 @@ ir_value* ir_block_create_mul(ir_block *self,
case TYPE_VECTOR:
op = INSTR_MUL_V;
break;
case TYPE_QUATERNION:
op = INSTR_MUL_Q;
break;
case TYPE_MATRIX:
op = INSTR_MUL_M;
break;
}
} else {
if ( (l == TYPE_VECTOR && r == TYPE_FLOAT) )
op = INSTR_MUL_VF;
else if ( (l == TYPE_FLOAT && r == TYPE_VECTOR) )
op = INSTR_MUL_FV;
else if ( (l == TYPE_QUATERNION && r == TYPE_FLOAT) )
op = INSTR_MUL_QF;
else if ( (l == TYPE_MATRIX && r == TYPE_FLOAT) )
op = INSTR_MUL_MF;
#if 0
else if ( (l == TYPE_VECTOR && r == TYPE_INTEGER) )
op = INSTR_MUL_VI;
@ -2618,8 +2580,6 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
return global->code.globaladdr >= 0;
}
case TYPE_VECTOR:
case TYPE_QUATERNION:
case TYPE_MATRIX:
{
size_t d;
if (code_defs_add(def) < 0)

4
ir.h
View file

@ -55,8 +55,6 @@ typedef struct ir_value_s {
char *vstring;
struct ir_value_s *vpointer;
struct ir_function_s *vfunc;
quaternion vquat;
matrix vmat;
} constval;
struct {
@ -100,8 +98,6 @@ bool GMQCC_WARN ir_value_set_vector(ir_value*, vector v);
bool GMQCC_WARN ir_value_set_field(ir_value*, ir_value *fld);
/*bool ir_value_set_pointer_v(ir_value*, ir_value* p); */
/*bool ir_value_set_pointer_i(ir_value*, int i); */
bool GMQCC_WARN ir_value_set_quaternion(ir_value*, quaternion v);
bool GMQCC_WARN ir_value_set_matrix(ir_value*, matrix v);
MEM_VECTOR_PROTO(ir_value, ir_life_entry_t, life);
/* merge an instruction into the life-range */