Commit Graph

30 Commits

Author SHA1 Message Date
Travis Staloch
8af59d1f98 ComptimeStringMap: return a regular struct and optimize
this patch renames ComptimeStringMap to StaticStringMap, makes it
accept only a single type parameter, and return a known struct type
instead of an anonymous struct.  initial motivation for these changes
was to reduce the 'very long type names' issue described here
https://github.com/ziglang/zig/pull/19682.

this breaks the previous API.  users will now need to write:
`const map = std.StaticStringMap(T).initComptime(kvs_list);`

* move `kvs_list` param from type param to an `initComptime()` param
* new public methods
  * `keys()`, `values()` helpers
  * `init(allocator)`, `deinit(allocator)` for runtime data
  * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure
     these belong but have left in for now incase they are deemed useful
* performance notes:
  * i posted some benchmarking results here:
    https://github.com/travisstaloch/comptime-string-map-revised/issues/1
  * i noticed a speedup reducing the size of the struct from 48 to 32
    bytes and thus use u32s instead of usize for all length fields
  * i noticed speedup storing KVs as a struct of arrays
  * latest benchmark shows these wall_time improvements for
    debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full
    output in link above.
2024-04-22 15:31:41 -07:00
Carl Åstholm
4c393c7468 Update usages of fmtId/isValidId
`{}` for decls
`{p}` for enum fields
`{p_}` for struct fields and in contexts following a `.`

Elsewhere, `{p}` was used since it's equivalent to the old behavior.
2024-04-07 14:47:11 +02:00
Robin Voetter
9b18125562
spirv: make generic globals invocation-local 2024-03-18 19:13:50 +01:00
Robin Voetter
20d7bb68ac
spirv: add zig-specific ext inst
This may be removed again in the future...
2024-03-18 19:13:49 +01:00
Robin Voetter
e566158acf
spirv: make IdResult an enum 2024-03-18 19:13:49 +01:00
Robin Voetter
3d5721da23
spirv: update spec generator
For module parsing and assembling, we will also need to know
all of the SPIR-V extensions and their instructions. This commit
updates the generator to generate those. Because there are
multiple instruction sets that each have a separate list of Opcodes,
no separate enum is generated for these opcodes. Additionally, the
previous mechanism for runtime instruction information, `Opcode`'s
`fn operands()`, has been removed in favor for
`InstructionSet.core.instructions()`.

Any mapping from operand to instruction is to be done at runtime.
Using a runtime populated hashmap should also be more efficient
than the previous mechanism using `stringToEnum`.
2024-03-18 19:13:46 +01:00
Ali Chraghi
afa7793351 spirv: basic shader support 2024-02-05 11:55:14 +03:30
Andrew Kelley
ddd8d59188 tools/gen_spirv_spec: fix wrong use of BoundedArray
It incorrectly, was returning an error, when it actually wanted to
assert that the array bounds were not exceeded. Fixed by using ArrayList
instead.
2023-11-22 11:33:34 -07:00
mlugg
026a8278f8
tools: correct unnecessary uses of 'var' 2023-11-19 09:57:04 +00:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Josh Wolfe
32cb9462ff
std: Support user-provided jsonParse method. Unify json.Parser and json.parse* (#15705) 2023-06-19 11:21:37 -04:00
r00ster91
6e84f46990 std: replace builtin.Version with SemanticVersion 2023-06-17 13:17:34 -07:00
Josh Wolfe
018b743c7a
std: Rewrite low-level json api to support streaming (#15602) 2023-05-13 14:31:53 -04: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
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
Stevie Hryciw
04f3067a79 run zig fmt on everything checked by CI 2022-11-18 19:22:42 +00:00
Veikka Tuominen
62ff8871ed stage2+stage1: remove type parameter from bit builtins
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
Veikka Tuominen
cbd5d6c704 spirv spec: do not align packed struct fields 2022-02-24 19:48:34 +02:00
Robin Voetter
ff042e8006 spirv: improve generator
The spirv spec generator now also generates some support information:
Opcode gains a function to query a Zig type representing the operands
of the opcode. The idea is that this will enable a richer interface for
emitting spirv instructions.
2022-01-28 14:38:57 +01:00
Lee Cannon
1093b09a98
allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
Lee Cannon
75548b50ff
allocgate: stage 1 and 2 building 2021-11-30 23:32:47 +00:00
LemonBoy
ff79b87fa0 tools: Unbreak many tools
Many tools were broken after the recent hash-table refactorings, fix
them and ensure they won't silently break again.
2021-06-13 15:25:18 -04:00
Andrew Kelley
138afd5cbf zig fmt 2021-06-10 20:13:43 -07:00
Andrew Kelley
597082adf4 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * src/Compilation.zig
 * src/codegen/spirv/spec.zig
 * src/link/SpirV.zig
 * test/stage2/darwin.zig
   - this one might be problematic; start.zig looks for `main` in the
     root source file, not `_main`. Not sure why there is an underscore
     there in master branch.
2021-05-15 21:44:38 -07:00
Robin Voetter
00428ac11b SPIR-V: Don't parse/render in gen_spirv_spec.zig, just emit in the right format 2021-05-14 19:49:32 +02:00
Robin Voetter
25329ca852 SPIR-V: Split out registry from gen_spirv_spec.zig 2021-05-14 19:49:32 +02:00
Robin Voetter
6d1a4c8b1e SPIR-V: Adapt spec generator to new render api 2021-05-14 19:49:32 +02:00
Robin Voetter
d45e7dfc24 SPIR-V: Begin generating types 2021-05-14 19:49:32 +02:00
Robin Voetter
fd33530aef SPIR-V: Spec generator 2021-01-19 15:28:17 +01:00