forked from M-Labs/artiq
1
0
Fork 0

compiler: implement ~ operator (fix #836).

This commit is contained in:
whitequark 2017-10-01 19:33:18 +00:00 committed by Sebastien Bourdeauducq
parent d0276abb5c
commit 1001993e3f
2 changed files with 6 additions and 0 deletions

View File

@ -1289,6 +1289,10 @@ class ARTIQIRGenerator(algorithm.Visitor):
return self.append(ir.Select(cond,
ir.Constant(False, builtins.TBool()),
ir.Constant(True, builtins.TBool())))
elif isinstance(node.op, ast.Invert):
operand = self.visit(node.operand)
return self.append(ir.Arith(ast.BitXor(loc=None),
ir.Constant(-1, operand.type), operand))
elif isinstance(node.op, ast.USub):
operand = self.visit(node.operand)
return self.append(ir.Arith(ast.Sub(loc=None),

View File

@ -41,6 +41,8 @@ assert -1 >> 32 == -1
assert 0x18 & 0x0f == 0x08
assert 0x18 | 0x0f == 0x1f
assert 0x18 ^ 0x0f == 0x17
#ARTIQ#assert ~0x18 == -25
#ARTIQ#assert ~int64(0x18) == -25
try:
1 / 0