From: Wolfgang (Blub) Bumiller Date: Sun, 19 Aug 2012 15:29:36 +0000 (+0200) Subject: calls for now use store_value since we don't properly deal with its liferange yet... X-Git-Tag: 0.1-rc1~163 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e1ffa04bc2c905328c621818b1c704c2738da2d7;p=xonotic%2Fgmqcc.git 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 --- diff --git a/data/frames.qc b/data/frames.qc index 9534f4a..4e8e219 100644 --- a/data/frames.qc +++ b/data/frames.qc @@ -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); +}; + diff --git a/ir.c b/ir.c index 02fb656..26aec5c 100644 --- a/ir.c +++ b/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); }