def false_to(self, cond_id, name_f): r'''Branch to 'name_f' if `triple` 'cond_id' is false. True falls through. This method is only called on Current_block. ''' if self.more(): Current_block.false_to(cond_id, name_f) else: self.last_triple = triple.triple('if-false', cond_id, string=name_f) self.next_conditional = name_f self.state = 'end_fall_through'
def gen_triple(self, operator, int1=None, int2=None, string=None, syntax_position_info=None, call_triple=None): r'''Create a new triple for this block. This method is only called on Current_block. ''' #print self.name, "gen_triple", operator, int1, int2, string if self.more(): return Current_block.gen_triple(operator, int1, int2, string, syntax_position_info, call_triple) if operator in ('global', 'local'): if int1 in self.labels and int1 not in self.dirty_labels: return self.labels[int1] if operator == 'call_direct': assert isinstance(int1, symbol_table.symbol) fn_symbol = int1 ans = triple.triple(operator, fn_symbol, int2, string, syntax_position_info) uses_vars, sets_vars = fn_xref.get_var_uses(fn_symbol.id) uses_or_sets_vars = uses_vars.union(sets_vars) for var_id in uses_vars.intersection(self.labels): self.labels[var_id].add_label(var_id, False) if fn_symbol.side_effects: if self.side_effects is not None: ans.add_hard_predecessor(self.side_effects) self.side_effects = ans for var_id in sets_vars.intersection(self.uses_global): for t in self.uses_global[var_id]: ans.add_soft_predecessor(t) del self.uses_global[var_id] for var_id in uses_or_sets_vars.intersection(self.sets_global): ans.add_hard_dependency(self.sets_global[var_id]) for var_id in uses_vars: self.uses_global[var_id].append(ans) for var_id in sets_vars: self.sets_global[var_id] = ans if var_id in self.labels: self.dirty_labels.add(var_id) return ans if operator == 'call_indirect': raise AssertionError("call_indirect not yet implemented") if operator not in ('param', 'input', 'input-bit', 'output', 'output-bit-set', 'output-bit-clear', 'var_data', 'const_data', 'bss', 'ioreg_init', 'eeprom'): key = operator, int1, int2, string if key not in self.triples: self.triples[key] = triple.triple(operator, int1, int2, string, syntax_position_info) return self.triples[key] ans = triple.triple(operator, int1, int2, string, syntax_position_info, call_triple) if operator == 'global': self.uses_global[int1].append(ans) if int1 in self.sets_global: ans.add_hard_predecessor(self.sets_global[int1]) if int1 in self.labels: self.labels[int1].add_label(int1, False) if operator in ('input', 'input-bit', 'output', 'output-bit-set', 'output-bit-clear'): #print self.name, "got", operator, "storing in side_effects" if self.side_effects is not None: ans.add_hard_predecessor(self.side_effects) self.side_effects = ans return ans