forked from M-Labs/artiq
1
0
Fork 0

compiler: first monomorphize ints, then casts.

Fixes #1242.
This commit is contained in:
whitequark 2019-01-12 13:37:20 +00:00
parent 49682d0159
commit 425cd7851e
3 changed files with 10 additions and 1 deletions

View File

@ -66,8 +66,8 @@ class Module:
interleaver = transforms.Interleaver(engine=self.engine) interleaver = transforms.Interleaver(engine=self.engine)
invariant_detection = analyses.InvariantDetection(engine=self.engine) invariant_detection = analyses.InvariantDetection(engine=self.engine)
cast_monomorphizer.visit(src.typedtree)
int_monomorphizer.visit(src.typedtree) int_monomorphizer.visit(src.typedtree)
cast_monomorphizer.visit(src.typedtree)
inferencer.visit(src.typedtree) inferencer.visit(src.typedtree)
monomorphism_validator.visit(src.typedtree) monomorphism_validator.visit(src.typedtree)
escape_validator.visit(src.typedtree) escape_validator.visit(src.typedtree)

View File

@ -18,6 +18,7 @@ class CastMonomorphizer(algorithm.Visitor):
types.is_builtin(node.func.type, "int64")): types.is_builtin(node.func.type, "int64")):
typ = node.type.find() typ = node.type.find()
if (not types.is_var(typ["width"]) and if (not types.is_var(typ["width"]) and
len(node.args) == 1 and
builtins.is_int(node.args[0].type) and builtins.is_int(node.args[0].type) and
types.is_var(node.args[0].type.find()["width"])): types.is_var(node.args[0].type.find()["width"])):
if isinstance(node.args[0], asttyped.BinOpT): if isinstance(node.args[0], asttyped.BinOpT):

View File

@ -0,0 +1,8 @@
# RUN: %python -m artiq.compiler.testbench.signature %s >%t
# RUN: OutputCheck %s --file-to-check=%t
x = 0x100000000
# CHECK-L: x: numpy.int64
y = int32(x)
# CHECK-L: y: numpy.int32