Changeset 512


Ignore:
Timestamp:
Jul 16, 2010, 6:28:29 AM (9 years ago)
Author:
cameron
Message:

Eliminate int_carry parameter

Location:
proto/Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/bitstream_compiler.py

    r434 r512  
    3434        f.close()
    3535
    36     def generate_code(self, s, file_path, int_carry):
     36    def generate_code(self, s, file_path):
    3737        # FRONT END
    3838        s = ast.parse(s)
     
    5151        all_lives, s = py2bitexpr.eliminate_dead_code(s, set(livelist))
    5252        s = py2bitexpr.factor_out(s)
    53         s, livelist = py2bitexpr.process_while_loops(s, int_carry)
     53        s, livelist = py2bitexpr.process_while_loops(s)
    5454       
    5555
    5656        # BACK END
    57         declarations = py2bitexpr.gen_declarations(s, int_carry)
     57        declarations = py2bitexpr.gen_declarations(s)
    5858        templ = self.read_template(file_path)
    5959
    60         templ = self.output(declarations, py2bitexpr.print_stream_stmts(copy.deepcopy(s)), py2bitexpr.print_block_stmts(s, int_carry), templ)
     60        templ = self.output(declarations, py2bitexpr.print_stream_stmts(copy.deepcopy(s)), py2bitexpr.print_block_stmts(s), templ)
    6161        self.write_final_code(templ)
    6262        return s
    6363
    6464OPTION_TEMPLATE_NAME = '-t'
    65 OPTION_INT_CARRY = '-int_carry'
    66 OPTION_SIMD_CARRY = '-simd-carry'
    6765
    6866
     
    8381
    8482    return flags, non_flags
    85 
    86 def option_carry(flags):
    87     l = len(flags)
    88     for i in range(l):
    89         if flags[i] == OPTION_SIMD_CARRY:
    90             return False, i
    91         if flags[i] == OPTION_INT_CARRY:
    92             return True, i
    93     return True, -1 #default carry type is int
    9483
    9584def option_template(flags):
     
    116105
    117106def read_options(flags):
    118     carry_option, index = option_carry(flags)
    119     if index >= 0:
    120         del flags[index]
    121    
    122107    template_name, index = option_template(flags)
    123108    if index >= 0:
     
    128113        print "WARNING: Unrecognized/duplicated options found!"
    129114   
    130     return carry_option, template_name
     115    return template_name
    131116###############################################################
    132117
     
    145130            out_file = non_flags[2]
    146131       
    147         carry_option, template_name = read_options(flags)
     132        template_name = read_options(flags)
    148133       
    149         s = Program(out_file, template_name).generate_code(read_input(non_flags[1]), file_path, carry_option)
     134        s = Program(out_file, template_name).generate_code(read_input(non_flags[1]), file_path)
  • proto/Compiler/py2bitexpr.py

    r460 r512  
    952952    return res
    953953
    954 def gen_output(var_dic, int_carry):
     954def gen_output(var_dic):
    955955        s = ''
    956956        for i in var_dic['bitblock']:
     
    975975
    976976        for i in  var_dic['int']:
    977                 if int_carry:
    978                         s+="CarryType %s = Carry0;\n"%i
    979                 else:
    980                         s+="CarryType %s = Carry0;\n"%i
     977                s+="CarryType %s = Carry0;\n"%i
     978
    981979
    982980
     
    10111009        return vd
    10121010
    1013 def gen_declarations(s, int_carry):
     1011def gen_declarations(s):
    10141012    vd = gen_var_dic(s)
    1015     return gen_output(vd, int_carry)
     1013    return gen_output(vd)
    10161014#################################################################################################################
    10171015## This class replaces all occurrences of a reduced variable to its value --- Pass 7
     
    12961294    return loop, carries
    12971295
    1298 def process_while_loops(code, int_carry):
     1296def process_while_loops(code):
    12991297    all = []
    13001298    update = {}
    13011299   
    1302     if int_carry:
    1303         carry_type = "int"
    1304     else:
    1305         carry_type = "vector"
     1300    carry_type = "int"
     1301
    13061302   
    13071303    for index, loc in enumerate(code):
     
    14611457        assert (1==0)
    14621458
    1463 def print_block_stmts(s, int_carry, indent = 0):
     1459def print_block_stmts(s, indent = 0):
    14641460    indent_unit = 4
    14651461    code = ""
     
    14681464    if isinstance(s[0], bitexpr.If):
    14691465        code = generate_statement(s[0].control_expr, indent, "if")
    1470         code += print_block_stmts(s[0].true_branch, int_carry, indent+indent_unit)
     1466        code += print_block_stmts(s[0].true_branch, indent+indent_unit)
    14711467        code += " "*indent+"}\n"
    14721468        code += " "*indent+"else {\n"
    1473         code += print_block_stmts(s[0].false_branch, int_carry, indent+indent_unit)
     1469        code += print_block_stmts(s[0].false_branch, indent+indent_unit)
    14741470        code += " "*indent+"}\n"
    14751471
    14761472    elif isinstance(s[0], bitexpr.WhileLoop):
    14771473        code = "\n%s((%s)||(test_carry(%s))) {\n"%(" "*indent+"while"+" ", generate_condition(s[0].control_expr), s[0].carry_expr.var.varname)
    1478         code += print_block_stmts(s[0].stmts, int_carry, indent+indent_unit)
     1474        code += print_block_stmts(s[0].stmts, indent+indent_unit)
    14791475        code += " "*indent+"}\n"
    14801476    elif (isinstance(s[0].RHS, bitexpr.Const)):
     
    15381534                code += ");\n"
    15391535    s.pop(0)
    1540     return code+print_block_stmts(s, int_carry, indent)
     1536    return code+print_block_stmts(s, indent)
    15411537
    15421538
Note: See TracChangeset for help on using the changeset viewer.