swap.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:ropf 作者: kevinkoo001 项目源码 文件源码
def get_reg_swaps(live_regs):
    """Given all the registers' live subsets, check which of them can
    be swapped. Returns a list with Swap objects."""

    swaps = set()
    # filter out any registers that are not used
    reg_vals = filter(lambda x: not x.dont_touch(), live_regs.values())
    for reg, other in itertools.permutations(reg_vals, 2):
        for subset in reg.subsets:
            if subset.no_swap:
                continue
            # print "ASDASD", reg, subset
            swap_subset = other.get_swap_subset(subset, reg)
            if swap_subset != None and swap_subset.size == 0:
                print "BUG: empty subset in get_swap_subset"
                continue
            if swap_subset != None:
                swaps.add(Swap(reg, other, swap_subset))

    return list(swaps)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号