forked from M-Labs/artiq
compiler: implement ~ operator (fix #836).
This commit is contained in:
parent
843786a091
commit
f86744c65c
@ -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),
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user