mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Clean up duplicated vector list construction
I wound up with a few too many copies for my liking.
This commit is contained in:
parent
81aa77b142
commit
ad45715359
3 changed files with 26 additions and 26 deletions
|
@ -745,6 +745,8 @@ float expr_float (const expr_t *e) __attribute__((pure));
|
||||||
const expr_t *new_vector_expr (const float *vector_val);
|
const expr_t *new_vector_expr (const float *vector_val);
|
||||||
const float *expr_vector (const expr_t *e) __attribute__((pure));
|
const float *expr_vector (const expr_t *e) __attribute__((pure));
|
||||||
const expr_t *new_vector_list (const expr_t *e);
|
const expr_t *new_vector_list (const expr_t *e);
|
||||||
|
const expr_t *new_vector_list_gather (const type_t *type,
|
||||||
|
const expr_t **elements, int count);
|
||||||
const expr_t *new_vector_value (const type_t *ele_type, int width,
|
const expr_t *new_vector_value (const type_t *ele_type, int width,
|
||||||
int count, const expr_t **elements,
|
int count, const expr_t **elements,
|
||||||
bool implicit);
|
bool implicit);
|
||||||
|
|
|
@ -127,25 +127,20 @@ construct_by_components (const type_t *type, const expr_t *params,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vec = new_expr ();
|
|
||||||
vec->type = ex_vector;
|
|
||||||
vec->vector.type = type;
|
|
||||||
if (is_matrix (type)) {
|
if (is_matrix (type)) {
|
||||||
const expr_t *columns[type_cols (type)];
|
auto ctype = column_type (type);
|
||||||
|
int num_cols = type_cols (type);
|
||||||
|
int num_rows = type_rows (type);
|
||||||
|
const expr_t *columns[num_cols];
|
||||||
const expr_t **col = components;
|
const expr_t **col = components;
|
||||||
for (int i = 0; i < type_cols (type); i++) {
|
for (int i = 0; i < num_cols; i++) {
|
||||||
auto c = new_expr ();
|
columns[i] = new_vector_list_gather (ctype, col, num_rows);
|
||||||
c->type = ex_vector;
|
col += num_rows;
|
||||||
c->vector.type = column_type (type);
|
|
||||||
list_gather (&c->vector.list, col, type_rows (type));
|
|
||||||
columns[i] = c;
|
|
||||||
col += type_rows (type);
|
|
||||||
}
|
}
|
||||||
list_gather (&vec->vector.list, columns, type_cols (type));
|
return new_vector_list_gather (type, columns, num_cols);
|
||||||
} else {
|
} else {
|
||||||
list_gather (&vec->vector.list, components, num_comp);
|
return new_vector_list_gather (type, components, num_comp);
|
||||||
}
|
}
|
||||||
return vec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const expr_t *
|
static const expr_t *
|
||||||
|
@ -170,7 +165,7 @@ construct_diagonal (const type_t *type, const expr_t *scalar, const expr_t *e)
|
||||||
static const expr_t *
|
static const expr_t *
|
||||||
construct_matrix (const type_t *type, const expr_t *matrix, const expr_t *e)
|
construct_matrix (const type_t *type, const expr_t *matrix, const expr_t *e)
|
||||||
{
|
{
|
||||||
scoped_src_loc (matrix);
|
scoped_src_loc (e);
|
||||||
int cols = type_cols (type);
|
int cols = type_cols (type);
|
||||||
int rows = type_rows (type);
|
int rows = type_rows (type);
|
||||||
int src_cols = type_cols (get_type (matrix));
|
int src_cols = type_cols (get_type (matrix));
|
||||||
|
@ -197,7 +192,7 @@ construct_matrix (const type_t *type, const expr_t *matrix, const expr_t *e)
|
||||||
static const expr_t *
|
static const expr_t *
|
||||||
construct_broadcast (const type_t *type, const expr_t *scalar, const expr_t *e)
|
construct_broadcast (const type_t *type, const expr_t *scalar, const expr_t *e)
|
||||||
{
|
{
|
||||||
scoped_src_loc (scalar);
|
scoped_src_loc (e);
|
||||||
int width = type_width (type);
|
int width = type_width (type);
|
||||||
const expr_t *components[width + 1] = {};
|
const expr_t *components[width + 1] = {};
|
||||||
|
|
||||||
|
@ -240,11 +235,8 @@ math_constructor (const type_t *type, const expr_t *params, const expr_t *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (by_vector) {
|
if (by_vector) {
|
||||||
auto mat = new_expr ();
|
scoped_src_loc (e);
|
||||||
mat->type = ex_vector;
|
return new_vector_list_gather (type, param_exprs, type_cols (type));
|
||||||
mat->vector.type = type;
|
|
||||||
list_gather (&mat->vector.list, param_exprs, type_cols (type));
|
|
||||||
return mat;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return construct_by_components (type, params, e);
|
return construct_by_components (type, params, e);
|
||||||
|
|
|
@ -68,6 +68,15 @@ new_matrix_value (const type_t *ele_type, int cols, int rows, int count,
|
||||||
return new_value_expr (new_type_value (mat_type, value), implicit);
|
return new_value_expr (new_type_value (mat_type, value), implicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const expr_t *
|
||||||
|
new_vector_list_gather (const type_t *type, const expr_t **elements, int count)
|
||||||
|
{
|
||||||
|
auto vec = new_expr ();
|
||||||
|
vec->type = ex_vector;
|
||||||
|
vec->vector.type = type;
|
||||||
|
list_gather (&vec->vector.list, elements, count);
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
const expr_t *
|
const expr_t *
|
||||||
new_vector_list (const expr_t *expr_list)
|
new_vector_list (const expr_t *expr_list)
|
||||||
|
@ -155,11 +164,8 @@ new_vector_list (const expr_t *expr_list)
|
||||||
all_implicit);
|
all_implicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t *vec = new_expr ();
|
auto type = vector_type (ele_type, width);
|
||||||
vec->type = ex_vector;
|
return new_vector_list_gather (type, elements, count);
|
||||||
vec->vector.type = vector_type (ele_type, width);
|
|
||||||
list_gather (&vec->vector.list, elements, count);
|
|
||||||
return vec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const expr_t *
|
const expr_t *
|
||||||
|
|
Loading…
Reference in a new issue