Veikka Tuominen
9bb1104e37
implement defining C variadic functions
2022-12-17 13:22:09 +02:00
Veikka Tuominen
8a0a6b7387
port packed vector elem ptr logic from stage1
...
Closes #12812
Closes #13925
2022-12-15 21:06:35 -05:00
Veikka Tuominen
7b2a936173
remove stack option from @call
2022-12-13 12:52:21 +02:00
Jacob Young
fc6d7d2799
CBE: fix compiling for aarch64-windows
...
These bugs were triggered in the C backend by aarch64-specific code in
os/windows.zig. Intentionally not updating zig1.wasm yet because of
upcoming changes and since aarch64-windows is not tested on master yet.
2022-12-10 09:15:40 -05:00
Veikka Tuominen
9d93b2ccf1
Eliminate BoundFn type from the language
...
Closes #9484
2022-12-09 20:37:18 -07:00
Andrew Kelley
50eb7983cd
remove most conditional compilation based on stage1
...
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Jacob Young
91e489174b
CBE: avoid trailing space
2022-12-06 12:27:28 -07:00
Jacob Young
3686787f67
CBE: add windows-specific reserved identifiers
2022-12-06 12:27:28 -07:00
Jacob Young
f421efbcc1
CBE: fix bad local reuse for volatile memset
2022-12-06 12:15:04 -07:00
Jacob Young
4ee79aa33c
CBE: revert broken change that got missed
2022-12-04 22:37:48 -05:00
Jacob Young
7d3cc3bc8d
CBE: defer invariant local reuse in loops
...
When a local defined outside a loop dies inside the loop, it can still
be needed on subsequent loop iterations, so reuse of the local must be
deferred until after the loop ends. This causes behavior tests to pass.
2022-12-04 15:57:40 -07:00
Andrew Kelley
cc8bcae8c0
CBE: fix liveness issue with wrapping optionals
2022-12-04 15:57:40 -07:00
Andrew Kelley
4a6deaff5f
CBE: remove stray comment
2022-12-04 15:57:40 -07:00
Andrew Kelley
701cebeb30
CBE: fix union init wrong field name
2022-12-04 15:57:40 -07:00
Andrew Kelley
aa98517b3e
CBE: aggregate_init: resolve all operands before processing Liveness
2022-12-04 15:57:40 -07:00
Andrew Kelley
4aae0b09cf
CBE and LLVM: handle unused try instructions
...
In both backends they did not observe the Liveness information for try
instructions. Now they do. For the C backend this is necessary for
correctness; for the LLVM backend, it improves code generation.
2022-12-04 15:57:40 -07:00
Andrew Kelley
f2e59e41c1
CBE: fix various regressions caught by behavior tests
2022-12-04 15:57:40 -07:00
Andrew Kelley
6c0a1417c6
CBE: fix static allocs being double allocated
2022-12-04 15:57:40 -07:00
Andrew Kelley
da73410e7f
CBE: avoid curly inits because they don't work in assignments
2022-12-04 15:57:40 -07:00
Andrew Kelley
db1819e8ed
CBE: fix use-after-free of Type keys in free_locals map
2022-12-04 15:57:40 -07:00
Andrew Kelley
7bd63a602a
CBE: fix assignment expr and switch free tracking
2022-12-04 15:57:40 -07:00
Andrew Kelley
8bfbfa589c
CBE: fix clone of freed locals not being deep clone
2022-12-04 15:57:40 -07:00
Andrew Kelley
73a76b45c5
CBE: take advantage of switch_br and cond_br liveness
2022-12-04 15:57:40 -07:00
Andrew Kelley
8d8b2c834d
CBE: exploit Liveness analysis to reuse locals
2022-12-04 15:57:40 -07:00
Andrew Kelley
2a0efbee56
Revert "cbe: reduce amount of temporary locals"
...
This reverts commit 15cc83e27ae8a1740d9b7e2ec14044903979a832.
2022-12-04 15:57:40 -07:00
Andrew Kelley
46f4a97d05
Revert "cbe: write more instructions inline"
...
This reverts commit f8b779c114a5fcb82f08168912f2300d7027a2fd.
2022-12-04 15:57:39 -07:00
Jacob Young
e3b8658e65
cbe: add forward declarations for optionals and error unions
...
Arrays will have to wait for type rewrite.
2022-12-03 21:58:18 -05:00
Jacob Young
6d1292552e
cbe: implement function alignment
2022-12-03 08:40:08 -05:00
Jacob Young
ec3116f573
cbe: fix zero-bit struct field pointer
2022-12-03 08:40:08 -05:00
Jacob Young
7fb6eb3d14
cbe: implement multiple exports of a symbols
2022-12-03 08:21:03 -05:00
Jacob Young
81c271cc62
cbe: don't emit extern decls that are already exported
2022-12-03 08:21:03 -05:00
Jacob Young
2cfc08ba0d
cbe: fix named constraints without modifiers
2022-12-03 08:21:03 -05:00
Andrew Kelley
f68bfe2eb7
CBE: no braces when lowering block instruction
...
This change alone solves the bracket-depth issue when compiling zig1.c
with Clang.
2022-12-03 05:22:50 -05:00
Andrew Kelley
610d604f5b
Merge pull request #13748 from jacobly0/c-unaligned
...
cbe: use memcpy for underaligned loads and stores
2022-12-03 02:18:07 -05:00
Jacob Young
e1216077f0
cbe: add support for constraint modifiers specified after a colon
...
This translates `%[name:mod]` to `%mod[name]` for C.
2022-12-02 22:21:24 -05:00
Jacob Young
fdedd62365
cbe: use memcpy for underaligned loads and stores
2022-12-02 22:21:24 -05:00
Andrew Kelley
29e8e67a7e
CBE: use bool, true, false, instead of zig_ prefixes
...
In general the C backend should lower to human-maintainable C code
whenever possible. Directly using C types that one would use when
writing C code is one part of the strategy.
The concern with including stdint.h is C89 compatibility. Well, we can
just check the C std lib version before deciding to include that header.
2022-12-02 16:12:49 -07:00
Andrew Kelley
d171279d79
CBE: use a 0 literal instead of error.@"(no error)"
...
This saves bytes and is easier to read too.
2022-12-02 15:42:20 -07:00
Andrew Kelley
665eba93c1
CBE: eliminate zig_void
...
C void is perfectly fine.
2022-12-02 00:46:27 -05:00
Veikka Tuominen
f8b779c114
cbe: write more instructions inline
2022-11-30 17:13:56 +02:00
Veikka Tuominen
11ec7109c3
cbe: do not memcpy identical integer types when bitcasting
2022-11-30 17:11:06 +02:00
Veikka Tuominen
15cc83e27a
cbe: reduce amount of temporary locals
2022-11-30 17:11:06 +02:00
Veikka Tuominen
7be6f352e3
cbe: fix asm return values
2022-11-30 15:14:34 +02:00
Veikka Tuominen
3281494dc5
cbe: prevent access of inactive union field in unimplemented instructions
2022-11-30 15:14:34 +02:00
Veikka Tuominen
a67ea4a4ae
cbe: include hash in tuple type name
...
Different (simple) tuple types do not necessarily print out as different strings.
This is issue would be caused by passing std.fmt.Formatter to std.fmt.format.
2022-11-30 15:14:33 +02:00
Veikka Tuominen
2dcac348e5
cbe: implement packed unions
2022-11-30 15:14:33 +02:00
Veikka Tuominen
1a1a5702ab
cbe: correctly handle pointers to zero bit error union payloads
2022-11-30 15:14:33 +02:00
Veikka Tuominen
4def9c4a9b
cbe: operand of address of operator must be an lvalue
2022-11-30 15:14:33 +02:00
Veikka Tuominen
6310186d52
cbe: cast pointer switch target to int
2022-11-30 15:14:33 +02:00
Veikka Tuominen
63ae7899ae
cbe: ensure test and tagName function names are unique
2022-11-30 15:14:33 +02:00