Commit Graph

1537 Commits

Author SHA1 Message Date
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 b822e841cd, reversing
changes made to 0c99ba1eab.

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
Andrew Kelley
ecfb18286a migrate make_ptr_const to new anonymous decl mechanism
Instead of creating Module.Decl objects, directly create InternPool
pointer values using the anon_decl Addr encoding.

The LLVM backend needed code to notice the alignment of the pointer and
lower accordingly. The other backends likely need a similar change.
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
Jacob Young
4d106076c3 link: initialize llvm before calling the llvm API 2023-10-19 16:51:11 -04:00
Jacob Young
fbbccc9d5f Builder: fix incorrect type for 32-bit systems 2023-10-19 08:06:44 -04: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
Robin Voetter
0552e504d0 spirv: work around OpSource parsing issue in llvm-spirv
The Khronos SPIRV-LLVM translator does not parse OpSource correctly. This
was causing tests to fail and other mysterious issues.

These are resolved by only generating a single OpSource instruction for now,
which does not have the source file locations also.

See https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2188
2023-10-15 17:07:39 +02: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
Robin Voetter
31ad2d72a7 spirv: use CacheString for source_file_names instead of []const u8 2023-10-15 13:59:26 +02:00
Robin Voetter
a3d77bdba9 spirv: get rid of SpvModule arena 2023-10-15 13:59:25 +02:00
Robin Voetter
ab701c3d37 spirv: anon decl refs 2023-10-15 13:59:24 +02:00
Robin Voetter
08ea9a9ff6 spirv: cast result of .elem pointers to right type if needed 2023-10-15 13:59:23 +02:00
Robin Voetter
a7c3d5e4ec spirv: constant elem ptr fix 2023-10-15 13:59:22 +02:00
Robin Voetter
4ea361f6dc spirv: lower pointers to zero-bit types as undef 2023-10-15 13:59:22 +02:00
Robin Voetter
4e22f811e7 spirv: opaque types 2023-10-15 13:59:20 +02:00
Andrew Kelley
ab4d6bf468 LLVM: work around @floatFromInt bug
see #17381
2023-10-14 00:33:46 -07:00
Andrew Kelley
69dc1a6bb2 llvm: fix incorrect file paths in debug info
The previous code incorrectly added `sub_path` twice.

Also for the compilation unit, it was passing empty string to realpath,
resulting in the error handling codepath being used.

closes #17482
2023-10-13 03:07:50 -07:00
Andrew Kelley
aaf46187ab Merge pull request #17391 from xxxbxxx/load-i4
codegen/llvm: truncate padding bits when loading a non-byte-sized value
2023-10-09 22:06:49 -07:00