| Age | Commit message (Collapse) | Author |
|
AmdgpuKernel and NvptxKernel are unified into a Kernel calling convention.
There is really no reason for these to be separate; no backend is allowed to
emit the calling convention of the other. This is in the same spirit as the
.Interrupt calling convention lowering to different LLVM calling conventions,
and opens the way for SPIR-V kernels to be exported using the Kernel calling
convention.
|
|
Also actually implement generating the OpEntryPoint instructions.
|
|
Entry points need to be attributed with a complete list of
global variables that they use. To that end, the global dependencies
mechanism is extended to also allow functions - when flushing the
module, the list of dependencies is examined to generate this
list of global variable result-ids.
|
|
SPIR-V cannot represent function pointers without extensions
that no vendor implements. For the time being, generate a test
kernel for each error, so that we can at least run SOME tests.
In the future we may be able to emulate function pointers in some
way, but that is not today.
|
|
Implements lowering types and constants for error sets and error unions.
|
|
SPIR-V globals must be emitted in order, so that any
declaration precedes usage. Zig, however, generates globals in
random order. To this end we keep for each global a list of
dependencies and perform a topological sort when flushing the
module.
|
|
Lowering constants is currently not really compatible with unions. In
this commit, constant lowering is drastically overhauled: instead of
playing nice and generating SPIR-V constant representations for everything
directly, we're just going to treat globals as an untyped bag of bytes (
or rather, SPIR-V 32-bit words), which we cast to the desired type at
usage. This is similar to how Rust generates constants in its LLVm backend.
|
|
Implements lowering union types and constants in the SPIR-V backend.
|
|
Implements lowering optional constants in the SPIR-V backend.
|
|
This little wrapper function allocates a result-id for us,
so that we don't have to do that.
|
|
Implements lowering slice constants in the SPIR-V backend
|
|
Implements lowering string literal constants in the SPIR-V backend
|
|
Implements lowering optional types in the SPIR-V backend.
|
|
Similar to function locals, taking the address of a global that does
not have an explicit address space assigned to it should result
in a generic pointer, not a global pointer. Also similar to function
locals, they cannot be generated into the generic storage class, and
so are generated into the global storage class and then cast to a
generic pointer, using OpSpecConstantOp. Note that using
OpSpecConstantOp results is only allowed by a hand full of other
OpSpecConstant instructions - which is why we generate constant
structs using OpSpecConstantComposite: These may use OpVariable
and OpSpecConstantOp results, while OpConstantComposite may not.
|
|
Starts lowering decl_ref Pointer constants.
|
|
This cloneAir/cloneLiveness idea used to ignore Zig's internals
has proven buggy. Instead, just generate the code directly from
updateFunc and updateDecl as the other backends do, but pretend
that Zig is not an incremental compiler. The SPIR-V backend will
for the time being not support this.
|
|
Start to lower decls which are not functions. These generate
an OpVariable instruction by which they can be used later on.
|
|
Bools have a different immediate representation and memory
representation - which means that they must be converted every time
a bool is loaded from or stored into memory.
|
|
Taking the address of a local variable should result in a generic
pointer - too much code breaks if we do not do this. We cannot
lower locals into the generic storage class directly though, so
instead, lower the variables into the Function storage class
implicitly, and convert the pointer to a generic pointer.
Also Correct OpInboundsAccessChain generation (we only need
the one index).
|
|
There are two main ways in which a value can be stored: "Direct", as it
will be operated on as an immediate value, and "indirect", as it is stored
in memory. Some types need a different representation here: Bools, for
example, are opaque in SPIR-V, and so these need to have a different
representation in memory. The bool operations are not easily interchangable
with integer operations, though, so they need to be OpTypeBool as
immediate value.
|
|
- Formatting.
- Improve `decorate` helper function to generate a decoration for a result-id.
- Reorder some functions in a more logical way
|
|
Previously they were strong aliases, but as these types are used quite
intermittendly it resulted in a lot of toRef() calls. Removing them
improves readability a bit.
|
|
- Adds the Int8. Int16, Int64 and GenericPointer capabilities.
TODO: This should integrate with the feature system.
- Default some struct fields of SPIR-V types so that we dont
need to type them all the time.
- Store struct field name's in SPIR-V types, and generate the
OpMemberName decoration if they are non-null.
- Also add the field names to the actual SPIR-V types.
- Generate OpName for functions.
|
|
Implements lowering switch statements in the SPIR-V backend.
|
|
Implements the AIR left_shift operation for the SPIR-V backend.
|
|
Implements the ptr_elem_ptr and struct_field_ptr_index_* AIR instructions
for the SPIR-V backend.
|
|
Implements the div-family and intcast AIR instructions, and starts
implementing a mechanism for masking the value of 'strange' integers
before they are used in an operation that does not hold under modulo.
|
|
Starts implementing constant lowering for some array and struct constants.
In particular, TODO are packed structs.
|
|
Implements lowering for enum constants, as well as the struct_field_val,
ret_ptr, and ret_load AIR instructions.
|
|
Implements lowering for the add_with_overflow AIR instructions. Also implements
a helper function, simpleStructType, to quickly generate a SPIR-V structure type
without having to do the whole allocation dance.
|
|
This commit adds support for SPIR-V code generation for the following AIR
instructions:
- slice_ptr
- slice_len
- slice_elem_ptr
- slice_elem_val
|
|
When a result of a pure instruction is not used, it also does not need to
be generated. The other backends already implement these checks, they were
ignored in SPIR-V up until now. New instructions added in the future should
have these be implemented from the start.
|
|
Implements type lowering for slices.
|
|
Implements type lowering for arrays and structs, and implements instruction
lowering for bitcast and call. Bitcast currently naively maps to the OpBitcast
instruction - this is only valid for some primitive types, and should be
improved to work with composites.
|
|
OpName instructions assign a debug name to a type. Some basic
types - bool, void, ints, and floats are given a debug name this way.
TODO is to extend this to the other types.
|
|
In practice there are only a few variations of these types allowed, so it
kind-of makes sense to write them all out. Because the types are hashed this
does not actually save all that many bytes in the long run, though. Perhaps
some of these types should be pre-registered?
|
|
Making Type.Ref an unbounded enum rather than a simple integer
ensures that we don't accidently confuse this token for another type.
|
|
This gives the spir-v backend the power to emit enum types. These
are simply lowered to their backing integer type.
|
|
This allows the Zig calling convention and makes way for a Kernel
calling convention in the future. Any future checks on calling
conventions should be placed in Sema.zig.
|
|
Also fix the many revealed bugs.
|
|
|
|
|
|
|
|
This lets us generate the store with knowledge of the type to be stored.
Therefore, we can avoid generating garbage Air with stores through
pointers to comptime-only types which backends cannot lower.
Closes #13410
Closes #15122
|
|
* @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.
|
|
As bpf program has no global section for constant values (especially strings),
so use llvm's builtins (like memcpy, memset, etc) will lead to compilation failure
(something like this: A call to built-in function 'memcpy' is not supported.)
Signed-off-by: Tw <tw19881113@gmail.com>
|
|
The result of buildStructGEP is not always a GEP (sorry), so we can't
use getGEPResultElementType on it.
Closes #14641
|
|
We just checked that inst_child_ty was effectively a zero-bit type, so
it is certainly not the non-zero alignment we are looking for.
Closes #15085
|
|
fixes `error(compilation): clang failed with stderr: error: array type 'uint32_t[10]' (aka 'unsigned int[10]') is not assignable`
|
|
Closes #14980
|