Changeset 810 for proto/Compiler


Ignore:
Timestamp:
Dec 11, 2010, 6:35:42 AM (9 years ago)
Author:
cameron
Message:

SIMD register dump facility for debugging.

Location:
proto/Compiler
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/Cgen.py

    r756 r810  
    294294    # expr
    295295    def Cgen_Str(self, tree):
    296         self.write("b" + repr(tree.s))
     296        self.write('"%s"' % tree.s)
    297297 
    298298    def Cgen_Name(self, t):
  • proto/Compiler/compiler2.py

    r806 r810  
    33#   equivalent block-by-block code in C.
    44#
    5 # (c) 2009 Ehsan Amiri and Robert D. Cameron
     5# (c) 2010 Robert D. Cameron, Ehsan Amiri, Ken Herdy
    66# All rights reserved.
    77# Licensed to International Characters, Inc. under Academic Free License 3.0
     
    3737        f.close()
    3838
    39     def generate_code(self, input_string):
     39    def generate_code(self, input_string, options):
    4040        # FRONT END
    4141        s = ast.parse(input_string)
     
    4444        xfrmr.gen_declarations()
    4545        xfrmr.gen_initializations()
    46         xfrmr.xfrm_block_stmts()     
     46        xfrmr.xfrm_block_stmts(options.add_dump_stmts)     
    4747        xfrmr.add_loop_carryQ_adjust()
    4848        # BACK END
     
    8282               
    8383        else:
    84                 s = Program(options.output_filename, options.template_filename).generate_code(input_string)
     84                s = Program(options.output_filename, options.template_filename).generate_code(input_string, options)
  • proto/Compiler/config.py

    r807 r810  
    3939                                help='Display struct declartation transforms.')
    4040
     41        dump.add_option('-a','--add_dump_stmts',
     42                                dest='add_dump_stmts',
     43                                action='store_true',
     44                                default=False,
     45                                help='Add SIMD register dump statements.')
     46
    4147        parser.add_option_group(dump)
    4248
  • proto/Compiler/pablo.py

    r787 r810  
    334334
    335335
     336#
     337# Adding Debugging Statements
     338#
     339class Add_SIMD_Register_Dump(ast.NodeTransformer):
     340  def xfrm(self, t):
     341    return self.generic_visit(t)
     342  def visit_Assign(self, t):
     343    self.generic_visit(t)
     344    v = t.targets[0]
     345    dump_stmt = mkCallStmt('print_simd_register', [ast.Str(Cgen.py2C().gen(v)), v])
     346    return [t, dump_stmt]
     347   
     348
    336349#  Translate a function
    337350#
     
    380393    if self.carry_count > 0: self.Cinits += "CarryInit(%s, %i);\n" % (self.carry_var, self.carry_count)
    381394    self.Cinits += StreamInitializations().xfrm(self.main_module)
    382   def xfrm_block_stmts(self):
     395  def xfrm_block_stmts(self, add_dump_stmts=False):
    383396    AugAssignRemoval().xfrm(self.main_fn)
    384397    Bitwise_to_SIMD().xfrm(self.main_fn)
    385398    CarryIntro().xfrm_fndef(self.main_fn)
     399    if add_dump_stmts: Add_SIMD_Register_Dump().xfrm(self.main_fn)
    386400  def add_loop_carryQ_adjust(self):
    387401    self.main_fn.body += [mkCallStmt('CarryQ_Adjust', [ast.Name(self.carry_var, ast.Load()), ast.Num(self.carry_count)])]
Note: See TracChangeset for help on using the changeset viewer.