1000 Commits

Author SHA1 Message Date
Jacob Young
bc913295b5 CBE: fix emitting a partially undefined string literal 2022-12-24 02:40:33 -05:00
Jacob Young
a52dcdd3c5 CBE: fix bitwise not
Closes #13911
2022-12-21 03:04:59 -05:00
Veikka Tuominen
e1345fd0a0
Merge pull request #14004 from Vexu/packed-struct-vector
llvm: handle vectors in packed structs
2022-12-20 23:13:36 +02:00
Veikka Tuominen
2926d95e6a llvm: handle vectors in packed structs
Closes #13201
2022-12-19 12:19:52 +02:00
Jacob Young
202e8a0589 cbe: fix type passed to renderParentPtr 2022-12-18 23:39:01 -05:00
Jacob Young
0e3feebb04 codegen: fix taking the address of a zero-bit field in a zero-bit struct
Normally when we want a pointer to the end of a struct we just add 1 to
the struct pointer.  However, when it is a zero-bit struct, the pointer
type being used during lowering is often a dummy pointer type that
actually points to a non-zero-bit type, so we actually want to add 0
instead, since a zero-bit struct begins and ends at the same address.
2022-12-18 22:11:26 -05:00
Jacob Young
52e5c66025 llvm: fix use of invalid alignment
* Initialize `big_align` with 1 as 0 is not a valid alignment.
 * Add an assert to `alignForwardGeneric` to catch this issue earlier.
 * Refactor valid alignment checks to call a more descriptive function.
2022-12-18 22:11:26 -05:00
Jacob Young
18f05664dc llvm: avoid creating an invalid llvm type
Fixes the following assertion:

```
zig: llvm/lib/IR/Type.cpp:729: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
```
2022-12-18 22:11:26 -05:00
Jacob Young
e96f65db77 llvm: fix lowering pointer to final zero-width field of a comptime value
* Handle a `null` return from `llvmFieldIndex`.
 * Add a behavior test to test this code path.
 * Reword this test name, which incorrectly described how pointers to
   zero-bit fields behave, and instead describe the actual test.
2022-12-18 22:11:26 -05:00
Andrew Kelley
aca9c74e80
Merge pull request #13914 from Vexu/variadic
implement defining C variadic functions
2022-12-18 16:24:13 -05:00
Andrew Kelley
6ed0910d6d Revert "llvm: fix lowering pointer to final zero-width field of a comptime value"
This reverts commit e0bc5f65b98d154b4318027d56f780b55605e33c.

Caused an assertion failure when running the behavior tests:

```
zig: llvm/lib/IR/Type.cpp:729: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
Aborted (core dumped)
```
2022-12-18 13:51:15 -07:00
Veikka Tuominen
40ed6ae846
Merge pull request #13930 from r00ster91/renamings
std.builtin: renamings
2022-12-18 19:33:15 +02:00
Jacob Young
e0bc5f65b9 llvm: fix lowering pointer to final zero-width field of a comptime value
* Handle a `null` return from `llvmFieldIndex`.
 * Add a behavior test to test this code path.
 * Reword this test name, which incorrectly described how pointers to
   zero-bit fields behave, and instead describe the actual test.
2022-12-18 02:17:11 -05:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
Veikka Tuominen
9bb1104e37 implement defining C variadic functions 2022-12-17 13:22:09 +02:00
yujiri8
68d2f68ed8
zig fmt: fix extra whitespace with multiline strings
Fixes #13937
2022-12-17 00:24:58 +02:00
Travis Staloch
1ebb761244 codegen - lower str_lit to vector 2022-12-16 06:08:10 -05: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
Jakub Konka
bda5180b2c llvm: resolve all relative paths when creating DIFiles
This will make stack traces and debugging experience more consistent
in the sense that the presence of source lines in stack traces will
not be dependent on the current working directory of the running process.
2022-12-09 14:16:44 +01: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