Skip to content

Commit 1c32571

Browse files
committed
Remove ncc, update docs to point to uvclang
1 parent 1f273e0 commit 1c32571

108 files changed

Lines changed: 168 additions & 16197 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,6 @@ jobs:
3333
working-directory: ./vm
3434
run: RUST_BACKTRACE=1 cargo test
3535

36-
- name: Test NCC
37-
working-directory: ./ncc
38-
run: |
39-
pwd
40-
ls -al
41-
RUST_BACKTRACE=1 cargo test
42-
43-
- name: Test NCC command-line arguments
44-
working-directory: ./ncc
45-
run: |
46-
cargo run examples/chess.c
47-
cargo run -- -o output_file.asm examples/chess.c
48-
cargo run -- -E examples/crc32.c > /dev/null
49-
cargo run -- -DTEST tests/test_macro.c
50-
5136
- name: Test uvclang
5237
working-directory: ./uvclang
5338
run: RUST_BACKTRACE=1 cargo test

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,43 +106,44 @@ To run an [asm file](vm/examples) with UVM:
106106
cargo run examples/fizzbuzz.asm
107107
```
108108

109-
There is also a toy C compiler in the `ncc` directory, along with many [example C programs](ncc/examples) that run on UVM:
109+
There is also a C compiler, [uvclang](uvclang/README.md), in the `uvclang` directory, along with many [example C programs](uvclang/examples) that run on UVM:
110110
```sh
111-
cd ncc
111+
cd uvclang
112112
./build_and_run.sh examples/snake.c
113113
```
114+
uvclang uses clang as a front end, so it needs a working clang/LLVM installation. See the [uvclang README](uvclang/README.md) for details.
114115

115116
### Running the Test Suite
116117

117-
Run `cargo test` from the `vm`, and `ncc` directories.
118+
Run `cargo test` from the `vm` and `uvclang` directories. uvclang also has shell-based end-to-end test harnesses; see the [uvclang README](uvclang/README.md).
118119

119120
## Codebase Organization
120121

121122
The repository is organized into a 3 different subprojects, each of which is a Rust codebase which can be compiled with `cargo`:
122123

123124
- `/vm` : The implementation of the UVM virtual machine itself
124125
- [`/vm/examples/*`](vm/examples): Example assembly programs that can be run by UVM
125-
- `/ncc`: An implementation of a toy C compiler that outputs UVM assembly
126-
- [`/ncc/README.md`](ncc/README.md): documentation for the NCC compiler.
127-
- [`/ncc/examples/*`](ncc/examples): Example C source files that can be compiled by NCC
126+
- `/uvclang`: A C/C++ compiler that outputs UVM assembly, using clang as a front end
127+
- [`/uvclang/README.md`](uvclang/README.md): documentation for the uvclang compiler
128+
- [`/uvclang/examples/*`](uvclang/examples): Example C source files that can be compiled by uvclang
128129
- `/spec`: A system to document and automatically export bindings for UVM system calls and constants.
129130
- `/spec/syscalls.json`: Declarative list of system calls exposed by UVM.
130131
- `/docs`: Markdown documentation for UVM
131132
- [`/docs/syscalls.md`](docs/syscalls.md): List of system calls and constants accessible to UVM programs
132133

133-
The `ncc` compiler is, at the time of this writing, incomplete in that it lacks some C features and the error messages need improvement. This compiler
134-
was implemented to serve as an example of how to write a compiler that targets UVM, and to write some library code to be used by other programs. Over
135-
time, the `ncc` compiler will be improved. Despite its limitations, it is still usable to write small programs. Contributions to it are welcome.
134+
The `uvclang` compiler drives clang to lower C/C++ to LLVM IR and then compiles that IR to UVM assembly. Because clang handles parsing, it supports the
135+
full C/C++ language; the work in progress is in the LLVM IR to UVM back end, which does not yet cover every construct clang can emit. It is already usable
136+
to write real programs, and ships with a set of UVM bindings and standard-library headers. Contributions are welcome.
136137

137138
The `spec` directory contains JSON files that represent a declarative list of system calls, constants and the permission system that UVM exposes
138139
to programs running on it. This is helpful for documentation purposes, or if you want to build a compiler that targets UVM. The directory also contains
139-
code that automatically generates [markdown documentation](docs/syscalls.md), Rust constants and [C definitions](ncc/include/uvm/syscalls.h) for system calls.
140+
code that automatically generates [markdown documentation](docs/syscalls.md), Rust constants and [C definitions](uvclang/include/uvm/syscalls.h) for system calls.
140141

141142
## Open Source License
142143

143-
The code for UVM, NCC and associated tools is shared under the [Apache-2.0 license](https://github.com/maximecb/uvm/blob/main/LICENSE).
144+
The code for UVM, uvclang and associated tools is shared under the [Apache-2.0 license](https://github.com/maximecb/uvm/blob/main/LICENSE).
144145

145-
The examples under the `vm/examples` and `ncc/examples` directories are shared under the [Creative Commons CC0](https://creativecommons.org/publicdomain/zero/1.0/) license.
146+
The examples under the `vm/examples` and `uvclang/examples` directories are shared under the [Creative Commons CC0](https://creativecommons.org/publicdomain/zero/1.0/) license.
146147

147148
## Contributing
148149

docs/design.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ These files can be written by hand, or generated by a compiler.
2424
The syntax is inspired by yasm/nasm and designed to be easy to read, and you can find some simple
2525
examples under [vm/examples](/vm/examples). The assembler supports both Python-style single-line
2626
comments and C-style multiline comments for convenience.
27-
This repo also contains a toy C compiler (ncc) that emits
27+
This repo also contains a C compiler ([uvclang](/uvclang/README.md)) that emits
2828
UVM asm files as its output.
2929

3030
There is a plan for UVM to eventually support a binary image format to store programs as well, but
@@ -85,9 +85,9 @@ calls you for the next event. UVM has different opcodes, `ret` and `exit`, such
8585
return to the external event loop without terminating execution, whereas `exit` means the program
8686
is completely done running and wants to stop.
8787

88-
In the case of C programs compiled with `ncc`, the `main()` function can act as an initialization
88+
In the case of C programs compiled with `uvclang`, the `main()` function can act as an initialization
8989
function, register callbacks and return to the VM without exiting. To get a better idea of how this
90-
works, you can look at the [paint example](/ncc/examples/paint.c) program.
90+
works, you can look at the [paint example](/uvclang/examples/paint.c) program.
9191

9292
## Design Goals
9393

docs/planning.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ because it's easier to refactor, which allows us to quickly make design changes.
1313

1414
## C Compiler Development
1515

16-
This repository includes [ncc](/ncc/README.md), which is a toy C compiler that targets UVM.
17-
This compiler is currently incomplete, but still able to compile useful code.
18-
Eventually, we're probably going to want to have an LLVM backend targeting UVM,
19-
but it seems useful to have a small compiler that people can easily wrap their
20-
head around so that they can understand how they could build their own.
21-
The plan is to put some amount of development effort into ncc to smooth out
22-
the rough edges, improve error messages and get it to the point where it
23-
supports most C features.
16+
This repository includes [uvclang](/uvclang/README.md), a C/C++ compiler that
17+
targets UVM. It uses clang as a front end to lower C/C++ to LLVM IR, then
18+
compiles that IR down to UVM assembly. Because clang does the parsing, uvclang
19+
gets full C/C++ language coverage for free; the ongoing work is in the LLVM IR
20+
to UVM back end, which does not yet support every construct clang can emit.
2421

2522
## Binary Image Format
2623

ncc/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

ncc/Cargo.lock

Lines changed: 0 additions & 7 deletions
This file was deleted.

ncc/Cargo.toml

Lines changed: 0 additions & 14 deletions
This file was deleted.

ncc/README.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

ncc/build_and_run.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

ncc/count_insns.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)