Changeset 2638


Ignore:
Timestamp:
Nov 15, 2012, 8:35:28 AM (7 years ago)
Author:
cameron
Message:

GenerateCarryWhileFinalization?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2637 r2638  
    487487
    488488class testCCGO():
    489     def __init__(self, carryInfoSet, carryGroupVar='carryQ'):
     489    def __init__(self, carryInfoSet, carryGroupVarName='carryQ'):
    490490        self.carryInfoSet = carryInfoSet
    491         self.carryGroupVar = carryGroupVar
     491        self.carryGroupVar = carryGroupVarName
    492492        self.carryIndex = {}
    493493        self.operation_offset = 0
     
    499499        # Add a dummy entry for any possible final block that is empty.
    500500        self.carryIndex[carryInfoSet.operation_no] = carry_counter
    501          
     501    def CarryGroupAtt(self, attname, CarryGroupVarName=""):
     502        if CarryGroupVarName == '': CarryGroupVarName = self.carryGroupVar
     503        return ast.Attribute(ast.Name(CarryGroupVarName, ast.Load()), attname, ast.Load())
    502504    def GenerateCarryInAccess(self, operation_no):
    503505        carry_index = self.carryIndex[operation_no - self.operation_offset]
     
    505507    def GenerateCarryOutStore(self, operation_no, carry_out_expr):
    506508        carry_index = self.carryIndex[operation_no - self.operation_offset]
    507         return ast.Assign([ast.Subscript(ast.Attribute(ast.Name(self.carryGroupVar, ast.Load()), 'cq', ast.Load()), ast.Index(ast.Num(carry_index)), ast.Store())],
     509        return ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(carry_index)), ast.Store())],
    508510                          mkCall("bitblock::srli<127>", [carry_out_expr]))
    509511    def GenerateCarryIfTest(self, block_no, ifTest):
     
    511513        if carry_count == 0: return ifTest
    512514        ifIndex = self.carryIndex[self.carryInfoSet.block_first_op[block_no]]       
    513         return ast.BoolOp(ast.Or(), [ifTest, mkCall(ast.Attribute(ast.Name(self.carryGroupVar, ast.Load()), 'CarryTest', ast.Load()), [ast.Num(ifIndex), ast.Num(carry_count)])])
     515        return ast.BoolOp(ast.Or(), [ifTest, mkCall(self.CarryGroupAtt('CarryTest'), [ast.Num(ifIndex), ast.Num(carry_count)])])
    514516    def GenerateCarryElseFinalization(self, block_no):
    515517        carry_count = self.carryInfoSet.block_op_count[block_no]
    516518        if carry_count == 0: return []
    517519        ifIndex = self.carryIndex[self.carryInfoSet.block_first_op[block_no]]       
    518         return [mkCallStmt(ast.Attribute(ast.Name(self.carryGroupVar, ast.Load()), 'CarryDequeueEnqueue', ast.Load()), [ast.Num(ifIndex), ast.Num(carry_count)])]
     520        return [mkCallStmt(self.CarryGroupAtt('CarryDequeueEnqueue'), [ast.Num(ifIndex), ast.Num(carry_count)])]
    519521    def GenerateCarryWhileTest(self, whileIndex): pass
    520522    def EnterLocalWhileBlock(self, operation_offset): 
     
    524526        self.operation_offset = 0
    525527        self.carryGroupVar = self.carryGroupVar[3:]
     528    def GenerateCarryWhileFinalization(self, block_no):
     529        carry_count = self.carryInfoSet.block_op_count[block_no]
     530        if carry_count == 0: return []
     531        loopIndex = self.carryIndex[self.carryInfoSet.block_first_op[block_no]]       
     532        return mkCallStmt(self.CarryGroupAtt('CarryCombine'), [self.CarryGroupAtt('cq', "sub" + self.carryGroupVar), ast.Num(loopIndex), ast.Num(carry_count)])
    526533    def GenerateStreamFunctionFinalization(self):
    527534        carry_count = self.carryInfoSet.countBlockCarrysWithAdv1(0)
    528535        if carry_count == 0: return []
    529         else: return [mkCallStmt(ast.Attribute(ast.Name(self.carryGroupVar, ast.Load()), 'CarryQ_Adjust', ast.Load()), [ast.Num(carry_count)])]
     536        else: return [mkCallStmt(self.CarryGroupAtt('CarryQ_Adjust'), [ast.Num(carry_count)])]
    530537
    531538def Strategic_CCGO_Factory(carryInfoSet):
     
    795802    # Determine the original test expression, now encloded in bitblock::any()
    796803    self.block_no += 1
     804    this_block = self.block_no
    797805    original_test_expr = whileNode.test.args[0]
    798806    if self.carryout == '':
     
    810818    local_carry_decl = mkCallStmt('LocalCarryDeclare', [local_carryvar, ast.Num(carries)])
    811819    inner_while.body.insert(0, local_carry_decl)
    812     final_combine = mkCallStmt(ast.Attribute(self.carryvar, 'CarryCombine', ast.Load()), [ast.Attribute(local_carryvar, 'cq', ast.Load()),ast.Num(carry_base), ast.Num(carries)])
     820    #final_combine = mkCallStmt(ast.Attribute(self.carryvar, 'CarryCombine', ast.Load()), [ast.Attribute(local_carryvar, 'cq', ast.Load()),ast.Num(carry_base), ast.Num(carries)])
     821    final_combine = self.ccgo.GenerateCarryWhileFinalization(this_block)
    813822    inner_while.body.append(final_combine)
    814823    #CARRYSET
Note: See TracChangeset for help on using the changeset viewer.