forked from M-Labs/artiq
1
0
Fork 0

compiler: remove now()/at().

Fixes #490.
This commit is contained in:
whitequark 2016-06-28 04:39:14 +00:00 committed by Sebastien Bourdeauducq
parent 1bb09f9ca6
commit d22eefc13e
4 changed files with 5 additions and 22 deletions

View File

@ -156,15 +156,9 @@ def obj_sequential():
def fn_watchdog(): def fn_watchdog():
return types.TBuiltinFunction("watchdog") return types.TBuiltinFunction("watchdog")
def fn_now():
return types.TBuiltinFunction("now")
def fn_delay(): def fn_delay():
return types.TBuiltinFunction("delay") return types.TBuiltinFunction("delay")
def fn_at():
return types.TBuiltinFunction("at")
def fn_now_mu(): def fn_now_mu():
return types.TBuiltinFunction("now_mu") return types.TBuiltinFunction("now_mu")

View File

@ -36,9 +36,7 @@ def globals():
"watchdog": builtins.fn_watchdog(), "watchdog": builtins.fn_watchdog(),
# ARTIQ time management functions # ARTIQ time management functions
"now": builtins.fn_now(),
"delay": builtins.fn_delay(), "delay": builtins.fn_delay(),
"at": builtins.fn_at(),
"now_mu": builtins.fn_now_mu(), "now_mu": builtins.fn_now_mu(),
"delay_mu": builtins.fn_delay_mu(), "delay_mu": builtins.fn_delay_mu(),
"at_mu": builtins.fn_at_mu(), "at_mu": builtins.fn_at_mu(),

View File

@ -1671,19 +1671,12 @@ class ARTIQIRGenerator(algorithm.Visitor):
self.polymorphic_print([self.visit(arg) for arg in args], self.polymorphic_print([self.visit(arg) for arg in args],
separator=" ", suffix="\n\x1D", as_rtio=True) separator=" ", suffix="\n\x1D", as_rtio=True)
return ir.Constant(None, builtins.TNone()) return ir.Constant(None, builtins.TNone())
elif types.is_builtin(typ, "now"): elif types.is_builtin(typ, "delay"):
if len(node.args) == 0 and len(node.keywords) == 0:
now_mu = self.append(ir.Builtin("now_mu", [], builtins.TInt64()))
now_mu_float = self.append(ir.Coerce(now_mu, builtins.TFloat()))
return self.append(ir.Arith(ast.Mult(loc=None), now_mu_float, self.ref_period))
else:
assert False
elif types.is_builtin(typ, "delay") or types.is_builtin(typ, "at"):
if len(node.args) == 1 and len(node.keywords) == 0: if len(node.args) == 1 and len(node.keywords) == 0:
arg = self.visit(node.args[0]) arg = self.visit(node.args[0])
arg_mu_float = self.append(ir.Arith(ast.Div(loc=None), arg, self.ref_period)) arg_mu_float = self.append(ir.Arith(ast.Div(loc=None), arg, self.ref_period))
arg_mu = self.append(ir.Coerce(arg_mu_float, builtins.TInt64())) arg_mu = self.append(ir.Coerce(arg_mu_float, builtins.TInt64()))
return self.append(ir.Builtin(typ.name + "_mu", [arg_mu], builtins.TNone())) return self.append(ir.Builtin("delay_mu", [arg_mu], builtins.TNone()))
else: else:
assert False assert False
elif types.is_builtin(typ, "now_mu") or types.is_builtin(typ, "delay_mu") \ elif types.is_builtin(typ, "now_mu") or types.is_builtin(typ, "delay_mu") \

View File

@ -1,10 +1,8 @@
# RUN: %python -m artiq.compiler.testbench.jit %s # RUN: %python -m artiq.compiler.testbench.jit %s
# REQUIRES: time # REQUIRES: time
assert now() == 0.0 assert now_mu() == 0
delay(100.0) delay(100.0)
assert now() == 100.0 assert now_mu() == 100000000
at(12345.0) at_mu(12345000000)
assert now() == 12345.0
assert now_mu() == 12345000000 assert now_mu() == 12345000000