Changeset 2786 for proto/Compiler


Ignore:
Timestamp:
Dec 17, 2012, 6:59:37 AM (6 years ago)
Author:
cameron
Message:

Add CCGO GenerateTestAll? method for @any_carry support

Location:
proto/Compiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/CCGO.py

    r2699 r2786  
    3030    def GenerateAdvanceInAccess(self, operation_no): return None
    3131    def GenerateAdvanceOutStore(self, operation_no, carry_out_expr): return []
     32    def GenerateTestAll(self, instance_name): return ast.Num(0)
    3233    def GenerateCarryIfTest(self, block_no, ifTest): return ifTest
    3334    def GenerateCarryElseFinalization(self, block_no): return []
     
    114115        return [ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(cq_index)), ast.Store())],
    115116                           mkCall("bitblock::srli<64>", [adv_out_expr]))]
     117
     118    def GenerateTestAll(self, instance_name):
     119        carry_count = self.carryInfoSet.block_op_count[0]
     120        if carry_count == 0: return ast.Num(0)
     121        else:
     122           #return "%s.carryQ.CarryTest(0, %i)" % (instance_name, carry_count)
     123           return mkCall(ast.Attribute(ast.Attribute(ast.Name(instance_name, ast.Load()), self.carryGroupVar, ast.Load()), 'CarryTest', ast.Load()),
     124                         [ast.Num(0), ast.Num(carry_count)])
    116125    def GenerateCarryIfTest(self, block_no, ifTest):
    117126        carry_count = self.carryInfoSet.block_op_count[block_no]
  • proto/Compiler/CCGO_HMCPS.py

    r2718 r2786  
    1717#
    1818def TestHelper_Bitblock_Or(testExpr, bitBlockExpr):
    19     assert isinstance(testExpr, ast.Call)
    20     assert isinstance(testExpr.func, ast.Name)
    21     assert testExpr.func.id == 'bitblock::any'
    22     testExpr.args[0] = make_call('simd_or', [bitBlockExpr, testExpr.args[0]])
    23     return testExpr
     19    if isinstance(testExpr, ast.Call):
     20      assert isinstance(testExpr.func, ast.Name)
     21      assert testExpr.func.id == 'bitblock::any'
     22      testExpr.args[0] = make_call('simd_or', [bitBlockExpr, testExpr.args[0]])
     23      return testExpr
     24    else:
     25      return ast.BinOp(testExpr, ast.BitOr(), make_call('bitblock::any', [bitBlockExpr]))
    2426
    2527def TestHelper_Integer_Or(testExpr, intExpr):
     
    363365        #return [ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(cq_index)), ast.Store())],
    364366                           #mkCall("bitblock::srli<64>", [adv_out_expr]))]
     367    def GenerateTestAll(self, instance_name):
     368        if self.ubitblock_count == 0: return ast.Num(0)
     369        else:
     370            t = make_att(make_index(make_att(instance_name, self.carryGroupVar), 0), '_128')
     371            for i in range(1, self.ubitblock_count):
     372              t2 = make_att(make_index(make_att(instance_name, self.carryGroupVar), i), '_128')
     373              t = make_call('simd_or', [t, t2])
     374            return make_call('bitblock::any', [t])
    365375    def GenerateTest(self, block_no, testExpr):
    366376        posn = self.block_base[block_no] - self.carry_offset
  • proto/Compiler/pablo.py

    r2717 r2786  
    10861086   
    10871087  def any_carry_expr(self):
    1088        
    1089         carry_test = []
    1090        
    1091         if self.main_carry_count > 0:
    1092                         carry_test.append(self.emitter.carry_test('carryQ', self.main_carry_count))
    1093                         carry_test.append(" || ")
    1094 
    1095         for key in self.stream_functions.keys():               
    1096                 if self.stream_functions[key].carry_count > 0:
    1097                         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
    1098                         carry_test.append(" || ")
    1099 
    1100         if len(carry_test) > 0:
    1101                 carry_test.pop()
    1102                 return "".join(carry_test)
    1103         return "1"
     1088
     1089        tests = [self.stream_functions[key].ccgo.GenerateTestAll(self.stream_functions[key].instance_name) for key in self.stream_functions.keys()]
     1090        return " || ".join([Cgen.py2C().gen(t) for t in tests])
    11041091
    11051092  def gen_globals(self):
Note: See TracChangeset for help on using the changeset viewer.