コード例 #1
0
ファイル: opcodeeffect.py プロジェクト: amorri40/awake
    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
コード例 #2
0
    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
コード例 #3
0
ファイル: instruction.py プロジェクト: amorri40/awake
    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
コード例 #4
0
ファイル: singledecoder.py プロジェクト: amorri40/awake
def fillOperand(text, params, argument, next_addr):
    e = parse(text)
    ctx = make_context(params, argument, next_addr)
    return e.optimizedWithContext(ctx)
コード例 #5
0
def fillOperand(text, params, argument, next_addr):
    e = parse(text)
    ctx = make_context(params, argument, next_addr)
    return e.optimizedWithContext(ctx)