Changeset 2628


Ignore:
Timestamp:
Nov 11, 2012, 2:05:37 PM (6 years ago)
Author:
cameron
Message:

Set up a single CarryIntro? visitor per stream function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2627 r2628  
    428428    if carry_count == 0: return fndef
    429429    self.generic_visit(fndef)
     430  def xfrm_fndef_final(self, fndef):
     431    self.carryout = ""
     432    self.current_carry = 0
     433    self.current_adv_n = 0
     434    carry_count = CarryCounter().count(fndef)
     435    if carry_count == 0: return fndef
     436    self.generic_visit(fndef)
    430437#   
    431438#    fndef.body.insert(0, mkCallStmt('CarryDeclare', [self.carryvar, ast.Num(carry_count)]))
     
    654661    #CARRYSET
    655662    if carries == 0: return whileNode
    656     local_carryvar = 'sub' + self.carryvar.id
    657     inner_while = CarryIntro(local_carryvar, '', self.carryout).generic_xfrm(copy.deepcopy(whileNode))
     663    local_carryvar = ast.Name('sub' + self.carryvar.id, ast.Load())
     664    saved_state = (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n)
     665    (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n) = (local_carryvar, '', self.carryout, 0, 0)
     666    inner_while = self.generic_visit(copy.deepcopy(whileNode))
     667    (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n) = saved_state
    658668    self.generic_visit(whileNode)
    659     local_carry_decl = mkCallStmt('LocalCarryDeclare', [ast.Name(local_carryvar, ast.Load()), ast.Num(carries)])
     669    local_carry_decl = mkCallStmt('LocalCarryDeclare', [local_carryvar, ast.Num(carries)])
    660670    inner_while.body.insert(0, local_carry_decl)
    661     final_combine = mkCallStmt(ast.Attribute(self.carryvar, 'CarryCombine', ast.Load()), [ast.Attribute(ast.Name(local_carryvar, ast.Load()), 'cq', ast.Load()),ast.Num(carry_base), ast.Num(carries)])
     671    final_combine = mkCallStmt(ast.Attribute(self.carryvar, 'CarryCombine', ast.Load()), [ast.Attribute(local_carryvar, 'cq', ast.Load()),ast.Num(carry_base), ast.Num(carries)])
    662672    inner_while.body.append(final_combine)
    663673    #CARRYSET
     
    10731083                        carryQname = stream_function.instance_name + ".carryQ"
    10741084                else: carryQname = "carryQ"
    1075                 CarryIntro(carryQname).xfrm_fndef(node)
    1076                 CarryIntro(carryQname, "_ci", "").xfrm_fndef(final_block_node)
     1085                CarryIntroVisitor = CarryIntro(carryQname)
     1086                CarryIntroVisitor.xfrm_fndef(node)
     1087                CarryIntroVisitor.xfrm_fndef_final(final_block_node)
    10771088
    10781089                if self.add_dump_stmts:
     
    11491160    AssertCompiler().xfrm(self.main_node)
    11501161    final_block_main = copy.deepcopy(self.main_node)
    1151     CarryIntro().xfrm_fndef(self.main_node)
    1152     CarryIntro('carryQ', '_ci', '').xfrm_fndef(final_block_main)
     1162    CarryIntroVisitor = CarryIntro()
     1163    CarryIntroVisitor.xfrm_fndef(self.main_node)
     1164    CarryIntroVisitor.xfrm_fndef_final(final_block_main)
    11531165    if self.add_dump_stmts:
    11541166        Add_SIMD_Register_Dump().xfrm(self.main_node)
Note: See TracChangeset for help on using the changeset viewer.