def filled(self, params, ctx): reads = set() writes = set() values = dict() loads = [] for x in self.reads: if x.startswith("#"): assert(len(x) == 2) value = params[x[1]] operand = placeholders.get(x[1], value) # XXX: solution here: just add operand.getDependencies() if hasattr(operand, 'target'): reads.add('mem') reads |= splitRegister('HL') # TODO: XXX: bad else: reads |= splitRegister(operand.name) else: reads |= splitRegister(x) for x in self.writes: if x.startswith("#"): assert(len(x) == 2) value = params[x[1]] operand = placeholders.get(x[1], value) if hasattr(operand, 'target'): name = '['+operand.target.name+']' writes.add('mem') reads |= splitRegister('HL') # TODO: XXX: bad else: name = operand.name writes |= splitRegister(name) if x in self.values: e = parse(self.values[x]) values[name] = e.optimizedWithContext(ctx) loads.append((name, values[name])) else: writes |= splitRegister(x) if x in self.values: e = parse(self.values[x]) values[x] = e.optimizedWithContext(ctx) loads.append((x, values[x])) #values = dict() # TODO: XXX: #loads = [] return reads, writes, values, loads
def filled(self, params, ctx): reads = set() writes = set() values = dict() loads = [] for x in self.reads: if x.startswith("#"): assert (len(x) == 2) value = params[x[1]] operand = placeholders.get(x[1], value) # XXX: solution here: just add operand.getDependencies() if hasattr(operand, 'target'): reads.add('mem') reads |= splitRegister('HL') # TODO: XXX: bad else: reads |= splitRegister(operand.name) else: reads |= splitRegister(x) for x in self.writes: if x.startswith("#"): assert (len(x) == 2) value = params[x[1]] operand = placeholders.get(x[1], value) if hasattr(operand, 'target'): name = '[' + operand.target.name + ']' writes.add('mem') reads |= splitRegister('HL') # TODO: XXX: bad else: name = operand.name writes |= splitRegister(name) if x in self.values: e = parse(self.values[x]) values[name] = e.optimizedWithContext(ctx) loads.append((name, values[name])) else: writes |= splitRegister(x) if x in self.values: e = parse(self.values[x]) values[x] = e.optimizedWithContext(ctx) loads.append((x, values[x])) #values = dict() # TODO: XXX: #loads = [] return reads, writes, values, loads
def splitToSimple(self): if 'sideeffects' in self._writes: return [self] writes = set(self._writes) - set(['mem']) out = [] for w in self._loads: name = w[0] value = w[1] target = parse(name) writes -= splitRegisters(target.getDependencies()) instr = LoadInstruction('LD_'+self.name, target, value, self.addr) out.append(instr) for w in writes: value = ComplexValue(self.name, self.getDependencySet().reads) target = parse(w) instr = LoadInstruction('LD_'+self.name, target, value, self.addr) out.append(instr) return out
def fillOperand(text, params, argument, next_addr): e = parse(text) ctx = make_context(params, argument, next_addr) return e.optimizedWithContext(ctx)