Changeset 770 for proto/Compiler


Ignore:
Timestamp:
Dec 3, 2010, 5:25:55 AM (9 years ago)
Author:
cameron
Message:

andc introduction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r769 r770  
    2424        return iscall and len(fncall.args) == 2 and fncall.kwargs == None and fncall.starargs == None
    2525
     26def is_simd_not(e):
     27  return isinstance(e, ast.Call) and isinstance(e.func, ast.Name) and e.func.id == 'simd_not'
     28
    2629def mkQname(obj, field):
    2730  return ast.Attribute(ast.Name(obj, ast.Load()), field, ast.Load())
     
    4245  Make the following substitutions:
    4346     x & y => simd_and(x, y)
     47     x & ~y => simd_andc(x, y)
    4448     x | y => simd_or(x, y)
    4549     x ^ y => simd_xor(x, y)
     
    6771      return mkCall('simd_or', [t.left, t.right])
    6872    elif isinstance(t.op, ast.BitAnd):
    69       return mkCall('simd_and', [t.left, t.right])
     73      if is_simd_not(t.right): return mkCall('simd_andc', [t.left, t.right.args[0]])
     74      elif is_simd_not(t.left): return mkCall('simd_andc', [t.right, t.left.args[0]])
     75      else: return mkCall('simd_and', [t.left, t.right])
    7076    elif isinstance(t.op, ast.BitXor):
    7177      return mkCall('simd_xor', [t.left, t.right])
Note: See TracChangeset for help on using the changeset viewer.