def __apply_constant_propagation(self, func): graph = func.graph for block in graph: block_id = block.get_id() before = ConstantState() for pre in graph.get_predecessor_ids(block_id): before.join(self.__outs[pre]) for instruction in block: before.apply_mapping(instruction) before.add_mapping(instruction)
def __compute_constant_states(self, func): graph = func.graph for block in graph: block_id = block.get_id() self.__outs[block_id] = ConstantState() change = True while change: change = False for block in graph: block_id = block.get_id() new_out = ConstantState() for pre in graph.get_predecessor_ids(block_id): new_out.join(self.__outs[pre]) for inst in block: new_out.add_mapping(inst) if not (self.__outs[block_id] == new_out): self.__outs[block_id] = new_out change = True