1
0
forked from M-Labs/nac3
Commit Graph

172 Commits

Author SHA1 Message Date
bd792904f9 core: Add size_t to primitive store
Used for ndims in ndarray.
2023-12-21 15:20:31 +08:00
f01d833d48 standalone: Add missing parenthesis 2023-12-20 15:15:47 +08:00
6dccb343bb Revert "core: Do not keep unification result for function arguments"
This reverts commit f09f3c27a5.
2023-12-18 10:01:23 +08:00
d47534e2ad interpret_demo: add typing.Literal 2023-12-18 08:50:49 +08:00
8886964776 core: Remove redundant argument in type annotation parsing 2023-12-16 18:40:48 +08:00
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
457d3b6cd7 core: Refactor generic constants to Literal
Better matches the syntax of `typing.Literal`.
2023-12-16 18:40:48 +08:00
c7735d935b standalone: Output id of undefined identifier 2023-12-16 18:40:48 +08:00
a19f1065e3 meta: Refactor to use more let-else bindings 2023-12-12 16:31:14 +08:00
32746c37be core: Refactor to return errors by HashSet 2023-12-12 15:41:59 +08:00
ddfb532b80 standalone: Apply clippy pedantic changes 2023-12-11 15:16:23 +08:00
02933753ca core: Apply clippy pedantic changes 2023-12-11 15:16:23 +08:00
d304afd333 meta: Apply clippy suggested changes 2023-12-11 15:16:23 +08:00
031e660f18 core: Initial implementation for const generics 2023-12-08 18:02:11 +08:00
68b97347b1 core: Infer builtins name list using builtin declaration list 2023-12-08 17:29:34 +08:00
adadf56e2b nac3standalone: generate PIC 2023-12-04 19:09:50 +08:00
98199768e3 demo: fix 64-bit format strings 2023-12-04 18:51:06 +08:00
120f8da5c7 fix compilation warnings 2023-11-26 09:09:24 +08:00
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
0af1e37e99 core: Prefix all NumPy/SciPy functions with np_/sp_spec 2023-11-23 13:35:23 +08:00
d322c91697 core: Change bitshift operators to accept int32/uint32 for RHS operand 2023-11-09 12:16:20 +08:00
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
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
9d737743c1 standalone: Add regression test for numeric primitive operations 2023-11-03 16:24:26 +08:00
447eb9c387 standalone: Fix output format string for output_uint* 2023-11-03 16:24:26 +08:00
7e4dab15ae standalone: Add math tests for non-number arguments 2023-11-01 18:03:29 +08:00
2b635a0b97 core: Implement numpy and scipy functions 2023-11-01 18:03:29 +08:00
60ad100fbb core: Implement and expose {isinf,isnan} 2023-11-01 18:03:29 +08:00
630897b779 standalone: Do not output sign if float is NaN
Matches behavior in Python.
2023-11-01 18:03:29 +08:00
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
bb27e3d400 standalone: Fix indentation of demo.c 2023-11-01 13:20:26 +08:00
bb5147521f standalone: Fix indentation of test files 2023-11-01 13:20:26 +08:00
7fc2a30c14 Force single-threaded compilation if LLVM is not thread-safe 2023-10-16 15:55:10 +08:00
950f431483 standalone: Update help text for --emit-llvm 2023-10-16 15:52:51 +08:00
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
48eb64403f standalone: Treat -T0 as using all available threads 2023-10-13 14:57:16 +08:00
2c44b58bb8 standalone: Require use of -T for specifying thread count 2023-10-13 14:36:34 +08:00
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
c5629d4eb5 standalone: Remove redundant const in demo library 2023-10-06 10:32:58 +08:00
a79286113e standalone: Add output_bool in demo library 2023-10-06 10:19:22 +08:00
f34c6053d6 standalone: Add flags to control demo output options 2023-10-04 18:11:44 +08:00
e8a5f0dfef standalone: Fix parsing NAC3 args in check_demo.sh 2023-10-04 18:03:28 +08:00
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
2a775d822e core: Demote dead code into a stdout warning 2023-10-04 18:03:25 +08:00
1659c3e724 standalone: Remove temporary logfiles after execution 2023-09-30 09:31:18 +08:00
f53cb804ec standalone: Add execution of test cases via lli 2023-09-30 09:31:18 +08:00
279376a373 standalone: Emit IRRT IR 2023-09-30 09:31:18 +08:00
b6afd1bfda standalone: Split check_demos into check_demo
Allows individual tests to be executed.
2023-09-30 09:31:18 +08:00
be3e8f50a2 standalone: Refactor demo library to C
Needed for use by lli.
2023-09-30 09:31:18 +08:00
059d3da58b standalone: Add float64 output tests 2023-09-30 09:31:18 +08:00