Changeset 2631


Ignore:
Timestamp:
Nov 12, 2012, 1:21:46 PM (6 years ago)
Author:
cameron
Message:

Make TempifyBuiltins? handle AugAssign?; define local_while_xfrm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2630 r2631  
    154154#
    155155#  Converting expressions involving built-ins to compiled form. 
    156 #  Make sure this is applied after AugAssign removal and before
    157 #  carry variable insertion.
     156#  Apply before carry variable insertion.
    158157#
    159158class TempifyBuiltins(ast.NodeTransformer):
     
    191190    def visit_Assign(self, node):
    192191      self.assigNode = node
     192      self.setUpStmts = []
     193      self.generic_visit(node)
     194      return self.setUpStmts + [node]
     195    def visit_AugAssign(self, node):
    193196      self.setUpStmts = []
    194197      self.generic_visit(node)
     
    445448    self.generic_visit(node)
    446449    return node
     450   
     451  def local_while_xfrm(self, local_carryvar, whileNode):
     452    saved_state = (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n)
     453    (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n) = (local_carryvar, '', self.carryout, 0, 0)
     454    inner_while = self.generic_visit(whileNode)
     455    (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n) = saved_state
     456    return inner_while
     457   
    447458  def visit_Call(self, callnode):
    448459    self.generic_visit(callnode)
     
    659670    if carries == 0: return whileNode
    660671    local_carryvar = ast.Name('sub' + self.carryvar.id, ast.Load())
    661     saved_state = (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n)
    662     (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n) = (local_carryvar, '', self.carryout, 0, 0)
    663     inner_while = self.generic_visit(copy.deepcopy(whileNode))
    664     (self.carryvar, self.carryin, self.carryout, self.current_carry, self.current_adv_n) = saved_state
     672    inner_while = self.local_while_xfrm(local_carryvar, copy.deepcopy(whileNode))
    665673    self.generic_visit(whileNode)
    666674    local_carry_decl = mkCallStmt('LocalCarryDeclare', [local_carryvar, ast.Num(carries)])
     
    10681076                stream_function.initializations = StreamInitializations().xfrm(node)
    10691077               
     1078                t = TempifyBuiltins()
     1079                t.xfrm(node)
     1080                stream_function.declarations += "\n" + BitBlock_decls_from_vars(t.tempVars())
     1081
    10701082                StringMatchCompiler().xfrm(node)
    10711083                AssertCompiler().xfrm(node)
    10721084                AugAssignRemoval().xfrm(node)
    10731085
    1074                 t = TempifyBuiltins()
    1075                 t.xfrm(node)
    1076                 stream_function.declarations += "\n" + BitBlock_decls_from_vars(t.tempVars())
    10771086               
    10781087                Bitwise_to_SIMD().xfrm(node)
Note: See TracChangeset for help on using the changeset viewer.