David Mak
5182453bd9
meta: Remove redundant path prefixes
2023-12-11 15:16:23 +08:00
David Mak
68b97347b1
core: Infer builtins name list using builtin declaration list
2023-12-08 17:29:34 +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
08a5050f9a
core: Implement non-trivial builtin functions using IRRT
2023-11-06 12:57:23 +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
2e055e8ab1
core: Replace rint implementation with LLVM intrinsic
2023-11-04 13:35:53 +08:00
David Mak
c6b9aefe00
core: Fix int32-to-uint64 conversion
...
This conversion should be sign-extended.
2023-11-03 16:24:26 +08:00
David Mak
8ad09748d0
core: Fix conversion from float to unsigned types
...
These conversions also need to wraparound.
2023-11-03 16:24:26 +08:00
David Mak
7a5a2db842
core: Fix handling of float-to-int32 casts
...
Out-of-bound conversions should be wrapped around.
2023-11-03 16:24:26 +08:00
David Mak
ff1fed112c
core: Rework gamma/gammaln to match SciPy behavior
...
Matches behavior for infinities and NaNs.
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
7cf7634985
core: Add create_fn_by_* functions
...
Used for abstracting the creation of function from different sources.
2023-11-01 18:03:29 +08:00
David Mak
068f0d9faf
core: Do not cast floor/ceil result to int
...
NumPy explicitly states that the return type of the floor/ceil is float.
2023-11-01 18:03:29 +08:00
David Mak
95810d4229
core: Remove {ceil64,floor64,round,round64}
...
These are not present in NumPy or Artiq.
2023-11-01 18:03:29 +08:00
David Mak
60a503a791
core: Allocate more stack variables at the beginning of function
...
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
allocated by different allocas.
2023-10-06 11:42:47 +08:00
David Mak
31dcd2dde9
core: Use i8 for boolean variable allocation
...
In LLVM, i1 represents a 1-byte integer with a single valid bit; The
rest of the 7 upper bits are undefined. This causes problems when
using these variables in memory operations (e.g. memcpy/memmove as
needed by List slicing and assignment).
We fix this by treating all local boolean variables as i8 so that they
are well-defined for memory operations. Function ABIs will continue to
use i1, as memory operations cannot be directly performed on function
arguments or return types, instead they are always converted back into
local boolean variables (which are i8s anyways).
Fixes #315 .
2023-09-25 15:42:07 +08:00
David Mak
6dfc43c8b0
core: Add name to build_gep_and_load
2023-09-22 17:16:29 +08:00
ychenfo
0e0871bc38
nac3core, artiq: to_basic_value_enum takes an argument indicating the expected type
2022-04-10 01:28:22 +08:00
ychenfo
c29cbf6ddd
nac3core: add bound check for list slice
2022-04-05 18:21:46 +08:00
ychenfo
26a4834254
fix warnings
2022-03-26 18:52:08 +08:00
ychenfo
80631fc92b
Option type support ( #224 )
...
Co-authored-by: ychenfo <yc@m-labs.hk>
Co-committed-by: ychenfo <yc@m-labs.hk>
2022-03-26 15:09:15 +08:00
Sebastien Bourdeauducq
0ca2797428
fix compilation warning
2022-03-17 21:31:45 +08:00
pca006132
642e3b2bad
nac3core: moved all builtin errors to nac3artiq code
...
This remove the need for hard-coding those definition IDs.
2022-03-17 00:04:49 +08:00
pca006132
e126fef012
nac3artiq: support more builtin errors
2022-03-16 23:42:08 +08:00
ychenfo
5006028e2d
nac3core: abs builtin function
2022-03-08 23:23:36 +08:00
ychenfo
8241a29908
nac3core: max builtin function
2022-03-08 22:22:00 +08:00
ychenfo
adb5c69e67
nac3core: min builtin function
2022-03-08 21:59:37 +08:00
ychenfo
9f6c7b3359
nac3core: type conversion to/from uint
2022-03-08 13:42:45 +08:00
ychenfo
79c469301a
basic unsigned integer support
2022-03-08 13:34:02 +08:00
ychenfo
8602852241
nac3core: use signed extension to convert i32 to i64
2022-03-06 04:49:02 +08:00
pca006132
323d77a455
nac3artiq: improve error message for out of range error
2022-02-28 23:09:14 +08:00
pca006132
f97f93d92c
applied rustfmt and clippy auto fix
2022-02-21 18:27:46 +08:00
pca006132
d9cb506f6a
nac3core: refactored for better error messages
2022-02-21 18:24:19 +08:00
pca006132
b267a656a8
nac3core: added exception type and fixed primitive representation
...
- Added `Exception` primitive type and some builtin exception types.
Note that all exception types share the same layout, and should
inherit from the base `Exception` type. There are some hacks in the
toplevel module for handling exception types, we should revisit and
fix them later.
- Added new primitive types to concrete type module, otherwise there
would be some weird type errors.
- Changed the representation of strings to CSlice<u8>, instead of
CString.
2022-02-12 22:13:59 +08:00
pca006132
050c862c1a
nac3core: function codegen callback changes
...
Added code generator argument to the callback, so it would be easier to
write complicated codegen with that callback. To prepare for RPC
codegen.
2022-02-12 21:24:41 +08:00
ychenfo
4976e89ae2
nac3core: list slice support
2022-01-13 16:53:32 +08:00
pca006132
1bd966965e
fixed M-Labs/nac3#146
2021-12-27 22:56:50 +08:00
Sebastien Bourdeauducq
9e3f75255e
update inkwell. Closes #67
2021-12-25 22:17:06 +08:00
Sebastien Bourdeauducq
e2b44a066b
return int32 in len(). Closes #141
2021-12-20 17:44:42 +08:00
ychenfo
b5637a04e9
nac3core: use official implementation for len
2021-12-13 10:44:33 +08:00
ychenfo
2c6601d97c
nac3core: fix len on range with step of different sign
2021-12-13 10:44:33 +08:00
ychenfo
82359b81a2
nac3core: fix bool to int conversion
2021-12-13 04:13:43 +08:00
ychenfo
b7892ce952
nac3core: add len support for list and range
2021-12-09 01:37:00 +08:00
Sebastien Bourdeauducq
1c31aa6e8e
consistent naming
2021-12-02 10:45:46 +08:00
ychenfo
aa2d79fea6
Merge branch 'master' into built_in_floor_ceil
2021-12-02 01:08:55 +08:00
ychenfo
fa2fe8ed5d
nac3core: add ceil and floor
2021-12-01 03:23:58 +08:00
ychenfo
7ede4f15b6
nac3core: move builtin definitions to another file
2021-12-01 02:52:00 +08:00