6 /***********************************************************************
10 ir_builder* ir_builder_new(const char *modulename)
14 self = (ir_builder*)mem_a(sizeof(*self));
15 MEM_VECTOR_INIT(self, functions);
16 MEM_VECTOR_INIT(self, globals);
18 ir_builder_set_name(self, modulename);
20 /* globals which always exist */
22 /* for now we give it a vector size */
23 ir_builder_create_global(self, "OFS_RETURN", qc_variant);
28 MEM_VEC_FUNCTIONS(ir_builder, ir_value*, globals)
29 MEM_VEC_FUNCTIONS(ir_builder, ir_function*, functions)
31 void ir_builder_delete(ir_builder* self)
34 mem_d((void*)self->name);
35 for (i = 0; i != self->functions_count; ++i) {
36 ir_function_delete(self->functions[i]);
38 MEM_VECTOR_CLEAR(self, functions);
39 for (i = 0; i != self->globals_count; ++i) {
40 ir_value_delete(self->globals[i]);
42 MEM_VECTOR_CLEAR(self, globals);
46 void ir_builder_set_name(ir_builder *self, const char *name)
49 mem_d((void*)self->name);
50 self->name = util_strdup(name);
53 ir_function* ir_builder_get_function(ir_builder *self, const char *name)
56 for (i = 0; i < self->functions_count; ++i) {
57 if (!strcmp(name, self->functions[i]->name))
58 return self->functions[i];
63 ir_function* ir_builder_create_function(ir_builder *self, const char *name)
65 ir_function *fn = ir_builder_get_function(self, name);
70 fn = ir_function_new(self);
71 ir_function_set_name(fn, name);
72 ir_builder_functions_add(self, fn);
76 ir_value* ir_builder_get_global(ir_builder *self, const char *name)
79 for (i = 0; i < self->globals_count; ++i) {
80 if (!strcmp(self->globals[i]->name, name))
81 return self->globals[i];
86 ir_value* ir_builder_create_global(ir_builder *self, const char *name, int vtype)
88 ir_value *ve = ir_builder_get_global(self, name);
93 ve = ir_value_var(name, store_global, vtype);
94 ir_builder_globals_add(self, ve);
98 /***********************************************************************
102 void ir_function_naive_phi(ir_function*);
103 void ir_function_enumerate(ir_function*);
104 void ir_function_calculate_liferanges(ir_function*);
106 ir_function* ir_function_new(ir_builder* owner)
109 self = (ir_function*)mem_a(sizeof(*self));
111 self->context.file = "<@no context>";
112 self->context.line = 0;
113 self->retype = qc_void;
114 MEM_VECTOR_INIT(self, params);
115 MEM_VECTOR_INIT(self, blocks);
116 MEM_VECTOR_INIT(self, values);
117 MEM_VECTOR_INIT(self, locals);
118 ir_function_set_name(self, "<@unnamed>");
123 MEM_VEC_FUNCTIONS(ir_function, ir_value*, values)
124 MEM_VEC_FUNCTIONS(ir_function, ir_block*, blocks)
125 MEM_VEC_FUNCTIONS(ir_function, ir_value*, locals)
127 void ir_function_set_name(ir_function *self, const char *name)
130 mem_d((void*)self->name);
131 self->name = util_strdup(name);
134 void ir_function_delete(ir_function *self)
137 mem_d((void*)self->name);
139 for (i = 0; i != self->blocks_count; ++i)
140 ir_block_delete(self->blocks[i]);
141 MEM_VECTOR_CLEAR(self, blocks);
143 MEM_VECTOR_CLEAR(self, params);
145 for (i = 0; i != self->values_count; ++i)
146 ir_value_delete(self->values[i]);
147 MEM_VECTOR_CLEAR(self, values);
149 for (i = 0; i != self->locals_count; ++i)
150 ir_value_delete(self->locals[i]);
151 MEM_VECTOR_CLEAR(self, locals);
156 void ir_function_collect_value(ir_function *self, ir_value *v)
158 ir_function_values_add(self, v);
161 ir_block* ir_function_create_block(ir_function *self, const char *label)
163 ir_block* bn = ir_block_new(self, label);
164 memcpy(&bn->context, &self->context, sizeof(self->context));
165 ir_function_blocks_add(self, bn);
169 void ir_function_finalize(ir_function *self)
171 ir_function_naive_phi(self);
172 ir_function_enumerate(self);
173 ir_function_calculate_liferanges(self);
176 ir_value* ir_function_get_local(ir_function *self, const char *name)
179 for (i = 0; i < self->locals_count; ++i) {
180 if (!strcmp(self->locals[i]->name, name))
181 return self->locals[i];
186 ir_value* ir_function_create_local(ir_function *self, const char *name, int vtype)
188 ir_value *ve = ir_function_get_local(self, name);
193 ve = ir_value_var(name, store_local, vtype);
194 ir_function_locals_add(self, ve);
198 /***********************************************************************
202 ir_block* ir_block_new(ir_function* owner, const char *name)
205 self = (ir_block*)mem_a(sizeof(*self));
207 self->context.file = "<@no context>";
208 self->context.line = 0;
210 MEM_VECTOR_INIT(self, instr);
211 MEM_VECTOR_INIT(self, entries);
212 MEM_VECTOR_INIT(self, exits);
214 ir_block_set_label(self, name);
217 self->is_return = false;
219 MEM_VECTOR_INIT(self, living);
222 MEM_VEC_FUNCTIONS(ir_block, ir_instr*, instr)
223 MEM_VEC_FUNCTIONS_ALL(ir_block, ir_block*, entries)
224 MEM_VEC_FUNCTIONS_ALL(ir_block, ir_block*, exits)
225 MEM_VEC_FUNCTIONS_ALL(ir_block, ir_value*, living)
227 void ir_block_delete(ir_block* self)
230 mem_d((void*)self->label);
231 for (i = 0; i != self->instr_count; ++i)
232 ir_instr_delete(self->instr[i]);
233 MEM_VECTOR_CLEAR(self, instr);
234 MEM_VECTOR_CLEAR(self, entries);
235 MEM_VECTOR_CLEAR(self, exits);
236 MEM_VECTOR_CLEAR(self, living);
240 void ir_block_set_label(ir_block *self, const char *name)
243 mem_d((void*)self->label);
244 self->label = util_strdup(name);
247 /***********************************************************************
251 ir_instr* ir_instr_new(ir_block* owner, int op)
254 self = (ir_instr*)mem_a(sizeof(*self));
256 self->context.file = "<@no context>";
257 self->context.line = 0;
259 self->_ops[0] = NULL;
260 self->_ops[1] = NULL;
261 self->_ops[2] = NULL;
262 self->bops[0] = NULL;
263 self->bops[1] = NULL;
264 MEM_VECTOR_INIT(self, phi);
269 MEM_VEC_FUNCTIONS(ir_instr, ir_phi_entry_t, phi)
271 void ir_instr_delete(ir_instr *self)
273 ir_instr_op(self, 0, NULL, false);
274 ir_instr_op(self, 1, NULL, false);
275 ir_instr_op(self, 2, NULL, false);
276 MEM_VECTOR_CLEAR(self, phi);
280 void ir_instr_op(ir_instr *self, int op, ir_value *v, qbool writing)
282 if (self->_ops[op]) {
284 ir_value_writes_add(self->_ops[op], self);
286 ir_value_reads_add(self->_ops[op], self);
290 ir_value_writes_add(v, self);
292 ir_value_reads_add(v, self);
297 /***********************************************************************
301 ir_value* ir_value_var(const char *name, int storetype, int vtype)
304 self = (ir_value*)mem_a(sizeof(*self));
306 self->store = storetype;
307 MEM_VECTOR_INIT(self, reads);
308 MEM_VECTOR_INIT(self, writes);
309 self->isconst = false;
310 self->context.file = "<@no context>";
311 self->context.line = 0;
313 ir_value_set_name(self, name);
315 MEM_VECTOR_INIT(self, life);
318 MEM_VEC_FUNCTIONS(ir_value, ir_life_entry_t, life)
319 MEM_VEC_FUNCTIONS(ir_value, ir_instr*, reads)
320 MEM_VEC_FUNCTIONS(ir_value, ir_instr*, writes)
322 ir_value* ir_value_out(ir_function *owner, const char *name, int storetype, int vtype)
324 ir_value *v = ir_value_var(name, storetype, vtype);
325 ir_function_collect_value(owner, v);
329 void ir_value_delete(ir_value* self)
331 mem_d((void*)self->name);
334 if (self->vtype == qc_string)
335 mem_d((void*)self->constval.vstring);
337 MEM_VECTOR_CLEAR(self, reads);
338 MEM_VECTOR_CLEAR(self, writes);
339 MEM_VECTOR_CLEAR(self, life);
343 void ir_value_set_name(ir_value *self, const char *name)
346 mem_d((void*)self->name);
347 self->name = util_strdup(name);
350 qbool ir_value_set_float(ir_value *self, float f)
352 if (self->vtype != qc_float)
354 self->constval.vfloat = f;
355 self->isconst = true;
359 qbool ir_value_set_vector(ir_value *self, vector_t v)
361 if (self->vtype != qc_vector)
363 self->constval.vvec = v;
364 self->isconst = true;
368 qbool ir_value_set_string(ir_value *self, const char *str)
370 if (self->vtype != qc_string)
372 self->constval.vstring = util_strdup(str);
373 self->isconst = true;
377 qbool ir_value_set_int(ir_value *self, int i)
379 if (self->vtype != qc_int)
381 self->constval.vint = i;
382 self->isconst = true;
386 qbool ir_value_lives(ir_value *self, size_t at)
389 for (i = 0; i < self->life_count; ++i)
391 ir_life_entry_t *life = &self->life[i];
392 if (life->start <= at && at <= life->end)
394 if (life->start > at) /* since it's ordered */
400 void ir_value_life_insert(ir_value *self, size_t idx, ir_life_entry_t e)
403 ir_value_life_add(self, e); /* naive... */
404 for (k = self->life_count-1; k > idx; --k)
405 self->life[k] = self->life[k-1];
409 qbool ir_value_life_merge(ir_value *self, size_t s)
412 ir_life_entry_t *life = NULL;
413 ir_life_entry_t *before = NULL;
414 ir_life_entry_t new_entry;
416 /* Find the first range >= s */
417 for (i = 0; i < self->life_count; ++i)
420 life = &self->life[i];
424 /* nothing found? append */
425 if (i == self->life_count) {
426 if (life && life->end+1 == s)
428 /* previous life range can be merged in */
432 if (life && life->end >= s)
436 ir_value_life_add(self, e);
442 if (before->end + 1 == s &&
443 life->start - 1 == s)
446 before->end = life->end;
447 ir_value_life_remove(self, i);
450 if (before->end + 1 == s)
456 /* already contained */
457 if (before->end >= s)
461 if (life->start - 1 == s)
466 /* insert a new entry */
467 new_entry.start = new_entry.end = s;
468 ir_value_life_insert(self, i, new_entry);
472 /***********************************************************************
476 qbool ir_block_create_store_op(ir_block *self, int op, ir_value *target, ir_value *what)
478 if (target->store == store_value) {
479 fprintf(stderr, "cannot store to an SSA value\n");
482 ir_instr *in = ir_instr_new(self, op);
483 ir_instr_op(in, 0, target, true);
484 ir_instr_op(in, 1, what, false);
485 ir_block_instr_add(self, in);
490 qbool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what)
494 if (target->vtype == qc_variant)
497 vtype = target->vtype;
502 if (what->vtype == qc_int)
503 op = INSTR_CONV_ITOF;
512 op = INSTR_STORE_ENT;
519 if (what->vtype == qc_int)
520 op = INSTR_CONV_FTOI;
529 op = INSTR_STORE_ENT;
533 return ir_block_create_store_op(self, op, target, what);
536 void ir_block_create_return(ir_block *self, ir_value *v)
540 fprintf(stderr, "block already ended (%s)\n", self->label);
544 self->is_return = true;
545 in = ir_instr_new(self, INSTR_RETURN);
546 ir_instr_op(in, 0, v, false);
547 ir_block_instr_add(self, in);
550 void ir_block_create_if(ir_block *self, ir_value *v,
551 ir_block *ontrue, ir_block *onfalse)
555 fprintf(stderr, "block already ended (%s)\n", self->label);
559 //in = ir_instr_new(self, (v->vtype == qc_string ? INSTR_IF_S : INSTR_IF_F));
560 in = ir_instr_new(self, VINSTR_COND);
561 ir_instr_op(in, 0, v, false);
562 in->bops[0] = ontrue;
563 in->bops[1] = onfalse;
564 ir_block_instr_add(self, in);
566 ir_block_exits_add(self, ontrue);
567 ir_block_exits_add(self, onfalse);
568 ir_block_entries_add(ontrue, self);
569 ir_block_entries_add(onfalse, self);
572 void ir_block_create_jump(ir_block *self, ir_block *to)
576 fprintf(stderr, "block already ended (%s)\n", self->label);
580 in = ir_instr_new(self, VINSTR_JUMP);
582 ir_block_instr_add(self, in);
584 ir_block_exits_add(self, to);
585 ir_block_entries_add(to, self);
588 void ir_block_create_goto(ir_block *self, ir_block *to)
592 fprintf(stderr, "block already ended (%s)\n", self->label);
596 in = ir_instr_new(self, INSTR_GOTO);
598 ir_block_instr_add(self, in);
600 ir_block_exits_add(self, to);
601 ir_block_entries_add(to, self);
604 ir_instr* ir_block_create_phi(ir_block *self, const char *label, int ot)
608 in = ir_instr_new(self, VINSTR_PHI);
609 out = ir_value_out(self->owner, label, store_local, ot);
610 ir_instr_op(in, 0, out, true);
611 ir_block_instr_add(self, in);
615 ir_value* ir_phi_value(ir_instr *self)
617 return self->_ops[0];
620 void ir_phi_add(ir_instr* self, ir_block *b, ir_value *v)
624 if (!ir_block_entries_find(self->owner, b, NULL)) {
625 /* Must not be possible to cause this, otherwise the AST
626 * is doing something wrong.
628 fprintf(stderr, "Invalid entry block for PHI\n");
634 ir_value_reads_add(v, self);
635 ir_instr_phi_add(self, pe);
638 /* binary op related code */
640 ir_value* ir_block_create_binop(ir_block *self,
641 const char *label, int opcode,
642 ir_value *left, ir_value *right)
664 case INSTR_SUB_S: /* -- offset of string as float */
671 case INSTR_BITAND_FI:
672 case INSTR_BITAND_IF:
713 /* boolean operations result in floats */
714 if (opcode >= INSTR_EQ_F && opcode <= INSTR_GT)
716 else if (opcode >= INSTR_LE && opcode <= INSTR_GT)
719 else if (opcode >= INSTR_LE_I && opcode <= INSTR_EQ_FI)
725 /* The AST or parser were supposed to check this! */
729 ir_value *out = ir_value_out(self->owner, label, store_local, ot);
730 ir_instr *in = ir_instr_new(self, opcode);
731 ir_instr_op(in, 0, out, true);
732 ir_instr_op(in, 1, left, false);
733 ir_instr_op(in, 2, right, false);
734 ir_block_instr_add(self, in);
738 ir_value* ir_block_create_add(ir_block *self,
740 ir_value *left, ir_value *right)
744 int r = right->vtype;
763 if ( (l == qc_float && r == qc_int) )
765 else if ( (l == qc_int && r == qc_float) )
771 return ir_block_create_binop(self, label, op, left, right);
774 ir_value* ir_block_create_sub(ir_block *self,
776 ir_value *left, ir_value *right)
780 int r = right->vtype;
800 if ( (l == qc_float && r == qc_int) )
802 else if ( (l == qc_int && r == qc_float) )
808 return ir_block_create_binop(self, label, op, left, right);
811 ir_value* ir_block_create_mul(ir_block *self,
813 ir_value *left, ir_value *right)
817 int r = right->vtype;
836 if ( (l == qc_vector && r == qc_float) )
838 else if ( (l == qc_float && r == qc_vector) )
841 else if ( (l == qc_vector && r == qc_int) )
843 else if ( (l == qc_int && r == qc_vector) )
845 else if ( (l == qc_float && r == qc_int) )
847 else if ( (l == qc_int && r == qc_float) )
853 return ir_block_create_binop(self, label, op, left, right);
856 ir_value* ir_block_create_div(ir_block *self,
858 ir_value *left, ir_value *right)
862 int r = right->vtype;
879 if ( (l == qc_vector && r == qc_float) )
881 else if ( (l == qc_float && r == qc_int) )
883 else if ( (l == qc_int && r == qc_float) )
889 return ir_block_create_binop(self, label, op, left, right);
892 /* PHI resolving breaks the SSA, and must thus be the last
893 * step before life-range calculation.
896 static void ir_block_naive_phi(ir_block *self);
897 void ir_function_naive_phi(ir_function *self)
901 for (i = 0; i < self->blocks_count; ++i)
902 ir_block_naive_phi(self->blocks[i]);
905 static void ir_naive_phi_emit_store(ir_block *block, size_t iid, ir_value *old, ir_value *what)
911 ir_block_create_store(block, old, what);
913 /* we now move it up */
914 instr = block->instr[block->instr_count-1];
915 for (i = block->instr_count; i > iid; --i)
916 block->instr[i] = block->instr[i-1];
917 block->instr[i] = instr;
920 static void ir_block_naive_phi(ir_block *self)
923 /* FIXME: optionally, create_phi can add the phis
924 * to a list so we don't need to loop through blocks
925 * - anyway: "don't optimize YET"
927 for (i = 0; i < self->instr_count; ++i)
929 ir_instr *instr = self->instr[i];
930 if (instr->opcode != VINSTR_PHI)
933 ir_block_instr_remove(self, i);
934 --i; /* NOTE: i+1 below */
936 for (p = 0; p < instr->phi_count; ++p)
938 ir_value *v = instr->phi[p].value;
939 for (w = 0; w < v->writes_count; ++w) {
942 if (!v->writes[w]->_ops[0])
945 /* When the write was to a global, we have to emit a mov */
946 old = v->writes[w]->_ops[0];
948 /* The original instruction now writes to the PHI target local */
949 if (v->writes[w]->_ops[0] == v)
950 v->writes[w]->_ops[0] = instr->_ops[0];
952 if (old->store != store_local)
954 /* If it originally wrote to a global we need to store the value
957 ir_naive_phi_emit_store(self, i+1, old, v);
958 if (i+1 < self->instr_count)
959 instr = self->instr[i+1];
962 /* In case I forget and access instr later, it'll be NULL
963 * when it's a problem, to make sure we crash, rather than accessing
969 /* If it didn't, we can replace all reads by the phi target now. */
971 for (r = 0; r < old->reads_count; ++r)
974 ir_instr *ri = old->reads[r];
975 for (op = 0; op < ri->phi_count; ++op) {
976 if (ri->phi[op].value == old)
977 ri->phi[op].value = v;
979 for (op = 0; op < 3; ++op) {
980 if (ri->_ops[op] == old)
987 ir_instr_delete(instr);
991 /***********************************************************************
992 *IR Temp allocation code
993 * Propagating value life ranges by walking through the function backwards
994 * until no more changes are made.
995 * In theory this should happen once more than once for every nested loop
997 * Though this implementation might run an additional time for if nests.
1006 MEM_VEC_FUNCTIONS_ALL(new_reads_t, ir_value*, v)
1008 /* Enumerate instructions used by value's life-ranges
1010 static void ir_block_enumerate(ir_block *self, size_t *_eid)
1014 for (i = 0; i < self->instr_count; ++i)
1016 self->instr[i]->eid = eid++;
1021 /* Enumerate blocks and instructions.
1022 * The block-enumeration is unordered!
1023 * We do not really use the block enumreation, however
1024 * the instruction enumeration is important for life-ranges.
1026 void ir_function_enumerate(ir_function *self)
1029 size_t instruction_id = 0;
1030 for (i = 0; i < self->blocks_count; ++i)
1032 self->blocks[i]->eid = i;
1033 self->blocks[i]->run_id = 0;
1034 ir_block_enumerate(self->blocks[i], &instruction_id);
1038 static void ir_block_life_propagate(ir_block *b, ir_block *prev, qbool *changed);
1039 void ir_function_calculate_liferanges(ir_function *self)
1047 for (i = 0; i != self->blocks_count; ++i)
1049 if (self->blocks[i]->is_return)
1050 ir_block_life_propagate(self->blocks[i], NULL, &changed);
1055 /* Get information about which operand
1056 * is read from, or written to.
1058 static void ir_op_read_write(int op, size_t *read, size_t *write)
1085 static qbool ir_block_living_add_instr(ir_block *self, size_t eid)
1088 qbool changed = false;
1090 for (i = 0; i != self->living_count; ++i)
1092 tempbool = ir_value_life_merge(self->living[i], eid);
1095 fprintf(stderr, "block_living_add_instr() value instruction added %s: %i\n", self->living[i]->_name, (int)eid);
1097 changed = changed || tempbool;
1102 static void ir_block_life_prop_previous(ir_block* self, ir_block *prev, qbool *changed)
1105 /* values which have been read in a previous iteration are now
1106 * in the "living" array even if the previous block doesn't use them.
1107 * So we have to remove whatever does not exist in the previous block.
1108 * They will be re-added on-read, but the liferange merge won't cause
1111 for (i = 0; i < self->living_count; ++i)
1113 if (!ir_block_living_find(prev, self->living[i], NULL)) {
1114 ir_block_living_remove(self, i);
1119 /* Whatever the previous block still has in its living set
1120 * must now be added to ours as well.
1122 for (i = 0; i < prev->living_count; ++i)
1124 if (ir_block_living_find(self, prev->living[i], NULL))
1126 ir_block_living_add(self, prev->living[i]);
1128 printf("%s got from prev: %s\n", self->label, prev->living[i]->_name);
1133 static void ir_block_life_propagate(ir_block *self, ir_block *prev, qbool *changed)
1139 /* bitmasks which operands are read from or written to */
1141 new_reads_t new_reads;
1142 char dbg_ind[16] = { '#', '0' };
1145 MEM_VECTOR_INIT(&new_reads, v);
1148 ir_block_life_prop_previous(self, prev, changed);
1150 i = self->instr_count;
1153 instr = self->instr[i];
1155 /* PHI operands are always read operands */
1156 for (p = 0; p < instr->phi_count; ++p)
1158 value = instr->phi[p].value;
1159 /* used this before new_reads - puts the last read into the life range as well
1160 if (!ir_block_living_find(self, value, NULL))
1161 ir_block_living_add(self, value);
1163 /* fprintf(stderr, "read: %s\n", value->_name); */
1164 if (!new_reads_t_v_find(&new_reads, value, NULL))
1165 new_reads_t_v_add(&new_reads, value);
1168 /* See which operands are read and write operands */
1169 ir_op_read_write(instr->opcode, &read, &write);
1171 /* Go through the 3 main operands */
1172 for (o = 0; o < 3; ++o)
1174 if (!instr->_ops[o]) /* no such operand */
1177 value = instr->_ops[o];
1179 /* We only care about locals */
1180 if (value->store != store_value &&
1181 value->store != store_local)
1187 /* used this before new_reads - puts the last read into the life range as well
1188 if (!ir_block_living_find(self, value, NULL))
1189 ir_block_living_add(self, value);
1191 /* fprintf(stderr, "read: %s\n", value->_name); */
1192 if (!new_reads_t_v_find(&new_reads, value, NULL))
1193 new_reads_t_v_add(&new_reads, value);
1196 /* write operands */
1197 /* When we write to a local, we consider it "dead" for the
1198 * remaining upper part of the function, since in SSA a value
1199 * can only be written once (== created)
1203 size_t idx, readidx;
1204 qbool in_living = ir_block_living_find(self, value, &idx);
1205 qbool in_reads = new_reads_t_v_find(&new_reads, value, &readidx);
1206 if (!in_living && !in_reads)
1208 /* If the value isn't alive it hasn't been read before... */
1209 /* TODO: See if the warning can be emitted during parsing or AST processing
1210 * otherwise have warning printed here.
1211 * IF printing a warning here: include filecontext_t,
1212 * and make sure it's only printed once
1213 * since this function is run multiple times.
1215 /* For now: debug info: */
1216 fprintf(stderr, "Value only written %s\n", value->name);
1217 tempbool = ir_value_life_merge(value, instr->eid);
1218 *changed = *changed || tempbool;
1220 ir_instr_dump(instr, dbg_ind, printf);
1224 /* since 'living' won't contain it
1225 * anymore, merge the value, since
1228 tempbool = ir_value_life_merge(value, instr->eid);
1231 fprintf(stderr, "value added id %s %i\n", value->name, (int)instr->eid);
1233 *changed = *changed || tempbool;
1235 ir_block_living_remove(self, idx);
1237 new_reads_t_v_remove(&new_reads, readidx);
1242 tempbool = ir_block_living_add_instr(self, instr->eid);
1243 //fprintf(stderr, "living added values\n");
1244 *changed = *changed || tempbool;
1247 for (rd = 0; rd < new_reads.v_count; ++rd)
1249 if (!ir_block_living_find(self, new_reads.v[rd], NULL)) {
1250 ir_block_living_add(self, new_reads.v[rd]);
1252 if (!i && !self->entries_count) {
1254 *changed = *changed || ir_value_life_merge(new_reads.v[rd], instr->eid);
1257 new_reads_t_v_clear(&new_reads);
1260 if (self->run_id == self->owner->run_id)
1262 self->run_id = self->owner->run_id;
1264 for (i = 0; i < self->entries_count; ++i)
1266 ir_block *entry = self->entries[i];
1267 ir_block_life_propagate(entry, self, changed);