1262 Commits

Author SHA1 Message Date
Andrew Kelley
3116477dcc stage2: move empty struct type and value to InternPool 2023-06-10 20:42:30 -07:00
Andrew Kelley
4d88f825bc stage2: implement intTagType logic
This commit changes a lot of `*const Module` to `*Module` to make it
work, since accessing the integer tag type of an enum might need to
mutate the InternPool by adding a new integer type into it.

An alternate strategy would be to pre-heat the InternPool with the
integer tag type when creating an enum type, which would make it so that
intTagType could accept a const Module instead of a mutable one,
asserting that the InternPool already had the integer tag type.
2023-06-10 20:42:29 -07:00
Andrew Kelley
a5fb169594 stage2: bug fixes related to Type/Value/InternPool 2023-06-10 20:42:29 -07:00
mlugg
2ffef605c7 Replace uses of Value.zero, Value.one, Value.negative_one
This is a bit nasty, mainly because Type.onePossibleValue is now
errorable, which is a quite viral change.
2023-06-10 20:42:29 -07:00
mlugg
c1ca16d779 wip: progress towards compiling tests 2023-06-10 20:42:29 -07:00
Andrew Kelley
75900ec1b5 stage2: move integer values to InternPool 2023-06-10 20:42:29 -07:00
Andrew Kelley
f7bd42785b LLVM backend: update integer constant lowering for InternPool 2023-06-10 20:42:29 -07:00
Andrew Kelley
31aee50c1a InternPool: add a slice encoding
This uses the data field to reference its pointer field type, which
allows for efficient and infallible access of a slice type's pointer
type.
2023-06-10 20:42:29 -07:00
Andrew Kelley
9ec0017f46 stage2: migrate many pointer types to the InternPool 2023-06-10 20:42:28 -07:00
Andrew Kelley
6ab8b6f8b2 stage2: move undef, unreach, null values to InternPool 2023-06-10 20:42:28 -07:00
Andrew Kelley
5e636643d2 stage2: move many Type encodings to InternPool
Notably, `vector`.

Additionally, all alternate encodings of `pointer`, `optional`, and
`array`.
2023-06-10 20:42:27 -07:00
Andrew Kelley
9d422bff18 stage2: move all integer types to InternPool 2023-06-10 20:40:04 -07:00
Andrew Kelley
85c69c5194 Type.isSlice: make it InternPool aware 2023-06-10 20:40:04 -07:00
Andrew Kelley
ca3cf93b21 stage2: move most simple values to InternPool 2023-06-10 20:40:04 -07:00
Andrew Kelley
836d8a1f64 stage2: move most simple types to InternPool 2023-06-10 20:40:04 -07:00
Andrew Kelley
bcd4bb8afb stage2: move named int types to InternPool 2023-06-10 20:40:04 -07:00
Andrew Kelley
4cd8a40b3b stage2: move float types to InternPool 2023-06-10 20:40:03 -07:00
Andrew Kelley
aa1bb5517d InternPool: implement isSinglePointer 2023-06-10 20:40:03 -07:00
Andrew Kelley
00f82f1c46 stage2: add interned AIR tag
This required additionally passing the `InternPool` into some AIR
methods.

Also, implement `Type.isNoReturn` for interned types.
2023-06-10 20:40:03 -07:00
Andrew Kelley
9aec2758cc stage2: start the InternPool transition
Instead of doing everything at once which is a hopelessly large task,
this introduces a piecemeal transition that can be done in small
increments at a time.

This is a minimal changeset that keeps the compiler compiling. It only
uses the InternPool for a small set of types.

Behavior tests are not passing.

Air.Inst.Ref and Zir.Inst.Ref are separated into different enums but
compile-time verified to have the same fields in the same order.

The large set of changes is mainly to deal with the fact that most Type
and Value methods now require a Module to be passed in, so that the
InternPool object can be accessed.
2023-06-10 20:40:03 -07:00
David Gonzalez Martin
c16d4ab9e4 llvm: stop generating FPU code if there is no FPU
Fixes https://github.com/ziglang/zig/issues/14465

For aarch64, LLVM was crashing because Zig commands it to generate FPU code
even when there is no FPU present. This commit implements the necessary checks
to avoid this undesired situation and aarch64 can be compiled again with
no FPU.
2023-06-06 18:30:56 +00:00
Robin Voetter
3c4cc1eedb
spirv: eliminate remaining uses of emitConstant 2023-05-30 19:43:37 +02:00
Robin Voetter
0c41945a01
spirv: rename TypeConstantCache -> Cache 2023-05-30 19:43:37 +02:00
Robin Voetter
0552a8b11f
spirv: translate remaining types 2023-05-30 19:43:37 +02:00
Robin Voetter
fcb422585c
spirv: translate remaining types 2023-05-30 19:43:37 +02:00
Robin Voetter
112acb1bda
spirv: cache strings for debug names 2023-05-30 19:43:37 +02:00
Robin Voetter
a72179fed0
spirv: translate structs to cache key 2023-05-30 19:43:37 +02:00
Robin Voetter
05f1392d8b
spirv: translate vectors to cache key 2023-05-30 19:43:37 +02:00
Robin Voetter
f13a6ee19e
spirv: cache pointers 2023-05-30 19:43:36 +02:00
Robin Voetter
e05ace7673
spirv: cache function prototypes 2023-05-30 19:43:36 +02:00
Robin Voetter
8c72ad5320
spirv: cache for ints 2023-05-30 19:43:36 +02:00
Robin Voetter
aade6f1195
spirv: cache for floats 2023-05-30 19:43:36 +02:00
Robin Voetter
b2a984cda6
spirv: basic setup for using new type constant cache 2023-05-30 19:43:36 +02:00
Robin Voetter
96a66d14a1
spirv: TypeConstantCache 2023-05-30 19:43:36 +02:00
Veikka Tuominen
ca16f1e8a7 std.Target adjustments
* move `ptrBitWidth` from Arch to Target since it needs to know about the abi
* double isn't always 8 bits
* AVR uses 1-byte alignment for everything in GCC
2023-05-26 21:42:19 -07:00
Veikka Tuominen
4a3539e449 llvm: fix vector type in vector_store_elem
Closes #15848
2023-05-25 15:57:30 +03:00
Ali Chraghi
3db3cf7790 std.sort: add pdqsort and heapsort 2023-05-23 17:55:59 -07:00
Veikka Tuominen
4ce1ae71a5
Merge pull request #15235 from Vexu/safety
add runtime safety for noreturn function returning
2023-05-23 13:34:52 +03:00
Tw
a0652fb930 llvm: also generate metadata for extern global variables
Signed-off-by: Tw <tw19881113@gmail.com>
2023-05-22 23:04:19 +03:00
Andrew Kelley
7621e56938
Merge pull request #15753 from Snektron/spirv-more-tests
spirv: make more tests pass
2023-05-20 13:54:01 -07:00
Robin Voetter
c92cc5798f
spirv: make constant handle float, errorset, errorunion
This is in preparation of removing indirect lowering again. Also
modifies constant() to accept a repr so that both direct as well
as indirect representations can be generated. Indirect is not yet
used, but will be used for globals.
2023-05-20 18:02:30 +02:00
Robin Voetter
d7ddaf64a2 spirv: don't generate union tag type if it doesnt exist
Previously the tag type was generated even if it was nonexistant,
triggering an assertion that an integer type should never have
zero bits. Now its only generated when the tag type is actually emitted.
2023-05-20 08:48:38 -07:00
Robin Voetter
65157d30ab
spirv: ptr_elem_val
Implements the ptr_elem_val air tag. Implementation is unified
with ptr_elem_ptr.
2023-05-20 17:30:23 +02:00
Robin Voetter
77b8bf2b82
spirv: ptr_sub
Implments the ptr_sub air tag. The code is unified with that of ptr_add.
2023-05-20 17:30:22 +02:00
Robin Voetter
2f28713bd7
spirv: pointer bitcasting 2023-05-20 17:30:22 +02:00
Robin Voetter
4203d099be
spirv: lower integer pointer constants 2023-05-20 17:30:22 +02:00
Robin Voetter
64f99f36a6
spirv: ptr_add
Implements the ptr_add air tag for spirv.

The implementation for slices is probably wrong, but there seems to be no test for this...
2023-05-20 17:30:22 +02:00
Robin Voetter
3c14438a93
spirv: use extractField more
reduce some code duplication
2023-05-20 17:30:21 +02:00
Robin Voetter
6c05557072
spirv: fix some (Ptr)AccessChain uses
The first dereference of PtrAccessChain returns a pointer of the same type
as the base pointer, in contrast to AccessChain, where the first dereference
returns a pointer of the dereferenced type of the base pointer.
2023-05-20 17:30:21 +02:00
Robin Voetter
0ba0d8fecb
spirv: dont use OpIAddCarry
This instruction is not really working well in the LLVM SPIRV translator,
as it is not implemented.

This commit also intruces the constructStruct helper function to initialize
structs at runtime. This is ALSO buggy in the translator, and we must work
around OpCompositeConstruct not working when some of the constituents are
runtime-known only.

Some other improvements are made:
- improved variable() so that it is more useful and no longer requires the
  address space. It always puts values in the Function address space,
  and returns a pointer to the Generic address space
- adds a boolToInt utility function
2023-05-20 17:30:21 +02:00