Commit Graph

151 Commits

Author SHA1 Message Date
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
David Mak 059d3da58b standalone: Add float64 output tests 2023-09-30 09:31:18 +08:00
David Mak 48c6498d1f core: Fix restoration of loop target in try statement
old_loop_target is only assigned if ctx.loop_target is overwritten,
meaning that if ctx.loop_target is never overwritten, ctx.loop_target
will always be overwritten to None.

We fix this by only restoring from old_loop_target if we previously
assigned to old_loop_target.
2023-09-28 20:00:02 +08:00
David Mak 2a38d5160e meta: Respect opt flags when performing whole-module optimization 2023-09-28 19:58:54 +08:00
David Mak b39831b388 standalone: Update demos
- Add `output_str` for printing a string
- Add demo_test.py to test interop
2023-09-28 19:58:53 +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 ab2360d7a0 core: Remove emit_llvm from CodeGenLLVMOptions
We instead output an LLVM bitcode file when the option is specified on
the command-line.
2023-09-22 17:16:29 +08:00
David Mak 769fd01df8 meta: Allow specifying compiler arguments for check_demos 2023-09-18 11:35:20 +08:00
David Mak f59d45805f standalone: Add command line flags for target properties
For testing codegen for different platforms on the host system.
2023-09-18 11:35:20 +08:00
David Mak 048fcb0a69 core: Switch to LLVM New Pass Manager 2023-09-18 11:35:15 +08:00
David Mak 676d07657a core: Add target field to CodeGenLLVMOptions
For specifying the target machine options when optimizing and linking.

This field is currently unused but will be required in a future
commit.
2023-09-18 09:46:24 +08:00
David Mak eb63f2ad48 meta: Update to Rust Edition 2021 2023-09-15 10:25:50 +08:00
David Mak 008d50995c meta: Update run_demo.sh
- Allow more than one argument to nac3standalone executable
2023-09-12 16:20:50 +08:00
David Mak 474f9050ce standalone: Expose flags in command-line 2023-09-12 16:20:49 +08:00
David Mak 3993a5cf3f core: Add LLVM options to WorkerRegistry 2023-09-12 10:57:05 +08:00
David Mak e4940247f3 standalone: Implement command-line parser using clap
In preparation for adding more command-line options.
2023-09-12 10:08:34 +08:00
David Mak 4481d48709 core: Use C-style for loop logic for iterables
Index increment is now performed at the end of the loop body.
2023-09-06 20:09:38 +08:00
David Mak e0de82993f core: Preserve value of variable shadowed by for loop
Previously, the final value of the target expression would be one after
the last element of the loop, which does not match Python's behavior.

This commit fixes this problem while also preserving the last assigned
value of the loop beyond the loop, matching Python's behavior.
2023-09-06 20:09:36 +08:00
David Mak 17b4686260 standalone: Adapt loop example to output loop variable 2023-09-06 18:56:45 +08:00
David Mak d37287a33d Cargo: Update dependencies 2023-09-04 10:43:57 +08:00
Sebastien Bourdeauducq aead36f0fd update dependencies 2023-03-08 15:19:09 +08:00
Sebastien Bourdeauducq f66ca02b2d update Rust dependencies 2022-08-05 16:58:57 +08:00
z78078 ebd25af38b nac3standalone: allow classes without explicit init (#221)
Reviewed-on: #304
Co-authored-by: z78078 <cc@m-labs.hk>
Co-committed-by: z78078 <cc@m-labs.hk>
2022-07-07 10:36:25 +08:00