# Path: backend/module.py
# class Module(object):
#     def __init__(self):
#     def packData(self):
#     def _getNewDataLabel(self):
#     def addFunction(self,f):
#     def getFunction(self,name):
#     def __iter__(self):
#     def addZeroInitData(self,sz,label=None):
#     def addReadOnlyData(self,d,label=None):
#     def addReadWriteData(self,d,label=None):
# 
# Path: backend/function.py
# class StackSlot(object):
# class Function(object):
#     def __init__(self,size):
#     def __init__(self,name):
#     def createStackSlot(self,size):
#     def addArgumentSlot(self,ss):
#     def resolveStack(self):
#     def setEntryBlock(self,entry):
#     def stackslots(self):
#     def variables(self):
#     def variables(self, value):
#     def __iter__(self):
# 
# Path: backend/basicblock.py
# class BasicBlock(object):
#     def __init__(self):
#     def __getitem__(self,k):
#     def __setitem__(self,k,v):
#     def __delitem__(self,idx):
#     def insert(self,idx,op):
#     def prepend(self,op):
#     def append(self,op):
#     def __len__(self):
#     def __iter__(self):
#     def __repr__(self):
#     def removeInstructions(self,instructions):
#     def unsafeEnding(self):
#     def getSuccessors(self):
#     def getReachableBlocks(self):
#         def generator():
# 
# Path: backend/ir.py
# class VirtualRegister(object):
# class I32(VirtualRegister):
# class I16(VirtualRegister):
# class I8(VirtualRegister):
# class Pointer(VirtualRegister):
# class ConstantInt(object):
# class ConstantI32(ConstantInt):
# class ConstantI8(ConstantInt):
# class Instruction(object):
# class Binop(Instruction):
# class Unop(Instruction):
# class Call(Instruction):
# class LoadGlobalAddr(Instruction):
# class LoadParamAddr(Instruction):
# class LoadLocalAddr(Instruction):
# class LoadConstant(Instruction):
# class Deref(Instruction):
# class Store(Instruction):
# class Terminator(Instruction):
# class Ret(Terminator):
# class Branch(Terminator):
# class Jmp(Terminator):
# class Phi(Instruction):
# class Move(Instruction):
#     def __init__(self):
#     def isPhysical(self):
#     def __repr__(self):
#     def getSize(self):
#     def getSize(self):
#     def getSize(self):
#     def getSize(self):
#     def getSize(self):
#     def __init__(self,v):
#     def __repr__(self):
#     def __init__(self):
#     def getDagDisplayText(self):
#     def isTerminator(self):
#     def isBranch(self):
#     def swapVar(self,old,new):
#     def swapRead(self,old,new):
#     def swapAssigned(self,old,new):
#     def asm(self):
#     def getSuccessors(self):
#     def setSuccessors(self,new):
#     def swapSuccessor(self,old,new):
#     def getStackSlots(self):
#     def readsMem(self):
#     def writesMem(self):
#     def isMD(self):
#     def isMove(self):
#     def isCall(self):
#     def getClobberedRegisters(self):
#     def getPreClobberedRegisters(self):
#     def __init__(self,op,res,l,r):
#     def getDagDisplayText(self):
#     def __repr__(self):
#     def __init__(self,op,res,arg):
#     def __repr__(self):
#     def __init__(self,label):
#     def __repr__(self):
#     def isCall(self):
#     def readsMem(self):
#     def writesMem(self):
#     def __init__(self,res,sym):
#     def __repr__(self):
#     def __init__(self,res,sym):
#     def __repr__(self):
#     def __init__(self,res,sym):
#     def __repr__(self):
#     def getStackSlots(self):
#     def __init__(self,res,const):
#     def __repr__(self):
#     def __init__(self,out,p):
#     def __repr__(self):
#     def readsMem(self):
#     def __init__(self,p,val):
#     def __repr__(self):
#     def writesMem(self):
#     def isTerminator(self):
#     def getTemplateLookupStr(self):
#     def __init__(self,v=None):
#     def __repr__(self):
#     def __init__(self,v,t,f):
#     def __repr__(self):
#     def __init__(self,dest):
#     def __repr__(self):
#     def __init__(self,lhs,args):
#     def __repr__(self):
#     def __init__(self,l,r):
#     def isMove(self):
#     def __repr__(self):


from pycparser import c_ast
from backend import module
from backend import function
from backend import basicblock
from backend import ir
from valtracker import ValTracker
import types
import cstrings
import operatorgen
        isstaticvar = 'static' in decl.storage
        if self.isGlobalScope() or isstaticvar:
            sym = GlobalSym(decl.name,t)
            if type(decl.type) != c_ast.FuncDecl:
                self.module.addZeroInitData(4,label=decl.name)
        else:
            sym = LocalSym(decl.name,t)
        self.symTab.addSymbol(sym)
        if not self.isGlobalScope() and not isstaticvar:
            if decl.init:
                if type(decl.type) == c_ast.ArrayDecl:
                    raise Exception("cannot currently handle Array initializers")
                elif type(decl.type) == c_ast.PtrDecl:
                    raise Exception("cannot currently handle Pointer initializers")
                initializer = self.inFunctionDispatch(decl.init)
                self.assertNonVoid(initializer)
                if not t.strictTypeMatch(initializer.type):
                    initializer = operatorgen.genCast(self.curBasicBlock,initializer,t)
                v = ir.Pointer()
                op = ir.LoadLocalAddr(v,sym)
                self.curBasicBlock.append(op)

                if initializer.lval:
                    initializer = self.genDeref(initializer)
                op = ir.Store(v,initializer.reg)
                self.curBasicBlock.append(op)
    
    def visit_FuncDef(self,funcdef):
        functype = types.parseTypeDecl(self.typeTab,funcdef.decl)
        self.symTab.addSymbol(GlobalSym(funcdef.decl.name,functype))

# Path: backend/module.py
# class Module(object):
#     def __init__(self):
#     def packData(self):
#     def _getNewDataLabel(self):
#     def addFunction(self,f):
#     def getFunction(self,name):
#     def __iter__(self):
#     def addZeroInitData(self,sz,label=None):
#     def addReadOnlyData(self,d,label=None):
#     def addReadWriteData(self,d,label=None):
# 
# Path: backend/function.py
# class StackSlot(object):
# class Function(object):
#     def __init__(self,size):
#     def __init__(self,name):
#     def createStackSlot(self,size):
#     def addArgumentSlot(self,ss):
#     def resolveStack(self):
#     def setEntryBlock(self,entry):
#     def stackslots(self):
#     def variables(self):
#     def variables(self, value):
#     def __iter__(self):
# 
# Path: backend/basicblock.py
# class BasicBlock(object):
#     def __init__(self):
#     def __getitem__(self,k):
#     def __setitem__(self,k,v):
#     def __delitem__(self,idx):
#     def insert(self,idx,op):
#     def prepend(self,op):
#     def append(self,op):
#     def __len__(self):
#     def __iter__(self):
#     def __repr__(self):
#     def removeInstructions(self,instructions):
#     def unsafeEnding(self):
#     def getSuccessors(self):
#     def getReachableBlocks(self):
#         def generator():
# 
# Path: backend/ir.py
# class VirtualRegister(object):
# class I32(VirtualRegister):
# class I16(VirtualRegister):
# class I8(VirtualRegister):
# class Pointer(VirtualRegister):
# class ConstantInt(object):
# class ConstantI32(ConstantInt):
# class ConstantI8(ConstantInt):
# class Instruction(object):
# class Binop(Instruction):
# class Unop(Instruction):
# class Call(Instruction):
# class LoadGlobalAddr(Instruction):
# class LoadParamAddr(Instruction):
# class LoadLocalAddr(Instruction):
# class LoadConstant(Instruction):
# class Deref(Instruction):
# class Store(Instruction):
# class Terminator(Instruction):
# class Ret(Terminator):
# class Branch(Terminator):
# class Jmp(Terminator):
# class Phi(Instruction):
# class Move(Instruction):
#     def __init__(self):
#     def isPhysical(self):
#     def __repr__(self):
#     def getSize(self):
#     def getSize(self):
#     def getSize(self):
#     def getSize(self):
#     def getSize(self):
#     def __init__(self,v):
#     def __repr__(self):
#     def __init__(self):
#     def getDagDisplayText(self):
#     def isTerminator(self):
#     def isBranch(self):
#     def swapVar(self,old,new):
#     def swapRead(self,old,new):
#     def swapAssigned(self,old,new):
#     def asm(self):
#     def getSuccessors(self):
#     def setSuccessors(self,new):
#     def swapSuccessor(self,old,new):
#     def getStackSlots(self):
#     def readsMem(self):
#     def writesMem(self):
#     def isMD(self):
#     def isMove(self):
#     def isCall(self):
#     def getClobberedRegisters(self):
#     def getPreClobberedRegisters(self):
#     def __init__(self,op,res,l,r):
#     def getDagDisplayText(self):
#     def __repr__(self):
#     def __init__(self,op,res,arg):
#     def __repr__(self):
#     def __init__(self,label):
#     def __repr__(self):
#     def isCall(self):
#     def readsMem(self):
#     def writesMem(self):
#     def __init__(self,res,sym):
#     def __repr__(self):
#     def __init__(self,res,sym):
#     def __repr__(self):
#     def __init__(self,res,sym):
#     def __repr__(self):
#     def getStackSlots(self):
#     def __init__(self,res,const):
#     def __repr__(self):
#     def __init__(self,out,p):
#     def __repr__(self):
#     def readsMem(self):
#     def __init__(self,p,val):
#     def __repr__(self):
#     def writesMem(self):
#     def isTerminator(self):
#     def getTemplateLookupStr(self):
#     def __init__(self,v=None):
#     def __repr__(self):
#     def __init__(self,v,t,f):
#     def __repr__(self):
#     def __init__(self,dest):
#     def __repr__(self):
#     def __init__(self,lhs,args):
#     def __repr__(self):
#     def __init__(self,l,r):
#     def isMove(self):
#     def __repr__(self):


# Path: c/irgen.py
from pycparser import c_ast
from backend import module
from backend import function
from backend import basicblock
from backend import ir
from valtracker import ValTracker
import types
import cstrings
import operatorgen

        isstaticvar = 'static' in decl.storage
        if self.isGlobalScope() or isstaticvar:
            sym = GlobalSym(decl.name,t)
            if type(decl.type) != c_ast.FuncDecl:
                self.module.addZeroInitData(4,label=decl.name)
        else:
            sym = LocalSym(decl.name,t)
        self.symTab.addSymbol(sym)
        if not self.isGlobalScope() and not isstaticvar:
            if decl.init:
                if type(decl.type) == c_ast.ArrayDecl:
                    raise Exception("cannot currently handle Array initializers")
                elif type(decl.type) == c_ast.PtrDecl:
                    raise Exception("cannot currently handle Pointer initializers")
                initializer = self.inFunctionDispatch(decl.init)
                self.assertNonVoid(initializer)
                if not t.strictTypeMatch(initializer.type):
                    initializer = operatorgen.genCast(self.curBasicBlock,initializer,t)
                v = ir.Pointer()
                op = ir.LoadLocalAddr(v,sym)
                self.curBasicBlock.append(op)

                if initializer.lval:
                    initializer = self.genDeref(initializer)
                op = ir.Store(v,initializer.reg)
                self.curBasicBlock.append(op)
    
    def visit_FuncDef(self,funcdef):
        functype = types.parseTypeDecl(self.typeTab,funcdef.decl)
        self.symTab.addSymbol(GlobalSym(funcdef.decl.name,functype))

        self.curFunction = function.Function(funcdef.decl.name)