# Path: awake/regutil.py
# def joinRegisters(regs):
#     out = set(regs)
#     for big in ('BC', 'DE', 'HL'):
#         if splitRegister(big) <= out:
#             out -= splitRegister(big)
#             out.add(big)
#     return out
# 
# def splitRegisters(regs):
#     out = set()
#     for x in regs:
#         out |= splitRegister(x)
#     return out
# 
# ALL_REGS = set(['B', 'C', 'D', 'E', 'H', 'L', 'SP', 'A', 'mem', 'ROMBANK', 'FZ', 'FC', 'FN', 'FH'])


from awake.regutil import joinRegisters, splitRegisters, ALL_REGS
# This file is part of Awake - GB decompiler.
# Copyright (C) 2012  Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


def joinDependencies(first, second):
    reads = second.reads - first.writes | first.reads
    writes = first.writes | second.writes
    return DependencySet(reads, writes)

def dependParallel(a, b):
    reads = a.reads | b.reads
    writes = a.writes | b.writes
    return DependencySet(reads, writes)

def unknownDependencySet():

# Path: awake/regutil.py
# def joinRegisters(regs):
#     out = set(regs)
#     for big in ('BC', 'DE', 'HL'):
#         if splitRegister(big) <= out:
#             out -= splitRegister(big)
#             out.add(big)
#     return out
# 
# def splitRegisters(regs):
#     out = set()
#     for x in regs:
#         out |= splitRegister(x)
#     return out
# 
# ALL_REGS = set(['B', 'C', 'D', 'E', 'H', 'L', 'SP', 'A', 'mem', 'ROMBANK', 'FZ', 'FC', 'FN', 'FH'])


# Path: awake/depend.py
from awake.regutil import joinRegisters, splitRegisters, ALL_REGS

# This file is part of Awake - GB decompiler.
# Copyright (C) 2012  Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


def joinDependencies(first, second):
    reads = second.reads - first.writes | first.reads
    writes = first.writes | second.writes
    return DependencySet(reads, writes)

def dependParallel(a, b):
    reads = a.reads | b.reads
    writes = a.writes | b.writes
    return DependencySet(reads, writes)

def unknownDependencySet():

    return DependencySet(ALL_REGS - set(['FZ', 'FC', 'FN', 'FH']), ALL_REGS - set(['ROMBANK']))