285 Commits

Author SHA1 Message Date
Robin Voetter
403c6262bb
spirv: use new vector stuff for arithOp and shift 2024-02-04 19:09:18 +01:00
Robin Voetter
cb9e20da00
spirv: element-wise operation helper 2024-02-04 19:09:00 +01:00
Robin Voetter
747f4ae3f5
spirv: sh[rl](_exact)? 2024-02-04 19:08:59 +01:00
mlugg
9eda6ccefc InternPool: use separate key for slices
This change eliminates some problematic recursive logic in InternPool,
and provides a safer API.
2024-02-02 11:02:03 +00:00
Veikka Tuominen
7d75c3d3b8 llvm: ensure returned undef is 0xaa bytes when runtime safety is enabled
Closes #13178
2024-01-29 17:35:07 -08:00
Andrew Kelley
33cdf33b95 compiler: update many references to bin_file.options 2024-01-01 17:51:19 -07:00
Jacob Young
daf91ed8d1 Air: use typesafe Air.Inst.Index
I need some indices for a thing...
2023-12-03 02:05:06 -08:00
Meghan Denny
2549de80b2 move Module.Decl.Index and Module.Namespace.Index to InternPool 2023-11-26 02:24:40 -05:00
Techatrix
18608223ef convert toType and toValue to Type.fromInterned and Value.fromInterned 2023-11-25 04:09:53 -05:00
Robin Voetter
decff51238
spirv: structured control flow 2023-11-24 17:50:11 +01:00
Robin Voetter
b4b1c4df64
spirv: add -fstructured-cfg option
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-24 11:40:18 +01:00
mlugg
b355893438
compiler: correct unnecessary uses of 'var' 2023-11-19 11:11:49 +00:00
mlugg
20bb81166f
InternPool: remove runtime_value representation
The main goal of this commit is to remove the `runtime_value` field from
`InternPool.Key` (and its associated representation), but there are a
few dominos. Specifically, this mostly eliminates the "maybe runtime"
concept from value resolution in Sema: so some resolution functions like
`resolveMaybeUndefValAllowVariablesMaybeRuntime` are gone. This required
a small change to struct/union/array initializers, to no longer
use `runtime_value` if a field was a `variable` - I'm not convinced this
case was even reachable, as `variable` should only ever exist as the
trivial value of a global runtime `var` decl.

Now, the only case in which a `Sema.resolveMaybeUndefVal`-esque function
can return the `variable` key is `resolveMaybeUndefValAllowVariables`,
which is directly called from `Sema.resolveInstValueAllowVariables`
(previously `Sema.resolveInstValue`), which is only used for resolving
the value of a Decl from `Module.semaDecl`.

While changing these functions, I also slightly reordered and
restructured some of them, and updated their doc comments.
2023-10-24 14:28:33 +01:00
Robin Voetter
4bf27da6a6 Revert "Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs""
This reverts commit 9f0359d78f9facc38418e32b0e8c1bf6f99f0d26 in an attempt to
make the tests pass again. The CI failure from that merge should be unrelated
to this commit.
2023-10-23 06:27:12 -04:00
Andrew Kelley
94d61ce964
Merge pull request #17651 from Vexu/error-limit
Make distinct error limit configurable (attempt #2)
2023-10-23 03:19:03 -04:00
Andrew Kelley
9f0359d78f Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs"
This reverts commit b822e841cda0adabe3fec260ff51c18508f7ee32, reversing
changes made to 0c99ba1eab63865592bb084feb271cd4e4b0357e.

This caused a CI failure when it landed in master branch.
2023-10-22 12:15:31 -07:00
Robin Voetter
b822e841cd
Merge pull request #17657 from Snektron/spirv-recursive-ptrs
spirv: recursive pointers
2023-10-22 15:35:00 +02:00
Veikka Tuominen
9d9e22e716 remove uses of non-configurable err_int 2023-10-22 14:29:26 +03:00
Andrew Kelley
7bab406c79 InternPool: store alignment of anon decls
Commit 5393e56500d499753dbc39704c0161b47d1e4d5c has a flaw pointed out
by @mlugg: the `ty` field of pointer values changes when comptime values
are pointer-casted. This commit introduces a new encoding which
additionally stores the "original pointer type" which is used to store
the alignment of the anonymous decl, and potentially other information
in the future such as section and pointer address space. However, this
new encoding is only used when the original pointer type differs from
the casted pointer type in a meaningful way.

I was able to make the LLVM backend and the C backend lower anonymous
decls with the appropriate alignment, however I will need some help
figuring out how to do this for the backends that lower anonymous decls
via src/codegen.zig and the wasm backend.
2023-10-21 21:38:41 -04:00
Robin Voetter
6281ad91df
spirv: self-referential pointers via new fwd_ptr_type
Its a little ugly but it works.
2023-10-21 17:46:54 +02:00
Robin Voetter
6e955af8c8
spirv: make constructStruct also use self.ptrType
This completes the migration from spv.ptrType to self.ptrType.
Unfortunately this requires us to pass a list of types to
constructStruct, which also requires some extra allocations
here and there.
2023-10-21 17:46:53 +02:00
Robin Voetter
1deec09f03
spirv: improve union operations
This removes the strategy where union with different active
fields would be generated, and instead simply pointer casts
the active field type where required. This also allows removing
spv.ptrType and using self.ptrType instead, and allows caching
all union types (because there is only the canonical one).
2023-10-21 17:46:53 +02:00
Robin Voetter
5090d75e48
spirv: make load() and store() accept MemoryOptions
This struct is used to configure the load, such as to make
it volatile. Previously this was done using a single bool, but
this struct makes it shorter to write non-volatile loads (the
usual) and more clear whats going on when a volatile load is
required.
2023-10-21 17:46:52 +02:00
Robin Voetter
200bca360e
spirv: replace most use of spv.ptrType with self.ptrType
To support self-referential pointers, in the future we will
need to pass the Zig type to any pointer that is created. This
lays some ground work for that by replacing most uses of
spv.ptrType with a new ptrType function that also accepts the
Zig type. This function's contents will soon be replaced by
a version that also supports self-referential pointers.

Also fixed some bugs regarding the use of direct/indirect.
2023-10-21 17:46:50 +02:00
Robin Voetter
c3120d5089
Merge pull request #17577 from alichraghi/spirv-1
spirv: switch on bool
2023-10-18 16:28:13 +02:00
Robin Voetter
24b065a6a8
Merge pull request #17561 from alichraghi/spirv-0
spirv: memcpy
2023-10-18 15:38:30 +02:00
Ali Chraghi
e5d5c1d423 spirv: switch on bool 2023-10-18 02:31:16 +03:30
Ali Chraghi
6d8a979265 spirv: memcpy 2023-10-17 13:02:30 +03:30
Ali Chraghi
e44152e252 spirv: fieldParentPtr 2023-10-16 20:27:28 -04:00
Ali Chraghi
45a1945dc4
spirv: simple binary and comparison vector operations 2023-10-15 14:00:33 +02:00
Ali Chraghi
2fe16e072a
spirv: emit vectors as arrays 2023-10-15 14:00:32 +02:00
Robin Voetter
f4064d98e2
spirv: optional comparison 2023-10-15 14:00:31 +02:00
Robin Voetter
10b8171466
spirv: handle errors in switch 2023-10-15 14:00:30 +02:00
Robin Voetter
e2e4e1f8b4
spirv: intcast, trunc for strange ints 2023-10-15 14:00:10 +02:00
Robin Voetter
b1499df1b8
spirv: sign-extension for strange integers 2023-10-15 14:00:09 +02:00
Robin Voetter
4f279078c8
spirv: air min/max 2023-10-15 14:00:07 +02:00
Robin Voetter
f858bf1616
spirv: air bitcast for non-numeric non-pointer types 2023-10-15 14:00:07 +02:00
Robin Voetter
0af16a58a0
spirv: fix air is_null optional slice field type 2023-10-15 14:00:06 +02:00
Robin Voetter
d0e7a3596b
spirv: allow generation of *i0 2023-10-15 14:00:06 +02:00
Robin Voetter
2d52fc762d
spirv: handle zero-sized arrays 2023-10-15 14:00:05 +02:00
Ali Chraghi
d8b591766a
spirv: fpext and fptrunc instructions 2023-10-15 14:00:04 +02:00
Robin Voetter
d2692af8e2
spirv: override function return type to void if it has no runtime bits 2023-10-15 14:00:04 +02:00
Robin Voetter
ae3efab226
spirv: generate *void as pointer to opaque 2023-10-15 14:00:03 +02:00
Robin Voetter
fe51ff9fc1
spirv: make air is_null not emit OpPtr(Not)Equal 2023-10-15 14:00:03 +02:00
Robin Voetter
15cf1315bb
spirv: fix incorrect repr of some optional operations 2023-10-15 14:00:01 +02:00
Robin Voetter
0a3e566f57
spirv: make bitcasts between the same spirv type a no-op 2023-10-15 14:00:01 +02:00
Robin Voetter
c6c5fb40de
spirv: fix float unequality 2023-10-15 14:00:00 +02:00
Robin Voetter
4a6a024a4b
spirv: properly skip comptime function parameters 2023-10-15 14:00:00 +02:00
Robin Voetter
89b1dafa78
spirv: aggregate_init for structs 2023-10-15 13:59:55 +02:00
Robin Voetter
28dda3bf89
spirv: put linkery bits in Object
This structure is used to group information that needs to
persist between decls in codegen.
2023-10-15 13:59:26 +02:00