New ARTIQ compiler, third iteration
Go to file
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
nac3artiq core: Minor formatting cleanup 2023-12-15 17:46:44 +08:00
nac3ast ast: Add Ord implementation to Location 2023-12-12 15:41:59 +08:00
nac3core core: Do not keep unification result for function arguments 2023-12-16 18:40:48 +08:00
nac3ld meta: Apply clippy suggested changes 2023-12-11 15:16:23 +08:00
nac3parser meta: Remove redundant path prefixes 2023-12-11 15:16:23 +08:00
nac3standalone core: Do not keep unification result for function arguments 2023-12-16 18:40:48 +08:00
nix pin down LLVM used for IRRT 2023-11-25 20:15:29 +08:00
runkernel meta: Update to Rust Edition 2021 2023-09-15 10:25:50 +08:00
.gitignore gitignore: fix msys2 path 2023-11-24 17:18:17 +08:00
Cargo.lock core: Refactor to return errors by HashSet 2023-12-12 15:41:59 +08:00
Cargo.toml meta: Update to Rust Edition 2021 2023-09-15 10:25:50 +08:00
README.md windows: switch to CLANG64 MSYS2 2023-11-24 18:10:00 +08:00
flake.lock switch to new nixpkgs release 2023-12-03 10:31:05 +08:00
flake.nix update ARTIQ version used for PGO profiling 2023-12-12 15:57:48 +08:00
nac3.svg add icon 2022-04-18 15:07:53 +08:00
rustfmt.toml move rustfmt.toml upper 2022-01-09 11:31:06 +08:00

README.md

icon

NAC3

NAC3 is a major, backward-incompatible rewrite of the compiler for the ARTIQ physics experiment control and data acquisition system. It features greatly improved compilation speeds, a much better type system, and more predictable and transparent operation.

NAC3 has a modular design and its applicability reaches beyond ARTIQ. The nac3core module does not contain anything specific to ARTIQ, and can be used in any project that requires compiling Python to machine code.

WARNING: NAC3 is currently experimental software and several important features are not implemented yet.

Packaging

NAC3 is packaged using the Nix Flakes system. Install Nix 2.8+ and enable flakes by adding experimental-features = nix-command flakes to nix.conf (e.g. ~/.config/nix/nix.conf).

Try NAC3

Linux

After setting up Nix as above, use nix shell git+https://github.com/m-labs/artiq.git?ref=nac3 to get a shell with the NAC3 version of ARTIQ. See the examples directory in ARTIQ (nac3 Git branch) for some samples of NAC3 kernel code.

Windows

Install MSYS2, and open "MSYS2 CLANG64". Edit /etc/pacman.conf to add:

[artiq]
SigLevel = Optional TrustAll
Server = https://msys2.m-labs.hk/artiq-nac3

Then run the following commands:

pacman -Syu
pacman -S mingw-w64-clang-x86_64-artiq

For developers

This repository contains:

  • nac3ast: Python abstract syntax tree definition (based on RustPython).
  • nac3parser: Python parser (based on RustPython).
  • nac3core: Core compiler library, containing type-checking and code generation.
  • nac3standalone: Standalone compiler tool (core language only).
  • nac3ld: Minimalist RISC-V and ARM linker.
  • nac3artiq: Integration with ARTIQ and implementation of ARTIQ-specific extensions to the core language.
  • runkernel: Simple program that runs compiled ARTIQ kernels on the host and displays RTIO operations. Useful for testing without hardware.

Use nix develop in this repository to enter a development shell. If you are using a different shell than bash you can use e.g. nix develop --command fish.

Build NAC3 with cargo build --release. See the demonstrations in nac3artiq and nac3standalone.