Commit Graph

148 Commits

Author SHA1 Message Date
David Nadlinger f0284b2549 compiler: Fix collision of environments in matmult implementations
GitHub: Fixes #1578.
2021-01-12 03:02:07 +01:00
David Nadlinger 96692791cf compiler: Implement assigning binops for arrays
GitHub: Fixes #1579.
2021-01-12 03:02:07 +01:00
Sebastien Bourdeauducq 072053c3b2 compiler: remove obsolete watchdog code (#1458) 2020-12-08 13:25:08 +08:00
Sebastien Bourdeauducq eda4850f64 Revert "fixes with statement with multiple items"
This reverts commit 88d346fa26.
2020-11-22 11:57:22 +08:00
Sebastien Bourdeauducq 8e46c3c1fd Revert "compiler: fix incorrect with behavior"
This reverts commit fe6115bcbb.
2020-11-22 11:57:21 +08:00
David Nadlinger d95e619567 compiler: Implement binary NumPy math functions (arctan2, …)
The bulk of the diff is just factoring out the implementation
for binary arithmetic implementations, to be reused for binary
function calls.
2020-11-11 01:35:28 +01:00
David Nadlinger 292043a0a7 compiler: Raise AssertionErrors instead of abort()ing on all targets 2020-11-10 20:40:18 +01:00
David Nadlinger 4f311e7448 compiler: Raise exception on failed assert()s rather than panic
This allows assert() to be used on Zynq, where abort() is not
currently implemented for kernels. Furthermore, this is arguably
the more natural implementation of assertions on all kernel targets
(i.e. where embedding into host Python is used), as it matches host
Python behavior, and the exception information actually makes it to
the user rather than leading to a ConnectionClosed error.

Since this does not implement printing of the subexpressions, I
left the old print+abort implementation as default for the time
being.

The lit/integration/instance.py diff isn't just a spurious change;
the exception-based assert implementation exposes a limitation in
the existing closure lifetime tracking algorithm (which is not
supposed to be what is tested there).

GitHub: Fixes #1539.
2020-11-10 00:51:24 +01:00
pca006132 e9988f9d3b compiler: error message for custom operations
Emit error messages for custom comparison and inclusion test,
instead of compiler crashing.
2020-10-08 19:38:26 +08:00
pca006132 fe6115bcbb compiler: fix incorrect with behavior 2020-10-07 18:59:35 +08:00
pca006132 02f46e8b79 Fixes none to bool coercion
Fixes #1413 and #1414.
2020-10-07 15:34:24 +08:00
pca006132 88d346fa26 fixes with statement with multiple items
Closes #1478
2020-10-07 15:33:34 +08:00
David Nadlinger 778f2cf905 compiler: Fix numpy.full, implement for >1D 2020-08-09 23:46:45 +01:00
David Nadlinger 8e262acd1e compiler: Slight array op implementation cleanup [nfc]
array_unaryop_funcs was never used; since the mangled names
are unique, a single dictionary would be nicer for overrides
anyway.s
2020-08-09 18:58:01 +01:00
David Nadlinger 33d931a5b7 compiler: Implement multi-dimensional indexing of arrays
This generates rather more code than necessary, but has
the advantage of automatically handling incomplete
multi-dimensional subscripts which still leave arrays
behind.
2020-08-09 17:08:43 +01:00
David Nadlinger b00ba5ece1 compiler: Support explicit array(…, dtype=…) syntax 2020-08-09 17:08:43 +01:00
David Nadlinger 5472e830f6 compiler: Assume array()s are always rectangular 2020-08-09 03:54:42 +01:00
David Nadlinger cc00ae9580 compiler: Implement broadcasting of math functions 2020-08-09 03:54:42 +01:00
David Nadlinger be7d78253f compiler: Implement 1D-/2D- array transpose
Left generic transpose (shape order inversion) for now, as that
would be less ugly if we implement forwarding to Python function
bodies for array function implementations.

Needs a runtime test case.
2020-08-09 03:54:42 +01:00
David Nadlinger faea886c44 compiler: Implement array vs. scalar broadcasting 2020-08-09 03:54:42 +01:00
David Nadlinger 56a872ccc0 compiler: Insert array binop shape check in caller for location information 2020-08-09 03:54:42 +01:00
David Nadlinger ef260adca8 compiler: Implement matrix multiplication
LLVM will take care of optimising the loops. This was still
unnecessarily painful; implementing generics and implementing
this in ARTIQ Python looks very attractive right now.
2020-08-09 03:54:42 +01:00
David Nadlinger 0da4a61d99 compiler: Fix method name typo [nfc] 2020-08-09 03:54:42 +01:00
David Nadlinger d37503f21d compiler: T{C -> External}Function, clarify docs [nfc] 2020-08-09 03:54:41 +01:00
David Nadlinger da255bee1b compiler: Implement element type coercion for arrays
So far, this is not exposed to the user beyond implicit conversions.

Note that all the implicit conversions, such as triggered by adding
arrays of mismatching types, or dividing integer arrays, are currently
emitted in a maximally inefficient way, where a temporary copy is first
made for the type conversion. The conversions would more sensibly be
implemented during the per-element operations to save on the extra
copies, but the current behaviour fell out of the rest of the IR
generator structure without extra changes.
2020-08-09 03:54:41 +01:00
David Nadlinger 4426e4144f compiler: Implement unary plus/minus for arrays
Implementation is needlessly generic to anticipate
coercion/transcendental functions.
2020-08-09 03:54:41 +01:00
David Nadlinger 4d002c7934 compiler: Explain use of rpc_tag() in array ops, formatting [nfc] 2020-08-09 03:54:41 +01:00
David Nadlinger 48fb80017f compiler: Implement basic element-wise array operations 2020-08-09 03:54:41 +01:00
David Nadlinger dea3c0c572 compiler: Don't store redundant ndarray buffer length, match list layout
This adds `elt` to _TPointer and the ir.Offset IR instruction,
which is like GetElem but without the final load.
2020-08-09 03:54:41 +01:00
David Nadlinger 38c17622cc compiler: Axis-wise iteration of ndarrays
Matches NumPy. Slicing a TList reallocates, this doesn't; offsetting
couldn't be handled in the IR without introducing new semantics
(the Alloc kludge; could/should be made its own IR type).
2020-08-09 03:54:41 +01:00
David Nadlinger c95a978ab6 compiler: Iteration for 1D ndarrays 2020-08-09 03:54:41 +01:00
David Nadlinger bc17bb4d1a compiler: Parametrize TArray in number of dimensions 2020-08-09 03:54:41 +01:00
David Nadlinger 575be2aeca compiler: Basic support for creation of multidimensional arrays
Breaks all uses of array(), as indexing is not yet implemented.
2020-08-09 03:54:41 +01:00
David Nadlinger cdaf554736 compiler: Implement abs() for scalars
GitHub: Fixes #1303.
2019-04-13 13:39:16 +08:00
David Nadlinger 990e0b7dd9 compiler: Fix comparison of tuples of lists 2019-03-31 17:10:27 +01:00
David Nadlinger baf102dbb2 compiler: Fix comparison of nested lists 2019-03-31 17:10:27 +01:00
Sebastien Bourdeauducq 8caea0e6d3 gateware,runtime: optimize RTIO kernel interface further
* now pinning (TODO: atomicity)
* for inputs, merge request and timeout registers
2018-11-08 18:29:24 +08:00
whitequark 9260cdb2e8 compiler: support conversion of list to bytearray and bytes.
Fixes #1077.
2018-06-21 00:40:45 +00:00
whitequark ce3c8fcd3e compiler: add source location to SSA arguments.
Fixes #1006.
2018-05-22 18:14:14 +00:00
whitequark b4e3c30d8c compiler: desugar x != y into not x == y (fixes #974). 2018-04-20 12:20:45 +00:00
whitequark 355acb5e13 compiler: fix typo in a0a2650f. 2017-12-26 21:55:22 +00:00
whitequark a0a2650fca compiler: do not use invoke for calls to nounwind ffi functions.
Otherwise, declarations such as:

  @syscall(flags={"nounwind", "nowrite"})
  def foo(...):

trip an LLVM assert because the invoke instruction and the !tbaa
metadata are no longer compatible since LLVM 4.0.
2017-12-26 16:24:57 +00:00
Sebastien Bourdeauducq 4387b0be1e clean up rtio_log 2017-11-03 00:52:53 +08:00
whitequark f86744c65c compiler: implement ~ operator (fix #836). 2017-10-01 19:33:18 +00:00
whitequark 62f2693e36 compiler: correct semantics of integer % operator (#830). 2017-10-01 18:32:57 +00:00
whitequark ea7549cfa4 compiler: coerce `while` condition to bool.
Fixes #768.
2017-07-01 18:59:07 +00:00
whitequark 9ed4e9c1cd compiler: add support for printing of bytearray values (#714). 2017-06-09 07:15:25 +00:00
whitequark e9564b15c8 compiler: add support for bytearray type (#714). 2017-06-09 07:15:24 +00:00
whitequark 7b2da5294f compiler: add support for printing of bytes values (#714). 2017-06-09 07:10:48 +00:00
whitequark c5d7445973 compiler: reject reachable implicit return if not returning TNone.
Fixes #718.
2017-04-21 18:11:14 +00:00