28199 Commits

Author SHA1 Message Date
antlilja
ff76ba64d6 Added values to AtomicRmw.Operation enum fields 2024-02-21 16:24:59 +01:00
antlilja
6df8302be6 Fixed values in AtomicOrdering enum 2024-02-21 16:24:59 +01:00
antlilja
fd3b81f93b LLVM Builder: Add toLlvm helper to Alignment 2024-02-21 16:24:59 +01:00
antlilja
2801bf6400 LLVM Builder: Add strtab helper to String 2024-02-21 16:24:59 +01:00
antlilja
9ccd7158b9 LLVM Builder: Make Type.Simple reflect LLVM codes 2024-02-21 16:24:59 +01:00
antlilja
1d94e9ef83 LLVM: Make sure child types get added first
The LLVM bitcode requires all type references in
structs to be to earlier defined types.

We make sure types are ordered in the builder
itself in order to avoid having to iterate the
types multiple times and changing the values
of type indicies.
2024-02-21 16:24:59 +01:00
antlilja
8feae5d2d5 LLVM: Assign correct values to enum/union tags 2024-02-21 16:24:59 +01:00
garrison hinson-hasty
955fd65cb1
Sema: fix peer type resolution for arrays of coercible elements 2024-02-21 00:55:29 +00:00
Jacob Young
ec7293422d llvm: fix c abi for structs not passed in registers
Closes #18916
2024-02-20 23:36:47 +01:00
Jacob Young
2291560424 c_import: extract behavior tests that use @cImport
This introduces the new test step `test-c-import`, and removes the
ability of the behavior tests to `@cImport` paths relative to `test`.
This allows the behavior tests to be run without translate c.
2024-02-20 18:44:43 +01:00
Techatrix
556db2ca36
json: make std.json.stringifyAlloc return a mutable slice (#19013) 2024-02-20 09:03:00 -05:00
mlugg
65a87ff299 Liveness: do not elide safety-checked instructions
Resolves: #19012
2024-02-20 12:10:29 +00:00
Jacob Young
97290e0bfc cbe: make more use of InternPool.Index.Slice
Attempts to fix the current CI failures introduced by #18983.
2024-02-19 19:32:06 -08:00
mlugg
7461309b73 Sema: validate that runtime-known inferred alloc does not have comptime-only type
Resolves: #18997
2024-02-19 21:48:50 +00:00
Ian Johnson
80f3ef6e14 Package.Fetch: fix Git package fetching
This commit works around #18967 by adding an `AccumulatingReader`, which
accumulates data read from the underlying packfile, and by keeping track
of the position in the packfile and hash/checksum information separately
rather than using reader composition. That is, the packfile position and
hashes/checksums are updated with the accumulated read history data only
after we can determine what data has actually been used by the
decompressor rather than merely being buffered.

The only addition to the standard library APIs to support this change is
the `unreadBytes` function in `std.compress.flate.Inflate`, which allows
the user to determine how many bytes have been read only for buffering
and not used as part of compressed data.

These changes can be reverted if #18967 is resolved with a decompressor
that reads precisely only the number of bytes needed for decompression.
2024-02-19 13:43:32 -08:00
Tristan Ross
5c25ad0fda std.zig.system.linux: detect risc-v 2024-02-19 10:12:17 +02:00
Andrew Kelley
7775e46e81
Merge pull request #18983 from jacobly0/dwarf-rewrite
dwarf: optimize dwarf parsing for speed
2024-02-18 12:41:37 -08:00
Jacob Young
247e4ac3cc dwarf: optimize dwarf parsing for speed
This code is run when printing a stack trace in a debug executable, so
it has to be fast even without compiler optimizations.

Adding a `@panic` to the top of `main` and running an x86_64 backend
compiled compiler goes from `1m32.773s` to `0m3.232s`.
2024-02-18 14:11:06 +01:00
Jacob Young
57b2b3df52 Dwarf: use a user tag for padding 2024-02-18 14:11:03 +01:00
Carl Åstholm
3cafb9655a zig fmt: Preserve trailing comma after single-item switch case 2024-02-18 12:36:04 +02:00
Alex Kladov
ab6317d32b std: fix copy-paste typo in spawnWindows 2024-02-17 21:49:00 -08:00
Jakub Konka
f3bd177723
Merge pull request #18976 from ziglang/elf-misc-fixes
elf: misc fixes
2024-02-18 00:43:33 +01:00
Igor Anić
3e8cb153ea fix flate regression
Until now literal and distance code lengths where treated as two
different arrays. But according to rfc they can overlap:

  The code length repeat codes can cross from HLIT + 257 to the
  HDIST + 1 code lengths.  In other words, all code lengths form
  a single sequence of HLIT + HDIST + 258 values.

Now code lengths are decoded in single array which is then split
to literal and distance part.
2024-02-17 15:31:13 -08:00
Jakub Konka
99584906bb elf: fix typo in resolving @"32" and @"32S" relocs on x86_64 2024-02-17 19:39:11 +01:00
Jakub Konka
57e71ce189 elf: @"64" is equivalent to GLOB_DAT on riscv 2024-02-17 19:39:11 +01:00
Jakub Konka
79e99c401c
Merge pull request #18973 from ziglang/elf-riscv
lib/std/elf: refactor relocation types + add RISCV relocs
2024-02-17 19:35:09 +01:00
Robin Voetter
dd4d320eb9
Merge pull request #18948 from alichraghi/vector
spirv: use extended instructions whenever possible
2024-02-17 14:01:07 +01:00
Jakub Konka
d1429a8fa9 lib/std/elf: refactor reloc enum values 2024-02-17 13:13:03 +01:00
Jakub Konka
509c7149b9 elf: fix formatting of relocs when reloc can be Zig specific 2024-02-17 12:35:16 +01:00
Jakub Konka
5fb54736df lib/std/elf: fix typo in R_RISCV_TLSDESC 2024-02-17 12:06:33 +01:00
Jakub Konka
9542ee9bf8 elf: create Zig specific reloc type shared across ISAs 2024-02-17 11:46:01 +01:00
Jakub Konka
ace1a69a55 elf: add new R_RISCV_TLSDESC reloc type 2024-02-17 11:41:18 +01:00
Jakub Konka
975862aca9 elf: add riscv dynamic relocs 2024-02-17 11:29:06 +01:00
Michael Dusan
50330ec22a cbe: do not set execute bits on emitted file 2024-02-17 10:50:46 +01:00
Jakub Konka
601aa10b82 elf: add riscv64 dynamic relocs mapping 2024-02-17 09:04:06 +01:00
Jakub Konka
5122a3d2d9 lib/std/elf: use enums for relocs 2024-02-17 08:50:53 +01:00
Jakub Konka
70a5dca13e elf: add riscv reloc types 2024-02-17 08:45:42 +01:00
Jakub Konka
fc7dd3e285 elf: enable adding support for additional cpu archs 2024-02-16 21:54:43 +01:00
Matthew Lugg
88d4b5cb18
Merge pull request #18909 from mlugg/random-enhancements
A loose collection of random enhancements:
* Eliminate `Sema.src` field
* Optimize size of ZIR
* Slightly improve some compile errors
2024-02-16 19:09:57 +00:00
mlugg
b2f28a104d
cases: account for changed compile errors 2024-02-16 12:15:39 +00:00
mlugg
5a957a3281
Sema: improved source location for @panic operand coercion error
Similar to the previous commit, errors coercing the panic message to
`[]const u8` now point at the operand to `@panic` rather than the actual
builtin call.
2024-02-16 12:04:00 +00:00
mlugg
e6cf3ce24c
Sema: correct source location for return value coercion errors
When coercing the operand of a `ret_node` etc instruction, the source
location for errors used to point to the entire `return` statement.
Instead, we now point to the operand, as would be expected if there was
an explicit `as_node` instruction (like there used to be).
2024-02-16 11:26:35 +00:00
mlugg
260c845355
Zir: make src_node of type declarations non-optional
Previously, the `src_node` field of `struct_decl`, `union_decl`,
`enum_decl`, and `opaque_decl` was optional, included in trailing data
only if a flag in `Small` was set. However, this was unnecessary logic:
AstGen always provided the source node. We can simplify a few bits of
logic by making this field non-optional, moving it into non-trailing
data.

There was one place where the field was actually omitted before: the
root struct of a file was at source node 0, so the node was
coincidentally elided. Therefore, this commit has a fixed cost of 4
bytes of ZIR per file.
2024-02-16 11:26:34 +00:00
mlugg
10784c7fc8
AstGen: migrate ty result locations to coerced_ty
In most cases where AstGen is coercing to a fixed type (such as `u29`,
`type`, `std.builtin.CallingConvention) we do not necessarily require an
explicit coercion instruction. Instead, Sema knows the type that is
required, and can perform the coercion after the fact. This means we can
use the `coerced_ty` result location kind, saving unnecessary coercion
instructions and therefore ZIR bytes.

This required a few enhancements to Sema to introduce missing coercions.
2024-02-16 11:26:34 +00:00
mlugg
434537213e
Sema: eliminate src field
`sema.src` is a failed experiment. It introduces complexity, and makes
often unwarranted assumptions about the existence of instructions
providing source locations, requiring an unreasonable amount of caution
in AstGen for correctness. Eliminating it simplifies the whole frontend.

This required adding source locations to a few instructions, but the
cost in ZIR bytes should be counteracted by the other work on this
branch.
2024-02-16 11:26:33 +00:00
mlugg
aba29f9789
AstGen: fix elision of unnecessary dbg_stmt instructions
AstGen has logic to elide leading `dbg_stmt` instructions when multiple
are emitted consecutively; however, it only applied in some cases. A
simple reshuffle here makes this logic apply universally, saving some
bytes in ZIR.
2024-02-16 11:26:33 +00:00
mlugg
2e27967a81
AstGen: avoid emitting multiple ret_type instructions
This is a small optimization to generated ZIR. In any function where the
return type is not a trivial Ref, we know it is almost certainly not
`void` (unless the user aliased it or did something else weird to fool
AstGen), and thus the return type is very likely to be required for
return value RLS at some point. Thus, we can just emit one `ret_type` at
the start of the function and use it throughout.

This sees a very small improvement in overall ZIR bytes.
2024-02-16 11:26:32 +00:00
Jacob Young
51e96a823c build.zig: support multiple args in cxx_compiler_arg1
An example of this happening is during CI runs where it has a value such
as `c++ -target x86_64-linux-musl -mcpu=baseline`.
2024-02-16 02:37:20 -08:00
Jacob Young
6f08e17229 InternPool: make more use of NullTerminatedString.Slice
This should avoid the random pointer invalidation crashes.

Closes #18954
2024-02-16 00:27:25 -08:00
Andrew Kelley
0183b44bb1 std.os.windows: add error.UnrecognizedVolume
Thanks to @matklad for finding this additional NTSTATUS possibility when
calling GetFinalPathNameByHandle.
2024-02-16 00:20:57 -08:00