Isaac Freund
60fb50ee5a
stage2/wasm: write exports on flush, cleanup
...
Exports now have a dirty flag and are rewritten on flush if this flag
has been set.
A couple other minor changes have been made based on Andrew's review.
2020-08-18 01:01:13 +02:00
Isaac Freund
97300896ed
stage2/wasm: implement trivial codegen
...
We now generate code for returning constants of any of the basic types.
2020-08-18 01:01:04 +02:00
Isaac Freund
3370b5f109
stage2/wasm: implement basic container generation
...
Thus far, we only generate the type, function, export, and code
sections. These are sufficient to generate and export simple functions.
Codegen is currently hardcoded to `i32.const 42`, the main goal of this
commit is to create infrastructure for the container format which will
work with incremental compilation.
2020-08-18 00:32:58 +02:00
Veikka Tuominen
d8fb377e2a
Merge pull request #6060 from Vexu/stage2
...
Stage2: more optionals stuff
2020-08-18 00:15:36 +03:00
Andrew Kelley
624e643872
Merge pull request #6046 from heidezomp/std-log-scoped-part2
...
std.log: (breaking) remove scope parameter from logging functions
2020-08-17 16:59:27 -04:00
Vexu
13b2f1e90b
address review feedback
2020-08-17 19:21:03 +03:00
Jakub Konka
5cb96681d9
Move Mach-O to link/MachO.zig submodule
...
Remove `ptrWidth` since as of Catalina, all apps are 64bits only.
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-17 18:16:29 +02:00
Jakub Konka
e23fc3905f
Add skeleton for MachO support in stage2
...
This commit adds an empty skeleton for MachO format support in stage2.
2020-08-17 18:16:29 +02:00
Vexu
ece4a2fc51
stage2: astgen for if and while with error unions
2020-08-17 14:28:04 +03:00
Vexu
db77b6b4e7
stage2: astgen for if and while with optionals
2020-08-17 14:28:04 +03:00
Vexu
012fac255f
stage2: fix optimization causing wrong optional child types
2020-08-17 14:26:32 +03:00
Vexu
c52513e25b
stage2: astgen for ptr types and address of
2020-08-17 14:24:56 +03:00
Andrew Kelley
6b141620a6
Merge pull request #6048 from pixelherodev/cleanup
...
Some minor cleanup and error handling
2020-08-17 01:41:52 -04:00
Isaac Freund
fc850aad61
stage2: fix signed <-> unsigned Value casts
2020-08-17 01:40:46 -04:00
Noam Preil
3ca8c42e7a
Astgen: further cleanup
2020-08-16 20:36:33 -04:00
Noam Preil
93619a5e4e
Module: panic when encountering unimplemented node
2020-08-16 20:32:51 -04:00
Noam Preil
34923e071e
CBE: minor doc change
2020-08-16 20:32:50 -04:00
Noam Preil
692f38c250
astgen: minor cleanup
2020-08-16 20:32:50 -04:00
Andrew Kelley
8d8d568854
stage2: implement zig version
2020-08-15 20:04:08 -04:00
Andrew Kelley
66d76cc4f9
stage2: codegen for labeled blocks
2020-08-15 17:03:05 -07:00
Andrew Kelley
0f3f96c850
stage2: astgen for labeled blocks and labeled breaks
2020-08-15 00:52:25 -07:00
Andrew Kelley
f356cba704
stage2: populate some of the astgen switch possibilities
...
Idea here is simply to entice people to contribute astgen code :)
2020-08-14 22:50:00 -04:00
Andrew Kelley
b49d3672f3
stage2 astgen for LabeledBlock
2020-08-14 22:50:00 -04:00
Andrew Kelley
9a5a1013a8
std.zig.ast: extract out Node.LabeledBlock from Node.Block
...
This is part of an ongoing effort to reduce size of in-memory AST. This
enum flattening pattern is widespread throughout the self-hosted
compiler.
This is a API breaking change for consumers of the self-hosted parser.
2020-08-14 22:50:00 -04:00
Andrew Kelley
7a39a038db
stage2: proper semantic analysis of improper returning of implicit void
2020-08-14 13:08:55 -07:00
Andrew Kelley
5f7c7191ab
stage2: astgen for non-labeled blocks
2020-08-14 11:28:40 -07:00
Andrew Kelley
28a9da8bfc
stage2: implement while loops (bool condition)
...
* introduce a dump() function on Module.Fn which helpfully prints to
stderr the ZIR representation of a function (can be called before
attempting to codegen it). This is a debugging tool.
* implement x86 codegen for loops
* liveness: fix analysis of conditional branches. The logic was buggy
in a couple ways:
- it never actually saved the results into the IR instruction (fixed now)
- it incorrectly labeled operands as dying when their true death was
after the conditional branch ended (fixed now)
* zir rendering is enhanced to show liveness analysis results. this
helps when debugging liveness analysis.
* fix bug in zir rendering not numbering instructions correctly
closes #6021
2020-08-13 20:32:32 -07:00
Andrew Kelley
fc402bdbbb
stage2: zir_sema for loops
...
Also remove the "repeat" instruction and make it implied to be at the
end of a Loop body.
2020-08-13 20:32:32 -07:00
Veikka Tuominen
f5b99abc93
Merge pull request #6045 from Vexu/block
...
Add error for unused/duplicate labels.
2020-08-14 01:04:05 +03:00
Andrew Kelley
ec4953504a
stage2: implement safety checks at the zir_sema level
2020-08-13 10:04:46 -07:00
Vexu
13e472aa2a
translate-c: add return if one is needed
2020-08-13 18:40:14 +03:00
heidezomp
16d118a8d9
update std and src-self-hosted for std.log breaking change
2020-08-13 17:14:15 +02:00
Vexu
6b2ce9d1e9
stage2: split unwrap_optional to safe and unsafe verions
2020-08-13 08:12:17 -07:00
Vexu
4a40282391
stage2: implement unwrap optional
2020-08-13 08:12:17 -07:00
Vexu
5c1fe58613
stage2: gen optional types
2020-08-13 08:12:17 -07:00
Vexu
75eaf15740
stage2: add optional types
2020-08-13 08:12:17 -07:00
Vexu
c5368ba20c
translate-c: ensure generated labels are unique
2020-08-13 15:27:29 +03:00
Andrew Kelley
eec53d67ab
stage2: anyerror -> explicit error set
2020-08-12 21:59:40 -07:00
Noam Preil
1eb5aaa4b5
CBE: renderValue pays attention to Type, not Tag
2020-08-12 21:58:21 -07:00
Noam Preil
5a166cead8
CBE: fix handling of IR dependencies
2020-08-12 21:58:21 -07:00
Noam Preil
dbd1e42ef2
CBE: Sorta working intcasts?
2020-08-12 21:58:21 -07:00
Noam Preil
78fe86dcd2
CBE: support unreachable on GCC
2020-08-12 21:58:21 -07:00
Noam Preil
d3eec7d46b
CBE: working parameters
2020-08-12 21:58:21 -07:00
Noam Preil
4d778e630a
Tests: print generated C on test failure
2020-08-12 21:58:21 -07:00
Noam Preil
dd1f1487e4
CBE: Use zig_noreturn instead of noreturn to avoid namespace conflict
2020-08-12 21:58:21 -07:00
Noam Preil
b59e2c1e00
CBE: improve noreturn definition, support noreturn on MSVC
2020-08-12 21:58:21 -07:00
Andrew Kelley
de4f3f11f7
stage2: astgen for while loops
...
See #6021
2020-08-12 21:13:16 -07:00
Vexu
3734881577
add error for unused/duplicate block labels
2020-08-13 01:13:17 +03:00
Andrew Kelley
8282f4271c
stage2: basic support for parameters .debug_info
...
see #6014
2020-08-11 22:23:32 -07:00
Andrew Kelley
a2a5cea286
stage2: emit DW_TAG_subprogram for function Decls
...
these have the virtual address range, return type, and name.
2020-08-11 19:02:21 -07:00