Changeset 1571


Ignore:
Timestamp:
Oct 22, 2011, 6:39:00 PM (6 years ago)
Author:
ksherdy
Message:

Updated Pablo for use with the new carryQ implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r1531 r1571  
    232232  def visit_Call(self, callnode):
    233233    self.generic_visit(callnode)
    234     carry_args = [self.carryvar, ast.Num(self.current_carry)]
     234    #CARRYSET
     235    carry_args = [ast.Num(self.current_carry)]
    235236    adv32_args = [ast.Subscript(ast.Name('pending32', ast.Load()), ast.Num(self.current_adv32), ast.Load())]
    236237    if is_BuiltIn_Call(callnode, 'Advance', 1):         
    237       rtn = "BitBlock_advance%s_co" % (self.carryin)
     238      #CARRYSET
     239      rtn = self.carryvar.id + "." + "BitBlock_advance%s_co" % (self.carryin)
    238240      c = mkCall(rtn, callnode.args + carry_args)
    239241      self.current_carry += 1
    240242      return c
    241243    elif is_BuiltIn_Call(callnode, 'Advance32', 1):     
    242       rtn = "BitBlock_advance32%s_co" % (self.carryin)
     244      #CARRYSET
     245      rtn = self.carryvar.id + "." + "BitBlock_advance32%s_co" % (self.carryin)
    243246      c = mkCall(rtn, callnode.args + adv32_args)
    244247      self.current_adv32 += 1
    245248      return c
    246249    elif is_BuiltIn_Call(callnode, 'ScanThru', 2):
    247       rtn = "BitBlock_scanthru%s_co" % (self.carryin)
     250      #CARRYSET
     251      rtn = self.carryvar.id + "." + "BitBlock_scanthru%s_co" % (self.carryin)
    248252      c = mkCall(rtn, callnode.args + carry_args)
    249253      self.current_carry += 1
     
    252256      # Modified Oct. 9, 2011 to directly use BitBlock_scanthru, eliminating duplication
    253257      # in having a separate BitBlock_scanto routine.
    254       rtn = "BitBlock_scanthru%s_co" % (self.carryin)
     258      #CARRYSET
     259      rtn = self.carryvar.id + "." + "BitBlock_scanthru%s_co" % (self.carryin)
    255260      if self.carryout == "":  scanclass = mkCall('simd_andc', [ast.Name('EOF_mask', ast.Load()), callnode.args[1]])
    256261      else: scanclass = mkCall('simd_not', [callnode.args[1]])
     
    259264      return c
    260265    elif is_BuiltIn_Call(callnode, 'ScanToFirst', 1):
    261       rtn = "BitBlock_scantofirst"
     266      #CARRYSET
     267      rtn = self.carryvar.id + "." + "BitBlock_scantofirst"
    262268      #if self.carryout == "":  carry_args = [ast.Name('EOF_mask', ast.Load())] + carry_args
    263269      c = mkCall(rtn, callnode.args + carry_args)
     
    283289  def visit_BinOp(self, exprnode):
    284290    self.generic_visit(exprnode)
    285     carry_args = [self.carryvar, ast.Num(self.current_carry)]
     291    carry_args = [ast.Num(self.current_carry)]
    286292    if isinstance(exprnode.op, ast.Sub):
    287       rtn = "BitBlock_sub%s_co" % (self.carryin)
     293      #CARRYSET
     294      rtn = self.carryvar.id + "." + "BitBlock_sub%s_co" % (self.carryin)
    288295      c = mkCall(rtn, [exprnode.left, exprnode.right] + carry_args)
    289296      self.current_carry += 1
    290297      return c
    291298    elif isinstance(exprnode.op, ast.Add):
    292       rtn = "BitBlock_add%s_co" % (self.carryin)
     299      #CARRYSET
     300      rtn = self.carryvar.id + "." + "BitBlock_add%s_co" % (self.carryin)
    293301      c = mkCall(rtn, [exprnode.left, exprnode.right] + carry_args)
    294302      self.current_carry += 1
     
    301309    self.generic_visit(ifNode)
    302310    if carries == 0 or self.carryin == "": return ifNode
    303     carry_arglist = [self.carryvar, ast.Num(carry_base), ast.Num(carries)]
    304     new_test = ast.BoolOp(ast.Or(), [ifNode.test, mkCall('CarryTest', carry_arglist)])
    305     new_else_part = ifNode.orelse + [mkCallStmt('CarryDequeueEnqueue', carry_arglist)]
     311    #CARRYSET
     312    carry_arglist = [ast.Num(carry_base), ast.Num(carries)]
     313    new_test = ast.BoolOp(ast.Or(), [ifNode.test, mkCall('carryQ.CarryTest', carry_arglist)])
     314    new_else_part = ifNode.orelse + [mkCallStmt('carryQ.CarryDequeueEnqueue', carry_arglist)]
    306315    return ast.If(new_test, ifNode.body, new_else_part)
    307316  def visit_While(self, whileNode):
     
    311320    assert Adv32Counter().count(whileNode) == 0, "Advance32() within while: illegal\n"
    312321    carries = CarryCounter().count(whileNode)
     322    #CARRYSET
    313323    if carries == 0: return whileNode
    314     carry_arglist = [self.carryvar, ast.Num(carry_base), ast.Num(carries)]
     324    carry_arglist = [ast.Num(carry_base), ast.Num(carries)]
    315325    local_carryvar = 'subcarryQ'
    316326    inner_while = CarryIntro(local_carryvar, '', self.carryout).generic_xfrm(copy.deepcopy(whileNode))
    317327    self.generic_visit(whileNode)
    318     local_decl = mkCallStmt('CarryDeclare', [ast.Name(local_carryvar, ast.Load()), ast.Num(carries)])
    319     local_init = mkCallStmt('CarryInit', [ast.Name(local_carryvar, ast.Load()), ast.Num(carries)])
    320     inner_while.body.insert(0, local_decl)
    321     inner_while.body.insert(1, local_init)
    322     final_combine = mkCallStmt('CarryCombine', [self.carryvar, ast.Name(local_carryvar, ast.Load()), ast.Num(carry_base), ast.Num(carries)])
     328    local_carry_decl = mkCallStmt('LocalCarryDeclare', [ast.Name(local_carryvar, ast.Load()), ast.Num(carries)])
     329    inner_while.body.insert(0, local_carry_decl)
     330    final_combine = mkCallStmt('carryQ.CarryCombine', [ast.Name(local_carryvar + '.array()', ast.Load()), ast.Num(carry_base), ast.Num(carries)])
    323331    inner_while.body.append(final_combine)
     332    #CARRYSET
    324333    if self.carryin == '': new_test = whileNode.test
    325     else: new_test = ast.BoolOp(ast.Or(), [whileNode.test, mkCall('CarryTest', carry_arglist)])
    326     else_part = [mkCallStmt('CarryDequeueEnqueue', carry_arglist)]
     334    else: new_test = ast.BoolOp(ast.Or(), [whileNode.test, mkCall('carryQ.CarryTest', carry_arglist)])
     335    else_part = [mkCallStmt('carryQ.CarryDequeueEnqueue', carry_arglist)]   
    327336    return ast.If(new_test, whileNode.body + [inner_while], else_part)
    328337
     
    490499                if stream_function.carry_count > 0 or stream_function.adv32_count > 0:
    491500                        constructor = self.constructor(stream_function.type_name, stream_function.carry_count, stream_function.adv32_count)
    492                         carry_declaration = self.carry_declare(stream_function.carry_count, stream_function.adv32_count)
     501                        carry_declaration = self.carry_declare('carryQ', stream_function.carry_count, stream_function.adv32_count)
    493502
    494503                do_block_function = self.do_block(self.do_block_parameters(stream_function.parameters),
     
    576585               
    577586        def carry_init(self, carry_count, icount=0):   
    578                 return self.indent(icount) + "CarryInit(carryQ, %i);" % (carry_count)
    579        
    580         def carry_declare(self, carry_count, adv32_count=0, icount=0):
     587                #CARRY SET
     588                return ""
     589               
     590        def carry_declare(self, carry_variable, carry_count, adv32_count=0, icount=0):
    581591                adv32_decl = ""
    582592                if adv32_count > 0:
    583593                        adv32_decl = "\n" + self.indent(icount) + "uint32_t pending32[%s];" % adv32_count
    584                 return self.indent(icount) + "CarryDeclare(carryQ, %i);" % (carry_count) + adv32_decl
     594                #CARRY SET
     595                return self.indent(icount) + "CarryArray<%i> %s;" % (carry_count, carry_variable) + adv32_decl
    585596
    586597        def carry_test(self, carry_variable, carry_count, icount=0):
    587                 return self.indent(icount) + "CarryTest(%s, 0, %i)" % (carry_variable, carry_count)             
     598                #CARRY SET
     599                return self.indent(icount) + "carryQ.CarryTest(0, %i)" % (carry_count)         
    588600               
    589601        def indent(self, icount):
     
    666678               
    667679                if stream_function.carry_count > 0:
    668                         node.body += [mkCallStmt('CarryQ_Adjust', [ast.Name(carryQname, ast.Load()), ast.Num(stream_function.carry_count)])]
     680                        node.body += [mkCallStmt('carryQ.CarryQ_Adjust', [ast.Num(stream_function.carry_count)])]
    669681               
    670682                stream_function.statements = Cgen.py2C(4).gen(node.body)
     
    679691       
    680692        if self.main_carry_count > 0:
    681                         carry_test.append(self.emitter.carry_test('carryQ', self.main_carry_count))
     693                        carry_test.append(self.emitter.carry_test('carryQ', self.main_carry_count)) 
    682694                        carry_test.append(" || ")
    683695
    684696        for key in self.stream_functions.keys():               
    685697                if self.stream_functions[key].carry_count > 0:
    686                         carry_test.append(self.emitter.carry_test(self.stream_functions[key].instance_name + ".carryQ", self.stream_functions[key].carry_count))
     698                        carry_test.append(self.stream_functions[key].instance_name + "." + self.emitter.carry_test('carryQ',self.stream_functions[key].carry_count))# TODO Update self.emitter.carry_test
    687699                        carry_test.append(" || ")
    688700
     
    701713    self.Cdecls += BitBlock_decls_of_fn(self.main_node)
    702714    if self.main_carry_count > 0:
    703         self.Cdecls += self.emitter.carry_declare(self.main_carry_count)
     715        self.Cdecls += self.emitter.carry_declare('carryQ', self.main_carry_count)
    704716               
    705717  def gen_initializations(self):
     
    732744   
    733745    if self.main_carry_count > 0:
    734                 self.main_node.body += [mkCallStmt('CarryQ_Adjust', [ast.Name('carryQ', ast.Load()), ast.Num(self.main_carry_count)])]
     746                #self.main_node.body += [mkCallStmt('CarryQ_Adjust', [ast.Name('carryQ', ast.Load()), ast.Num(self.main_carry_count)])]
     747                self.main_node.body += [mkCallStmt('carryQ.CarryQ_Adjust', [ast.Num(self.main_carry_count)])]
    735748   
    736749   
Note: See TracChangeset for help on using the changeset viewer.