Commit Graph

1736 Commits

Author SHA1 Message Date
Robin Voetter 7057bffc14 Merge pull request #19337 from Snektron/spirv-globals
spirv: rework generic global
2024-03-19 09:34:59 +01:00
Robin Voetter 335ff5a5f4 spirv: fix optional comparison 2024-03-18 19:13:50 +01:00
Robin Voetter 9b18125562 spirv: make generic globals invocation-local 2024-03-18 19:13:50 +01:00
Robin Voetter 20d7bb68ac spirv: add zig-specific ext inst
This may be removed again in the future...
2024-03-18 19:13:49 +01:00
Robin Voetter e566158acf spirv: make IdResult an enum 2024-03-18 19:13:49 +01:00
Robin Voetter 9b058117f0 spirv: update assembler with new spec 2024-03-18 19:13:48 +01:00
Robin Voetter 028f532dc0 spirv: update spec to SPIRV-Headers/8b246ff
We need this "unstable" version to get the Zig identifiers.
2024-03-18 19:13:47 +01:00
Veikka Tuominen 64173dadca Merge pull request #19334 from antlilja/llvm-fast-math
Fix setFloatMode in LLVM backend
2024-03-18 04:27:39 +02:00
kcbanner 54f6e74cda cbe: rework StringLiteral to decide between string literal or array initializator syntax
This fixes an issue with boostrapping the compiler using MSVC. There is a CircularBuffer with
an array of length 65536 initialized to undefined, and because the undefined path of `renderValue`
was using `StringLiteral` to render this, the resulting zig2.c would fail to compile using MSVC.

The solution was to move the already-existing array initializer path (used in the non-undefined path)
into StringLiteral, and make StringLiteral aware of the total length so it could decide between which
style of initialization to use. We prefer to use string literals if we can, as this results in the least
amount of emitted C source.
2024-03-17 16:17:04 -07:00
Andrew Kelley 95cb939440 Merge pull request #19333 from Vexu/fixes
Miscellaneous error fixes
2024-03-17 15:26:55 -07:00
Andrew Kelley d981549d65 Merge pull request #19323 from jacobly0/rm-fn-type-align
AstGen: disallow alignment on function types
2024-03-17 15:19:54 -07:00
antlilja 79b868d504 LLVM: Use fast math when requested 2024-03-17 16:26:28 +01:00
antlilja b20cee586c LLVM: Fix incorrect fast constant in FastMath packed struct 2024-03-17 16:25:59 +01:00
antlilja 37a4d9391f LLVM: Fix reaching unreachable code when emitting fast call 2024-03-17 16:23:14 +01:00
Robin Voetter 3bffa58012 Revert "spirv: merge construct(Struct/Vector/Array) into constructComposite"
This reverts commit eb2d61d02e.
2024-03-17 14:17:26 +01:00
Veikka Tuominen fec4b7ef5c Sema: fix spurious type has no namespace error
Closes #19232
2024-03-17 14:42:12 +02:00
Anton Lilja 294f51814f LLVM lowerDebugType: Lower union types without a layout into an empty namespace 2024-03-17 13:25:09 +02:00
Jacob Young d10c52c194 AstGen: disallow alignment on function types
A pointer type already has an alignment, so this information does not
need to be duplicated on the function type.  This already has precedence
with addrspace which is already disallowed on function types for this
reason.  Also fixes `@TypeOf(&func)` to have the correct addrspace and
alignment.
2024-03-17 03:06:17 +01:00
Tristan Ross 6067d39522 std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross c260b4c753 std.builtin: make global linkage fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross 099f3c4039 std.builtin: make container layout fields lowercase 2024-03-11 07:09:07 -07:00
mlugg e043fe474f Fix incorrectly resolved merge conflicts
To be honest, I can't be bothered to figure out which commits these
changes should be in.
2024-03-06 21:26:38 +00:00
mlugg d0c022f734 compiler: namespace type equivalence based on AST node + captures
This implements the accepted proposal #18816. Namespace-owning types
(struct, enum, union, opaque) are no longer unique whenever analysed;
instead, their identity is determined based on their AST node and the
set of values they capture.

Reified types (`@Type`) are deduplicated based on the structure of the
type created. For instance, if two structs are created by the same
reification with identical fields, layout, etc, they will be the same
type.

This commit does not produce a working compiler; the next commit, adding
captures for decl references, is necessary. It felt appropriate to split
this up.

Resolves: #18816
2024-03-06 21:26:37 +00:00
mlugg 975b859377 InternPool: create specialized functions for loading namespace types
Namespace types (`struct`, `enum`, `union`, `opaque`) do not use
structural equality - equivalence is based on their Decl index (and soon
will change to AST node + captures). However, we previously stored all
other information in the corresponding `InternPool.Key` anyway. For
logical consistency, it makes sense to have the key only be the true key
(that is, the Decl index) and to load all other data through another
function. This introduces those functions, by the name of
`loadStructType` etc. It's a big diff, but most of it is no-brainer
changes.

In future, it might be nice to eliminate a bunch of the loaded state in
favour of accessor functions on the `LoadedXyzType` types (like how we
have `LoadedUnionType.size()`), but that can be explored at a later
date.
2024-03-06 21:26:37 +00:00
Andrew Kelley 90c1a2c41a Merge pull request #19152 from antlilja/llvm-broken-debug
LLVM: Fail to emit if LLVM encounters broken debug info
2024-03-02 21:43:39 -08:00
Jacob Young aa688567f5 Air: replace .dbg_inline_* with .dbg_inline_block
This prevents the possibility of not emitting a `.dbg_inline_end`
instruction and reduces the allocation requirements of the backends.

Closes #19093
2024-03-02 21:19:34 -08:00
antlilja d345068ec2 LLVM: Fail to emit if LLVM encounters broken debug info 2024-03-02 20:53:06 +01:00
antlilja e2345f006f LLVM: Add enableBrokenDebugInfoCheck and getBrokenDebugInfo
These functions allows the caller to find out wether the context
encounters broken debug info or not.
2024-03-02 20:53:06 +01:00
mlugg 321045cf33 codegen: handle dbg_var scoping correctly after eliding more ZIR blocks
Since we now elide more ZIR blocks in AstGen, care must be taken in
codegen to introduce lexical scopes for every body, not just `block`s.

Also, elide a few unnecessary AIR blocks in Sema.
2024-02-29 23:38:18 +00:00
antlilja 147beec7da LLVM Builder: Fix emission of enum debug enumerator info bitcode 2024-02-29 12:02:13 -08:00
antlilja 5c2e463ecd LLVM: Don't create a debug lexical block when inlining 2024-02-28 14:46:43 +01:00
antlilja 40f99862e1 Builder: Implement StrtabString and use it for Global names 2024-02-28 14:46:43 +01:00
antlilja 826c6c0ec6 LLVM: Implement more efficient blob writing 2024-02-28 14:46:43 +01:00
Andrew Kelley 7b37bc771b move Zir to std.zig.Zir
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:35:30 -07:00
Andrew Kelley f7143e18e3 move Zcu.LazySrcLoc to std.zig.LazySrcLoc
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:35:30 -07:00
mlugg 59447e5305 compiler: decide dbg_var scoping based on AIR blocks
This commit eliminates the `dbg_block_{begin,end}` instructions from
both ZIR and AIR. Instead, lexical scoping of `dbg_var_{ptr,val}`
instructions is decided based on the AIR block they exist within. This
is a much more robust system, and also results in a huge drop in ZIR
bytes - around 7% for Sema.zig.

This required some enhancements to Sema to prevent elision of blocks
when they are required for debug variable scoping. This can be observed
by looking at the AIR for the following simple test program with and
without `-fstrip`:

```zig
export fn f() void {
    {
        var a: u32 = 0;
        _ = &a;
    }
    {
        var a: u32 = 0;
        _ = &a;
    }
}
```

When `-fstrip` is passed, no AIR blocks are generated. When `-fno-strip`
is passed, the ZIR blocks are lowered to true AIR blocks to give correct
lexical scoping to the debug vars.

The changes here incidentally reolve #19060. A corresponding behavior
test has been added.

Resolves: #19060
2024-02-26 13:20:45 +00:00
Andrew Kelley 031f23117d Merge pull request #19083 from antlilja/llvm-blockinfo
LLVM reduce size of emitted bitcode
2024-02-26 04:03:40 -08:00
Andrew Kelley 9dda2eb1ab Merge pull request #19080 from jacobly0/llvm-per-mod-strip
llvm: implement per-module stripping
2024-02-25 21:44:10 -08:00
Andrew Kelley 91fb211faa Merge pull request #18906 from jacobly0/x86_64-tests
x86_64: pass more tests
2024-02-25 21:43:20 -08:00
Jacob Young d656c2a7ab test: rework how filtering works
* make test names contain the fully qualified name
 * make test filters match the fully qualified name
 * allow multiple test filters, where a test is skipped if it does not
   match any of the specified filters
2024-02-25 19:12:08 -08:00
antlilja 73a16d440b Builder: Reduce size of DebugLoc abbrev 2024-02-26 01:02:16 +01:00
antlilja 9754d6d0a0 Builder: Use BlockInfo block to reduce size of bitcode 2024-02-26 01:00:58 +01:00
Jacob Young ed026b5dff llvm: free llvm data before running llvm optimizations
This reduces the max memory usage.
2024-02-25 17:37:27 +01:00
Jacob Young 1e1598950a llvm: implement per-module stripping
This avoids llvm module verification errors when the strip option
is different across modules.
2024-02-25 17:37:27 +01:00
Jacob Young 661137ac92 Merge pull request #19074 from antlilja/llvm-debug-loc
Rework LLVM debug locations to not emit them twice
2024-02-25 17:03:45 +01:00
Jacob Young f6af773578 llvm: remork memory management in emit 2024-02-25 03:58:06 -08:00
Jacob Young e5c439a16d x86_64: implement optional comparisons
Closes #18959
2024-02-25 11:22:10 +01:00
Jacob Young 2fcb2f5975 Sema: implement vector coercions
These used to be lowered elementwise in air, and now are a single air
instruction that can be lowered elementwise in the backend if necessary.
2024-02-25 11:22:10 +01:00
antlilja 71d9f3a86b Builder: Fix llvm ir debug location output 2024-02-25 03:16:52 +01:00
antlilja 928914e25a Builder: Improve debug location system
Debug locations are no longer emitted twice every time
2024-02-25 03:16:52 +01:00