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
ralloc.h
raw
| 1 | #ifndef ralloc_H |
| 2 | #define ralloc_H |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | #include "riscv.h" |
| 7 | #include "types.h" |
| 8 | |
| 9 | /* Number of available registers. */ |
| 10 | #define RALLOC_NREGS 15 |
| 11 | |
| 12 | /* Order of registers to allocate. */ |
| 13 | extern const reg_t ralloc_regs[RALLOC_NREGS]; |
| 14 | |
| 15 | /* Register allocator context. */ |
| 16 | typedef struct { |
| 17 | bool regs[RALLOC_NREGS]; /* Registers status. */ |
| 18 | } ralloc_t; |
| 19 | |
| 20 | /* Return a new register allocator. */ |
| 21 | ralloc_t ralloc(void); |
| 22 | /* Allocate and return a new register. */ |
| 23 | reg_t ralloc_next(ralloc_t *ra); |
| 24 | /* Allocate and return a new register, avoiding `r` when possible. */ |
| 25 | reg_t ralloc_next_except(ralloc_t *ra, reg_t r); |
| 26 | /* Free the given register. */ |
| 27 | void ralloc_free(ralloc_t *ra, reg_t r); |
| 28 | /* Free all allocated registers. */ |
| 29 | void ralloc_free_all(ralloc_t *ra); |
| 30 | /* Returns whether this register is free to reserve. */ |
| 31 | bool ralloc_is_free(ralloc_t *ra, reg_t r); |
| 32 | /* Reserve a register. Fails if the register is already reserved. */ |
| 33 | void ralloc_reserve(ralloc_t *ra, reg_t r); |
| 34 | /* Save the register allocation state. */ |
| 35 | void ralloc_save(ralloc_t *ra, bool *reserved); |
| 36 | /* Restore the register allocation state. */ |
| 37 | void ralloc_restore(ralloc_t *ra, bool *reserved); |
| 38 | |
| 39 | #endif |