shecc
shecc copied to clipboard
A self-hosting and educational C optimizing compiler
Add new compiler option +m/-m as the switch to take whether m extension or not. Check the global variable "use_m_ext" before riscv-codegen going to call `__mul()/__div()/__mod().` If there is no...
Error on make: /bin/sh: line 1: 21530 Segmentation fault out/shecc --dump-ir -o out/shecc-stage1.elf
I have a mistake when doing `make`. ```sh make SHECC out/shecc-stage1.elf /bin/sh: line 1: 21530 Segmentation fault out/shecc --dump-ir -o out/shecc-stage1.elf src/main.c > out/shecc-stage1.log make: *** [Makefile:71: out/shecc-stage1.elf] Error 139...
Both `src/arm-codegen` and `src/riscv-codegen.c` have some functions in common. The code generation can be refactored with the following changes: 1. split the shared functions/variables to new file `src/codegen.c` from src/{arm,riscv}-codegen.c...
Some Arm targets such as Cortex-A9 might lack of integer division instructions, and the current `shecc` would not generate the correct instruction sequence for them. Consequently, we have to provide...
The build target "config" should not only specify the target for code generation (Arm by default) but also check the availability of prerequisites such as `qemu-arm` and `qemu-riscv32`.
As title, current `shecc` didn't support "#ifdef ... #else ... #endif".
Reproducible with the following change: ```diff --- a/src/codegen.c +++ b/src/codegen.c @@ -77,7 +77,7 @@ void size_funcs(int data_start) data_start + elf_data_idx); /* TODO: add .bss section */ if (strcmp(blk->locals[i].type_name, "int") ==...
The way recent `shecc` evaluating local expression is generating relative arithmetic instruction and calculating in run-time. I think we can change the scheme into **evaluating in compile time**. Although it...
There's a test case: ``` a = 1 + (2 + (3 + (4 + (5 + (6 + (7 + (8 + (9 + (10 + (11 + (12...
At present, `malloc` was implemented via `brk` system call, which is obsolete. Most malloc implementations use `mmap` system call instead. We shall drop the use of `brk` in favor of...