forked from M-Labs/artiq
1
0
Fork 0
Commit Graph

2076 Commits

Author SHA1 Message Date
whitequark 0bf425eefa compiler.ir: maintain use lists while mutating instructions. 2015-11-23 19:18:58 +08:00
whitequark 03b4e4027c transforms.interleaver: fix IR type/value mismatch. 2015-11-23 18:53:42 +08:00
whitequark 9fc7a42036 pipistrello: expose LED{1..4} as RTIO channels. 2015-11-23 18:26:45 +08:00
whitequark 73845279ae transforms.interleaver: determine when inlining is not necessary. 2015-11-23 18:08:33 +08:00
whitequark af43c66149 artiq_compile: set file_import prefix, like in artiq_run. 2015-11-21 17:37:14 +08:00
whitequark a01e328b4a transforms.interleaver: don't assume all delay expressions are folded. 2015-11-21 17:24:00 +08:00
whitequark 5cd12ffd28 compiler.iodelay: fold MUToS and SToMU. 2015-11-21 17:23:20 +08:00
whitequark 82b470891f transforms.interleaver: handle function calls (as atomic so far).
This commit solves issue #2 described in 50e7b44; a function call
is now a valid decomposition for a delay instruction, and this
metadata is propagated when the interleaver converts delays.

However, the interleaver does not yet detect that a called function
is compound, i.e. it is not correct.
2015-11-21 03:34:24 +08:00
whitequark 57dd163d37 transforms.artiq_ir_generator: fix decomposition of explicit delay_mu(). 2015-11-21 03:27:06 +08:00
whitequark cb3b811fd7 compiler: maintain both the IR and iodelay forms of delay expressions.
After this commit, the delay instruction (again) does not generate
any LLVM IR: all heavy lifting is relegated to the delay and delay_mu
intrinsics. When the interleave transform needs to adjust the global
timeline, it synthesizes a delay_mu intrinsnic. This way,
the interleave transformation becomes composable, as the input and
the output IR invariants are the same.

Also, code generation is adjusted so that a basic block is split off
not only after a delay call, but also before one; otherwise, e.g.,
code immediately at the beginning of a `with parallel:` branch
would have no choice but to execute after another branch has already
advanced the timeline.

This takes care of issue #1 described in 50e7b44 and is a step
to solving issue #2.
2015-11-21 03:22:47 +08:00
whitequark 50e7b44d04 compiler: actually implement interleaving correctly (calls are still broken).
The previous implementation was completely wrong: it always advanced
the global timeline by the same amount as the non-interleaved basic
block did.

The new implementation only advances the global timeline by
the difference between its current time and the virtual time of
the branch, which requires it to adjust the delay instructions.

Previously, the delay expression was present in the IR twice: once
as the iodelay.Expr transformation-visible form, and once as regular
IR instructions, with the latter form being passed to the delay_mu
builtin and advancing the runtime timeline.

As a result of this change, this strategy is no longer valid:
we can meaningfully mutate the iodelay.Expr form but not the IR
instruction form. Thus, IR instructions are no longer generated for
delay expressions, and the LLVM lowering pass now has to lower
the iodelay.Expr objects as well.

This works OK for flat `with parallel:` expressions, but breaks down
outside of `with parallel:` or when calls are present. The reasons
it breaks down are as follows:

  * Outside of `with parallel:`, delay() and delay_mu() must accept
    any expression, but iodelay.Expr's are not nearly expressive
    enough. So, the IR instruction form must actually be kept as well.

  * A delay instruction is currently inserted after a call to
    a user-defined function; this delay instruction introduces
    a point where basic block reordering is possible as well as
    provides delay information. However, the callee knows nothing
    about the context in which it is called, which means that
    the runtime timeline is advanced twice. So, a new terminator
    instruction must be added that combines the properties of delay
    and call instructions (and another for delay and invoke as well).
2015-11-21 00:02:47 +08:00
whitequark 73c358a59a Reformat. 2015-11-20 23:33:06 +08:00
whitequark cb9e7d15bf compiler.iodelay: subtraction certainly shouldn't be commutative. 2015-11-20 22:15:03 +08:00
whitequark cc623c13b4 Reformat. 2015-11-20 21:45:34 +08:00
whitequark d0f86e05d0 transforms.interleaver: add safety check. 2015-11-20 17:27:04 +08:00
whitequark 88b7990714 transforms.iodelay_estimator: fail statements with indeterminate delay inside `with parallel`. 2015-11-20 17:10:25 +08:00
whitequark 28fa68730a Merge branch 'master' into new-py2llvm 2015-11-20 15:55:29 +08:00
whitequark 00ec574d73 transforms.interleaver: implement (without inlining). 2015-11-20 00:03:26 +08:00
whitequark 025bfbe746 transforms.llvm_ir_generator: accept delay instructions.
The delay instruction is just like a branch (discontinuity
in instruction flow), but it also carries metadata: how long
did the execution of its basic block take. This metadata only
matters during inlining and interleaving, so we treat it here
as a mere branch.
2015-11-19 23:55:52 +08:00
whitequark 9639a831bc transforms.artiq_ir_generator: correctly emit IfExpT with control flow.
This can happen with nested if expressions, as well as if
the if expression includes delays.
2015-11-19 23:44:39 +08:00
whitequark b9bb5fba6a lit-test: fix iodelay/class test (broken in 506725f). 2015-11-19 23:28:50 +08:00
whitequark a04d0f8fbd lit-test: fix inferencer/error_class test (broken in b0c6b70). 2015-11-19 23:28:00 +08:00
whitequark 2543daa5cf transforms.artiq_ir_generator: don't emit delay instruction for zero delay.
Call nodes with iodelay=Const(0) can be generated outside of
`with parallel:`, where Interleaver won't and LLVMIRGenerator can't
lower them.
2015-11-19 23:24:46 +08:00
whitequark 58db347e01 transforms.iodelay_estimator: fix uninitialized access. 2015-11-19 23:23:39 +08:00
whitequark 48a2bb10d5 transforms.interleaver: add boilerplate. 2015-11-17 05:22:20 +03:00
whitequark de9d7eb2e4 compiler: add `delay` IR instruction. 2015-11-17 05:16:43 +03:00
whitequark 956d2afcb2 compiler.iodelay: fold Max further. 2015-11-17 03:06:07 +03:00
whitequark 7d2fca291d compiler.iodelay: add missing import. 2015-11-17 01:30:19 +03:00
whitequark e619154c81 transforms.iodelay_estimator: fix handling of `with sequential`. 2015-11-17 01:22:48 +03:00
whitequark 506725f78a transforms.iodelay_estimator: fix handling of methods. 2015-11-17 01:19:22 +03:00
whitequark b0c6b70971 transforms.asttyped_rewriter: fix class redefinition diagnostic. 2015-11-17 01:17:25 +03:00
whitequark 80f0bfe0ad lit-test: add test for iodelay order invariance. 2015-11-17 01:04:20 +03:00
whitequark 3fb12b74d6 lit-test: update to follow IR serialization changes. 2015-11-17 01:04:08 +03:00
whitequark 9e0a5b9404 transforms.iodelay_estimator: skip statements, not modules on _UnknownDelay. 2015-11-17 01:00:10 +03:00
whitequark 44d0a35409 transforms.iodelay_estimator: actually iterate to fixpoint. 2015-11-17 00:59:40 +03:00
whitequark 10f82ff2c8 transforms.iodelay_estimator: do not unify indeterminate delays. 2015-11-17 00:59:09 +03:00
whitequark 841e01a8bb compiler.iodelay: fix typo in Var.__eq__. 2015-11-17 00:53:12 +03:00
whitequark a2d73c8b05 compiler.types: dump type variable iodelay explicitly. 2015-11-17 00:51:56 +03:00
whitequark e67705dc27 compiler.iodelay: fix typo in BinOp.__eq__. 2015-11-17 00:51:37 +03:00
whitequark 629aacec09 compiler.iodelay: add forgotten Conv.__eq__. 2015-11-17 00:51:22 +03:00
whitequark fd46690cf5 compiler: make IR dumps vastly more readable. 2015-11-17 00:23:34 +03:00
whitequark eefa9e2ea6 transforms.inferencer: fix typo. 2015-11-17 00:02:15 +03:00
whitequark c8cfa7c7bd compiler: give suggestions in diagnostics for unbound variable.
This uses the Jaro-Winkler edit distance, which seemed like the best
fit for identifiers, even though it is intended for people's names.
2015-11-15 23:09:40 +03:00
whitequark 9670939ca6 compiler.analyses.domination: fix PostDominatorTree. 2015-11-09 12:49:27 +03:00
whitequark 19fae9181c compiler.analyses.domination: implement new dominator tree algorithm. 2015-11-09 11:51:54 +03:00
whitequark 73c22b0b1e Fix tests. 2015-11-07 15:17:31 +03:00
whitequark 0b8535dc67 Update .gitignore. 2015-11-07 15:14:43 +03:00
whitequark a0c6f75f9b compiler.types: fix obsolete iodelay references. 2015-11-07 15:14:19 +03:00
whitequark 51f04f6311 Explicitly use the python3.5 binary everywhere. 2015-11-07 13:39:39 +03:00
whitequark 0b5e1d174c Unbreak artiq_flash.sh. 2015-11-07 13:26:14 +03:00