diff python/ir/module.py @ 170:4348da5ca307

Cleanup of ir dir
author Windel Bouwman
date Fri, 29 Mar 2013 17:33:17 +0100
parents 9683a4cd848f
children 3eb9b9e2958d
line wrap: on
line diff
--- a/python/ir/module.py	Sat Mar 23 18:34:41 2013 +0100
+++ b/python/ir/module.py	Fri Mar 29 17:33:17 2013 +0100
@@ -1,88 +1,18 @@
-from .symboltable import SymbolTable
-
-# Types:
-class Type:
-   def __init__(self):
-      pass
-      
-class IntegerType(Type):
-   def __init__(self, bits):
-      super().__init__()
-      self.bits = bits
-
-class VoidType(Type):
-   pass
-
-class FunctionType(Type):
-   def __init__(self, resultType, parameterTypes):
-      super().__init__()
-      assert type(parameterTypes) is list
-      self.resultType = resultType
-      self.parameterTypes = parameterTypes
-
-# Default types:
-i8 = IntegerType(8)
-i16 = IntegerType(16)
-i32 = IntegerType(32)
-void = VoidType()
-
 # IR-Structures:
 
 class Module:
-   """ Main container for a piece of code. Contains globals and functions. """
+   """ Main container for a piece of code. """
    def __init__(self, name):
       self.name = name
-      self.functions = [] # Do functions come out of symbol table?
-      self.globs = [] # TODO: are globals in symbol table?
-      self.symtable = SymbolTable()
-   Globals = property(lambda self: self.globs)
-   Functions = property(lambda self: self.functions)
+      self.instructions = []
    def __repr__(self):
-      return 'IR-mod {0}'.format(self.name)
-
-class Argument:
-   def __init__(self, argtype, name, function):
-      self.t = argtype
-      self.name = name
-      self.function = function
-
-class Function:
-   def __init__(self, name, functiontype):
-      super().__init__()
-      self.name = name
-      self.functiontype = functiontype
-
-      self.basicblocks = []
-      self.arguments = []
-   BasicBlocks = property(lambda self: self.basicblocks)
-   Arguments = property(lambda self: self.arguments)
-   ReturnType = property(lambda self: self.functiontype.returnType)
-   FunctionType = property(lambda self: self.functiontype)
-   def __repr__(self):
-      return 'FUNC {0}'.format(self.name)
-   
-class BasicBlock:
-   """ 
-     A basic block represents a sequence of instructions without
-     jumps and branches.
-   """
-   def __init__(self):
-      super().__init__()
-      self.instructions = []
-      self.label = None
+      return 'IR-module [{0}]'.format(self.name)
    def getInstructions(self):
       return self.instructions
    Instructions = property(getInstructions)
+   def dump(self):
+      print(self)
+      for i in self.Instructions:
+         print(i)
+      print('END')
 
-def printIr(md):
-   print(md)
-   for g in md.Globals:
-      print(g)
-   for f in md.Functions:
-      print(f)
-      for bb in f.BasicBlocks:
-         print('{0}:'.format(bb))
-         for ins in bb.Instructions:
-            print(' {0}'.format(ins))
-      print()
-