view python/irmach.py @ 274:ea93e0a7a31e

Move docs
author Windel Bouwman
date Wed, 04 Sep 2013 17:35:06 +0200
parents cdc76d183bcc
children 6f2423df0675
line wrap: on
line source


"""
  Abstract assembly language instructions.

  This is the second intermediate representation.
  
  Instructions are selected and scheduled at this stage.
"""

class Frame:
    """ 
        Activation record abstraction. This class contains a flattened 
        function. Instructions are selected and scheduled at this stage.
        Frames differ per machine.
    """
    def __init__(self, name):
        self.name = name
        self.instructions = []

    def __repr__(self):
        return 'Frame'


class AbstractInstruction:
    """ 
        Abstract machine instruction class. This is a very simple
        abstraction of machine instructions.
    """
    def __init__(self, assem, src=(), dst=(), jumps=()):
        self.assem = assem
        self.src = tuple(src)
        self.dst = tuple(dst)
        self.jumps = tuple(jumps)

    def __repr__(self):
        s = str(self.src) if self.src else ''
        d = str(self.dst) if self.dst else ''
        l = str(self.jumps) if self.jumps else ''
        return self.assem + s + d + l