lyken
44487b76ae
standalone: interpret_demo.py remove duplicated section
2024-07-22 17:23:35 +08:00
lyken
1332f113e8
standalone: fix interpret_demo.py comments
2024-07-22 17:06:14 +08:00
David Mak
4948395ca2
core/toplevel/type_annotation: Add handling for mismatching class def
...
Primitive types only contain fields in its Type and not its TopLevelDef.
This causes primitive object types to lack some fields.
2024-07-19 14:42:14 +08:00
lyken
1a31a50b8a
standalone: fix __nac3_raise def in demo.c
2024-07-17 21:22:08 +08:00
Sebastien Bourdeauducq
c80378063a
add np_argmin/argmax to interpret_demo environment
2024-07-12 13:27:52 +02:00
abdul124
45e9360c4d
standalone: Add np_argmax and np_argmin tests
2024-07-12 18:19:56 +08:00
David Mak
f47cdec650
standalone: Fix output format of output_range
2024-07-09 13:55:48 +08:00
David Mak
d656880e44
standalone: Fix missing implementation for output_range
2024-07-09 13:53:50 +08:00
David Mak
25d2de67f7
standalone: Add output_range and tests
2024-07-09 04:44:40 +08:00
David Mak
9238a5e86e
standalone: Rename output_str to output_strln and add output_str
...
output_str is for outputting strings without newline, and the newly
introduced output_strln now has the old behavior of ending with a
newline.
2024-07-09 04:44:40 +08:00
David Mak
ba32fab374
standalone: Add demos for list arithmetic operators
2024-07-04 16:01:15 +08:00
abdul124
83154ef8e1
core/llvm_intrinsics: remove llvm.roundeven call from call_float_roundeven
2024-07-03 14:17:47 +08:00
lyken
5b11a1dbdd
core: support tuple and int32 input for np_empty, np_ones, and more
2024-06-27 14:30:17 +08:00
lyken
ca8459dc7b
standalone: prettify TopLevelComposer error reporting
2024-06-27 10:15:14 +08:00
David Mak
5bade81ddb
standalone: Add test for multidim array index with one index
2024-06-20 12:50:30 +08:00
David Mak
07adfb2a18
standalone: Add *.ll to Gitignore list
2024-06-19 18:56:15 +08:00
Sébastien Bourdeauducq
f00e458f60
add test for class without __init__
2024-06-19 18:16:54 +08:00
lyken
f026b48e2a
core: refactor to use `TypeVarId` and `TypeVar`
2024-06-13 16:59:10 +08:00
lyken
95de0800b4
core/demo: fix typo in .gitignore
2024-06-13 16:05:33 +08:00
lyken
3d71c6a850
core/demo: gitignore to ignore *.bc & *.o
2024-06-13 16:00:23 +08:00
David Mak
23974feae7
meta: Restrict number of allowed lints
2024-06-12 16:10:57 +08:00
David Mak
40a3bded36
meta: Set clippy lints in {main,lib}.rs
...
So that this does not have to be manually passed to the `cargo clippy`
command-line every single time. Also allows incrementally addressing
these lints by removing and fixing them one-by-one.
2024-06-12 16:10:57 +08:00
lyken
8168692cc3
apply cargo fmt
2024-06-12 14:45:03 +08:00
David Mak
53d44b9595
standalone: Add np_array tests
2024-06-11 16:44:36 +08:00
David Mak
23b2fee4e7
standalone: Add test case for ndarray slicing
2024-06-03 16:40:05 +08:00
David Mak
520e1adc56
core/builtins: Add np_minimum/np_maximum
2024-05-09 15:01:20 +08:00
David Mak
73e81259f3
core/builtins: Add np_min/np_max
2024-05-09 15:01:20 +08:00
David Mak
30c6cffbad
core/builtins: Refactored numpy builtins to accept scalar and ndarrays
2024-05-06 15:38:29 +08:00
David Mak
9566047241
standalone: Fix cbrt never tested
2024-05-06 13:21:54 +08:00
David Mak
c4dc36ae99
standalone: Add explicit `--` for delimiting run args vs NAC3 args
2024-05-06 13:21:54 +08:00
David Mak
847615fc2f
core: Implement numpy.matmul for 2D-2D ndarrays
2024-04-23 10:27:37 +08:00
David Mak
e0f440040c
core/expr: Implement negative indices for ndarray
2024-04-15 12:49:42 +08:00
David Mak
52c731c312
core: Implement Not/UAdd/USub for booleans
...
Not sure if this is deliberate or an oversight, but we implement it
anyway for consistency with other Python implementations.
2024-04-12 18:29:58 +08:00
David Mak
00d1b9be9b
core: Fix __inv__ for i8-based boolean operands
2024-04-12 15:35:54 +08:00
David Mak
a920fe0501
core: Implement elementwise comparison operators
2024-04-03 00:07:33 +08:00
David Mak
727a1886b3
core: Implement elementwise unary operators
2024-04-03 00:07:33 +08:00
David Mak
6af13a8261
core: Implement elementwise binary operators
...
Including immediate variants of these operators.
2024-04-03 00:07:33 +08:00
David Mak
fd44ee6887
core: Apply clippy suggestions
2024-03-22 15:07:23 +08:00
David Mak
2edc1de0b6
standalone: Update ndarray.py to output all elements in ndarrays
2024-03-07 14:59:13 +08:00
David Mak
96b7f29679
core: Implement `ndarray.fill`
2024-03-07 14:59:13 +08:00
David Mak
77de24ef74
core: Use BTreeMap for type variable mapping
...
There have been multiple instances where I had the need to iterate over
type variables, only to discover that the traversal order is arbitrary.
This commit fixes that by adding SortedMapping, which utilizes BTreeMap
internally to guarantee a traversal order. All instances of VarMap are
now refactored to use this to ensure that type variables are iterated in
the order of its variable ID, which should be monotonically incremented
by the unifier.
2024-03-04 23:56:04 +08:00
David Mak
8492503af2
core: Update cargo dependencies
2024-02-23 15:41:04 +08:00
David Mak
22e831cb76
core: Add test for indexing into ndarray
2024-02-19 17:13:10 +08:00
David Mak
5cecb2bb74
core: Fix Literal use in variable type annotation
2024-02-06 18:16:14 +08:00
David Mak
fef4b2a5ce
standalone: Disable tests requiring return of non-primitive values
2024-01-29 12:49:50 +08:00
David Mak
af95ba5012
standalone: Add debug flag to run_demo.sh
...
Allows running demos using the debug build instead of the (default)
release build.
2024-01-25 15:50:53 +08:00
David Mak
9c9756be33
standalone: Use size_t in demo.c
2024-01-25 15:50:53 +08:00
David Mak
c679474f5c
standalone: Fix redefinition of ndarray consumer functions
2024-01-17 09:38:13 +08:00
Sébastien Bourdeauducq
ab3fa05996
demo: use portable format strings
2024-01-10 18:35:35 +08:00
David Mak
140f8f8a08
core: Implement most ndarray-creation functions
2023-12-22 16:29:55 +08:00
David Mak
27fcf8926e
core: Implement ndarray constructor and numpy.empty
2023-12-22 16:29:54 +08:00
David Mak
bd792904f9
core: Add size_t to primitive store
...
Used for ndims in ndarray.
2023-12-21 15:20:31 +08:00
David Mak
f01d833d48
standalone: Add missing parenthesis
2023-12-20 15:15:47 +08:00
David Mak
6dccb343bb
Revert "core: Do not keep unification result for function arguments"
...
This reverts commit f09f3c27a5
.
2023-12-18 10:01:23 +08:00
Sebastien Bourdeauducq
d47534e2ad
interpret_demo: add typing.Literal
2023-12-18 08:50:49 +08:00
David Mak
8886964776
core: Remove redundant argument in type annotation parsing
2023-12-16 18:40:48 +08:00
David Mak
f09f3c27a5
core: Do not keep unification result for function arguments
...
For some reason, when unifying a function call parameter with an
argument, subsequent calls to the same function will only accept the
type of the substituted argument.
This affect snippets like:
```
def make1() -> C[Literal[1]]:
return ...
def make2() -> C[Literal[2]]:
return ...
def consume(instance: C[Literal[1, 2]]):
pass
consume(make1())
consume(make2())
```
The last statement will result in a compiler error, as the parameter of
consume is replaced with C[Literal[1]].
We fix this by getting a snapshot before performing unification, and
restoring the snapshot after unification succeeds.
2023-12-16 18:40:48 +08:00
David Mak
457d3b6cd7
core: Refactor generic constants to `Literal`
...
Better matches the syntax of `typing.Literal`.
2023-12-16 18:40:48 +08:00
David Mak
c7735d935b
standalone: Output id of undefined identifier
2023-12-16 18:40:48 +08:00
David Mak
a19f1065e3
meta: Refactor to use more let-else bindings
2023-12-12 16:31:14 +08:00
David Mak
32746c37be
core: Refactor to return errors by HashSet
2023-12-12 15:41:59 +08:00
David Mak
ddfb532b80
standalone: Apply clippy pedantic changes
2023-12-11 15:16:23 +08:00
David Mak
02933753ca
core: Apply clippy pedantic changes
2023-12-11 15:16:23 +08:00
David Mak
d304afd333
meta: Apply clippy suggested changes
2023-12-11 15:16:23 +08:00
David Mak
031e660f18
core: Initial implementation for const generics
2023-12-08 18:02:11 +08:00
David Mak
68b97347b1
core: Infer builtins name list using builtin declaration list
2023-12-08 17:29:34 +08:00
Sebastien Bourdeauducq
adadf56e2b
nac3standalone: generate PIC
2023-12-04 19:09:50 +08:00
Sebastien Bourdeauducq
98199768e3
demo: fix 64-bit format strings
2023-12-04 18:51:06 +08:00
Sebastien Bourdeauducq
120f8da5c7
fix compilation warnings
2023-11-26 09:09:24 +08:00
David Mak
5c5620692f
core: Add np_{round,floor,ceil}
...
These functions are NumPy variants of round/floor/ceil, which returns
floats instead of ints.
2023-11-23 13:45:07 +08:00
David Mak
0af1e37e99
core: Prefix all NumPy/SciPy functions with np_/sp_spec
2023-11-23 13:35:23 +08:00
David Mak
d322c91697
core: Change bitshift operators to accept int32/uint32 for RHS operand
2023-11-09 12:16:20 +08:00
David Mak
fd787ca3f5
core: Remove trunc
...
The behavior of trunc is already implemented by casts and is therefore
redundant.
2023-11-04 13:35:53 +08:00
David Mak
4dbe07a0c0
core: Revert breaking changes to round-family functions
...
These functions should return ints as the math.* functions do instead of
following the convention of numpy.* functions.
2023-11-04 13:35:53 +08:00
David Mak
9d737743c1
standalone: Add regression test for numeric primitive operations
2023-11-03 16:24:26 +08:00
David Mak
447eb9c387
standalone: Fix output format string for output_uint*
2023-11-03 16:24:26 +08:00
David Mak
7e4dab15ae
standalone: Add math tests for non-number arguments
2023-11-01 18:03:29 +08:00
David Mak
2b635a0b97
core: Implement numpy and scipy functions
2023-11-01 18:03:29 +08:00
David Mak
60ad100fbb
core: Implement and expose {isinf,isnan}
2023-11-01 18:03:29 +08:00
David Mak
630897b779
standalone: Do not output sign if float is NaN
...
Matches behavior in Python.
2023-11-01 18:03:29 +08:00
David Mak
e95586f61e
core: Fix IR generation of `for` loop containing break/continue
...
Fix cases where the body BB would have two terminators because of a
preceding continue/break statement already emitting a terminator.
2023-11-01 13:21:27 +08:00
David Mak
bb27e3d400
standalone: Fix indentation of demo.c
2023-11-01 13:20:26 +08:00
David Mak
bb5147521f
standalone: Fix indentation of test files
2023-11-01 13:20:26 +08:00
David Mak
7fc2a30c14
Force single-threaded compilation if LLVM is not thread-safe
2023-10-16 15:55:10 +08:00
David Mak
950f431483
standalone: Update help text for `--emit-llvm`
2023-10-16 15:52:51 +08:00
David Mak
a50c690428
standalone: Fix run_demo script
...
- Link main and module*.bc together if using multiple threads
- Fix temporary files not being deleted
2023-10-16 15:52:48 +08:00
David Mak
48eb64403f
standalone: Treat -T0 as using all available threads
2023-10-13 14:57:16 +08:00
David Mak
2c44b58bb8
standalone: Require use of `-T` for specifying thread count
2023-10-13 14:36:34 +08:00
David Mak
c7de22287e
core: Fix restoration of stack address
...
All allocas for temporary objects are now placed in the beginning of the
function. Allocas for on-temporary objects are not modified because
these variables may appear in a loop and thus must be uniquely
represented.
2023-10-06 11:34:23 +08:00
David Mak
c5629d4eb5
standalone: Remove redundant const in demo library
2023-10-06 10:32:58 +08:00
David Mak
a79286113e
standalone: Add output_bool in demo library
2023-10-06 10:19:22 +08:00
David Mak
f34c6053d6
standalone: Add flags to control demo output options
2023-10-04 18:11:44 +08:00
David Mak
e8a5f0dfef
standalone: Fix parsing NAC3 args in check_demo.sh
2023-10-04 18:03:28 +08:00
David Mak
7140901261
standalone: Fix missing libraries when linking
...
Fixes `undefined reference to 'pow'` for pow.py using -O0.
2023-10-04 18:03:28 +08:00
David Mak
2a775d822e
core: Demote dead code into a stdout warning
2023-10-04 18:03:25 +08:00
David Mak
1659c3e724
standalone: Remove temporary logfiles after execution
2023-09-30 09:31:18 +08:00
David Mak
f53cb804ec
standalone: Add execution of test cases via lli
2023-09-30 09:31:18 +08:00
David Mak
279376a373
standalone: Emit IRRT IR
2023-09-30 09:31:18 +08:00
David Mak
b6afd1bfda
standalone: Split check_demos into check_demo
...
Allows individual tests to be executed.
2023-09-30 09:31:18 +08:00
David Mak
be3e8f50a2
standalone: Refactor demo library to C
...
Needed for use by lli.
2023-09-30 09:31:18 +08:00