Commit Graph

539 Commits

Author SHA1 Message Date
whitequark
cf41890255 Correctly display backtraces that contain inlined functions. 2016-02-24 17:44:19 +00:00
whitequark
442673076f compiler: setting ARTIQ_DUMP_* dumps to a file instead of stderr. 2016-02-24 17:44:19 +00:00
whitequark
bc81be1345 Implement dumb 'with parallel' (#265). 2016-02-22 13:51:08 +00:00
whitequark
51a5910002 Rename 'with parallel' to 'with interleave' (#265). 2016-02-22 13:24:43 +00:00
whitequark
9db2be2b03 compiler: only use colors in diagnostics on POSIX (fixes #272). 2016-02-22 11:27:45 +00:00
whitequark
1465fe6f81 Add channel name as the first argument to rtio_log (#206). 2016-02-15 21:17:54 +00:00
whitequark
74a75841f6 Add rtio_log() and make print() an RPC (#206). 2016-02-15 03:56:56 +00:00
89f68f3470 style 2016-02-02 21:57:25 +01:00
whitequark
0acc86b3b3 transforms.iodelay_estimator: make diagnostics much more clear. 2016-01-27 02:10:15 +00:00
whitequark
3573a8750a transforms.inferencer: give a suggestion on "raise Exception". 2016-01-20 03:20:25 +00:00
whitequark
5c6b1517d0 Rigorously treat builtin core device exceptions. 2016-01-19 01:45:25 +00:00
whitequark
5f0e2bf9f9 analyses.domination: all blocks dominate themselves. 2016-01-18 21:33:14 +00:00
whitequark
cc22837627 transforms.inferencer: infer a monomorphic type for slice ":" 2016-01-16 03:09:03 +00:00
whitequark
85222783ee transforms.llvm_ir_generator: fix memoize(). 2016-01-16 00:38:57 +00:00
whitequark
bed62349d2 transforms.llvm_ir_generator: i64 doesn't need sret (fixes #228). 2016-01-15 23:58:11 +00:00
whitequark
127b117113 Add @host_only function decorator (#172). 2016-01-15 16:42:08 +00:00
whitequark
63f7899f93 Commit missing parts of 7f914a0. 2016-01-10 20:25:58 +00:00
whitequark
1be9e7576d transforms.llvm_ir_generator: use byval for FFI calls where appropriate. 2016-01-10 18:31:35 +00:00
whitequark
ee1ef551bc Fix symbolizer invocation with no addresses. 2016-01-10 18:04:10 +00:00
whitequark
d436093317 transforms.llvm_ir_generator: use sret attribute on FFI calls too. 2016-01-10 17:42:40 +00:00
whitequark
7f914a057c transforms.llvm_ir_generator: use sret attribute. 2016-01-10 17:31:59 +00:00
whitequark
edb7423a4f transforms.llvm_ir_generator: use getelementptr inbounds. 2016-01-10 16:36:04 +00:00
whitequark
a2a00e8b35 Set LLVM inlining threshold explicitly.
llvmlite's pass manager builder does not use a default when it
is not specified explicitly, unlike the C++ one.
2016-01-10 16:15:23 +00:00
whitequark
f92ce291ef transforms.llvm_ir_generator: call devirtualized functions directly. 2016-01-10 15:54:46 +00:00
whitequark
c46fccdf4b transforms.llvm_ir_generator: annotate invariant loads as such. 2016-01-10 15:45:34 +00:00
whitequark
b298170973 transforms.artiq_ir_generator: annotate embedded functions as internal. 2016-01-10 15:45:20 +00:00
whitequark
211af77e77 validators.escape: cache_get result lives forever. 2016-01-10 14:43:21 +00:00
whitequark
f2f1deb9db transforms.llvm_ir_generator: quote recrusive objects correctly (fixes #213). 2016-01-07 19:52:31 +00:00
whitequark
e8bba0a7d6 Commit missing parts of 6a6d7d. 2016-01-05 04:21:46 +00:00
whitequark
6a6d7dab19 transforms.artiq_ir_generator: add support for user-defined context managers. 2016-01-05 04:10:40 +00:00
whitequark
2955f9a1e0 Commit missing parts of 5baf18b. 2016-01-05 00:16:58 +08:00
whitequark
dfbf55fed2 transforms/inferencer: add support for user-defined context manager. 2016-01-05 00:11:03 +08:00
whitequark
5baf18ba0d transforms.inferencer: factor out _unify_attribute. 2016-01-04 22:13:05 +08:00
whitequark
05fa80818a transforms.inferencer: make sure parallel/sequential is lone manager. 2016-01-04 21:26:03 +08:00
whitequark
3aa5acbaf3 transforms.llvm_ir_generator: don't crash if embedding is not enabled. 2016-01-03 19:07:11 +08:00
whitequark
81427af506 Remove selective attribute writeback; always synchronize all attributes.
The reasons are:
  1. Shadow memory manipulation added ~12 instructions to TTLOut.pulse
     (without inlining), and it's already barely fast enough.
  2. More importantly, code such as self.ts[1] did not trigger
     attribute writeback, and there seems to be no easy way to fix
     that.
2016-01-03 04:57:58 +08:00
whitequark
38a99fde52 Implement selective attribute writeback using shadow memory. 2016-01-02 22:51:04 +08:00
whitequark
2e33084a5f transforms.llvm_ir_generator: implement instrumentation for attribute writeback. 2016-01-02 06:51:30 +08:00
whitequark
5f68cc6a21 transforms.artiq_ir_generator: handle raise in except: with finally:. 2016-01-02 06:51:29 +08:00
whitequark
693a364d85 transforms.artiq_ir_generator: fix typo. 2015-12-31 22:39:33 +08:00
whitequark
ff0ab736e9 Commit missing parts of 8aa34ee9. 2015-12-31 22:36:25 +08:00
whitequark
79d020dd3a transforms.artiq_ir_generator: handle terminated try body. 2015-12-31 22:36:25 +08:00
whitequark
8aa34ee952 compiler: don't require exceptions to inherit ARTIQException. 2015-12-31 21:54:54 +08:00
whitequark
0b69e488e6 transforms.llvm_ir_generator: compare exn typeinfo using strcmp.
This is necessary to correctly catch exceptions from RPCs.
2015-12-31 19:53:28 +08:00
whitequark
9ed6b54249 transforms.cfg_simplifier: remove.
Specifically, the following idiom broke our CFGSimplifier:

b1:
  branch_if %cond, %b2, %b3
b2:
  branch %b3
b3:
  %v = phi [ %b2 => 0, %b3 => 1 ]

This is very annoying to properly handle in general case, and also
this (specifically %b2) is exactly what broke LocalAccessValidator
in the first place. So, remove CFGSimplifier altogether.

Instead, teach LocalAccessValidator how to look through predecessors
in order to get a location.
2015-12-31 17:07:36 +08:00
whitequark
787a1d34fe transforms.llvm_ir_generator: don't crash when quoting over than one list. 2015-12-30 16:22:26 +08:00
whitequark
25e2824709 validators.escape: infer correct region for arguments. 2015-12-30 16:19:35 +08:00
whitequark
72b6cca9c3 transforms.cfg_simplifier: correctly update phis. 2015-12-30 16:07:14 +08:00
whitequark
2a474b7166 ir: fix incoming_{blocks,values,value_for_block}. 2015-12-30 16:06:18 +08:00
whitequark
ac3a170c8f transforms.llvm_ir_generator: don't crash when quoting empty lists. 2015-12-30 15:47:57 +08:00
whitequark
5dcf936f4e transforms.inferencer: don't crash on partially-inferred binary expressions. 2015-12-30 15:46:54 +08:00
whitequark
6938036b28 embedding: unify all derived attribute types. 2015-12-30 15:38:49 +08:00
whitequark
f52d364806 Mollify PEP 0479. 2015-12-30 15:33:30 +08:00
whitequark
78fb3e1b7b compiler: validate local accesses after interleaving. 2015-12-30 15:26:30 +08:00
whitequark
df91500f68 Fix ff3206be. 2015-12-30 15:16:05 +08:00
whitequark
ff3206be07 compiler.embedding: treat RPC methods like any others (fixes #211). 2015-12-30 14:21:09 +08:00
whitequark
14484216ec transforms.cfg_simplifier: handle phi and branch_if properly. 2015-12-30 12:10:28 +08:00
whitequark
8822db089f transforms.cfg_simplifier: implement.
This allows error reporting in LocalAccessValidator to proceed
even when the predecessor is an empty block with only a branch.
2015-12-29 02:15:57 +08:00
whitequark
57ebd57ddb transforms.dead_code_eliminator: update doc. 2015-12-29 02:15:57 +08:00
whitequark
82ec76af3e compiler.types: fix TFunction internal field order (closes #208). 2015-12-26 18:08:51 +08:00
whitequark
b931096ec3 transforms.artiq_ir_generator: fix While codegen (closes #207). 2015-12-26 17:24:05 +08:00
whitequark
502e570e86 compiler: embed host exception constructors as such (fixes #204). 2015-12-26 03:17:29 +08:00
whitequark
8051fe9592 Commit missing parts of 082e9e20dd. 2015-12-26 03:16:50 +08:00
whitequark
082e9e20dd compiler: do not associate SSA values with iodelay even when inlining.
Fixes #201.
2015-12-25 15:02:33 +08:00
whitequark
33c3b3377e ir: keep loc when copying. 2015-12-25 14:59:28 +08:00
whitequark
690b2fd034 transforms.artiq_ir_generator: fix optarg codegen (closes #205). 2015-12-25 12:40:45 +08:00
whitequark
25188f0ca9 transforms.interleaver: correctly handle degenerate with parallel: blocks. 2015-12-21 21:32:48 +08:00
whitequark
f957be4e6f transforms.llvm_ir_generator: handle loop instruction (fixes #202). 2015-12-21 21:12:17 +08:00
whitequark
e4615e7b37 transforms.int_monomorphizer: visit children of CallT. 2015-12-20 18:07:31 +08:00
whitequark
54aeb5030d transforms.int_monomorphizer: also monomorphize round() calls (#198). 2015-12-20 02:36:30 +08:00
whitequark
95af6daa28 transforms.inferencer: accept round(width=n) form (#198). 2015-12-20 01:02:57 +08:00
whitequark
4fcd6abc5e Commit missing parts of 0395efd4. 2015-12-19 06:33:29 +08:00
whitequark
4fb1de33c9 Initial invocation of a @kernel function can now return a value (fixes #197). 2015-12-19 05:26:18 +08:00
whitequark
0395efd479 compiler: give environment types in LLVM IR readable names. 2015-12-18 23:41:51 +08:00
whitequark
baa986aa32 compiler.prelude: add @portable as an alias for @kernel. 2015-12-18 23:00:29 +08:00
whitequark
7b3ace2e30 transforms.inferencer: fix unsupported decorator diagnostic when embedding.
decorator.loc points to the quoted object with a synthesized location,
and it's not really worth refactoring when we can just point at the @.
2015-12-18 22:58:17 +08:00
whitequark
0755aa38ff transforms.iodelay_estimator: allow goto in zero-iodelay while statements. 2015-12-18 21:14:40 +08:00
whitequark
2759310662 transforms.iodelay_estimator: reject control flow in 'with parallel:' (fixes #195). 2015-12-18 21:02:53 +08:00
whitequark
f4b19fee5c compiler.types: make TValue hashable. 2015-12-18 17:31:20 +08:00
whitequark
3fbee2707b analyses.domination: consider unreachable blocks dominated by any other.
As a result, the dominator tree can now process arbitrary (reducible)
CFGs and we do not run DCE before analyses, risking loss of
correspondence to the AST, which would arbitrarily silence analyses.
2015-12-18 16:39:52 +08:00
whitequark
8cb7844621 transforms.interleaver: unroll loops. 2015-12-17 00:52:22 +08:00
whitequark
5dd1fc993e transforms.dead_code_eliminator: also remove dead instructions. 2015-12-17 00:52:22 +08:00
whitequark
2570932264 transforms.interleaver: don't fail on delay-free loops/conditionals. 2015-12-16 19:26:17 +08:00
whitequark
69cdeaf706 transforms.interleaver: don't fail on degenerate parallel blocks. 2015-12-16 19:26:17 +08:00
whitequark
f8eaeaa43f compiler: explicitly represent loops in IR. 2015-12-16 15:33:26 +08:00
whitequark
35acc33ef6 validators.escape: don't fail on quoted values in lhs. 2015-12-16 13:57:02 +08:00
whitequark
8751d2ee6c Delay.{expr→interval}. 2015-12-16 13:57:02 +08:00
whitequark
e755e1ba9e validators.escape: support arrays in multiple assignment. 2015-12-14 16:31:03 +08:00
whitequark
25027f6907 compiler: fix tests. 2015-12-10 23:16:36 +08:00
whitequark
2d906daf7f compiler: implement 'with watchdog' support. 2015-12-10 23:11:00 +08:00
whitequark
64f19b84f2 compiler.testbench.llvmgen: fix. 2015-12-10 23:08:05 +08:00
whitequark
4888e897b9 compiler: refactor to use builtins.TInt{32,64}. (NFC) 2015-12-10 23:06:23 +08:00
whitequark
143bae4bd3 compiler.builtins: {fn→obj}_{serial,parallel}. 2015-12-10 23:03:28 +08:00
whitequark
c660028abf transforms.llvm_ir_generator: fix reraise inside EH block. 2015-12-10 23:02:32 +08:00
whitequark
3ec9b677b2 Revert "transforms.artiq_ir_generator: treat builtins in 'with' syntactically."
This reverts commit ccc993071b.
2015-12-10 22:25:15 +08:00
whitequark
ccc993071b transforms.artiq_ir_generator: treat builtins in 'with' syntactically. 2015-12-10 21:29:16 +08:00
whitequark
22dab0c7cc compiler: clarify confusing comment (NFC). 2015-12-10 20:50:28 +08:00
whitequark
8cb2215edb transforms.inferencer: only instantiate RPC function types, not regular. 2015-12-02 21:48:14 +08:00
whitequark
3c9b53b07b compiler.embedding: add fast path for inference for lists of scalars in a host object. 2015-11-27 19:06:04 +08:00
whitequark
237e983770 compiler.types: replace isinstance() with .__class__==.
This provides a 50% speedup.
2015-11-27 18:22:55 +08:00
whitequark
6122fd70ca compiler.types: TVar.find: improve path compression.
After this change, the compiler's complexity is nearly linear
even when very large arrays are used.
2015-11-27 18:08:46 +08:00
whitequark
bf1a583fda compiler.types: fix TVar.find() for very large paths. 2015-11-27 18:02:27 +08:00
whitequark
00164390a1 compiler.types: fix TDelay.unify(TVar()). 2015-11-27 17:10:36 +08:00
whitequark
4b410ce720 compiler.testbench.perf_embedding: fix. 2015-11-27 17:08:45 +08:00
whitequark
16ae0fb6eb compiler.embedding: instantiate RPC method types (fixes #180). 2015-11-27 16:29:13 +08:00
whitequark
0a794fe7e4 compiler.embedding: instantiate type of even the first embedding of an RPC. 2015-11-27 14:55:47 +08:00
whitequark
cde21bcd26 compiler.embedding: instantiate RPC function types (#180). 2015-11-27 14:29:15 +08:00
whitequark
3b529c6f90 compiler.types: implement map. 2015-11-26 11:16:39 +08:00
whitequark
e2f7d1047d compiler.testbench: fix after e1cd2ccd. 2015-11-26 10:24:14 +08:00
whitequark
d14ad6727a compiler.embedding: avoid showing wildly incorrect suggestions. 2015-11-24 17:50:46 +08:00
whitequark
14993e89e2 compiler.embedding: show suggestions for mistyped host object attributes. 2015-11-24 17:44:58 +08:00
whitequark
e1cd2ccd40 compiler: pull in dependencies in more finely grained way (fixes #181). 2015-11-24 17:32:04 +08:00
whitequark
66b1388a63 transforms.artiq_ir_generator: never put TVars in dicts.
A TVar looks just like whatever it points to, but it does not
compare equal, nor is its hash the same.
2015-11-24 02:59:15 +08:00
whitequark
fec5c2ebf0 transforms.interleaver: add a diagnostic for interleave inlining failure. 2015-11-24 02:57:03 +08:00
whitequark
8527e306c3 testbench.embedding: use dmgr to get core and export it. 2015-11-24 02:02:34 +08:00
whitequark
2bfc72fba9 testbench.embedding: fix ref_period mismatch. 2015-11-24 00:54:20 +08:00
whitequark
d3f0059cab compiler.iodelay: correctly fold max(0, [0, ]...). 2015-11-24 00:46:55 +08:00
whitequark
9bc62fa3d2 transforms.iodelay_estimator: correctly handle functions with empty body. 2015-11-24 00:46:26 +08:00
whitequark
32fe4a8a0c transforms.llvm_ir_generator: don't assert on inlined functions. 2015-11-24 00:20:33 +08:00
whitequark
abb36b42be compiler.iodelay: fold and eval SToMU to an int, not float. 2015-11-24 00:19:33 +08:00
whitequark
178ff74da2 transforms.interleaver: inline calls. 2015-11-24 00:02:07 +08:00
whitequark
2a82eb7219 compiler.ir: return dict from Delay.substs, not pair iterable. 2015-11-24 00:01:10 +08:00
whitequark
02f2763ea8 compiler.iodelay: always fully fold SToMU and MUToS. 2015-11-23 23:59:59 +08:00
whitequark
f3da227e2d compiler.ir: change argument order for BasicBlock.insert. 2015-11-23 23:59:25 +08:00
whitequark
f0fd6cd0ca compiler.algorithms.inline: implement. 2015-11-23 23:58:37 +08:00
whitequark
a4525b21cf compiler.ir: print even blocks without predecessors. 2015-11-23 23:55:12 +08:00
whitequark
d92b3434a0 compiler.ir: print basic blocks in reverse postorder for readability. 2015-11-23 21:44:38 +08:00
whitequark
c73b2c1a78 compiler.ir: fix typo. 2015-11-23 21:21:01 +08:00
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
73845279ae transforms.interleaver: determine when inlining is not necessary. 2015-11-23 18:08:33 +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
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
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