Jacob Young
3ae04ed949
cbe: fix identifiers colliding with the short keyword
2022-11-16 01:26:37 -05:00
Jacob Young
a9c005e0e4
cbe: fixed tagged union initializers of a zero-bit field type
...
Fixes missing braces warnings on gcc 11.3.0.
2022-11-15 23:33:48 -05:00
Jacob Young
b82aec5a15
cbe: fix indexing with a zero-bit element type
...
Fixes void dereference warnings on gcc 11.3.0.
2022-11-15 23:33:48 -05:00
Jacob Young
b5b507a742
zig.h: match float comparison signatures from compiler rt
2022-11-15 23:33:48 -05:00
Veikka Tuominen
28cbe5e92a
Sema+llvm: improve handling of namespace-like unions
...
Closes #13557
2022-11-16 01:13:35 +02:00
Veikka Tuominen
11c64bfe6e
llvm: implement arbitrary precision debug enumerators
...
Closes #645
2022-11-16 01:12:27 +02:00
Veikka Tuominen
87cf2783eb
llvm: check that tuple fields have runtime bits
...
Just checking that they aren't comptime isn't enough for `@Type` constructed tuples.
Closes #13531
2022-11-12 15:41:29 +02:00
Veikka Tuominen
d42f4abb9d
llvm: correctly lower references to generic functions
...
Closes #13522
2022-11-12 15:41:29 +02:00
Veikka Tuominen
d2cc55109a
llvm: correct calculation of index of zero-bit field
...
If the field comes before any non-zero-bit field then the index of
the next field should be returned.
Closes #13363
2022-11-11 17:59:53 +02:00
Veikka Tuominen
cacfb0cfe4
llvm: fix leaks of fully qualified names
2022-11-11 17:59:53 +02:00
Cody Tapscott
2897641fb9
stage2: Support modifiers in inline asm
...
These are supported using %[ident:mod] syntax. This allows requesting,
e.g., the "w" (32-bit) vs. "x" (64-bit) views of AArch64 registers.
See https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers
2022-11-11 16:01:31 +02:00
Cody Tapscott
a2f4de1663
stage2 llvm: Elide more loads
...
Adds optimizations for by-ref types to:
- .struct_field_val
- .slice_elem_val
- .ptr_elem_val
I would have expected LLVM to be able to optimize away these
temporaries since we don't leak pointers to them and they are fed
straight from def to use, but empirically it does not.
Resolves https://github.com/ziglang/zig/issues/12713
Resolves https://github.com/ziglang/zig/issues/12638
2022-11-10 12:22:40 -07:00
Cody Tapscott
8f3880074f
stage2: Be more strict about eliding loads
...
This change makes any of the `*_val` instructions check whether it's
safe to elide copies for by-ref types rather than performing this
elision blindly.
AIR instructions fixed:
- .array_elem_val
- .struct_field_val
- .unwrap_errunion_payload
- .try
- .optional_payload
These now all respect value semantics, as expected.
P.S. Thanks to Andrew for the new way to approach this. Many of the
lines here are from his recommended change, which comes with the
significant advantage that loads are now as small as the intervening
memory access allows.
Co-authored by: Andrew Kelley <andrew@ziglang.org>
2022-11-10 12:22:40 -07:00
Veikka Tuominen
61842da9f7
llvm: implement packed unions
...
Closes #13340
2022-11-09 17:14:38 +02:00
Ali Chraghi
f5f1f8c666
all: rename i386 to x86
2022-11-04 00:09:27 +03:30
Jacob Young
f02b8a9cca
cbe: fix padding bits after a bitcast
2022-11-02 23:00:10 -04:00
Jacob Young
085f6fd8f7
cbe: use wrapping for left shifts
2022-11-02 23:00:10 -04:00
Jacob Young
4537c1b8b6
cbe: fix crash rendering union with zero-bit tag
2022-11-02 21:42:40 -04:00
Jacob Young
fa46f9a3d7
cbe: fix extern
2022-11-02 21:42:40 -04:00
Andrew Kelley
e50789f1cb
Merge pull request #13389 from jacobly0/fix-only-c
...
cbe: enough fixes for `-Donly-c` to be able to produce an executable
2022-11-02 15:53:59 -04:00
Andrew Kelley
57dbeb90af
Merge pull request #13396 from Luukdegram/fix-12880
...
llvm: mangle extern function names for Wasm target
2022-11-02 14:10:07 -04:00
Jacob Young
37c104ade0
cbe: ignore comptime fields when generating tuple typedefs
...
This vastly reduces the amount of deduplication state we need to deal with.
2022-11-02 10:21:05 -04:00
Jacob Young
5f31070b8b
cbe: hack around invalid Air
...
Can be changed to `!inst_ty.hisRuntimeBitsIgnoreComptime()` when the
"result location with inferred type ends up being pointer to comptime_int"
test stops producing Air containing a `bitcast(*comptime_int, ...)`.
See #13410
2022-11-02 10:20:31 -04:00
Cody Tapscott
c22f17e15f
stage2 llvm: Respect alignment for .union_init
...
Resolves #13232 .
2022-11-02 12:45:06 +02:00
Jacob Young
d8635af1dc
cbe: correctly implement volatile memset
2022-11-01 20:43:54 -04:00
Jacob Young
4d594090b1
cbe: incorrectly implement volatile memset
...
This will have to be replaced with manual volatile stores.
2022-11-01 20:39:06 -04:00
Jacob Young
09763435a8
cbe: support arrays in more places
2022-11-01 20:39:06 -04:00
Jacob Young
071404ff65
cbe: fix optional access
2022-11-01 20:39:05 -04:00
Jacob Young
8e52be1602
cbe: avoid emitting code for zero-bit field access
2022-11-01 20:38:52 -04:00
Jacob Young
fb8c08d4ac
cbe: disambiguate struct typedefs with decl index
2022-11-01 20:38:52 -04:00
Jacob Young
91fe0b80a2
cbe: fix threadlocal
2022-11-01 20:38:51 -04:00
Luuk de Gram
66bcc55e01
llvm: mangle extern Wasm functions
...
When Wasm extern functions contain the same name, but have a
different module name such as `extern "a"` vs `extern "b"` LLVM will
currently resolve the two functions to the same symbol. By mangling
the name of the symbol, we ensure the functions are resolved
seperately. We mangle the name by applying <name>|<module> where
module is also known as the library name.
2022-11-01 15:05:09 +01:00
Jacob Young
ff83296256
cbe: fix gcc warnings
2022-10-31 21:01:47 -04:00
Jacob Young
b945d3eb90
cbe: improve support for non-native float types
...
* Fix _start on aarch64.
* Add fallbacks when a float type is unsupported.
Fixes #13357
2022-10-31 20:18:15 -04:00
Jacob Young
48a2783969
cbe: implement optional slice representation change
2022-10-29 05:58:41 -04:00
Andrew Kelley
2991e4a454
Merge pull request #13288 from Vexu/opt-slice
...
Optimize size of optional slices (+ some fixes)
2022-10-27 22:09:17 -04:00
Andrew Kelley
1d1c7ae5de
Merge pull request #13257 from topolarity/ctype-fixes
...
stage 2: Update `CType` size/alignment
2022-10-27 21:15:22 -04:00
Veikka Tuominen
d03c47bf85
Sema: use runtime_value instead of creating allocs
2022-10-27 21:08:25 -04:00
Veikka Tuominen
f3a3fb3d88
llvm: pass optional slices like regular slices
2022-10-27 01:31:18 +03:00
Veikka Tuominen
595ccecd88
llvm: do not return undefined pointers from array_to_slice
2022-10-27 01:31:18 +03:00
Veikka Tuominen
78a7bb108a
llvm: handle namespace like packed structs
...
Closes #13159
Closes #13188
2022-10-27 01:31:18 +03:00
Veikka Tuominen
dd437ae399
stage2: optimize size of optional slices
2022-10-27 01:31:17 +03:00
Jacob Young
e20d2b3151
cbe: fix floating point builtins
2022-10-25 07:02:06 -04:00
Jacob Young
94425fe46e
cbe: improve floating point type support
2022-10-25 05:22:55 -04:00
Jacob Young
6021edd7ce
cbe: add support for all float literals types
2022-10-25 05:22:55 -04:00
Jacob Young
54326cc554
cbe: implement field_parent_ptr
2022-10-25 05:11:29 -04:00
Jacob Young
361035fe7a
cbe: implement cmp_lt_errors_len
2022-10-25 05:11:29 -04:00
Jacob Young
ab468d57e3
cbe: implement packed structs
...
Sometimes you have to break a test to make progress :)
2022-10-25 05:11:29 -04:00
Jacob Young
1bab854868
cbe: implement 128-bit and fix smaller integer builtins
2022-10-25 05:11:29 -04:00
Jacob Young
65a48df532
cbe: fix globals that reference functions
...
Global constant initializers can reference functions, so forward declare
the constants and initialize them later with the function definitions,
which guarantees that they appear after all declarations.
2022-10-25 05:11:29 -04:00