mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
calls for now use store_value since we don't properly deal with its liferange yet; fixing some local-alloation things; taking call parameters into account in ir_block_life_propagate
This commit is contained in:
parent
611973bc59
commit
e1ffa04bc2
2 changed files with 57 additions and 10 deletions
|
@ -9,7 +9,7 @@ entity() spawn = #3;
|
|||
void(entity) kill = #4;
|
||||
|
||||
$frame stand1 stand2 standX
|
||||
|
||||
/*
|
||||
.float frame;
|
||||
.float nextthink;
|
||||
.void() think;
|
||||
|
@ -20,11 +20,10 @@ float time;
|
|||
void() stand2;
|
||||
|
||||
void() stand1 = [ 0, stand2 ] {
|
||||
/* expands to:
|
||||
self.frame = 0;
|
||||
self.nextthink = time + 0.1;
|
||||
self.think = stand2
|
||||
*/
|
||||
// expands to:
|
||||
//self.frame = 0;
|
||||
//self.nextthink = time + 0.1;
|
||||
//self.think = stand2
|
||||
print("In stand 1...\n");
|
||||
print3("--> self.frame should be 0, is ", ftos(self.frame), "\n");
|
||||
};
|
||||
|
@ -34,6 +33,13 @@ void() stand2 = [ 1, stand1 ] {
|
|||
print3("--> self.frame should be 1, is ", ftos(self.frame), "\n");
|
||||
};
|
||||
|
||||
void() standm = {
|
||||
print3("Foo ", ftos(self), "\n");
|
||||
self.frame = 0;
|
||||
self.nextthink = time + 0.1;
|
||||
self.think = stand2;
|
||||
};
|
||||
|
||||
void() main = {
|
||||
self = spawn();
|
||||
|
||||
|
@ -43,7 +49,28 @@ void() main = {
|
|||
self.think = stand1;
|
||||
|
||||
print("Running think\n");
|
||||
standm();
|
||||
print("Running from 'self'\n");
|
||||
self.think();
|
||||
self.think();
|
||||
self.think();
|
||||
};
|
||||
*/
|
||||
|
||||
entity self;
|
||||
|
||||
.float frame;
|
||||
.float nextthink;
|
||||
|
||||
void(float a, float b) foo = {};
|
||||
|
||||
void() main = {
|
||||
self = spawn();
|
||||
self.frame = 1;
|
||||
self.nextthink = 2;
|
||||
print2(ftos(self.frame), "\n");
|
||||
print2(ftos(self.nextthink), "\n");
|
||||
foo(self.frame, self.nextthink);
|
||||
kill(self);
|
||||
};
|
||||
|
||||
|
|
28
ir.c
28
ir.c
|
@ -1225,7 +1225,7 @@ ir_instr* ir_block_create_call(ir_block *self, const char *label, ir_value *func
|
|||
in = ir_instr_new(self, INSTR_CALL0);
|
||||
if (!in)
|
||||
return NULL;
|
||||
out = ir_value_out(self->owner, label, store_return, func->outtype);
|
||||
out = ir_value_out(self->owner, label, store_value, func->outtype);
|
||||
if (!out) {
|
||||
ir_instr_delete(in);
|
||||
return NULL;
|
||||
|
@ -1844,7 +1844,7 @@ bool ir_function_allocate_locals(ir_function *self)
|
|||
|
||||
function_allocator alloc;
|
||||
|
||||
if (!self->locals_count)
|
||||
if (!self->locals_count && !self->values_count)
|
||||
return true;
|
||||
|
||||
MEM_VECTOR_INIT(&alloc, locals);
|
||||
|
@ -1907,8 +1907,9 @@ bool ir_function_allocate_locals(ir_function *self)
|
|||
self->allocated_locals = pos + alloc.sizes[alloc.sizes_count-1];
|
||||
|
||||
/* Take over the actual slot positions */
|
||||
for (i = 0; i < self->values_count; ++i)
|
||||
for (i = 0; i < self->values_count; ++i) {
|
||||
self->values[i]->code.local = alloc.positions[self->values[i]->code.local];
|
||||
}
|
||||
|
||||
goto cleanup;
|
||||
|
||||
|
@ -2053,6 +2054,25 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change
|
|||
#endif
|
||||
}
|
||||
|
||||
/* call params are read operands too */
|
||||
for (p = 0; p < instr->params_count; ++p)
|
||||
{
|
||||
value = instr->params[p];
|
||||
#if ! defined(LIFE_RANGE_WITHOUT_LAST_READ)
|
||||
if (!ir_block_living_find(self, value, NULL) &&
|
||||
!ir_block_living_add(self, value))
|
||||
{
|
||||
goto on_error;
|
||||
}
|
||||
#else
|
||||
if (!new_reads_t_v_find(&new_reads, value, NULL))
|
||||
{
|
||||
if (!new_reads_t_v_add(&new_reads, value))
|
||||
goto on_error;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* See which operands are read and write operands */
|
||||
ir_op_read_write(instr->opcode, &read, &write);
|
||||
|
||||
|
@ -2566,7 +2586,7 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
|
|||
ir_value *v = irfun->values[i];
|
||||
ir_value_code_setaddr(v, local_var_end + v->code.local);
|
||||
}
|
||||
for (i = 0; i < irfun->locals_count; ++i) {
|
||||
for (i = 0; i < irfun->allocated_locals; ++i) {
|
||||
/* fill the locals with zeros */
|
||||
code_globals_add(0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue