Ignore:
Timestamp:
Sep 9, 2013, 12:38:58 PM (6 years ago)
Author:
cameron
Message:

Clean out mkCall in favor of mkast.call, add C mode framework for mkast.call

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/mkast.py

    r3017 r3452  
    1010import ast
    1111
     12use_C_syntax = False
     13
     14C_map = {"esimd<%i>::mergeh" : "simd_mergeh_%i",
     15         "bitblock::any" : "bitblock_has_bit",
     16         "print_register<BitBlock>" : "print_bitblock"}
     17
     18def map_if_C(str):
     19        if not use_C_syntax: return str
     20        if not C_map.has_key(str): return str
     21        return C_map[str]
    1222#
    1323# Helper functions
     
    1626    if isinstance(testExpr, ast.Call):
    1727      assert isinstance(testExpr.func, ast.Name)
    18       assert testExpr.func.id == 'bitblock::any'
     28      assert testExpr.func.id == 'bitblock::any' or testExpr.func.id == 'bitblock_has_bit'
    1929      testExpr.args[0] = call('simd_or', [bitBlockExpr, testExpr.args[0]])
    2030      return testExpr
    2131    else:
    22       return ast.BinOp(testExpr, ast.BitOr(), call('bitblock::any', [bitBlockExpr]))
     32      return ast.BinOp(testExpr, ast.BitOr(), call(map_if_C('bitblock::any'), [bitBlockExpr]))
    2333
    2434def TestHelper_Integer_Or(testExpr, intExpr):
     
    5868  if isinstance(fn_name, str):
    5969        fn_name = ast.Name(fn_name, ast.Load())
    60   return ast.Call(fn_name, args, [], None, None)
     70  return ast.Call(map_if_C(fn_name), args, [], None, None)
    6171
    6272def callStmt(fn_name, args):
    6373  if isinstance(fn_name, str): fn_name = ast.Name(fn_name, ast.Load())
    64   return ast.Expr(ast.Call(fn_name, args, [], None, None))
     74  return ast.Expr(ast.Call(map_if_C(fn_name), args, [], None, None))
    6575
    6676def mergeh(fw, x, y):
    67   return call("esimd<%i>::mergeh" % fw, [var(x), var(y)])
     77  return call(map_if_C("esimd<%i>::mergeh") % fw, [var(x), var(y)])
    6878
    6979def zero(fw):
    70   return call("simd<%i>::constant<0>" % fw, [])
     80  return call(map_if_C("simd<%i>::constant<0>") % fw, [])
    7181
    7282def Qname(obj, field):
Note: See TracChangeset for help on using the changeset viewer.