416 Commits

Author SHA1 Message Date
Auguste Rame
1e310d3350
Finish shuffle, fix arrayElemVal for vectors 2023-04-07 20:35:15 -04:00
Auguste Rame
d5511b35a9
Make airShuffle work for unrolled 2023-04-07 19:07:48 -04:00
Luuk de Gram
4ebf483e0d
Merge pull request #14668 from Techatrix/wasm-floatops
wasm: implement float operations with compiler-rt
2023-04-07 18:22:41 +02:00
Andrew Kelley
48f98494fd
Merge pull request #15195 from mlugg/fix/liveness-loop-defer-deaths
Liveness: defer deaths of externally-scoped instructions in loop bodies
2023-04-07 11:12:44 -04:00
Auguste Rame
dac62424f9 Make self-hosted wasm @returnAddress return 0 2023-04-07 14:59:22 +03:00
mlugg
1059b57898
Liveness: defer deaths of externally-scoped instructions in loop bodies 2023-04-07 01:29:20 +01:00
Robin Voetter
3357c59ceb new builtins: @workItemId, @workGroupId, @workGroupSize
* @workItemId returns the index of the work item in a work group for a
  dimension.
* @workGroupId returns the index of the work group in the kernel dispatch for a
  dimension.
* @workGroupSize returns the size of the work group for a dimension.

These builtins are mainly useful for GPU backends. They are currently only
implemented for the AMDGCN LLVM backend.
2023-03-30 12:20:24 +03:00
Jakub Konka
0dc210f950 link: pass expected lib name as hint in getGlobalSymbol() 2023-03-28 12:28:48 +02:00
Techatrix
8ec7723992 wasm: implement float operations with compiler-rt 2023-03-26 22:48:56 +02:00
Jacob Young
3f4569bf18 codegen: fix backend breakage due to optional layout change 2023-03-21 08:49:54 +01:00
Luuk de Gram
09d6938df9
wasm: add atomics opcodes and refactoring
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-18 20:13:30 +01:00
Andrew Kelley
e7f128c205
Merge pull request #14782 from r00ster91/trap
add `@trap` builtin
2023-03-04 16:20:31 -05:00
r00ster91
4eb3f50fcf Wasm @breakpoint: emit unreachable
This should improve the developer debugging experience.
2023-03-04 12:08:23 +01:00
r00ster91
65368683ad add @trap builtin
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-04 12:08:19 +01:00
Jakub Konka
dc709fbf48 codegen: rename GenerateSymbolError to CodeGenError 2023-03-03 18:56:57 +01:00
Jakub Konka
c746cbc686 codegen: move gen logic for typed values, consts and decl ref to common codegen 2023-03-03 18:06:25 +01:00
Isaac Freund
05da5b32a8 Sema: implement @fieldParentPtr for unions 2023-02-21 15:57:13 +02:00
Veikka Tuominen
f10950526e implement writeToMemory/readFromMemory for pointers 2023-02-19 13:54:52 -05:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Luuk de Gram
c9b957c937 link: remove FnData and make it self-owned
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-03 22:55:46 +01:00
Jakub Konka
304420b99c
Merge pull request #14502 from ziglang/link-owned-atoms
link: move ownership of linker atom from frontend to the linkers
2023-02-02 01:39:01 +01:00
Jakub Konka
beb20d29db link: remove union types which are now internal to backends 2023-02-01 19:32:54 +01:00
Luuk de Gram
46f54b23ae
link: make Wasm atoms fully owned by the linker 2023-02-01 19:10:56 +01:00
Jakub Konka
5de2aae63c link: decouple DI atoms from linker atoms, and manage them in Dwarf linker 2023-02-01 15:03:55 +01:00
Techatrix
47ff57ed7d wasm: apply request change 2023-01-31 17:01:56 +01:00
Techatrix
1f64432196 wasm: correctly handle optional slices 2023-01-31 00:59:18 +01:00
Luuk de Gram
b25efb86e1
wasm: migrate to new non-allocateDeclIndexes API 2023-01-27 19:24:15 +01:00
Jakub Konka
a95d58caf2 self-hosted: rename codegen Result.appended to Result.ok 2023-01-25 10:28:18 +01:00
Jakub Konka
4983da40d0 self-hosted: remove unused externally_managed prong for Decls code 2023-01-25 10:10:50 +01:00
Veikka Tuominen
4e64373fc0 fix generic function arg debug info referencing wrong parameter
Closes #14123
2022-12-30 17:00:50 +02:00
Luuk de Gram
0d66112643 wasm: refactor extended instructions
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-21 17:02:53 +01:00
Andrew Kelley
aca9c74e80
Merge pull request #13914 from Vexu/variadic
implement defining C variadic functions
2022-12-18 16:24:13 -05:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
Veikka Tuominen
9bb1104e37 implement defining C variadic functions 2022-12-17 13:22:09 +02:00
Veikka Tuominen
8a0a6b7387 port packed vector elem ptr logic from stage1
Closes #12812
Closes #13925
2022-12-15 21:06:35 -05:00
Andrew Kelley
6378644d4e
Merge pull request #13907 from Vexu/call-merge
Remove `stack` option from `@call`
2022-12-13 18:15:18 -05:00
Veikka Tuominen
7b2a936173 remove stack option from @call 2022-12-13 12:52:21 +02:00
Luuk de Gram
355b5929b2
wasm: splat for vector elements divisible by 8
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-12 17:42:00 +01:00
Luuk de Gram
c6d654f73b
wasm: implement the 'splat' instruction part 1
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-12 17:42:00 +01:00
Luuk de Gram
63b69e2c55
wasm: load+store simd immediate values
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-12 17:41:59 +01:00
Veikka Tuominen
9d93b2ccf1 Eliminate BoundFn type from the language
Closes #9484
2022-12-09 20:37:18 -07:00
Andrew Kelley
3a9375cae9 wasm codegen: fix some missing Liveness reaps
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-04 15:57:40 -07:00
Andrew Kelley
fdbb0fb7b9
Merge pull request #13744 from Vexu/stage2-fixes
Improve error messages, fix dependency loops
2022-12-03 00:42:11 -05:00
Veikka Tuominen
0e38cc16d5 Sema: fix comparisons between lazy and runtime values
Closes #12498
2022-12-03 00:09:23 +02:00
Jakub Konka
bfd36cbf97 dwarf: pass linker Tag and owner Decl.Index instead of *Atom 2022-12-02 13:17:52 +01:00
Jakub Konka
3ec0520bac dwarf: use common DI union object for arg and var gen 2022-12-02 12:22:17 +01:00
Jakub Konka
8fea84f77e dwarf: move Wasm specific dwarf gen out of codegen 2022-12-01 20:55:55 +01:00
Luuk de Gram
3933a4bac5
codegen: support generating packed structs 2022-11-30 17:56:02 +01:00
Luuk de Gram
df7ddb475e
wasm: Fix pointer to field of packed struct
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-30 17:56:02 +01:00
Luuk de Gram
6924f21bbd
wasm: support non-natural alignment in load/store
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-30 17:56:02 +01:00