aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
AgeCommit message (Collapse)Author
2024-02-04spirv: element-wise operation helperRobin Voetter
2024-02-04spirv: sh[rl](_exact)?Robin Voetter
2024-02-02InternPool: use separate key for slicesmlugg
This change eliminates some problematic recursive logic in InternPool, and provides a safer API.
2024-01-29llvm: ensure returned undef is 0xaa bytes when runtime safety is enabledVeikka Tuominen
Closes #13178
2024-01-29Introduce type-erased writers to C backend codegenIan Johnson
This reduces generic instantiations of several write functions. Before: ``` @as(type, io.writer.Writer(*array_list.ArrayListAligned(u8,null),error{OutOfMemory},(function 'appendWrite'))) @as(type, io.writer.Writer(*codegen.c.IndentWriter(io.writer.Writer(*array_list.ArrayListAligned(u8,null),error{OutOfMemory},(function 'appendWrite'))),error{OutOfMemory},(function 'write'))) ``` After: ``` @as(type, io.GenericWriter(io.Writer,error{OutOfMemory},(function 'write'))) ```
2024-01-29Merge pull request #18729 from Vexu/fixesAndrew Kelley
Fix some generic{Reader,Writer} related issues
2024-01-29llvm: revert bad array access optimizationVeikka Tuominen
Closes #18723
2024-01-29llvm: fix alignment of array ptr when bitcasting vectorVeikka Tuominen
Closes #17996
2024-01-16Skip all dbg instructionsocrap7
2024-01-15Sema: fix `@extern` declsJacob Young
Closes #18550
2024-01-11LLVM: fix lowering of extern anyopaqueAndrew Kelley
closes #18461
2024-01-08llvm: optional slices cannot be passed in parts when they allowzeroVeikka Tuominen
Closes #18428
2024-01-03cbe: fix non-msvc externs and exportsJacob Young
Closes #17817
2024-01-03Reapply "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"Jacob Young
This reverts commit 2b589783602c5428ecde9dbb3f41a81f85eb0f25.
2024-01-01fix population of builtin.zig not making the parent dirAndrew Kelley
2024-01-01fix remaining compile errors except oneAndrew Kelley
2024-01-01move dll_export_fns and rdynamic to Compilation.ConfigAndrew Kelley
2024-01-01update codegen.llvm references to bin_file.optionsAndrew Kelley
2024-01-01update bin_file.options references in SemaAndrew Kelley
mainly pertaining to error return tracing
2024-01-01fix a round of compile errors caused by this branchAndrew Kelley
2024-01-01compiler: miscellaneous branch progressAndrew Kelley
implement builtin.zig file population for all modules rather than assuming there is only one global builtin.zig module. move some fields from link.File to Compilation move some fields from Module to Compilation compute debug_format in global Compilation config resolution wire up C compilation to the concept of owner modules make whole cache mode call link.File.createEmpty() instead of link.File.open()
2024-01-01compiler: update many references to bin_file.optionsAndrew Kelley
2024-01-01update bin_file.options references in Module (Zcu)Andrew Kelley
2024-01-01update references to module (to be renamed to zcu)Andrew Kelley
2024-01-01linkers: update references to "options" fieldAndrew Kelley
2024-01-01compiler: update references to single_threadedAndrew Kelley
2024-01-01move a large chunk of linker logic away from "options"Andrew Kelley
These options are only supposed to be provided to the initialization functions, resolved, and then computed values stored in the appropriate place (base struct or the object-format-specific structs). Many more to go...
2024-01-01WIP: move many global settings to become per-ModuleAndrew Kelley
Much of the logic from Compilation.create() is extracted into Compilation.Config.resolve() which accepts many optional settings and produces concrete settings. This separate step is needed by API users of Compilation so that they can pass the resolved global settings to the Module creation function, which itself needs to resolve per-Module settings. Since the target and other things are no longer global settings, I did not want them stored in link.File (in the `options` field). That options field was already a kludge; those options should be resolved into concrete settings. This commit also starts to work on that, deleting link.Options, moving the fields into Compilation and ObjectFormat-specific structs instead. Some fields were ephemeral and should not have been stored at all, such as symbol_size_hint. The link.File object of Compilation is now a `?*link.File` and `null` when -fno-emit-bin is passed. It is now arena-allocated along with Compilation itself, avoiding some messy cleanup code that was there before. On the command line, it is now possible to configure the standard library itself by using `--mod std` just like any other module. This meant that the CLI needed to create the standard library module rather than having Compilation create it. There are a lot of changes in this commit and it's still not done. I didn't realize how quickly this changeset was going to balloon out of control, and there are still many lines that need to be changed before it even compiles successfully. * introduce std.Build.Cache.HashHelper.oneShot * add error_tracing to std.Build.Module * extract build.zig file generation into src/Builtin.zig * each CSourceFile and RcSourceFile now has a Module owner, which determines some of the C compiler flags.
2024-01-01Revert "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"Andrew Kelley
This reverts commit 7161ed79c4abcaccdd56fe0b4fbd3d93472d41b8, reversing changes made to 3f2a65594e1d3c0a4f4943a4ea522e8405db81e0. Unfortunately, this sat in the PR queue too long and the merge broke the zig1.wasm bootstrap process.
2024-01-01Merge pull request #17824 from kcbanner/fixup_msvc_fmaxAndrew Kelley
cbe: add a system for avoiding collisions with C compiler intrinsics
2024-01-01Compilation: cleanup hashmap usageJacob Young
2023-12-22use `casted_rhs` instead of `rhs` so `icmp` works correctly for `airShlSat`Stefan Su
2023-12-03Air: use typesafe `Air.Inst.Index`Jacob Young
I need some indices for a thing...
2023-11-26move Module.Decl.Index and Module.Namespace.Index to InternPoolMeghan Denny
2023-11-25convert `toType` and `toValue` to `Type.fromInterned` and `Value.fromInterned`Techatrix
2023-11-24spirv: structured control flowRobin Voetter
2023-11-24spirv: add -fstructured-cfg optionRobin Voetter
This enables the compiler to generate a structured cfg even in opencl, even if it is not strictly required by the SPIR-V Kernel specification.
2023-11-24spirv: always emit mask constants even if no bits are setRobin Voetter
A parameter like this is not always optional, even if that is usually implied. SPIR-V tools fail to parse a module with an OpLoopMerge instruction where the loop control parameter is left out.
2023-11-24spirv: fix memory leak in SpvModuleRobin Voetter
2023-11-19compiler: correct unnecessary uses of 'var'mlugg
2023-11-12rework memory management of Module.Namespace hash mapsAndrew Kelley
The motivating problem here was a memory leak in the hash maps of Module.Namespace. The commit deletes more of the legacy incremental compilation implementation. It had things like use of orderedRemove and trying to do too much OOP-style creation and deletion of objects. Instead, this commit iterates over all the namespaces on Module deinit and calls deinit on the hash map fields. This logic is much simpler to reason about. Similarly, change global inline assembly to an array hash map since iterating over the values is a primary use of it, and clean up the remaining values on Module deinit, solving another memory leak. After this there are no more memory leaks remaining when using the x86 backend in a libc-less compiler.
2023-11-11Merge pull request #17963 from jacobly0/workaround/16392Andrew Kelley
llvm: workaround SROA misoptimizations in LLVM
2023-11-10BitcodeReader: followup cleanupJacob Young
2023-11-10llvm: workaround SROA misoptimizations in LLVMJacob Young
Workaround #16392
2023-11-09Compilation: forward clang diagnostics to error bundlesJacob Young
2023-11-07cbe: support rendering union values that have no defined tag typekcbanner
This was regressed in d657b6c0e2ab7c47f5416dc4df1abb2bfbecd4b6, when the comptime memory model for unions was changed to allow them to have no defined tag type.
2023-11-05cbe: handle underscore prexfix on macos, don't mangle extern function nameskcbanner
2023-11-05cbe: add DeclVisibility and zig_extern_mangled to handle exporting mangled ↵kcbanner
symbols under a different name
2023-11-05cbe: avoid collisions with builtins and intrinsicskcbanner
Changes: - Add `isMangledIdent` to determine if `fmtIdent` would make any edits to the identifier - Any function that has a mangled identifier is referred to using the mangled identifer within the current file, but if it is exported the first export will be with the non-mangled name. - Add `zig_import` to import a symbol under a different name - Add a level of indirection to float function names. Now, they are referred to as `zig_float_fn_<float type>_<operation>`. The definitions in zig.h are wrapped with `zig_import` to import the symbol under the real name. The specific problem that sparked this change was the combination of `zig_libc_name_f80(name) __##name##x` with the input `fma`, resulting in `__fmax`, which is a new intrinsic in recent versions of cl.exe. With the above changes in place, compiler_rt can output the following: ``` static zig_weak_linkage_fn zig_f80 zig_e___fmax(zig_f80, zig_f80, zig_f80); zig_export(zig_weak_linkage_fn zig_f80 zig_e___fmax(zig_f80, zig_f80, zig_f80), __fmax, "__fmax"); ``` Within compiler_rt, `zig_e___fmax` is used to refer to the function, but consumers will import `__fmax`, which maps to their `zig_float_fn_f80_fma` definition from zig.h.
2023-10-31cbe: fix `@bitCast` warningsJacob Young