compiler/
lib/
scripts/
seed/
test/
vim/
.gitignore
353 B
.gitsigners
112 B
LICENSE
1.1 KiB
Makefile
3.1 KiB
README
2.5 KiB
std.lib
987 B
std.lib.test
252 B
Makefile
raw
| 1 | # Radiance build file. |
| 2 | |
| 3 | # Core standard library modules. |
| 4 | STD := -pkg std $(patsubst %,-mod %,$(shell cat std.lib)) |
| 5 | |
| 6 | # Full standard library with test modules. |
| 7 | STD_TEST := $(STD) $(patsubst %,-mod %,$(shell cat std.lib.test)) |
| 8 | |
| 9 | # Source files. |
| 10 | STD_LIB := $(shell find lib -name '*.rad') |
| 11 | RAD_BIN := bin/radiance.rv64.dev |
| 12 | |
| 13 | # Emulator command used to invoke the self-hosted compiler. |
| 14 | EMU := $(or $(RAD_EMULATOR),emulator) |
| 15 | EMU_FLAGS := -memory-size=385024 \ |
| 16 | -data-size=348160 \ |
| 17 | -stack-size=512 \ |
| 18 | -count-instructions |
| 19 | RADIANCE := $(EMU) $(EMU_FLAGS) -run $(RAD_BIN) |
| 20 | |
| 21 | # Verify the emulator binary exists. |
| 22 | EMU_PATH := $(shell command -v $(EMU) 2>/dev/null) |
| 23 | |
| 24 | default: emulator $(RAD_BIN) |
| 25 | test: emulator std-test lower-test asm-test |
| 26 | |
| 27 | # Emulator command check |
| 28 | |
| 29 | emulator: |
| 30 | ifeq ($(EMU_PATH),) |
| 31 | $(error Emulator not found. Install it or set RAD_EMULATOR to its path) |
| 32 | endif |
| 33 | |
| 34 | # Compiler build |
| 35 | |
| 36 | SEED := seed/radiance.rv64 |
| 37 | SEED_OPTS := $(STD) -pkg radiance -mod compiler/radiance.rad -entry radiance |
| 38 | |
| 39 | $(RAD_BIN): $(STD_LIB) compiler/radiance.rad |
| 40 | @echo "radiance $(SEED) => $@" |
| 41 | @$(EMU) $(EMU_FLAGS) -run $(SEED) $(SEED_OPTS) -o $@ |
| 42 | |
| 43 | # Standard Library Tests |
| 44 | |
| 45 | STD_LIB_TEST := lib/std.test.rv64 |
| 46 | |
| 47 | std-test: $(STD_LIB_TEST) |
| 48 | @echo |
| 49 | @$(EMU) $(EMU_FLAGS) -run $(STD_LIB_TEST) |
| 50 | |
| 51 | $(STD_LIB_TEST): $(STD_LIB) $(RAD_BIN) |
| 52 | @echo "radiance -test $(STD_TEST) -entry std -o $@" |
| 53 | @$(RADIANCE) -test $(STD_TEST) -entry std -o $@ |
| 54 | |
| 55 | clean-std-test: |
| 56 | @rm -f lib/std.test.rv64 \ |
| 57 | lib/std.test.rv64.debug \ |
| 58 | lib/std.test.rv64.s \ |
| 59 | lib/std.test.rv64.o \ |
| 60 | lib/std.test.rv64.rw.data \ |
| 61 | lib/std.test.rv64.ro.data |
| 62 | |
| 63 | # Lowering Tests |
| 64 | |
| 65 | LOWER_TEST := test/lower/lower-test.rv64 |
| 66 | LOWER_TEST_RUN := test/lower/run |
| 67 | |
| 68 | lower-test: $(LOWER_TEST) |
| 69 | @echo |
| 70 | @$(LOWER_TEST_RUN) |
| 71 | |
| 72 | $(LOWER_TEST): test/lower/lower-test.rad $(STD_LIB) $(RAD_BIN) |
| 73 | @echo "radiance $(STD) -pkg lower -mod test/lower/lower-test.rad -entry lower -o $@" |
| 74 | @$(RADIANCE) $(STD) -pkg lower -mod test/lower/lower-test.rad -entry lower -o $@ |
| 75 | |
| 76 | clean-lower-test: |
| 77 | @rm -f $(LOWER_TEST) \ |
| 78 | test/lower/lower-test.rv64.debug \ |
| 79 | test/lower/lower-test.rv64.s \ |
| 80 | test/lower/lower-test.rv64.o \ |
| 81 | test/lower/lower-test.rv64.rw.data \ |
| 82 | test/lower/lower-test.rv64.ro.data |
| 83 | |
| 84 | # Code generation tests. |
| 85 | |
| 86 | ASM_TEST_DIR := lib/std/arch/rv64/tests |
| 87 | ASM_TEST_SRC := $(wildcard $(ASM_TEST_DIR)/*.rad) |
| 88 | ASM_TEST_BIN := $(ASM_TEST_SRC:.rad=.rv64) |
| 89 | ASM_TEST_RUN := test/asm/run |
| 90 | |
| 91 | asm-test: $(ASM_TEST_BIN) $(RAD_BIN) |
| 92 | @echo |
| 93 | @$(ASM_TEST_RUN) $(ASM_TEST_SRC) |
| 94 | |
| 95 | $(ASM_TEST_DIR)/%.rv64: $(ASM_TEST_DIR)/%.rad $(RAD_BIN) |
| 96 | @echo "radiance $< => $@" |
| 97 | @$(RADIANCE) -pkg test -mod $< -o $@ |
| 98 | |
| 99 | clean-asm-test: |
| 100 | @rm -f $(ASM_TEST_BIN) \ |
| 101 | $(wildcard $(ASM_TEST_DIR)/*.rv64.debug) \ |
| 102 | $(wildcard $(ASM_TEST_DIR)/*.rv64.s) \ |
| 103 | $(wildcard $(ASM_TEST_DIR)/*.rv64) \ |
| 104 | $(wildcard $(ASM_TEST_DIR)/*.rv64.rw.data) \ |
| 105 | $(wildcard $(ASM_TEST_DIR)/*.rv64.ro.data) |
| 106 | |
| 107 | seed: |
| 108 | seed/update |
| 109 | |
| 110 | clean-rad: |
| 111 | rm -f $(RAD_BIN) $(RAD_BIN).ro.data $(RAD_BIN).rw.data |
| 112 | rm -f seed/radiance.rv64.s[0-9]* |
| 113 | |
| 114 | clean: clean-std-test clean-lower-test clean-asm-test clean-rad |
| 115 | |
| 116 | t: test |
| 117 | c: clean |
| 118 | |
| 119 | .PHONY: test clean default std-test lower-test asm-test seed \ |
| 120 | clean-std-test clean-lower-test clean-asm-test clean-rad emulator |
| 121 | .SUFFIXES: |
| 122 | .DELETE_ON_ERROR: |
| 123 | .SILENT: |