aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
AgeCommit message (Collapse)Author
2024-07-21std.Target: Remove `hsail`/`hsail64` arch tags.Alex Rønne Petersen
This seems to just be dead. See: https://github.com/search?q=repo%3Allvm%2Fllvm-project%20hsail&type=code See: https://github.com/HSAFoundation/HSAIL-Tools/commits/master
2024-07-21std.Target: Remove `amdil`/`amdil64` arch tags.Alex Rønne Petersen
This is really obscure and no one is 100% sure what it is. It seems to be old and unused. My suspicion is that it's just an old term for "AMDGPU" before it was upstreamed to LLVM. See: https://github.com/search?q=repo%3Allvm%2Fllvm-project+amdil&type=code
2024-07-21std.Target: Remove the `r600` arch tag.Alex Rønne Petersen
These are quite old GPUs, and it is unlikely that Zig will ever be able to target them. See: https://en.wikipedia.org/wiki/Radeon_HD_2000_series
2024-07-21std.Target: Remove the `renderscript32`/`renderscript64` arch tags.Alex Rønne Petersen
It's dead: https://developer.android.com/guide/topics/renderscript/migrate
2024-07-21Revert "Merge pull request #20380 from tau-dev/master"Andrew Kelley
This reverts commit 397be0c9cc8156d38d1487a4c80210007033cbd0, reversing changes made to 18d412ab2fb7bda92f7bfbdf732849bbcd066c33. Caused test failures in master branch.
2024-07-21Riscv32e align stack to 4 bytes (#20673)cheme
2024-07-21Merge pull request #20380 from tau-dev/masterAndrew Kelley
llvm: Nest debug info correctly
2024-07-20Merge pull request #20402 from alexrp/target-cleanupAndrew Kelley
std.Target: Remove some obsolete/dead specifiers.
2024-07-20Fix typos in code comments in `src/`sobolevn
2024-07-20dev: fix llvm backend checksJacob Young
2024-07-19dev: introduce dev environments that enable compiler feature setsJacob Young
2024-07-20std.Target: Remove `coreclr` ABI specifier.Alex Rønne Petersen
This was added to LLVM in 2015 for the LLILC project, which was discontinued in ~2018, and subsequently archived in 2022. https://github.com/dotnet/llilc/commit/933b58d00ffb4b357956c940b37a379bdf891324
2024-07-20std.Target: Remove `nacl` OS specifier and `le32`/`le64` arch specifiers.Alex Rønne Petersen
Native Client is dead. https://developer.chrome.com/docs/native-client
2024-07-20std.Target: Remove `kfreebsd` OS specifier.Alex Rønne Petersen
kFreeBSD is dead. https://lists.debian.org/debian-devel/2023/07/msg00176.html
2024-07-20std.Target: Remove the `gnuf64` ABI specifier.Alex Rønne Petersen
This was used for LoongArch64, where: * `gnuf64` -> `ilp32d` / `lp64d` (full hard float) * `gnuf32` -> `ilp32f` / `lp64f` (hard float for `f32` only) * `gnusf` -> `ilp32` / `lp64` (soft float) But Loongson eventually settled on just `gnu` for the first case since that's what most people will actually be targeting outside embedded scenarios. The `gnuf32` and `gnusf` specifiers remain in use.
2024-07-19llvm: add pass-by-reference info to debug typesTau
Without this data, debugger expressions try to pass structs by-value, which mostly just crashes. Also: mark enums as enum classes to prevent the enumerators from shadowing other identifiers.
2024-07-19llvm: Do not generate static member definitionsTau
They were not helping LLDB and actively throwing off GDB. Also: clean up some llvm.Builder and llvm.ir definitions that are no longer necessary.
2024-07-19Try linking static members' definitions to their declarations.Tau
This does not help anything though: gdb would follow the DW_AT_specification link only in the opposite direction, which LLVM cannot emit.
2024-07-19ModuleDebugInfo: Discard C++ namespaces appearing in PDBsTau
2024-07-19llvm: Fix debug gen for 0-bit typesTau
Add a regression test for that, since these weirdly never occur in any of the other tests on x86-64-linux.
2024-07-19Don't attach a top-level function to its file, but to the file's structTau
2024-07-19llvm: encode variables as DW_TAG_imported_declarationTau
Now we get working global variable lookup in GDB! LLDB still re-mangles, and it looks like we can't do much about that for now. Also: translate non-owning type declarations into typedefs.
2024-07-19llvm: set precise scopes on namespace types and variablesTau
This will allow accessing non-local declarations from debuggers, which, AFAICT, was impossible before. Getting scopes right already works for type declarations and functions, but will need some fiddling for variables: For those, I tried imitating what Clang does for static member variables, but LLDB tries to re-mangle those and then fails at lookup, while GDB outright crashes. Hopefully I can find some other dwarven incantation to do the right thing.
2024-07-16Value: eliminate static recursion loop from value printingmlugg
2024-07-13Compilation: introduce work stages for better work distributionJacob Young
2024-07-13InternPool: add and use a mutate mutex for each listJacob Young
This allows the mutate mutex to only be locked during actual grows, which are rare. For the lists that didn't previously have a mutex, this change has little effect since grows are rare and there is zero contention on a mutex that is only ever locked by one thread. This change allows `extra` to be mutated without racing with a grow.
2024-07-13Builder: fix llvm ir syntaxJacob Young
2024-07-10InternPool: make `global_error_set` thread-safeJacob Young
2024-07-10InternPool: add `FileIndex` to `*File` mappingJacob Young
2024-07-10Air: store param names directly instead of referencing Zirmlugg
2024-07-10Zcu: cache fully qualified name on DeclJacob Young
This avoids needing to mutate the intern pool from backends.
2024-07-07Zcu: pass `PerThread` to intern pool string functionsJacob Young
2024-07-07Zcu: introduce `PerThread` and pass to all the functionsJacob Young
2024-07-04Zcu: extract permanent state from FileAndrew Kelley
Primarily, this commit removes 2 fields from File, relying on the data being stored in the `files` field, with the key as the path digest, and the value as the struct decl corresponding to the File. This table is serialized into the compiler state that survives between incremental updates. Meanwhile, the File struct remains ephemeral data that can be reconstructed the first time it is needed by the compiler process, as well as operated on by independent worker threads. A key outcome of this commit is that there is now a stable index that can be used to refer to a File. This will be needed when serializing error messages to survive incremental compilation updates.
2024-07-04cbe: fix for export changesJacob Young
2024-07-04compiler: rework type resolution, fully resolve all typesmlugg
I'm so sorry. This commit was just meant to be making all types fully resolve by queueing resolution at the moment of their creation. Unfortunately, a lot of dominoes ended up falling. Here's what happened: * I added a work queue job to fully resolve a type. * I realised that from here we could eliminate `Sema.types_to_resolve` if we made function codegen a separate job. This is desirable for simplicity of both spec and implementation. * This led to a new AIR traversal to detect whether any required type is unresolved. If a type in the AIR failed to resolve, then we can't run codegen. * Because full type resolution now occurs by the work queue job, a bug was exposed whereby error messages for type resolution were associated with the wrong `Decl`, resulting in duplicate error messages when the type was also resolved "by" its owner `Decl` (which really *all* resolution should be done on). * A correct fix for this requires using a different `Sema` when performing type resolution: we need a `Sema` owned by the type. Also note that this fix is necessary for incremental compilation. * This means a whole bunch of functions no longer need to take `Sema`s. * First-order effects: `resolveTypeFields`, `resolveTypeLayout`, etc * Second-order effects: `Type.abiAlignmentAdvanced`, `Value.orderAgainstZeroAdvanced`, etc The end result of this is, in short, a more correct compiler and a simpler language specification. This regressed a few error notes in the test cases, but nothing that seems worth blocking this change. Oh, also, I ripped out the old code in `test/src/Cases.zig` which introduced a dependency on `Compilation`. This dependency was problematic at best, and this code has been unused for a while. When we re-enable incremental test cases, we must rewrite their executor to use the compiler server protocol.
2024-07-04compiler: type.zig -> Type.zigmlugg
2024-07-04Zcu: store `LazySrcLoc` in error messagesmlugg
This change modifies `Zcu.ErrorMsg` to store a `Zcu.LazySrcLoc` rather than a `Zcu.SrcLoc`. Everything else is dominoes. The reason for this change is incremental compilation. If a failed `AnalUnit` is up-to-date on an update, we want to re-use the old error messages. However, the file containing the error location may have been modified, and `SrcLoc` cannot survive such a modification. `LazySrcLoc` is designed to be correct across incremental updates. Therefore, we defer source location resolution until `Compilation` gathers the compile errors into the `ErrorBundle`.
2024-07-04Zcu: key compile errors on `AnalUnit` where appropriatemlugg
This change seeks to more appropriately model the way semantic analysis works by drawing a more clear line between errors emitted by analyzing a `Decl` (in future a `Cau`) and errors emitted by analyzing a runtime function. This does change a few compile errors surrounding compile logs by adding more "also here" notes. The new notes are more technically correct, but perhaps not so helpful. They're not doing enough harm for me to put extensive thought into this for now.
2024-07-04Zcu: rework exportsmlugg
This commit reworks our representation of exported Decls and values in Zcu to be memory-optimized and trivially serialized. All exports are now stored in the `all_exports` array on `Zcu`. An `AnalUnit` which performs an export (either through an `export` annotation or by containing an analyzed `@export`) gains an entry into `single_exports` if it performs only one export, or `multi_exports` if it performs multiple. We no longer store a persistent mapping from a `Decl`/value to all exports of that entity; this state is not necessary for the majority of the pipeline. Instead, we construct it in `Zcu.processExports`, just before flush. This does not affect the algorithmic complexity of `processExports`, since this function already iterates all exports in the `Zcu`. The elimination of `decl_exports` and `value_exports` led to a few non-trivial backend changes. The LLVM backend has been wrangled into a more reasonable state in general regarding exports and externs. The C backend is currently disabled in this commit, because its support for `export` was quite broken, and that was exposed by this work -- I'm hoping @jacobly0 will be able to pick this up!
2024-07-03LLVM Builder: Pass correct argument to ensureUnusedMetadataCapacityantlilja
The trail_len was being multiplied by the size of the type before
2024-06-26Zir: make `src_line` absolute for `declaration` instructionsmlugg
We need special logic for updating line numbers anyway, so it's fine to just use absolute numbers here. This eliminates a field from `Decl`.
2024-06-22rename src/Module.zig to src/Zcu.zigAndrew Kelley
This patch is a pure rename plus only changing the file path in `@import` sites, so it is expected to not create version control conflicts, even when rebasing.
2024-06-20Merge pull request #20299 from mlugg/the-great-decl-splitMatthew Lugg
The Great Decl Split (preliminary work): refactor source locations and eliminate `Sema.Block.src_decl`.
2024-06-19Merge pull request #20070 from Rexicon226/riscvJakub Konka
more RISC-V backend progress
2024-06-16llvm: avoid debug info for naked function argumentsJacob Young
This is not supported by llvm.
2024-06-16spirv: add support for workItemId, workGroupId, workGroupSizeRobin Voetter
2024-06-15Zcu: rework source locationsmlugg
`LazySrcLoc` now stores a reference to the "base AST node" to which it is relative. The previous tagged union is `LazySrcLoc.Offset`. To make working with this structure convenient, `Sema.Block` contains a convenience `src` method which takes an `Offset` and returns a `LazySrcLoc`. The "base node" of a source location is no longer given by a `Decl`, but rather a `TrackedInst` representing either a `declaration`, `struct_decl`, `union_decl`, `enum_decl`, or `opaque_decl`. This is a more appropriate model, and removes an unnecessary responsibility from `Decl` in preparation for the upcoming refactor which will split it into `Nav` and `Cau`. As a part of these `Decl` reworks, the `src_node` field is eliminated. This change aids incremental compilation, and simplifies `Decl`. In some cases -- particularly in backends -- the source location of a declaration is desired. This was previously `Decl.srcLoc` and worked for any `Decl`. Now, it is `Decl.navSrcLoc` in reference to the upcoming refactor, since the set of `Decl`s this works for precisely corresponds to what will in future become a `Nav` -- that is, source-level declarations and generic function instantiations, but *not* type owner Decls. This commit introduces more tags to `LazySrcLoc.Offset` so as to eliminate the concept of `error.NeededSourceLocation`. Now, `.unneeded` should only be used to assert that an error path is unreachable. In the future, uses of `.unneeded` can probably be replaced with `undefined`. The `src_decl` field of `Sema.Block` no longer has a role in type resolution. Its main remaining purpose is to handle namespacing of type names. It will be eliminated entirely in a future commit to remove another undue responsibility from `Decl`. It is worth noting that in future, the `Zcu.SrcLoc` type should probably be eliminated entirely in favour of storing `Zcu.LazySrcLoc` values. This is because `Zcu.SrcLoc` is not valid across incremental updates, and we want to be able to reuse error messages from previous updates even if the source file in question changed. The error reporting logic should instead simply resolve the location from the `LazySrcLoc` on the fly.
2024-06-15compiler: move LazySrcLoc out of stdmlugg
This is in preparation for some upcoming changes to how we represent source locations in the compiler. The bulk of the change here is dealing with the removal of `src()` methods from `Zir` types.
2024-06-13std: Convert deprecated aliases to compile errors and fix usagesRyan Liptak
Deprecated aliases that are now compile errors: - `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`) - `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`) - `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`) - `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`) - `std.unicode` + `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`) + `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`) - `std.zig.CrossTarget` (moved to `std.Target.Query`) Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are: - `std.rand` (renamed to `std.Random`) - `std.TailQueue` (renamed to `std.DoublyLinkedList`) - `std.ChildProcess` (renamed/moved to `std.process.Child`) This is not exhaustive. Deprecated aliases that I didn't touch: + `std.io.*` + `std.Build.*` + `std.builtin.Mode` + `std.zig.c_translation.CIntLiteralRadix` + anything in `src/`