From 6155f65366e50c3eec60e7ed42d81f8d27b4a98b Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 28 Jun 2016 04:39:14 +0000 Subject: [PATCH] compiler: remove now()/at(). Fixes #490. --- artiq/compiler/builtins.py | 6 ------ artiq/compiler/prelude.py | 2 -- artiq/compiler/transforms/artiq_ir_generator.py | 11 ++--------- artiq/test/lit/time/advance.py | 8 +++----- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/artiq/compiler/builtins.py b/artiq/compiler/builtins.py index 0d091e74f..baef12797 100644 --- a/artiq/compiler/builtins.py +++ b/artiq/compiler/builtins.py @@ -162,15 +162,9 @@ def obj_sequential(): def fn_watchdog(): return types.TBuiltinFunction("watchdog") -def fn_now(): - return types.TBuiltinFunction("now") - def fn_delay(): return types.TBuiltinFunction("delay") -def fn_at(): - return types.TBuiltinFunction("at") - def fn_now_mu(): return types.TBuiltinFunction("now_mu") diff --git a/artiq/compiler/prelude.py b/artiq/compiler/prelude.py index 8809f7612..c8dfb3561 100644 --- a/artiq/compiler/prelude.py +++ b/artiq/compiler/prelude.py @@ -38,9 +38,7 @@ def globals(): "watchdog": builtins.fn_watchdog(), # ARTIQ time management functions - "now": builtins.fn_now(), "delay": builtins.fn_delay(), - "at": builtins.fn_at(), "now_mu": builtins.fn_now_mu(), "delay_mu": builtins.fn_delay_mu(), "at_mu": builtins.fn_at_mu(), diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index 5db5809e5..0bea60020 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -1692,19 +1692,12 @@ class ARTIQIRGenerator(algorithm.Visitor): self.polymorphic_print([self.visit(arg) for arg in args], separator=" ", suffix="\n\x1D", as_rtio=True) return ir.Constant(None, builtins.TNone()) - elif types.is_builtin(typ, "now"): - 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"): + elif types.is_builtin(typ, "delay"): if len(node.args) == 1 and len(node.keywords) == 0: arg = self.visit(node.args[0]) 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())) - return self.append(ir.Builtin(typ.name + "_mu", [arg_mu], builtins.TNone())) + return self.append(ir.Builtin("delay_mu", [arg_mu], builtins.TNone())) else: assert False elif types.is_builtin(typ, "now_mu") or types.is_builtin(typ, "delay_mu") \ diff --git a/artiq/test/lit/time/advance.py b/artiq/test/lit/time/advance.py index 99ca1f1d7..7a6a894aa 100644 --- a/artiq/test/lit/time/advance.py +++ b/artiq/test/lit/time/advance.py @@ -1,10 +1,8 @@ # RUN: %python -m artiq.compiler.testbench.jit %s # REQUIRES: time -assert now() == 0.0 +assert now_mu() == 0 delay(100.0) -assert now() == 100.0 -at(12345.0) -assert now() == 12345.0 - +assert now_mu() == 100000000 +at_mu(12345000000) assert now_mu() == 12345000000