62 Commits

Author SHA1 Message Date
Robin Voetter
8a00ec162c
spirv: more fixes and improvements
- Formatting.
- Improve `decorate` helper function to generate a decoration for a result-id.
- Reorder some functions in a more logical way
2023-04-09 01:51:51 +02:00
Robin Voetter
700dee34d5
spirv: make IdResultType and IdRef weak aliases of IdResult
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.
2023-04-09 01:51:51 +02:00
Robin Voetter
0c2526b18e
spirv: some fixes and improvements
- 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.
2023-04-09 01:51:50 +02:00
Robin Voetter
e443b1bed7
spirv: switch_br lowering
Implements lowering switch statements in the SPIR-V backend.
2023-04-09 01:51:50 +02:00
Robin Voetter
3f92eaceb6
spirv: array, structs, bitcast, call
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.
2023-04-09 01:51:49 +02:00
Robin Voetter
dae8b4c11f
spirv: emit OpName for some primitive types
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.
2023-04-09 01:51:49 +02:00
Robin Voetter
3eafe3033e
spirv: improve storage efficiency for integer and float 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?
2023-04-09 01:51:48 +02:00
Robin Voetter
5826a8a064
spirv: make Type.Ref stronger
Making Type.Ref an unbounded enum rather than a simple integer
ensures that we don't accidently confuse this token for another type.
2023-04-09 01:51:48 +02:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Robin Voetter
074ba69ba6
spirv: assembler
spirv: introduce SpvModule.Fn to generate function code into

spirv: assembler error message setup

spirv: runtime spec info

spirv: inline assembly tokenizer

spirv: inline assembly lhs result/opcode parsing

spirv: forgot to fmt

spirv: tokenize opcodes and assigned result-ids

spirv: operand parsing setup

spirv: assembler string literals

spirv: assembler integer literals

spirv: assembler value enums

spirv: assembler bit masks

spirv: update assembler to new asm air format

spirv: target 1.5 for now

Current vulkan sdk version (1.3.204) ships spirv tools targetting 1.5,
and so these do not work with binaries targetting 1.6 yet. In the
future, this version number should be decided by the target.

spirv: store operands in flat arraylist.

Instead of having dedicated Operand variants for variadic operands,
just flatten them and store them in the normal inst.operands list.
This is a little simpler, but is not easily decodable in the operand
data representation.

spirv: parse variadic assembly operands

spirv: improve assembler result-id tokenization

spirv: begin instruction processing

spirv: only remove decl if it was actually allocated

spirv: work around weird miscompilation

Seems like there are problems with switch in anonymous struct literals.

spirv: begin resolving some types in assembler

spirv: improve instruction processing

spirv: rename some types + process OpTypeInt

spirv: process OpTypeVector

spirv: process OpTypeMatrix and OpTypeSampler

spirv: add opcode class to spec, remove @exclude'd instructions

spirv: process more type instructions

spirv: OpTypeFunction

spirv: OpTypeOpaque

spirv: parse LiteralContextDependentNumber operands

spirv: emit assembly instruction into right section

spirv: parse OpPhi parameters

spirv: inline assembly inputs

spirv: also copy air types

spirv: inline assembly outputs

spirv: spir-v address spaces

spirv: basic vector constants/types and shuffle

spirv: assembler OpTypeImage

spirv: some stuff

spirv: remove spirv address spaces for now
2022-11-23 19:17:58 +01:00
Robin Voetter
98ee39d1b0 spirv: spir-v dedicated type system 2022-01-28 14:45:23 +01:00
Robin Voetter
1b6ebce0da spirv: new module
This introduces a dedicated struct that handles module-wide information.
2022-01-28 14:38:58 +01:00