TYPE_FUNCTION ,
TYPE_POINTER ,
TYPE_INTEGER ,
- TYPE_QUATERNION ,
- TYPE_MATRIX ,
TYPE_VARIANT ,
TYPE_COUNT
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,
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
{ "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 },
{ "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 */
};
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.
#if 0
"integer",
#endif
- "quaternion",
- "matrix",
"variant"
};
#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] = {
#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] = {
#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)
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)
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;
}
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;
return global->code.globaladdr >= 0;
}
case TYPE_VECTOR:
- case TYPE_QUATERNION:
- case TYPE_MATRIX:
{
size_t d;
if (code_defs_add(def) < 0)
char *vstring;
struct ir_value_s *vpointer;
struct ir_function_s *vfunc;
- quaternion vquat;
- matrix vmat;
} constval;
struct {
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 */