add the vector-calls "optimisation" from fteqcc. makes it possible to

compile the version of frogbot with waypoints for almost 300 maps.
This commit is contained in:
Bill Currie 2005-06-10 07:31:25 +00:00
parent 116860bb66
commit 66cabb587f
6 changed files with 50 additions and 16 deletions

View file

@ -165,6 +165,12 @@ mode.
Use float values directly in \*(lqif\*(rq statements. Defaults to on. This
option is always enabled when using version 6 progs.
.TP
.B vector\-calls
Where a function is called with just a vector, this causes the function call to
store three floats instead of one vector. This can save a good number of
pr_globals where those vectors contain many duplicate coordinates but do not
match entirly. However, this will generate slower code for such calls.
.TP
.B v6only
Restrict the compiler to only version 6 progs (original Quake/QuakeWorld)
features. This means that the compiled data file should be able to run on
@ -229,7 +235,7 @@ report the details (operating system, detection methods, correct execution
specification). The base default execution spec (on most Linux systems) is
\fBcpp %d -o %o %i\fP. This spec is similar in concept to a \fBprintf\fP
string. The name of the program may be either absolute (eg \fB/lib/cpp\fP) or
relative as the \fBPATH\fB will be searched. Available substitutions:
relative as the \fBPATH\fP will be searched. Available substitutions:
.TP
.B %d
Mainly for defines (\-D, \-U and \-I) but \fB%d\fP will be replaced by all
@ -249,6 +255,13 @@ Sky-father, and Papatuanuku, the Earth-mother. Ruamoko is the god of
volcanoes and earthquakes \fB(Quake, get it?)\fP. For more information, see
the Web site at <\fBhttp://maori.com/kmst1.htm\fP>.
.TP
.B qfcc hangs
This is almost always caused by qfcc incorrectly invoking \fBcpp\fP. Using the
\fB--cpp\fP option (refer to the \fBCPP NAME\fP section above), the correct
method for invoking cpp can be specified. Once you have found this, please
send the correct \fBcpp\fP command line, preferably along with the output of
\fBconfig.guess\fP, to the team.
.TP
.B qfcc is singing a bad 80s rap song to me. What's going on?
\*(lqice ice baby\*(rq is QuakeForge-speak for \*(lqInternal Compiler
Error\*(rq. It usually means there's a bug in \fBqfcc\fP, so please report it

View file

@ -39,6 +39,7 @@ typedef struct {
qboolean debug; // Generate debug info for the engine
qboolean short_circuit; // short circuit logic for && and ||
qboolean fast_float; // use floats directly in ifs
qboolean vector_calls; // use floats instead of vectors for constant function args
unsigned int progsversion; // Progs version to generate code for
} code_options_t;

View file

@ -202,10 +202,11 @@ static def_t *
emit_function_call (expr_t *e, def_t *dest)
{
def_t *func = emit_sub_expr (e->e.expr.e1, 0);
def_t *parm;
def_t *ret;
def_t *arg;
def_t *p;
expr_t *earg;
expr_t *parm;
opcode_t *op;
int count = 0, ind;
@ -214,17 +215,34 @@ emit_function_call (expr_t *e, def_t *dest)
ind = count;
for (earg = e->e.expr.e2; earg; earg = earg->next) {
ind--;
parm = emit_sub_expr (new_param_expr (get_type (earg), ind), 0);
if (parm->type->type == ev_struct) {
expr_t *a = assign_expr (new_def_expr (parm), earg);
parm = new_param_expr (get_type (earg), ind);
if (extract_type (parm) == ev_struct) {
expr_t *a = assign_expr (parm, earg);
a->line = e->line;
a->file = e->file;
emit_expr (a);
} else {
arg = emit_sub_expr (earg, parm);
if (arg != parm) {
op = opcode_find ("=", arg->type, arg->type, &type_void);
emit_statement (e, op, arg, parm, 0);
if (options.code.vector_calls && earg->type == ex_vector) {
expr_t *a, *v, *n;
int i;
static const char *names[] = {"x", "y", "z"};
for (i = 0; i < 3; i++) {
n = new_name_expr (names[i]);
v = new_float_expr (earg->e.vector_val[i]);
a = assign_expr (binary_expr ('.', parm, n), v);
parm = new_param_expr (get_type (earg), ind);
a->line = e->line;
a->file = e->file;
emit_expr (a);
}
} else {
p = emit_sub_expr (parm, 0);
arg = emit_sub_expr (earg, p);
if (arg != p) {
op = opcode_find ("=", arg->type, arg->type, &type_void);
emit_statement (e, op, arg, p, 0);
}
}
}
}

View file

@ -953,7 +953,7 @@ field_expr (expr_t *e1, expr_t *e2)
break;
case ev_vector:
case ev_quat:
if (!options.traditional && e2->type == ex_name) {
if (e2->type == ex_name) {
if (t1->type == ev_quat) {
field = struct_find_field (quaternion_struct,
e2->e.string_val);

View file

@ -281,6 +281,8 @@ DecodeArgs (int argc, char **argv)
options.code.short_circuit = flag;
} else if (!(strcasecmp (temp, "fast-float"))) {
options.code.fast_float = flag;
} else if (!(strcasecmp (temp, "vector-calls"))) {
options.code.vector_calls = flag;
} else if (!(strcasecmp (temp, "v6only"))) {
if (flag)
options.code.progsversion = PROG_ID_VERSION;

View file

@ -656,6 +656,12 @@ init_types (void)
new_struct_field (strct, &type_integer, "integer_val", vis_public);
new_struct_field (strct, &type_uinteger, "uinteger_val", vis_public);
strct = vector_struct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_float, "x", vis_public);
new_struct_field (strct, &type_float, "y", vis_public);
new_struct_field (strct, &type_float, "z", vis_public);
if (options.traditional)
return;
@ -666,12 +672,6 @@ init_types (void)
strct = type_param.s.strct;
new_struct_field (strct, &type_quaternion, "quaternion_val", vis_public);
strct = vector_struct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_float, "x", vis_public);
new_struct_field (strct, &type_float, "y", vis_public);
new_struct_field (strct, &type_float, "z", vis_public);
strct = quaternion_struct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_float, "s", vis_public);