gen/
.clang-format
570 B
.gitignore
30 B
.gitsigners
112 B
LICENSE
1.1 KiB
Makefile
911 B
README
1.8 KiB
ast.c
5.0 KiB
ast.h
15.1 KiB
desugar.c
23.1 KiB
desugar.h
286 B
gen.c
108.5 KiB
gen.h
4.9 KiB
io.c
1.1 KiB
io.h
444 B
limits.h
1.3 KiB
module.c
10.0 KiB
module.h
2.2 KiB
options.c
1.4 KiB
options.h
472 B
parser.c
68.3 KiB
parser.h
942 B
radiance.c
3.7 KiB
ralloc.c
2.0 KiB
ralloc.h
1.1 KiB
resolver.c
109.7 KiB
resolver.h
5.6 KiB
riscv.c
12.0 KiB
riscv.h
12.0 KiB
scanner.c
10.2 KiB
scanner.h
3.2 KiB
strings.c
2.6 KiB
strings.h
407 B
symtab.c
5.7 KiB
symtab.h
4.6 KiB
types.h
1.0 KiB
util.h
1.5 KiB
README
raw
| 1 | |
| 2 | RADIANCE BOOTSTRAPPING COMPILER |
| 3 | |
| 4 | Bootstrap compiler for the Radiance programming language, written in C99. |
| 5 | |
| 6 | This is the Stage 0 compiler used to bootstrap Radiance from scratch. It |
| 7 | compiles Radiance source code to RISC-V machine code. Once built, it can be |
| 8 | used to compile the self-hosted Radiance compiler, which then recompiles |
| 9 | itself until a fixed point is reached. |
| 10 | |
| 11 | BUILDING |
| 12 | |
| 13 | Requirements: |
| 14 | |
| 15 | * clang (or another C99 compiler) |
| 16 | * lld (the LLVM linker) |
| 17 | |
| 18 | To build the compiler: |
| 19 | |
| 20 | make |
| 21 | |
| 22 | This produces `bin/radiance.s0`, the Stage 0 compiler binary. |
| 23 | You can specify a different C compiler with: |
| 24 | |
| 25 | make CC=gcc |
| 26 | |
| 27 | USAGE |
| 28 | |
| 29 | bin/radiance.s0 [options] <input.rad> |
| 30 | |
| 31 | Options: |
| 32 | |
| 33 | -o <path> Output file path (required) |
| 34 | -mod <path> Register an additional module |
| 35 | |
| 36 | COMPILER PIPELINE |
| 37 | |
| 38 | The compiler is structured as a series of passes: |
| 39 | |
| 40 | Scanner (scanner.c) Tokenizes source text |
| 41 | Parser (parser.c) Builds an AST from tokens |
| 42 | Desugar (desugar.c) Syntactic transformations on the AST |
| 43 | Resolver (resolver.c) Name resolution and type checking |
| 44 | Gen (gen.c) Code generation targeting RISC-V 64-bit |
| 45 | RISC-V (riscv.c) Instruction encoding |
| 46 | |
| 47 | Supporting modules: |
| 48 | |
| 49 | ast.c AST node definitions and utilities |
| 50 | module.c Module loading and management |
| 51 | symtab.c Symbol table |
| 52 | strings.c Interned string table |
| 53 | ralloc.c Region-based memory allocator |
| 54 | io.c File I/O helpers |
| 55 | options.c Command line option parsing |
| 56 | gen/emit.c Binary emission |
| 57 | gen/data.c Read-only and read-write data sections |
| 58 | |
| 59 | FORMATTING |
| 60 | |
| 61 | To format source files before committing, run `make fmt`. |
| 62 | |
| 63 | LICENSE |
| 64 | |
| 65 | Licensed under the MIT License, |
| 66 | Copyright (c) 2025-2026 Radiant Computer (https://radiant.computer) |