aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm/CodeGen.zig
AgeCommit message (Collapse)Author
2023-03-26wasm: implement float operations with compiler-rtTechatrix
2023-03-21codegen: fix backend breakage due to optional layout changeJacob Young
2023-03-18wasm: add atomics opcodes and refactoringLuuk de Gram
This adds the atomic opcodes for the Threads proposal to the WebAssembly specification: https://github.com/WebAssembly/threads PrefixedOpcode has been renamed to MiscOpcode as there's multiple types of prefixed opcodes. This naming is similar to other tools such as LLVM. As we now use the 0xFE prefix, we moved the function_index MIR instruction as it was occupying the same value. This commit includes renaming all related opcodes.
2023-03-04Merge pull request #14782 from r00ster91/trapAndrew Kelley
add `@trap` builtin
2023-03-04Wasm @breakpoint: emit unreachabler00ster91
This should improve the developer debugging experience.
2023-03-04add @trap builtinr00ster91
This introduces a new builtin function that compiles down to something that results in an illegal instruction exception/interrupt. It can be used to exit a program abnormally. This implements the builtin for all backends.
2023-03-03codegen: rename GenerateSymbolError to CodeGenErrorJakub Konka
2023-03-03codegen: move gen logic for typed values, consts and decl ref to common codegenJakub Konka
2023-02-21Sema: implement @fieldParentPtr for unionsIsaac Freund
2023-02-19implement `writeToMemory`/`readFromMemory` for pointersVeikka Tuominen
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-02-03link: remove `FnData` and make it self-ownedLuuk de Gram
This finishes the work started in #14502 where atoms are owned by the linker themselves. This now makes debug atoms fully owned by dwarf, and no information is left stored on the decl.
2023-02-02Merge pull request #14502 from ziglang/link-owned-atomsJakub Konka
link: move ownership of linker atom from frontend to the linkers
2023-02-01link: remove union types which are now internal to backendsJakub Konka
2023-02-01link: make Wasm atoms fully owned by the linkerLuuk de Gram
2023-02-01link: decouple DI atoms from linker atoms, and manage them in Dwarf linkerJakub Konka
2023-01-31wasm: apply request changeTechatrix
2023-01-31wasm: correctly handle optional slicesTechatrix
2023-01-27wasm: migrate to new non-allocateDeclIndexes APILuuk de Gram
2023-01-25self-hosted: rename codegen Result.appended to Result.okJakub Konka
2023-01-25self-hosted: remove unused `externally_managed` prong for Decls codeJakub Konka
2022-12-30fix generic function arg debug info referencing wrong parameterVeikka Tuominen
Closes #14123
2022-12-21wasm: refactor extended instructionsLuuk de Gram
The extended instructions starting with opcode `0xFC` are refactored to make the work the same as the SIMD instructions. This means a `Mir` instruction no longer contains a field 'secondary'. Instead, we use the `payload` field to store the index into the extra list which contains the extended opcode value. In case of instructions such as 'memory.fill' which also have an immediate value, such values will also be stored in the extra list right after the instruction itself. This makes each `Mir` instruction smaller.
2022-12-18Merge pull request #13914 from Vexu/variadicAndrew Kelley
implement defining C variadic functions
2022-12-17std.builtin: rename Type.UnionField and Type.StructField's field_type to typer00ster91
2022-12-17implement defining C variadic functionsVeikka Tuominen
2022-12-15port packed vector elem ptr logic from stage1Veikka Tuominen
Closes #12812 Closes #13925
2022-12-13Merge pull request #13907 from Vexu/call-mergeAndrew Kelley
Remove `stack` option from `@call`
2022-12-13remove `stack` option from `@call`Veikka Tuominen
2022-12-12wasm: `splat` for vector elements divisible by 8Luuk de Gram
This implements `@splat` for vectors where the element type is divisible by 8 and a power of two. This is fairly simple as we can store the values directly within the virtual stack. But for all other sizes, we must first shift and bitwise-or the values before we can store them to fit them like a packed-struct, rather than an array.
2022-12-12wasm: implement the 'splat' instruction part 1Luuk de Gram
This implements `airSplat` for the native WebAssembly backend when the features 'simd128' or 'relaxed-simd' are enabled. The commit supports splat where the value lives in the linear memory segment, as well as on the stack. This saves a lot of instruction cost. When it detects the element type is not 8, 16, 32 or 64 bits, the backend will instead use the same strategy as if the features where disabled.
2022-12-12wasm: load+store simd immediate valuesLuuk de Gram
This implements loading and storing immediate values representing a vector with exactly 128 bits. When the vector does not equal to 128 bits, or when the simd128 or relaxed-simd features are disabled the value will be treated as an array instead.
2022-12-09Eliminate `BoundFn` type from the languageVeikka Tuominen
Closes #9484
2022-12-04wasm codegen: fix some missing Liveness reapsAndrew Kelley
I did not do a full audit, but I did notice a few issues which are resolved in this commit. Probably it would be worth adding debug infrastructure to assert that the number of reaps equals the number of calls to resolveInst() per air lowering function.
2022-12-03Merge pull request #13744 from Vexu/stage2-fixesAndrew Kelley
Improve error messages, fix dependency loops
2022-12-03Sema: fix comparisons between lazy and runtime valuesVeikka Tuominen
Closes #12498
2022-12-02dwarf: pass linker Tag and owner Decl.Index instead of *AtomJakub Konka
2022-12-02dwarf: use common DI union object for arg and var genJakub Konka
2022-12-01dwarf: move Wasm specific dwarf gen out of codegenJakub Konka
2022-11-30codegen: support generating packed structsLuuk de Gram
2022-11-30wasm: Fix pointer to field of packed structLuuk de Gram
When requesting a pointer to a field of a packed struct (of which is not byte-aligned), we simply provide the address of the packed struct itself.
2022-11-30wasm: support non-natural alignment in load/storeLuuk de Gram
This implements support for loading and storing where the lhs is of pointer type with host_size != 0. e.g. when loading a specific field from a packed struct with a non-byte alignment such as (0:1:3).
2022-11-30wasm: airAggregateInit - Support packed structsLuuk de Gram
This allows the Wasm backend to construct an instance of a packed struct during runtime. We first allocate a local, and then shift+or each field's value into the result local. We then finally return this result local as value. The commit also fixes a type-issue in `airElemVal` where we used the element type instead of a pointer type to store the value's address into.
2022-11-30wasm: support passing packed struct over C-ABILuuk de Gram
This also adds support loading a runtime pointer from a packed struct. Also, this commit improves many utility functions such as `trunc` and `intcast` to also support non-integer types such as booleans.
2022-11-30wasm: airStructFieldPtr - Support packed structsLuuk de Gram
Simplifies the airStructFieldPtr(index) functions to only obtain the correct struct type and field index, which is then passed into the structFieldPtr function. This function now calculates the byte-offset of the field's address and returns a new `WValue` with this offset. This means we only have to do this calculation in a single function, and no longer have to duplicate any logic. This also handles both regular (tagged) unions and packed unions.
2022-11-30wasm: airStructFieldVal - Support packed structsLuuk de Gram
This implements loading a field from a packed struct, regardless of its field's type. This means it supports pointers, floats and integers. The commit also extracts the logic from airTrunc into its own `trunc` function so it can be re-used.
2022-11-30wasm: Support bitcasting between floats and intsLuuk de Gram
2022-11-30wasm: add support packed structs in lowerConstantLuuk de Gram
When lowering constants of packed structs, which are smaller than 65 bits, we lower the value to an integer rather than store it in the constant data section. This allows us to use an immediate value, for quick loads and stores.
2022-11-29std.mem.Allocator: allow shrink to failAndrew Kelley
closes #13535
2022-10-27Sema: use `runtime_value` instead of creating allocsVeikka Tuominen