Commit a9646f1
committed
Port to DynASM, passes (almost) all selftests
Changes main output to be generating machine code via DynASM, rather
than outputting text to be passed to the assembler.
Because chibicc assumes run-and-exit, it doesn't do any free/cleanup.
To work around this, while compiling multiple translation units in a
single run, each module jankily purges and resets and the heap is tossed
between files.
For each translation unit, a custom-obj-ish thing is output (which maybe
should have been ELF or whatever instead of custom...). After compiling
all the files listed on the command line, it does a link pass to handle
function references cross-module as well as data relocations (for
example to create literals or initialize global data). There's also no
particularly good reason that these objs (.dyo) need to be written to
disk (rather than simply being an in-memory structure), it was just
useful to debug the output.
All chibicc self-tests are passing except for two: 1) asm.c (because it
just passes the text of the asm block to the system assembler which no
longer exists); and 2) tls.c just because TLS support hasn't been
written yet.
This change also deletes most of the "driver" part of main.c as it
didn't seem to make a lot of sense with a JIT mode. Perhaps it would be
useful to bring some of that back, if only to be able to use it to build
common C software like sqlite, etc. for testing purposes.
The code for -S (output textual assembler) that is chibicc's normal mode
is still in the code, this was done during the rewrite to make it easier
to track. A future change will remove that code; a pristine copy of
chibicc is equally useful to compare final output with in any case.1 parent 33fcb55 commit a9646f1
File tree
32 files changed
+23283
-2605
lines changed- dynasm
32 files changed
+23283
-2605
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
10 | 57 | | |
11 | 58 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 59 | + | |
19 | 60 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 61 | + | |
| 62 | + | |
23 | 63 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 64 | + | |
30 | 65 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 66 | + | |
| 67 | + | |
34 | 68 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 69 | + | |
| 70 | + | |
39 | 71 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 72 | + | |
| 73 | + | |
43 | 74 | | |
44 | 75 | | |
45 | 76 | | |
46 | 77 | | |
47 | | - | |
| 78 | + | |
48 | 79 | | |
49 | 80 | | |
50 | | - | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
0 commit comments