Changeset 2688 for proto/Compiler


Ignore:
Timestamp:
Nov 24, 2012, 7:21:00 AM (6 years ago)
Author:
cameron
Message:

Generate declarations and initializations with CCGO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2640 r2688  
    8989    self.advance_amount = {}
    9090    self.init_one_list = []
    91    
     91    self.carry_count = 0
     92    self.adv_n_count = 0
     93    self.adv_1_count = 0
     94    self.total_advance = 0
     95    self.max_advance = 0
     96
    9297  def visit_Call(self, callnode):
    9398    self.generic_visit(callnode)
     
    97102      if usesCarryInit1(builtin): self.init_one_list.append(self.operation_no)
    98103      self.operation_no += 1
     104      self.carry_count += 1
    99105    elif isAdvance(builtin):
    100106      if len(callnode.args) > 1:
    101107        adv_amount = callnode.args[1].n
    102       else: adv_amount = 1
     108        self.adv_n_count += 1
     109      else:
     110        adv_amount = 1
     111        self.adv_1_count += 1
    103112      self.advance_amount[self.operation_no] = adv_amount
     113      self.total_advance += adv_amount
     114      if adv_amount > self.max_advance: self.max_advance = adv_amount
    104115      self.operation_no += 1
    105116    else: return
     
    112123    self.block_first_op[this_block_no] = self.operation_no
    113124    self.generic_visit(ifNode)
    114    
    115125    self.block_op_count[this_block_no] = self.operation_no - self.block_first_op[this_block_no]
    116 
    117     # reset
     126    # reset for processing remainder of parent
    118127    self.block_no = self.parent_block[this_block_no]
    119128 
     
    143152    self.block_first_op[0] = 0
    144153    self.block_op_count[0] = self.operation_no
     154    self.carry_count = 0
     155    self.adv_n_count = 0
     156    self.adv_1_count = 0
     157    self.total_advance = 0
     158    self.max_advance = 0
    145159    return self
    146160
     
    511525          else: adv_n_counter += 1
    512526        return "CarryArray<%i, %i> %s;" % (carry_counter, adv_n_counter, self.carryGroupVar)
    513 
     527    def GenerateInitializations(self):
     528        carry_counter = 0
     529        adv_n_counter = 0
     530        inits = ""
     531        for op_no in range(self.carryInfoSet.block_op_count[0]):
     532          if op_no in self.carryInfoSet.init_one_list: inits += "carryQ.cq[%s] = carryQ.carry_flip(carryQ.cq[%s]);\n" % (carry_counter, carry_counter)
     533          if not op_no in self.carryInfoSet.advance_amount.keys(): carry_counter += 1
     534          elif self.carryInfoSet.advance_amount[op_no] == 1: carry_counter += 1
     535          else: adv_n_counter += 1
     536        return inits
     537    def GenerateStreamFunctionDecls(self):  return ""
    514538    def GenerateCarryInAccess(self, operation_no):
    515539        carry_index = self.carryIndex[operation_no - self.operation_offset]
     
    10981122
    10991123        def constructor(self, type_name, carry_count, init_to_one_list, adv_n_count, icount=0):
    1100                 one_inits = ""
    1101                 for v in init_to_one_list:
    1102                         one_inits += "  carryQ.cq[%s] = carryQ.carry_flip(carryQ.cq[%s]);\n" % (v, v)
     1124                one_inits = self.ccgo.GenerateInitializations()
     1125                #one_inits = ""
     1126                #for v in init_to_one_list:
     1127                #       one_inits += "  carryQ.cq[%s] = carryQ.carry_flip(carryQ.cq[%s]);\n" % (v, v)
    11031128                adv_n_decl = ""
    11041129                #for i in range(adv_n_count): adv_n_decl += self.indent(icount+2) + "pending64[%s] = simd<1>::constant<0>();\n" % i     
     
    12421267                stream_function.parameters = FunctionVars(node).params
    12431268                stream_function.declarations = BitBlock_decls_of_fn(node)
     1269                stream_function.declarations += stream_function.ccgo.GenerateStreamFunctionDecls()
    12441270                stream_function.initializations = StreamInitializations().xfrm(node)
    12451271               
Note: See TracChangeset for help on using the changeset viewer.