authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-08-03 17:02:51+03:30
committergravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-08-04 07:05:00+03:30
logcd4b03c5ed1bc5b48ad9c353679b309ead75551d
treed1da1bcfac91d5ed55f977c7fae37dd947f92d49
parent246e1de55485b0b4e9392529778b8f50275e204a
signaturelock-open Commit is signed but in an unrecognized format.

spirv: define and use extended instruction set opcodes


7 files changed, 1504 insertions(+), 4206 deletions(-)

src/codegen/spirv/Assembler.zig+292-289
...@@ -16,7 +16,7 @@ const Assembler = @This();...@@ -16,7 +16,7 @@ const Assembler = @This();
16cg: *CodeGen,16cg: *CodeGen,
17errors: std.ArrayListUnmanaged(ErrorMsg) = .empty,17errors: std.ArrayListUnmanaged(ErrorMsg) = .empty,
18src: []const u8 = undefined,18src: []const u8 = undefined,
19/// `self.src` tokenized.19/// `ass.src` tokenized.
20tokens: std.ArrayListUnmanaged(Token) = .empty,20tokens: std.ArrayListUnmanaged(Token) = .empty,
21current_token: u32 = 0,21current_token: u32 = 0,
22/// The instruction that is currently being parsed or has just been parsed.22/// The instruction that is currently being parsed or has just been parsed.
...@@ -25,8 +25,8 @@ inst: struct {...@@ -25,8 +25,8 @@ inst: struct {
25 operands: std.ArrayListUnmanaged(Operand) = .empty,25 operands: std.ArrayListUnmanaged(Operand) = .empty,
26 string_bytes: std.ArrayListUnmanaged(u8) = .empty,26 string_bytes: std.ArrayListUnmanaged(u8) = .empty,
2727
28 fn result(self: @This()) ?AsmValue.Ref {28 fn result(ass: @This()) ?AsmValue.Ref {
29 for (self.operands.items[0..@min(self.operands.items.len, 2)]) |op| {29 for (ass.operands.items[0..@min(ass.operands.items.len, 2)]) |op| {
30 switch (op) {30 switch (op) {
31 .result_id => |index| return index,31 .result_id => |index| return index,
32 else => {},32 else => {},
...@@ -55,42 +55,42 @@ const Operand = union(enum) {...@@ -55,42 +55,42 @@ const Operand = union(enum) {
55 string: u32,55 string: u32,
56};56};
5757
58pub fn deinit(self: *Assembler) void {58pub fn deinit(ass: *Assembler) void {
59 const gpa = self.cg.module.gpa;59 const gpa = ass.cg.module.gpa;
60 for (self.errors.items) |err| gpa.free(err.msg);60 for (ass.errors.items) |err| gpa.free(err.msg);
61 self.tokens.deinit(gpa);61 ass.tokens.deinit(gpa);
62 self.errors.deinit(gpa);62 ass.errors.deinit(gpa);
63 self.inst.operands.deinit(gpa);63 ass.inst.operands.deinit(gpa);
64 self.inst.string_bytes.deinit(gpa);64 ass.inst.string_bytes.deinit(gpa);
65 self.value_map.deinit(gpa);65 ass.value_map.deinit(gpa);
66 self.inst_map.deinit(gpa);66 ass.inst_map.deinit(gpa);
67}67}
6868
69const Error = error{ AssembleFail, OutOfMemory };69const Error = error{ AssembleFail, OutOfMemory };
7070
71pub fn assemble(self: *Assembler, src: []const u8) Error!void {71pub fn assemble(ass: *Assembler, src: []const u8) Error!void {
72 const gpa = self.cg.module.gpa;72 const gpa = ass.cg.module.gpa;
7373
74 self.src = src;74 ass.src = src;
75 self.errors.clearRetainingCapacity();75 ass.errors.clearRetainingCapacity();
7676
77 // Populate the opcode map if it isn't already77 // Populate the opcode map if it isn't already
78 if (self.inst_map.count() == 0) {78 if (ass.inst_map.count() == 0) {
79 const instructions = spec.InstructionSet.core.instructions();79 const instructions = spec.InstructionSet.core.instructions();
80 try self.inst_map.ensureUnusedCapacity(gpa, @intCast(instructions.len));80 try ass.inst_map.ensureUnusedCapacity(gpa, @intCast(instructions.len));
81 for (spec.InstructionSet.core.instructions(), 0..) |inst, i| {81 for (spec.InstructionSet.core.instructions(), 0..) |inst, i| {
82 const entry = try self.inst_map.getOrPut(gpa, inst.name);82 const entry = try ass.inst_map.getOrPut(gpa, inst.name);
83 assert(entry.index == i);83 assert(entry.index == i);
84 }84 }
85 }85 }
8686
87 try self.tokenize();87 try ass.tokenize();
88 while (!self.testToken(.eof)) {88 while (!ass.testToken(.eof)) {
89 try self.parseInstruction();89 try ass.parseInstruction();
90 try self.processInstruction();90 try ass.processInstruction();
91 }91 }
9292
93 if (self.errors.items.len > 0) return error.AssembleFail;93 if (ass.errors.items.len > 0) return error.AssembleFail;
94}94}
9595
96const ErrorMsg = struct {96const ErrorMsg = struct {
...@@ -99,23 +99,23 @@ const ErrorMsg = struct {...@@ -99,23 +99,23 @@ const ErrorMsg = struct {
99 msg: []const u8,99 msg: []const u8,
100};100};
101101
102fn addError(self: *Assembler, offset: u32, comptime fmt: []const u8, args: anytype) !void {102fn addError(ass: *Assembler, offset: u32, comptime fmt: []const u8, args: anytype) !void {
103 const gpa = self.cg.module.gpa;103 const gpa = ass.cg.module.gpa;
104 const msg = try std.fmt.allocPrint(gpa, fmt, args);104 const msg = try std.fmt.allocPrint(gpa, fmt, args);
105 errdefer gpa.free(msg);105 errdefer gpa.free(msg);
106 try self.errors.append(gpa, .{106 try ass.errors.append(gpa, .{
107 .byte_offset = offset,107 .byte_offset = offset,
108 .msg = msg,108 .msg = msg,
109 });109 });
110}110}
111111
112fn fail(self: *Assembler, offset: u32, comptime fmt: []const u8, args: anytype) Error {112fn fail(ass: *Assembler, offset: u32, comptime fmt: []const u8, args: anytype) Error {
113 try self.addError(offset, fmt, args);113 try ass.addError(offset, fmt, args);
114 return error.AssembleFail;114 return error.AssembleFail;
115}115}
116116
117fn todo(self: *Assembler, comptime fmt: []const u8, args: anytype) Error {117fn todo(ass: *Assembler, comptime fmt: []const u8, args: anytype) Error {
118 return self.fail(0, "todo: " ++ fmt, args);118 return ass.fail(0, "todo: " ++ fmt, args);
119}119}
120120
121const AsmValue = union(enum) {121const AsmValue = union(enum) {
...@@ -139,8 +139,8 @@ const AsmValue = union(enum) {...@@ -139,8 +139,8 @@ const AsmValue = union(enum) {
139 /// Retrieve the result-id of this AsmValue. Asserts that this AsmValue139 /// Retrieve the result-id of this AsmValue. Asserts that this AsmValue
140 /// is of a variant that allows the result to be obtained (not an unresolved140 /// is of a variant that allows the result to be obtained (not an unresolved
141 /// forward declaration, not in the process of being declared, etc).141 /// forward declaration, not in the process of being declared, etc).
142 pub fn resultId(self: AsmValue) Id {142 pub fn resultId(value: AsmValue) Id {
143 return switch (self) {143 return switch (value) {
144 .just_declared,144 .just_declared,
145 .unresolved_forward_reference,145 .unresolved_forward_reference,
146 // TODO: Lower this value as constant?146 // TODO: Lower this value as constant?
...@@ -153,61 +153,62 @@ const AsmValue = union(enum) {...@@ -153,61 +153,62 @@ const AsmValue = union(enum) {
153 }153 }
154};154};
155155
156/// Attempt to process the instruction currently in `self.inst`.156/// Attempt to process the instruction currently in `ass.inst`.
157/// This for example emits the instruction in the module or function, or157/// This for example emits the instruction in the module or function, or
158/// records type definitions.158/// records type definitions.
159/// If this function returns `error.AssembleFail`, an explanatory159/// If this function returns `error.AssembleFail`, an explanatory
160/// error message has already been emitted into `self.errors`.160/// error message has already been emitted into `ass.errors`.
161fn processInstruction(self: *Assembler) !void {161fn processInstruction(ass: *Assembler) !void {
162 const module = self.cg.module;162 const module = ass.cg.module;
163 const result: AsmValue = switch (self.inst.opcode) {163 const result: AsmValue = switch (ass.inst.opcode) {
164 .OpEntryPoint => {164 .OpEntryPoint => {
165 return self.fail(self.currentToken().start, "cannot export entry points in assembly", .{});165 return ass.fail(ass.currentToken().start, "cannot export entry points in assembly", .{});
166 },166 },
167 .OpExecutionMode, .OpExecutionModeId => {167 .OpExecutionMode, .OpExecutionModeId => {
168 return self.fail(self.currentToken().start, "cannot set execution mode in assembly", .{});168 return ass.fail(ass.currentToken().start, "cannot set execution mode in assembly", .{});
169 },169 },
170 .OpCapability => {170 .OpCapability => {
171 try module.addCapability(@enumFromInt(self.inst.operands.items[0].value));171 try module.addCapability(@enumFromInt(ass.inst.operands.items[0].value));
172 return;172 return;
173 },173 },
174 .OpExtension => {174 .OpExtension => {
175 const ext_name_offset = self.inst.operands.items[0].string;175 const ext_name_offset = ass.inst.operands.items[0].string;
176 const ext_name = std.mem.sliceTo(self.inst.string_bytes.items[ext_name_offset..], 0);176 const ext_name = std.mem.sliceTo(ass.inst.string_bytes.items[ext_name_offset..], 0);
177 try module.addExtension(ext_name);177 try module.addExtension(ext_name);
178 return;178 return;
179 },179 },
180 .OpExtInstImport => blk: {180 .OpExtInstImport => blk: {
181 const set_name_offset = self.inst.operands.items[1].string;181 const set_name_offset = ass.inst.operands.items[1].string;
182 const set_name = std.mem.sliceTo(self.inst.string_bytes.items[set_name_offset..], 0);182 const set_name = std.mem.sliceTo(ass.inst.string_bytes.items[set_name_offset..], 0);
183 const set_tag = std.meta.stringToEnum(spec.InstructionSet, set_name) orelse {183 const set_tag = std.meta.stringToEnum(spec.InstructionSet, set_name) orelse {
184 return self.fail(set_name_offset, "unknown instruction set: {s}", .{set_name});184 return ass.fail(set_name_offset, "unknown instruction set: {s}", .{set_name});
185 };185 };
186 break :blk .{ .value = try module.importInstructionSet(set_tag) };186 break :blk .{ .value = try module.importInstructionSet(set_tag) };
187 },187 },
188 else => switch (self.inst.opcode.class()) {188 else => switch (ass.inst.opcode.class()) {
189 .type_declaration => try self.processTypeInstruction(),189 .type_declaration => try ass.processTypeInstruction(),
190 else => (try self.processGenericInstruction()) orelse return,190 else => (try ass.processGenericInstruction()) orelse return,
191 },191 },
192 };192 };
193193
194 const result_ref = self.inst.result().?;194 const result_ref = ass.inst.result().?;
195 switch (self.value_map.values()[result_ref]) {195 switch (ass.value_map.values()[result_ref]) {
196 .just_declared => self.value_map.values()[result_ref] = result,196 .just_declared => ass.value_map.values()[result_ref] = result,
197 else => {197 else => {
198 // TODO: Improve source location.198 // TODO: Improve source location.
199 const name = self.value_map.keys()[result_ref];199 const name = ass.value_map.keys()[result_ref];
200 return self.fail(0, "duplicate definition of %{s}", .{name});200 return ass.fail(0, "duplicate definition of %{s}", .{name});
201 },201 },
202 }202 }
203}203}
204204
205fn processTypeInstruction(self: *Assembler) !AsmValue {205fn processTypeInstruction(ass: *Assembler) !AsmValue {
206 const gpa = self.cg.module.gpa;206 const cg = ass.cg;
207 const module = self.cg.module;207 const gpa = cg.module.gpa;
208 const operands = self.inst.operands.items;208 const module = cg.module;
209 const operands = ass.inst.operands.items;
209 const section = &module.sections.globals;210 const section = &module.sections.globals;
210 const id = switch (self.inst.opcode) {211 const id = switch (ass.inst.opcode) {
211 .OpTypeVoid => try module.voidType(),212 .OpTypeVoid => try module.voidType(),
212 .OpTypeBool => try module.boolType(),213 .OpTypeBool => try module.boolType(),
213 .OpTypeInt => blk: {214 .OpTypeInt => blk: {
...@@ -216,11 +217,11 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {...@@ -216,11 +217,11 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
216 1 => .signed,217 1 => .signed,
217 else => {218 else => {
218 // TODO: Improve source location.219 // TODO: Improve source location.
219 return self.fail(0, "{} is not a valid signedness (expected 0 or 1)", .{operands[2].literal32});220 return ass.fail(0, "{} is not a valid signedness (expected 0 or 1)", .{operands[2].literal32});
220 },221 },
221 };222 };
222 const width = std.math.cast(u16, operands[1].literal32) orelse {223 const width = std.math.cast(u16, operands[1].literal32) orelse {
223 return self.fail(0, "int type of {} bits is too large", .{operands[1].literal32});224 return ass.fail(0, "int type of {} bits is too large", .{operands[1].literal32});
224 };225 };
225 break :blk try module.intType(signedness, width);226 break :blk try module.intType(signedness, width);
226 },227 },
...@@ -229,22 +230,22 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {...@@ -229,22 +230,22 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
229 switch (bits) {230 switch (bits) {
230 16, 32, 64 => {},231 16, 32, 64 => {},
231 else => {232 else => {
232 return self.fail(0, "{} is not a valid bit count for floats (expected 16, 32 or 64)", .{bits});233 return ass.fail(0, "{} is not a valid bit count for floats (expected 16, 32 or 64)", .{bits});
233 },234 },
234 }235 }
235 break :blk try module.floatType(@intCast(bits));236 break :blk try module.floatType(@intCast(bits));
236 },237 },
237 .OpTypeVector => blk: {238 .OpTypeVector => blk: {
238 const child_type = try self.resolveRefId(operands[1].ref_id);239 const child_type = try ass.resolveRefId(operands[1].ref_id);
239 break :blk try module.vectorType(operands[2].literal32, child_type);240 break :blk try module.vectorType(operands[2].literal32, child_type);
240 },241 },
241 .OpTypeArray => {242 .OpTypeArray => {
242 // TODO: The length of an OpTypeArray is determined by a constant (which may be a spec constant),243 // TODO: The length of an OpTypeArray is determined by a constant (which may be a spec constant),
243 // and so some consideration must be taken when entering this in the type system.244 // and so some consideration must be taken when entering this in the type system.
244 return self.todo("process OpTypeArray", .{});245 return ass.todo("process OpTypeArray", .{});
245 },246 },
246 .OpTypeRuntimeArray => blk: {247 .OpTypeRuntimeArray => blk: {
247 const element_type = try self.resolveRefId(operands[1].ref_id);248 const element_type = try ass.resolveRefId(operands[1].ref_id);
248 const result_id = module.allocId();249 const result_id = module.allocId();
249 try section.emit(module.gpa, .OpTypeRuntimeArray, .{250 try section.emit(module.gpa, .OpTypeRuntimeArray, .{
250 .id_result = result_id,251 .id_result = result_id,
...@@ -254,7 +255,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {...@@ -254,7 +255,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
254 },255 },
255 .OpTypePointer => blk: {256 .OpTypePointer => blk: {
256 const storage_class: StorageClass = @enumFromInt(operands[1].value);257 const storage_class: StorageClass = @enumFromInt(operands[1].value);
257 const child_type = try self.resolveRefId(operands[2].ref_id);258 const child_type = try ass.resolveRefId(operands[2].ref_id);
258 const result_id = module.allocId();259 const result_id = module.allocId();
259 try section.emit(module.gpa, .OpTypePointer, .{260 try section.emit(module.gpa, .OpTypePointer, .{
260 .id_result = result_id,261 .id_result = result_id,
...@@ -264,13 +265,14 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {...@@ -264,13 +265,14 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
264 break :blk result_id;265 break :blk result_id;
265 },266 },
266 .OpTypeStruct => blk: {267 .OpTypeStruct => blk: {
267 const ids = try gpa.alloc(Id, operands[1..].len);268 const scratch_top = cg.id_scratch.items.len;
268 defer gpa.free(ids);269 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
269 for (operands[1..], ids) |op, *id| id.* = try self.resolveRefId(op.ref_id);270 const ids = try cg.id_scratch.addManyAsSlice(gpa, operands[1..].len);
271 for (operands[1..], ids) |op, *id| id.* = try ass.resolveRefId(op.ref_id);
270 break :blk try module.structType(ids, null, null, .none);272 break :blk try module.structType(ids, null, null, .none);
271 },273 },
272 .OpTypeImage => blk: {274 .OpTypeImage => blk: {
273 const sampled_type = try self.resolveRefId(operands[1].ref_id);275 const sampled_type = try ass.resolveRefId(operands[1].ref_id);
274 const result_id = module.allocId();276 const result_id = module.allocId();
275 try section.emit(gpa, .OpTypeImage, .{277 try section.emit(gpa, .OpTypeImage, .{
276 .id_result = result_id,278 .id_result = result_id,
...@@ -290,19 +292,21 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {...@@ -290,19 +292,21 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
290 break :blk result_id;292 break :blk result_id;
291 },293 },
292 .OpTypeSampledImage => blk: {294 .OpTypeSampledImage => blk: {
293 const image_type = try self.resolveRefId(operands[1].ref_id);295 const image_type = try ass.resolveRefId(operands[1].ref_id);
294 const result_id = module.allocId();296 const result_id = module.allocId();
295 try section.emit(gpa, .OpTypeSampledImage, .{ .id_result = result_id, .image_type = image_type });297 try section.emit(gpa, .OpTypeSampledImage, .{ .id_result = result_id, .image_type = image_type });
296 break :blk result_id;298 break :blk result_id;
297 },299 },
298 .OpTypeFunction => blk: {300 .OpTypeFunction => blk: {
299 const param_operands = operands[2..];301 const param_operands = operands[2..];
300 const return_type = try self.resolveRefId(operands[1].ref_id);302 const return_type = try ass.resolveRefId(operands[1].ref_id);
303
304 const scratch_top = cg.id_scratch.items.len;
305 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
306 const param_types = try cg.id_scratch.addManyAsSlice(gpa, param_operands.len);
301307
302 const param_types = try module.gpa.alloc(Id, param_operands.len);
303 defer module.gpa.free(param_types);
304 for (param_types, param_operands) |*param, operand| {308 for (param_types, param_operands) |*param, operand| {
305 param.* = try self.resolveRefId(operand.ref_id);309 param.* = try ass.resolveRefId(operand.ref_id);
306 }310 }
307 const result_id = module.allocId();311 const result_id = module.allocId();
308 try section.emit(module.gpa, .OpTypeFunction, .{312 try section.emit(module.gpa, .OpTypeFunction, .{
...@@ -312,7 +316,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {...@@ -312,7 +316,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
312 });316 });
313 break :blk result_id;317 break :blk result_id;
314 },318 },
315 else => return self.todo("process type instruction {s}", .{@tagName(self.inst.opcode)}),319 else => return ass.todo("process type instruction {s}", .{@tagName(ass.inst.opcode)}),
316 };320 };
317321
318 return .{ .ty = id };322 return .{ .ty = id };
...@@ -320,31 +324,30 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {...@@ -320,31 +324,30 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
320324
321/// - No forward references are allowed in operands.325/// - No forward references are allowed in operands.
322/// - Target section is determined from instruction type.326/// - Target section is determined from instruction type.
323fn processGenericInstruction(self: *Assembler) !?AsmValue {327fn processGenericInstruction(ass: *Assembler) !?AsmValue {
324 const module = self.cg.module;328 const module = ass.cg.module;
325 const target = module.zcu.getTarget();329 const target = module.zcu.getTarget();
326 const operands = self.inst.operands.items;330 const operands = ass.inst.operands.items;
327 var maybe_spv_decl_index: ?Decl.Index = null;331 var maybe_spv_decl_index: ?Decl.Index = null;
328 const section = switch (self.inst.opcode.class()) {332 const section = switch (ass.inst.opcode.class()) {
329 .constant_creation => &module.sections.globals,333 .constant_creation => &module.sections.globals,
330 .annotation => &module.sections.annotations,334 .annotation => &module.sections.annotations,
331 .type_declaration => unreachable, // Handled elsewhere.335 .type_declaration => unreachable, // Handled elsewhere.
332 else => switch (self.inst.opcode) {336 else => switch (ass.inst.opcode) {
333 .OpEntryPoint => unreachable,337 .OpEntryPoint => unreachable,
334 .OpExecutionMode, .OpExecutionModeId => &module.sections.execution_modes,338 .OpExecutionMode, .OpExecutionModeId => &module.sections.execution_modes,
335 .OpVariable => section: {339 .OpVariable => section: {
336 const storage_class: spec.StorageClass = @enumFromInt(operands[2].value);340 const storage_class: spec.StorageClass = @enumFromInt(operands[2].value);
337 if (storage_class == .function) break :section &self.cg.prologue;341 if (storage_class == .function) break :section &ass.cg.prologue;
338 maybe_spv_decl_index = try module.allocDecl(.global);342 maybe_spv_decl_index = try module.allocDecl(.global);
339 if (!target.cpu.has(.spirv, .v1_4) and storage_class != .input and storage_class != .output) {343 if (!target.cpu.has(.spirv, .v1_4) and storage_class != .input and storage_class != .output) {
340 // Before version 1.4, the interface’s storage classes are limited to the Input and Output344 // Before version 1.4, the interface’s storage classes are limited to the Input and Output
341 break :section &module.sections.globals;345 break :section &module.sections.globals;
342 }346 }
343 try self.cg.decl_deps.put(module.gpa, maybe_spv_decl_index.?, {});347 try ass.cg.module.decl_deps.append(module.gpa, maybe_spv_decl_index.?);
344 try module.declareDeclDeps(maybe_spv_decl_index.?, &.{});
345 break :section &module.sections.globals;348 break :section &module.sections.globals;
346 },349 },
347 else => &self.cg.body,350 else => &ass.cg.body,
348 },351 },
349 };352 };
350353
...@@ -374,12 +377,12 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {...@@ -374,12 +377,12 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {
374 section.writeOperand(Id, maybe_result_id.?);377 section.writeOperand(Id, maybe_result_id.?);
375 },378 },
376 .ref_id => |index| {379 .ref_id => |index| {
377 const result = try self.resolveRef(index);380 const result = try ass.resolveRef(index);
378 try section.ensureUnusedCapacity(module.gpa, 1);381 try section.ensureUnusedCapacity(module.gpa, 1);
379 section.writeOperand(spec.Id, result.resultId());382 section.writeOperand(spec.Id, result.resultId());
380 },383 },
381 .string => |offset| {384 .string => |offset| {
382 const text = std.mem.sliceTo(self.inst.string_bytes.items[offset..], 0);385 const text = std.mem.sliceTo(ass.inst.string_bytes.items[offset..], 0);
383 const size = std.math.divCeil(usize, text.len + 1, @sizeOf(Word)) catch unreachable;386 const size = std.math.divCeil(usize, text.len + 1, @sizeOf(Word)) catch unreachable;
384 try section.ensureUnusedCapacity(module.gpa, size);387 try section.ensureUnusedCapacity(module.gpa, size);
385 section.writeOperand(spec.LiteralString, text);388 section.writeOperand(spec.LiteralString, text);
...@@ -388,74 +391,74 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {...@@ -388,74 +391,74 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {
388 }391 }
389392
390 const actual_word_count = section.instructions.items.len - first_word;393 const actual_word_count = section.instructions.items.len - first_word;
391 section.instructions.items[first_word] |= @as(u32, @as(u16, @intCast(actual_word_count))) << 16 | @intFromEnum(self.inst.opcode);394 section.instructions.items[first_word] |= @as(u32, @as(u16, @intCast(actual_word_count))) << 16 | @intFromEnum(ass.inst.opcode);
392395
393 if (maybe_result_id) |result| return .{ .value = result };396 if (maybe_result_id) |result| return .{ .value = result };
394 return null;397 return null;
395}398}
396399
397fn resolveMaybeForwardRef(self: *Assembler, ref: AsmValue.Ref) !AsmValue {400fn resolveMaybeForwardRef(ass: *Assembler, ref: AsmValue.Ref) !AsmValue {
398 const value = self.value_map.values()[ref];401 const value = ass.value_map.values()[ref];
399 switch (value) {402 switch (value) {
400 .just_declared => {403 .just_declared => {
401 const name = self.value_map.keys()[ref];404 const name = ass.value_map.keys()[ref];
402 // TODO: Improve source location.405 // TODO: Improve source location.
403 return self.fail(0, "self-referential parameter %{s}", .{name});406 return ass.fail(0, "ass-referential parameter %{s}", .{name});
404 },407 },
405 else => return value,408 else => return value,
406 }409 }
407}410}
408411
409fn resolveRef(self: *Assembler, ref: AsmValue.Ref) !AsmValue {412fn resolveRef(ass: *Assembler, ref: AsmValue.Ref) !AsmValue {
410 const value = try self.resolveMaybeForwardRef(ref);413 const value = try ass.resolveMaybeForwardRef(ref);
411 switch (value) {414 switch (value) {
412 .just_declared => unreachable,415 .just_declared => unreachable,
413 .unresolved_forward_reference => {416 .unresolved_forward_reference => {
414 const name = self.value_map.keys()[ref];417 const name = ass.value_map.keys()[ref];
415 // TODO: Improve source location.418 // TODO: Improve source location.
416 return self.fail(0, "reference to undeclared result-id %{s}", .{name});419 return ass.fail(0, "reference to undeclared result-id %{s}", .{name});
417 },420 },
418 else => return value,421 else => return value,
419 }422 }
420}423}
421424
422fn resolveRefId(self: *Assembler, ref: AsmValue.Ref) !Id {425fn resolveRefId(ass: *Assembler, ref: AsmValue.Ref) !Id {
423 const value = try self.resolveRef(ref);426 const value = try ass.resolveRef(ref);
424 return value.resultId();427 return value.resultId();
425}428}
426429
427fn parseInstruction(self: *Assembler) !void {430fn parseInstruction(ass: *Assembler) !void {
428 const gpa = self.cg.module.gpa;431 const gpa = ass.cg.module.gpa;
429432
430 self.inst.opcode = undefined;433 ass.inst.opcode = undefined;
431 self.inst.operands.clearRetainingCapacity();434 ass.inst.operands.clearRetainingCapacity();
432 self.inst.string_bytes.clearRetainingCapacity();435 ass.inst.string_bytes.clearRetainingCapacity();
433436
434 const lhs_result_tok = self.currentToken();437 const lhs_result_tok = ass.currentToken();
435 const maybe_lhs_result: ?AsmValue.Ref = if (self.eatToken(.result_id_assign)) blk: {438 const maybe_lhs_result: ?AsmValue.Ref = if (ass.eatToken(.result_id_assign)) blk: {
436 const name = self.tokenText(lhs_result_tok)[1..];439 const name = ass.tokenText(lhs_result_tok)[1..];
437 const entry = try self.value_map.getOrPut(gpa, name);440 const entry = try ass.value_map.getOrPut(gpa, name);
438 try self.expectToken(.equals);441 try ass.expectToken(.equals);
439 if (!entry.found_existing) {442 if (!entry.found_existing) {
440 entry.value_ptr.* = .just_declared;443 entry.value_ptr.* = .just_declared;
441 }444 }
442 break :blk @intCast(entry.index);445 break :blk @intCast(entry.index);
443 } else null;446 } else null;
444447
445 const opcode_tok = self.currentToken();448 const opcode_tok = ass.currentToken();
446 if (maybe_lhs_result != null) {449 if (maybe_lhs_result != null) {
447 try self.expectToken(.opcode);450 try ass.expectToken(.opcode);
448 } else if (!self.eatToken(.opcode)) {451 } else if (!ass.eatToken(.opcode)) {
449 return self.fail(opcode_tok.start, "expected start of instruction, found {s}", .{opcode_tok.tag.name()});452 return ass.fail(opcode_tok.start, "expected start of instruction, found {s}", .{opcode_tok.tag.name()});
450 }453 }
451454
452 const opcode_text = self.tokenText(opcode_tok);455 const opcode_text = ass.tokenText(opcode_tok);
453 const index = self.inst_map.getIndex(opcode_text) orelse {456 const index = ass.inst_map.getIndex(opcode_text) orelse {
454 return self.fail(opcode_tok.start, "invalid opcode '{s}'", .{opcode_text});457 return ass.fail(opcode_tok.start, "invalid opcode '{s}'", .{opcode_text});
455 };458 };
456459
457 const inst = spec.InstructionSet.core.instructions()[index];460 const inst = spec.InstructionSet.core.instructions()[index];
458 self.inst.opcode = @enumFromInt(inst.opcode);461 ass.inst.opcode = @enumFromInt(inst.opcode);
459462
460 const expected_operands = inst.operands;463 const expected_operands = inst.operands;
461 // This is a loop because the result-id is not always the first operand.464 // This is a loop because the result-id is not always the first operand.
...@@ -464,67 +467,67 @@ fn parseInstruction(self: *Assembler) !void {...@@ -464,67 +467,67 @@ fn parseInstruction(self: *Assembler) !void {
464 } else false;467 } else false;
465468
466 if (requires_lhs_result and maybe_lhs_result == null) {469 if (requires_lhs_result and maybe_lhs_result == null) {
467 return self.fail(opcode_tok.start, "opcode '{s}' expects result on left-hand side", .{@tagName(self.inst.opcode)});470 return ass.fail(opcode_tok.start, "opcode '{s}' expects result on left-hand side", .{@tagName(ass.inst.opcode)});
468 } else if (!requires_lhs_result and maybe_lhs_result != null) {471 } else if (!requires_lhs_result and maybe_lhs_result != null) {
469 return self.fail(472 return ass.fail(
470 lhs_result_tok.start,473 lhs_result_tok.start,
471 "opcode '{s}' does not expect a result-id on the left-hand side",474 "opcode '{s}' does not expect a result-id on the left-hand side",
472 .{@tagName(self.inst.opcode)},475 .{@tagName(ass.inst.opcode)},
473 );476 );
474 }477 }
475478
476 for (expected_operands) |operand| {479 for (expected_operands) |operand| {
477 if (operand.kind == .id_result) {480 if (operand.kind == .id_result) {
478 try self.inst.operands.append(gpa, .{ .result_id = maybe_lhs_result.? });481 try ass.inst.operands.append(gpa, .{ .result_id = maybe_lhs_result.? });
479 continue;482 continue;
480 }483 }
481484
482 switch (operand.quantifier) {485 switch (operand.quantifier) {
483 .required => if (self.isAtInstructionBoundary()) {486 .required => if (ass.isAtInstructionBoundary()) {
484 return self.fail(487 return ass.fail(
485 self.currentToken().start,488 ass.currentToken().start,
486 "missing required operand", // TODO: Operand name?489 "missing required operand", // TODO: Operand name?
487 .{},490 .{},
488 );491 );
489 } else {492 } else {
490 try self.parseOperand(operand.kind);493 try ass.parseOperand(operand.kind);
491 },494 },
492 .optional => if (!self.isAtInstructionBoundary()) {495 .optional => if (!ass.isAtInstructionBoundary()) {
493 try self.parseOperand(operand.kind);496 try ass.parseOperand(operand.kind);
494 },497 },
495 .variadic => while (!self.isAtInstructionBoundary()) {498 .variadic => while (!ass.isAtInstructionBoundary()) {
496 try self.parseOperand(operand.kind);499 try ass.parseOperand(operand.kind);
497 },500 },
498 }501 }
499 }502 }
500}503}
501504
502fn parseOperand(self: *Assembler, kind: spec.OperandKind) Error!void {505fn parseOperand(ass: *Assembler, kind: spec.OperandKind) Error!void {
503 switch (kind.category()) {506 switch (kind.category()) {
504 .bit_enum => try self.parseBitEnum(kind),507 .bit_enum => try ass.parseBitEnum(kind),
505 .value_enum => try self.parseValueEnum(kind),508 .value_enum => try ass.parseValueEnum(kind),
506 .id => try self.parseRefId(),509 .id => try ass.parseRefId(),
507 else => switch (kind) {510 else => switch (kind) {
508 .literal_integer => try self.parseLiteralInteger(),511 .literal_integer => try ass.parseLiteralInteger(),
509 .literal_string => try self.parseString(),512 .literal_string => try ass.parseString(),
510 .literal_context_dependent_number => try self.parseContextDependentNumber(),513 .literal_context_dependent_number => try ass.parseContextDependentNumber(),
511 .literal_ext_inst_integer => try self.parseLiteralExtInstInteger(),514 .literal_ext_inst_integer => try ass.parseLiteralExtInstInteger(),
512 .pair_id_ref_id_ref => try self.parsePhiSource(),515 .pair_id_ref_id_ref => try ass.parsePhiSource(),
513 else => return self.todo("parse operand of type {s}", .{@tagName(kind)}),516 else => return ass.todo("parse operand of type {s}", .{@tagName(kind)}),
514 },517 },
515 }518 }
516}519}
517520
518/// Also handles parsing any required extra operands.521/// Also handles parsing any required extra operands.
519fn parseBitEnum(self: *Assembler, kind: spec.OperandKind) !void {522fn parseBitEnum(ass: *Assembler, kind: spec.OperandKind) !void {
520 const gpa = self.cg.module.gpa;523 const gpa = ass.cg.module.gpa;
521524
522 var tok = self.currentToken();525 var tok = ass.currentToken();
523 try self.expectToken(.value);526 try ass.expectToken(.value);
524527
525 var text = self.tokenText(tok);528 var text = ass.tokenText(tok);
526 if (std.mem.eql(u8, text, "None")) {529 if (std.mem.eql(u8, text, "None")) {
527 try self.inst.operands.append(gpa, .{ .value = 0 });530 try ass.inst.operands.append(gpa, .{ .value = 0 });
528 return;531 return;
529 }532 }
530533
...@@ -535,18 +538,18 @@ fn parseBitEnum(self: *Assembler, kind: spec.OperandKind) !void {...@@ -535,18 +538,18 @@ fn parseBitEnum(self: *Assembler, kind: spec.OperandKind) !void {
535 if (std.mem.eql(u8, enumerant.name, text))538 if (std.mem.eql(u8, enumerant.name, text))
536 break enumerant;539 break enumerant;
537 } else {540 } else {
538 return self.fail(tok.start, "'{s}' is not a valid flag for bitmask {s}", .{ text, @tagName(kind) });541 return ass.fail(tok.start, "'{s}' is not a valid flag for bitmask {s}", .{ text, @tagName(kind) });
539 };542 };
540 mask |= enumerant.value;543 mask |= enumerant.value;
541 if (!self.eatToken(.pipe))544 if (!ass.eatToken(.pipe))
542 break;545 break;
543546
544 tok = self.currentToken();547 tok = ass.currentToken();
545 try self.expectToken(.value);548 try ass.expectToken(.value);
546 text = self.tokenText(tok);549 text = ass.tokenText(tok);
547 }550 }
548551
549 try self.inst.operands.append(gpa, .{ .value = mask });552 try ass.inst.operands.append(gpa, .{ .value = mask });
550553
551 // Assume values are sorted.554 // Assume values are sorted.
552 // TODO: ensure in generator.555 // TODO: ensure in generator.
...@@ -555,45 +558,45 @@ fn parseBitEnum(self: *Assembler, kind: spec.OperandKind) !void {...@@ -555,45 +558,45 @@ fn parseBitEnum(self: *Assembler, kind: spec.OperandKind) !void {
555 continue;558 continue;
556559
557 for (enumerant.parameters) |param_kind| {560 for (enumerant.parameters) |param_kind| {
558 if (self.isAtInstructionBoundary()) {561 if (ass.isAtInstructionBoundary()) {
559 return self.fail(self.currentToken().start, "missing required parameter for bit flag '{s}'", .{enumerant.name});562 return ass.fail(ass.currentToken().start, "missing required parameter for bit flag '{s}'", .{enumerant.name});
560 }563 }
561564
562 try self.parseOperand(param_kind);565 try ass.parseOperand(param_kind);
563 }566 }
564 }567 }
565}568}
566569
567/// Also handles parsing any required extra operands.570/// Also handles parsing any required extra operands.
568fn parseValueEnum(self: *Assembler, kind: spec.OperandKind) !void {571fn parseValueEnum(ass: *Assembler, kind: spec.OperandKind) !void {
569 const gpa = self.cg.module.gpa;572 const gpa = ass.cg.module.gpa;
570573
571 const tok = self.currentToken();574 const tok = ass.currentToken();
572 if (self.eatToken(.placeholder)) {575 if (ass.eatToken(.placeholder)) {
573 const name = self.tokenText(tok)[1..];576 const name = ass.tokenText(tok)[1..];
574 const value = self.value_map.get(name) orelse {577 const value = ass.value_map.get(name) orelse {
575 return self.fail(tok.start, "invalid placeholder '${s}'", .{name});578 return ass.fail(tok.start, "invalid placeholder '${s}'", .{name});
576 };579 };
577 switch (value) {580 switch (value) {
578 .constant => |literal32| {581 .constant => |literal32| {
579 try self.inst.operands.append(gpa, .{ .value = literal32 });582 try ass.inst.operands.append(gpa, .{ .value = literal32 });
580 },583 },
581 .string => |str| {584 .string => |str| {
582 const enumerant = for (kind.enumerants()) |enumerant| {585 const enumerant = for (kind.enumerants()) |enumerant| {
583 if (std.mem.eql(u8, enumerant.name, str)) break enumerant;586 if (std.mem.eql(u8, enumerant.name, str)) break enumerant;
584 } else {587 } else {
585 return self.fail(tok.start, "'{s}' is not a valid value for enumeration {s}", .{ str, @tagName(kind) });588 return ass.fail(tok.start, "'{s}' is not a valid value for enumeration {s}", .{ str, @tagName(kind) });
586 };589 };
587 try self.inst.operands.append(gpa, .{ .value = enumerant.value });590 try ass.inst.operands.append(gpa, .{ .value = enumerant.value });
588 },591 },
589 else => return self.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name}),592 else => return ass.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name}),
590 }593 }
591 return;594 return;
592 }595 }
593596
594 try self.expectToken(.value);597 try ass.expectToken(.value);
595598
596 const text = self.tokenText(tok);599 const text = ass.tokenText(tok);
597 const int_value = std.fmt.parseInt(u32, text, 0) catch null;600 const int_value = std.fmt.parseInt(u32, text, 0) catch null;
598 const enumerant = for (kind.enumerants()) |enumerant| {601 const enumerant = for (kind.enumerants()) |enumerant| {
599 if (int_value) |v| {602 if (int_value) |v| {
...@@ -602,131 +605,131 @@ fn parseValueEnum(self: *Assembler, kind: spec.OperandKind) !void {...@@ -602,131 +605,131 @@ fn parseValueEnum(self: *Assembler, kind: spec.OperandKind) !void {
602 if (std.mem.eql(u8, enumerant.name, text)) break enumerant;605 if (std.mem.eql(u8, enumerant.name, text)) break enumerant;
603 }606 }
604 } else {607 } else {
605 return self.fail(tok.start, "'{s}' is not a valid value for enumeration {s}", .{ text, @tagName(kind) });608 return ass.fail(tok.start, "'{s}' is not a valid value for enumeration {s}", .{ text, @tagName(kind) });
606 };609 };
607610
608 try self.inst.operands.append(gpa, .{ .value = enumerant.value });611 try ass.inst.operands.append(gpa, .{ .value = enumerant.value });
609612
610 for (enumerant.parameters) |param_kind| {613 for (enumerant.parameters) |param_kind| {
611 if (self.isAtInstructionBoundary()) {614 if (ass.isAtInstructionBoundary()) {
612 return self.fail(self.currentToken().start, "missing required parameter for enum variant '{s}'", .{enumerant.name});615 return ass.fail(ass.currentToken().start, "missing required parameter for enum variant '{s}'", .{enumerant.name});
613 }616 }
614617
615 try self.parseOperand(param_kind);618 try ass.parseOperand(param_kind);
616 }619 }
617}620}
618621
619fn parseRefId(self: *Assembler) !void {622fn parseRefId(ass: *Assembler) !void {
620 const gpa = self.cg.module.gpa;623 const gpa = ass.cg.module.gpa;
621624
622 const tok = self.currentToken();625 const tok = ass.currentToken();
623 try self.expectToken(.result_id);626 try ass.expectToken(.result_id);
624627
625 const name = self.tokenText(tok)[1..];628 const name = ass.tokenText(tok)[1..];
626 const entry = try self.value_map.getOrPut(gpa, name);629 const entry = try ass.value_map.getOrPut(gpa, name);
627 if (!entry.found_existing) {630 if (!entry.found_existing) {
628 entry.value_ptr.* = .unresolved_forward_reference;631 entry.value_ptr.* = .unresolved_forward_reference;
629 }632 }
630633
631 const index: AsmValue.Ref = @intCast(entry.index);634 const index: AsmValue.Ref = @intCast(entry.index);
632 try self.inst.operands.append(gpa, .{ .ref_id = index });635 try ass.inst.operands.append(gpa, .{ .ref_id = index });
633}636}
634637
635fn parseLiteralInteger(self: *Assembler) !void {638fn parseLiteralInteger(ass: *Assembler) !void {
636 const gpa = self.cg.module.gpa;639 const gpa = ass.cg.module.gpa;
637640
638 const tok = self.currentToken();641 const tok = ass.currentToken();
639 if (self.eatToken(.placeholder)) {642 if (ass.eatToken(.placeholder)) {
640 const name = self.tokenText(tok)[1..];643 const name = ass.tokenText(tok)[1..];
641 const value = self.value_map.get(name) orelse {644 const value = ass.value_map.get(name) orelse {
642 return self.fail(tok.start, "invalid placeholder '${s}'", .{name});645 return ass.fail(tok.start, "invalid placeholder '${s}'", .{name});
643 };646 };
644 switch (value) {647 switch (value) {
645 .constant => |literal32| {648 .constant => |literal32| {
646 try self.inst.operands.append(gpa, .{ .literal32 = literal32 });649 try ass.inst.operands.append(gpa, .{ .literal32 = literal32 });
647 },650 },
648 else => {651 else => {
649 return self.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name});652 return ass.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name});
650 },653 },
651 }654 }
652 return;655 return;
653 }656 }
654657
655 try self.expectToken(.value);658 try ass.expectToken(.value);
656 // According to the SPIR-V machine readable grammar, a LiteralInteger659 // According to the SPIR-V machine readable grammar, a LiteralInteger
657 // may consist of one or more words. From the SPIR-V docs it seems like there660 // may consist of one or more words. From the SPIR-V docs it seems like there
658 // only one instruction where multiple words are allowed, the literals that make up the661 // only one instruction where multiple words are allowed, the literals that make up the
659 // switch cases of OpSwitch. This case is handled separately, and so we just assume662 // switch cases of OpSwitch. This case is handled separately, and so we just assume
660 // everything is a 32-bit integer in this function.663 // everything is a 32-bit integer in this function.
661 const text = self.tokenText(tok);664 const text = ass.tokenText(tok);
662 const value = std.fmt.parseInt(u32, text, 0) catch {665 const value = std.fmt.parseInt(u32, text, 0) catch {
663 return self.fail(tok.start, "'{s}' is not a valid 32-bit integer literal", .{text});666 return ass.fail(tok.start, "'{s}' is not a valid 32-bit integer literal", .{text});
664 };667 };
665 try self.inst.operands.append(gpa, .{ .literal32 = value });668 try ass.inst.operands.append(gpa, .{ .literal32 = value });
666}669}
667670
668fn parseLiteralExtInstInteger(self: *Assembler) !void {671fn parseLiteralExtInstInteger(ass: *Assembler) !void {
669 const gpa = self.cg.module.gpa;672 const gpa = ass.cg.module.gpa;
670673
671 const tok = self.currentToken();674 const tok = ass.currentToken();
672 if (self.eatToken(.placeholder)) {675 if (ass.eatToken(.placeholder)) {
673 const name = self.tokenText(tok)[1..];676 const name = ass.tokenText(tok)[1..];
674 const value = self.value_map.get(name) orelse {677 const value = ass.value_map.get(name) orelse {
675 return self.fail(tok.start, "invalid placeholder '${s}'", .{name});678 return ass.fail(tok.start, "invalid placeholder '${s}'", .{name});
676 };679 };
677 switch (value) {680 switch (value) {
678 .constant => |literal32| {681 .constant => |literal32| {
679 try self.inst.operands.append(gpa, .{ .literal32 = literal32 });682 try ass.inst.operands.append(gpa, .{ .literal32 = literal32 });
680 },683 },
681 else => {684 else => {
682 return self.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name});685 return ass.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name});
683 },686 },
684 }687 }
685 return;688 return;
686 }689 }
687690
688 try self.expectToken(.value);691 try ass.expectToken(.value);
689 const text = self.tokenText(tok);692 const text = ass.tokenText(tok);
690 const value = std.fmt.parseInt(u32, text, 0) catch {693 const value = std.fmt.parseInt(u32, text, 0) catch {
691 return self.fail(tok.start, "'{s}' is not a valid 32-bit integer literal", .{text});694 return ass.fail(tok.start, "'{s}' is not a valid 32-bit integer literal", .{text});
692 };695 };
693 try self.inst.operands.append(gpa, .{ .literal32 = value });696 try ass.inst.operands.append(gpa, .{ .literal32 = value });
694}697}
695698
696fn parseString(self: *Assembler) !void {699fn parseString(ass: *Assembler) !void {
697 const gpa = self.cg.module.gpa;700 const gpa = ass.cg.module.gpa;
698701
699 const tok = self.currentToken();702 const tok = ass.currentToken();
700 try self.expectToken(.string);703 try ass.expectToken(.string);
701 // Note, the string might not have a closing quote. In this case,704 // Note, the string might not have a closing quote. In this case,
702 // an error is already emitted but we are trying to continue processing705 // an error is already emitted but we are trying to continue processing
703 // anyway, so in this function we have to deal with that situation.706 // anyway, so in this function we have to deal with that situation.
704 const text = self.tokenText(tok);707 const text = ass.tokenText(tok);
705 assert(text.len > 0 and text[0] == '"');708 assert(text.len > 0 and text[0] == '"');
706 const literal = if (text.len != 1 and text[text.len - 1] == '"')709 const literal = if (text.len != 1 and text[text.len - 1] == '"')
707 text[1 .. text.len - 1]710 text[1 .. text.len - 1]
708 else711 else
709 text[1..];712 text[1..];
710713
711 const string_offset: u32 = @intCast(self.inst.string_bytes.items.len);714 const string_offset: u32 = @intCast(ass.inst.string_bytes.items.len);
712 try self.inst.string_bytes.ensureUnusedCapacity(gpa, literal.len + 1);715 try ass.inst.string_bytes.ensureUnusedCapacity(gpa, literal.len + 1);
713 self.inst.string_bytes.appendSliceAssumeCapacity(literal);716 ass.inst.string_bytes.appendSliceAssumeCapacity(literal);
714 self.inst.string_bytes.appendAssumeCapacity(0);717 ass.inst.string_bytes.appendAssumeCapacity(0);
715718
716 try self.inst.operands.append(gpa, .{ .string = string_offset });719 try ass.inst.operands.append(gpa, .{ .string = string_offset });
717}720}
718721
719fn parseContextDependentNumber(self: *Assembler) !void {722fn parseContextDependentNumber(ass: *Assembler) !void {
720 const module = self.cg.module;723 const module = ass.cg.module;
721724
722 // For context dependent numbers, the actual type to parse is determined by the instruction.725 // For context dependent numbers, the actual type to parse is determined by the instruction.
723 // Currently, this operand appears in OpConstant and OpSpecConstant, where the too-be-parsed type726 // Currently, this operand appears in OpConstant and OpSpecConstant, where the too-be-parsed type
724 // is determined by the result type. That means that in this instructions we have to resolve the727 // is determined by the result type. That means that in this instructions we have to resolve the
725 // operand type early and look at the result to see how we need to proceed.728 // operand type early and look at the result to see how we need to proceed.
726 assert(self.inst.opcode == .OpConstant or self.inst.opcode == .OpSpecConstant);729 assert(ass.inst.opcode == .OpConstant or ass.inst.opcode == .OpSpecConstant);
727730
728 const tok = self.currentToken();731 const tok = ass.currentToken();
729 const result = try self.resolveRef(self.inst.operands.items[0].ref_id);732 const result = try ass.resolveRef(ass.inst.operands.items[0].ref_id);
730 const result_id = result.resultId();733 const result_id = result.resultId();
731 // We are going to cheat a little bit: The types we are interested in, int and float,734 // We are going to cheat a little bit: The types we are interested in, int and float,
732 // are added to the module and cached via module.intType and module.floatType. Therefore,735 // are added to the module and cached via module.intType and module.floatType. Therefore,
...@@ -741,7 +744,7 @@ fn parseContextDependentNumber(self: *Assembler) !void {...@@ -741,7 +744,7 @@ fn parseContextDependentNumber(self: *Assembler) !void {
741 const id = entry.value_ptr.*;744 const id = entry.value_ptr.*;
742 if (id != result_id) continue;745 if (id != result_id) continue;
743 const info = entry.key_ptr.*;746 const info = entry.key_ptr.*;
744 return try self.parseContextDependentInt(info.signedness, info.bits);747 return try ass.parseContextDependentInt(info.signedness, info.bits);
745 }748 }
746 }749 }
747750
...@@ -752,44 +755,44 @@ fn parseContextDependentNumber(self: *Assembler) !void {...@@ -752,44 +755,44 @@ fn parseContextDependentNumber(self: *Assembler) !void {
752 if (id != result_id) continue;755 if (id != result_id) continue;
753 const info = entry.key_ptr.*;756 const info = entry.key_ptr.*;
754 switch (info.bits) {757 switch (info.bits) {
755 16 => try self.parseContextDependentFloat(16),758 16 => try ass.parseContextDependentFloat(16),
756 32 => try self.parseContextDependentFloat(32),759 32 => try ass.parseContextDependentFloat(32),
757 64 => try self.parseContextDependentFloat(64),760 64 => try ass.parseContextDependentFloat(64),
758 else => return self.fail(tok.start, "cannot parse {}-bit info literal", .{info.bits}),761 else => return ass.fail(tok.start, "cannot parse {}-bit info literal", .{info.bits}),
759 }762 }
760 }763 }
761 }764 }
762765
763 return self.fail(tok.start, "cannot parse literal constant", .{});766 return ass.fail(tok.start, "cannot parse literal constant", .{});
764}767}
765768
766fn parseContextDependentInt(self: *Assembler, signedness: std.builtin.Signedness, width: u32) !void {769fn parseContextDependentInt(ass: *Assembler, signedness: std.builtin.Signedness, width: u32) !void {
767 const gpa = self.cg.module.gpa;770 const gpa = ass.cg.module.gpa;
768771
769 const tok = self.currentToken();772 const tok = ass.currentToken();
770 if (self.eatToken(.placeholder)) {773 if (ass.eatToken(.placeholder)) {
771 const name = self.tokenText(tok)[1..];774 const name = ass.tokenText(tok)[1..];
772 const value = self.value_map.get(name) orelse {775 const value = ass.value_map.get(name) orelse {
773 return self.fail(tok.start, "invalid placeholder '${s}'", .{name});776 return ass.fail(tok.start, "invalid placeholder '${s}'", .{name});
774 };777 };
775 switch (value) {778 switch (value) {
776 .constant => |literal32| {779 .constant => |literal32| {
777 try self.inst.operands.append(gpa, .{ .literal32 = literal32 });780 try ass.inst.operands.append(gpa, .{ .literal32 = literal32 });
778 },781 },
779 else => {782 else => {
780 return self.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name});783 return ass.fail(tok.start, "value '{s}' cannot be used as placeholder", .{name});
781 },784 },
782 }785 }
783 return;786 return;
784 }787 }
785788
786 try self.expectToken(.value);789 try ass.expectToken(.value);
787790
788 if (width == 0 or width > 2 * @bitSizeOf(spec.Word)) {791 if (width == 0 or width > 2 * @bitSizeOf(spec.Word)) {
789 return self.fail(tok.start, "cannot parse {}-bit integer literal", .{width});792 return ass.fail(tok.start, "cannot parse {}-bit integer literal", .{width});
790 }793 }
791794
792 const text = self.tokenText(tok);795 const text = ass.tokenText(tok);
793 invalid: {796 invalid: {
794 // Just parse the integer as the next larger integer type, and check if it overflows afterwards.797 // Just parse the integer as the next larger integer type, and check if it overflows afterwards.
795 const int = std.fmt.parseInt(i128, text, 0) catch break :invalid;798 const int = std.fmt.parseInt(i128, text, 0) catch break :invalid;
...@@ -804,104 +807,104 @@ fn parseContextDependentInt(self: *Assembler, signedness: std.builtin.Signedness...@@ -804,104 +807,104 @@ fn parseContextDependentInt(self: *Assembler, signedness: std.builtin.Signedness
804807
805 // Note, we store the sign-extended version here.808 // Note, we store the sign-extended version here.
806 if (width <= @bitSizeOf(spec.Word)) {809 if (width <= @bitSizeOf(spec.Word)) {
807 try self.inst.operands.append(gpa, .{ .literal32 = @truncate(@as(u128, @bitCast(int))) });810 try ass.inst.operands.append(gpa, .{ .literal32 = @truncate(@as(u128, @bitCast(int))) });
808 } else {811 } else {
809 try self.inst.operands.append(gpa, .{ .literal64 = @truncate(@as(u128, @bitCast(int))) });812 try ass.inst.operands.append(gpa, .{ .literal64 = @truncate(@as(u128, @bitCast(int))) });
810 }813 }
811 return;814 return;
812 }815 }
813816
814 return self.fail(tok.start, "'{s}' is not a valid {s} {}-bit int literal", .{ text, @tagName(signedness), width });817 return ass.fail(tok.start, "'{s}' is not a valid {s} {}-bit int literal", .{ text, @tagName(signedness), width });
815}818}
816819
817fn parseContextDependentFloat(self: *Assembler, comptime width: u16) !void {820fn parseContextDependentFloat(ass: *Assembler, comptime width: u16) !void {
818 const gpa = self.cg.module.gpa;821 const gpa = ass.cg.module.gpa;
819822
820 const Float = std.meta.Float(width);823 const Float = std.meta.Float(width);
821 const Int = std.meta.Int(.unsigned, width);824 const Int = std.meta.Int(.unsigned, width);
822825
823 const tok = self.currentToken();826 const tok = ass.currentToken();
824 try self.expectToken(.value);827 try ass.expectToken(.value);
825828
826 const text = self.tokenText(tok);829 const text = ass.tokenText(tok);
827830
828 const value = std.fmt.parseFloat(Float, text) catch {831 const value = std.fmt.parseFloat(Float, text) catch {
829 return self.fail(tok.start, "'{s}' is not a valid {}-bit float literal", .{ text, width });832 return ass.fail(tok.start, "'{s}' is not a valid {}-bit float literal", .{ text, width });
830 };833 };
831834
832 const float_bits: Int = @bitCast(value);835 const float_bits: Int = @bitCast(value);
833 if (width <= @bitSizeOf(spec.Word)) {836 if (width <= @bitSizeOf(spec.Word)) {
834 try self.inst.operands.append(gpa, .{ .literal32 = float_bits });837 try ass.inst.operands.append(gpa, .{ .literal32 = float_bits });
835 } else {838 } else {
836 assert(width <= 2 * @bitSizeOf(spec.Word));839 assert(width <= 2 * @bitSizeOf(spec.Word));
837 try self.inst.operands.append(gpa, .{ .literal64 = float_bits });840 try ass.inst.operands.append(gpa, .{ .literal64 = float_bits });
838 }841 }
839}842}
840843
841fn parsePhiSource(self: *Assembler) !void {844fn parsePhiSource(ass: *Assembler) !void {
842 try self.parseRefId();845 try ass.parseRefId();
843 if (self.isAtInstructionBoundary()) {846 if (ass.isAtInstructionBoundary()) {
844 return self.fail(self.currentToken().start, "missing phi block parent", .{});847 return ass.fail(ass.currentToken().start, "missing phi block parent", .{});
845 }848 }
846 try self.parseRefId();849 try ass.parseRefId();
847}850}
848851
849/// Returns whether the `current_token` cursor852/// Returns whether the `current_token` cursor
850/// is currently pointing at the start of a new instruction.853/// is currently pointing at the start of a new instruction.
851fn isAtInstructionBoundary(self: Assembler) bool {854fn isAtInstructionBoundary(ass: Assembler) bool {
852 return switch (self.currentToken().tag) {855 return switch (ass.currentToken().tag) {
853 .opcode, .result_id_assign, .eof => true,856 .opcode, .result_id_assign, .eof => true,
854 else => false,857 else => false,
855 };858 };
856}859}
857860
858fn expectToken(self: *Assembler, tag: Token.Tag) !void {861fn expectToken(ass: *Assembler, tag: Token.Tag) !void {
859 if (self.eatToken(tag))862 if (ass.eatToken(tag))
860 return;863 return;
861864
862 return self.fail(self.currentToken().start, "unexpected {s}, expected {s}", .{865 return ass.fail(ass.currentToken().start, "unexpected {s}, expected {s}", .{
863 self.currentToken().tag.name(),866 ass.currentToken().tag.name(),
864 tag.name(),867 tag.name(),
865 });868 });
866}869}
867870
868fn eatToken(self: *Assembler, tag: Token.Tag) bool {871fn eatToken(ass: *Assembler, tag: Token.Tag) bool {
869 if (self.testToken(tag)) {872 if (ass.testToken(tag)) {
870 self.current_token += 1;873 ass.current_token += 1;
871 return true;874 return true;
872 }875 }
873 return false;876 return false;
874}877}
875878
876fn testToken(self: Assembler, tag: Token.Tag) bool {879fn testToken(ass: Assembler, tag: Token.Tag) bool {
877 return self.currentToken().tag == tag;880 return ass.currentToken().tag == tag;
878}881}
879882
880fn currentToken(self: Assembler) Token {883fn currentToken(ass: Assembler) Token {
881 return self.tokens.items[self.current_token];884 return ass.tokens.items[ass.current_token];
882}885}
883886
884fn tokenText(self: Assembler, tok: Token) []const u8 {887fn tokenText(ass: Assembler, tok: Token) []const u8 {
885 return self.src[tok.start..tok.end];888 return ass.src[tok.start..tok.end];
886}889}
887890
888/// Tokenize `self.src` and put the tokens in `self.tokens`.891/// Tokenize `ass.src` and put the tokens in `ass.tokens`.
889/// Any errors encountered are appended to `self.errors`.892/// Any errors encountered are appended to `ass.errors`.
890fn tokenize(self: *Assembler) !void {893fn tokenize(ass: *Assembler) !void {
891 const gpa = self.cg.module.gpa;894 const gpa = ass.cg.module.gpa;
892895
893 self.tokens.clearRetainingCapacity();896 ass.tokens.clearRetainingCapacity();
894897
895 var offset: u32 = 0;898 var offset: u32 = 0;
896 while (true) {899 while (true) {
897 const tok = try self.nextToken(offset);900 const tok = try ass.nextToken(offset);
898 // Resolve result-id assignment now.901 // Resolve result-id assignment now.
899 // NOTE: If the previous token wasn't a result-id, just ignore it,902 // NOTE: If the previous token wasn't a result-id, just ignore it,
900 // we will catch it while parsing.903 // we will catch it while parsing.
901 if (tok.tag == .equals and self.tokens.items[self.tokens.items.len - 1].tag == .result_id) {904 if (tok.tag == .equals and ass.tokens.items[ass.tokens.items.len - 1].tag == .result_id) {
902 self.tokens.items[self.tokens.items.len - 1].tag = .result_id_assign;905 ass.tokens.items[ass.tokens.items.len - 1].tag = .result_id_assign;
903 }906 }
904 try self.tokens.append(gpa, tok);907 try ass.tokens.append(gpa, tok);
905 if (tok.tag == .eof)908 if (tok.tag == .eof)
906 break;909 break;
907 offset = tok.end;910 offset = tok.end;
...@@ -943,8 +946,8 @@ const Token = struct {...@@ -943,8 +946,8 @@ const Token = struct {
943 /// These can be used in place of a normal `value`.946 /// These can be used in place of a normal `value`.
944 placeholder,947 placeholder,
945948
946 fn name(self: Tag) []const u8 {949 fn name(tag: Tag) []const u8 {
947 return switch (self) {950 return switch (tag) {
948 .eof => "<end of input>",951 .eof => "<end of input>",
949 .result_id => "<result-id>",952 .result_id => "<result-id>",
950 .result_id_assign => "<assigned result-id>",953 .result_id_assign => "<assigned result-id>",
...@@ -963,7 +966,7 @@ const Token = struct {...@@ -963,7 +966,7 @@ const Token = struct {
963/// that the token is surrounded by whitespace if required, but will not966/// that the token is surrounded by whitespace if required, but will not
964/// interpret the token yet.967/// interpret the token yet.
965/// NOTE: This function doesn't handle .result_id_assign - this is handled in tokenize().968/// NOTE: This function doesn't handle .result_id_assign - this is handled in tokenize().
966fn nextToken(self: *Assembler, start_offset: u32) !Token {969fn nextToken(ass: *Assembler, start_offset: u32) !Token {
967 // We generally separate the input into the following types:970 // We generally separate the input into the following types:
968 // - Whitespace. Generally ignored, but also used as delimiter for some971 // - Whitespace. Generally ignored, but also used as delimiter for some
969 // tokens.972 // tokens.
...@@ -989,8 +992,8 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {...@@ -989,8 +992,8 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {
989 var token_start = start_offset;992 var token_start = start_offset;
990 var offset = start_offset;993 var offset = start_offset;
991 var tag = Token.Tag.eof;994 var tag = Token.Tag.eof;
992 while (offset < self.src.len) : (offset += 1) {995 while (offset < ass.src.len) : (offset += 1) {
993 const c = self.src[offset];996 const c = ass.src[offset];
994 switch (state) {997 switch (state) {
995 .start => switch (c) {998 .start => switch (c) {
996 ' ', '\t', '\r', '\n' => token_start = offset + 1,999 ' ', '\t', '\r', '\n' => token_start = offset + 1,
...@@ -1023,7 +1026,7 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {...@@ -1023,7 +1026,7 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {
1023 },1026 },
1024 .value => switch (c) {1027 .value => switch (c) {
1025 '"' => {1028 '"' => {
1026 try self.addError(offset, "unexpected string literal", .{});1029 try ass.addError(offset, "unexpected string literal", .{});
1027 // The user most likely just forgot a delimiter here - keep1030 // The user most likely just forgot a delimiter here - keep
1028 // the tag as value.1031 // the tag as value.
1029 break;1032 break;
...@@ -1035,7 +1038,7 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {...@@ -1035,7 +1038,7 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {
1035 '_', 'a'...'z', 'A'...'Z', '0'...'9' => {},1038 '_', 'a'...'z', 'A'...'Z', '0'...'9' => {},
1036 ' ', '\t', '\r', '\n', '=', '|' => break,1039 ' ', '\t', '\r', '\n', '=', '|' => break,
1037 else => {1040 else => {
1038 try self.addError(offset, "illegal character in result-id or placeholder", .{});1041 try ass.addError(offset, "illegal character in result-id or placeholder", .{});
1039 // Again, probably a forgotten delimiter here.1042 // Again, probably a forgotten delimiter here.
1040 break;1043 break;
1041 },1044 },
...@@ -1048,7 +1051,7 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {...@@ -1048,7 +1051,7 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {
1048 .string_end => switch (c) {1051 .string_end => switch (c) {
1049 ' ', '\t', '\r', '\n', '=', '|' => break,1052 ' ', '\t', '\r', '\n', '=', '|' => break,
1050 else => {1053 else => {
1051 try self.addError(offset, "unexpected character after string literal", .{});1054 try ass.addError(offset, "unexpected character after string literal", .{});
1052 // The token is still unmistakibly a string.1055 // The token is still unmistakibly a string.
1053 break;1056 break;
1054 },1057 },
...@@ -1066,13 +1069,13 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {...@@ -1066,13 +1069,13 @@ fn nextToken(self: *Assembler, start_offset: u32) !Token {
10661069
1067 switch (state) {1070 switch (state) {
1068 .string, .escape => {1071 .string, .escape => {
1069 try self.addError(token_start, "unterminated string", .{});1072 try ass.addError(token_start, "unterminated string", .{});
1070 },1073 },
1071 .result_id => if (offset - token_start == 1) {1074 .result_id => if (offset - token_start == 1) {
1072 try self.addError(token_start, "result-id must have at least one name character", .{});1075 try ass.addError(token_start, "result-id must have at least one name character", .{});
1073 },1076 },
1074 .value => {1077 .value => {
1075 const text = self.tokenText(tok);1078 const text = ass.tokenText(tok);
1076 const prefix = "Op";1079 const prefix = "Op";
1077 const looks_like_opcode = text.len > prefix.len and1080 const looks_like_opcode = text.len > prefix.len and
1078 std.mem.startsWith(u8, text, prefix) and1081 std.mem.startsWith(u8, text, prefix) and
src/codegen/spirv/CodeGen.zig+310-290
...@@ -144,36 +144,28 @@ const ControlFlow = union(enum) {...@@ -144,36 +144,28 @@ const ControlFlow = union(enum) {
144144
145pt: Zcu.PerThread,145pt: Zcu.PerThread,
146air: Air,146air: Air,
147/// Note: If the declaration is not a function, this value will be undefined!
148liveness: Air.Liveness,147liveness: Air.Liveness,
149owner_nav: InternPool.Nav.Index,148owner_nav: InternPool.Nav.Index,
150module: *Module,149module: *Module,
151control_flow: ControlFlow,150control_flow: ControlFlow,
152base_line: u32,151base_line: u32,
153block_label: Id = .none,152block_label: Id = .none,
154/// The base offset of the current decl, which is what `dbg_stmt` is relative to.
155/// An array of function argument result-ids. Each index corresponds with the
156/// function argument of the same index.
157args: std.ArrayListUnmanaged(Id) = .empty,
158/// A counter to keep track of how many `arg` instructions we've seen yet.
159next_arg_index: u32 = 0,153next_arg_index: u32 = 0,
160/// A map keeping track of which instruction generated which result-id.154args: std.ArrayListUnmanaged(Id) = .empty,
161inst_results: std.AutoHashMapUnmanaged(Air.Inst.Index, Id) = .empty,155inst_results: std.AutoHashMapUnmanaged(Air.Inst.Index, Id) = .empty,
162file_path_id: Id = .none,156id_scratch: std.ArrayListUnmanaged(Id) = .empty,
163prologue: Section = .{},157prologue: Section = .{},
164body: Section = .{},158body: Section = .{},
165decl_deps: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .empty,
166error_msg: ?*Zcu.ErrorMsg = null,159error_msg: ?*Zcu.ErrorMsg = null,
167160
168/// Free resources owned by the CodeGen.
169pub fn deinit(cg: *CodeGen) void {161pub fn deinit(cg: *CodeGen) void {
170 const gpa = cg.module.gpa;162 const gpa = cg.module.gpa;
163 cg.control_flow.deinit(gpa);
171 cg.args.deinit(gpa);164 cg.args.deinit(gpa);
172 cg.inst_results.deinit(gpa);165 cg.inst_results.deinit(gpa);
173 cg.control_flow.deinit(gpa);166 cg.id_scratch.deinit(gpa);
174 cg.prologue.deinit(gpa);167 cg.prologue.deinit(gpa);
175 cg.body.deinit(gpa);168 cg.body.deinit(gpa);
176 cg.decl_deps.deinit(gpa);
177}169}
178170
179const Error = error{ CodegenFail, OutOfMemory };171const Error = error{ CodegenFail, OutOfMemory };
...@@ -191,9 +183,11 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -191,9 +183,11 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
191 if (!do_codegen and !ty.hasRuntimeBits(zcu)) return;183 if (!do_codegen and !ty.hasRuntimeBits(zcu)) return;
192184
193 const spv_decl_index = try cg.module.resolveNav(ip, cg.owner_nav);185 const spv_decl_index = try cg.module.resolveNav(ip, cg.owner_nav);
194 const result_id = cg.module.declPtr(spv_decl_index).result_id;186 const decl = cg.module.declPtr(spv_decl_index);
187 const result_id = decl.result_id;
188 decl.begin_dep = cg.module.decl_deps.items.len;
195189
196 switch (cg.module.declPtr(spv_decl_index).kind) {190 switch (decl.kind) {
197 .func => {191 .func => {
198 const fn_info = zcu.typeToFunc(ty).?;192 const fn_info = zcu.typeToFunc(ty).?;
199 const return_ty_id = try cg.resolveFnReturnType(.fromInterned(fn_info.return_type));193 const return_ty_id = try cg.resolveFnReturnType(.fromInterned(fn_info.return_type));
...@@ -201,7 +195,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -201,7 +195,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
201195
202 const func_result_id = if (is_test) cg.module.allocId() else result_id;196 const func_result_id = if (is_test) cg.module.allocId() else result_id;
203 const prototype_ty_id = try cg.resolveType(ty, .direct);197 const prototype_ty_id = try cg.resolveType(ty, .direct);
204 try cg.prologue.emit(cg.module.gpa, .OpFunction, .{198 try cg.prologue.emit(gpa, .OpFunction, .{
205 .id_result_type = return_ty_id,199 .id_result_type = return_ty_id,
206 .id_result = func_result_id,200 .id_result = func_result_id,
207 .function_type = prototype_ty_id,201 .function_type = prototype_ty_id,
...@@ -218,7 +212,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -218,7 +212,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
218212
219 const param_type_id = try cg.resolveType(param_ty, .direct);213 const param_type_id = try cg.resolveType(param_ty, .direct);
220 const arg_result_id = cg.module.allocId();214 const arg_result_id = cg.module.allocId();
221 try cg.prologue.emit(cg.module.gpa, .OpFunctionParameter, .{215 try cg.prologue.emit(gpa, .OpFunctionParameter, .{
222 .id_result_type = param_type_id,216 .id_result_type = param_type_id,
223 .id_result = arg_result_id,217 .id_result = arg_result_id,
224 });218 });
...@@ -230,7 +224,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -230,7 +224,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
230224
231 // The root block of a function declaration should appear before OpVariable instructions,225 // The root block of a function declaration should appear before OpVariable instructions,
232 // so it is generated into the function's prologue.226 // so it is generated into the function's prologue.
233 try cg.prologue.emit(cg.module.gpa, .OpLabel, .{227 try cg.prologue.emit(gpa, .OpLabel, .{
234 .id_result = root_block_id,228 .id_result = root_block_id,
235 });229 });
236 cg.block_label = root_block_id;230 cg.block_label = root_block_id;
...@@ -241,23 +235,22 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -241,23 +235,22 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
241 _ = try cg.genStructuredBody(.selection, main_body);235 _ = try cg.genStructuredBody(.selection, main_body);
242 // We always expect paths to here to end, but we still need the block236 // We always expect paths to here to end, but we still need the block
243 // to act as a dummy merge block.237 // to act as a dummy merge block.
244 try cg.body.emit(cg.module.gpa, .OpUnreachable, {});238 try cg.body.emit(gpa, .OpUnreachable, {});
245 },239 },
246 .unstructured => {240 .unstructured => {
247 try cg.genBody(main_body);241 try cg.genBody(main_body);
248 },242 },
249 }243 }
250 try cg.body.emit(cg.module.gpa, .OpFunctionEnd, {});244 try cg.body.emit(gpa, .OpFunctionEnd, {});
251 // Append the actual code into the functions section.245 // Append the actual code into the functions section.
252 try cg.module.sections.functions.append(cg.module.gpa, cg.prologue);246 try cg.module.sections.functions.append(gpa, cg.prologue);
253 try cg.module.sections.functions.append(cg.module.gpa, cg.body);247 try cg.module.sections.functions.append(gpa, cg.body);
254248
255 // Temporarily generate a test kernel declaration if this is a test function.249 // Temporarily generate a test kernel declaration if this is a test function.
256 if (is_test) {250 if (is_test) {
257 try cg.generateTestEntryPoint(nav.fqn.toSlice(ip), spv_decl_index, func_result_id);251 try cg.generateTestEntryPoint(nav.fqn.toSlice(ip), spv_decl_index, func_result_id);
258 }252 }
259253
260 try cg.module.declareDeclDeps(spv_decl_index, cg.decl_deps.keys());
261 try cg.module.debugName(func_result_id, nav.fqn.toSlice(ip));254 try cg.module.debugName(func_result_id, nav.fqn.toSlice(ip));
262 },255 },
263 .global => {256 .global => {
...@@ -275,7 +268,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -275,7 +268,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
275 const ty_id = try cg.resolveType(ty, .indirect);268 const ty_id = try cg.resolveType(ty, .indirect);
276 const ptr_ty_id = try cg.module.ptrType(ty_id, storage_class);269 const ptr_ty_id = try cg.module.ptrType(ty_id, storage_class);
277270
278 try cg.module.sections.globals.emit(cg.module.gpa, .OpVariable, .{271 try cg.module.sections.globals.emit(gpa, .OpVariable, .{
279 .id_result_type = ptr_ty_id,272 .id_result_type = ptr_ty_id,
280 .id_result = result_id,273 .id_result = result_id,
281 .storage_class = storage_class,274 .storage_class = storage_class,
...@@ -307,7 +300,6 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -307,7 +300,6 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
307 }300 }
308301
309 try cg.module.debugName(result_id, nav.fqn.toSlice(ip));302 try cg.module.debugName(result_id, nav.fqn.toSlice(ip));
310 try cg.module.declareDeclDeps(spv_decl_index, &.{});
311 },303 },
312 .invocation_global => {304 .invocation_global => {
313 const maybe_init_val: ?Value = switch (ip.indexToKey(val.toIntern())) {305 const maybe_init_val: ?Value = switch (ip.indexToKey(val.toIntern())) {
...@@ -317,8 +309,6 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -317,8 +309,6 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
317 else => val,309 else => val,
318 };310 };
319311
320 try cg.module.declareDeclDeps(spv_decl_index, &.{});
321
322 const ty_id = try cg.resolveType(ty, .indirect);312 const ty_id = try cg.resolveType(ty, .indirect);
323 const ptr_ty_id = try cg.module.ptrType(ty_id, .function);313 const ptr_ty_id = try cg.module.ptrType(ty_id, .function);
324314
...@@ -328,7 +318,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -328,7 +318,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
328 const initializer_proto_ty_id = try cg.module.functionType(void_ty_id, &.{});318 const initializer_proto_ty_id = try cg.module.functionType(void_ty_id, &.{});
329319
330 const initializer_id = cg.module.allocId();320 const initializer_id = cg.module.allocId();
331 try cg.prologue.emit(cg.module.gpa, .OpFunction, .{321 try cg.prologue.emit(gpa, .OpFunction, .{
332 .id_result_type = try cg.resolveType(.void, .direct),322 .id_result_type = try cg.resolveType(.void, .direct),
333 .id_result = initializer_id,323 .id_result = initializer_id,
334 .function_control = .{},324 .function_control = .{},
...@@ -336,26 +326,25 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -336,26 +326,25 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
336 });326 });
337327
338 const root_block_id = cg.module.allocId();328 const root_block_id = cg.module.allocId();
339 try cg.prologue.emit(cg.module.gpa, .OpLabel, .{329 try cg.prologue.emit(gpa, .OpLabel, .{
340 .id_result = root_block_id,330 .id_result = root_block_id,
341 });331 });
342 cg.block_label = root_block_id;332 cg.block_label = root_block_id;
343333
344 const val_id = try cg.constant(ty, init_val, .indirect);334 const val_id = try cg.constant(ty, init_val, .indirect);
345 try cg.body.emit(cg.module.gpa, .OpStore, .{335 try cg.body.emit(gpa, .OpStore, .{
346 .pointer = result_id,336 .pointer = result_id,
347 .object = val_id,337 .object = val_id,
348 });338 });
349339
350 try cg.body.emit(cg.module.gpa, .OpReturn, {});340 try cg.body.emit(gpa, .OpReturn, {});
351 try cg.body.emit(cg.module.gpa, .OpFunctionEnd, {});341 try cg.body.emit(gpa, .OpFunctionEnd, {});
352 try cg.module.sections.functions.append(cg.module.gpa, cg.prologue);342 try cg.module.sections.functions.append(gpa, cg.prologue);
353 try cg.module.sections.functions.append(cg.module.gpa, cg.body);343 try cg.module.sections.functions.append(gpa, cg.body);
354 try cg.module.declareDeclDeps(spv_decl_index, cg.decl_deps.keys());
355344
356 try cg.module.debugNameFmt(initializer_id, "initializer of {f}", .{nav.fqn.fmt(ip)});345 try cg.module.debugNameFmt(initializer_id, "initializer of {f}", .{nav.fqn.fmt(ip)});
357346
358 try cg.module.sections.globals.emit(cg.module.gpa, .OpExtInst, .{347 try cg.module.sections.globals.emit(gpa, .OpExtInst, .{
359 .id_result_type = ptr_ty_id,348 .id_result_type = ptr_ty_id,
360 .id_result = result_id,349 .id_result = result_id,
361 .set = try cg.module.importInstructionSet(.zig),350 .set = try cg.module.importInstructionSet(.zig),
...@@ -363,7 +352,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -363,7 +352,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
363 .id_ref_4 = &.{initializer_id},352 .id_ref_4 = &.{initializer_id},
364 });353 });
365 } else {354 } else {
366 try cg.module.sections.globals.emit(cg.module.gpa, .OpExtInst, .{355 try cg.module.sections.globals.emit(gpa, .OpExtInst, .{
367 .id_result_type = ptr_ty_id,356 .id_result_type = ptr_ty_id,
368 .id_result = result_id,357 .id_result = result_id,
369 .set = try cg.module.importInstructionSet(.zig),358 .set = try cg.module.importInstructionSet(.zig),
...@@ -373,6 +362,8 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {...@@ -373,6 +362,8 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
373 }362 }
374 },363 },
375 }364 }
365
366 cg.module.declPtr(spv_decl_index).end_dep = cg.module.decl_deps.items.len;
376}367}
377368
378pub fn fail(cg: *CodeGen, comptime format: []const u8, args: anytype) Error {369pub fn fail(cg: *CodeGen, comptime format: []const u8, args: anytype) Error {
...@@ -413,7 +404,7 @@ fn resolve(cg: *CodeGen, inst: Air.Inst.Ref) !Id {...@@ -413,7 +404,7 @@ fn resolve(cg: *CodeGen, inst: Air.Inst.Ref) !Id {
413 else => unreachable,404 else => unreachable,
414 };405 };
415 const spv_decl_index = try cg.module.resolveNav(ip, fn_nav);406 const spv_decl_index = try cg.module.resolveNav(ip, fn_nav);
416 try cg.decl_deps.put(cg.module.gpa, spv_decl_index, {});407 try cg.module.decl_deps.append(cg.module.gpa, spv_decl_index);
417 return cg.module.declPtr(spv_decl_index).result_id;408 return cg.module.declPtr(spv_decl_index).result_id;
418 }409 }
419410
...@@ -433,7 +424,7 @@ fn resolveUav(cg: *CodeGen, val: InternPool.Index) !Id {...@@ -433,7 +424,7 @@ fn resolveUav(cg: *CodeGen, val: InternPool.Index) !Id {
433 const ty_id = try cg.resolveType(ty, .indirect);424 const ty_id = try cg.resolveType(ty, .indirect);
434425
435 const spv_decl_index = blk: {426 const spv_decl_index = blk: {
436 const entry = try cg.module.uav_link.getOrPut(cg.module.gpa, .{ val, .function });427 const entry = try cg.module.uav_link.getOrPut(gpa, .{ val, .function });
437 if (entry.found_existing) {428 if (entry.found_existing) {
438 try cg.addFunctionDep(entry.value_ptr.*, .function);429 try cg.addFunctionDep(entry.value_ptr.*, .function);
439 return cg.module.declPtr(entry.value_ptr.*).result_id;430 return cg.module.declPtr(entry.value_ptr.*).result_id;
...@@ -458,57 +449,52 @@ fn resolveUav(cg: *CodeGen, val: InternPool.Index) !Id {...@@ -458,57 +449,52 @@ fn resolveUav(cg: *CodeGen, val: InternPool.Index) !Id {
458 // TODO: This should probably be made a little more robust.449 // TODO: This should probably be made a little more robust.
459 const func_prologue = cg.prologue;450 const func_prologue = cg.prologue;
460 const func_body = cg.body;451 const func_body = cg.body;
461 const func_deps = cg.decl_deps;
462 const block_label = cg.block_label;452 const block_label = cg.block_label;
463 defer {453 defer {
464 cg.prologue = func_prologue;454 cg.prologue = func_prologue;
465 cg.body = func_body;455 cg.body = func_body;
466 cg.decl_deps = func_deps;
467 cg.block_label = block_label;456 cg.block_label = block_label;
468 }457 }
469458
470 cg.prologue = .{};459 cg.prologue = .{};
471 cg.body = .{};460 cg.body = .{};
472 cg.decl_deps = .{};
473 defer {461 defer {
474 cg.prologue.deinit(gpa);462 cg.prologue.deinit(gpa);
475 cg.body.deinit(gpa);463 cg.body.deinit(gpa);
476 cg.decl_deps.deinit(gpa);
477 }464 }
478465
479 const void_ty_id = try cg.resolveType(.void, .direct);466 const void_ty_id = try cg.resolveType(.void, .direct);
480 const initializer_proto_ty_id = try cg.module.functionType(void_ty_id, &.{});467 const initializer_proto_ty_id = try cg.module.functionType(void_ty_id, &.{});
481468
482 const initializer_id = cg.module.allocId();469 const initializer_id = cg.module.allocId();
483 try cg.prologue.emit(cg.module.gpa, .OpFunction, .{470 try cg.prologue.emit(gpa, .OpFunction, .{
484 .id_result_type = try cg.resolveType(.void, .direct),471 .id_result_type = try cg.resolveType(.void, .direct),
485 .id_result = initializer_id,472 .id_result = initializer_id,
486 .function_control = .{},473 .function_control = .{},
487 .function_type = initializer_proto_ty_id,474 .function_type = initializer_proto_ty_id,
488 });475 });
489 const root_block_id = cg.module.allocId();476 const root_block_id = cg.module.allocId();
490 try cg.prologue.emit(cg.module.gpa, .OpLabel, .{477 try cg.prologue.emit(gpa, .OpLabel, .{
491 .id_result = root_block_id,478 .id_result = root_block_id,
492 });479 });
493 cg.block_label = root_block_id;480 cg.block_label = root_block_id;
494481
495 const val_id = try cg.constant(ty, .fromInterned(val), .indirect);482 const val_id = try cg.constant(ty, .fromInterned(val), .indirect);
496 try cg.body.emit(cg.module.gpa, .OpStore, .{483 try cg.body.emit(gpa, .OpStore, .{
497 .pointer = result_id,484 .pointer = result_id,
498 .object = val_id,485 .object = val_id,
499 });486 });
500487
501 try cg.body.emit(cg.module.gpa, .OpReturn, {});488 try cg.body.emit(gpa, .OpReturn, {});
502 try cg.body.emit(cg.module.gpa, .OpFunctionEnd, {});489 try cg.body.emit(gpa, .OpFunctionEnd, {});
503490
504 try cg.module.sections.functions.append(cg.module.gpa, cg.prologue);491 try cg.module.sections.functions.append(gpa, cg.prologue);
505 try cg.module.sections.functions.append(cg.module.gpa, cg.body);492 try cg.module.sections.functions.append(gpa, cg.body);
506 try cg.module.declareDeclDeps(spv_decl_index, cg.decl_deps.keys());
507493
508 try cg.module.debugNameFmt(initializer_id, "initializer of __anon_{d}", .{@intFromEnum(val)});494 try cg.module.debugNameFmt(initializer_id, "initializer of __anon_{d}", .{@intFromEnum(val)});
509495
510 const fn_decl_ptr_ty_id = try cg.module.ptrType(ty_id, .function);496 const fn_decl_ptr_ty_id = try cg.module.ptrType(ty_id, .function);
511 try cg.module.sections.globals.emit(cg.module.gpa, .OpExtInst, .{497 try cg.module.sections.globals.emit(gpa, .OpExtInst, .{
512 .id_result_type = fn_decl_ptr_ty_id,498 .id_result_type = fn_decl_ptr_ty_id,
513 .id_result = result_id,499 .id_result = result_id,
514 .set = try cg.module.importInstructionSet(.zig),500 .set = try cg.module.importInstructionSet(.zig),
...@@ -521,13 +507,14 @@ fn resolveUav(cg: *CodeGen, val: InternPool.Index) !Id {...@@ -521,13 +507,14 @@ fn resolveUav(cg: *CodeGen, val: InternPool.Index) !Id {
521}507}
522508
523fn addFunctionDep(cg: *CodeGen, decl_index: Module.Decl.Index, storage_class: StorageClass) !void {509fn addFunctionDep(cg: *CodeGen, decl_index: Module.Decl.Index, storage_class: StorageClass) !void {
510 const gpa = cg.module.gpa;
524 const target = cg.module.zcu.getTarget();511 const target = cg.module.zcu.getTarget();
525 if (target.cpu.has(.spirv, .v1_4)) {512 if (target.cpu.has(.spirv, .v1_4)) {
526 try cg.decl_deps.put(cg.module.gpa, decl_index, {});513 try cg.module.decl_deps.append(gpa, decl_index);
527 } else {514 } else {
528 // Before version 1.4, the interface’s storage classes are limited to the Input and Output515 // Before version 1.4, the interface’s storage classes are limited to the Input and Output
529 if (storage_class == .input or storage_class == .output) {516 if (storage_class == .input or storage_class == .output) {
530 try cg.decl_deps.put(cg.module.gpa, decl_index, {});517 try cg.module.decl_deps.append(gpa, decl_index);
531 }518 }
532 }519 }
533}520}
...@@ -752,8 +739,10 @@ fn constructCompositeSplat(cg: *CodeGen, ty: Type, constituent: Id) !Id {...@@ -752,8 +739,10 @@ fn constructCompositeSplat(cg: *CodeGen, ty: Type, constituent: Id) !Id {
752 const zcu = cg.module.zcu;739 const zcu = cg.module.zcu;
753 const n: usize = @intCast(ty.arrayLen(zcu));740 const n: usize = @intCast(ty.arrayLen(zcu));
754741
755 const constituents = try gpa.alloc(Id, n);742 const scratch_top = cg.id_scratch.items.len;
756 defer gpa.free(constituents);743 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
744
745 const constituents = try cg.id_scratch.addManyAsSlice(gpa, n);
757 @memset(constituents, constituent);746 @memset(constituents, constituent);
758747
759 const result_ty_id = try cg.resolveType(ty, .direct);748 const result_ty_id = try cg.resolveType(ty, .direct);
...@@ -928,8 +917,9 @@ fn constant(cg: *CodeGen, ty: Type, val: Value, repr: Repr) Error!Id {...@@ -928,8 +917,9 @@ fn constant(cg: *CodeGen, ty: Type, val: Value, repr: Repr) Error!Id {
928 inline .array_type, .vector_type => |array_type, tag| {917 inline .array_type, .vector_type => |array_type, tag| {
929 const elem_ty: Type = .fromInterned(array_type.child);918 const elem_ty: Type = .fromInterned(array_type.child);
930919
931 const constituents = try gpa.alloc(Id, @intCast(ty.arrayLenIncludingSentinel(zcu)));920 const scratch_top = cg.id_scratch.items.len;
932 defer gpa.free(constituents);921 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
922 const constituents = try cg.id_scratch.addManyAsSlice(gpa, @intCast(ty.arrayLenIncludingSentinel(zcu)));
933923
934 const child_repr: Repr = switch (tag) {924 const child_repr: Repr = switch (tag) {
935 .array_type => .indirect,925 .array_type => .indirect,
...@@ -1044,6 +1034,7 @@ fn constantPtr(cg: *CodeGen, ptr_val: Value) !Id {...@@ -1044,6 +1034,7 @@ fn constantPtr(cg: *CodeGen, ptr_val: Value) !Id {
1044}1034}
10451035
1046fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {1036fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
1037 const gpa = cg.module.gpa;
1047 const pt = cg.pt;1038 const pt = cg.pt;
1048 const zcu = cg.module.zcu;1039 const zcu = cg.module.zcu;
1049 switch (derivation) {1040 switch (derivation) {
...@@ -1055,7 +1046,7 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {...@@ -1055,7 +1046,7 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
1055 // as a runtime operation.1046 // as a runtime operation.
1056 const result_ptr_id = cg.module.allocId();1047 const result_ptr_id = cg.module.allocId();
1057 const value_id = try cg.constInt(.usize, int.addr);1048 const value_id = try cg.constInt(.usize, int.addr);
1058 try cg.body.emit(cg.module.gpa, .OpConvertUToPtr, .{1049 try cg.body.emit(gpa, .OpConvertUToPtr, .{
1059 .id_result_type = result_ty_id,1050 .id_result_type = result_ty_id,
1060 .id_result = result_ptr_id,1051 .id_result = result_ptr_id,
1061 .integer_value = value_id,1052 .integer_value = value_id,
...@@ -1103,7 +1094,7 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {...@@ -1103,7 +1094,7 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
1103 // Allow changing the pointer type child only to restructure arrays.1094 // Allow changing the pointer type child only to restructure arrays.
1104 // e.g. [3][2]T to T is fine, as is [2]T -> [2][1]T.1095 // e.g. [3][2]T to T is fine, as is [2]T -> [2][1]T.
1105 const result_ptr_id = cg.module.allocId();1096 const result_ptr_id = cg.module.allocId();
1106 try cg.body.emit(cg.module.gpa, .OpBitcast, .{1097 try cg.body.emit(gpa, .OpBitcast, .{
1107 .id_result_type = result_ty_id,1098 .id_result_type = result_ty_id,
1108 .id_result = result_ptr_id,1099 .id_result = result_ptr_id,
1109 .operand = parent_ptr_id,1100 .operand = parent_ptr_id,
...@@ -1191,6 +1182,7 @@ fn constantNavRef(cg: *CodeGen, ty: Type, nav_index: InternPool.Nav.Index) !Id {...@@ -1191,6 +1182,7 @@ fn constantNavRef(cg: *CodeGen, ty: Type, nav_index: InternPool.Nav.Index) !Id {
11911182
1192 const spv_decl_index = try cg.module.resolveNav(ip, nav_index);1183 const spv_decl_index = try cg.module.resolveNav(ip, nav_index);
1193 const spv_decl = cg.module.declPtr(spv_decl_index);1184 const spv_decl = cg.module.declPtr(spv_decl_index);
1185 const spv_decl_result_id = spv_decl.result_id;
1194 assert(spv_decl.kind != .func);1186 assert(spv_decl.kind != .func);
11951187
1196 const storage_class = cg.module.storageClass(nav.getAddrspace());1188 const storage_class = cg.module.storageClass(nav.getAddrspace());
...@@ -1205,12 +1197,12 @@ fn constantNavRef(cg: *CodeGen, ty: Type, nav_index: InternPool.Nav.Index) !Id {...@@ -1205,12 +1197,12 @@ fn constantNavRef(cg: *CodeGen, ty: Type, nav_index: InternPool.Nav.Index) !Id {
1205 try cg.body.emit(cg.module.gpa, .OpBitcast, .{1197 try cg.body.emit(cg.module.gpa, .OpBitcast, .{
1206 .id_result_type = ty_id,1198 .id_result_type = ty_id,
1207 .id_result = casted_ptr_id,1199 .id_result = casted_ptr_id,
1208 .operand = spv_decl.result_id,1200 .operand = spv_decl_result_id,
1209 });1201 });
1210 return casted_ptr_id;1202 return casted_ptr_id;
1211 }1203 }
12121204
1213 return spv_decl.result_id;1205 return spv_decl_result_id;
1214}1206}
12151207
1216// Turn a Zig type's name into a cache reference.1208// Turn a Zig type's name into a cache reference.
...@@ -1430,8 +1422,11 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id {...@@ -1430,8 +1422,11 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id {
1430 }1422 }
14311423
1432 const return_ty_id = try cg.resolveFnReturnType(.fromInterned(fn_info.return_type));1424 const return_ty_id = try cg.resolveFnReturnType(.fromInterned(fn_info.return_type));
1433 const param_ty_ids = try gpa.alloc(Id, fn_info.param_types.len);1425
1434 defer gpa.free(param_ty_ids);1426 const scratch_top = cg.id_scratch.items.len;
1427 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
1428 const param_ty_ids = try cg.id_scratch.addManyAsSlice(gpa, fn_info.param_types.len);
1429
1435 var param_index: usize = 0;1430 var param_index: usize = 0;
1436 for (fn_info.param_types.get(ip)) |param_ty_index| {1431 for (fn_info.param_types.get(ip)) |param_ty_index| {
1437 const param_ty: Type = .fromInterned(param_ty_index);1432 const param_ty: Type = .fromInterned(param_ty_index);
...@@ -1472,8 +1467,9 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id {...@@ -1472,8 +1467,9 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id {
1472 .@"struct" => {1467 .@"struct" => {
1473 const struct_type = switch (ip.indexToKey(ty.toIntern())) {1468 const struct_type = switch (ip.indexToKey(ty.toIntern())) {
1474 .tuple_type => |tuple| {1469 .tuple_type => |tuple| {
1475 const member_types = try gpa.alloc(Id, tuple.values.len);1470 const scratch_top = cg.id_scratch.items.len;
1476 defer gpa.free(member_types);1471 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
1472 const member_types = try cg.id_scratch.addManyAsSlice(gpa, tuple.values.len);
14771473
1478 var member_index: usize = 0;1474 var member_index: usize = 0;
1479 for (tuple.types.get(ip), tuple.values.get(ip)) |field_ty, field_val| {1475 for (tuple.types.get(ip), tuple.values.get(ip)) |field_ty, field_val| {
...@@ -1755,11 +1751,14 @@ const Temporary = struct {...@@ -1755,11 +1751,14 @@ const Temporary = struct {
1755 .exploded_vector => |range| {1751 .exploded_vector => |range| {
1756 assert(temp.ty.isVector(zcu));1752 assert(temp.ty.isVector(zcu));
1757 assert(temp.ty.vectorLen(zcu) == range.len);1753 assert(temp.ty.vectorLen(zcu) == range.len);
1758 const constituents = try gpa.alloc(Id, range.len);1754
1759 defer gpa.free(constituents);1755 const scratch_top = cg.id_scratch.items.len;
1756 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
1757 const constituents = try cg.id_scratch.addManyAsSlice(gpa, range.len);
1760 for (constituents, 0..range.len) |*id, i| {1758 for (constituents, 0..range.len) |*id, i| {
1761 id.* = range.at(i);1759 id.* = range.at(i);
1762 }1760 }
1761
1763 const result_ty_id = try cg.resolveType(temp.ty, .direct);1762 const result_ty_id = try cg.resolveType(temp.ty, .direct);
1764 return cg.constructComposite(result_ty_id, constituents);1763 return cg.constructComposite(result_ty_id, constituents);
1765 },1764 },
...@@ -2039,14 +2038,12 @@ fn buildFma(cg: *CodeGen, a: Temporary, b: Temporary, c: Temporary) !Temporary {...@@ -2039,14 +2038,12 @@ fn buildFma(cg: *CodeGen, a: Temporary, b: Temporary, c: Temporary) !Temporary {
2039 const op_c = try v.prepare(cg, c);2038 const op_c = try v.prepare(cg, c);
20402039
2041 const set = try cg.importExtendedSet();2040 const set = try cg.importExtendedSet();
20422041 const opcode: u32 = switch (target.os.tag) {
2043 // TODO: Put these numbers in some definition2042 .opencl => @intFromEnum(spec.OpenClOpcode.fma),
2044 const instruction: u32 = switch (target.os.tag) {
2045 .opencl => 26, // fma
2046 // NOTE: Vulkan's FMA instruction does *NOT* produce the right values!2043 // NOTE: Vulkan's FMA instruction does *NOT* produce the right values!
2047 // its precision guarantees do NOT match zigs and it does NOT match OpenCLs!2044 // its precision guarantees do NOT match zigs and it does NOT match OpenCLs!
2048 // it needs to be emulated!2045 // it needs to be emulated!
2049 .vulkan, .opengl => return cg.todo("implement fma operation for {s} os", .{@tagName(target.os.tag)}),2046 .vulkan, .opengl => @intFromEnum(spec.GlslOpcode.Fma),
2050 else => unreachable,2047 else => unreachable,
2051 };2048 };
20522049
...@@ -2055,7 +2052,7 @@ fn buildFma(cg: *CodeGen, a: Temporary, b: Temporary, c: Temporary) !Temporary {...@@ -2055,7 +2052,7 @@ fn buildFma(cg: *CodeGen, a: Temporary, b: Temporary, c: Temporary) !Temporary {
2055 .id_result_type = op_result_ty_id,2052 .id_result_type = op_result_ty_id,
2056 .id_result = results.at(i),2053 .id_result = results.at(i),
2057 .set = set,2054 .set = set,
2058 .instruction = .{ .inst = instruction },2055 .instruction = .{ .inst = opcode },
2059 .id_ref_4 = &.{ op_a.at(i), op_b.at(i), op_c.at(i) },2056 .id_ref_4 = &.{ op_a.at(i), op_b.at(i), op_c.at(i) },
2060 });2057 });
2061 }2058 }
...@@ -2138,6 +2135,44 @@ const UnaryOp = enum {...@@ -2138,6 +2135,44 @@ const UnaryOp = enum {
2138 log,2135 log,
2139 log2,2136 log2,
2140 log10,2137 log10,
2138
2139 pub fn extInstOpcode(op: UnaryOp, target: *const std.Target) ?u32 {
2140 return switch (target.os.tag) {
2141 .opencl => @intFromEnum(@as(spec.OpenClOpcode, switch (op) {
2142 .i_abs => .s_abs,
2143 .f_abs => .fabs,
2144 .clz => .clz,
2145 .ctz => .ctz,
2146 .floor => .floor,
2147 .ceil => .ceil,
2148 .trunc => .trunc,
2149 .round => .round,
2150 .sqrt => .sqrt,
2151 .sin => .sin,
2152 .cos => .cos,
2153 .tan => .tan,
2154 .exp => .exp,
2155 .exp2 => .exp2,
2156 .log => .log,
2157 .log2 => .log2,
2158 .log10 => .log10,
2159 else => return null,
2160 })),
2161 // Note: We'll need to check these for floating point accuracy
2162 // Vulkan does not put tight requirements on these, for correction
2163 // we might want to emulate them at some point.
2164 .vulkan, .opengl => @intFromEnum(@as(spec.GlslOpcode, switch (op) {
2165 .i_abs => .SAbs,
2166 .f_abs => .FAbs,
2167 .floor => .Floor,
2168 .ceil => .Ceil,
2169 .trunc => .Trunc,
2170 .round => .Round,
2171 else => return null,
2172 })),
2173 else => unreachable,
2174 };
2175 }
2141};2176};
21422177
2143fn buildUnary(cg: *CodeGen, op: UnaryOp, operand: Temporary) !Temporary {2178fn buildUnary(cg: *CodeGen, op: UnaryOp, operand: Temporary) !Temporary {
...@@ -2149,84 +2184,36 @@ fn buildUnary(cg: *CodeGen, op: UnaryOp, operand: Temporary) !Temporary {...@@ -2149,84 +2184,36 @@ fn buildUnary(cg: *CodeGen, op: UnaryOp, operand: Temporary) !Temporary {
2149 const op_result_ty = operand.ty.scalarType(zcu);2184 const op_result_ty = operand.ty.scalarType(zcu);
2150 const op_result_ty_id = try cg.resolveType(op_result_ty, .direct);2185 const op_result_ty_id = try cg.resolveType(op_result_ty, .direct);
2151 const result_ty = try v.resultType(cg, operand.ty);2186 const result_ty = try v.resultType(cg, operand.ty);
2152
2153 const op_operand = try v.prepare(cg, operand);2187 const op_operand = try v.prepare(cg, operand);
21542188
2155 if (switch (op) {2189 if (op.extInstOpcode(target)) |opcode| {
2156 .l_not => .OpLogicalNot,
2157 .bit_not => .OpNot,
2158 .i_neg => .OpSNegate,
2159 .f_neg => .OpFNegate,
2160 else => @as(?Opcode, null),
2161 }) |opcode| {
2162 for (0..ops) |i| {
2163 try cg.body.emitRaw(cg.module.gpa, opcode, 3);
2164 cg.body.writeOperand(Id, op_result_ty_id);
2165 cg.body.writeOperand(Id, results.at(i));
2166 cg.body.writeOperand(Id, op_operand.at(i));
2167 }
2168 } else {
2169 const set = try cg.importExtendedSet();2190 const set = try cg.importExtendedSet();
2170 const extinst: u32 = switch (target.os.tag) {
2171 .opencl => switch (op) {
2172 .i_abs => 141, // s_abs
2173 .f_abs => 23, // fabs
2174 .clz => 151, // clz
2175 .ctz => 152, // ctz
2176 .floor => 25, // floor
2177 .ceil => 12, // ceil
2178 .trunc => 66, // trunc
2179 .round => 55, // round
2180 .sqrt => 61, // sqrt
2181 .sin => 57, // sin
2182 .cos => 14, // cos
2183 .tan => 62, // tan
2184 .exp => 19, // exp
2185 .exp2 => 20, // exp2
2186 .log => 37, // log
2187 .log2 => 38, // log2
2188 .log10 => 39, // log10
2189 else => unreachable,
2190 },
2191 // Note: We'll need to check these for floating point accuracy
2192 // Vulkan does not put tight requirements on these, for correction
2193 // we might want to emulate them at some point.
2194 .vulkan, .opengl => switch (op) {
2195 .i_abs => 5, // SAbs
2196 .f_abs => 4, // FAbs
2197 .floor => 8, // Floor
2198 .ceil => 9, // Ceil
2199 .trunc => 3, // Trunc
2200 .round => 1, // Round
2201 .clz,
2202 .ctz,
2203 .sqrt,
2204 .sin,
2205 .cos,
2206 .tan,
2207 .exp,
2208 .exp2,
2209 .log,
2210 .log2,
2211 .log10,
2212 => return cg.todo(
2213 "implement unary operation '{s}' for {s} os",
2214 .{ @tagName(op), @tagName(target.os.tag) },
2215 ),
2216 else => unreachable,
2217 },
2218 else => unreachable,
2219 };
2220
2221 for (0..ops) |i| {2191 for (0..ops) |i| {
2222 try cg.body.emit(cg.module.gpa, .OpExtInst, .{2192 try cg.body.emit(cg.module.gpa, .OpExtInst, .{
2223 .id_result_type = op_result_ty_id,2193 .id_result_type = op_result_ty_id,
2224 .id_result = results.at(i),2194 .id_result = results.at(i),
2225 .set = set,2195 .set = set,
2226 .instruction = .{ .inst = extinst },2196 .instruction = .{ .inst = opcode },
2227 .id_ref_4 = &.{op_operand.at(i)},2197 .id_ref_4 = &.{op_operand.at(i)},
2228 });2198 });
2229 }2199 }
2200 } else {
2201 const opcode: Opcode = switch (op) {
2202 .l_not => .OpLogicalNot,
2203 .bit_not => .OpNot,
2204 .i_neg => .OpSNegate,
2205 .f_neg => .OpFNegate,
2206 else => return cg.todo(
2207 "implement unary operation '{s}' for {s} os",
2208 .{ @tagName(op), @tagName(target.os.tag) },
2209 ),
2210 };
2211 for (0..ops) |i| {
2212 try cg.body.emitRaw(cg.module.gpa, opcode, 3);
2213 cg.body.writeOperand(Id, op_result_ty_id);
2214 cg.body.writeOperand(Id, results.at(i));
2215 cg.body.writeOperand(Id, op_operand.at(i));
2216 }
2230 }2217 }
22312218
2232 return v.finalize(result_ty, results);2219 return v.finalize(result_ty, results);
...@@ -2288,9 +2275,9 @@ fn buildWideMul(...@@ -2288,9 +2275,9 @@ fn buildWideMul(
2288 // OpUMulExtended. For these we will use the OpenCL s_mul_hi to compute the high-order bits2275 // OpUMulExtended. For these we will use the OpenCL s_mul_hi to compute the high-order bits
2289 // instead.2276 // instead.
2290 const set = try cg.importExtendedSet();2277 const set = try cg.importExtendedSet();
2291 const overflow_inst: u32 = switch (signedness) {2278 const overflow_inst: spec.OpenClOpcode = switch (signedness) {
2292 .signed => 160, // s_mul_hi2279 .signed => .s_mul_hi,
2293 .unsigned => 203, // u_mul_hi2280 .unsigned => .u_mul_hi,
2294 };2281 };
22952282
2296 for (0..ops) |i| {2283 for (0..ops) |i| {
...@@ -2305,7 +2292,7 @@ fn buildWideMul(...@@ -2305,7 +2292,7 @@ fn buildWideMul(
2305 .id_result_type = arith_op_ty_id,2292 .id_result_type = arith_op_ty_id,
2306 .id_result = overflow_results.at(i),2293 .id_result = overflow_results.at(i),
2307 .set = set,2294 .set = set,
2308 .instruction = .{ .inst = overflow_inst },2295 .instruction = .{ .inst = @intFromEnum(overflow_inst) },
2309 .id_ref_4 = &.{ lhs_op.at(i), rhs_op.at(i) },2296 .id_ref_4 = &.{ lhs_op.at(i), rhs_op.at(i) },
2310 });2297 });
2311 }2298 }
...@@ -2428,7 +2415,7 @@ fn generateTestEntryPoint(...@@ -2428,7 +2415,7 @@ fn generateTestEntryPoint(
2428 .vulkan, .opengl => {2415 .vulkan, .opengl => {
2429 if (cg.module.error_buffer == null) {2416 if (cg.module.error_buffer == null) {
2430 const spv_err_decl_index = try cg.module.allocDecl(.global);2417 const spv_err_decl_index = try cg.module.allocDecl(.global);
2431 try cg.module.declareDeclDeps(spv_err_decl_index, &.{});2418 const err_buf_result_id = cg.module.declPtr(spv_err_decl_index).result_id;
24322419
2433 const buffer_struct_ty_id = try cg.module.structType(2420 const buffer_struct_ty_id = try cg.module.structType(
2434 &.{anyerror_ty_id},2421 &.{anyerror_ty_id},
...@@ -2446,14 +2433,13 @@ fn generateTestEntryPoint(...@@ -2446,14 +2433,13 @@ fn generateTestEntryPoint(
2446 .type = buffer_struct_ty_id,2433 .type = buffer_struct_ty_id,
2447 });2434 });
24482435
2449 const buffer_struct_id = cg.module.declPtr(spv_err_decl_index).result_id;
2450 try cg.module.sections.globals.emit(gpa, .OpVariable, .{2436 try cg.module.sections.globals.emit(gpa, .OpVariable, .{
2451 .id_result_type = ptr_buffer_struct_ty_id,2437 .id_result_type = ptr_buffer_struct_ty_id,
2452 .id_result = buffer_struct_id,2438 .id_result = err_buf_result_id,
2453 .storage_class = cg.module.storageClass(.global),2439 .storage_class = cg.module.storageClass(.global),
2454 });2440 });
2455 try cg.module.decorate(buffer_struct_id, .{ .descriptor_set = .{ .descriptor_set = 0 } });2441 try cg.module.decorate(err_buf_result_id, .{ .descriptor_set = .{ .descriptor_set = 0 } });
2456 try cg.module.decorate(buffer_struct_id, .{ .binding = .{ .binding_point = 0 } });2442 try cg.module.decorate(err_buf_result_id, .{ .binding = .{ .binding_point = 0 } });
24572443
2458 cg.module.error_buffer = spv_err_decl_index;2444 cg.module.error_buffer = spv_err_decl_index;
2459 }2445 }
...@@ -2481,7 +2467,7 @@ fn generateTestEntryPoint(...@@ -2481,7 +2467,7 @@ fn generateTestEntryPoint(
24812467
2482 const spv_err_decl_index = cg.module.error_buffer.?;2468 const spv_err_decl_index = cg.module.error_buffer.?;
2483 const buffer_id = cg.module.declPtr(spv_err_decl_index).result_id;2469 const buffer_id = cg.module.declPtr(spv_err_decl_index).result_id;
2484 try cg.decl_deps.put(gpa, spv_err_decl_index, {});2470 try cg.module.decl_deps.append(gpa, spv_err_decl_index);
24852471
2486 const zero_id = try cg.constInt(.u32, 0);2472 const zero_id = try cg.constInt(.u32, 0);
2487 try section.emit(gpa, .OpInBoundsAccessChain, .{2473 try section.emit(gpa, .OpInBoundsAccessChain, .{
...@@ -2867,7 +2853,54 @@ fn airShift(cg: *CodeGen, inst: Air.Inst.Index, unsigned: Opcode, signed: Opcode...@@ -2867,7 +2853,54 @@ fn airShift(cg: *CodeGen, inst: Air.Inst.Index, unsigned: Opcode, signed: Opcode
2867 return try result.materialize(cg);2853 return try result.materialize(cg);
2868}2854}
28692855
2870const MinMax = enum { min, max };2856const MinMax = enum {
2857 min,
2858 max,
2859
2860 pub fn extInstOpcode(
2861 op: MinMax,
2862 target: *const std.Target,
2863 info: ArithmeticTypeInfo,
2864 ) u32 {
2865 return switch (target.os.tag) {
2866 .opencl => @intFromEnum(@as(spec.OpenClOpcode, switch (info.class) {
2867 .float => switch (op) {
2868 .min => .fmin,
2869 .max => .fmax,
2870 },
2871 .integer, .strange_integer, .composite_integer => switch (info.signedness) {
2872 .signed => switch (op) {
2873 .min => .s_min,
2874 .max => .s_max,
2875 },
2876 .unsigned => switch (op) {
2877 .min => .u_min,
2878 .max => .u_max,
2879 },
2880 },
2881 .bool => unreachable,
2882 })),
2883 .vulkan, .opengl => @intFromEnum(@as(spec.GlslOpcode, switch (info.class) {
2884 .float => switch (op) {
2885 .min => .FMin,
2886 .max => .FMax,
2887 },
2888 .integer, .strange_integer, .composite_integer => switch (info.signedness) {
2889 .signed => switch (op) {
2890 .min => .SMin,
2891 .max => .SMax,
2892 },
2893 .unsigned => switch (op) {
2894 .min => .UMin,
2895 .max => .UMax,
2896 },
2897 },
2898 .bool => unreachable,
2899 })),
2900 else => unreachable,
2901 };
2902 }
2903};
28712904
2872fn airMinMax(cg: *CodeGen, inst: Air.Inst.Index, op: MinMax) !?Id {2905fn airMinMax(cg: *CodeGen, inst: Air.Inst.Index, op: MinMax) !?Id {
2873 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2906 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
...@@ -2895,57 +2928,14 @@ fn minMax(cg: *CodeGen, lhs: Temporary, rhs: Temporary, op: MinMax) !Temporary {...@@ -2895,57 +2928,14 @@ fn minMax(cg: *CodeGen, lhs: Temporary, rhs: Temporary, op: MinMax) !Temporary {
2895 const op_lhs = try v.prepare(cg, lhs);2928 const op_lhs = try v.prepare(cg, lhs);
2896 const op_rhs = try v.prepare(cg, rhs);2929 const op_rhs = try v.prepare(cg, rhs);
28972930
2898 const ext_inst: u32 = switch (target.os.tag) {
2899 .opencl => switch (info.class) {
2900 .float => switch (op) {
2901 .min => 28, // fmin
2902 .max => 27, // fmax
2903 },
2904 .integer,
2905 .strange_integer,
2906 .composite_integer,
2907 => switch (info.signedness) {
2908 .signed => switch (op) {
2909 .min => 158, // s_min
2910 .max => 156, // s_max
2911 },
2912 .unsigned => switch (op) {
2913 .min => 159, // u_min
2914 .max => 157, // u_max
2915 },
2916 },
2917 .bool => unreachable,
2918 },
2919 .vulkan, .opengl => switch (info.class) {
2920 .float => switch (op) {
2921 .min => 37, // FMin
2922 .max => 40, // FMax
2923 },
2924 .integer,
2925 .strange_integer,
2926 .composite_integer,
2927 => switch (info.signedness) {
2928 .signed => switch (op) {
2929 .min => 39, // SMin
2930 .max => 42, // SMax
2931 },
2932 .unsigned => switch (op) {
2933 .min => 38, // UMin
2934 .max => 41, // UMax
2935 },
2936 },
2937 .bool => unreachable,
2938 },
2939 else => unreachable,
2940 };
2941
2942 const set = try cg.importExtendedSet();2931 const set = try cg.importExtendedSet();
2932 const opcode = op.extInstOpcode(target, info);
2943 for (0..ops) |i| {2933 for (0..ops) |i| {
2944 try cg.body.emit(cg.module.gpa, .OpExtInst, .{2934 try cg.body.emit(cg.module.gpa, .OpExtInst, .{
2945 .id_result_type = op_result_ty_id,2935 .id_result_type = op_result_ty_id,
2946 .id_result = results.at(i),2936 .id_result = results.at(i),
2947 .set = set,2937 .set = set,
2948 .instruction = .{ .inst = ext_inst },2938 .instruction = .{ .inst = opcode },
2949 .id_ref_4 = &.{ op_lhs.at(i), op_rhs.at(i) },2939 .id_ref_4 = &.{ op_lhs.at(i), op_rhs.at(i) },
2950 });2940 });
2951 }2941 }
...@@ -3562,8 +3552,9 @@ fn airShuffleOne(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3562,8 +3552,9 @@ fn airShuffleOne(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
3562 const elem_ty = result_ty.childType(zcu);3552 const elem_ty = result_ty.childType(zcu);
3563 const operand = try cg.resolve(unwrapped.operand);3553 const operand = try cg.resolve(unwrapped.operand);
35643554
3565 const constituents = try gpa.alloc(Id, mask.len);3555 const scratch_top = cg.id_scratch.items.len;
3566 defer gpa.free(constituents);3556 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
3557 const constituents = try cg.id_scratch.addManyAsSlice(gpa, mask.len);
35673558
3568 for (constituents, mask) |*id, mask_elem| {3559 for (constituents, mask) |*id, mask_elem| {
3569 id.* = switch (mask_elem.unwrap()) {3560 id.* = switch (mask_elem.unwrap()) {
...@@ -3588,8 +3579,9 @@ fn airShuffleTwo(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3588,8 +3579,9 @@ fn airShuffleTwo(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
3588 const operand_a = try cg.resolve(unwrapped.operand_a);3579 const operand_a = try cg.resolve(unwrapped.operand_a);
3589 const operand_b = try cg.resolve(unwrapped.operand_b);3580 const operand_b = try cg.resolve(unwrapped.operand_b);
35903581
3591 const constituents = try gpa.alloc(Id, mask.len);3582 const scratch_top = cg.id_scratch.items.len;
3592 defer gpa.free(constituents);3583 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
3584 const constituents = try cg.id_scratch.addManyAsSlice(gpa, mask.len);
35933585
3594 for (constituents, mask) |*id, mask_elem| {3586 for (constituents, mask) |*id, mask_elem| {
3595 id.* = switch (mask_elem.unwrap()) {3587 id.* = switch (mask_elem.unwrap()) {
...@@ -3603,17 +3595,6 @@ fn airShuffleTwo(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -3603,17 +3595,6 @@ fn airShuffleTwo(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
3603 return try cg.constructComposite(result_ty_id, constituents);3595 return try cg.constructComposite(result_ty_id, constituents);
3604}3596}
36053597
3606fn indicesToIds(cg: *CodeGen, indices: []const u32) ![]Id {
3607 const gpa = cg.module.gpa;
3608 const ids = try gpa.alloc(Id, indices.len);
3609 errdefer gpa.free(ids);
3610 for (indices, ids) |index, *id| {
3611 id.* = try cg.constInt(.u32, index);
3612 }
3613
3614 return ids;
3615}
3616
3617fn accessChainId(3598fn accessChainId(
3618 cg: *CodeGen,3599 cg: *CodeGen,
3619 result_ty_id: Id,3600 result_ty_id: Id,
...@@ -3641,8 +3622,12 @@ fn accessChain(...@@ -3641,8 +3622,12 @@ fn accessChain(
3641 indices: []const u32,3622 indices: []const u32,
3642) !Id {3623) !Id {
3643 const gpa = cg.module.gpa;3624 const gpa = cg.module.gpa;
3644 const ids = try cg.indicesToIds(indices);3625 const scratch_top = cg.id_scratch.items.len;
3645 defer gpa.free(ids);3626 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
3627 const ids = try cg.id_scratch.addManyAsSlice(gpa, indices.len);
3628 for (indices, ids) |index, *id| {
3629 id.* = try cg.constInt(.u32, index);
3630 }
3646 return try cg.accessChainId(result_ty_id, base, ids);3631 return try cg.accessChainId(result_ty_id, base, ids);
3647}3632}
36483633
...@@ -3655,13 +3640,18 @@ fn ptrAccessChain(...@@ -3655,13 +3640,18 @@ fn ptrAccessChain(
3655) !Id {3640) !Id {
3656 const gpa = cg.module.gpa;3641 const gpa = cg.module.gpa;
3657 const target = cg.module.zcu.getTarget();3642 const target = cg.module.zcu.getTarget();
3658 const ids = try cg.indicesToIds(indices);3643
3659 defer gpa.free(ids);3644 const scratch_top = cg.id_scratch.items.len;
3645 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
3646 const ids = try cg.id_scratch.addManyAsSlice(gpa, indices.len);
3647 for (indices, ids) |index, *id| {
3648 id.* = try cg.constInt(.u32, index);
3649 }
36603650
3661 const result_id = cg.module.allocId();3651 const result_id = cg.module.allocId();
3662 switch (target.os.tag) {3652 switch (target.os.tag) {
3663 .opencl, .amdhsa => {3653 .opencl, .amdhsa => {
3664 try cg.body.emit(cg.module.gpa, .OpInBoundsPtrAccessChain, .{3654 try cg.body.emit(gpa, .OpInBoundsPtrAccessChain, .{
3665 .id_result_type = result_ty_id,3655 .id_result_type = result_ty_id,
3666 .id_result = result_id,3656 .id_result = result_id,
3667 .base = base,3657 .base = base,
...@@ -3669,8 +3659,8 @@ fn ptrAccessChain(...@@ -3669,8 +3659,8 @@ fn ptrAccessChain(
3669 .indexes = ids,3659 .indexes = ids,
3670 });3660 });
3671 },3661 },
3672 else => {3662 .vulkan, .opengl => {
3673 try cg.body.emit(cg.module.gpa, .OpPtrAccessChain, .{3663 try cg.body.emit(gpa, .OpPtrAccessChain, .{
3674 .id_result_type = result_ty_id,3664 .id_result_type = result_ty_id,
3675 .id_result = result_id,3665 .id_result = result_id,
3676 .base = base,3666 .base = base,
...@@ -3678,6 +3668,7 @@ fn ptrAccessChain(...@@ -3678,6 +3668,7 @@ fn ptrAccessChain(
3678 .indexes = ids,3668 .indexes = ids,
3679 });3669 });
3680 },3670 },
3671 else => unreachable,
3681 }3672 }
3682 return result_id;3673 return result_id;
3683}3674}
...@@ -3739,6 +3730,7 @@ fn cmp(...@@ -3739,6 +3730,7 @@ fn cmp(
3739 lhs: Temporary,3730 lhs: Temporary,
3740 rhs: Temporary,3731 rhs: Temporary,
3741) !Temporary {3732) !Temporary {
3733 const gpa = cg.module.gpa;
3742 const pt = cg.pt;3734 const pt = cg.pt;
3743 const zcu = cg.module.zcu;3735 const zcu = cg.module.zcu;
3744 const ip = &zcu.intern_pool;3736 const ip = &zcu.intern_pool;
...@@ -3771,14 +3763,14 @@ fn cmp(...@@ -3771,14 +3763,14 @@ fn cmp(
3771 const usize_ty_id = try cg.resolveType(.usize, .direct);3763 const usize_ty_id = try cg.resolveType(.usize, .direct);
37723764
3773 const lhs_int_id = cg.module.allocId();3765 const lhs_int_id = cg.module.allocId();
3774 try cg.body.emit(cg.module.gpa, .OpConvertPtrToU, .{3766 try cg.body.emit(gpa, .OpConvertPtrToU, .{
3775 .id_result_type = usize_ty_id,3767 .id_result_type = usize_ty_id,
3776 .id_result = lhs_int_id,3768 .id_result = lhs_int_id,
3777 .pointer = try lhs.materialize(cg),3769 .pointer = try lhs.materialize(cg),
3778 });3770 });
37793771
3780 const rhs_int_id = cg.module.allocId();3772 const rhs_int_id = cg.module.allocId();
3781 try cg.body.emit(cg.module.gpa, .OpConvertPtrToU, .{3773 try cg.body.emit(gpa, .OpConvertPtrToU, .{
3782 .id_result_type = usize_ty_id,3774 .id_result_type = usize_ty_id,
3783 .id_result = rhs_int_id,3775 .id_result = rhs_int_id,
3784 .pointer = try rhs.materialize(cg),3776 .pointer = try rhs.materialize(cg),
...@@ -3937,6 +3929,7 @@ fn bitCast(...@@ -3937,6 +3929,7 @@ fn bitCast(
3937 src_ty: Type,3929 src_ty: Type,
3938 src_id: Id,3930 src_id: Id,
3939) !Id {3931) !Id {
3932 const gpa = cg.module.gpa;
3940 const zcu = cg.module.zcu;3933 const zcu = cg.module.zcu;
3941 const src_ty_id = try cg.resolveType(src_ty, .direct);3934 const src_ty_id = try cg.resolveType(src_ty, .direct);
3942 const dst_ty_id = try cg.resolveType(dst_ty, .direct);3935 const dst_ty_id = try cg.resolveType(dst_ty, .direct);
...@@ -3949,7 +3942,7 @@ fn bitCast(...@@ -3949,7 +3942,7 @@ fn bitCast(
39493942
3950 if (src_ty.zigTypeTag(zcu) == .int and dst_ty.isPtrAtRuntime(zcu)) {3943 if (src_ty.zigTypeTag(zcu) == .int and dst_ty.isPtrAtRuntime(zcu)) {
3951 const result_id = cg.module.allocId();3944 const result_id = cg.module.allocId();
3952 try cg.body.emit(cg.module.gpa, .OpConvertUToPtr, .{3945 try cg.body.emit(gpa, .OpConvertUToPtr, .{
3953 .id_result_type = dst_ty_id,3946 .id_result_type = dst_ty_id,
3954 .id_result = result_id,3947 .id_result = result_id,
3955 .integer_value = src_id,3948 .integer_value = src_id,
...@@ -3963,7 +3956,7 @@ fn bitCast(...@@ -3963,7 +3956,7 @@ fn bitCast(
3963 const can_bitcast = (src_ty.isNumeric(zcu) and dst_ty.isNumeric(zcu)) or (src_ty.isPtrAtRuntime(zcu) and dst_ty.isPtrAtRuntime(zcu));3956 const can_bitcast = (src_ty.isNumeric(zcu) and dst_ty.isNumeric(zcu)) or (src_ty.isPtrAtRuntime(zcu) and dst_ty.isPtrAtRuntime(zcu));
3964 if (can_bitcast) {3957 if (can_bitcast) {
3965 const result_id = cg.module.allocId();3958 const result_id = cg.module.allocId();
3966 try cg.body.emit(cg.module.gpa, .OpBitcast, .{3959 try cg.body.emit(gpa, .OpBitcast, .{
3967 .id_result_type = dst_ty_id,3960 .id_result_type = dst_ty_id,
3968 .id_result = result_id,3961 .id_result = result_id,
3969 .operand = src_id,3962 .operand = src_id,
...@@ -3977,7 +3970,7 @@ fn bitCast(...@@ -3977,7 +3970,7 @@ fn bitCast(
3977 const tmp_id = try cg.alloc(src_ty, .{ .storage_class = .function });3970 const tmp_id = try cg.alloc(src_ty, .{ .storage_class = .function });
3978 try cg.store(src_ty, tmp_id, src_id, .{});3971 try cg.store(src_ty, tmp_id, src_id, .{});
3979 const casted_ptr_id = cg.module.allocId();3972 const casted_ptr_id = cg.module.allocId();
3980 try cg.body.emit(cg.module.gpa, .OpBitcast, .{3973 try cg.body.emit(gpa, .OpBitcast, .{
3981 .id_result_type = dst_ptr_ty_id,3974 .id_result_type = dst_ptr_ty_id,
3982 .id_result = casted_ptr_id,3975 .id_result = casted_ptr_id,
3983 .operand = tmp_id,3976 .operand = tmp_id,
...@@ -4057,16 +4050,17 @@ fn airFloatFromInt(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4057,16 +4050,17 @@ fn airFloatFromInt(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4057}4050}
40584051
4059fn floatFromInt(cg: *CodeGen, result_ty: Type, operand_ty: Type, operand_id: Id) !Id {4052fn floatFromInt(cg: *CodeGen, result_ty: Type, operand_ty: Type, operand_id: Id) !Id {
4053 const gpa = cg.module.gpa;
4060 const operand_info = cg.arithmeticTypeInfo(operand_ty);4054 const operand_info = cg.arithmeticTypeInfo(operand_ty);
4061 const result_id = cg.module.allocId();4055 const result_id = cg.module.allocId();
4062 const result_ty_id = try cg.resolveType(result_ty, .direct);4056 const result_ty_id = try cg.resolveType(result_ty, .direct);
4063 switch (operand_info.signedness) {4057 switch (operand_info.signedness) {
4064 .signed => try cg.body.emit(cg.module.gpa, .OpConvertSToF, .{4058 .signed => try cg.body.emit(gpa, .OpConvertSToF, .{
4065 .id_result_type = result_ty_id,4059 .id_result_type = result_ty_id,
4066 .id_result = result_id,4060 .id_result = result_id,
4067 .signed_value = operand_id,4061 .signed_value = operand_id,
4068 }),4062 }),
4069 .unsigned => try cg.body.emit(cg.module.gpa, .OpConvertUToF, .{4063 .unsigned => try cg.body.emit(gpa, .OpConvertUToF, .{
4070 .id_result_type = result_ty_id,4064 .id_result_type = result_ty_id,
4071 .id_result = result_id,4065 .id_result = result_id,
4072 .unsigned_value = operand_id,4066 .unsigned_value = operand_id,
...@@ -4083,16 +4077,17 @@ fn airIntFromFloat(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4083,16 +4077,17 @@ fn airIntFromFloat(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4083}4077}
40844078
4085fn intFromFloat(cg: *CodeGen, result_ty: Type, operand_id: Id) !Id {4079fn intFromFloat(cg: *CodeGen, result_ty: Type, operand_id: Id) !Id {
4080 const gpa = cg.module.gpa;
4086 const result_info = cg.arithmeticTypeInfo(result_ty);4081 const result_info = cg.arithmeticTypeInfo(result_ty);
4087 const result_ty_id = try cg.resolveType(result_ty, .direct);4082 const result_ty_id = try cg.resolveType(result_ty, .direct);
4088 const result_id = cg.module.allocId();4083 const result_id = cg.module.allocId();
4089 switch (result_info.signedness) {4084 switch (result_info.signedness) {
4090 .signed => try cg.body.emit(cg.module.gpa, .OpConvertFToS, .{4085 .signed => try cg.body.emit(gpa, .OpConvertFToS, .{
4091 .id_result_type = result_ty_id,4086 .id_result_type = result_ty_id,
4092 .id_result = result_id,4087 .id_result = result_id,
4093 .float_value = operand_id,4088 .float_value = operand_id,
4094 }),4089 }),
4095 .unsigned => try cg.body.emit(cg.module.gpa, .OpConvertFToU, .{4090 .unsigned => try cg.body.emit(gpa, .OpConvertFToU, .{
4096 .id_result_type = result_ty_id,4091 .id_result_type = result_ty_id,
4097 .id_result = result_id,4092 .id_result = result_id,
4098 .float_value = operand_id,4093 .float_value = operand_id,
...@@ -4214,10 +4209,13 @@ fn airAggregateInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4214,10 +4209,13 @@ fn airAggregateInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4214 return running_int_id;4209 return running_int_id;
4215 }4210 }
42164211
4212 const scratch_top = cg.id_scratch.items.len;
4213 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
4214 const constituents = try cg.id_scratch.addManyAsSlice(gpa, elements.len);
4215
4217 const types = try gpa.alloc(Type, elements.len);4216 const types = try gpa.alloc(Type, elements.len);
4218 defer gpa.free(types);4217 defer gpa.free(types);
4219 const constituents = try gpa.alloc(Id, elements.len);4218
4220 defer gpa.free(constituents);
4221 var index: usize = 0;4219 var index: usize = 0;
42224220
4223 switch (ip.indexToKey(result_ty.toIntern())) {4221 switch (ip.indexToKey(result_ty.toIntern())) {
...@@ -4255,8 +4253,9 @@ fn airAggregateInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4255,8 +4253,9 @@ fn airAggregateInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4255 },4253 },
4256 .vector => {4254 .vector => {
4257 const n_elems = result_ty.vectorLen(zcu);4255 const n_elems = result_ty.vectorLen(zcu);
4258 const elem_ids = try gpa.alloc(Id, n_elems);4256 const scratch_top = cg.id_scratch.items.len;
4259 defer gpa.free(elem_ids);4257 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
4258 const elem_ids = try cg.id_scratch.addManyAsSlice(gpa, n_elems);
42604259
4261 for (elements, 0..) |element, i| {4260 for (elements, 0..) |element, i| {
4262 elem_ids[i] = try cg.resolve(element);4261 elem_ids[i] = try cg.resolve(element);
...@@ -4268,8 +4267,9 @@ fn airAggregateInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4268,8 +4267,9 @@ fn airAggregateInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4268 .array => {4267 .array => {
4269 const array_info = result_ty.arrayInfo(zcu);4268 const array_info = result_ty.arrayInfo(zcu);
4270 const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(zcu));4269 const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(zcu));
4271 const elem_ids = try gpa.alloc(Id, n_elems);4270 const scratch_top = cg.id_scratch.items.len;
4272 defer gpa.free(elem_ids);4271 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
4272 const elem_ids = try cg.id_scratch.addManyAsSlice(gpa, n_elems);
42734273
4274 for (elements, 0..) |element, i| {4274 for (elements, 0..) |element, i| {
4275 const id = try cg.resolve(element);4275 const id = try cg.resolve(element);
...@@ -4407,6 +4407,7 @@ fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4407,6 +4407,7 @@ fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4407}4407}
44084408
4409fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {4409fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4410 const gpa = cg.module.gpa;
4410 const zcu = cg.module.zcu;4411 const zcu = cg.module.zcu;
4411 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4412 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
4412 const array_ty = cg.typeOf(bin_op.lhs);4413 const array_ty = cg.typeOf(bin_op.lhs);
...@@ -4427,13 +4428,13 @@ fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4427,13 +4428,13 @@ fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4427 const ptr_elem_ty_id = try cg.module.ptrType(elem_ty_id, .function);4428 const ptr_elem_ty_id = try cg.module.ptrType(elem_ty_id, .function);
44284429
4429 const tmp_id = cg.module.allocId();4430 const tmp_id = cg.module.allocId();
4430 try cg.prologue.emit(cg.module.gpa, .OpVariable, .{4431 try cg.prologue.emit(gpa, .OpVariable, .{
4431 .id_result_type = ptr_array_ty_id,4432 .id_result_type = ptr_array_ty_id,
4432 .id_result = tmp_id,4433 .id_result = tmp_id,
4433 .storage_class = .function,4434 .storage_class = .function,
4434 });4435 });
44354436
4436 try cg.body.emit(cg.module.gpa, .OpStore, .{4437 try cg.body.emit(gpa, .OpStore, .{
4437 .pointer = tmp_id,4438 .pointer = tmp_id,
4438 .object = array_id,4439 .object = array_id,
4439 });4440 });
...@@ -4441,7 +4442,7 @@ fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -4441,7 +4442,7 @@ fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4441 const elem_ptr_id = try cg.accessChainId(ptr_elem_ty_id, tmp_id, &.{index_id});4442 const elem_ptr_id = try cg.accessChainId(ptr_elem_ty_id, tmp_id, &.{index_id});
44424443
4443 const result_id = cg.module.allocId();4444 const result_id = cg.module.allocId();
4444 try cg.body.emit(cg.module.gpa, .OpLoad, .{4445 try cg.body.emit(gpa, .OpLoad, .{
4445 .id_result_type = try cg.resolveType(elem_ty, elem_repr),4446 .id_result_type = try cg.resolveType(elem_ty, elem_repr),
4446 .id_result = result_id,4447 .id_result = result_id,
4447 .pointer = elem_ptr_id,4448 .pointer = elem_ptr_id,
...@@ -4914,7 +4915,7 @@ fn structuredBreak(cg: *CodeGen, target_block: Id) !void {...@@ -4914,7 +4915,7 @@ fn structuredBreak(cg: *CodeGen, target_block: Id) !void {
4914 .loop => unreachable,4915 .loop => unreachable,
4915 };4916 };
49164917
4917 try cg.body.emitBranch(cg.module.gpa, merge_block);4918 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_block });
4918}4919}
49194920
4920/// Generate a body in a way that exits the body using only structured constructs.4921/// Generate a body in a way that exits the body using only structured constructs.
...@@ -4997,7 +4998,8 @@ fn genStructuredBody(...@@ -4997,7 +4998,8 @@ fn genStructuredBody(
4997 while (i > 0) {4998 while (i > 0) {
4998 i -= 1;4999 i -= 1;
4999 const step = merge_stack[i];5000 const step = merge_stack[i];
5000 try cg.body.emitBranch(cg.module.gpa, step.merge_block);5001
5002 try cg.body.emit(gpa, .OpBranch, .{ .target_label = step.merge_block });
5001 try cg.beginSpvBlock(step.merge_block);5003 try cg.beginSpvBlock(step.merge_block);
5002 const next_block = try cg.structuredNextBlock(&.{ incoming, step.incoming });5004 const next_block = try cg.structuredNextBlock(&.{ incoming, step.incoming });
5003 incoming = .{5005 incoming = .{
...@@ -5010,7 +5012,8 @@ fn genStructuredBody(...@@ -5010,7 +5012,8 @@ fn genStructuredBody(
5010 },5012 },
5011 .loop => |merge| {5013 .loop => |merge| {
5012 // Close the loop by jumping to the continue label5014 // Close the loop by jumping to the continue label
5013 try cg.body.emitBranch(cg.module.gpa, block_merge_type.loop.continue_label);5015
5016 try cg.body.emit(gpa, .OpBranch, .{ .target_label = block_merge_type.loop.continue_label });
5014 // For blocks we must simple merge all the incoming blocks to get the next block.5017 // For blocks we must simple merge all the incoming blocks to get the next block.
5015 try cg.beginSpvBlock(merge.merge_block);5018 try cg.beginSpvBlock(merge.merge_block);
5016 return try cg.structuredNextBlock(merge.merges.items);5019 return try cg.structuredNextBlock(merge.merges.items);
...@@ -5064,7 +5067,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)...@@ -5064,7 +5067,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)
5064 const result_type_id = try cg.resolveType(ty, .direct);5067 const result_type_id = try cg.resolveType(ty, .direct);
50655068
5066 try cg.body.emitRaw(5069 try cg.body.emitRaw(
5067 cg.module.gpa,5070 gpa,
5068 .OpPhi,5071 .OpPhi,
5069 // result type + result + variable/parent...5072 // result type + result + variable/parent...
5070 2 + @as(u16, @intCast(block.incoming_blocks.items.len * 2)),5073 2 + @as(u16, @intCast(block.incoming_blocks.items.len * 2)),
...@@ -5100,7 +5103,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)...@@ -5100,7 +5103,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)
5100 const this_block = try cg.constInt(.u32, @intFromEnum(inst));5103 const this_block = try cg.constInt(.u32, @intFromEnum(inst));
5101 const jump_to_this_block_id = cg.module.allocId();5104 const jump_to_this_block_id = cg.module.allocId();
5102 const bool_ty_id = try cg.resolveType(.bool, .direct);5105 const bool_ty_id = try cg.resolveType(.bool, .direct);
5103 try cg.body.emit(cg.module.gpa, .OpIEqual, .{5106 try cg.body.emit(gpa, .OpIEqual, .{
5104 .id_result_type = bool_ty_id,5107 .id_result_type = bool_ty_id,
5105 .id_result = jump_to_this_block_id,5108 .id_result = jump_to_this_block_id,
5106 .operand_1 = next_block,5109 .operand_1 = next_block,
...@@ -5120,11 +5123,11 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)...@@ -5120,11 +5123,11 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)
5120 // generate a conditional branch to there and to the instructions following this block.5123 // generate a conditional branch to there and to the instructions following this block.
5121 const merge_label = cg.module.allocId();5124 const merge_label = cg.module.allocId();
5122 const then_label = cg.module.allocId();5125 const then_label = cg.module.allocId();
5123 try cg.body.emit(cg.module.gpa, .OpSelectionMerge, .{5126 try cg.body.emit(gpa, .OpSelectionMerge, .{
5124 .merge_block = merge_label,5127 .merge_block = merge_label,
5125 .selection_control = .{},5128 .selection_control = .{},
5126 });5129 });
5127 try cg.body.emit(cg.module.gpa, .OpBranchConditional, .{5130 try cg.body.emit(gpa, .OpBranchConditional, .{
5128 .condition = jump_to_this_block_id,5131 .condition = jump_to_this_block_id,
5129 .true_label = then_label,5132 .true_label = then_label,
5130 .false_label = merge_label,5133 .false_label = merge_label,
...@@ -5143,7 +5146,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)...@@ -5143,7 +5146,7 @@ fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, body: []const Air.Inst.Index)
5143 // To jump out of a loop block, generate a conditional that exits the block5146 // To jump out of a loop block, generate a conditional that exits the block
5144 // to the loop merge if the target ID is not the one of this block.5147 // to the loop merge if the target ID is not the one of this block.
5145 const continue_label = cg.module.allocId();5148 const continue_label = cg.module.allocId();
5146 try cg.body.emit(cg.module.gpa, .OpBranchConditional, .{5149 try cg.body.emit(gpa, .OpBranchConditional, .{
5147 .condition = jump_to_this_block_id,5150 .condition = jump_to_this_block_id,
5148 .true_label = continue_label,5151 .true_label = continue_label,
5149 .false_label = merge.merge_block,5152 .false_label = merge.merge_block,
...@@ -5197,12 +5200,13 @@ fn airBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5197,12 +5200,13 @@ fn airBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5197 block.label = cg.module.allocId();5200 block.label = cg.module.allocId();
5198 }5201 }
51995202
5200 try cg.body.emitBranch(cg.module.gpa, block.label.?);5203 try cg.body.emit(gpa, .OpBranch, .{ .target_label = block.label.? });
5201 },5204 },
5202 }5205 }
5203}5206}
52045207
5205fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {5208fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5209 const gpa = cg.module.gpa;
5206 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;5210 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
5207 const cond_br = cg.air.extraData(Air.CondBr, pl_op.payload);5211 const cond_br = cg.air.extraData(Air.CondBr, pl_op.payload);
5208 const then_body: []const Air.Inst.Index = @ptrCast(cg.air.extra.items[cond_br.end..][0..cond_br.data.then_body_len]);5212 const then_body: []const Air.Inst.Index = @ptrCast(cg.air.extra.items[cond_br.end..][0..cond_br.data.then_body_len]);
...@@ -5216,11 +5220,11 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5216,11 +5220,11 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5216 .structured => {5220 .structured => {
5217 const merge_label = cg.module.allocId();5221 const merge_label = cg.module.allocId();
52185222
5219 try cg.body.emit(cg.module.gpa, .OpSelectionMerge, .{5223 try cg.body.emit(gpa, .OpSelectionMerge, .{
5220 .merge_block = merge_label,5224 .merge_block = merge_label,
5221 .selection_control = .{},5225 .selection_control = .{},
5222 });5226 });
5223 try cg.body.emit(cg.module.gpa, .OpBranchConditional, .{5227 try cg.body.emit(gpa, .OpBranchConditional, .{
5224 .condition = condition_id,5228 .condition = condition_id,
5225 .true_label = then_label,5229 .true_label = then_label,
5226 .false_label = else_label,5230 .false_label = else_label,
...@@ -5232,7 +5236,8 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5232,7 +5236,8 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5232 .src_label = cg.block_label,5236 .src_label = cg.block_label,
5233 .next_block = then_next,5237 .next_block = then_next,
5234 };5238 };
5235 try cg.body.emitBranch(cg.module.gpa, merge_label);5239
5240 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label });
52365241
5237 try cg.beginSpvBlock(else_label);5242 try cg.beginSpvBlock(else_label);
5238 const else_next = try cg.genStructuredBody(.selection, else_body);5243 const else_next = try cg.genStructuredBody(.selection, else_body);
...@@ -5240,7 +5245,8 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5240,7 +5245,8 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5240 .src_label = cg.block_label,5245 .src_label = cg.block_label,
5241 .next_block = else_next,5246 .next_block = else_next,
5242 };5247 };
5243 try cg.body.emitBranch(cg.module.gpa, merge_label);5248
5249 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label });
52445250
5245 try cg.beginSpvBlock(merge_label);5251 try cg.beginSpvBlock(merge_label);
5246 const next_block = try cg.structuredNextBlock(&.{ then_incoming, else_incoming });5252 const next_block = try cg.structuredNextBlock(&.{ then_incoming, else_incoming });
...@@ -5248,7 +5254,7 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5248,7 +5254,7 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5248 try cg.structuredBreak(next_block);5254 try cg.structuredBreak(next_block);
5249 },5255 },
5250 .unstructured => {5256 .unstructured => {
5251 try cg.body.emit(cg.module.gpa, .OpBranchConditional, .{5257 try cg.body.emit(gpa, .OpBranchConditional, .{
5252 .condition = condition_id,5258 .condition = condition_id,
5253 .true_label = then_label,5259 .true_label = then_label,
5254 .false_label = else_label,5260 .false_label = else_label,
...@@ -5263,6 +5269,7 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5263,6 +5269,7 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5263}5269}
52645270
5265fn airLoop(cg: *CodeGen, inst: Air.Inst.Index) !void {5271fn airLoop(cg: *CodeGen, inst: Air.Inst.Index) !void {
5272 const gpa = cg.module.gpa;
5266 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;5273 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
5267 const loop = cg.air.extraData(Air.Block, ty_pl.payload);5274 const loop = cg.air.extraData(Air.Block, ty_pl.payload);
5268 const body: []const Air.Inst.Index = @ptrCast(cg.air.extra.items[loop.end..][0..loop.data.body_len]);5275 const body: []const Air.Inst.Index = @ptrCast(cg.air.extra.items[loop.end..][0..loop.data.body_len]);
...@@ -5278,16 +5285,18 @@ fn airLoop(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5278,16 +5285,18 @@ fn airLoop(cg: *CodeGen, inst: Air.Inst.Index) !void {
5278 // The back-edge must point to the loop header, so generate a separate block for the5285 // The back-edge must point to the loop header, so generate a separate block for the
5279 // loop header so that we don't accidentally include some instructions from there5286 // loop header so that we don't accidentally include some instructions from there
5280 // in the loop.5287 // in the loop.
5281 try cg.body.emitBranch(cg.module.gpa, header_label);5288
5289 try cg.body.emit(gpa, .OpBranch, .{ .target_label = header_label });
5282 try cg.beginSpvBlock(header_label);5290 try cg.beginSpvBlock(header_label);
52835291
5284 // Emit loop header and jump to loop body5292 // Emit loop header and jump to loop body
5285 try cg.body.emit(cg.module.gpa, .OpLoopMerge, .{5293 try cg.body.emit(gpa, .OpLoopMerge, .{
5286 .merge_block = merge_label,5294 .merge_block = merge_label,
5287 .continue_target = continue_label,5295 .continue_target = continue_label,
5288 .loop_control = .{},5296 .loop_control = .{},
5289 });5297 });
5290 try cg.body.emitBranch(cg.module.gpa, body_label);5298
5299 try cg.body.emit(gpa, .OpBranch, .{ .target_label = body_label });
52915300
5292 try cg.beginSpvBlock(body_label);5301 try cg.beginSpvBlock(body_label);
52935302
...@@ -5298,13 +5307,15 @@ fn airLoop(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5298,13 +5307,15 @@ fn airLoop(cg: *CodeGen, inst: Air.Inst.Index) !void {
5298 try cg.structuredBreak(next_block);5307 try cg.structuredBreak(next_block);
52995308
5300 try cg.beginSpvBlock(continue_label);5309 try cg.beginSpvBlock(continue_label);
5301 try cg.body.emitBranch(cg.module.gpa, header_label);5310
5311 try cg.body.emit(gpa, .OpBranch, .{ .target_label = header_label });
5302 },5312 },
5303 .unstructured => {5313 .unstructured => {
5304 try cg.body.emitBranch(cg.module.gpa, body_label);5314 try cg.body.emit(gpa, .OpBranch, .{ .target_label = body_label });
5305 try cg.beginSpvBlock(body_label);5315 try cg.beginSpvBlock(body_label);
5306 try cg.genBody(body);5316 try cg.genBody(body);
5307 try cg.body.emitBranch(cg.module.gpa, body_label);5317
5318 try cg.body.emit(gpa, .OpBranch, .{ .target_label = body_label });
5308 },5319 },
5309 }5320 }
5310}5321}
...@@ -5332,6 +5343,7 @@ fn airStore(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5332,6 +5343,7 @@ fn airStore(cg: *CodeGen, inst: Air.Inst.Index) !void {
5332}5343}
53335344
5334fn airRet(cg: *CodeGen, inst: Air.Inst.Index) !void {5345fn airRet(cg: *CodeGen, inst: Air.Inst.Index) !void {
5346 const gpa = cg.module.gpa;
5335 const zcu = cg.module.zcu;5347 const zcu = cg.module.zcu;
5336 const operand = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;5348 const operand = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
5337 const ret_ty = cg.typeOf(operand);5349 const ret_ty = cg.typeOf(operand);
...@@ -5342,17 +5354,18 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5342,17 +5354,18 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index) !void {
5342 // return type and return zero so they can be function pointers coerced5354 // return type and return zero so they can be function pointers coerced
5343 // to functions that return anyerror.5355 // to functions that return anyerror.
5344 const no_err_id = try cg.constInt(.anyerror, 0);5356 const no_err_id = try cg.constInt(.anyerror, 0);
5345 return try cg.body.emit(cg.module.gpa, .OpReturnValue, .{ .value = no_err_id });5357 return try cg.body.emit(gpa, .OpReturnValue, .{ .value = no_err_id });
5346 } else {5358 } else {
5347 return try cg.body.emit(cg.module.gpa, .OpReturn, {});5359 return try cg.body.emit(gpa, .OpReturn, {});
5348 }5360 }
5349 }5361 }
53505362
5351 const operand_id = try cg.resolve(operand);5363 const operand_id = try cg.resolve(operand);
5352 try cg.body.emit(cg.module.gpa, .OpReturnValue, .{ .value = operand_id });5364 try cg.body.emit(gpa, .OpReturnValue, .{ .value = operand_id });
5353}5365}
53545366
5355fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void {5367fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void {
5368 const gpa = cg.module.gpa;
5356 const zcu = cg.module.zcu;5369 const zcu = cg.module.zcu;
5357 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;5370 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
5358 const ptr_ty = cg.typeOf(un_op);5371 const ptr_ty = cg.typeOf(un_op);
...@@ -5365,20 +5378,21 @@ fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5365,20 +5378,21 @@ fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void {
5365 // return type and return zero so they can be function pointers coerced5378 // return type and return zero so they can be function pointers coerced
5366 // to functions that return anyerror.5379 // to functions that return anyerror.
5367 const no_err_id = try cg.constInt(.anyerror, 0);5380 const no_err_id = try cg.constInt(.anyerror, 0);
5368 return try cg.body.emit(cg.module.gpa, .OpReturnValue, .{ .value = no_err_id });5381 return try cg.body.emit(gpa, .OpReturnValue, .{ .value = no_err_id });
5369 } else {5382 } else {
5370 return try cg.body.emit(cg.module.gpa, .OpReturn, {});5383 return try cg.body.emit(gpa, .OpReturn, {});
5371 }5384 }
5372 }5385 }
53735386
5374 const ptr = try cg.resolve(un_op);5387 const ptr = try cg.resolve(un_op);
5375 const value = try cg.load(ret_ty, ptr, .{ .is_volatile = ptr_ty.isVolatilePtr(zcu) });5388 const value = try cg.load(ret_ty, ptr, .{ .is_volatile = ptr_ty.isVolatilePtr(zcu) });
5376 try cg.body.emit(cg.module.gpa, .OpReturnValue, .{5389 try cg.body.emit(gpa, .OpReturnValue, .{
5377 .value = value,5390 .value = value,
5378 });5391 });
5379}5392}
53805393
5381fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {5394fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
5395 const gpa = cg.module.gpa;
5382 const zcu = cg.module.zcu;5396 const zcu = cg.module.zcu;
5383 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;5397 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
5384 const err_union_id = try cg.resolve(pl_op.operand);5398 const err_union_id = try cg.resolve(pl_op.operand);
...@@ -5400,7 +5414,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -5400,7 +5414,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
54005414
5401 const zero_id = try cg.constInt(.anyerror, 0);5415 const zero_id = try cg.constInt(.anyerror, 0);
5402 const is_err_id = cg.module.allocId();5416 const is_err_id = cg.module.allocId();
5403 try cg.body.emit(cg.module.gpa, .OpINotEqual, .{5417 try cg.body.emit(gpa, .OpINotEqual, .{
5404 .id_result_type = bool_ty_id,5418 .id_result_type = bool_ty_id,
5405 .id_result = is_err_id,5419 .id_result = is_err_id,
5406 .operand_1 = err_id,5420 .operand_1 = err_id,
...@@ -5420,7 +5434,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -5420,7 +5434,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
5420 // to not break and end in a return instruction. Thus,5434 // to not break and end in a return instruction. Thus,
5421 // for structured control flow, we can just naively use5435 // for structured control flow, we can just naively use
5422 // the ok block as the merge block here.5436 // the ok block as the merge block here.
5423 try cg.body.emit(cg.module.gpa, .OpSelectionMerge, .{5437 try cg.body.emit(gpa, .OpSelectionMerge, .{
5424 .merge_block = ok_block,5438 .merge_block = ok_block,
5425 .selection_control = .{},5439 .selection_control = .{},
5426 });5440 });
...@@ -5428,7 +5442,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -5428,7 +5442,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
5428 .unstructured => {},5442 .unstructured => {},
5429 }5443 }
54305444
5431 try cg.body.emit(cg.module.gpa, .OpBranchConditional, .{5445 try cg.body.emit(gpa, .OpBranchConditional, .{
5432 .condition = is_err_id,5446 .condition = is_err_id,
5433 .true_label = err_block,5447 .true_label = err_block,
5434 .false_label = ok_block,5448 .false_label = ok_block,
...@@ -5768,14 +5782,14 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5768,14 +5782,14 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5768 };5782 };
57695783
5770 if (cg.control_flow == .structured) {5784 if (cg.control_flow == .structured) {
5771 try cg.body.emit(cg.module.gpa, .OpSelectionMerge, .{5785 try cg.body.emit(gpa, .OpSelectionMerge, .{
5772 .merge_block = merge_label.?,5786 .merge_block = merge_label.?,
5773 .selection_control = .{},5787 .selection_control = .{},
5774 });5788 });
5775 }5789 }
57765790
5777 // Emit the instruction before generating the blocks.5791 // Emit the instruction before generating the blocks.
5778 try cg.body.emitRaw(cg.module.gpa, .OpSwitch, 2 + (cond_words + 1) * num_conditions);5792 try cg.body.emitRaw(gpa, .OpSwitch, 2 + (cond_words + 1) * num_conditions);
5779 cg.body.writeOperand(Id, cond_indirect);5793 cg.body.writeOperand(Id, cond_indirect);
5780 cg.body.writeOperand(Id, default);5794 cg.body.writeOperand(Id, default);
57815795
...@@ -5830,7 +5844,8 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5830,7 +5844,8 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5830 .src_label = cg.block_label,5844 .src_label = cg.block_label,
5831 .next_block = next_block,5845 .next_block = next_block,
5832 });5846 });
5833 try cg.body.emitBranch(cg.module.gpa, merge_label.?);5847
5848 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label.? });
5834 },5849 },
5835 .unstructured => {5850 .unstructured => {
5836 try cg.genBody(case.body);5851 try cg.genBody(case.body);
...@@ -5848,14 +5863,15 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5848,14 +5863,15 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
5848 .src_label = cg.block_label,5863 .src_label = cg.block_label,
5849 .next_block = next_block,5864 .next_block = next_block,
5850 });5865 });
5851 try cg.body.emitBranch(cg.module.gpa, merge_label.?);5866
5867 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label.? });
5852 },5868 },
5853 .unstructured => {5869 .unstructured => {
5854 try cg.genBody(else_body);5870 try cg.genBody(else_body);
5855 },5871 },
5856 }5872 }
5857 } else {5873 } else {
5858 try cg.body.emit(cg.module.gpa, .OpUnreachable, {});5874 try cg.body.emit(gpa, .OpUnreachable, {});
5859 }5875 }
58605876
5861 if (cg.control_flow == .structured) {5877 if (cg.control_flow == .structured) {
...@@ -5921,8 +5937,8 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -5921,8 +5937,8 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
5921 return cg.todo("implement inline asm with more than 1 output", .{});5937 return cg.todo("implement inline asm with more than 1 output", .{});
5922 }5938 }
59235939
5924 var as: Assembler = .{ .cg = cg };5940 var ass: Assembler = .{ .cg = cg };
5925 defer as.deinit();5941 defer ass.deinit();
59265942
5927 var output_extra_i = extra_i;5943 var output_extra_i = extra_i;
5928 for (outputs) |output| {5944 for (outputs) |output| {
...@@ -5974,8 +5990,8 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -5974,8 +5990,8 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
59745990
5975 .undef => return cg.fail("assembly input with 'c' constraint cannot be undefined", .{}),5991 .undef => return cg.fail("assembly input with 'c' constraint cannot be undefined", .{}),
59765992
5977 .int => try as.value_map.put(gpa, name, .{ .constant = @intCast(val.toUnsignedInt(zcu)) }),5993 .int => try ass.value_map.put(gpa, name, .{ .constant = @intCast(val.toUnsignedInt(zcu)) }),
5978 .enum_literal => |str| try as.value_map.put(gpa, name, .{ .string = str.toSlice(ip) }),5994 .enum_literal => |str| try ass.value_map.put(gpa, name, .{ .string = str.toSlice(ip) }),
59795995
5980 else => unreachable, // TODO5996 else => unreachable, // TODO
5981 }5997 }
...@@ -5986,10 +6002,10 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -5986,10 +6002,10 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
5986 // That's fine for now, just make sure to resolve it as such.6002 // That's fine for now, just make sure to resolve it as such.
5987 const val = (try cg.air.value(input, cg.pt)).?;6003 const val = (try cg.air.value(input, cg.pt)).?;
5988 const ty_id = try cg.resolveType(val.toType(), .direct);6004 const ty_id = try cg.resolveType(val.toType(), .direct);
5989 try as.value_map.put(gpa, name, .{ .ty = ty_id });6005 try ass.value_map.put(gpa, name, .{ .ty = ty_id });
5990 } else {6006 } else {
5991 const ty_id = try cg.resolveType(input_ty, .direct);6007 const ty_id = try cg.resolveType(input_ty, .direct);
5992 try as.value_map.put(gpa, name, .{ .ty = ty_id });6008 try ass.value_map.put(gpa, name, .{ .ty = ty_id });
5993 }6009 }
5994 } else {6010 } else {
5995 if (input_ty.zigTypeTag(zcu) == .type) {6011 if (input_ty.zigTypeTag(zcu) == .type) {
...@@ -5997,7 +6013,7 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -5997,7 +6013,7 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
5997 }6013 }
59986014
5999 const val_id = try cg.resolve(input);6015 const val_id = try cg.resolve(input);
6000 try as.value_map.put(gpa, name, .{ .value = val_id });6016 try ass.value_map.put(gpa, name, .{ .value = val_id });
6001 }6017 }
6002 }6018 }
60036019
...@@ -6006,17 +6022,17 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -6006,17 +6022,17 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
60066022
6007 const asm_source = std.mem.sliceAsBytes(cg.air.extra.items[extra_i..])[0..extra.data.source_len];6023 const asm_source = std.mem.sliceAsBytes(cg.air.extra.items[extra_i..])[0..extra.data.source_len];
60086024
6009 as.assemble(asm_source) catch |err| switch (err) {6025 ass.assemble(asm_source) catch |err| switch (err) {
6010 error.AssembleFail => {6026 error.AssembleFail => {
6011 // TODO: For now the compiler only supports a single error message per decl,6027 // TODO: For now the compiler only supports a single error message per decl,
6012 // so to translate the possible multiple errors from the assembler, emit6028 // so to translate the possible multiple errors from the assembler, emit
6013 // them as notes here.6029 // them as notes here.
6014 // TODO: Translate proper error locations.6030 // TODO: Translate proper error locations.
6015 assert(as.errors.items.len != 0);6031 assert(ass.errors.items.len != 0);
6016 assert(cg.error_msg == null);6032 assert(cg.error_msg == null);
6017 const src_loc = zcu.navSrcLoc(cg.owner_nav);6033 const src_loc = zcu.navSrcLoc(cg.owner_nav);
6018 cg.error_msg = try Zcu.ErrorMsg.create(zcu.gpa, src_loc, "failed to assemble SPIR-V inline assembly", .{});6034 cg.error_msg = try Zcu.ErrorMsg.create(zcu.gpa, src_loc, "failed to assemble SPIR-V inline assembly", .{});
6019 const notes = try zcu.gpa.alloc(Zcu.ErrorMsg, as.errors.items.len);6035 const notes = try zcu.gpa.alloc(Zcu.ErrorMsg, ass.errors.items.len);
60206036
6021 // Sub-scope to prevent `return error.CodegenFail` from running the errdefers.6037 // Sub-scope to prevent `return error.CodegenFail` from running the errdefers.
6022 {6038 {
...@@ -6026,8 +6042,8 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -6026,8 +6042,8 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
6026 note.deinit(zcu.gpa);6042 note.deinit(zcu.gpa);
6027 };6043 };
60286044
6029 while (i < as.errors.items.len) : (i += 1) {6045 while (i < ass.errors.items.len) : (i += 1) {
6030 notes[i] = try Zcu.ErrorMsg.init(zcu.gpa, src_loc, "{s}", .{as.errors.items[i].msg});6046 notes[i] = try Zcu.ErrorMsg.init(zcu.gpa, src_loc, "{s}", .{ass.errors.items[i].msg});
6031 }6047 }
6032 }6048 }
6033 cg.error_msg.?.notes = notes;6049 cg.error_msg.?.notes = notes;
...@@ -6043,7 +6059,7 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {...@@ -6043,7 +6059,7 @@ fn airAssembly(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
6043 const name = std.mem.sliceTo(extra_bytes[constraint.len + 1 ..], 0);6059 const name = std.mem.sliceTo(extra_bytes[constraint.len + 1 ..], 0);
6044 output_extra_i += (constraint.len + name.len + (2 + 3)) / 4;6060 output_extra_i += (constraint.len + name.len + (2 + 3)) / 4;
60456061
6046 const result = as.value_map.get(name) orelse return {6062 const result = ass.value_map.get(name) orelse return {
6047 return cg.fail("invalid asm output '{s}'", .{name});6063 return cg.fail("invalid asm output '{s}'", .{name});
6048 };6064 };
60496065
...@@ -6083,8 +6099,11 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie...@@ -6083,8 +6099,11 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie
6083 const callee_id = try cg.resolve(pl_op.operand);6099 const callee_id = try cg.resolve(pl_op.operand);
60846100
6085 comptime assert(zig_call_abi_ver == 3);6101 comptime assert(zig_call_abi_ver == 3);
6086 const params = try gpa.alloc(Id, args.len);6102
6087 defer gpa.free(params);6103 const scratch_top = cg.id_scratch.items.len;
6104 defer cg.id_scratch.shrinkRetainingCapacity(scratch_top);
6105 const params = try cg.id_scratch.addManyAsSlice(gpa, args.len);
6106
6088 var n_params: usize = 0;6107 var n_params: usize = 0;
6089 for (args) |arg| {6108 for (args) |arg| {
6090 // Note: resolve() might emit instructions, so we need to call it6109 // Note: resolve() might emit instructions, so we need to call it
...@@ -6098,7 +6117,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie...@@ -6098,7 +6117,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie
6098 n_params += 1;6117 n_params += 1;
6099 }6118 }
61006119
6101 try cg.body.emit(cg.module.gpa, .OpFunctionCall, .{6120 try cg.body.emit(gpa, .OpFunctionCall, .{
6102 .id_result_type = result_type_id,6121 .id_result_type = result_type_id,
6103 .id_result = result_id,6122 .id_result = result_id,
6104 .function = callee_id,6123 .function = callee_id,
...@@ -6119,15 +6138,16 @@ fn builtin3D(...@@ -6119,15 +6138,16 @@ fn builtin3D(
6119 dimension: u32,6138 dimension: u32,
6120 out_of_range_value: anytype,6139 out_of_range_value: anytype,
6121) !Id {6140) !Id {
6141 const gpa = cg.module.gpa;
6122 if (dimension >= 3) return try cg.constInt(result_ty, out_of_range_value);6142 if (dimension >= 3) return try cg.constInt(result_ty, out_of_range_value);
6123 const u32_ty_id = try cg.module.intType(.unsigned, 32);6143 const u32_ty_id = try cg.module.intType(.unsigned, 32);
6124 const vec_ty_id = try cg.module.vectorType(3, u32_ty_id);6144 const vec_ty_id = try cg.module.vectorType(3, u32_ty_id);
6125 const ptr_ty_id = try cg.module.ptrType(vec_ty_id, .input);6145 const ptr_ty_id = try cg.module.ptrType(vec_ty_id, .input);
6126 const spv_decl_index = try cg.module.builtin(ptr_ty_id, builtin, .input);6146 const spv_decl_index = try cg.module.builtin(ptr_ty_id, builtin, .input);
6127 try cg.decl_deps.put(cg.module.gpa, spv_decl_index, {});6147 try cg.module.decl_deps.append(gpa, spv_decl_index);
6128 const ptr_id = cg.module.declPtr(spv_decl_index).result_id;6148 const ptr_id = cg.module.declPtr(spv_decl_index).result_id;
6129 const vec_id = cg.module.allocId();6149 const vec_id = cg.module.allocId();
6130 try cg.body.emit(cg.module.gpa, .OpLoad, .{6150 try cg.body.emit(gpa, .OpLoad, .{
6131 .id_result_type = vec_ty_id,6151 .id_result_type = vec_ty_id,
6132 .id_result = vec_id,6152 .id_result = vec_id,
6133 .pointer = ptr_id,6153 .pointer = ptr_id,
src/codegen/spirv/Module.zig+6-20
...@@ -125,9 +125,9 @@ pub const Decl = struct {...@@ -125,9 +125,9 @@ pub const Decl = struct {
125 /// - For `invocation_global`, this is the result-id of the associated InvocationGlobal instruction.125 /// - For `invocation_global`, this is the result-id of the associated InvocationGlobal instruction.
126 result_id: Id,126 result_id: Id,
127 /// The offset of the first dependency of this decl in the `decl_deps` array.127 /// The offset of the first dependency of this decl in the `decl_deps` array.
128 begin_dep: u32,128 begin_dep: usize = 0,
129 /// The past-end offset of the dependencies of this decl in the `decl_deps` array.129 /// The past-end offset of the dependencies of this decl in the `decl_deps` array.
130 end_dep: u32,130 end_dep: usize = 0,
131};131};
132132
133/// This models a kernel entry point.133/// This models a kernel entry point.
...@@ -258,7 +258,6 @@ pub fn resolveNav(module: *Module, ip: *InternPool, nav_index: InternPool.Nav.In...@@ -258,7 +258,6 @@ pub fn resolveNav(module: *Module, ip: *InternPool, nav_index: InternPool.Nav.In
258 .generic => .invocation_global,258 .generic => .invocation_global,
259 else => .global,259 else => .global,
260 };260 };
261
262 entry.value_ptr.* = try module.allocDecl(kind);261 entry.value_ptr.* = try module.allocDecl(kind);
263 }262 }
264263
...@@ -782,15 +781,15 @@ pub fn builtin(...@@ -782,15 +781,15 @@ pub fn builtin(
782 const gop = try module.cache.builtins.getOrPut(module.gpa, .{ spirv_builtin, storage_class });781 const gop = try module.cache.builtins.getOrPut(module.gpa, .{ spirv_builtin, storage_class });
783 if (!gop.found_existing) {782 if (!gop.found_existing) {
784 const decl_index = try module.allocDecl(.global);783 const decl_index = try module.allocDecl(.global);
785 const result_id = module.declPtr(decl_index).result_id;784 const decl = module.declPtr(decl_index);
785
786 gop.value_ptr.* = decl_index;786 gop.value_ptr.* = decl_index;
787 try module.sections.globals.emit(module.gpa, .OpVariable, .{787 try module.sections.globals.emit(module.gpa, .OpVariable, .{
788 .id_result_type = result_ty_id,788 .id_result_type = result_ty_id,
789 .id_result = result_id,789 .id_result = decl.result_id,
790 .storage_class = storage_class,790 .storage_class = storage_class,
791 });791 });
792 try module.decorate(result_id, .{ .built_in = .{ .built_in = spirv_builtin } });792 try module.decorate(decl.result_id, .{ .built_in = .{ .built_in = spirv_builtin } });
793 try module.declareDeclDeps(decl_index, &.{});
794 }793 }
795 return gop.value_ptr.*;794 return gop.value_ptr.*;
796}795}
...@@ -847,8 +846,6 @@ pub fn allocDecl(module: *Module, kind: Decl.Kind) !Decl.Index {...@@ -847,8 +846,6 @@ pub fn allocDecl(module: *Module, kind: Decl.Kind) !Decl.Index {
847 try module.decls.append(module.gpa, .{846 try module.decls.append(module.gpa, .{
848 .kind = kind,847 .kind = kind,
849 .result_id = module.allocId(),848 .result_id = module.allocId(),
850 .begin_dep = undefined,
851 .end_dep = undefined,
852 });849 });
853850
854 return @as(Decl.Index, @enumFromInt(@as(u32, @intCast(module.decls.items.len - 1))));851 return @as(Decl.Index, @enumFromInt(@as(u32, @intCast(module.decls.items.len - 1))));
...@@ -858,17 +855,6 @@ pub fn declPtr(module: *Module, index: Decl.Index) *Decl {...@@ -858,17 +855,6 @@ pub fn declPtr(module: *Module, index: Decl.Index) *Decl {
858 return &module.decls.items[@intFromEnum(index)];855 return &module.decls.items[@intFromEnum(index)];
859}856}
860857
861/// Declare ALL dependencies for a decl.
862pub fn declareDeclDeps(module: *Module, decl_index: Decl.Index, deps: []const Decl.Index) !void {
863 const begin_dep: u32 = @intCast(module.decl_deps.items.len);
864 try module.decl_deps.appendSlice(module.gpa, deps);
865 const end_dep: u32 = @intCast(module.decl_deps.items.len);
866
867 const decl = module.declPtr(decl_index);
868 decl.begin_dep = begin_dep;
869 decl.end_dep = end_dep;
870}
871
872/// Declare a SPIR-V function as an entry point. This causes an extra wrapper858/// Declare a SPIR-V function as an entry point. This causes an extra wrapper
873/// function to be generated, which is then exported as the real entry point. The purpose of this859/// function to be generated, which is then exported as the real entry point. The purpose of this
874/// wrapper is to allocate and initialize the structure holding the instance globals.860/// wrapper is to allocate and initialize the structure holding the instance globals.
src/codegen/spirv/Section.zig+1-11
...@@ -21,7 +21,7 @@ pub fn deinit(section: *Section, allocator: Allocator) void {...@@ -21,7 +21,7 @@ pub fn deinit(section: *Section, allocator: Allocator) void {
21}21}
2222
23pub fn reset(section: *Section) void {23pub fn reset(section: *Section) void {
24 section.instructions.items.len = 0;24 section.instructions.clearRetainingCapacity();
25}25}
2626
27pub fn toWords(section: Section) []Word {27pub fn toWords(section: Section) []Word {
...@@ -86,16 +86,6 @@ pub fn emit(...@@ -86,16 +86,6 @@ pub fn emit(
86 section.writeOperands(opcode.Operands(), operands);86 section.writeOperands(opcode.Operands(), operands);
87}87}
8888
89pub fn emitBranch(
90 section: *Section,
91 allocator: Allocator,
92 target_label: spec.Id,
93) !void {
94 try section.emit(allocator, .OpBranch, .{
95 .target_label = target_label,
96 });
97}
98
99pub fn writeWord(section: *Section, word: Word) void {89pub fn writeWord(section: *Section, word: Word) void {
100 section.instructions.appendAssumeCapacity(word);90 section.instructions.appendAssumeCapacity(word);
101}91}
src/codegen/spirv/spec.zig+783-3529
...@@ -191,25 +191,6 @@ pub const OperandKind = enum {...@@ -191,25 +191,6 @@ pub const OperandKind = enum {
191 pair_id_ref_literal_integer,191 pair_id_ref_literal_integer,
192 pair_id_ref_id_ref,192 pair_id_ref_id_ref,
193 tensor_operands,193 tensor_operands,
194 debug_info_debug_info_flags,
195 debug_info_debug_base_type_attribute_encoding,
196 debug_info_debug_composite_type,
197 debug_info_debug_type_qualifier,
198 debug_info_debug_operation,
199 open_cl_debug_info_100_debug_info_flags,
200 open_cl_debug_info_100_debug_base_type_attribute_encoding,
201 open_cl_debug_info_100_debug_composite_type,
202 open_cl_debug_info_100_debug_type_qualifier,
203 open_cl_debug_info_100_debug_operation,
204 open_cl_debug_info_100_debug_imported_entity,
205 non_semantic_clspv_reflection_6_kernel_property_flags,
206 non_semantic_shader_debug_info_100_debug_info_flags,
207 non_semantic_shader_debug_info_100_build_identifier_flags,
208 non_semantic_shader_debug_info_100_debug_base_type_attribute_encoding,
209 non_semantic_shader_debug_info_100_debug_composite_type,
210 non_semantic_shader_debug_info_100_debug_type_qualifier,
211 non_semantic_shader_debug_info_100_debug_operation,
212 non_semantic_shader_debug_info_100_debug_imported_entity,
213194
214 pub fn category(self: OperandKind) OperandCategory {195 pub fn category(self: OperandKind) OperandCategory {
215 return switch (self) {196 return switch (self) {
...@@ -285,25 +266,6 @@ pub const OperandKind = enum {...@@ -285,25 +266,6 @@ pub const OperandKind = enum {
285 .pair_id_ref_literal_integer => .composite,266 .pair_id_ref_literal_integer => .composite,
286 .pair_id_ref_id_ref => .composite,267 .pair_id_ref_id_ref => .composite,
287 .tensor_operands => .bit_enum,268 .tensor_operands => .bit_enum,
288 .debug_info_debug_info_flags => .bit_enum,
289 .debug_info_debug_base_type_attribute_encoding => .value_enum,
290 .debug_info_debug_composite_type => .value_enum,
291 .debug_info_debug_type_qualifier => .value_enum,
292 .debug_info_debug_operation => .value_enum,
293 .open_cl_debug_info_100_debug_info_flags => .bit_enum,
294 .open_cl_debug_info_100_debug_base_type_attribute_encoding => .value_enum,
295 .open_cl_debug_info_100_debug_composite_type => .value_enum,
296 .open_cl_debug_info_100_debug_type_qualifier => .value_enum,
297 .open_cl_debug_info_100_debug_operation => .value_enum,
298 .open_cl_debug_info_100_debug_imported_entity => .value_enum,
299 .non_semantic_clspv_reflection_6_kernel_property_flags => .bit_enum,
300 .non_semantic_shader_debug_info_100_debug_info_flags => .bit_enum,
301 .non_semantic_shader_debug_info_100_build_identifier_flags => .bit_enum,
302 .non_semantic_shader_debug_info_100_debug_base_type_attribute_encoding => .value_enum,
303 .non_semantic_shader_debug_info_100_debug_composite_type => .value_enum,
304 .non_semantic_shader_debug_info_100_debug_type_qualifier => .value_enum,
305 .non_semantic_shader_debug_info_100_debug_operation => .value_enum,
306 .non_semantic_shader_debug_info_100_debug_imported_entity => .value_enum,
307 };269 };
308 }270 }
309 pub fn enumerants(self: OperandKind) []const Enumerant {271 pub fn enumerants(self: OperandKind) []const Enumerant {
...@@ -1475,178 +1437,10 @@ pub const OperandKind = enum {...@@ -1475,178 +1437,10 @@ pub const OperandKind = enum {
1475 .{ .name = "MakeElementVisibleARM", .value = 0x0008, .parameters = &.{.id_ref} },1437 .{ .name = "MakeElementVisibleARM", .value = 0x0008, .parameters = &.{.id_ref} },
1476 .{ .name = "NonPrivateElementARM", .value = 0x0010, .parameters = &.{} },1438 .{ .name = "NonPrivateElementARM", .value = 0x0010, .parameters = &.{} },
1477 },1439 },
1478 .debug_info_debug_info_flags => &.{
1479 .{ .name = "FlagIsProtected", .value = 0x01, .parameters = &.{} },
1480 .{ .name = "FlagIsPrivate", .value = 0x02, .parameters = &.{} },
1481 .{ .name = "FlagIsPublic", .value = 0x03, .parameters = &.{} },
1482 .{ .name = "FlagIsLocal", .value = 0x04, .parameters = &.{} },
1483 .{ .name = "FlagIsDefinition", .value = 0x08, .parameters = &.{} },
1484 .{ .name = "FlagFwdDecl", .value = 0x10, .parameters = &.{} },
1485 .{ .name = "FlagArtificial", .value = 0x20, .parameters = &.{} },
1486 .{ .name = "FlagExplicit", .value = 0x40, .parameters = &.{} },
1487 .{ .name = "FlagPrototyped", .value = 0x80, .parameters = &.{} },
1488 .{ .name = "FlagObjectPointer", .value = 0x100, .parameters = &.{} },
1489 .{ .name = "FlagStaticMember", .value = 0x200, .parameters = &.{} },
1490 .{ .name = "FlagIndirectVariable", .value = 0x400, .parameters = &.{} },
1491 .{ .name = "FlagLValueReference", .value = 0x800, .parameters = &.{} },
1492 .{ .name = "FlagRValueReference", .value = 0x1000, .parameters = &.{} },
1493 .{ .name = "FlagIsOptimized", .value = 0x2000, .parameters = &.{} },
1494 },
1495 .debug_info_debug_base_type_attribute_encoding => &.{
1496 .{ .name = "Unspecified", .value = 0, .parameters = &.{} },
1497 .{ .name = "Address", .value = 1, .parameters = &.{} },
1498 .{ .name = "Boolean", .value = 2, .parameters = &.{} },
1499 .{ .name = "Float", .value = 4, .parameters = &.{} },
1500 .{ .name = "Signed", .value = 5, .parameters = &.{} },
1501 .{ .name = "SignedChar", .value = 6, .parameters = &.{} },
1502 .{ .name = "Unsigned", .value = 7, .parameters = &.{} },
1503 .{ .name = "UnsignedChar", .value = 8, .parameters = &.{} },
1504 },
1505 .debug_info_debug_composite_type => &.{
1506 .{ .name = "Class", .value = 0, .parameters = &.{} },
1507 .{ .name = "Structure", .value = 1, .parameters = &.{} },
1508 .{ .name = "Union", .value = 2, .parameters = &.{} },
1509 },
1510 .debug_info_debug_type_qualifier => &.{
1511 .{ .name = "ConstType", .value = 0, .parameters = &.{} },
1512 .{ .name = "VolatileType", .value = 1, .parameters = &.{} },
1513 .{ .name = "RestrictType", .value = 2, .parameters = &.{} },
1514 },
1515 .debug_info_debug_operation => &.{
1516 .{ .name = "Deref", .value = 0, .parameters = &.{} },
1517 .{ .name = "Plus", .value = 1, .parameters = &.{} },
1518 .{ .name = "Minus", .value = 2, .parameters = &.{} },
1519 .{ .name = "PlusUconst", .value = 3, .parameters = &.{.literal_integer} },
1520 .{ .name = "BitPiece", .value = 4, .parameters = &.{ .literal_integer, .literal_integer } },
1521 .{ .name = "Swap", .value = 5, .parameters = &.{} },
1522 .{ .name = "Xderef", .value = 6, .parameters = &.{} },
1523 .{ .name = "StackValue", .value = 7, .parameters = &.{} },
1524 .{ .name = "Constu", .value = 8, .parameters = &.{.literal_integer} },
1525 },
1526 .open_cl_debug_info_100_debug_info_flags => &.{
1527 .{ .name = "FlagIsProtected", .value = 0x01, .parameters = &.{} },
1528 .{ .name = "FlagIsPrivate", .value = 0x02, .parameters = &.{} },
1529 .{ .name = "FlagIsPublic", .value = 0x03, .parameters = &.{} },
1530 .{ .name = "FlagIsLocal", .value = 0x04, .parameters = &.{} },
1531 .{ .name = "FlagIsDefinition", .value = 0x08, .parameters = &.{} },
1532 .{ .name = "FlagFwdDecl", .value = 0x10, .parameters = &.{} },
1533 .{ .name = "FlagArtificial", .value = 0x20, .parameters = &.{} },
1534 .{ .name = "FlagExplicit", .value = 0x40, .parameters = &.{} },
1535 .{ .name = "FlagPrototyped", .value = 0x80, .parameters = &.{} },
1536 .{ .name = "FlagObjectPointer", .value = 0x100, .parameters = &.{} },
1537 .{ .name = "FlagStaticMember", .value = 0x200, .parameters = &.{} },
1538 .{ .name = "FlagIndirectVariable", .value = 0x400, .parameters = &.{} },
1539 .{ .name = "FlagLValueReference", .value = 0x800, .parameters = &.{} },
1540 .{ .name = "FlagRValueReference", .value = 0x1000, .parameters = &.{} },
1541 .{ .name = "FlagIsOptimized", .value = 0x2000, .parameters = &.{} },
1542 .{ .name = "FlagIsEnumClass", .value = 0x4000, .parameters = &.{} },
1543 .{ .name = "FlagTypePassByValue", .value = 0x8000, .parameters = &.{} },
1544 .{ .name = "FlagTypePassByReference", .value = 0x10000, .parameters = &.{} },
1545 },
1546 .open_cl_debug_info_100_debug_base_type_attribute_encoding => &.{
1547 .{ .name = "Unspecified", .value = 0, .parameters = &.{} },
1548 .{ .name = "Address", .value = 1, .parameters = &.{} },
1549 .{ .name = "Boolean", .value = 2, .parameters = &.{} },
1550 .{ .name = "Float", .value = 3, .parameters = &.{} },
1551 .{ .name = "Signed", .value = 4, .parameters = &.{} },
1552 .{ .name = "SignedChar", .value = 5, .parameters = &.{} },
1553 .{ .name = "Unsigned", .value = 6, .parameters = &.{} },
1554 .{ .name = "UnsignedChar", .value = 7, .parameters = &.{} },
1555 },
1556 .open_cl_debug_info_100_debug_composite_type => &.{
1557 .{ .name = "Class", .value = 0, .parameters = &.{} },
1558 .{ .name = "Structure", .value = 1, .parameters = &.{} },
1559 .{ .name = "Union", .value = 2, .parameters = &.{} },
1560 },
1561 .open_cl_debug_info_100_debug_type_qualifier => &.{
1562 .{ .name = "ConstType", .value = 0, .parameters = &.{} },
1563 .{ .name = "VolatileType", .value = 1, .parameters = &.{} },
1564 .{ .name = "RestrictType", .value = 2, .parameters = &.{} },
1565 .{ .name = "AtomicType", .value = 3, .parameters = &.{} },
1566 },
1567 .open_cl_debug_info_100_debug_operation => &.{
1568 .{ .name = "Deref", .value = 0, .parameters = &.{} },
1569 .{ .name = "Plus", .value = 1, .parameters = &.{} },
1570 .{ .name = "Minus", .value = 2, .parameters = &.{} },
1571 .{ .name = "PlusUconst", .value = 3, .parameters = &.{.literal_integer} },
1572 .{ .name = "BitPiece", .value = 4, .parameters = &.{ .literal_integer, .literal_integer } },
1573 .{ .name = "Swap", .value = 5, .parameters = &.{} },
1574 .{ .name = "Xderef", .value = 6, .parameters = &.{} },
1575 .{ .name = "StackValue", .value = 7, .parameters = &.{} },
1576 .{ .name = "Constu", .value = 8, .parameters = &.{.literal_integer} },
1577 .{ .name = "Fragment", .value = 9, .parameters = &.{ .literal_integer, .literal_integer } },
1578 },
1579 .open_cl_debug_info_100_debug_imported_entity => &.{
1580 .{ .name = "ImportedModule", .value = 0, .parameters = &.{} },
1581 .{ .name = "ImportedDeclaration", .value = 1, .parameters = &.{} },
1582 },
1583 .non_semantic_clspv_reflection_6_kernel_property_flags => &.{
1584 .{ .name = "MayUsePrintf", .value = 0x1, .parameters = &.{} },
1585 },
1586 .non_semantic_shader_debug_info_100_debug_info_flags => &.{
1587 .{ .name = "FlagIsProtected", .value = 0x01, .parameters = &.{} },
1588 .{ .name = "FlagIsPrivate", .value = 0x02, .parameters = &.{} },
1589 .{ .name = "FlagIsPublic", .value = 0x03, .parameters = &.{} },
1590 .{ .name = "FlagIsLocal", .value = 0x04, .parameters = &.{} },
1591 .{ .name = "FlagIsDefinition", .value = 0x08, .parameters = &.{} },
1592 .{ .name = "FlagFwdDecl", .value = 0x10, .parameters = &.{} },
1593 .{ .name = "FlagArtificial", .value = 0x20, .parameters = &.{} },
1594 .{ .name = "FlagExplicit", .value = 0x40, .parameters = &.{} },
1595 .{ .name = "FlagPrototyped", .value = 0x80, .parameters = &.{} },
1596 .{ .name = "FlagObjectPointer", .value = 0x100, .parameters = &.{} },
1597 .{ .name = "FlagStaticMember", .value = 0x200, .parameters = &.{} },
1598 .{ .name = "FlagIndirectVariable", .value = 0x400, .parameters = &.{} },
1599 .{ .name = "FlagLValueReference", .value = 0x800, .parameters = &.{} },
1600 .{ .name = "FlagRValueReference", .value = 0x1000, .parameters = &.{} },
1601 .{ .name = "FlagIsOptimized", .value = 0x2000, .parameters = &.{} },
1602 .{ .name = "FlagIsEnumClass", .value = 0x4000, .parameters = &.{} },
1603 .{ .name = "FlagTypePassByValue", .value = 0x8000, .parameters = &.{} },
1604 .{ .name = "FlagTypePassByReference", .value = 0x10000, .parameters = &.{} },
1605 .{ .name = "FlagUnknownPhysicalLayout", .value = 0x20000, .parameters = &.{} },
1606 },
1607 .non_semantic_shader_debug_info_100_build_identifier_flags => &.{
1608 .{ .name = "IdentifierPossibleDuplicates", .value = 0x01, .parameters = &.{} },
1609 },
1610 .non_semantic_shader_debug_info_100_debug_base_type_attribute_encoding => &.{
1611 .{ .name = "Unspecified", .value = 0, .parameters = &.{} },
1612 .{ .name = "Address", .value = 1, .parameters = &.{} },
1613 .{ .name = "Boolean", .value = 2, .parameters = &.{} },
1614 .{ .name = "Float", .value = 3, .parameters = &.{} },
1615 .{ .name = "Signed", .value = 4, .parameters = &.{} },
1616 .{ .name = "SignedChar", .value = 5, .parameters = &.{} },
1617 .{ .name = "Unsigned", .value = 6, .parameters = &.{} },
1618 .{ .name = "UnsignedChar", .value = 7, .parameters = &.{} },
1619 },
1620 .non_semantic_shader_debug_info_100_debug_composite_type => &.{
1621 .{ .name = "Class", .value = 0, .parameters = &.{} },
1622 .{ .name = "Structure", .value = 1, .parameters = &.{} },
1623 .{ .name = "Union", .value = 2, .parameters = &.{} },
1624 },
1625 .non_semantic_shader_debug_info_100_debug_type_qualifier => &.{
1626 .{ .name = "ConstType", .value = 0, .parameters = &.{} },
1627 .{ .name = "VolatileType", .value = 1, .parameters = &.{} },
1628 .{ .name = "RestrictType", .value = 2, .parameters = &.{} },
1629 .{ .name = "AtomicType", .value = 3, .parameters = &.{} },
1630 },
1631 .non_semantic_shader_debug_info_100_debug_operation => &.{
1632 .{ .name = "Deref", .value = 0, .parameters = &.{} },
1633 .{ .name = "Plus", .value = 1, .parameters = &.{} },
1634 .{ .name = "Minus", .value = 2, .parameters = &.{} },
1635 .{ .name = "PlusUconst", .value = 3, .parameters = &.{.id_ref} },
1636 .{ .name = "BitPiece", .value = 4, .parameters = &.{ .id_ref, .id_ref } },
1637 .{ .name = "Swap", .value = 5, .parameters = &.{} },
1638 .{ .name = "Xderef", .value = 6, .parameters = &.{} },
1639 .{ .name = "StackValue", .value = 7, .parameters = &.{} },
1640 .{ .name = "Constu", .value = 8, .parameters = &.{.id_ref} },
1641 .{ .name = "Fragment", .value = 9, .parameters = &.{ .id_ref, .id_ref } },
1642 },
1643 .non_semantic_shader_debug_info_100_debug_imported_entity => &.{
1644 .{ .name = "ImportedModule", .value = 0, .parameters = &.{} },
1645 .{ .name = "ImportedDeclaration", .value = 1, .parameters = &.{} },
1646 },
1647 };1440 };
1648 }1441 }
1649};1442};
1443
1650pub const Opcode = enum(u16) {1444pub const Opcode = enum(u16) {
1651 OpNop = 0,1445 OpNop = 0,
1652 OpUndef = 1,1446 OpUndef = 1,
...@@ -3533,6 +3327,259 @@ pub const Opcode = enum(u16) {...@@ -3533,6 +3327,259 @@ pub const Opcode = enum(u16) {
3533 };3327 };
3534 }3328 }
3535};3329};
3330
3331pub const GlslOpcode = enum(u16) {
3332 Round = 1,
3333 RoundEven = 2,
3334 Trunc = 3,
3335 FAbs = 4,
3336 SAbs = 5,
3337 FSign = 6,
3338 SSign = 7,
3339 Floor = 8,
3340 Ceil = 9,
3341 Fract = 10,
3342 Radians = 11,
3343 Degrees = 12,
3344 Sin = 13,
3345 Cos = 14,
3346 Tan = 15,
3347 Asin = 16,
3348 Acos = 17,
3349 Atan = 18,
3350 Sinh = 19,
3351 Cosh = 20,
3352 Tanh = 21,
3353 Asinh = 22,
3354 Acosh = 23,
3355 Atanh = 24,
3356 Atan2 = 25,
3357 Pow = 26,
3358 Exp = 27,
3359 Log = 28,
3360 Exp2 = 29,
3361 Log2 = 30,
3362 Sqrt = 31,
3363 InverseSqrt = 32,
3364 Determinant = 33,
3365 MatrixInverse = 34,
3366 Modf = 35,
3367 ModfStruct = 36,
3368 FMin = 37,
3369 UMin = 38,
3370 SMin = 39,
3371 FMax = 40,
3372 UMax = 41,
3373 SMax = 42,
3374 FClamp = 43,
3375 UClamp = 44,
3376 SClamp = 45,
3377 FMix = 46,
3378 IMix = 47,
3379 Step = 48,
3380 SmoothStep = 49,
3381 Fma = 50,
3382 Frexp = 51,
3383 FrexpStruct = 52,
3384 Ldexp = 53,
3385 PackSnorm4x8 = 54,
3386 PackUnorm4x8 = 55,
3387 PackSnorm2x16 = 56,
3388 PackUnorm2x16 = 57,
3389 PackHalf2x16 = 58,
3390 PackDouble2x32 = 59,
3391 UnpackSnorm2x16 = 60,
3392 UnpackUnorm2x16 = 61,
3393 UnpackHalf2x16 = 62,
3394 UnpackSnorm4x8 = 63,
3395 UnpackUnorm4x8 = 64,
3396 UnpackDouble2x32 = 65,
3397 Length = 66,
3398 Distance = 67,
3399 Cross = 68,
3400 Normalize = 69,
3401 FaceForward = 70,
3402 Reflect = 71,
3403 Refract = 72,
3404 FindILsb = 73,
3405 FindSMsb = 74,
3406 FindUMsb = 75,
3407 InterpolateAtCentroid = 76,
3408 InterpolateAtSample = 77,
3409 InterpolateAtOffset = 78,
3410 NMin = 79,
3411 NMax = 80,
3412 NClamp = 81,
3413};
3414
3415pub const OpenClOpcode = enum(u16) {
3416 acos = 0,
3417 acosh = 1,
3418 acospi = 2,
3419 asin = 3,
3420 asinh = 4,
3421 asinpi = 5,
3422 atan = 6,
3423 atan2 = 7,
3424 atanh = 8,
3425 atanpi = 9,
3426 atan2pi = 10,
3427 cbrt = 11,
3428 ceil = 12,
3429 copysign = 13,
3430 cos = 14,
3431 cosh = 15,
3432 cospi = 16,
3433 erfc = 17,
3434 erf = 18,
3435 exp = 19,
3436 exp2 = 20,
3437 exp10 = 21,
3438 expm1 = 22,
3439 fabs = 23,
3440 fdim = 24,
3441 floor = 25,
3442 fma = 26,
3443 fmax = 27,
3444 fmin = 28,
3445 fmod = 29,
3446 fract = 30,
3447 frexp = 31,
3448 hypot = 32,
3449 ilogb = 33,
3450 ldexp = 34,
3451 lgamma = 35,
3452 lgamma_r = 36,
3453 log = 37,
3454 log2 = 38,
3455 log10 = 39,
3456 log1p = 40,
3457 logb = 41,
3458 mad = 42,
3459 maxmag = 43,
3460 minmag = 44,
3461 modf = 45,
3462 nan = 46,
3463 nextafter = 47,
3464 pow = 48,
3465 pown = 49,
3466 powr = 50,
3467 remainder = 51,
3468 remquo = 52,
3469 rint = 53,
3470 rootn = 54,
3471 round = 55,
3472 rsqrt = 56,
3473 sin = 57,
3474 sincos = 58,
3475 sinh = 59,
3476 sinpi = 60,
3477 sqrt = 61,
3478 tan = 62,
3479 tanh = 63,
3480 tanpi = 64,
3481 tgamma = 65,
3482 trunc = 66,
3483 half_cos = 67,
3484 half_divide = 68,
3485 half_exp = 69,
3486 half_exp2 = 70,
3487 half_exp10 = 71,
3488 half_log = 72,
3489 half_log2 = 73,
3490 half_log10 = 74,
3491 half_powr = 75,
3492 half_recip = 76,
3493 half_rsqrt = 77,
3494 half_sin = 78,
3495 half_sqrt = 79,
3496 half_tan = 80,
3497 native_cos = 81,
3498 native_divide = 82,
3499 native_exp = 83,
3500 native_exp2 = 84,
3501 native_exp10 = 85,
3502 native_log = 86,
3503 native_log2 = 87,
3504 native_log10 = 88,
3505 native_powr = 89,
3506 native_recip = 90,
3507 native_rsqrt = 91,
3508 native_sin = 92,
3509 native_sqrt = 93,
3510 native_tan = 94,
3511 fclamp = 95,
3512 degrees = 96,
3513 fmax_common = 97,
3514 fmin_common = 98,
3515 mix = 99,
3516 radians = 100,
3517 step = 101,
3518 smoothstep = 102,
3519 sign = 103,
3520 cross = 104,
3521 distance = 105,
3522 length = 106,
3523 normalize = 107,
3524 fast_distance = 108,
3525 fast_length = 109,
3526 fast_normalize = 110,
3527 s_abs = 141,
3528 s_abs_diff = 142,
3529 s_add_sat = 143,
3530 u_add_sat = 144,
3531 s_hadd = 145,
3532 u_hadd = 146,
3533 s_rhadd = 147,
3534 u_rhadd = 148,
3535 s_clamp = 149,
3536 u_clamp = 150,
3537 clz = 151,
3538 ctz = 152,
3539 s_mad_hi = 153,
3540 u_mad_sat = 154,
3541 s_mad_sat = 155,
3542 s_max = 156,
3543 u_max = 157,
3544 s_min = 158,
3545 u_min = 159,
3546 s_mul_hi = 160,
3547 rotate = 161,
3548 s_sub_sat = 162,
3549 u_sub_sat = 163,
3550 u_upsample = 164,
3551 s_upsample = 165,
3552 popcount = 166,
3553 s_mad24 = 167,
3554 u_mad24 = 168,
3555 s_mul24 = 169,
3556 u_mul24 = 170,
3557 vloadn = 171,
3558 vstoren = 172,
3559 vload_half = 173,
3560 vload_halfn = 174,
3561 vstore_half = 175,
3562 vstore_half_r = 176,
3563 vstore_halfn = 177,
3564 vstore_halfn_r = 178,
3565 vloada_halfn = 179,
3566 vstorea_halfn = 180,
3567 vstorea_halfn_r = 181,
3568 shuffle = 182,
3569 shuffle2 = 183,
3570 printf = 184,
3571 prefetch = 185,
3572 bitselect = 186,
3573 select = 187,
3574 u_abs = 201,
3575 u_abs_diff = 202,
3576 u_mul_hi = 203,
3577 u_mad_hi = 204,
3578};
3579
3580pub const Zig = enum(u16) {
3581 InvocationGlobal = 0,
3582};
3536pub const ImageOperands = packed struct {3583pub const ImageOperands = packed struct {
3537 bias: bool = false,3584 bias: bool = false,
3538 lod: bool = false,3585 lod: bool = false,
...@@ -5494,335 +5541,10 @@ pub const TensorOperands = packed struct {...@@ -5494,335 +5541,10 @@ pub const TensorOperands = packed struct {
5494 _reserved_bit_31: bool = false,5541 _reserved_bit_31: bool = false,
5495 };5542 };
5496};5543};
5497pub const @"DebugInfo.DebugInfoFlags" = packed struct {
5498 flag_is_protected: bool = false,
5499 flag_is_private: bool = false,
5500 flag_is_local: bool = false,
5501 flag_is_definition: bool = false,
5502 flag_fwd_decl: bool = false,
5503 flag_artificial: bool = false,
5504 flag_explicit: bool = false,
5505 flag_prototyped: bool = false,
5506 flag_object_pointer: bool = false,
5507 flag_static_member: bool = false,
5508 flag_indirect_variable: bool = false,
5509 flag_l_value_reference: bool = false,
5510 flag_r_value_reference: bool = false,
5511 flag_is_optimized: bool = false,
5512 _reserved_bit_14: bool = false,
5513 _reserved_bit_15: bool = false,
5514 _reserved_bit_16: bool = false,
5515 _reserved_bit_17: bool = false,
5516 _reserved_bit_18: bool = false,
5517 _reserved_bit_19: bool = false,
5518 _reserved_bit_20: bool = false,
5519 _reserved_bit_21: bool = false,
5520 _reserved_bit_22: bool = false,
5521 _reserved_bit_23: bool = false,
5522 _reserved_bit_24: bool = false,
5523 _reserved_bit_25: bool = false,
5524 _reserved_bit_26: bool = false,
5525 _reserved_bit_27: bool = false,
5526 _reserved_bit_28: bool = false,
5527 _reserved_bit_29: bool = false,
5528 _reserved_bit_30: bool = false,
5529 _reserved_bit_31: bool = false,
5530};
5531pub const @"DebugInfo.DebugBaseTypeAttributeEncoding" = enum(u32) {
5532 unspecified = 0,
5533 address = 1,
5534 boolean = 2,
5535 float = 4,
5536 signed = 5,
5537 signed_char = 6,
5538 unsigned = 7,
5539 unsigned_char = 8,
5540};
5541pub const @"DebugInfo.DebugCompositeType" = enum(u32) {
5542 class = 0,
5543 structure = 1,
5544 @"union" = 2,
5545};
5546pub const @"DebugInfo.DebugTypeQualifier" = enum(u32) {
5547 const_type = 0,
5548 volatile_type = 1,
5549 restrict_type = 2,
5550};
5551pub const @"DebugInfo.DebugOperation" = enum(u32) {
5552 deref = 0,
5553 plus = 1,
5554 minus = 2,
5555 plus_uconst = 3,
5556 bit_piece = 4,
5557 swap = 5,
5558 xderef = 6,
5559 stack_value = 7,
5560 constu = 8,
5561
5562 pub const Extended = union(@"DebugInfo.DebugOperation") {
5563 deref,
5564 plus,
5565 minus,
5566 plus_uconst: struct { literal_integer: LiteralInteger },
5567 bit_piece: struct { literal_integer_0: LiteralInteger, literal_integer_1: LiteralInteger },
5568 swap,
5569 xderef,
5570 stack_value,
5571 constu: struct { literal_integer: LiteralInteger },
5572 };
5573};
5574pub const @"OpenCL.DebugInfo.100.DebugInfoFlags" = packed struct {
5575 flag_is_protected: bool = false,
5576 flag_is_private: bool = false,
5577 flag_is_local: bool = false,
5578 flag_is_definition: bool = false,
5579 flag_fwd_decl: bool = false,
5580 flag_artificial: bool = false,
5581 flag_explicit: bool = false,
5582 flag_prototyped: bool = false,
5583 flag_object_pointer: bool = false,
5584 flag_static_member: bool = false,
5585 flag_indirect_variable: bool = false,
5586 flag_l_value_reference: bool = false,
5587 flag_r_value_reference: bool = false,
5588 flag_is_optimized: bool = false,
5589 flag_is_enum_class: bool = false,
5590 flag_type_pass_by_value: bool = false,
5591 flag_type_pass_by_reference: bool = false,
5592 _reserved_bit_17: bool = false,
5593 _reserved_bit_18: bool = false,
5594 _reserved_bit_19: bool = false,
5595 _reserved_bit_20: bool = false,
5596 _reserved_bit_21: bool = false,
5597 _reserved_bit_22: bool = false,
5598 _reserved_bit_23: bool = false,
5599 _reserved_bit_24: bool = false,
5600 _reserved_bit_25: bool = false,
5601 _reserved_bit_26: bool = false,
5602 _reserved_bit_27: bool = false,
5603 _reserved_bit_28: bool = false,
5604 _reserved_bit_29: bool = false,
5605 _reserved_bit_30: bool = false,
5606 _reserved_bit_31: bool = false,
5607};
5608pub const @"OpenCL.DebugInfo.100.DebugBaseTypeAttributeEncoding" = enum(u32) {
5609 unspecified = 0,
5610 address = 1,
5611 boolean = 2,
5612 float = 3,
5613 signed = 4,
5614 signed_char = 5,
5615 unsigned = 6,
5616 unsigned_char = 7,
5617};
5618pub const @"OpenCL.DebugInfo.100.DebugCompositeType" = enum(u32) {
5619 class = 0,
5620 structure = 1,
5621 @"union" = 2,
5622};
5623pub const @"OpenCL.DebugInfo.100.DebugTypeQualifier" = enum(u32) {
5624 const_type = 0,
5625 volatile_type = 1,
5626 restrict_type = 2,
5627 atomic_type = 3,
5628};
5629pub const @"OpenCL.DebugInfo.100.DebugOperation" = enum(u32) {
5630 deref = 0,
5631 plus = 1,
5632 minus = 2,
5633 plus_uconst = 3,
5634 bit_piece = 4,
5635 swap = 5,
5636 xderef = 6,
5637 stack_value = 7,
5638 constu = 8,
5639 fragment = 9,
5640
5641 pub const Extended = union(@"OpenCL.DebugInfo.100.DebugOperation") {
5642 deref,
5643 plus,
5644 minus,
5645 plus_uconst: struct { literal_integer: LiteralInteger },
5646 bit_piece: struct { literal_integer_0: LiteralInteger, literal_integer_1: LiteralInteger },
5647 swap,
5648 xderef,
5649 stack_value,
5650 constu: struct { literal_integer: LiteralInteger },
5651 fragment: struct { literal_integer_0: LiteralInteger, literal_integer_1: LiteralInteger },
5652 };
5653};
5654pub const @"OpenCL.DebugInfo.100.DebugImportedEntity" = enum(u32) {
5655 imported_module = 0,
5656 imported_declaration = 1,
5657};
5658pub const @"NonSemantic.ClspvReflection.6.KernelPropertyFlags" = packed struct {
5659 may_use_printf: bool = false,
5660 _reserved_bit_1: bool = false,
5661 _reserved_bit_2: bool = false,
5662 _reserved_bit_3: bool = false,
5663 _reserved_bit_4: bool = false,
5664 _reserved_bit_5: bool = false,
5665 _reserved_bit_6: bool = false,
5666 _reserved_bit_7: bool = false,
5667 _reserved_bit_8: bool = false,
5668 _reserved_bit_9: bool = false,
5669 _reserved_bit_10: bool = false,
5670 _reserved_bit_11: bool = false,
5671 _reserved_bit_12: bool = false,
5672 _reserved_bit_13: bool = false,
5673 _reserved_bit_14: bool = false,
5674 _reserved_bit_15: bool = false,
5675 _reserved_bit_16: bool = false,
5676 _reserved_bit_17: bool = false,
5677 _reserved_bit_18: bool = false,
5678 _reserved_bit_19: bool = false,
5679 _reserved_bit_20: bool = false,
5680 _reserved_bit_21: bool = false,
5681 _reserved_bit_22: bool = false,
5682 _reserved_bit_23: bool = false,
5683 _reserved_bit_24: bool = false,
5684 _reserved_bit_25: bool = false,
5685 _reserved_bit_26: bool = false,
5686 _reserved_bit_27: bool = false,
5687 _reserved_bit_28: bool = false,
5688 _reserved_bit_29: bool = false,
5689 _reserved_bit_30: bool = false,
5690 _reserved_bit_31: bool = false,
5691};
5692pub const @"NonSemantic.Shader.DebugInfo.100.DebugInfoFlags" = packed struct {
5693 flag_is_protected: bool = false,
5694 flag_is_private: bool = false,
5695 flag_is_local: bool = false,
5696 flag_is_definition: bool = false,
5697 flag_fwd_decl: bool = false,
5698 flag_artificial: bool = false,
5699 flag_explicit: bool = false,
5700 flag_prototyped: bool = false,
5701 flag_object_pointer: bool = false,
5702 flag_static_member: bool = false,
5703 flag_indirect_variable: bool = false,
5704 flag_l_value_reference: bool = false,
5705 flag_r_value_reference: bool = false,
5706 flag_is_optimized: bool = false,
5707 flag_is_enum_class: bool = false,
5708 flag_type_pass_by_value: bool = false,
5709 flag_type_pass_by_reference: bool = false,
5710 flag_unknown_physical_layout: bool = false,
5711 _reserved_bit_18: bool = false,
5712 _reserved_bit_19: bool = false,
5713 _reserved_bit_20: bool = false,
5714 _reserved_bit_21: bool = false,
5715 _reserved_bit_22: bool = false,
5716 _reserved_bit_23: bool = false,
5717 _reserved_bit_24: bool = false,
5718 _reserved_bit_25: bool = false,
5719 _reserved_bit_26: bool = false,
5720 _reserved_bit_27: bool = false,
5721 _reserved_bit_28: bool = false,
5722 _reserved_bit_29: bool = false,
5723 _reserved_bit_30: bool = false,
5724 _reserved_bit_31: bool = false,
5725};
5726pub const @"NonSemantic.Shader.DebugInfo.100.BuildIdentifierFlags" = packed struct {
5727 identifier_possible_duplicates: bool = false,
5728 _reserved_bit_1: bool = false,
5729 _reserved_bit_2: bool = false,
5730 _reserved_bit_3: bool = false,
5731 _reserved_bit_4: bool = false,
5732 _reserved_bit_5: bool = false,
5733 _reserved_bit_6: bool = false,
5734 _reserved_bit_7: bool = false,
5735 _reserved_bit_8: bool = false,
5736 _reserved_bit_9: bool = false,
5737 _reserved_bit_10: bool = false,
5738 _reserved_bit_11: bool = false,
5739 _reserved_bit_12: bool = false,
5740 _reserved_bit_13: bool = false,
5741 _reserved_bit_14: bool = false,
5742 _reserved_bit_15: bool = false,
5743 _reserved_bit_16: bool = false,
5744 _reserved_bit_17: bool = false,
5745 _reserved_bit_18: bool = false,
5746 _reserved_bit_19: bool = false,
5747 _reserved_bit_20: bool = false,
5748 _reserved_bit_21: bool = false,
5749 _reserved_bit_22: bool = false,
5750 _reserved_bit_23: bool = false,
5751 _reserved_bit_24: bool = false,
5752 _reserved_bit_25: bool = false,
5753 _reserved_bit_26: bool = false,
5754 _reserved_bit_27: bool = false,
5755 _reserved_bit_28: bool = false,
5756 _reserved_bit_29: bool = false,
5757 _reserved_bit_30: bool = false,
5758 _reserved_bit_31: bool = false,
5759};
5760pub const @"NonSemantic.Shader.DebugInfo.100.DebugBaseTypeAttributeEncoding" = enum(u32) {
5761 unspecified = 0,
5762 address = 1,
5763 boolean = 2,
5764 float = 3,
5765 signed = 4,
5766 signed_char = 5,
5767 unsigned = 6,
5768 unsigned_char = 7,
5769};
5770pub const @"NonSemantic.Shader.DebugInfo.100.DebugCompositeType" = enum(u32) {
5771 class = 0,
5772 structure = 1,
5773 @"union" = 2,
5774};
5775pub const @"NonSemantic.Shader.DebugInfo.100.DebugTypeQualifier" = enum(u32) {
5776 const_type = 0,
5777 volatile_type = 1,
5778 restrict_type = 2,
5779 atomic_type = 3,
5780};
5781pub const @"NonSemantic.Shader.DebugInfo.100.DebugOperation" = enum(u32) {
5782 deref = 0,
5783 plus = 1,
5784 minus = 2,
5785 plus_uconst = 3,
5786 bit_piece = 4,
5787 swap = 5,
5788 xderef = 6,
5789 stack_value = 7,
5790 constu = 8,
5791 fragment = 9,
5792
5793 pub const Extended = union(@"NonSemantic.Shader.DebugInfo.100.DebugOperation") {
5794 deref,
5795 plus,
5796 minus,
5797 plus_uconst: struct { id_ref: Id },
5798 bit_piece: struct { id_ref_0: Id, id_ref_1: Id },
5799 swap,
5800 xderef,
5801 stack_value,
5802 constu: struct { id_ref: Id },
5803 fragment: struct { id_ref_0: Id, id_ref_1: Id },
5804 };
5805};
5806pub const @"NonSemantic.Shader.DebugInfo.100.DebugImportedEntity" = enum(u32) {
5807 imported_module = 0,
5808 imported_declaration = 1,
5809};
5810pub const InstructionSet = enum {5544pub const InstructionSet = enum {
5811 core,5545 core,
5812 SPV_AMD_shader_trinary_minmax,
5813 SPV_EXT_INST_TYPE_TOSA_001000_1,
5814 @"NonSemantic.VkspReflection",
5815 SPV_AMD_shader_explicit_vertex_parameter,
5816 DebugInfo,
5817 @"NonSemantic.DebugBreak",
5818 @"OpenCL.DebugInfo.100",
5819 @"NonSemantic.ClspvReflection.6",
5820 @"GLSL.std.450",5546 @"GLSL.std.450",
5821 SPV_AMD_shader_ballot,
5822 @"NonSemantic.DebugPrintf",
5823 SPV_AMD_gcn_shader,
5824 @"OpenCL.std",5547 @"OpenCL.std",
5825 @"NonSemantic.Shader.DebugInfo.100",
5826 zig,5548 zig,
58275549
5828 pub fn instructions(self: InstructionSet) []const Instruction {5550 pub fn instructions(self: InstructionSet) []const Instruction {
...@@ -14088,480 +13810,321 @@ pub const InstructionSet = enum {...@@ -14088,480 +13810,321 @@ pub const InstructionSet = enum {
14088 },13810 },
14089 },13811 },
14090 },13812 },
14091 .SPV_AMD_shader_trinary_minmax => &.{13813 .@"GLSL.std.450" => &.{
14092 .{13814 .{
14093 .name = "FMin3AMD",13815 .name = "Round",
14094 .opcode = 1,13816 .opcode = 1,
14095 .operands = &.{13817 .operands = &.{
14096 .{ .kind = .id_ref, .quantifier = .required },13818 .{ .kind = .id_ref, .quantifier = .required },
14097 .{ .kind = .id_ref, .quantifier = .required },
14098 .{ .kind = .id_ref, .quantifier = .required },
14099 },13819 },
14100 },13820 },
14101 .{13821 .{
14102 .name = "UMin3AMD",13822 .name = "RoundEven",
14103 .opcode = 2,13823 .opcode = 2,
14104 .operands = &.{13824 .operands = &.{
14105 .{ .kind = .id_ref, .quantifier = .required },13825 .{ .kind = .id_ref, .quantifier = .required },
14106 .{ .kind = .id_ref, .quantifier = .required },
14107 .{ .kind = .id_ref, .quantifier = .required },
14108 },13826 },
14109 },13827 },
14110 .{13828 .{
14111 .name = "SMin3AMD",13829 .name = "Trunc",
14112 .opcode = 3,13830 .opcode = 3,
14113 .operands = &.{13831 .operands = &.{
14114 .{ .kind = .id_ref, .quantifier = .required },13832 .{ .kind = .id_ref, .quantifier = .required },
14115 .{ .kind = .id_ref, .quantifier = .required },
14116 .{ .kind = .id_ref, .quantifier = .required },
14117 },13833 },
14118 },13834 },
14119 .{13835 .{
14120 .name = "FMax3AMD",13836 .name = "FAbs",
14121 .opcode = 4,13837 .opcode = 4,
14122 .operands = &.{13838 .operands = &.{
14123 .{ .kind = .id_ref, .quantifier = .required },13839 .{ .kind = .id_ref, .quantifier = .required },
14124 .{ .kind = .id_ref, .quantifier = .required },
14125 .{ .kind = .id_ref, .quantifier = .required },
14126 },13840 },
14127 },13841 },
14128 .{13842 .{
14129 .name = "UMax3AMD",13843 .name = "SAbs",
14130 .opcode = 5,13844 .opcode = 5,
14131 .operands = &.{13845 .operands = &.{
14132 .{ .kind = .id_ref, .quantifier = .required },13846 .{ .kind = .id_ref, .quantifier = .required },
14133 .{ .kind = .id_ref, .quantifier = .required },
14134 .{ .kind = .id_ref, .quantifier = .required },
14135 },13847 },
14136 },13848 },
14137 .{13849 .{
14138 .name = "SMax3AMD",13850 .name = "FSign",
14139 .opcode = 6,13851 .opcode = 6,
14140 .operands = &.{13852 .operands = &.{
14141 .{ .kind = .id_ref, .quantifier = .required },13853 .{ .kind = .id_ref, .quantifier = .required },
14142 .{ .kind = .id_ref, .quantifier = .required },
14143 .{ .kind = .id_ref, .quantifier = .required },
14144 },13854 },
14145 },13855 },
14146 .{13856 .{
14147 .name = "FMid3AMD",13857 .name = "SSign",
14148 .opcode = 7,13858 .opcode = 7,
14149 .operands = &.{13859 .operands = &.{
14150 .{ .kind = .id_ref, .quantifier = .required },13860 .{ .kind = .id_ref, .quantifier = .required },
14151 .{ .kind = .id_ref, .quantifier = .required },
14152 .{ .kind = .id_ref, .quantifier = .required },
14153 },13861 },
14154 },13862 },
14155 .{13863 .{
14156 .name = "UMid3AMD",13864 .name = "Floor",
14157 .opcode = 8,13865 .opcode = 8,
14158 .operands = &.{13866 .operands = &.{
14159 .{ .kind = .id_ref, .quantifier = .required },13867 .{ .kind = .id_ref, .quantifier = .required },
14160 .{ .kind = .id_ref, .quantifier = .required },
14161 .{ .kind = .id_ref, .quantifier = .required },
14162 },13868 },
14163 },13869 },
14164 .{13870 .{
14165 .name = "SMid3AMD",13871 .name = "Ceil",
14166 .opcode = 9,13872 .opcode = 9,
14167 .operands = &.{13873 .operands = &.{
14168 .{ .kind = .id_ref, .quantifier = .required },13874 .{ .kind = .id_ref, .quantifier = .required },
14169 .{ .kind = .id_ref, .quantifier = .required },
14170 .{ .kind = .id_ref, .quantifier = .required },
14171 },13875 },
14172 },13876 },
14173 },
14174 .SPV_EXT_INST_TYPE_TOSA_001000_1 => &.{
14175 .{13877 .{
14176 .name = "ARGMAX",13878 .name = "Fract",
14177 .opcode = 0,13879 .opcode = 10,
14178 .operands = &.{13880 .operands = &.{
14179 .{ .kind = .id_ref, .quantifier = .required },13881 .{ .kind = .id_ref, .quantifier = .required },
14180 .{ .kind = .id_ref, .quantifier = .required },
14181 .{ .kind = .id_ref, .quantifier = .required },
14182 },13882 },
14183 },13883 },
14184 .{13884 .{
14185 .name = "AVG_POOL2D",13885 .name = "Radians",
14186 .opcode = 1,13886 .opcode = 11,
14187 .operands = &.{13887 .operands = &.{
14188 .{ .kind = .id_ref, .quantifier = .required },13888 .{ .kind = .id_ref, .quantifier = .required },
14189 .{ .kind = .id_ref, .quantifier = .required },
14190 .{ .kind = .id_ref, .quantifier = .required },
14191 .{ .kind = .id_ref, .quantifier = .required },
14192 .{ .kind = .id_ref, .quantifier = .required },
14193 .{ .kind = .id_ref, .quantifier = .required },
14194 .{ .kind = .id_ref, .quantifier = .required },
14195 },13889 },
14196 },13890 },
14197 .{13891 .{
14198 .name = "CONV2D",13892 .name = "Degrees",
14199 .opcode = 2,13893 .opcode = 12,
14200 .operands = &.{13894 .operands = &.{
14201 .{ .kind = .id_ref, .quantifier = .required },13895 .{ .kind = .id_ref, .quantifier = .required },
14202 .{ .kind = .id_ref, .quantifier = .required },
14203 .{ .kind = .id_ref, .quantifier = .required },
14204 .{ .kind = .id_ref, .quantifier = .required },
14205 .{ .kind = .id_ref, .quantifier = .required },
14206 .{ .kind = .id_ref, .quantifier = .required },
14207 .{ .kind = .id_ref, .quantifier = .required },
14208 .{ .kind = .id_ref, .quantifier = .required },
14209 .{ .kind = .id_ref, .quantifier = .required },
14210 .{ .kind = .id_ref, .quantifier = .required },
14211 },13896 },
14212 },13897 },
14213 .{13898 .{
14214 .name = "CONV3D",13899 .name = "Sin",
14215 .opcode = 3,13900 .opcode = 13,
14216 .operands = &.{13901 .operands = &.{
14217 .{ .kind = .id_ref, .quantifier = .required },13902 .{ .kind = .id_ref, .quantifier = .required },
14218 .{ .kind = .id_ref, .quantifier = .required },
14219 .{ .kind = .id_ref, .quantifier = .required },
14220 .{ .kind = .id_ref, .quantifier = .required },
14221 .{ .kind = .id_ref, .quantifier = .required },
14222 .{ .kind = .id_ref, .quantifier = .required },
14223 .{ .kind = .id_ref, .quantifier = .required },
14224 .{ .kind = .id_ref, .quantifier = .required },
14225 .{ .kind = .id_ref, .quantifier = .required },
14226 .{ .kind = .id_ref, .quantifier = .required },
14227 },13903 },
14228 },13904 },
14229 .{13905 .{
14230 .name = "DEPTHWISE_CONV2D",13906 .name = "Cos",
14231 .opcode = 4,13907 .opcode = 14,
14232 .operands = &.{13908 .operands = &.{
14233 .{ .kind = .id_ref, .quantifier = .required },13909 .{ .kind = .id_ref, .quantifier = .required },
14234 .{ .kind = .id_ref, .quantifier = .required },
14235 .{ .kind = .id_ref, .quantifier = .required },
14236 .{ .kind = .id_ref, .quantifier = .required },
14237 .{ .kind = .id_ref, .quantifier = .required },
14238 .{ .kind = .id_ref, .quantifier = .required },
14239 .{ .kind = .id_ref, .quantifier = .required },
14240 .{ .kind = .id_ref, .quantifier = .required },
14241 .{ .kind = .id_ref, .quantifier = .required },
14242 .{ .kind = .id_ref, .quantifier = .required },
14243 },13910 },
14244 },13911 },
14245 .{13912 .{
14246 .name = "FFT2D",13913 .name = "Tan",
14247 .opcode = 5,13914 .opcode = 15,
14248 .operands = &.{13915 .operands = &.{
14249 .{ .kind = .id_ref, .quantifier = .required },13916 .{ .kind = .id_ref, .quantifier = .required },
14250 .{ .kind = .id_ref, .quantifier = .required },
14251 .{ .kind = .id_ref, .quantifier = .required },
14252 .{ .kind = .id_ref, .quantifier = .required },
14253 },13917 },
14254 },13918 },
14255 .{13919 .{
14256 .name = "MATMUL",13920 .name = "Asin",
14257 .opcode = 6,13921 .opcode = 16,
14258 .operands = &.{13922 .operands = &.{
14259 .{ .kind = .id_ref, .quantifier = .required },13923 .{ .kind = .id_ref, .quantifier = .required },
14260 .{ .kind = .id_ref, .quantifier = .required },
14261 .{ .kind = .id_ref, .quantifier = .required },
14262 .{ .kind = .id_ref, .quantifier = .required },
14263 },13924 },
14264 },13925 },
14265 .{13926 .{
14266 .name = "MAX_POOL2D",13927 .name = "Acos",
14267 .opcode = 7,13928 .opcode = 17,
14268 .operands = &.{13929 .operands = &.{
14269 .{ .kind = .id_ref, .quantifier = .required },13930 .{ .kind = .id_ref, .quantifier = .required },
14270 .{ .kind = .id_ref, .quantifier = .required },
14271 .{ .kind = .id_ref, .quantifier = .required },
14272 .{ .kind = .id_ref, .quantifier = .required },
14273 .{ .kind = .id_ref, .quantifier = .required },
14274 },
14275 },
14276 .{
14277 .name = "RFFT2D",
14278 .opcode = 8,
14279 .operands = &.{
14280 .{ .kind = .id_ref, .quantifier = .required },
14281 .{ .kind = .id_ref, .quantifier = .required },
14282 },
14283 },
14284 .{
14285 .name = "TRANSPOSE_CONV2D",
14286 .opcode = 9,
14287 .operands = &.{
14288 .{ .kind = .id_ref, .quantifier = .required },
14289 .{ .kind = .id_ref, .quantifier = .required },
14290 .{ .kind = .id_ref, .quantifier = .required },
14291 .{ .kind = .id_ref, .quantifier = .required },
14292 .{ .kind = .id_ref, .quantifier = .required },
14293 .{ .kind = .id_ref, .quantifier = .required },
14294 .{ .kind = .id_ref, .quantifier = .required },
14295 .{ .kind = .id_ref, .quantifier = .required },
14296 .{ .kind = .id_ref, .quantifier = .required },
14297 },
14298 },
14299 .{
14300 .name = "CLAMP",
14301 .opcode = 10,
14302 .operands = &.{
14303 .{ .kind = .id_ref, .quantifier = .required },
14304 .{ .kind = .id_ref, .quantifier = .required },
14305 .{ .kind = .id_ref, .quantifier = .required },
14306 .{ .kind = .id_ref, .quantifier = .required },
14307 },
14308 },
14309 .{
14310 .name = "ERF",
14311 .opcode = 11,
14312 .operands = &.{
14313 .{ .kind = .id_ref, .quantifier = .required },
14314 },
14315 },
14316 .{
14317 .name = "SIGMOID",
14318 .opcode = 12,
14319 .operands = &.{
14320 .{ .kind = .id_ref, .quantifier = .required },
14321 },
14322 },
14323 .{
14324 .name = "TANH",
14325 .opcode = 13,
14326 .operands = &.{
14327 .{ .kind = .id_ref, .quantifier = .required },
14328 },
14329 },
14330 .{
14331 .name = "ADD",
14332 .opcode = 14,
14333 .operands = &.{
14334 .{ .kind = .id_ref, .quantifier = .required },
14335 .{ .kind = .id_ref, .quantifier = .required },
14336 },
14337 },
14338 .{
14339 .name = "ARITHMETIC_RIGHT_SHIFT",
14340 .opcode = 15,
14341 .operands = &.{
14342 .{ .kind = .id_ref, .quantifier = .required },
14343 .{ .kind = .id_ref, .quantifier = .required },
14344 .{ .kind = .id_ref, .quantifier = .required },
14345 },
14346 },
14347 .{
14348 .name = "BITWISE_AND",
14349 .opcode = 16,
14350 .operands = &.{
14351 .{ .kind = .id_ref, .quantifier = .required },
14352 .{ .kind = .id_ref, .quantifier = .required },
14353 },13931 },
14354 },13932 },
14355 .{13933 .{
14356 .name = "BITWISE_OR",13934 .name = "Atan",
14357 .opcode = 17,
14358 .operands = &.{
14359 .{ .kind = .id_ref, .quantifier = .required },
14360 .{ .kind = .id_ref, .quantifier = .required },
14361 },
14362 },
14363 .{
14364 .name = "BITWISE_XOR",
14365 .opcode = 18,13935 .opcode = 18,
14366 .operands = &.{13936 .operands = &.{
14367 .{ .kind = .id_ref, .quantifier = .required },13937 .{ .kind = .id_ref, .quantifier = .required },
14368 .{ .kind = .id_ref, .quantifier = .required },
14369 },13938 },
14370 },13939 },
14371 .{13940 .{
14372 .name = "INTDIV",13941 .name = "Sinh",
14373 .opcode = 19,13942 .opcode = 19,
14374 .operands = &.{13943 .operands = &.{
14375 .{ .kind = .id_ref, .quantifier = .required },13944 .{ .kind = .id_ref, .quantifier = .required },
14376 .{ .kind = .id_ref, .quantifier = .required },
14377 },13945 },
14378 },13946 },
14379 .{13947 .{
14380 .name = "LOGICAL_AND",13948 .name = "Cosh",
14381 .opcode = 20,13949 .opcode = 20,
14382 .operands = &.{13950 .operands = &.{
14383 .{ .kind = .id_ref, .quantifier = .required },13951 .{ .kind = .id_ref, .quantifier = .required },
14384 .{ .kind = .id_ref, .quantifier = .required },
14385 },13952 },
14386 },13953 },
14387 .{13954 .{
14388 .name = "LOGICAL_LEFT_SHIFT",13955 .name = "Tanh",
14389 .opcode = 21,13956 .opcode = 21,
14390 .operands = &.{13957 .operands = &.{
14391 .{ .kind = .id_ref, .quantifier = .required },13958 .{ .kind = .id_ref, .quantifier = .required },
14392 .{ .kind = .id_ref, .quantifier = .required },
14393 },13959 },
14394 },13960 },
14395 .{13961 .{
14396 .name = "LOGICAL_RIGHT_SHIFT",13962 .name = "Asinh",
14397 .opcode = 22,13963 .opcode = 22,
14398 .operands = &.{13964 .operands = &.{
14399 .{ .kind = .id_ref, .quantifier = .required },13965 .{ .kind = .id_ref, .quantifier = .required },
14400 .{ .kind = .id_ref, .quantifier = .required },
14401 },13966 },
14402 },13967 },
14403 .{13968 .{
14404 .name = "LOGICAL_OR",13969 .name = "Acosh",
14405 .opcode = 23,13970 .opcode = 23,
14406 .operands = &.{13971 .operands = &.{
14407 .{ .kind = .id_ref, .quantifier = .required },13972 .{ .kind = .id_ref, .quantifier = .required },
14408 .{ .kind = .id_ref, .quantifier = .required },
14409 },13973 },
14410 },13974 },
14411 .{13975 .{
14412 .name = "LOGICAL_XOR",13976 .name = "Atanh",
14413 .opcode = 24,13977 .opcode = 24,
14414 .operands = &.{13978 .operands = &.{
14415 .{ .kind = .id_ref, .quantifier = .required },13979 .{ .kind = .id_ref, .quantifier = .required },
14416 .{ .kind = .id_ref, .quantifier = .required },
14417 },13980 },
14418 },13981 },
14419 .{13982 .{
14420 .name = "MAXIMUM",13983 .name = "Atan2",
14421 .opcode = 25,13984 .opcode = 25,
14422 .operands = &.{13985 .operands = &.{
14423 .{ .kind = .id_ref, .quantifier = .required },13986 .{ .kind = .id_ref, .quantifier = .required },
14424 .{ .kind = .id_ref, .quantifier = .required },13987 .{ .kind = .id_ref, .quantifier = .required },
14425 .{ .kind = .id_ref, .quantifier = .required },
14426 },13988 },
14427 },13989 },
14428 .{13990 .{
14429 .name = "MINIMUM",13991 .name = "Pow",
14430 .opcode = 26,13992 .opcode = 26,
14431 .operands = &.{13993 .operands = &.{
14432 .{ .kind = .id_ref, .quantifier = .required },13994 .{ .kind = .id_ref, .quantifier = .required },
14433 .{ .kind = .id_ref, .quantifier = .required },13995 .{ .kind = .id_ref, .quantifier = .required },
14434 .{ .kind = .id_ref, .quantifier = .required },
14435 },13996 },
14436 },13997 },
14437 .{13998 .{
14438 .name = "MUL",13999 .name = "Exp",
14439 .opcode = 27,14000 .opcode = 27,
14440 .operands = &.{14001 .operands = &.{
14441 .{ .kind = .id_ref, .quantifier = .required },14002 .{ .kind = .id_ref, .quantifier = .required },
14442 .{ .kind = .id_ref, .quantifier = .required },
14443 .{ .kind = .id_ref, .quantifier = .required },
14444 },14003 },
14445 },14004 },
14446 .{14005 .{
14447 .name = "POW",14006 .name = "Log",
14448 .opcode = 28,14007 .opcode = 28,
14449 .operands = &.{14008 .operands = &.{
14450 .{ .kind = .id_ref, .quantifier = .required },14009 .{ .kind = .id_ref, .quantifier = .required },
14451 .{ .kind = .id_ref, .quantifier = .required },
14452 },14010 },
14453 },14011 },
14454 .{14012 .{
14455 .name = "SUB",14013 .name = "Exp2",
14456 .opcode = 29,14014 .opcode = 29,
14457 .operands = &.{14015 .operands = &.{
14458 .{ .kind = .id_ref, .quantifier = .required },14016 .{ .kind = .id_ref, .quantifier = .required },
14459 .{ .kind = .id_ref, .quantifier = .required },
14460 },14017 },
14461 },14018 },
14462 .{14019 .{
14463 .name = "TABLE",14020 .name = "Log2",
14464 .opcode = 30,14021 .opcode = 30,
14465 .operands = &.{14022 .operands = &.{
14466 .{ .kind = .id_ref, .quantifier = .required },14023 .{ .kind = .id_ref, .quantifier = .required },
14467 .{ .kind = .id_ref, .quantifier = .required },
14468 },14024 },
14469 },14025 },
14470 .{14026 .{
14471 .name = "ABS",14027 .name = "Sqrt",
14472 .opcode = 31,14028 .opcode = 31,
14473 .operands = &.{14029 .operands = &.{
14474 .{ .kind = .id_ref, .quantifier = .required },14030 .{ .kind = .id_ref, .quantifier = .required },
14475 },14031 },
14476 },14032 },
14477 .{14033 .{
14478 .name = "BITWISE_NOT",14034 .name = "InverseSqrt",
14479 .opcode = 32,14035 .opcode = 32,
14480 .operands = &.{14036 .operands = &.{
14481 .{ .kind = .id_ref, .quantifier = .required },14037 .{ .kind = .id_ref, .quantifier = .required },
14482 },14038 },
14483 },14039 },
14484 .{14040 .{
14485 .name = "CEIL",14041 .name = "Determinant",
14486 .opcode = 33,14042 .opcode = 33,
14487 .operands = &.{14043 .operands = &.{
14488 .{ .kind = .id_ref, .quantifier = .required },14044 .{ .kind = .id_ref, .quantifier = .required },
14489 },14045 },
14490 },14046 },
14491 .{14047 .{
14492 .name = "CLZ",14048 .name = "MatrixInverse",
14493 .opcode = 34,14049 .opcode = 34,
14494 .operands = &.{14050 .operands = &.{
14495 .{ .kind = .id_ref, .quantifier = .required },14051 .{ .kind = .id_ref, .quantifier = .required },
14496 },14052 },
14497 },14053 },
14498 .{14054 .{
14499 .name = "COS",14055 .name = "Modf",
14500 .opcode = 35,14056 .opcode = 35,
14501 .operands = &.{14057 .operands = &.{
14502 .{ .kind = .id_ref, .quantifier = .required },14058 .{ .kind = .id_ref, .quantifier = .required },
14059 .{ .kind = .id_ref, .quantifier = .required },
14503 },14060 },
14504 },14061 },
14505 .{14062 .{
14506 .name = "EXP",14063 .name = "ModfStruct",
14507 .opcode = 36,14064 .opcode = 36,
14508 .operands = &.{14065 .operands = &.{
14509 .{ .kind = .id_ref, .quantifier = .required },14066 .{ .kind = .id_ref, .quantifier = .required },
14510 },14067 },
14511 },14068 },
14512 .{14069 .{
14513 .name = "FLOOR",14070 .name = "FMin",
14514 .opcode = 37,14071 .opcode = 37,
14515 .operands = &.{14072 .operands = &.{
14516 .{ .kind = .id_ref, .quantifier = .required },14073 .{ .kind = .id_ref, .quantifier = .required },
14074 .{ .kind = .id_ref, .quantifier = .required },
14517 },14075 },
14518 },14076 },
14519 .{14077 .{
14520 .name = "LOG",14078 .name = "UMin",
14521 .opcode = 38,14079 .opcode = 38,
14522 .operands = &.{14080 .operands = &.{
14523 .{ .kind = .id_ref, .quantifier = .required },14081 .{ .kind = .id_ref, .quantifier = .required },
14082 .{ .kind = .id_ref, .quantifier = .required },
14524 },14083 },
14525 },14084 },
14526 .{14085 .{
14527 .name = "LOGICAL_NOT",14086 .name = "SMin",
14528 .opcode = 39,14087 .opcode = 39,
14529 .operands = &.{14088 .operands = &.{
14530 .{ .kind = .id_ref, .quantifier = .required },14089 .{ .kind = .id_ref, .quantifier = .required },
14090 .{ .kind = .id_ref, .quantifier = .required },
14531 },14091 },
14532 },14092 },
14533 .{14093 .{
14534 .name = "NEGATE",14094 .name = "FMax",
14535 .opcode = 40,14095 .opcode = 40,
14536 .operands = &.{14096 .operands = &.{
14537 .{ .kind = .id_ref, .quantifier = .required },14097 .{ .kind = .id_ref, .quantifier = .required },
14538 .{ .kind = .id_ref, .quantifier = .required },14098 .{ .kind = .id_ref, .quantifier = .required },
14539 .{ .kind = .id_ref, .quantifier = .required },
14540 },14099 },
14541 },14100 },
14542 .{14101 .{
14543 .name = "RECIPROCAL",14102 .name = "UMax",
14544 .opcode = 41,14103 .opcode = 41,
14545 .operands = &.{14104 .operands = &.{
14546 .{ .kind = .id_ref, .quantifier = .required },14105 .{ .kind = .id_ref, .quantifier = .required },
14106 .{ .kind = .id_ref, .quantifier = .required },
14547 },14107 },
14548 },14108 },
14549 .{14109 .{
14550 .name = "RSQRT",14110 .name = "SMax",
14551 .opcode = 42,14111 .opcode = 42,
14552 .operands = &.{14112 .operands = &.{
14553 .{ .kind = .id_ref, .quantifier = .required },14113 .{ .kind = .id_ref, .quantifier = .required },
14114 .{ .kind = .id_ref, .quantifier = .required },
14554 },14115 },
14555 },14116 },
14556 .{14117 .{
14557 .name = "SIN",14118 .name = "FClamp",
14558 .opcode = 43,14119 .opcode = 43,
14559 .operands = &.{14120 .operands = &.{
14560 .{ .kind = .id_ref, .quantifier = .required },14121 .{ .kind = .id_ref, .quantifier = .required },
14122 .{ .kind = .id_ref, .quantifier = .required },
14123 .{ .kind = .id_ref, .quantifier = .required },
14561 },14124 },
14562 },14125 },
14563 .{14126 .{
14564 .name = "SELECT",14127 .name = "UClamp",
14565 .opcode = 44,14128 .opcode = 44,
14566 .operands = &.{14129 .operands = &.{
14567 .{ .kind = .id_ref, .quantifier = .required },14130 .{ .kind = .id_ref, .quantifier = .required },
...@@ -14570,31 +14133,34 @@ pub const InstructionSet = enum {...@@ -14570,31 +14133,34 @@ pub const InstructionSet = enum {
14570 },14133 },
14571 },14134 },
14572 .{14135 .{
14573 .name = "EQUAL",14136 .name = "SClamp",
14574 .opcode = 45,14137 .opcode = 45,
14575 .operands = &.{14138 .operands = &.{
14576 .{ .kind = .id_ref, .quantifier = .required },14139 .{ .kind = .id_ref, .quantifier = .required },
14577 .{ .kind = .id_ref, .quantifier = .required },14140 .{ .kind = .id_ref, .quantifier = .required },
14141 .{ .kind = .id_ref, .quantifier = .required },
14578 },14142 },
14579 },14143 },
14580 .{14144 .{
14581 .name = "GREATER",14145 .name = "FMix",
14582 .opcode = 46,14146 .opcode = 46,
14583 .operands = &.{14147 .operands = &.{
14584 .{ .kind = .id_ref, .quantifier = .required },14148 .{ .kind = .id_ref, .quantifier = .required },
14585 .{ .kind = .id_ref, .quantifier = .required },14149 .{ .kind = .id_ref, .quantifier = .required },
14150 .{ .kind = .id_ref, .quantifier = .required },
14586 },14151 },
14587 },14152 },
14588 .{14153 .{
14589 .name = "GREATER_EQUAL",14154 .name = "IMix",
14590 .opcode = 47,14155 .opcode = 47,
14591 .operands = &.{14156 .operands = &.{
14592 .{ .kind = .id_ref, .quantifier = .required },14157 .{ .kind = .id_ref, .quantifier = .required },
14593 .{ .kind = .id_ref, .quantifier = .required },14158 .{ .kind = .id_ref, .quantifier = .required },
14159 .{ .kind = .id_ref, .quantifier = .required },
14594 },14160 },
14595 },14161 },
14596 .{14162 .{
14597 .name = "REDUCE_ALL",14163 .name = "Step",
14598 .opcode = 48,14164 .opcode = 48,
14599 .operands = &.{14165 .operands = &.{
14600 .{ .kind = .id_ref, .quantifier = .required },14166 .{ .kind = .id_ref, .quantifier = .required },
...@@ -14602,15 +14168,16 @@ pub const InstructionSet = enum {...@@ -14602,15 +14168,16 @@ pub const InstructionSet = enum {
14602 },14168 },
14603 },14169 },
14604 .{14170 .{
14605 .name = "REDUCE_ANY",14171 .name = "SmoothStep",
14606 .opcode = 49,14172 .opcode = 49,
14607 .operands = &.{14173 .operands = &.{
14608 .{ .kind = .id_ref, .quantifier = .required },14174 .{ .kind = .id_ref, .quantifier = .required },
14609 .{ .kind = .id_ref, .quantifier = .required },14175 .{ .kind = .id_ref, .quantifier = .required },
14176 .{ .kind = .id_ref, .quantifier = .required },
14610 },14177 },
14611 },14178 },
14612 .{14179 .{
14613 .name = "REDUCE_MAX",14180 .name = "Fma",
14614 .opcode = 50,14181 .opcode = 50,
14615 .operands = &.{14182 .operands = &.{
14616 .{ .kind = .id_ref, .quantifier = .required },14183 .{ .kind = .id_ref, .quantifier = .required },
...@@ -14619,24 +14186,22 @@ pub const InstructionSet = enum {...@@ -14619,24 +14186,22 @@ pub const InstructionSet = enum {
14619 },14186 },
14620 },14187 },
14621 .{14188 .{
14622 .name = "REDUCE_MIN",14189 .name = "Frexp",
14623 .opcode = 51,14190 .opcode = 51,
14624 .operands = &.{14191 .operands = &.{
14625 .{ .kind = .id_ref, .quantifier = .required },14192 .{ .kind = .id_ref, .quantifier = .required },
14626 .{ .kind = .id_ref, .quantifier = .required },14193 .{ .kind = .id_ref, .quantifier = .required },
14627 .{ .kind = .id_ref, .quantifier = .required },
14628 },14194 },
14629 },14195 },
14630 .{14196 .{
14631 .name = "REDUCE_PRODUCT",14197 .name = "FrexpStruct",
14632 .opcode = 52,14198 .opcode = 52,
14633 .operands = &.{14199 .operands = &.{
14634 .{ .kind = .id_ref, .quantifier = .required },14200 .{ .kind = .id_ref, .quantifier = .required },
14635 .{ .kind = .id_ref, .quantifier = .required },
14636 },14201 },
14637 },14202 },
14638 .{14203 .{
14639 .name = "REDUCE_SUM",14204 .name = "Ldexp",
14640 .opcode = 53,14205 .opcode = 53,
14641 .operands = &.{14206 .operands = &.{
14642 .{ .kind = .id_ref, .quantifier = .required },14207 .{ .kind = .id_ref, .quantifier = .required },
...@@ -14644,3368 +14209,1112 @@ pub const InstructionSet = enum {...@@ -14644,3368 +14209,1112 @@ pub const InstructionSet = enum {
14644 },14209 },
14645 },14210 },
14646 .{14211 .{
14647 .name = "CONCAT",14212 .name = "PackSnorm4x8",
14648 .opcode = 54,14213 .opcode = 54,
14649 .operands = &.{14214 .operands = &.{
14650 .{ .kind = .id_ref, .quantifier = .required },14215 .{ .kind = .id_ref, .quantifier = .required },
14651 .{ .kind = .id_ref, .quantifier = .variadic },
14652 },14216 },
14653 },14217 },
14654 .{14218 .{
14655 .name = "PAD",14219 .name = "PackUnorm4x8",
14656 .opcode = 55,14220 .opcode = 55,
14657 .operands = &.{14221 .operands = &.{
14658 .{ .kind = .id_ref, .quantifier = .required },14222 .{ .kind = .id_ref, .quantifier = .required },
14659 .{ .kind = .id_ref, .quantifier = .required },
14660 .{ .kind = .id_ref, .quantifier = .required },
14661 },14223 },
14662 },14224 },
14663 .{14225 .{
14664 .name = "RESHAPE",14226 .name = "PackSnorm2x16",
14665 .opcode = 56,14227 .opcode = 56,
14666 .operands = &.{14228 .operands = &.{
14667 .{ .kind = .id_ref, .quantifier = .required },14229 .{ .kind = .id_ref, .quantifier = .required },
14668 .{ .kind = .id_ref, .quantifier = .required },
14669 },14230 },
14670 },14231 },
14671 .{14232 .{
14672 .name = "REVERSE",14233 .name = "PackUnorm2x16",
14673 .opcode = 57,14234 .opcode = 57,
14674 .operands = &.{14235 .operands = &.{
14675 .{ .kind = .id_ref, .quantifier = .required },14236 .{ .kind = .id_ref, .quantifier = .required },
14676 .{ .kind = .id_ref, .quantifier = .required },
14677 },14237 },
14678 },14238 },
14679 .{14239 .{
14680 .name = "SLICE",14240 .name = "PackHalf2x16",
14681 .opcode = 58,14241 .opcode = 58,
14682 .operands = &.{14242 .operands = &.{
14683 .{ .kind = .id_ref, .quantifier = .required },14243 .{ .kind = .id_ref, .quantifier = .required },
14684 .{ .kind = .id_ref, .quantifier = .required },
14685 .{ .kind = .id_ref, .quantifier = .required },
14686 },14244 },
14687 },14245 },
14688 .{14246 .{
14689 .name = "TILE",14247 .name = "PackDouble2x32",
14690 .opcode = 59,14248 .opcode = 59,
14691 .operands = &.{14249 .operands = &.{
14692 .{ .kind = .id_ref, .quantifier = .required },14250 .{ .kind = .id_ref, .quantifier = .required },
14693 .{ .kind = .id_ref, .quantifier = .required },
14694 },14251 },
14695 },14252 },
14696 .{14253 .{
14697 .name = "TRANSPOSE",14254 .name = "UnpackSnorm2x16",
14698 .opcode = 60,14255 .opcode = 60,
14699 .operands = &.{14256 .operands = &.{
14700 .{ .kind = .id_ref, .quantifier = .required },14257 .{ .kind = .id_ref, .quantifier = .required },
14701 .{ .kind = .id_ref, .quantifier = .required },
14702 },14258 },
14703 },14259 },
14704 .{14260 .{
14705 .name = "GATHER",14261 .name = "UnpackUnorm2x16",
14706 .opcode = 61,14262 .opcode = 61,
14707 .operands = &.{14263 .operands = &.{
14708 .{ .kind = .id_ref, .quantifier = .required },14264 .{ .kind = .id_ref, .quantifier = .required },
14709 .{ .kind = .id_ref, .quantifier = .required },
14710 },14265 },
14711 },14266 },
14712 .{14267 .{
14713 .name = "SCATTER",14268 .name = "UnpackHalf2x16",
14714 .opcode = 62,14269 .opcode = 62,
14715 .operands = &.{14270 .operands = &.{
14716 .{ .kind = .id_ref, .quantifier = .required },14271 .{ .kind = .id_ref, .quantifier = .required },
14717 .{ .kind = .id_ref, .quantifier = .required },
14718 .{ .kind = .id_ref, .quantifier = .required },
14719 },14272 },
14720 },14273 },
14721 .{14274 .{
14722 .name = "RESIZE",14275 .name = "UnpackSnorm4x8",
14723 .opcode = 63,14276 .opcode = 63,
14724 .operands = &.{14277 .operands = &.{
14725 .{ .kind = .id_ref, .quantifier = .required },14278 .{ .kind = .id_ref, .quantifier = .required },
14726 .{ .kind = .id_ref, .quantifier = .required },
14727 .{ .kind = .id_ref, .quantifier = .required },
14728 .{ .kind = .id_ref, .quantifier = .required },
14729 .{ .kind = .id_ref, .quantifier = .required },
14730 },14279 },
14731 },14280 },
14732 .{14281 .{
14733 .name = "CAST",14282 .name = "UnpackUnorm4x8",
14734 .opcode = 64,14283 .opcode = 64,
14735 .operands = &.{14284 .operands = &.{
14736 .{ .kind = .id_ref, .quantifier = .required },14285 .{ .kind = .id_ref, .quantifier = .required },
14737 },14286 },
14738 },14287 },
14739 .{14288 .{
14740 .name = "RESCALE",14289 .name = "UnpackDouble2x32",
14741 .opcode = 65,14290 .opcode = 65,
14742 .operands = &.{14291 .operands = &.{
14743 .{ .kind = .id_ref, .quantifier = .required },14292 .{ .kind = .id_ref, .quantifier = .required },
14293 },
14294 },
14295 .{
14296 .name = "Length",
14297 .opcode = 66,
14298 .operands = &.{
14744 .{ .kind = .id_ref, .quantifier = .required },14299 .{ .kind = .id_ref, .quantifier = .required },
14300 },
14301 },
14302 .{
14303 .name = "Distance",
14304 .opcode = 67,
14305 .operands = &.{
14745 .{ .kind = .id_ref, .quantifier = .required },14306 .{ .kind = .id_ref, .quantifier = .required },
14746 .{ .kind = .id_ref, .quantifier = .required },14307 .{ .kind = .id_ref, .quantifier = .required },
14747 .{ .kind = .id_ref, .quantifier = .required },14308 },
14748 .{ .kind = .id_ref, .quantifier = .required },14309 },
14749 .{ .kind = .id_ref, .quantifier = .required },14310 .{
14750 .{ .kind = .id_ref, .quantifier = .required },14311 .name = "Cross",
14312 .opcode = 68,
14313 .operands = &.{
14751 .{ .kind = .id_ref, .quantifier = .required },14314 .{ .kind = .id_ref, .quantifier = .required },
14752 .{ .kind = .id_ref, .quantifier = .required },14315 .{ .kind = .id_ref, .quantifier = .required },
14753 },14316 },
14754 },14317 },
14755 },
14756 .@"NonSemantic.VkspReflection" => &.{
14757 .{14318 .{
14758 .name = "Configuration",14319 .name = "Normalize",
14759 .opcode = 1,14320 .opcode = 69,
14760 .operands = &.{14321 .operands = &.{
14761 .{ .kind = .id_ref, .quantifier = .required },14322 .{ .kind = .id_ref, .quantifier = .required },
14323 },
14324 },
14325 .{
14326 .name = "FaceForward",
14327 .opcode = 70,
14328 .operands = &.{
14762 .{ .kind = .id_ref, .quantifier = .required },14329 .{ .kind = .id_ref, .quantifier = .required },
14763 .{ .kind = .id_ref, .quantifier = .required },14330 .{ .kind = .id_ref, .quantifier = .required },
14764 .{ .kind = .id_ref, .quantifier = .required },14331 .{ .kind = .id_ref, .quantifier = .required },
14332 },
14333 },
14334 .{
14335 .name = "Reflect",
14336 .opcode = 71,
14337 .operands = &.{
14765 .{ .kind = .id_ref, .quantifier = .required },14338 .{ .kind = .id_ref, .quantifier = .required },
14766 .{ .kind = .id_ref, .quantifier = .required },14339 .{ .kind = .id_ref, .quantifier = .required },
14340 },
14341 },
14342 .{
14343 .name = "Refract",
14344 .opcode = 72,
14345 .operands = &.{
14767 .{ .kind = .id_ref, .quantifier = .required },14346 .{ .kind = .id_ref, .quantifier = .required },
14768 .{ .kind = .id_ref, .quantifier = .required },14347 .{ .kind = .id_ref, .quantifier = .required },
14769 .{ .kind = .id_ref, .quantifier = .required },14348 .{ .kind = .id_ref, .quantifier = .required },
14770 },14349 },
14771 },14350 },
14772 .{14351 .{
14773 .name = "StartCounter",14352 .name = "FindILsb",
14774 .opcode = 2,14353 .opcode = 73,
14775 .operands = &.{14354 .operands = &.{
14776 .{ .kind = .id_ref, .quantifier = .required },14355 .{ .kind = .id_ref, .quantifier = .required },
14777 },14356 },
14778 },14357 },
14779 .{14358 .{
14780 .name = "StopCounter",14359 .name = "FindSMsb",
14781 .opcode = 3,14360 .opcode = 74,
14782 .operands = &.{14361 .operands = &.{
14783 .{ .kind = .id_ref, .quantifier = .required },14362 .{ .kind = .id_ref, .quantifier = .required },
14784 },14363 },
14785 },14364 },
14786 .{14365 .{
14787 .name = "PushConstants",14366 .name = "FindUMsb",
14788 .opcode = 4,14367 .opcode = 75,
14789 .operands = &.{14368 .operands = &.{
14790 .{ .kind = .id_ref, .quantifier = .required },14369 .{ .kind = .id_ref, .quantifier = .required },
14370 },
14371 },
14372 .{
14373 .name = "InterpolateAtCentroid",
14374 .opcode = 76,
14375 .operands = &.{
14791 .{ .kind = .id_ref, .quantifier = .required },14376 .{ .kind = .id_ref, .quantifier = .required },
14377 },
14378 },
14379 .{
14380 .name = "InterpolateAtSample",
14381 .opcode = 77,
14382 .operands = &.{
14792 .{ .kind = .id_ref, .quantifier = .required },14383 .{ .kind = .id_ref, .quantifier = .required },
14793 .{ .kind = .id_ref, .quantifier = .required },14384 .{ .kind = .id_ref, .quantifier = .required },
14794 },14385 },
14795 },14386 },
14796 .{14387 .{
14797 .name = "SpecializationMapEntry",14388 .name = "InterpolateAtOffset",
14798 .opcode = 5,14389 .opcode = 78,
14799 .operands = &.{14390 .operands = &.{
14800 .{ .kind = .id_ref, .quantifier = .required },14391 .{ .kind = .id_ref, .quantifier = .required },
14801 .{ .kind = .id_ref, .quantifier = .required },14392 .{ .kind = .id_ref, .quantifier = .required },
14802 .{ .kind = .id_ref, .quantifier = .required },
14803 },14393 },
14804 },14394 },
14805 .{14395 .{
14806 .name = "DescriptorSetBuffer",14396 .name = "NMin",
14807 .opcode = 6,14397 .opcode = 79,
14808 .operands = &.{14398 .operands = &.{
14809 .{ .kind = .id_ref, .quantifier = .required },14399 .{ .kind = .id_ref, .quantifier = .required },
14810 .{ .kind = .id_ref, .quantifier = .required },14400 .{ .kind = .id_ref, .quantifier = .required },
14401 },
14402 },
14403 .{
14404 .name = "NMax",
14405 .opcode = 80,
14406 .operands = &.{
14811 .{ .kind = .id_ref, .quantifier = .required },14407 .{ .kind = .id_ref, .quantifier = .required },
14812 .{ .kind = .id_ref, .quantifier = .required },14408 .{ .kind = .id_ref, .quantifier = .required },
14813 .{ .kind = .id_ref, .quantifier = .required },14409 },
14814 .{ .kind = .id_ref, .quantifier = .required },14410 },
14815 .{ .kind = .id_ref, .quantifier = .required },14411 .{
14816 .{ .kind = .id_ref, .quantifier = .required },14412 .name = "NClamp",
14817 .{ .kind = .id_ref, .quantifier = .required },14413 .opcode = 81,
14818 .{ .kind = .id_ref, .quantifier = .required },14414 .operands = &.{
14819 .{ .kind = .id_ref, .quantifier = .required },
14820 .{ .kind = .id_ref, .quantifier = .required },
14821 .{ .kind = .id_ref, .quantifier = .required },
14822 .{ .kind = .id_ref, .quantifier = .required },
14823 .{ .kind = .id_ref, .quantifier = .required },
14824 },
14825 },
14826 .{
14827 .name = "DescriptorSetImage",
14828 .opcode = 7,
14829 .operands = &.{
14830 .{ .kind = .id_ref, .quantifier = .required },
14831 .{ .kind = .id_ref, .quantifier = .required },
14832 .{ .kind = .id_ref, .quantifier = .required },
14833 .{ .kind = .id_ref, .quantifier = .required },
14834 .{ .kind = .id_ref, .quantifier = .required },
14835 .{ .kind = .id_ref, .quantifier = .required },
14836 .{ .kind = .id_ref, .quantifier = .required },
14837 .{ .kind = .id_ref, .quantifier = .required },
14838 .{ .kind = .id_ref, .quantifier = .required },
14839 .{ .kind = .id_ref, .quantifier = .required },
14840 .{ .kind = .id_ref, .quantifier = .required },
14841 .{ .kind = .id_ref, .quantifier = .required },
14842 .{ .kind = .id_ref, .quantifier = .required },
14843 .{ .kind = .id_ref, .quantifier = .required },
14844 .{ .kind = .id_ref, .quantifier = .required },
14845 .{ .kind = .id_ref, .quantifier = .required },
14846 .{ .kind = .id_ref, .quantifier = .required },
14847 .{ .kind = .id_ref, .quantifier = .required },
14848 .{ .kind = .id_ref, .quantifier = .required },
14849 .{ .kind = .id_ref, .quantifier = .required },
14850 .{ .kind = .id_ref, .quantifier = .required },
14851 .{ .kind = .id_ref, .quantifier = .required },
14852 .{ .kind = .id_ref, .quantifier = .required },
14853 .{ .kind = .id_ref, .quantifier = .required },
14854 .{ .kind = .id_ref, .quantifier = .required },
14855 .{ .kind = .id_ref, .quantifier = .required },
14856 .{ .kind = .id_ref, .quantifier = .required },
14857 .{ .kind = .id_ref, .quantifier = .required },
14858 .{ .kind = .id_ref, .quantifier = .required },
14859 .{ .kind = .id_ref, .quantifier = .required },
14860 .{ .kind = .id_ref, .quantifier = .required },
14861 .{ .kind = .id_ref, .quantifier = .required },
14862 .{ .kind = .id_ref, .quantifier = .required },
14863 },
14864 },
14865 .{
14866 .name = "DescriptorSetSampler",
14867 .opcode = 8,
14868 .operands = &.{
14869 .{ .kind = .id_ref, .quantifier = .required },
14870 .{ .kind = .id_ref, .quantifier = .required },
14871 .{ .kind = .id_ref, .quantifier = .required },
14872 .{ .kind = .id_ref, .quantifier = .required },
14873 .{ .kind = .id_ref, .quantifier = .required },
14874 .{ .kind = .id_ref, .quantifier = .required },
14875 .{ .kind = .id_ref, .quantifier = .required },
14876 .{ .kind = .id_ref, .quantifier = .required },
14877 .{ .kind = .id_ref, .quantifier = .required },
14878 .{ .kind = .id_ref, .quantifier = .required },
14879 .{ .kind = .id_ref, .quantifier = .required },
14880 .{ .kind = .id_ref, .quantifier = .required },
14881 .{ .kind = .id_ref, .quantifier = .required },
14882 .{ .kind = .id_ref, .quantifier = .required },
14883 .{ .kind = .id_ref, .quantifier = .required },
14884 .{ .kind = .id_ref, .quantifier = .required },
14885 .{ .kind = .id_ref, .quantifier = .required },14415 .{ .kind = .id_ref, .quantifier = .required },
14886 .{ .kind = .id_ref, .quantifier = .required },14416 .{ .kind = .id_ref, .quantifier = .required },
14887 .{ .kind = .id_ref, .quantifier = .required },14417 .{ .kind = .id_ref, .quantifier = .required },
14888 },14418 },
14889 },14419 },
14890 },14420 },
14891 .SPV_AMD_shader_explicit_vertex_parameter => &.{14421 .@"OpenCL.std" => &.{
14892 .{14422 .{
14893 .name = "InterpolateAtVertexAMD",14423 .name = "acos",
14894 .opcode = 1,14424 .opcode = 0,
14895 .operands = &.{14425 .operands = &.{
14896 .{ .kind = .id_ref, .quantifier = .required },14426 .{ .kind = .id_ref, .quantifier = .required },
14897 .{ .kind = .id_ref, .quantifier = .required },
14898 },14427 },
14899 },14428 },
14900 },
14901 .DebugInfo => &.{
14902 .{
14903 .name = "DebugInfoNone",
14904 .opcode = 0,
14905 .operands = &.{},
14906 },
14907 .{14429 .{
14908 .name = "DebugCompilationUnit",14430 .name = "acosh",
14909 .opcode = 1,14431 .opcode = 1,
14910 .operands = &.{14432 .operands = &.{
14911 .{ .kind = .id_ref, .quantifier = .required },14433 .{ .kind = .id_ref, .quantifier = .required },
14912 .{ .kind = .literal_integer, .quantifier = .required },
14913 .{ .kind = .literal_integer, .quantifier = .required },
14914 },14434 },
14915 },14435 },
14916 .{14436 .{
14917 .name = "DebugTypeBasic",14437 .name = "acospi",
14918 .opcode = 2,14438 .opcode = 2,
14919 .operands = &.{14439 .operands = &.{
14920 .{ .kind = .id_ref, .quantifier = .required },14440 .{ .kind = .id_ref, .quantifier = .required },
14921 .{ .kind = .id_ref, .quantifier = .required },
14922 .{ .kind = .debug_info_debug_base_type_attribute_encoding, .quantifier = .required },
14923 },14441 },
14924 },14442 },
14925 .{14443 .{
14926 .name = "DebugTypePointer",14444 .name = "asin",
14927 .opcode = 3,14445 .opcode = 3,
14928 .operands = &.{14446 .operands = &.{
14929 .{ .kind = .id_ref, .quantifier = .required },14447 .{ .kind = .id_ref, .quantifier = .required },
14930 .{ .kind = .storage_class, .quantifier = .required },
14931 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
14932 },14448 },
14933 },14449 },
14934 .{14450 .{
14935 .name = "DebugTypeQualifier",14451 .name = "asinh",
14936 .opcode = 4,14452 .opcode = 4,
14937 .operands = &.{14453 .operands = &.{
14938 .{ .kind = .id_ref, .quantifier = .required },14454 .{ .kind = .id_ref, .quantifier = .required },
14939 .{ .kind = .debug_info_debug_type_qualifier, .quantifier = .required },
14940 },14455 },
14941 },14456 },
14942 .{14457 .{
14943 .name = "DebugTypeArray",14458 .name = "asinpi",
14944 .opcode = 5,14459 .opcode = 5,
14945 .operands = &.{14460 .operands = &.{
14946 .{ .kind = .id_ref, .quantifier = .required },14461 .{ .kind = .id_ref, .quantifier = .required },
14947 .{ .kind = .id_ref, .quantifier = .variadic },
14948 },14462 },
14949 },14463 },
14950 .{14464 .{
14951 .name = "DebugTypeVector",14465 .name = "atan",
14952 .opcode = 6,14466 .opcode = 6,
14953 .operands = &.{14467 .operands = &.{
14954 .{ .kind = .id_ref, .quantifier = .required },14468 .{ .kind = .id_ref, .quantifier = .required },
14955 .{ .kind = .literal_integer, .quantifier = .required },
14956 },14469 },
14957 },14470 },
14958 .{14471 .{
14959 .name = "DebugTypedef",14472 .name = "atan2",
14960 .opcode = 7,14473 .opcode = 7,
14961 .operands = &.{14474 .operands = &.{
14962 .{ .kind = .id_ref, .quantifier = .required },14475 .{ .kind = .id_ref, .quantifier = .required },
14963 .{ .kind = .id_ref, .quantifier = .required },14476 .{ .kind = .id_ref, .quantifier = .required },
14964 .{ .kind = .id_ref, .quantifier = .required },
14965 .{ .kind = .literal_integer, .quantifier = .required },
14966 .{ .kind = .literal_integer, .quantifier = .required },
14967 .{ .kind = .id_ref, .quantifier = .required },
14968 },14477 },
14969 },14478 },
14970 .{14479 .{
14971 .name = "DebugTypeFunction",14480 .name = "atanh",
14972 .opcode = 8,14481 .opcode = 8,
14973 .operands = &.{14482 .operands = &.{
14974 .{ .kind = .id_ref, .quantifier = .required },14483 .{ .kind = .id_ref, .quantifier = .required },
14975 .{ .kind = .id_ref, .quantifier = .variadic },
14976 },14484 },
14977 },14485 },
14978 .{14486 .{
14979 .name = "DebugTypeEnum",14487 .name = "atanpi",
14980 .opcode = 9,14488 .opcode = 9,
14981 .operands = &.{14489 .operands = &.{
14982 .{ .kind = .id_ref, .quantifier = .required },14490 .{ .kind = .id_ref, .quantifier = .required },
14983 .{ .kind = .id_ref, .quantifier = .required },
14984 .{ .kind = .id_ref, .quantifier = .required },
14985 .{ .kind = .literal_integer, .quantifier = .required },
14986 .{ .kind = .literal_integer, .quantifier = .required },
14987 .{ .kind = .id_ref, .quantifier = .required },
14988 .{ .kind = .id_ref, .quantifier = .required },
14989 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
14990 .{ .kind = .pair_id_ref_id_ref, .quantifier = .variadic },
14991 },14491 },
14992 },14492 },
14993 .{14493 .{
14994 .name = "DebugTypeComposite",14494 .name = "atan2pi",
14995 .opcode = 10,14495 .opcode = 10,
14996 .operands = &.{14496 .operands = &.{
14997 .{ .kind = .id_ref, .quantifier = .required },14497 .{ .kind = .id_ref, .quantifier = .required },
14998 .{ .kind = .debug_info_debug_composite_type, .quantifier = .required },
14999 .{ .kind = .id_ref, .quantifier = .required },
15000 .{ .kind = .literal_integer, .quantifier = .required },
15001 .{ .kind = .literal_integer, .quantifier = .required },
15002 .{ .kind = .id_ref, .quantifier = .required },
15003 .{ .kind = .id_ref, .quantifier = .required },
15004 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
15005 .{ .kind = .id_ref, .quantifier = .variadic },
15006 },
15007 },
15008 .{
15009 .name = "DebugTypeMember",
15010 .opcode = 11,
15011 .operands = &.{
15012 .{ .kind = .id_ref, .quantifier = .required },
15013 .{ .kind = .id_ref, .quantifier = .required },
15014 .{ .kind = .id_ref, .quantifier = .required },
15015 .{ .kind = .literal_integer, .quantifier = .required },
15016 .{ .kind = .literal_integer, .quantifier = .required },
15017 .{ .kind = .id_ref, .quantifier = .required },
15018 .{ .kind = .id_ref, .quantifier = .required },
15019 .{ .kind = .id_ref, .quantifier = .required },
15020 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
15021 .{ .kind = .id_ref, .quantifier = .optional },
15022 },
15023 },
15024 .{
15025 .name = "DebugTypeInheritance",
15026 .opcode = 12,
15027 .operands = &.{
15028 .{ .kind = .id_ref, .quantifier = .required },
15029 .{ .kind = .id_ref, .quantifier = .required },
15030 .{ .kind = .id_ref, .quantifier = .required },
15031 .{ .kind = .id_ref, .quantifier = .required },
15032 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
15033 },
15034 },
15035 .{
15036 .name = "DebugTypePtrToMember",
15037 .opcode = 13,
15038 .operands = &.{
15039 .{ .kind = .id_ref, .quantifier = .required },
15040 .{ .kind = .id_ref, .quantifier = .required },
15041 },
15042 },
15043 .{
15044 .name = "DebugTypeTemplate",
15045 .opcode = 14,
15046 .operands = &.{
15047 .{ .kind = .id_ref, .quantifier = .required },
15048 .{ .kind = .id_ref, .quantifier = .variadic },
15049 },
15050 },
15051 .{
15052 .name = "DebugTypeTemplateParameter",
15053 .opcode = 15,
15054 .operands = &.{
15055 .{ .kind = .id_ref, .quantifier = .required },
15056 .{ .kind = .id_ref, .quantifier = .required },
15057 .{ .kind = .id_ref, .quantifier = .required },
15058 .{ .kind = .id_ref, .quantifier = .required },
15059 .{ .kind = .literal_integer, .quantifier = .required },
15060 .{ .kind = .literal_integer, .quantifier = .required },
15061 },
15062 },
15063 .{
15064 .name = "DebugTypeTemplateTemplateParameter",
15065 .opcode = 16,
15066 .operands = &.{
15067 .{ .kind = .id_ref, .quantifier = .required },
15068 .{ .kind = .id_ref, .quantifier = .required },
15069 .{ .kind = .id_ref, .quantifier = .required },
15070 .{ .kind = .literal_integer, .quantifier = .required },
15071 .{ .kind = .literal_integer, .quantifier = .required },
15072 },
15073 },
15074 .{
15075 .name = "DebugTypeTemplateParameterPack",
15076 .opcode = 17,
15077 .operands = &.{
15078 .{ .kind = .id_ref, .quantifier = .required },
15079 .{ .kind = .id_ref, .quantifier = .required },
15080 .{ .kind = .literal_integer, .quantifier = .required },
15081 .{ .kind = .literal_integer, .quantifier = .required },
15082 .{ .kind = .id_ref, .quantifier = .variadic },
15083 },
15084 },
15085 .{
15086 .name = "DebugGlobalVariable",
15087 .opcode = 18,
15088 .operands = &.{
15089 .{ .kind = .id_ref, .quantifier = .required },
15090 .{ .kind = .id_ref, .quantifier = .required },
15091 .{ .kind = .id_ref, .quantifier = .required },
15092 .{ .kind = .literal_integer, .quantifier = .required },
15093 .{ .kind = .literal_integer, .quantifier = .required },
15094 .{ .kind = .id_ref, .quantifier = .required },
15095 .{ .kind = .id_ref, .quantifier = .required },
15096 .{ .kind = .id_ref, .quantifier = .required },
15097 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
15098 .{ .kind = .id_ref, .quantifier = .optional },
15099 },
15100 },
15101 .{
15102 .name = "DebugFunctionDeclaration",
15103 .opcode = 19,
15104 .operands = &.{
15105 .{ .kind = .id_ref, .quantifier = .required },
15106 .{ .kind = .id_ref, .quantifier = .required },
15107 .{ .kind = .id_ref, .quantifier = .required },
15108 .{ .kind = .literal_integer, .quantifier = .required },
15109 .{ .kind = .literal_integer, .quantifier = .required },
15110 .{ .kind = .id_ref, .quantifier = .required },
15111 .{ .kind = .id_ref, .quantifier = .required },
15112 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
15113 },
15114 },
15115 .{
15116 .name = "DebugFunction",
15117 .opcode = 20,
15118 .operands = &.{
15119 .{ .kind = .id_ref, .quantifier = .required },
15120 .{ .kind = .id_ref, .quantifier = .required },
15121 .{ .kind = .id_ref, .quantifier = .required },
15122 .{ .kind = .literal_integer, .quantifier = .required },
15123 .{ .kind = .literal_integer, .quantifier = .required },
15124 .{ .kind = .id_ref, .quantifier = .required },
15125 .{ .kind = .id_ref, .quantifier = .required },
15126 .{ .kind = .debug_info_debug_info_flags, .quantifier = .required },
15127 .{ .kind = .literal_integer, .quantifier = .required },
15128 .{ .kind = .id_ref, .quantifier = .required },
15129 .{ .kind = .id_ref, .quantifier = .optional },
15130 },
15131 },
15132 .{
15133 .name = "DebugLexicalBlock",
15134 .opcode = 21,
15135 .operands = &.{
15136 .{ .kind = .id_ref, .quantifier = .required },
15137 .{ .kind = .literal_integer, .quantifier = .required },
15138 .{ .kind = .literal_integer, .quantifier = .required },
15139 .{ .kind = .id_ref, .quantifier = .required },
15140 .{ .kind = .id_ref, .quantifier = .optional },
15141 },
15142 },
15143 .{
15144 .name = "DebugLexicalBlockDiscriminator",
15145 .opcode = 22,
15146 .operands = &.{
15147 .{ .kind = .id_ref, .quantifier = .required },
15148 .{ .kind = .literal_integer, .quantifier = .required },
15149 .{ .kind = .id_ref, .quantifier = .required },
15150 },
15151 },
15152 .{
15153 .name = "DebugScope",
15154 .opcode = 23,
15155 .operands = &.{
15156 .{ .kind = .id_ref, .quantifier = .required },
15157 .{ .kind = .id_ref, .quantifier = .optional },
15158 },
15159 },
15160 .{
15161 .name = "DebugNoScope",
15162 .opcode = 24,
15163 .operands = &.{},
15164 },
15165 .{
15166 .name = "DebugInlinedAt",
15167 .opcode = 25,
15168 .operands = &.{
15169 .{ .kind = .literal_integer, .quantifier = .required },
15170 .{ .kind = .id_ref, .quantifier = .required },
15171 .{ .kind = .id_ref, .quantifier = .optional },
15172 },
15173 },
15174 .{
15175 .name = "DebugLocalVariable",
15176 .opcode = 26,
15177 .operands = &.{
15178 .{ .kind = .id_ref, .quantifier = .required },
15179 .{ .kind = .id_ref, .quantifier = .required },
15180 .{ .kind = .id_ref, .quantifier = .required },
15181 .{ .kind = .literal_integer, .quantifier = .required },
15182 .{ .kind = .literal_integer, .quantifier = .required },
15183 .{ .kind = .id_ref, .quantifier = .required },
15184 .{ .kind = .literal_integer, .quantifier = .optional },
15185 },
15186 },
15187 .{
15188 .name = "DebugInlinedVariable",
15189 .opcode = 27,
15190 .operands = &.{
15191 .{ .kind = .id_ref, .quantifier = .required },
15192 .{ .kind = .id_ref, .quantifier = .required },
15193 },
15194 },
15195 .{
15196 .name = "DebugDeclare",
15197 .opcode = 28,
15198 .operands = &.{
15199 .{ .kind = .id_ref, .quantifier = .required },
15200 .{ .kind = .id_ref, .quantifier = .required },
15201 .{ .kind = .id_ref, .quantifier = .required },
15202 },
15203 },
15204 .{
15205 .name = "DebugValue",
15206 .opcode = 29,
15207 .operands = &.{
15208 .{ .kind = .id_ref, .quantifier = .required },
15209 .{ .kind = .id_ref, .quantifier = .required },
15210 .{ .kind = .id_ref, .quantifier = .variadic },
15211 },
15212 },
15213 .{
15214 .name = "DebugOperation",
15215 .opcode = 30,
15216 .operands = &.{
15217 .{ .kind = .debug_info_debug_operation, .quantifier = .required },
15218 .{ .kind = .literal_integer, .quantifier = .variadic },
15219 },
15220 },
15221 .{
15222 .name = "DebugExpression",
15223 .opcode = 31,
15224 .operands = &.{
15225 .{ .kind = .id_ref, .quantifier = .variadic },
15226 },
15227 },
15228 .{
15229 .name = "DebugMacroDef",
15230 .opcode = 32,
15231 .operands = &.{
15232 .{ .kind = .id_ref, .quantifier = .required },
15233 .{ .kind = .literal_integer, .quantifier = .required },
15234 .{ .kind = .id_ref, .quantifier = .required },
15235 .{ .kind = .id_ref, .quantifier = .optional },
15236 },
15237 },
15238 .{
15239 .name = "DebugMacroUndef",
15240 .opcode = 33,
15241 .operands = &.{
15242 .{ .kind = .id_ref, .quantifier = .required },
15243 .{ .kind = .literal_integer, .quantifier = .required },
15244 .{ .kind = .id_ref, .quantifier = .required },
15245 },
15246 },
15247 },
15248 .@"NonSemantic.DebugBreak" => &.{
15249 .{
15250 .name = "DebugBreak",
15251 .opcode = 1,
15252 .operands = &.{},
15253 },
15254 },
15255 .@"OpenCL.DebugInfo.100" => &.{
15256 .{
15257 .name = "DebugInfoNone",
15258 .opcode = 0,
15259 .operands = &.{},
15260 },
15261 .{
15262 .name = "DebugCompilationUnit",
15263 .opcode = 1,
15264 .operands = &.{
15265 .{ .kind = .literal_integer, .quantifier = .required },
15266 .{ .kind = .literal_integer, .quantifier = .required },
15267 .{ .kind = .id_ref, .quantifier = .required },
15268 .{ .kind = .source_language, .quantifier = .required },
15269 },
15270 },
15271 .{
15272 .name = "DebugTypeBasic",
15273 .opcode = 2,
15274 .operands = &.{
15275 .{ .kind = .id_ref, .quantifier = .required },
15276 .{ .kind = .id_ref, .quantifier = .required },
15277 .{ .kind = .open_cl_debug_info_100_debug_base_type_attribute_encoding, .quantifier = .required },
15278 },
15279 },
15280 .{
15281 .name = "DebugTypePointer",
15282 .opcode = 3,
15283 .operands = &.{
15284 .{ .kind = .id_ref, .quantifier = .required },
15285 .{ .kind = .storage_class, .quantifier = .required },
15286 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15287 },
15288 },
15289 .{
15290 .name = "DebugTypeQualifier",
15291 .opcode = 4,
15292 .operands = &.{
15293 .{ .kind = .id_ref, .quantifier = .required },
15294 .{ .kind = .open_cl_debug_info_100_debug_type_qualifier, .quantifier = .required },
15295 },
15296 },
15297 .{
15298 .name = "DebugTypeArray",
15299 .opcode = 5,
15300 .operands = &.{
15301 .{ .kind = .id_ref, .quantifier = .required },
15302 .{ .kind = .id_ref, .quantifier = .variadic },
15303 },
15304 },
15305 .{
15306 .name = "DebugTypeVector",
15307 .opcode = 6,
15308 .operands = &.{
15309 .{ .kind = .id_ref, .quantifier = .required },
15310 .{ .kind = .literal_integer, .quantifier = .required },
15311 },
15312 },
15313 .{
15314 .name = "DebugTypedef",
15315 .opcode = 7,
15316 .operands = &.{
15317 .{ .kind = .id_ref, .quantifier = .required },
15318 .{ .kind = .id_ref, .quantifier = .required },
15319 .{ .kind = .id_ref, .quantifier = .required },
15320 .{ .kind = .literal_integer, .quantifier = .required },
15321 .{ .kind = .literal_integer, .quantifier = .required },
15322 .{ .kind = .id_ref, .quantifier = .required },
15323 },
15324 },
15325 .{
15326 .name = "DebugTypeFunction",
15327 .opcode = 8,
15328 .operands = &.{
15329 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15330 .{ .kind = .id_ref, .quantifier = .required },
15331 .{ .kind = .id_ref, .quantifier = .variadic },
15332 },
15333 },
15334 .{
15335 .name = "DebugTypeEnum",
15336 .opcode = 9,
15337 .operands = &.{
15338 .{ .kind = .id_ref, .quantifier = .required },
15339 .{ .kind = .id_ref, .quantifier = .required },
15340 .{ .kind = .id_ref, .quantifier = .required },
15341 .{ .kind = .literal_integer, .quantifier = .required },
15342 .{ .kind = .literal_integer, .quantifier = .required },
15343 .{ .kind = .id_ref, .quantifier = .required },
15344 .{ .kind = .id_ref, .quantifier = .required },
15345 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15346 .{ .kind = .pair_id_ref_id_ref, .quantifier = .variadic },
15347 },
15348 },
15349 .{
15350 .name = "DebugTypeComposite",
15351 .opcode = 10,
15352 .operands = &.{
15353 .{ .kind = .id_ref, .quantifier = .required },
15354 .{ .kind = .open_cl_debug_info_100_debug_composite_type, .quantifier = .required },
15355 .{ .kind = .id_ref, .quantifier = .required },
15356 .{ .kind = .literal_integer, .quantifier = .required },
15357 .{ .kind = .literal_integer, .quantifier = .required },
15358 .{ .kind = .id_ref, .quantifier = .required },
15359 .{ .kind = .id_ref, .quantifier = .required },
15360 .{ .kind = .id_ref, .quantifier = .required },
15361 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15362 .{ .kind = .id_ref, .quantifier = .variadic },
15363 },
15364 },
15365 .{
15366 .name = "DebugTypeMember",
15367 .opcode = 11,
15368 .operands = &.{
15369 .{ .kind = .id_ref, .quantifier = .required },
15370 .{ .kind = .id_ref, .quantifier = .required },
15371 .{ .kind = .id_ref, .quantifier = .required },
15372 .{ .kind = .literal_integer, .quantifier = .required },
15373 .{ .kind = .literal_integer, .quantifier = .required },
15374 .{ .kind = .id_ref, .quantifier = .required },
15375 .{ .kind = .id_ref, .quantifier = .required },
15376 .{ .kind = .id_ref, .quantifier = .required },
15377 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15378 .{ .kind = .id_ref, .quantifier = .optional },
15379 },
15380 },
15381 .{
15382 .name = "DebugTypeInheritance",
15383 .opcode = 12,
15384 .operands = &.{
15385 .{ .kind = .id_ref, .quantifier = .required },
15386 .{ .kind = .id_ref, .quantifier = .required },
15387 .{ .kind = .id_ref, .quantifier = .required },
15388 .{ .kind = .id_ref, .quantifier = .required },
15389 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15390 },
15391 },
15392 .{
15393 .name = "DebugTypePtrToMember",
15394 .opcode = 13,
15395 .operands = &.{
15396 .{ .kind = .id_ref, .quantifier = .required },
15397 .{ .kind = .id_ref, .quantifier = .required },
15398 },
15399 },
15400 .{
15401 .name = "DebugTypeTemplate",
15402 .opcode = 14,
15403 .operands = &.{
15404 .{ .kind = .id_ref, .quantifier = .required },
15405 .{ .kind = .id_ref, .quantifier = .variadic },
15406 },
15407 },
15408 .{
15409 .name = "DebugTypeTemplateParameter",
15410 .opcode = 15,
15411 .operands = &.{
15412 .{ .kind = .id_ref, .quantifier = .required },
15413 .{ .kind = .id_ref, .quantifier = .required },
15414 .{ .kind = .id_ref, .quantifier = .required },
15415 .{ .kind = .id_ref, .quantifier = .required },
15416 .{ .kind = .literal_integer, .quantifier = .required },
15417 .{ .kind = .literal_integer, .quantifier = .required },
15418 },
15419 },
15420 .{
15421 .name = "DebugTypeTemplateTemplateParameter",
15422 .opcode = 16,
15423 .operands = &.{
15424 .{ .kind = .id_ref, .quantifier = .required },
15425 .{ .kind = .id_ref, .quantifier = .required },
15426 .{ .kind = .id_ref, .quantifier = .required },
15427 .{ .kind = .literal_integer, .quantifier = .required },
15428 .{ .kind = .literal_integer, .quantifier = .required },
15429 },
15430 },
15431 .{
15432 .name = "DebugTypeTemplateParameterPack",
15433 .opcode = 17,
15434 .operands = &.{
15435 .{ .kind = .id_ref, .quantifier = .required },
15436 .{ .kind = .id_ref, .quantifier = .required },
15437 .{ .kind = .literal_integer, .quantifier = .required },
15438 .{ .kind = .literal_integer, .quantifier = .required },
15439 .{ .kind = .id_ref, .quantifier = .variadic },
15440 },
15441 },
15442 .{
15443 .name = "DebugGlobalVariable",
15444 .opcode = 18,
15445 .operands = &.{
15446 .{ .kind = .id_ref, .quantifier = .required },
15447 .{ .kind = .id_ref, .quantifier = .required },
15448 .{ .kind = .id_ref, .quantifier = .required },
15449 .{ .kind = .literal_integer, .quantifier = .required },
15450 .{ .kind = .literal_integer, .quantifier = .required },
15451 .{ .kind = .id_ref, .quantifier = .required },
15452 .{ .kind = .id_ref, .quantifier = .required },
15453 .{ .kind = .id_ref, .quantifier = .required },
15454 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15455 .{ .kind = .id_ref, .quantifier = .optional },
15456 },
15457 },
15458 .{
15459 .name = "DebugFunctionDeclaration",
15460 .opcode = 19,
15461 .operands = &.{
15462 .{ .kind = .id_ref, .quantifier = .required },
15463 .{ .kind = .id_ref, .quantifier = .required },
15464 .{ .kind = .id_ref, .quantifier = .required },
15465 .{ .kind = .literal_integer, .quantifier = .required },
15466 .{ .kind = .literal_integer, .quantifier = .required },
15467 .{ .kind = .id_ref, .quantifier = .required },
15468 .{ .kind = .id_ref, .quantifier = .required },
15469 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15470 },
15471 },
15472 .{
15473 .name = "DebugFunction",
15474 .opcode = 20,
15475 .operands = &.{
15476 .{ .kind = .id_ref, .quantifier = .required },
15477 .{ .kind = .id_ref, .quantifier = .required },
15478 .{ .kind = .id_ref, .quantifier = .required },
15479 .{ .kind = .literal_integer, .quantifier = .required },
15480 .{ .kind = .literal_integer, .quantifier = .required },
15481 .{ .kind = .id_ref, .quantifier = .required },
15482 .{ .kind = .id_ref, .quantifier = .required },
15483 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15484 .{ .kind = .literal_integer, .quantifier = .required },
15485 .{ .kind = .id_ref, .quantifier = .required },
15486 .{ .kind = .id_ref, .quantifier = .optional },
15487 },
15488 },
15489 .{
15490 .name = "DebugLexicalBlock",
15491 .opcode = 21,
15492 .operands = &.{
15493 .{ .kind = .id_ref, .quantifier = .required },
15494 .{ .kind = .literal_integer, .quantifier = .required },
15495 .{ .kind = .literal_integer, .quantifier = .required },
15496 .{ .kind = .id_ref, .quantifier = .required },
15497 .{ .kind = .id_ref, .quantifier = .optional },
15498 },
15499 },
15500 .{
15501 .name = "DebugLexicalBlockDiscriminator",
15502 .opcode = 22,
15503 .operands = &.{
15504 .{ .kind = .id_ref, .quantifier = .required },
15505 .{ .kind = .literal_integer, .quantifier = .required },
15506 .{ .kind = .id_ref, .quantifier = .required },
15507 },
15508 },
15509 .{
15510 .name = "DebugScope",
15511 .opcode = 23,
15512 .operands = &.{
15513 .{ .kind = .id_ref, .quantifier = .required },
15514 .{ .kind = .id_ref, .quantifier = .optional },
15515 },
15516 },
15517 .{
15518 .name = "DebugNoScope",
15519 .opcode = 24,
15520 .operands = &.{},
15521 },
15522 .{
15523 .name = "DebugInlinedAt",
15524 .opcode = 25,
15525 .operands = &.{
15526 .{ .kind = .literal_integer, .quantifier = .required },
15527 .{ .kind = .id_ref, .quantifier = .required },
15528 .{ .kind = .id_ref, .quantifier = .optional },
15529 },
15530 },
15531 .{
15532 .name = "DebugLocalVariable",
15533 .opcode = 26,
15534 .operands = &.{
15535 .{ .kind = .id_ref, .quantifier = .required },
15536 .{ .kind = .id_ref, .quantifier = .required },
15537 .{ .kind = .id_ref, .quantifier = .required },
15538 .{ .kind = .literal_integer, .quantifier = .required },
15539 .{ .kind = .literal_integer, .quantifier = .required },
15540 .{ .kind = .id_ref, .quantifier = .required },
15541 .{ .kind = .open_cl_debug_info_100_debug_info_flags, .quantifier = .required },
15542 .{ .kind = .literal_integer, .quantifier = .optional },
15543 },
15544 },
15545 .{
15546 .name = "DebugInlinedVariable",
15547 .opcode = 27,
15548 .operands = &.{
15549 .{ .kind = .id_ref, .quantifier = .required },
15550 .{ .kind = .id_ref, .quantifier = .required },
15551 },
15552 },
15553 .{
15554 .name = "DebugDeclare",
15555 .opcode = 28,
15556 .operands = &.{
15557 .{ .kind = .id_ref, .quantifier = .required },
15558 .{ .kind = .id_ref, .quantifier = .required },
15559 .{ .kind = .id_ref, .quantifier = .required },
15560 },
15561 },
15562 .{
15563 .name = "DebugValue",
15564 .opcode = 29,
15565 .operands = &.{
15566 .{ .kind = .id_ref, .quantifier = .required },
15567 .{ .kind = .id_ref, .quantifier = .required },
15568 .{ .kind = .id_ref, .quantifier = .required },
15569 .{ .kind = .id_ref, .quantifier = .variadic },
15570 },
15571 },
15572 .{
15573 .name = "DebugOperation",
15574 .opcode = 30,
15575 .operands = &.{
15576 .{ .kind = .open_cl_debug_info_100_debug_operation, .quantifier = .required },
15577 .{ .kind = .literal_integer, .quantifier = .variadic },
15578 },
15579 },
15580 .{
15581 .name = "DebugExpression",
15582 .opcode = 31,
15583 .operands = &.{
15584 .{ .kind = .id_ref, .quantifier = .variadic },
15585 },
15586 },
15587 .{
15588 .name = "DebugMacroDef",
15589 .opcode = 32,
15590 .operands = &.{
15591 .{ .kind = .id_ref, .quantifier = .required },
15592 .{ .kind = .literal_integer, .quantifier = .required },
15593 .{ .kind = .id_ref, .quantifier = .required },
15594 .{ .kind = .id_ref, .quantifier = .optional },
15595 },
15596 },
15597 .{
15598 .name = "DebugMacroUndef",
15599 .opcode = 33,
15600 .operands = &.{
15601 .{ .kind = .id_ref, .quantifier = .required },
15602 .{ .kind = .literal_integer, .quantifier = .required },
15603 .{ .kind = .id_ref, .quantifier = .required },
15604 },
15605 },
15606 .{
15607 .name = "DebugImportedEntity",
15608 .opcode = 34,
15609 .operands = &.{
15610 .{ .kind = .id_ref, .quantifier = .required },
15611 .{ .kind = .open_cl_debug_info_100_debug_imported_entity, .quantifier = .required },
15612 .{ .kind = .id_ref, .quantifier = .required },
15613 .{ .kind = .id_ref, .quantifier = .required },
15614 .{ .kind = .literal_integer, .quantifier = .required },
15615 .{ .kind = .literal_integer, .quantifier = .required },
15616 .{ .kind = .id_ref, .quantifier = .required },
15617 },
15618 },
15619 .{
15620 .name = "DebugSource",
15621 .opcode = 35,
15622 .operands = &.{
15623 .{ .kind = .id_ref, .quantifier = .required },
15624 .{ .kind = .id_ref, .quantifier = .optional },
15625 },
15626 },
15627 .{
15628 .name = "DebugModuleINTEL",
15629 .opcode = 36,
15630 .operands = &.{
15631 .{ .kind = .id_ref, .quantifier = .required },
15632 .{ .kind = .id_ref, .quantifier = .required },
15633 .{ .kind = .id_ref, .quantifier = .required },
15634 .{ .kind = .literal_integer, .quantifier = .required },
15635 .{ .kind = .id_ref, .quantifier = .required },
15636 .{ .kind = .id_ref, .quantifier = .required },
15637 .{ .kind = .id_ref, .quantifier = .required },
15638 .{ .kind = .literal_integer, .quantifier = .required },
15639 },
15640 },
15641 },
15642 .@"NonSemantic.ClspvReflection.6" => &.{
15643 .{
15644 .name = "Kernel",
15645 .opcode = 1,
15646 .operands = &.{
15647 .{ .kind = .id_ref, .quantifier = .required },
15648 .{ .kind = .id_ref, .quantifier = .required },
15649 .{ .kind = .id_ref, .quantifier = .optional },
15650 .{ .kind = .id_ref, .quantifier = .optional },
15651 .{ .kind = .id_ref, .quantifier = .optional },
15652 },
15653 },
15654 .{
15655 .name = "ArgumentInfo",
15656 .opcode = 2,
15657 .operands = &.{
15658 .{ .kind = .id_ref, .quantifier = .required },
15659 .{ .kind = .id_ref, .quantifier = .optional },
15660 .{ .kind = .id_ref, .quantifier = .optional },
15661 .{ .kind = .id_ref, .quantifier = .optional },
15662 .{ .kind = .id_ref, .quantifier = .optional },
15663 },
15664 },
15665 .{
15666 .name = "ArgumentStorageBuffer",
15667 .opcode = 3,
15668 .operands = &.{
15669 .{ .kind = .id_ref, .quantifier = .required },
15670 .{ .kind = .id_ref, .quantifier = .required },
15671 .{ .kind = .id_ref, .quantifier = .required },
15672 .{ .kind = .id_ref, .quantifier = .required },
15673 .{ .kind = .id_ref, .quantifier = .optional },
15674 },
15675 },
15676 .{
15677 .name = "ArgumentUniform",
15678 .opcode = 4,
15679 .operands = &.{
15680 .{ .kind = .id_ref, .quantifier = .required },
15681 .{ .kind = .id_ref, .quantifier = .required },
15682 .{ .kind = .id_ref, .quantifier = .required },
15683 .{ .kind = .id_ref, .quantifier = .required },
15684 .{ .kind = .id_ref, .quantifier = .optional },
15685 },
15686 },
15687 .{
15688 .name = "ArgumentPodStorageBuffer",
15689 .opcode = 5,
15690 .operands = &.{
15691 .{ .kind = .id_ref, .quantifier = .required },
15692 .{ .kind = .id_ref, .quantifier = .required },
15693 .{ .kind = .id_ref, .quantifier = .required },
15694 .{ .kind = .id_ref, .quantifier = .required },
15695 .{ .kind = .id_ref, .quantifier = .required },
15696 .{ .kind = .id_ref, .quantifier = .required },
15697 .{ .kind = .id_ref, .quantifier = .optional },
15698 },
15699 },
15700 .{
15701 .name = "ArgumentPodUniform",
15702 .opcode = 6,
15703 .operands = &.{
15704 .{ .kind = .id_ref, .quantifier = .required },
15705 .{ .kind = .id_ref, .quantifier = .required },
15706 .{ .kind = .id_ref, .quantifier = .required },
15707 .{ .kind = .id_ref, .quantifier = .required },
15708 .{ .kind = .id_ref, .quantifier = .required },
15709 .{ .kind = .id_ref, .quantifier = .required },
15710 .{ .kind = .id_ref, .quantifier = .optional },
15711 },
15712 },
15713 .{
15714 .name = "ArgumentPodPushConstant",
15715 .opcode = 7,
15716 .operands = &.{
15717 .{ .kind = .id_ref, .quantifier = .required },
15718 .{ .kind = .id_ref, .quantifier = .required },
15719 .{ .kind = .id_ref, .quantifier = .required },
15720 .{ .kind = .id_ref, .quantifier = .required },
15721 .{ .kind = .id_ref, .quantifier = .optional },
15722 },
15723 },
15724 .{
15725 .name = "ArgumentSampledImage",
15726 .opcode = 8,
15727 .operands = &.{
15728 .{ .kind = .id_ref, .quantifier = .required },
15729 .{ .kind = .id_ref, .quantifier = .required },
15730 .{ .kind = .id_ref, .quantifier = .required },
15731 .{ .kind = .id_ref, .quantifier = .required },
15732 .{ .kind = .id_ref, .quantifier = .optional },
15733 },
15734 },
15735 .{
15736 .name = "ArgumentStorageImage",
15737 .opcode = 9,
15738 .operands = &.{
15739 .{ .kind = .id_ref, .quantifier = .required },
15740 .{ .kind = .id_ref, .quantifier = .required },
15741 .{ .kind = .id_ref, .quantifier = .required },
15742 .{ .kind = .id_ref, .quantifier = .required },
15743 .{ .kind = .id_ref, .quantifier = .optional },
15744 },
15745 },
15746 .{
15747 .name = "ArgumentSampler",
15748 .opcode = 10,
15749 .operands = &.{
15750 .{ .kind = .id_ref, .quantifier = .required },
15751 .{ .kind = .id_ref, .quantifier = .required },
15752 .{ .kind = .id_ref, .quantifier = .required },
15753 .{ .kind = .id_ref, .quantifier = .required },
15754 .{ .kind = .id_ref, .quantifier = .optional },
15755 },
15756 },
15757 .{
15758 .name = "ArgumentWorkgroup",
15759 .opcode = 11,
15760 .operands = &.{
15761 .{ .kind = .id_ref, .quantifier = .required },
15762 .{ .kind = .id_ref, .quantifier = .required },
15763 .{ .kind = .id_ref, .quantifier = .required },
15764 .{ .kind = .id_ref, .quantifier = .required },
15765 .{ .kind = .id_ref, .quantifier = .optional },
15766 },
15767 },
15768 .{
15769 .name = "SpecConstantWorkgroupSize",
15770 .opcode = 12,
15771 .operands = &.{
15772 .{ .kind = .id_ref, .quantifier = .required },
15773 .{ .kind = .id_ref, .quantifier = .required },
15774 .{ .kind = .id_ref, .quantifier = .required },
15775 },
15776 },
15777 .{
15778 .name = "SpecConstantGlobalOffset",
15779 .opcode = 13,
15780 .operands = &.{
15781 .{ .kind = .id_ref, .quantifier = .required },
15782 .{ .kind = .id_ref, .quantifier = .required },
15783 .{ .kind = .id_ref, .quantifier = .required },
15784 },
15785 },
15786 .{
15787 .name = "SpecConstantWorkDim",
15788 .opcode = 14,
15789 .operands = &.{
15790 .{ .kind = .id_ref, .quantifier = .required },
15791 },
15792 },
15793 .{
15794 .name = "PushConstantGlobalOffset",
15795 .opcode = 15,
15796 .operands = &.{
15797 .{ .kind = .id_ref, .quantifier = .required },
15798 .{ .kind = .id_ref, .quantifier = .required },
15799 },
15800 },
15801 .{
15802 .name = "PushConstantEnqueuedLocalSize",
15803 .opcode = 16,
15804 .operands = &.{
15805 .{ .kind = .id_ref, .quantifier = .required },
15806 .{ .kind = .id_ref, .quantifier = .required },
15807 },
15808 },
15809 .{
15810 .name = "PushConstantGlobalSize",
15811 .opcode = 17,
15812 .operands = &.{
15813 .{ .kind = .id_ref, .quantifier = .required },
15814 .{ .kind = .id_ref, .quantifier = .required },
15815 },
15816 },
15817 .{
15818 .name = "PushConstantRegionOffset",
15819 .opcode = 18,
15820 .operands = &.{
15821 .{ .kind = .id_ref, .quantifier = .required },
15822 .{ .kind = .id_ref, .quantifier = .required },
15823 },
15824 },
15825 .{
15826 .name = "PushConstantNumWorkgroups",
15827 .opcode = 19,
15828 .operands = &.{
15829 .{ .kind = .id_ref, .quantifier = .required },
15830 .{ .kind = .id_ref, .quantifier = .required },
15831 },
15832 },
15833 .{
15834 .name = "PushConstantRegionGroupOffset",
15835 .opcode = 20,
15836 .operands = &.{
15837 .{ .kind = .id_ref, .quantifier = .required },
15838 .{ .kind = .id_ref, .quantifier = .required },
15839 },
15840 },
15841 .{
15842 .name = "ConstantDataStorageBuffer",
15843 .opcode = 21,
15844 .operands = &.{
15845 .{ .kind = .id_ref, .quantifier = .required },
15846 .{ .kind = .id_ref, .quantifier = .required },
15847 .{ .kind = .id_ref, .quantifier = .required },
15848 },
15849 },
15850 .{
15851 .name = "ConstantDataUniform",
15852 .opcode = 22,
15853 .operands = &.{
15854 .{ .kind = .id_ref, .quantifier = .required },
15855 .{ .kind = .id_ref, .quantifier = .required },
15856 .{ .kind = .id_ref, .quantifier = .required },
15857 },
15858 },
15859 .{
15860 .name = "LiteralSampler",
15861 .opcode = 23,
15862 .operands = &.{
15863 .{ .kind = .id_ref, .quantifier = .required },
15864 .{ .kind = .id_ref, .quantifier = .required },
15865 .{ .kind = .id_ref, .quantifier = .required },
15866 },
15867 },
15868 .{
15869 .name = "PropertyRequiredWorkgroupSize",
15870 .opcode = 24,
15871 .operands = &.{
15872 .{ .kind = .id_ref, .quantifier = .required },
15873 .{ .kind = .id_ref, .quantifier = .required },
15874 .{ .kind = .id_ref, .quantifier = .required },
15875 .{ .kind = .id_ref, .quantifier = .required },
15876 },
15877 },
15878 .{
15879 .name = "SpecConstantSubgroupMaxSize",
15880 .opcode = 25,
15881 .operands = &.{
15882 .{ .kind = .id_ref, .quantifier = .required },
15883 },
15884 },
15885 .{
15886 .name = "ArgumentPointerPushConstant",
15887 .opcode = 26,
15888 .operands = &.{
15889 .{ .kind = .id_ref, .quantifier = .required },
15890 .{ .kind = .id_ref, .quantifier = .required },
15891 .{ .kind = .id_ref, .quantifier = .required },
15892 .{ .kind = .id_ref, .quantifier = .required },
15893 .{ .kind = .id_ref, .quantifier = .optional },
15894 },
15895 },
15896 .{
15897 .name = "ArgumentPointerUniform",
15898 .opcode = 27,
15899 .operands = &.{
15900 .{ .kind = .id_ref, .quantifier = .required },
15901 .{ .kind = .id_ref, .quantifier = .required },
15902 .{ .kind = .id_ref, .quantifier = .required },
15903 .{ .kind = .id_ref, .quantifier = .required },
15904 .{ .kind = .id_ref, .quantifier = .required },
15905 .{ .kind = .id_ref, .quantifier = .required },
15906 .{ .kind = .id_ref, .quantifier = .optional },
15907 },
15908 },
15909 .{
15910 .name = "ProgramScopeVariablesStorageBuffer",
15911 .opcode = 28,
15912 .operands = &.{
15913 .{ .kind = .id_ref, .quantifier = .required },
15914 .{ .kind = .id_ref, .quantifier = .required },
15915 .{ .kind = .id_ref, .quantifier = .required },
15916 },
15917 },
15918 .{
15919 .name = "ProgramScopeVariablePointerRelocation",
15920 .opcode = 29,
15921 .operands = &.{
15922 .{ .kind = .id_ref, .quantifier = .required },
15923 .{ .kind = .id_ref, .quantifier = .required },
15924 .{ .kind = .id_ref, .quantifier = .required },
15925 },
15926 },
15927 .{
15928 .name = "ImageArgumentInfoChannelOrderPushConstant",
15929 .opcode = 30,
15930 .operands = &.{
15931 .{ .kind = .id_ref, .quantifier = .required },
15932 .{ .kind = .id_ref, .quantifier = .required },
15933 .{ .kind = .id_ref, .quantifier = .required },
15934 .{ .kind = .id_ref, .quantifier = .required },
15935 },
15936 },
15937 .{
15938 .name = "ImageArgumentInfoChannelDataTypePushConstant",
15939 .opcode = 31,
15940 .operands = &.{
15941 .{ .kind = .id_ref, .quantifier = .required },
15942 .{ .kind = .id_ref, .quantifier = .required },
15943 .{ .kind = .id_ref, .quantifier = .required },
15944 .{ .kind = .id_ref, .quantifier = .required },
15945 },
15946 },
15947 .{
15948 .name = "ImageArgumentInfoChannelOrderUniform",
15949 .opcode = 32,
15950 .operands = &.{
15951 .{ .kind = .id_ref, .quantifier = .required },
15952 .{ .kind = .id_ref, .quantifier = .required },
15953 .{ .kind = .id_ref, .quantifier = .required },
15954 .{ .kind = .id_ref, .quantifier = .required },
15955 .{ .kind = .id_ref, .quantifier = .required },
15956 .{ .kind = .id_ref, .quantifier = .required },
15957 },
15958 },
15959 .{
15960 .name = "ImageArgumentInfoChannelDataTypeUniform",
15961 .opcode = 33,
15962 .operands = &.{
15963 .{ .kind = .id_ref, .quantifier = .required },
15964 .{ .kind = .id_ref, .quantifier = .required },
15965 .{ .kind = .id_ref, .quantifier = .required },
15966 .{ .kind = .id_ref, .quantifier = .required },
15967 .{ .kind = .id_ref, .quantifier = .required },
15968 .{ .kind = .id_ref, .quantifier = .required },
15969 },
15970 },
15971 .{
15972 .name = "ArgumentStorageTexelBuffer",
15973 .opcode = 34,
15974 .operands = &.{
15975 .{ .kind = .id_ref, .quantifier = .required },
15976 .{ .kind = .id_ref, .quantifier = .required },
15977 .{ .kind = .id_ref, .quantifier = .required },
15978 .{ .kind = .id_ref, .quantifier = .required },
15979 .{ .kind = .id_ref, .quantifier = .optional },
15980 },
15981 },
15982 .{
15983 .name = "ArgumentUniformTexelBuffer",
15984 .opcode = 35,
15985 .operands = &.{
15986 .{ .kind = .id_ref, .quantifier = .required },
15987 .{ .kind = .id_ref, .quantifier = .required },
15988 .{ .kind = .id_ref, .quantifier = .required },
15989 .{ .kind = .id_ref, .quantifier = .required },
15990 .{ .kind = .id_ref, .quantifier = .optional },
15991 },
15992 },
15993 .{
15994 .name = "ConstantDataPointerPushConstant",
15995 .opcode = 36,
15996 .operands = &.{
15997 .{ .kind = .id_ref, .quantifier = .required },
15998 .{ .kind = .id_ref, .quantifier = .required },
15999 .{ .kind = .id_ref, .quantifier = .required },
16000 },
16001 },
16002 .{
16003 .name = "ProgramScopeVariablePointerPushConstant",
16004 .opcode = 37,
16005 .operands = &.{
16006 .{ .kind = .id_ref, .quantifier = .required },
16007 .{ .kind = .id_ref, .quantifier = .required },
16008 .{ .kind = .id_ref, .quantifier = .required },
16009 },
16010 },
16011 .{
16012 .name = "PrintfInfo",
16013 .opcode = 38,
16014 .operands = &.{
16015 .{ .kind = .id_ref, .quantifier = .required },
16016 .{ .kind = .id_ref, .quantifier = .required },
16017 .{ .kind = .id_ref, .quantifier = .variadic },
16018 },
16019 },
16020 .{
16021 .name = "PrintfBufferStorageBuffer",
16022 .opcode = 39,
16023 .operands = &.{
16024 .{ .kind = .id_ref, .quantifier = .required },
16025 .{ .kind = .id_ref, .quantifier = .required },
16026 .{ .kind = .id_ref, .quantifier = .required },
16027 },
16028 },
16029 .{
16030 .name = "PrintfBufferPointerPushConstant",
16031 .opcode = 40,
16032 .operands = &.{
16033 .{ .kind = .id_ref, .quantifier = .required },
16034 .{ .kind = .id_ref, .quantifier = .required },
16035 .{ .kind = .id_ref, .quantifier = .required },
16036 },
16037 },
16038 .{
16039 .name = "NormalizedSamplerMaskPushConstant",
16040 .opcode = 41,
16041 .operands = &.{
16042 .{ .kind = .id_ref, .quantifier = .required },
16043 .{ .kind = .id_ref, .quantifier = .required },
16044 .{ .kind = .id_ref, .quantifier = .required },
16045 .{ .kind = .id_ref, .quantifier = .required },
16046 },
16047 },
16048 .{
16049 .name = "WorkgroupVariableSize",
16050 .opcode = 42,
16051 .operands = &.{
16052 .{ .kind = .id_ref, .quantifier = .required },
16053 .{ .kind = .id_ref, .quantifier = .required },
16054 },
16055 },
16056 },
16057 .@"GLSL.std.450" => &.{
16058 .{
16059 .name = "Round",
16060 .opcode = 1,
16061 .operands = &.{
16062 .{ .kind = .id_ref, .quantifier = .required },
16063 },
16064 },
16065 .{
16066 .name = "RoundEven",
16067 .opcode = 2,
16068 .operands = &.{
16069 .{ .kind = .id_ref, .quantifier = .required },
16070 },
16071 },
16072 .{
16073 .name = "Trunc",
16074 .opcode = 3,
16075 .operands = &.{
16076 .{ .kind = .id_ref, .quantifier = .required },
16077 },
16078 },
16079 .{
16080 .name = "FAbs",
16081 .opcode = 4,
16082 .operands = &.{
16083 .{ .kind = .id_ref, .quantifier = .required },
16084 },
16085 },
16086 .{
16087 .name = "SAbs",
16088 .opcode = 5,
16089 .operands = &.{
16090 .{ .kind = .id_ref, .quantifier = .required },
16091 },
16092 },
16093 .{
16094 .name = "FSign",
16095 .opcode = 6,
16096 .operands = &.{
16097 .{ .kind = .id_ref, .quantifier = .required },
16098 },
16099 },
16100 .{
16101 .name = "SSign",
16102 .opcode = 7,
16103 .operands = &.{
16104 .{ .kind = .id_ref, .quantifier = .required },
16105 },
16106 },
16107 .{
16108 .name = "Floor",
16109 .opcode = 8,
16110 .operands = &.{
16111 .{ .kind = .id_ref, .quantifier = .required },
16112 },
16113 },
16114 .{
16115 .name = "Ceil",
16116 .opcode = 9,
16117 .operands = &.{
16118 .{ .kind = .id_ref, .quantifier = .required },
16119 },
16120 },
16121 .{
16122 .name = "Fract",
16123 .opcode = 10,
16124 .operands = &.{
16125 .{ .kind = .id_ref, .quantifier = .required },
16126 },
16127 },
16128 .{
16129 .name = "Radians",
16130 .opcode = 11,
16131 .operands = &.{
16132 .{ .kind = .id_ref, .quantifier = .required },
16133 },
16134 },
16135 .{
16136 .name = "Degrees",
16137 .opcode = 12,
16138 .operands = &.{
16139 .{ .kind = .id_ref, .quantifier = .required },
16140 },
16141 },
16142 .{
16143 .name = "Sin",
16144 .opcode = 13,
16145 .operands = &.{
16146 .{ .kind = .id_ref, .quantifier = .required },
16147 },
16148 },
16149 .{
16150 .name = "Cos",
16151 .opcode = 14,
16152 .operands = &.{
16153 .{ .kind = .id_ref, .quantifier = .required },
16154 },
16155 },
16156 .{
16157 .name = "Tan",
16158 .opcode = 15,
16159 .operands = &.{
16160 .{ .kind = .id_ref, .quantifier = .required },
16161 },
16162 },
16163 .{
16164 .name = "Asin",
16165 .opcode = 16,
16166 .operands = &.{
16167 .{ .kind = .id_ref, .quantifier = .required },
16168 },
16169 },
16170 .{
16171 .name = "Acos",
16172 .opcode = 17,
16173 .operands = &.{
16174 .{ .kind = .id_ref, .quantifier = .required },
16175 },
16176 },
16177 .{
16178 .name = "Atan",
16179 .opcode = 18,
16180 .operands = &.{
16181 .{ .kind = .id_ref, .quantifier = .required },
16182 },
16183 },
16184 .{
16185 .name = "Sinh",
16186 .opcode = 19,
16187 .operands = &.{
16188 .{ .kind = .id_ref, .quantifier = .required },
16189 },
16190 },
16191 .{
16192 .name = "Cosh",
16193 .opcode = 20,
16194 .operands = &.{
16195 .{ .kind = .id_ref, .quantifier = .required },
16196 },
16197 },
16198 .{
16199 .name = "Tanh",
16200 .opcode = 21,
16201 .operands = &.{
16202 .{ .kind = .id_ref, .quantifier = .required },
16203 },
16204 },
16205 .{
16206 .name = "Asinh",
16207 .opcode = 22,
16208 .operands = &.{
16209 .{ .kind = .id_ref, .quantifier = .required },
16210 },
16211 },
16212 .{
16213 .name = "Acosh",
16214 .opcode = 23,
16215 .operands = &.{
16216 .{ .kind = .id_ref, .quantifier = .required },
16217 },
16218 },
16219 .{
16220 .name = "Atanh",
16221 .opcode = 24,
16222 .operands = &.{
16223 .{ .kind = .id_ref, .quantifier = .required },
16224 },
16225 },
16226 .{
16227 .name = "Atan2",
16228 .opcode = 25,
16229 .operands = &.{
16230 .{ .kind = .id_ref, .quantifier = .required },
16231 .{ .kind = .id_ref, .quantifier = .required },
16232 },
16233 },
16234 .{
16235 .name = "Pow",
16236 .opcode = 26,
16237 .operands = &.{
16238 .{ .kind = .id_ref, .quantifier = .required },
16239 .{ .kind = .id_ref, .quantifier = .required },
16240 },
16241 },
16242 .{
16243 .name = "Exp",
16244 .opcode = 27,
16245 .operands = &.{
16246 .{ .kind = .id_ref, .quantifier = .required },
16247 },
16248 },
16249 .{
16250 .name = "Log",
16251 .opcode = 28,
16252 .operands = &.{
16253 .{ .kind = .id_ref, .quantifier = .required },
16254 },
16255 },
16256 .{
16257 .name = "Exp2",
16258 .opcode = 29,
16259 .operands = &.{
16260 .{ .kind = .id_ref, .quantifier = .required },
16261 },
16262 },
16263 .{
16264 .name = "Log2",
16265 .opcode = 30,
16266 .operands = &.{
16267 .{ .kind = .id_ref, .quantifier = .required },
16268 },
16269 },
16270 .{
16271 .name = "Sqrt",
16272 .opcode = 31,
16273 .operands = &.{
16274 .{ .kind = .id_ref, .quantifier = .required },
16275 },
16276 },
16277 .{
16278 .name = "InverseSqrt",
16279 .opcode = 32,
16280 .operands = &.{
16281 .{ .kind = .id_ref, .quantifier = .required },
16282 },
16283 },
16284 .{
16285 .name = "Determinant",
16286 .opcode = 33,
16287 .operands = &.{
16288 .{ .kind = .id_ref, .quantifier = .required },
16289 },
16290 },
16291 .{
16292 .name = "MatrixInverse",
16293 .opcode = 34,
16294 .operands = &.{
16295 .{ .kind = .id_ref, .quantifier = .required },
16296 },
16297 },
16298 .{
16299 .name = "Modf",
16300 .opcode = 35,
16301 .operands = &.{
16302 .{ .kind = .id_ref, .quantifier = .required },
16303 .{ .kind = .id_ref, .quantifier = .required },
16304 },
16305 },
16306 .{
16307 .name = "ModfStruct",
16308 .opcode = 36,
16309 .operands = &.{
16310 .{ .kind = .id_ref, .quantifier = .required },
16311 },
16312 },
16313 .{
16314 .name = "FMin",
16315 .opcode = 37,
16316 .operands = &.{
16317 .{ .kind = .id_ref, .quantifier = .required },
16318 .{ .kind = .id_ref, .quantifier = .required },
16319 },
16320 },
16321 .{
16322 .name = "UMin",
16323 .opcode = 38,
16324 .operands = &.{
16325 .{ .kind = .id_ref, .quantifier = .required },
16326 .{ .kind = .id_ref, .quantifier = .required },
16327 },
16328 },
16329 .{
16330 .name = "SMin",
16331 .opcode = 39,
16332 .operands = &.{
16333 .{ .kind = .id_ref, .quantifier = .required },
16334 .{ .kind = .id_ref, .quantifier = .required },
16335 },
16336 },
16337 .{
16338 .name = "FMax",
16339 .opcode = 40,
16340 .operands = &.{
16341 .{ .kind = .id_ref, .quantifier = .required },
16342 .{ .kind = .id_ref, .quantifier = .required },
16343 },
16344 },
16345 .{
16346 .name = "UMax",
16347 .opcode = 41,
16348 .operands = &.{
16349 .{ .kind = .id_ref, .quantifier = .required },
16350 .{ .kind = .id_ref, .quantifier = .required },
16351 },
16352 },
16353 .{
16354 .name = "SMax",
16355 .opcode = 42,
16356 .operands = &.{
16357 .{ .kind = .id_ref, .quantifier = .required },
16358 .{ .kind = .id_ref, .quantifier = .required },
16359 },
16360 },
16361 .{
16362 .name = "FClamp",
16363 .opcode = 43,
16364 .operands = &.{
16365 .{ .kind = .id_ref, .quantifier = .required },
16366 .{ .kind = .id_ref, .quantifier = .required },
16367 .{ .kind = .id_ref, .quantifier = .required },
16368 },
16369 },
16370 .{
16371 .name = "UClamp",
16372 .opcode = 44,
16373 .operands = &.{
16374 .{ .kind = .id_ref, .quantifier = .required },
16375 .{ .kind = .id_ref, .quantifier = .required },
16376 .{ .kind = .id_ref, .quantifier = .required },
16377 },
16378 },
16379 .{
16380 .name = "SClamp",
16381 .opcode = 45,
16382 .operands = &.{
16383 .{ .kind = .id_ref, .quantifier = .required },
16384 .{ .kind = .id_ref, .quantifier = .required },
16385 .{ .kind = .id_ref, .quantifier = .required },
16386 },
16387 },
16388 .{
16389 .name = "FMix",
16390 .opcode = 46,
16391 .operands = &.{
16392 .{ .kind = .id_ref, .quantifier = .required },
16393 .{ .kind = .id_ref, .quantifier = .required },
16394 .{ .kind = .id_ref, .quantifier = .required },
16395 },
16396 },
16397 .{
16398 .name = "IMix",
16399 .opcode = 47,
16400 .operands = &.{
16401 .{ .kind = .id_ref, .quantifier = .required },
16402 .{ .kind = .id_ref, .quantifier = .required },
16403 .{ .kind = .id_ref, .quantifier = .required },
16404 },
16405 },
16406 .{
16407 .name = "Step",
16408 .opcode = 48,
16409 .operands = &.{
16410 .{ .kind = .id_ref, .quantifier = .required },
16411 .{ .kind = .id_ref, .quantifier = .required },
16412 },
16413 },
16414 .{
16415 .name = "SmoothStep",
16416 .opcode = 49,
16417 .operands = &.{
16418 .{ .kind = .id_ref, .quantifier = .required },
16419 .{ .kind = .id_ref, .quantifier = .required },
16420 .{ .kind = .id_ref, .quantifier = .required },
16421 },
16422 },
16423 .{
16424 .name = "Fma",
16425 .opcode = 50,
16426 .operands = &.{
16427 .{ .kind = .id_ref, .quantifier = .required },
16428 .{ .kind = .id_ref, .quantifier = .required },
16429 .{ .kind = .id_ref, .quantifier = .required },
16430 },
16431 },
16432 .{
16433 .name = "Frexp",
16434 .opcode = 51,
16435 .operands = &.{
16436 .{ .kind = .id_ref, .quantifier = .required },
16437 .{ .kind = .id_ref, .quantifier = .required },
16438 },
16439 },
16440 .{
16441 .name = "FrexpStruct",
16442 .opcode = 52,
16443 .operands = &.{
16444 .{ .kind = .id_ref, .quantifier = .required },
16445 },
16446 },
16447 .{
16448 .name = "Ldexp",
16449 .opcode = 53,
16450 .operands = &.{
16451 .{ .kind = .id_ref, .quantifier = .required },
16452 .{ .kind = .id_ref, .quantifier = .required },
16453 },
16454 },
16455 .{
16456 .name = "PackSnorm4x8",
16457 .opcode = 54,
16458 .operands = &.{
16459 .{ .kind = .id_ref, .quantifier = .required },
16460 },
16461 },
16462 .{
16463 .name = "PackUnorm4x8",
16464 .opcode = 55,
16465 .operands = &.{
16466 .{ .kind = .id_ref, .quantifier = .required },
16467 },
16468 },
16469 .{
16470 .name = "PackSnorm2x16",
16471 .opcode = 56,
16472 .operands = &.{
16473 .{ .kind = .id_ref, .quantifier = .required },
16474 },
16475 },
16476 .{
16477 .name = "PackUnorm2x16",
16478 .opcode = 57,
16479 .operands = &.{
16480 .{ .kind = .id_ref, .quantifier = .required },
16481 },
16482 },
16483 .{
16484 .name = "PackHalf2x16",
16485 .opcode = 58,
16486 .operands = &.{
16487 .{ .kind = .id_ref, .quantifier = .required },
16488 },
16489 },
16490 .{
16491 .name = "PackDouble2x32",
16492 .opcode = 59,
16493 .operands = &.{
16494 .{ .kind = .id_ref, .quantifier = .required },
16495 },
16496 },
16497 .{
16498 .name = "UnpackSnorm2x16",
16499 .opcode = 60,
16500 .operands = &.{
16501 .{ .kind = .id_ref, .quantifier = .required },
16502 },
16503 },
16504 .{
16505 .name = "UnpackUnorm2x16",
16506 .opcode = 61,
16507 .operands = &.{
16508 .{ .kind = .id_ref, .quantifier = .required },
16509 },
16510 },
16511 .{
16512 .name = "UnpackHalf2x16",
16513 .opcode = 62,
16514 .operands = &.{
16515 .{ .kind = .id_ref, .quantifier = .required },
16516 },
16517 },
16518 .{
16519 .name = "UnpackSnorm4x8",
16520 .opcode = 63,
16521 .operands = &.{
16522 .{ .kind = .id_ref, .quantifier = .required },
16523 },
16524 },
16525 .{
16526 .name = "UnpackUnorm4x8",
16527 .opcode = 64,
16528 .operands = &.{
16529 .{ .kind = .id_ref, .quantifier = .required },
16530 },
16531 },
16532 .{
16533 .name = "UnpackDouble2x32",
16534 .opcode = 65,
16535 .operands = &.{
16536 .{ .kind = .id_ref, .quantifier = .required },
16537 },
16538 },
16539 .{
16540 .name = "Length",
16541 .opcode = 66,
16542 .operands = &.{
16543 .{ .kind = .id_ref, .quantifier = .required },
16544 },
16545 },
16546 .{
16547 .name = "Distance",
16548 .opcode = 67,
16549 .operands = &.{
16550 .{ .kind = .id_ref, .quantifier = .required },
16551 .{ .kind = .id_ref, .quantifier = .required },
16552 },
16553 },
16554 .{
16555 .name = "Cross",
16556 .opcode = 68,
16557 .operands = &.{
16558 .{ .kind = .id_ref, .quantifier = .required },
16559 .{ .kind = .id_ref, .quantifier = .required },
16560 },
16561 },
16562 .{
16563 .name = "Normalize",
16564 .opcode = 69,
16565 .operands = &.{
16566 .{ .kind = .id_ref, .quantifier = .required },
16567 },
16568 },
16569 .{
16570 .name = "FaceForward",
16571 .opcode = 70,
16572 .operands = &.{
16573 .{ .kind = .id_ref, .quantifier = .required },
16574 .{ .kind = .id_ref, .quantifier = .required },
16575 .{ .kind = .id_ref, .quantifier = .required },
16576 },
16577 },
16578 .{
16579 .name = "Reflect",
16580 .opcode = 71,
16581 .operands = &.{
16582 .{ .kind = .id_ref, .quantifier = .required },
16583 .{ .kind = .id_ref, .quantifier = .required },
16584 },
16585 },
16586 .{
16587 .name = "Refract",
16588 .opcode = 72,
16589 .operands = &.{
16590 .{ .kind = .id_ref, .quantifier = .required },
16591 .{ .kind = .id_ref, .quantifier = .required },
16592 .{ .kind = .id_ref, .quantifier = .required },
16593 },
16594 },
16595 .{
16596 .name = "FindILsb",
16597 .opcode = 73,
16598 .operands = &.{
16599 .{ .kind = .id_ref, .quantifier = .required },
16600 },
16601 },
16602 .{
16603 .name = "FindSMsb",
16604 .opcode = 74,
16605 .operands = &.{
16606 .{ .kind = .id_ref, .quantifier = .required },
16607 },
16608 },
16609 .{
16610 .name = "FindUMsb",
16611 .opcode = 75,
16612 .operands = &.{
16613 .{ .kind = .id_ref, .quantifier = .required },
16614 },
16615 },
16616 .{
16617 .name = "InterpolateAtCentroid",
16618 .opcode = 76,
16619 .operands = &.{
16620 .{ .kind = .id_ref, .quantifier = .required },
16621 },
16622 },
16623 .{
16624 .name = "InterpolateAtSample",
16625 .opcode = 77,
16626 .operands = &.{
16627 .{ .kind = .id_ref, .quantifier = .required },
16628 .{ .kind = .id_ref, .quantifier = .required },
16629 },
16630 },
16631 .{
16632 .name = "InterpolateAtOffset",
16633 .opcode = 78,
16634 .operands = &.{
16635 .{ .kind = .id_ref, .quantifier = .required },
16636 .{ .kind = .id_ref, .quantifier = .required },
16637 },
16638 },
16639 .{
16640 .name = "NMin",
16641 .opcode = 79,
16642 .operands = &.{
16643 .{ .kind = .id_ref, .quantifier = .required },
16644 .{ .kind = .id_ref, .quantifier = .required },
16645 },
16646 },
16647 .{
16648 .name = "NMax",
16649 .opcode = 80,
16650 .operands = &.{
16651 .{ .kind = .id_ref, .quantifier = .required },
16652 .{ .kind = .id_ref, .quantifier = .required },
16653 },
16654 },
16655 .{
16656 .name = "NClamp",
16657 .opcode = 81,
16658 .operands = &.{
16659 .{ .kind = .id_ref, .quantifier = .required },
16660 .{ .kind = .id_ref, .quantifier = .required },
16661 .{ .kind = .id_ref, .quantifier = .required },
16662 },
16663 },
16664 },
16665 .SPV_AMD_shader_ballot => &.{
16666 .{
16667 .name = "SwizzleInvocationsAMD",
16668 .opcode = 1,
16669 .operands = &.{
16670 .{ .kind = .id_ref, .quantifier = .required },
16671 .{ .kind = .id_ref, .quantifier = .required },
16672 },
16673 },
16674 .{
16675 .name = "SwizzleInvocationsMaskedAMD",
16676 .opcode = 2,
16677 .operands = &.{
16678 .{ .kind = .id_ref, .quantifier = .required },
16679 .{ .kind = .id_ref, .quantifier = .required },
16680 },
16681 },
16682 .{
16683 .name = "WriteInvocationAMD",
16684 .opcode = 3,
16685 .operands = &.{
16686 .{ .kind = .id_ref, .quantifier = .required },
16687 .{ .kind = .id_ref, .quantifier = .required },
16688 .{ .kind = .id_ref, .quantifier = .required },
16689 },
16690 },
16691 .{
16692 .name = "MbcntAMD",
16693 .opcode = 4,
16694 .operands = &.{
16695 .{ .kind = .id_ref, .quantifier = .required },
16696 },
16697 },
16698 },
16699 .@"NonSemantic.DebugPrintf" => &.{
16700 .{
16701 .name = "DebugPrintf",
16702 .opcode = 1,
16703 .operands = &.{
16704 .{ .kind = .id_ref, .quantifier = .required },
16705 .{ .kind = .id_ref, .quantifier = .variadic },
16706 },
16707 },
16708 },
16709 .SPV_AMD_gcn_shader => &.{
16710 .{
16711 .name = "CubeFaceIndexAMD",
16712 .opcode = 1,
16713 .operands = &.{
16714 .{ .kind = .id_ref, .quantifier = .required },
16715 },
16716 },
16717 .{
16718 .name = "CubeFaceCoordAMD",
16719 .opcode = 2,
16720 .operands = &.{
16721 .{ .kind = .id_ref, .quantifier = .required },
16722 },
16723 },
16724 .{
16725 .name = "TimeAMD",
16726 .opcode = 3,
16727 .operands = &.{},
16728 },
16729 },
16730 .@"OpenCL.std" => &.{
16731 .{
16732 .name = "acos",
16733 .opcode = 0,
16734 .operands = &.{
16735 .{ .kind = .id_ref, .quantifier = .required },
16736 },
16737 },
16738 .{
16739 .name = "acosh",
16740 .opcode = 1,
16741 .operands = &.{
16742 .{ .kind = .id_ref, .quantifier = .required },
16743 },
16744 },
16745 .{
16746 .name = "acospi",
16747 .opcode = 2,
16748 .operands = &.{
16749 .{ .kind = .id_ref, .quantifier = .required },
16750 },
16751 },
16752 .{
16753 .name = "asin",
16754 .opcode = 3,
16755 .operands = &.{
16756 .{ .kind = .id_ref, .quantifier = .required },
16757 },
16758 },
16759 .{
16760 .name = "asinh",
16761 .opcode = 4,
16762 .operands = &.{
16763 .{ .kind = .id_ref, .quantifier = .required },
16764 },
16765 },
16766 .{
16767 .name = "asinpi",
16768 .opcode = 5,
16769 .operands = &.{
16770 .{ .kind = .id_ref, .quantifier = .required },
16771 },
16772 },
16773 .{
16774 .name = "atan",
16775 .opcode = 6,
16776 .operands = &.{
16777 .{ .kind = .id_ref, .quantifier = .required },
16778 },
16779 },
16780 .{
16781 .name = "atan2",
16782 .opcode = 7,
16783 .operands = &.{
16784 .{ .kind = .id_ref, .quantifier = .required },
16785 .{ .kind = .id_ref, .quantifier = .required },
16786 },
16787 },
16788 .{
16789 .name = "atanh",
16790 .opcode = 8,
16791 .operands = &.{
16792 .{ .kind = .id_ref, .quantifier = .required },
16793 },
16794 },
16795 .{
16796 .name = "atanpi",
16797 .opcode = 9,
16798 .operands = &.{
16799 .{ .kind = .id_ref, .quantifier = .required },
16800 },
16801 },
16802 .{
16803 .name = "atan2pi",
16804 .opcode = 10,
16805 .operands = &.{
16806 .{ .kind = .id_ref, .quantifier = .required },
16807 .{ .kind = .id_ref, .quantifier = .required },
16808 },
16809 },
16810 .{
16811 .name = "cbrt",
16812 .opcode = 11,
16813 .operands = &.{
16814 .{ .kind = .id_ref, .quantifier = .required },
16815 },
16816 },
16817 .{
16818 .name = "ceil",
16819 .opcode = 12,
16820 .operands = &.{
16821 .{ .kind = .id_ref, .quantifier = .required },
16822 },
16823 },
16824 .{
16825 .name = "copysign",
16826 .opcode = 13,
16827 .operands = &.{
16828 .{ .kind = .id_ref, .quantifier = .required },
16829 .{ .kind = .id_ref, .quantifier = .required },
16830 },
16831 },
16832 .{
16833 .name = "cos",
16834 .opcode = 14,
16835 .operands = &.{
16836 .{ .kind = .id_ref, .quantifier = .required },
16837 },
16838 },
16839 .{
16840 .name = "cosh",
16841 .opcode = 15,
16842 .operands = &.{
16843 .{ .kind = .id_ref, .quantifier = .required },
16844 },
16845 },
16846 .{
16847 .name = "cospi",
16848 .opcode = 16,
16849 .operands = &.{
16850 .{ .kind = .id_ref, .quantifier = .required },
16851 },
16852 },
16853 .{
16854 .name = "erfc",
16855 .opcode = 17,
16856 .operands = &.{
16857 .{ .kind = .id_ref, .quantifier = .required },
16858 },
16859 },
16860 .{
16861 .name = "erf",
16862 .opcode = 18,
16863 .operands = &.{
16864 .{ .kind = .id_ref, .quantifier = .required },
16865 },
16866 },
16867 .{
16868 .name = "exp",
16869 .opcode = 19,
16870 .operands = &.{
16871 .{ .kind = .id_ref, .quantifier = .required },
16872 },
16873 },
16874 .{
16875 .name = "exp2",
16876 .opcode = 20,
16877 .operands = &.{
16878 .{ .kind = .id_ref, .quantifier = .required },
16879 },
16880 },
16881 .{
16882 .name = "exp10",
16883 .opcode = 21,
16884 .operands = &.{
16885 .{ .kind = .id_ref, .quantifier = .required },
16886 },
16887 },
16888 .{
16889 .name = "expm1",
16890 .opcode = 22,
16891 .operands = &.{
16892 .{ .kind = .id_ref, .quantifier = .required },
16893 },
16894 },
16895 .{
16896 .name = "fabs",
16897 .opcode = 23,
16898 .operands = &.{
16899 .{ .kind = .id_ref, .quantifier = .required },
16900 },
16901 },
16902 .{
16903 .name = "fdim",
16904 .opcode = 24,
16905 .operands = &.{
16906 .{ .kind = .id_ref, .quantifier = .required },
16907 .{ .kind = .id_ref, .quantifier = .required },
16908 },
16909 },
16910 .{
16911 .name = "floor",
16912 .opcode = 25,
16913 .operands = &.{
16914 .{ .kind = .id_ref, .quantifier = .required },
16915 },
16916 },
16917 .{
16918 .name = "fma",
16919 .opcode = 26,
16920 .operands = &.{
16921 .{ .kind = .id_ref, .quantifier = .required },
16922 .{ .kind = .id_ref, .quantifier = .required },
16923 .{ .kind = .id_ref, .quantifier = .required },
16924 },
16925 },
16926 .{
16927 .name = "fmax",
16928 .opcode = 27,
16929 .operands = &.{
16930 .{ .kind = .id_ref, .quantifier = .required },
16931 .{ .kind = .id_ref, .quantifier = .required },
16932 },
16933 },
16934 .{
16935 .name = "fmin",
16936 .opcode = 28,
16937 .operands = &.{
16938 .{ .kind = .id_ref, .quantifier = .required },
16939 .{ .kind = .id_ref, .quantifier = .required },
16940 },
16941 },
16942 .{
16943 .name = "fmod",
16944 .opcode = 29,
16945 .operands = &.{
16946 .{ .kind = .id_ref, .quantifier = .required },
16947 .{ .kind = .id_ref, .quantifier = .required },
16948 },
16949 },
16950 .{
16951 .name = "fract",
16952 .opcode = 30,
16953 .operands = &.{
16954 .{ .kind = .id_ref, .quantifier = .required },
16955 .{ .kind = .id_ref, .quantifier = .required },
16956 },
16957 },
16958 .{
16959 .name = "frexp",
16960 .opcode = 31,
16961 .operands = &.{
16962 .{ .kind = .id_ref, .quantifier = .required },
16963 .{ .kind = .id_ref, .quantifier = .required },
16964 },
16965 },
16966 .{
16967 .name = "hypot",
16968 .opcode = 32,
16969 .operands = &.{
16970 .{ .kind = .id_ref, .quantifier = .required },
16971 .{ .kind = .id_ref, .quantifier = .required },
16972 },
16973 },
16974 .{
16975 .name = "ilogb",
16976 .opcode = 33,
16977 .operands = &.{
16978 .{ .kind = .id_ref, .quantifier = .required },
16979 },
16980 },
16981 .{
16982 .name = "ldexp",
16983 .opcode = 34,
16984 .operands = &.{
16985 .{ .kind = .id_ref, .quantifier = .required },
16986 .{ .kind = .id_ref, .quantifier = .required },
16987 },
16988 },
16989 .{
16990 .name = "lgamma",
16991 .opcode = 35,
16992 .operands = &.{
16993 .{ .kind = .id_ref, .quantifier = .required },
16994 },
16995 },
16996 .{
16997 .name = "lgamma_r",
16998 .opcode = 36,
16999 .operands = &.{
17000 .{ .kind = .id_ref, .quantifier = .required },
17001 .{ .kind = .id_ref, .quantifier = .required },
17002 },
17003 },
17004 .{
17005 .name = "log",
17006 .opcode = 37,
17007 .operands = &.{
17008 .{ .kind = .id_ref, .quantifier = .required },
17009 },
17010 },
17011 .{
17012 .name = "log2",
17013 .opcode = 38,
17014 .operands = &.{
17015 .{ .kind = .id_ref, .quantifier = .required },
17016 },
17017 },
17018 .{
17019 .name = "log10",
17020 .opcode = 39,
17021 .operands = &.{
17022 .{ .kind = .id_ref, .quantifier = .required },
17023 },
17024 },
17025 .{
17026 .name = "log1p",
17027 .opcode = 40,
17028 .operands = &.{
17029 .{ .kind = .id_ref, .quantifier = .required },
17030 },
17031 },
17032 .{
17033 .name = "logb",
17034 .opcode = 41,
17035 .operands = &.{
17036 .{ .kind = .id_ref, .quantifier = .required },
17037 },
17038 },
17039 .{
17040 .name = "mad",
17041 .opcode = 42,
17042 .operands = &.{
17043 .{ .kind = .id_ref, .quantifier = .required },
17044 .{ .kind = .id_ref, .quantifier = .required },
17045 .{ .kind = .id_ref, .quantifier = .required },
17046 },
17047 },
17048 .{
17049 .name = "maxmag",
17050 .opcode = 43,
17051 .operands = &.{
17052 .{ .kind = .id_ref, .quantifier = .required },
17053 .{ .kind = .id_ref, .quantifier = .required },
17054 },
17055 },
17056 .{
17057 .name = "minmag",
17058 .opcode = 44,
17059 .operands = &.{
17060 .{ .kind = .id_ref, .quantifier = .required },
17061 .{ .kind = .id_ref, .quantifier = .required },
17062 },
17063 },
17064 .{
17065 .name = "modf",
17066 .opcode = 45,
17067 .operands = &.{
17068 .{ .kind = .id_ref, .quantifier = .required },
17069 .{ .kind = .id_ref, .quantifier = .required },
17070 },
17071 },
17072 .{
17073 .name = "nan",
17074 .opcode = 46,
17075 .operands = &.{
17076 .{ .kind = .id_ref, .quantifier = .required },
17077 },
17078 },
17079 .{
17080 .name = "nextafter",
17081 .opcode = 47,
17082 .operands = &.{
17083 .{ .kind = .id_ref, .quantifier = .required },
17084 .{ .kind = .id_ref, .quantifier = .required },
17085 },
17086 },
17087 .{
17088 .name = "pow",
17089 .opcode = 48,
17090 .operands = &.{
17091 .{ .kind = .id_ref, .quantifier = .required },
17092 .{ .kind = .id_ref, .quantifier = .required },
17093 },
17094 },
17095 .{
17096 .name = "pown",
17097 .opcode = 49,
17098 .operands = &.{
17099 .{ .kind = .id_ref, .quantifier = .required },
17100 .{ .kind = .id_ref, .quantifier = .required },
17101 },
17102 },
17103 .{
17104 .name = "powr",
17105 .opcode = 50,
17106 .operands = &.{
17107 .{ .kind = .id_ref, .quantifier = .required },
17108 .{ .kind = .id_ref, .quantifier = .required },
17109 },
17110 },
17111 .{
17112 .name = "remainder",
17113 .opcode = 51,
17114 .operands = &.{
17115 .{ .kind = .id_ref, .quantifier = .required },
17116 .{ .kind = .id_ref, .quantifier = .required },
17117 },
17118 },
17119 .{
17120 .name = "remquo",
17121 .opcode = 52,
17122 .operands = &.{
17123 .{ .kind = .id_ref, .quantifier = .required },
17124 .{ .kind = .id_ref, .quantifier = .required },
17125 .{ .kind = .id_ref, .quantifier = .required },
17126 },
17127 },
17128 .{
17129 .name = "rint",
17130 .opcode = 53,
17131 .operands = &.{
17132 .{ .kind = .id_ref, .quantifier = .required },
17133 },
17134 },
17135 .{
17136 .name = "rootn",
17137 .opcode = 54,
17138 .operands = &.{
17139 .{ .kind = .id_ref, .quantifier = .required },
17140 .{ .kind = .id_ref, .quantifier = .required },
17141 },
17142 },
17143 .{
17144 .name = "round",
17145 .opcode = 55,
17146 .operands = &.{
17147 .{ .kind = .id_ref, .quantifier = .required },14498 .{ .kind = .id_ref, .quantifier = .required },
17148 },14499 },
17149 },14500 },
17150 .{14501 .{
17151 .name = "rsqrt",14502 .name = "cbrt",
17152 .opcode = 56,14503 .opcode = 11,
17153 .operands = &.{14504 .operands = &.{
17154 .{ .kind = .id_ref, .quantifier = .required },14505 .{ .kind = .id_ref, .quantifier = .required },
17155 },14506 },
17156 },14507 },
17157 .{14508 .{
17158 .name = "sin",14509 .name = "ceil",
17159 .opcode = 57,14510 .opcode = 12,
17160 .operands = &.{14511 .operands = &.{
17161 .{ .kind = .id_ref, .quantifier = .required },14512 .{ .kind = .id_ref, .quantifier = .required },
17162 },14513 },
17163 },14514 },
17164 .{14515 .{
17165 .name = "sincos",14516 .name = "copysign",
17166 .opcode = 58,14517 .opcode = 13,
17167 .operands = &.{14518 .operands = &.{
17168 .{ .kind = .id_ref, .quantifier = .required },14519 .{ .kind = .id_ref, .quantifier = .required },
17169 .{ .kind = .id_ref, .quantifier = .required },14520 .{ .kind = .id_ref, .quantifier = .required },
17170 },14521 },
17171 },14522 },
17172 .{14523 .{
17173 .name = "sinh",14524 .name = "cos",
17174 .opcode = 59,14525 .opcode = 14,
17175 .operands = &.{14526 .operands = &.{
17176 .{ .kind = .id_ref, .quantifier = .required },14527 .{ .kind = .id_ref, .quantifier = .required },
17177 },14528 },
17178 },14529 },
17179 .{14530 .{
17180 .name = "sinpi",14531 .name = "cosh",
17181 .opcode = 60,14532 .opcode = 15,
17182 .operands = &.{14533 .operands = &.{
17183 .{ .kind = .id_ref, .quantifier = .required },14534 .{ .kind = .id_ref, .quantifier = .required },
17184 },14535 },
17185 },14536 },
17186 .{14537 .{
17187 .name = "sqrt",14538 .name = "cospi",
17188 .opcode = 61,14539 .opcode = 16,
17189 .operands = &.{14540 .operands = &.{
17190 .{ .kind = .id_ref, .quantifier = .required },14541 .{ .kind = .id_ref, .quantifier = .required },
17191 },14542 },
17192 },14543 },
17193 .{14544 .{
17194 .name = "tan",14545 .name = "erfc",
17195 .opcode = 62,14546 .opcode = 17,
17196 .operands = &.{14547 .operands = &.{
17197 .{ .kind = .id_ref, .quantifier = .required },14548 .{ .kind = .id_ref, .quantifier = .required },
17198 },14549 },
17199 },14550 },
17200 .{14551 .{
17201 .name = "tanh",14552 .name = "erf",
17202 .opcode = 63,14553 .opcode = 18,
17203 .operands = &.{14554 .operands = &.{
17204 .{ .kind = .id_ref, .quantifier = .required },14555 .{ .kind = .id_ref, .quantifier = .required },
17205 },14556 },
17206 },14557 },
17207 .{14558 .{
17208 .name = "tanpi",14559 .name = "exp",
17209 .opcode = 64,14560 .opcode = 19,
17210 .operands = &.{14561 .operands = &.{
17211 .{ .kind = .id_ref, .quantifier = .required },14562 .{ .kind = .id_ref, .quantifier = .required },
17212 },14563 },
17213 },14564 },
17214 .{14565 .{
17215 .name = "tgamma",14566 .name = "exp2",
17216 .opcode = 65,14567 .opcode = 20,
17217 .operands = &.{14568 .operands = &.{
17218 .{ .kind = .id_ref, .quantifier = .required },14569 .{ .kind = .id_ref, .quantifier = .required },
17219 },14570 },
17220 },14571 },
17221 .{14572 .{
17222 .name = "trunc",14573 .name = "exp10",
17223 .opcode = 66,14574 .opcode = 21,
17224 .operands = &.{14575 .operands = &.{
17225 .{ .kind = .id_ref, .quantifier = .required },14576 .{ .kind = .id_ref, .quantifier = .required },
17226 },14577 },
17227 },14578 },
17228 .{14579 .{
17229 .name = "half_cos",14580 .name = "expm1",
17230 .opcode = 67,14581 .opcode = 22,
17231 .operands = &.{14582 .operands = &.{
17232 .{ .kind = .id_ref, .quantifier = .required },14583 .{ .kind = .id_ref, .quantifier = .required },
17233 },14584 },
17234 },14585 },
17235 .{14586 .{
17236 .name = "half_divide",14587 .name = "fabs",
17237 .opcode = 68,14588 .opcode = 23,
17238 .operands = &.{14589 .operands = &.{
17239 .{ .kind = .id_ref, .quantifier = .required },14590 .{ .kind = .id_ref, .quantifier = .required },
17240 .{ .kind = .id_ref, .quantifier = .required },
17241 },14591 },
17242 },14592 },
17243 .{14593 .{
17244 .name = "half_exp",14594 .name = "fdim",
17245 .opcode = 69,14595 .opcode = 24,
17246 .operands = &.{14596 .operands = &.{
17247 .{ .kind = .id_ref, .quantifier = .required },14597 .{ .kind = .id_ref, .quantifier = .required },
14598 .{ .kind = .id_ref, .quantifier = .required },
17248 },14599 },
17249 },14600 },
17250 .{14601 .{
17251 .name = "half_exp2",14602 .name = "floor",
17252 .opcode = 70,14603 .opcode = 25,
17253 .operands = &.{14604 .operands = &.{
17254 .{ .kind = .id_ref, .quantifier = .required },14605 .{ .kind = .id_ref, .quantifier = .required },
17255 },14606 },
17256 },14607 },
17257 .{14608 .{
17258 .name = "half_exp10",14609 .name = "fma",
17259 .opcode = 71,14610 .opcode = 26,
17260 .operands = &.{14611 .operands = &.{
17261 .{ .kind = .id_ref, .quantifier = .required },14612 .{ .kind = .id_ref, .quantifier = .required },
14613 .{ .kind = .id_ref, .quantifier = .required },
14614 .{ .kind = .id_ref, .quantifier = .required },
17262 },14615 },
17263 },14616 },
17264 .{14617 .{
17265 .name = "half_log",14618 .name = "fmax",
17266 .opcode = 72,14619 .opcode = 27,
17267 .operands = &.{14620 .operands = &.{
17268 .{ .kind = .id_ref, .quantifier = .required },14621 .{ .kind = .id_ref, .quantifier = .required },
14622 .{ .kind = .id_ref, .quantifier = .required },
17269 },14623 },
17270 },14624 },
17271 .{14625 .{
17272 .name = "half_log2",14626 .name = "fmin",
17273 .opcode = 73,14627 .opcode = 28,
17274 .operands = &.{14628 .operands = &.{
17275 .{ .kind = .id_ref, .quantifier = .required },14629 .{ .kind = .id_ref, .quantifier = .required },
14630 .{ .kind = .id_ref, .quantifier = .required },
17276 },14631 },
17277 },14632 },
17278 .{14633 .{
17279 .name = "half_log10",14634 .name = "fmod",
17280 .opcode = 74,14635 .opcode = 29,
17281 .operands = &.{14636 .operands = &.{
17282 .{ .kind = .id_ref, .quantifier = .required },14637 .{ .kind = .id_ref, .quantifier = .required },
14638 .{ .kind = .id_ref, .quantifier = .required },
17283 },14639 },
17284 },14640 },
17285 .{14641 .{
17286 .name = "half_powr",14642 .name = "fract",
17287 .opcode = 75,14643 .opcode = 30,
17288 .operands = &.{14644 .operands = &.{
17289 .{ .kind = .id_ref, .quantifier = .required },14645 .{ .kind = .id_ref, .quantifier = .required },
17290 .{ .kind = .id_ref, .quantifier = .required },14646 .{ .kind = .id_ref, .quantifier = .required },
17291 },14647 },
17292 },14648 },
17293 .{14649 .{
17294 .name = "half_recip",14650 .name = "frexp",
17295 .opcode = 76,14651 .opcode = 31,
17296 .operands = &.{14652 .operands = &.{
17297 .{ .kind = .id_ref, .quantifier = .required },14653 .{ .kind = .id_ref, .quantifier = .required },
14654 .{ .kind = .id_ref, .quantifier = .required },
17298 },14655 },
17299 },14656 },
17300 .{14657 .{
17301 .name = "half_rsqrt",14658 .name = "hypot",
17302 .opcode = 77,14659 .opcode = 32,
17303 .operands = &.{14660 .operands = &.{
17304 .{ .kind = .id_ref, .quantifier = .required },14661 .{ .kind = .id_ref, .quantifier = .required },
14662 .{ .kind = .id_ref, .quantifier = .required },
17305 },14663 },
17306 },14664 },
17307 .{14665 .{
17308 .name = "half_sin",14666 .name = "ilogb",
17309 .opcode = 78,14667 .opcode = 33,
17310 .operands = &.{14668 .operands = &.{
17311 .{ .kind = .id_ref, .quantifier = .required },14669 .{ .kind = .id_ref, .quantifier = .required },
17312 },14670 },
17313 },14671 },
17314 .{14672 .{
17315 .name = "half_sqrt",14673 .name = "ldexp",
17316 .opcode = 79,14674 .opcode = 34,
17317 .operands = &.{14675 .operands = &.{
17318 .{ .kind = .id_ref, .quantifier = .required },14676 .{ .kind = .id_ref, .quantifier = .required },
14677 .{ .kind = .id_ref, .quantifier = .required },
17319 },14678 },
17320 },14679 },
17321 .{14680 .{
17322 .name = "half_tan",14681 .name = "lgamma",
17323 .opcode = 80,14682 .opcode = 35,
17324 .operands = &.{14683 .operands = &.{
17325 .{ .kind = .id_ref, .quantifier = .required },14684 .{ .kind = .id_ref, .quantifier = .required },
17326 },14685 },
17327 },14686 },
17328 .{14687 .{
17329 .name = "native_cos",14688 .name = "lgamma_r",
17330 .opcode = 81,14689 .opcode = 36,
17331 .operands = &.{14690 .operands = &.{
17332 .{ .kind = .id_ref, .quantifier = .required },14691 .{ .kind = .id_ref, .quantifier = .required },
14692 .{ .kind = .id_ref, .quantifier = .required },
17333 },14693 },
17334 },14694 },
17335 .{14695 .{
17336 .name = "native_divide",14696 .name = "log",
17337 .opcode = 82,14697 .opcode = 37,
17338 .operands = &.{14698 .operands = &.{
17339 .{ .kind = .id_ref, .quantifier = .required },14699 .{ .kind = .id_ref, .quantifier = .required },
17340 .{ .kind = .id_ref, .quantifier = .required },
17341 },14700 },
17342 },14701 },
17343 .{14702 .{
17344 .name = "native_exp",14703 .name = "log2",
17345 .opcode = 83,14704 .opcode = 38,
17346 .operands = &.{14705 .operands = &.{
17347 .{ .kind = .id_ref, .quantifier = .required },14706 .{ .kind = .id_ref, .quantifier = .required },
17348 },14707 },
17349 },14708 },
17350 .{14709 .{
17351 .name = "native_exp2",14710 .name = "log10",
17352 .opcode = 84,14711 .opcode = 39,
17353 .operands = &.{14712 .operands = &.{
17354 .{ .kind = .id_ref, .quantifier = .required },14713 .{ .kind = .id_ref, .quantifier = .required },
17355 },14714 },
17356 },14715 },
17357 .{14716 .{
17358 .name = "native_exp10",14717 .name = "log1p",
17359 .opcode = 85,14718 .opcode = 40,
17360 .operands = &.{14719 .operands = &.{
17361 .{ .kind = .id_ref, .quantifier = .required },14720 .{ .kind = .id_ref, .quantifier = .required },
17362 },14721 },
17363 },14722 },
17364 .{14723 .{
17365 .name = "native_log",14724 .name = "logb",
17366 .opcode = 86,14725 .opcode = 41,
17367 .operands = &.{14726 .operands = &.{
17368 .{ .kind = .id_ref, .quantifier = .required },14727 .{ .kind = .id_ref, .quantifier = .required },
17369 },14728 },
17370 },14729 },
17371 .{14730 .{
17372 .name = "native_log2",14731 .name = "mad",
17373 .opcode = 87,14732 .opcode = 42,
17374 .operands = &.{14733 .operands = &.{
17375 .{ .kind = .id_ref, .quantifier = .required },14734 .{ .kind = .id_ref, .quantifier = .required },
14735 .{ .kind = .id_ref, .quantifier = .required },
14736 .{ .kind = .id_ref, .quantifier = .required },
17376 },14737 },
17377 },14738 },
17378 .{14739 .{
17379 .name = "native_log10",14740 .name = "maxmag",
17380 .opcode = 88,14741 .opcode = 43,
17381 .operands = &.{14742 .operands = &.{
17382 .{ .kind = .id_ref, .quantifier = .required },14743 .{ .kind = .id_ref, .quantifier = .required },
14744 .{ .kind = .id_ref, .quantifier = .required },
17383 },14745 },
17384 },14746 },
17385 .{14747 .{
17386 .name = "native_powr",14748 .name = "minmag",
17387 .opcode = 89,14749 .opcode = 44,
17388 .operands = &.{14750 .operands = &.{
17389 .{ .kind = .id_ref, .quantifier = .required },14751 .{ .kind = .id_ref, .quantifier = .required },
17390 .{ .kind = .id_ref, .quantifier = .required },14752 .{ .kind = .id_ref, .quantifier = .required },
17391 },14753 },
17392 },14754 },
17393 .{14755 .{
17394 .name = "native_recip",14756 .name = "modf",
17395 .opcode = 90,14757 .opcode = 45,
17396 .operands = &.{14758 .operands = &.{
17397 .{ .kind = .id_ref, .quantifier = .required },14759 .{ .kind = .id_ref, .quantifier = .required },
14760 .{ .kind = .id_ref, .quantifier = .required },
17398 },14761 },
17399 },14762 },
17400 .{14763 .{
17401 .name = "native_rsqrt",14764 .name = "nan",
17402 .opcode = 91,14765 .opcode = 46,
17403 .operands = &.{14766 .operands = &.{
17404 .{ .kind = .id_ref, .quantifier = .required },14767 .{ .kind = .id_ref, .quantifier = .required },
17405 },14768 },
17406 },14769 },
17407 .{14770 .{
17408 .name = "native_sin",14771 .name = "nextafter",
17409 .opcode = 92,14772 .opcode = 47,
17410 .operands = &.{14773 .operands = &.{
17411 .{ .kind = .id_ref, .quantifier = .required },14774 .{ .kind = .id_ref, .quantifier = .required },
14775 .{ .kind = .id_ref, .quantifier = .required },
17412 },14776 },
17413 },14777 },
17414 .{14778 .{
17415 .name = "native_sqrt",14779 .name = "pow",
17416 .opcode = 93,14780 .opcode = 48,
17417 .operands = &.{14781 .operands = &.{
17418 .{ .kind = .id_ref, .quantifier = .required },14782 .{ .kind = .id_ref, .quantifier = .required },
14783 .{ .kind = .id_ref, .quantifier = .required },
17419 },14784 },
17420 },14785 },
17421 .{14786 .{
17422 .name = "native_tan",14787 .name = "pown",
17423 .opcode = 94,14788 .opcode = 49,
17424 .operands = &.{14789 .operands = &.{
17425 .{ .kind = .id_ref, .quantifier = .required },14790 .{ .kind = .id_ref, .quantifier = .required },
14791 .{ .kind = .id_ref, .quantifier = .required },
17426 },14792 },
17427 },14793 },
17428 .{14794 .{
17429 .name = "fclamp",14795 .name = "powr",
17430 .opcode = 95,14796 .opcode = 50,
17431 .operands = &.{14797 .operands = &.{
17432 .{ .kind = .id_ref, .quantifier = .required },14798 .{ .kind = .id_ref, .quantifier = .required },
17433 .{ .kind = .id_ref, .quantifier = .required },14799 .{ .kind = .id_ref, .quantifier = .required },
17434 .{ .kind = .id_ref, .quantifier = .required },
17435 },14800 },
17436 },14801 },
17437 .{14802 .{
17438 .name = "degrees",14803 .name = "remainder",
17439 .opcode = 96,14804 .opcode = 51,
17440 .operands = &.{14805 .operands = &.{
17441 .{ .kind = .id_ref, .quantifier = .required },14806 .{ .kind = .id_ref, .quantifier = .required },
14807 .{ .kind = .id_ref, .quantifier = .required },
17442 },14808 },
17443 },14809 },
17444 .{14810 .{
17445 .name = "fmax_common",14811 .name = "remquo",
17446 .opcode = 97,14812 .opcode = 52,
17447 .operands = &.{14813 .operands = &.{
17448 .{ .kind = .id_ref, .quantifier = .required },14814 .{ .kind = .id_ref, .quantifier = .required },
17449 .{ .kind = .id_ref, .quantifier = .required },14815 .{ .kind = .id_ref, .quantifier = .required },
14816 .{ .kind = .id_ref, .quantifier = .required },
17450 },14817 },
17451 },14818 },
17452 .{14819 .{
17453 .name = "fmin_common",14820 .name = "rint",
17454 .opcode = 98,14821 .opcode = 53,
17455 .operands = &.{14822 .operands = &.{
17456 .{ .kind = .id_ref, .quantifier = .required },14823 .{ .kind = .id_ref, .quantifier = .required },
17457 .{ .kind = .id_ref, .quantifier = .required },
17458 },14824 },
17459 },14825 },
17460 .{14826 .{
17461 .name = "mix",14827 .name = "rootn",
17462 .opcode = 99,14828 .opcode = 54,
17463 .operands = &.{14829 .operands = &.{
17464 .{ .kind = .id_ref, .quantifier = .required },14830 .{ .kind = .id_ref, .quantifier = .required },
17465 .{ .kind = .id_ref, .quantifier = .required },14831 .{ .kind = .id_ref, .quantifier = .required },
17466 .{ .kind = .id_ref, .quantifier = .required },
17467 },14832 },
17468 },14833 },
17469 .{14834 .{
17470 .name = "radians",14835 .name = "round",
17471 .opcode = 100,14836 .opcode = 55,
17472 .operands = &.{14837 .operands = &.{
17473 .{ .kind = .id_ref, .quantifier = .required },14838 .{ .kind = .id_ref, .quantifier = .required },
17474 },14839 },
17475 },14840 },
17476 .{14841 .{
17477 .name = "step",14842 .name = "rsqrt",
17478 .opcode = 101,14843 .opcode = 56,
17479 .operands = &.{14844 .operands = &.{
17480 .{ .kind = .id_ref, .quantifier = .required },14845 .{ .kind = .id_ref, .quantifier = .required },
17481 .{ .kind = .id_ref, .quantifier = .required },
17482 },14846 },
17483 },14847 },
17484 .{14848 .{
17485 .name = "smoothstep",14849 .name = "sin",
17486 .opcode = 102,14850 .opcode = 57,
17487 .operands = &.{14851 .operands = &.{
17488 .{ .kind = .id_ref, .quantifier = .required },14852 .{ .kind = .id_ref, .quantifier = .required },
14853 },
14854 },
14855 .{
14856 .name = "sincos",
14857 .opcode = 58,
14858 .operands = &.{
17489 .{ .kind = .id_ref, .quantifier = .required },14859 .{ .kind = .id_ref, .quantifier = .required },
17490 .{ .kind = .id_ref, .quantifier = .required },14860 .{ .kind = .id_ref, .quantifier = .required },
17491 },14861 },
17492 },14862 },
17493 .{14863 .{
17494 .name = "sign",14864 .name = "sinh",
17495 .opcode = 103,14865 .opcode = 59,
17496 .operands = &.{14866 .operands = &.{
17497 .{ .kind = .id_ref, .quantifier = .required },14867 .{ .kind = .id_ref, .quantifier = .required },
17498 },14868 },
17499 },14869 },
17500 .{14870 .{
17501 .name = "cross",14871 .name = "sinpi",
17502 .opcode = 104,14872 .opcode = 60,
17503 .operands = &.{14873 .operands = &.{
17504 .{ .kind = .id_ref, .quantifier = .required },14874 .{ .kind = .id_ref, .quantifier = .required },
17505 .{ .kind = .id_ref, .quantifier = .required },
17506 },14875 },
17507 },14876 },
17508 .{14877 .{
17509 .name = "distance",14878 .name = "sqrt",
17510 .opcode = 105,14879 .opcode = 61,
17511 .operands = &.{14880 .operands = &.{
17512 .{ .kind = .id_ref, .quantifier = .required },14881 .{ .kind = .id_ref, .quantifier = .required },
17513 .{ .kind = .id_ref, .quantifier = .required },
17514 },14882 },
17515 },14883 },
17516 .{14884 .{
17517 .name = "length",14885 .name = "tan",
17518 .opcode = 106,14886 .opcode = 62,
17519 .operands = &.{14887 .operands = &.{
17520 .{ .kind = .id_ref, .quantifier = .required },14888 .{ .kind = .id_ref, .quantifier = .required },
17521 },14889 },
17522 },14890 },
17523 .{14891 .{
17524 .name = "normalize",14892 .name = "tanh",
17525 .opcode = 107,14893 .opcode = 63,
17526 .operands = &.{14894 .operands = &.{
17527 .{ .kind = .id_ref, .quantifier = .required },14895 .{ .kind = .id_ref, .quantifier = .required },
17528 },14896 },
17529 },14897 },
17530 .{14898 .{
17531 .name = "fast_distance",14899 .name = "tanpi",
17532 .opcode = 108,14900 .opcode = 64,
17533 .operands = &.{14901 .operands = &.{
17534 .{ .kind = .id_ref, .quantifier = .required },14902 .{ .kind = .id_ref, .quantifier = .required },
17535 .{ .kind = .id_ref, .quantifier = .required },
17536 },14903 },
17537 },14904 },
17538 .{14905 .{
17539 .name = "fast_length",14906 .name = "tgamma",
17540 .opcode = 109,14907 .opcode = 65,
17541 .operands = &.{14908 .operands = &.{
17542 .{ .kind = .id_ref, .quantifier = .required },14909 .{ .kind = .id_ref, .quantifier = .required },
17543 },14910 },
17544 },14911 },
17545 .{14912 .{
17546 .name = "fast_normalize",14913 .name = "trunc",
17547 .opcode = 110,14914 .opcode = 66,
17548 .operands = &.{14915 .operands = &.{
17549 .{ .kind = .id_ref, .quantifier = .required },14916 .{ .kind = .id_ref, .quantifier = .required },
17550 },14917 },
17551 },14918 },
17552 .{14919 .{
17553 .name = "s_abs",14920 .name = "half_cos",
17554 .opcode = 141,14921 .opcode = 67,
17555 .operands = &.{14922 .operands = &.{
17556 .{ .kind = .id_ref, .quantifier = .required },14923 .{ .kind = .id_ref, .quantifier = .required },
17557 },14924 },
17558 },14925 },
17559 .{14926 .{
17560 .name = "s_abs_diff",14927 .name = "half_divide",
17561 .opcode = 142,14928 .opcode = 68,
17562 .operands = &.{14929 .operands = &.{
17563 .{ .kind = .id_ref, .quantifier = .required },14930 .{ .kind = .id_ref, .quantifier = .required },
17564 .{ .kind = .id_ref, .quantifier = .required },14931 .{ .kind = .id_ref, .quantifier = .required },
17565 },14932 },
17566 },14933 },
17567 .{14934 .{
17568 .name = "s_add_sat",14935 .name = "half_exp",
17569 .opcode = 143,14936 .opcode = 69,
17570 .operands = &.{14937 .operands = &.{
17571 .{ .kind = .id_ref, .quantifier = .required },14938 .{ .kind = .id_ref, .quantifier = .required },
17572 .{ .kind = .id_ref, .quantifier = .required },
17573 },14939 },
17574 },14940 },
17575 .{14941 .{
17576 .name = "u_add_sat",14942 .name = "half_exp2",
17577 .opcode = 144,14943 .opcode = 70,
17578 .operands = &.{14944 .operands = &.{
17579 .{ .kind = .id_ref, .quantifier = .required },14945 .{ .kind = .id_ref, .quantifier = .required },
17580 .{ .kind = .id_ref, .quantifier = .required },
17581 },14946 },
17582 },14947 },
17583 .{14948 .{
17584 .name = "s_hadd",14949 .name = "half_exp10",
17585 .opcode = 145,14950 .opcode = 71,
17586 .operands = &.{14951 .operands = &.{
17587 .{ .kind = .id_ref, .quantifier = .required },14952 .{ .kind = .id_ref, .quantifier = .required },
17588 .{ .kind = .id_ref, .quantifier = .required },
17589 },14953 },
17590 },14954 },
17591 .{14955 .{
17592 .name = "u_hadd",14956 .name = "half_log",
17593 .opcode = 146,14957 .opcode = 72,
17594 .operands = &.{14958 .operands = &.{
17595 .{ .kind = .id_ref, .quantifier = .required },14959 .{ .kind = .id_ref, .quantifier = .required },
17596 .{ .kind = .id_ref, .quantifier = .required },
17597 },14960 },
17598 },14961 },
17599 .{14962 .{
17600 .name = "s_rhadd",14963 .name = "half_log2",
17601 .opcode = 147,14964 .opcode = 73,
17602 .operands = &.{14965 .operands = &.{
17603 .{ .kind = .id_ref, .quantifier = .required },14966 .{ .kind = .id_ref, .quantifier = .required },
17604 .{ .kind = .id_ref, .quantifier = .required },
17605 },14967 },
17606 },14968 },
17607 .{14969 .{
17608 .name = "u_rhadd",14970 .name = "half_log10",
17609 .opcode = 148,14971 .opcode = 74,
17610 .operands = &.{14972 .operands = &.{
17611 .{ .kind = .id_ref, .quantifier = .required },14973 .{ .kind = .id_ref, .quantifier = .required },
17612 .{ .kind = .id_ref, .quantifier = .required },
17613 },14974 },
17614 },14975 },
17615 .{14976 .{
17616 .name = "s_clamp",14977 .name = "half_powr",
17617 .opcode = 149,14978 .opcode = 75,
17618 .operands = &.{14979 .operands = &.{
17619 .{ .kind = .id_ref, .quantifier = .required },14980 .{ .kind = .id_ref, .quantifier = .required },
17620 .{ .kind = .id_ref, .quantifier = .required },14981 .{ .kind = .id_ref, .quantifier = .required },
17621 .{ .kind = .id_ref, .quantifier = .required },
17622 },14982 },
17623 },14983 },
17624 .{14984 .{
17625 .name = "u_clamp",14985 .name = "half_recip",
17626 .opcode = 150,14986 .opcode = 76,
17627 .operands = &.{14987 .operands = &.{
17628 .{ .kind = .id_ref, .quantifier = .required },14988 .{ .kind = .id_ref, .quantifier = .required },
17629 .{ .kind = .id_ref, .quantifier = .required },
17630 .{ .kind = .id_ref, .quantifier = .required },
17631 },14989 },
17632 },14990 },
17633 .{14991 .{
17634 .name = "clz",14992 .name = "half_rsqrt",
17635 .opcode = 151,14993 .opcode = 77,
17636 .operands = &.{14994 .operands = &.{
17637 .{ .kind = .id_ref, .quantifier = .required },14995 .{ .kind = .id_ref, .quantifier = .required },
17638 },14996 },
17639 },14997 },
17640 .{14998 .{
17641 .name = "ctz",14999 .name = "half_sin",
17642 .opcode = 152,15000 .opcode = 78,
17643 .operands = &.{15001 .operands = &.{
17644 .{ .kind = .id_ref, .quantifier = .required },15002 .{ .kind = .id_ref, .quantifier = .required },
17645 },15003 },
17646 },15004 },
17647 .{15005 .{
17648 .name = "s_mad_hi",15006 .name = "half_sqrt",
17649 .opcode = 153,15007 .opcode = 79,
17650 .operands = &.{15008 .operands = &.{
17651 .{ .kind = .id_ref, .quantifier = .required },15009 .{ .kind = .id_ref, .quantifier = .required },
17652 .{ .kind = .id_ref, .quantifier = .required },
17653 .{ .kind = .id_ref, .quantifier = .required },
17654 },15010 },
17655 },15011 },
17656 .{15012 .{
17657 .name = "u_mad_sat",15013 .name = "half_tan",
17658 .opcode = 154,15014 .opcode = 80,
17659 .operands = &.{15015 .operands = &.{
17660 .{ .kind = .id_ref, .quantifier = .required },15016 .{ .kind = .id_ref, .quantifier = .required },
17661 .{ .kind = .id_ref, .quantifier = .required },
17662 .{ .kind = .id_ref, .quantifier = .required },
17663 },15017 },
17664 },15018 },
17665 .{15019 .{
17666 .name = "s_mad_sat",15020 .name = "native_cos",
17667 .opcode = 155,15021 .opcode = 81,
17668 .operands = &.{15022 .operands = &.{
17669 .{ .kind = .id_ref, .quantifier = .required },15023 .{ .kind = .id_ref, .quantifier = .required },
17670 .{ .kind = .id_ref, .quantifier = .required },
17671 .{ .kind = .id_ref, .quantifier = .required },
17672 },15024 },
17673 },15025 },
17674 .{15026 .{
17675 .name = "s_max",15027 .name = "native_divide",
17676 .opcode = 156,15028 .opcode = 82,
17677 .operands = &.{15029 .operands = &.{
17678 .{ .kind = .id_ref, .quantifier = .required },15030 .{ .kind = .id_ref, .quantifier = .required },
17679 .{ .kind = .id_ref, .quantifier = .required },15031 .{ .kind = .id_ref, .quantifier = .required },
17680 },15032 },
17681 },15033 },
17682 .{15034 .{
17683 .name = "u_max",15035 .name = "native_exp",
17684 .opcode = 157,15036 .opcode = 83,
17685 .operands = &.{15037 .operands = &.{
17686 .{ .kind = .id_ref, .quantifier = .required },15038 .{ .kind = .id_ref, .quantifier = .required },
17687 .{ .kind = .id_ref, .quantifier = .required },
17688 },15039 },
17689 },15040 },
17690 .{15041 .{
17691 .name = "s_min",15042 .name = "native_exp2",
17692 .opcode = 158,15043 .opcode = 84,
17693 .operands = &.{15044 .operands = &.{
17694 .{ .kind = .id_ref, .quantifier = .required },15045 .{ .kind = .id_ref, .quantifier = .required },
17695 .{ .kind = .id_ref, .quantifier = .required },
17696 },15046 },
17697 },15047 },
17698 .{15048 .{
17699 .name = "u_min",15049 .name = "native_exp10",
17700 .opcode = 159,15050 .opcode = 85,
17701 .operands = &.{15051 .operands = &.{
17702 .{ .kind = .id_ref, .quantifier = .required },15052 .{ .kind = .id_ref, .quantifier = .required },
17703 .{ .kind = .id_ref, .quantifier = .required },
17704 },15053 },
17705 },15054 },
17706 .{15055 .{
17707 .name = "s_mul_hi",15056 .name = "native_log",
17708 .opcode = 160,15057 .opcode = 86,
17709 .operands = &.{15058 .operands = &.{
17710 .{ .kind = .id_ref, .quantifier = .required },15059 .{ .kind = .id_ref, .quantifier = .required },
17711 .{ .kind = .id_ref, .quantifier = .required },
17712 },15060 },
17713 },15061 },
17714 .{15062 .{
17715 .name = "rotate",15063 .name = "native_log2",
17716 .opcode = 161,15064 .opcode = 87,
17717 .operands = &.{15065 .operands = &.{
17718 .{ .kind = .id_ref, .quantifier = .required },15066 .{ .kind = .id_ref, .quantifier = .required },
17719 .{ .kind = .id_ref, .quantifier = .required },
17720 },15067 },
17721 },15068 },
17722 .{15069 .{
17723 .name = "s_sub_sat",15070 .name = "native_log10",
17724 .opcode = 162,15071 .opcode = 88,
17725 .operands = &.{15072 .operands = &.{
17726 .{ .kind = .id_ref, .quantifier = .required },15073 .{ .kind = .id_ref, .quantifier = .required },
17727 .{ .kind = .id_ref, .quantifier = .required },
17728 },15074 },
17729 },15075 },
17730 .{15076 .{
17731 .name = "u_sub_sat",15077 .name = "native_powr",
17732 .opcode = 163,15078 .opcode = 89,
17733 .operands = &.{15079 .operands = &.{
17734 .{ .kind = .id_ref, .quantifier = .required },15080 .{ .kind = .id_ref, .quantifier = .required },
17735 .{ .kind = .id_ref, .quantifier = .required },15081 .{ .kind = .id_ref, .quantifier = .required },
17736 },15082 },
17737 },15083 },
17738 .{15084 .{
17739 .name = "u_upsample",15085 .name = "native_recip",
17740 .opcode = 164,15086 .opcode = 90,
17741 .operands = &.{15087 .operands = &.{
17742 .{ .kind = .id_ref, .quantifier = .required },15088 .{ .kind = .id_ref, .quantifier = .required },
17743 .{ .kind = .id_ref, .quantifier = .required },
17744 },15089 },
17745 },15090 },
17746 .{15091 .{
17747 .name = "s_upsample",15092 .name = "native_rsqrt",
17748 .opcode = 165,15093 .opcode = 91,
17749 .operands = &.{15094 .operands = &.{
17750 .{ .kind = .id_ref, .quantifier = .required },15095 .{ .kind = .id_ref, .quantifier = .required },
17751 .{ .kind = .id_ref, .quantifier = .required },
17752 },15096 },
17753 },15097 },
17754 .{15098 .{
17755 .name = "popcount",15099 .name = "native_sin",
17756 .opcode = 166,15100 .opcode = 92,
17757 .operands = &.{15101 .operands = &.{
17758 .{ .kind = .id_ref, .quantifier = .required },15102 .{ .kind = .id_ref, .quantifier = .required },
17759 },15103 },
17760 },15104 },
17761 .{15105 .{
17762 .name = "s_mad24",15106 .name = "native_sqrt",
17763 .opcode = 167,15107 .opcode = 93,
17764 .operands = &.{15108 .operands = &.{
17765 .{ .kind = .id_ref, .quantifier = .required },15109 .{ .kind = .id_ref, .quantifier = .required },
17766 .{ .kind = .id_ref, .quantifier = .required },
17767 .{ .kind = .id_ref, .quantifier = .required },
17768 },15110 },
17769 },15111 },
17770 .{15112 .{
17771 .name = "u_mad24",15113 .name = "native_tan",
17772 .opcode = 168,15114 .opcode = 94,
17773 .operands = &.{15115 .operands = &.{
17774 .{ .kind = .id_ref, .quantifier = .required },15116 .{ .kind = .id_ref, .quantifier = .required },
17775 .{ .kind = .id_ref, .quantifier = .required },
17776 .{ .kind = .id_ref, .quantifier = .required },
17777 },15117 },
17778 },15118 },
17779 .{15119 .{
17780 .name = "s_mul24",15120 .name = "fclamp",
17781 .opcode = 169,15121 .opcode = 95,
17782 .operands = &.{15122 .operands = &.{
17783 .{ .kind = .id_ref, .quantifier = .required },15123 .{ .kind = .id_ref, .quantifier = .required },
17784 .{ .kind = .id_ref, .quantifier = .required },15124 .{ .kind = .id_ref, .quantifier = .required },
15125 .{ .kind = .id_ref, .quantifier = .required },
17785 },15126 },
17786 },15127 },
17787 .{15128 .{
17788 .name = "u_mul24",15129 .name = "degrees",
17789 .opcode = 170,15130 .opcode = 96,
17790 .operands = &.{15131 .operands = &.{
17791 .{ .kind = .id_ref, .quantifier = .required },15132 .{ .kind = .id_ref, .quantifier = .required },
17792 .{ .kind = .id_ref, .quantifier = .required },
17793 },15133 },
17794 },15134 },
17795 .{15135 .{
17796 .name = "vloadn",15136 .name = "fmax_common",
17797 .opcode = 171,15137 .opcode = 97,
17798 .operands = &.{15138 .operands = &.{
17799 .{ .kind = .id_ref, .quantifier = .required },15139 .{ .kind = .id_ref, .quantifier = .required },
17800 .{ .kind = .id_ref, .quantifier = .required },15140 .{ .kind = .id_ref, .quantifier = .required },
17801 .{ .kind = .literal_integer, .quantifier = .required },
17802 },15141 },
17803 },15142 },
17804 .{15143 .{
17805 .name = "vstoren",15144 .name = "fmin_common",
17806 .opcode = 172,15145 .opcode = 98,
17807 .operands = &.{15146 .operands = &.{
17808 .{ .kind = .id_ref, .quantifier = .required },15147 .{ .kind = .id_ref, .quantifier = .required },
17809 .{ .kind = .id_ref, .quantifier = .required },15148 .{ .kind = .id_ref, .quantifier = .required },
17810 .{ .kind = .id_ref, .quantifier = .required },
17811 },15149 },
17812 },15150 },
17813 .{15151 .{
17814 .name = "vload_half",15152 .name = "mix",
17815 .opcode = 173,15153 .opcode = 99,
17816 .operands = &.{15154 .operands = &.{
17817 .{ .kind = .id_ref, .quantifier = .required },15155 .{ .kind = .id_ref, .quantifier = .required },
17818 .{ .kind = .id_ref, .quantifier = .required },15156 .{ .kind = .id_ref, .quantifier = .required },
15157 .{ .kind = .id_ref, .quantifier = .required },
17819 },15158 },
17820 },15159 },
17821 .{15160 .{
17822 .name = "vload_halfn",15161 .name = "radians",
17823 .opcode = 174,15162 .opcode = 100,
17824 .operands = &.{15163 .operands = &.{
17825 .{ .kind = .id_ref, .quantifier = .required },15164 .{ .kind = .id_ref, .quantifier = .required },
17826 .{ .kind = .id_ref, .quantifier = .required },
17827 .{ .kind = .literal_integer, .quantifier = .required },
17828 },15165 },
17829 },15166 },
17830 .{15167 .{
17831 .name = "vstore_half",15168 .name = "step",
17832 .opcode = 175,15169 .opcode = 101,
17833 .operands = &.{15170 .operands = &.{
17834 .{ .kind = .id_ref, .quantifier = .required },15171 .{ .kind = .id_ref, .quantifier = .required },
17835 .{ .kind = .id_ref, .quantifier = .required },15172 .{ .kind = .id_ref, .quantifier = .required },
17836 .{ .kind = .id_ref, .quantifier = .required },
17837 },15173 },
17838 },15174 },
17839 .{15175 .{
17840 .name = "vstore_half_r",15176 .name = "smoothstep",
17841 .opcode = 176,15177 .opcode = 102,
17842 .operands = &.{15178 .operands = &.{
17843 .{ .kind = .id_ref, .quantifier = .required },15179 .{ .kind = .id_ref, .quantifier = .required },
17844 .{ .kind = .id_ref, .quantifier = .required },15180 .{ .kind = .id_ref, .quantifier = .required },
17845 .{ .kind = .id_ref, .quantifier = .required },15181 .{ .kind = .id_ref, .quantifier = .required },
17846 .{ .kind = .fp_rounding_mode, .quantifier = .required },
17847 },15182 },
17848 },15183 },
17849 .{15184 .{
17850 .name = "vstore_halfn",15185 .name = "sign",
17851 .opcode = 177,15186 .opcode = 103,
17852 .operands = &.{15187 .operands = &.{
17853 .{ .kind = .id_ref, .quantifier = .required },15188 .{ .kind = .id_ref, .quantifier = .required },
17854 .{ .kind = .id_ref, .quantifier = .required },
17855 .{ .kind = .id_ref, .quantifier = .required },
17856 },15189 },
17857 },15190 },
17858 .{15191 .{
17859 .name = "vstore_halfn_r",15192 .name = "cross",
17860 .opcode = 178,15193 .opcode = 104,
17861 .operands = &.{15194 .operands = &.{
17862 .{ .kind = .id_ref, .quantifier = .required },15195 .{ .kind = .id_ref, .quantifier = .required },
17863 .{ .kind = .id_ref, .quantifier = .required },15196 .{ .kind = .id_ref, .quantifier = .required },
17864 .{ .kind = .id_ref, .quantifier = .required },
17865 .{ .kind = .fp_rounding_mode, .quantifier = .required },
17866 },15197 },
17867 },15198 },
17868 .{15199 .{
17869 .name = "vloada_halfn",15200 .name = "distance",
17870 .opcode = 179,15201 .opcode = 105,
17871 .operands = &.{15202 .operands = &.{
17872 .{ .kind = .id_ref, .quantifier = .required },15203 .{ .kind = .id_ref, .quantifier = .required },
17873 .{ .kind = .id_ref, .quantifier = .required },15204 .{ .kind = .id_ref, .quantifier = .required },
17874 .{ .kind = .literal_integer, .quantifier = .required },
17875 },15205 },
17876 },15206 },
17877 .{15207 .{
17878 .name = "vstorea_halfn",15208 .name = "length",
17879 .opcode = 180,15209 .opcode = 106,
17880 .operands = &.{15210 .operands = &.{
17881 .{ .kind = .id_ref, .quantifier = .required },15211 .{ .kind = .id_ref, .quantifier = .required },
17882 .{ .kind = .id_ref, .quantifier = .required },
17883 .{ .kind = .id_ref, .quantifier = .required },
17884 },15212 },
17885 },15213 },
17886 .{15214 .{
17887 .name = "vstorea_halfn_r",15215 .name = "normalize",
17888 .opcode = 181,15216 .opcode = 107,
17889 .operands = &.{15217 .operands = &.{
17890 .{ .kind = .id_ref, .quantifier = .required },15218 .{ .kind = .id_ref, .quantifier = .required },
17891 .{ .kind = .id_ref, .quantifier = .required },
17892 .{ .kind = .id_ref, .quantifier = .required },
17893 .{ .kind = .fp_rounding_mode, .quantifier = .required },
17894 },15219 },
17895 },15220 },
17896 .{15221 .{
17897 .name = "shuffle",15222 .name = "fast_distance",
17898 .opcode = 182,15223 .opcode = 108,
17899 .operands = &.{15224 .operands = &.{
17900 .{ .kind = .id_ref, .quantifier = .required },15225 .{ .kind = .id_ref, .quantifier = .required },
17901 .{ .kind = .id_ref, .quantifier = .required },15226 .{ .kind = .id_ref, .quantifier = .required },
17902 },15227 },
17903 },15228 },
17904 .{15229 .{
17905 .name = "shuffle2",15230 .name = "fast_length",
17906 .opcode = 183,15231 .opcode = 109,
17907 .operands = &.{15232 .operands = &.{
17908 .{ .kind = .id_ref, .quantifier = .required },15233 .{ .kind = .id_ref, .quantifier = .required },
17909 .{ .kind = .id_ref, .quantifier = .required },
17910 .{ .kind = .id_ref, .quantifier = .required },
17911 },15234 },
17912 },15235 },
17913 .{15236 .{
17914 .name = "printf",15237 .name = "fast_normalize",
17915 .opcode = 184,15238 .opcode = 110,
17916 .operands = &.{15239 .operands = &.{
17917 .{ .kind = .id_ref, .quantifier = .required },15240 .{ .kind = .id_ref, .quantifier = .required },
17918 .{ .kind = .id_ref, .quantifier = .variadic },
17919 },15241 },
17920 },15242 },
17921 .{15243 .{
17922 .name = "prefetch",15244 .name = "s_abs",
17923 .opcode = 185,15245 .opcode = 141,
17924 .operands = &.{15246 .operands = &.{
17925 .{ .kind = .id_ref, .quantifier = .required },15247 .{ .kind = .id_ref, .quantifier = .required },
17926 .{ .kind = .id_ref, .quantifier = .required },
17927 },15248 },
17928 },15249 },
17929 .{15250 .{
17930 .name = "bitselect",15251 .name = "s_abs_diff",
17931 .opcode = 186,15252 .opcode = 142,
17932 .operands = &.{15253 .operands = &.{
17933 .{ .kind = .id_ref, .quantifier = .required },15254 .{ .kind = .id_ref, .quantifier = .required },
17934 .{ .kind = .id_ref, .quantifier = .required },15255 .{ .kind = .id_ref, .quantifier = .required },
17935 .{ .kind = .id_ref, .quantifier = .required },
17936 },15256 },
17937 },15257 },
17938 .{15258 .{
17939 .name = "select",15259 .name = "s_add_sat",
17940 .opcode = 187,15260 .opcode = 143,
17941 .operands = &.{15261 .operands = &.{
17942 .{ .kind = .id_ref, .quantifier = .required },15262 .{ .kind = .id_ref, .quantifier = .required },
17943 .{ .kind = .id_ref, .quantifier = .required },15263 .{ .kind = .id_ref, .quantifier = .required },
17944 .{ .kind = .id_ref, .quantifier = .required },
17945 },15264 },
17946 },15265 },
17947 .{15266 .{
17948 .name = "u_abs",15267 .name = "u_add_sat",
17949 .opcode = 201,15268 .opcode = 144,
17950 .operands = &.{15269 .operands = &.{
17951 .{ .kind = .id_ref, .quantifier = .required },15270 .{ .kind = .id_ref, .quantifier = .required },
15271 .{ .kind = .id_ref, .quantifier = .required },
17952 },15272 },
17953 },15273 },
17954 .{15274 .{
17955 .name = "u_abs_diff",15275 .name = "s_hadd",
17956 .opcode = 202,15276 .opcode = 145,
17957 .operands = &.{15277 .operands = &.{
17958 .{ .kind = .id_ref, .quantifier = .required },15278 .{ .kind = .id_ref, .quantifier = .required },
17959 .{ .kind = .id_ref, .quantifier = .required },15279 .{ .kind = .id_ref, .quantifier = .required },
17960 },15280 },
17961 },15281 },
17962 .{15282 .{
17963 .name = "u_mul_hi",15283 .name = "u_hadd",
17964 .opcode = 203,15284 .opcode = 146,
17965 .operands = &.{15285 .operands = &.{
17966 .{ .kind = .id_ref, .quantifier = .required },15286 .{ .kind = .id_ref, .quantifier = .required },
17967 .{ .kind = .id_ref, .quantifier = .required },15287 .{ .kind = .id_ref, .quantifier = .required },
17968 },15288 },
17969 },15289 },
17970 .{15290 .{
17971 .name = "u_mad_hi",15291 .name = "s_rhadd",
17972 .opcode = 204,15292 .opcode = 147,
17973 .operands = &.{15293 .operands = &.{
17974 .{ .kind = .id_ref, .quantifier = .required },15294 .{ .kind = .id_ref, .quantifier = .required },
17975 .{ .kind = .id_ref, .quantifier = .required },15295 .{ .kind = .id_ref, .quantifier = .required },
17976 .{ .kind = .id_ref, .quantifier = .required },
17977 },15296 },
17978 },15297 },
17979 },
17980 .@"NonSemantic.Shader.DebugInfo.100" => &.{
17981 .{
17982 .name = "DebugInfoNone",
17983 .opcode = 0,
17984 .operands = &.{},
17985 },
17986 .{15298 .{
17987 .name = "DebugCompilationUnit",15299 .name = "u_rhadd",
17988 .opcode = 1,15300 .opcode = 148,
17989 .operands = &.{15301 .operands = &.{
17990 .{ .kind = .id_ref, .quantifier = .required },15302 .{ .kind = .id_ref, .quantifier = .required },
17991 .{ .kind = .id_ref, .quantifier = .required },15303 .{ .kind = .id_ref, .quantifier = .required },
17992 .{ .kind = .id_ref, .quantifier = .required },
17993 .{ .kind = .id_ref, .quantifier = .required },
17994 },15304 },
17995 },15305 },
17996 .{15306 .{
17997 .name = "DebugTypeBasic",15307 .name = "s_clamp",
17998 .opcode = 2,15308 .opcode = 149,
17999 .operands = &.{15309 .operands = &.{
18000 .{ .kind = .id_ref, .quantifier = .required },15310 .{ .kind = .id_ref, .quantifier = .required },
18001 .{ .kind = .id_ref, .quantifier = .required },15311 .{ .kind = .id_ref, .quantifier = .required },
18002 .{ .kind = .id_ref, .quantifier = .required },15312 .{ .kind = .id_ref, .quantifier = .required },
18003 .{ .kind = .id_ref, .quantifier = .required },
18004 },15313 },
18005 },15314 },
18006 .{15315 .{
18007 .name = "DebugTypePointer",15316 .name = "u_clamp",
18008 .opcode = 3,15317 .opcode = 150,
18009 .operands = &.{15318 .operands = &.{
18010 .{ .kind = .id_ref, .quantifier = .required },15319 .{ .kind = .id_ref, .quantifier = .required },
18011 .{ .kind = .id_ref, .quantifier = .required },15320 .{ .kind = .id_ref, .quantifier = .required },
...@@ -18013,216 +15322,179 @@ pub const InstructionSet = enum {...@@ -18013,216 +15322,179 @@ pub const InstructionSet = enum {
18013 },15322 },
18014 },15323 },
18015 .{15324 .{
18016 .name = "DebugTypeQualifier",15325 .name = "clz",
18017 .opcode = 4,15326 .opcode = 151,
18018 .operands = &.{15327 .operands = &.{
18019 .{ .kind = .id_ref, .quantifier = .required },15328 .{ .kind = .id_ref, .quantifier = .required },
18020 .{ .kind = .id_ref, .quantifier = .required },
18021 },15329 },
18022 },15330 },
18023 .{15331 .{
18024 .name = "DebugTypeArray",15332 .name = "ctz",
18025 .opcode = 5,15333 .opcode = 152,
18026 .operands = &.{15334 .operands = &.{
18027 .{ .kind = .id_ref, .quantifier = .required },15335 .{ .kind = .id_ref, .quantifier = .required },
18028 .{ .kind = .id_ref, .quantifier = .variadic },
18029 },15336 },
18030 },15337 },
18031 .{15338 .{
18032 .name = "DebugTypeVector",15339 .name = "s_mad_hi",
18033 .opcode = 6,15340 .opcode = 153,
18034 .operands = &.{15341 .operands = &.{
18035 .{ .kind = .id_ref, .quantifier = .required },15342 .{ .kind = .id_ref, .quantifier = .required },
18036 .{ .kind = .id_ref, .quantifier = .required },15343 .{ .kind = .id_ref, .quantifier = .required },
15344 .{ .kind = .id_ref, .quantifier = .required },
18037 },15345 },
18038 },15346 },
18039 .{15347 .{
18040 .name = "DebugTypedef",15348 .name = "u_mad_sat",
18041 .opcode = 7,15349 .opcode = 154,
18042 .operands = &.{15350 .operands = &.{
18043 .{ .kind = .id_ref, .quantifier = .required },15351 .{ .kind = .id_ref, .quantifier = .required },
18044 .{ .kind = .id_ref, .quantifier = .required },15352 .{ .kind = .id_ref, .quantifier = .required },
18045 .{ .kind = .id_ref, .quantifier = .required },15353 .{ .kind = .id_ref, .quantifier = .required },
15354 },
15355 },
15356 .{
15357 .name = "s_mad_sat",
15358 .opcode = 155,
15359 .operands = &.{
18046 .{ .kind = .id_ref, .quantifier = .required },15360 .{ .kind = .id_ref, .quantifier = .required },
18047 .{ .kind = .id_ref, .quantifier = .required },15361 .{ .kind = .id_ref, .quantifier = .required },
18048 .{ .kind = .id_ref, .quantifier = .required },15362 .{ .kind = .id_ref, .quantifier = .required },
18049 },15363 },
18050 },15364 },
18051 .{15365 .{
18052 .name = "DebugTypeFunction",15366 .name = "s_max",
18053 .opcode = 8,15367 .opcode = 156,
18054 .operands = &.{15368 .operands = &.{
18055 .{ .kind = .id_ref, .quantifier = .required },15369 .{ .kind = .id_ref, .quantifier = .required },
18056 .{ .kind = .id_ref, .quantifier = .required },15370 .{ .kind = .id_ref, .quantifier = .required },
18057 .{ .kind = .id_ref, .quantifier = .variadic },
18058 },15371 },
18059 },15372 },
18060 .{15373 .{
18061 .name = "DebugTypeEnum",15374 .name = "u_max",
18062 .opcode = 9,15375 .opcode = 157,
18063 .operands = &.{15376 .operands = &.{
18064 .{ .kind = .id_ref, .quantifier = .required },15377 .{ .kind = .id_ref, .quantifier = .required },
18065 .{ .kind = .id_ref, .quantifier = .required },15378 .{ .kind = .id_ref, .quantifier = .required },
18066 .{ .kind = .id_ref, .quantifier = .required },
18067 .{ .kind = .id_ref, .quantifier = .required },
18068 .{ .kind = .id_ref, .quantifier = .required },
18069 .{ .kind = .id_ref, .quantifier = .required },
18070 .{ .kind = .id_ref, .quantifier = .required },
18071 .{ .kind = .id_ref, .quantifier = .required },
18072 .{ .kind = .pair_id_ref_id_ref, .quantifier = .variadic },
18073 },15379 },
18074 },15380 },
18075 .{15381 .{
18076 .name = "DebugTypeComposite",15382 .name = "s_min",
18077 .opcode = 10,15383 .opcode = 158,
18078 .operands = &.{15384 .operands = &.{
18079 .{ .kind = .id_ref, .quantifier = .required },15385 .{ .kind = .id_ref, .quantifier = .required },
18080 .{ .kind = .id_ref, .quantifier = .required },15386 .{ .kind = .id_ref, .quantifier = .required },
18081 .{ .kind = .id_ref, .quantifier = .required },
18082 .{ .kind = .id_ref, .quantifier = .required },
18083 .{ .kind = .id_ref, .quantifier = .required },
18084 .{ .kind = .id_ref, .quantifier = .required },
18085 .{ .kind = .id_ref, .quantifier = .required },
18086 .{ .kind = .id_ref, .quantifier = .required },
18087 .{ .kind = .id_ref, .quantifier = .required },
18088 .{ .kind = .id_ref, .quantifier = .variadic },
18089 },15387 },
18090 },15388 },
18091 .{15389 .{
18092 .name = "DebugTypeMember",15390 .name = "u_min",
18093 .opcode = 11,15391 .opcode = 159,
18094 .operands = &.{15392 .operands = &.{
18095 .{ .kind = .id_ref, .quantifier = .required },15393 .{ .kind = .id_ref, .quantifier = .required },
18096 .{ .kind = .id_ref, .quantifier = .required },15394 .{ .kind = .id_ref, .quantifier = .required },
18097 .{ .kind = .id_ref, .quantifier = .required },
18098 .{ .kind = .id_ref, .quantifier = .required },
18099 .{ .kind = .id_ref, .quantifier = .required },
18100 .{ .kind = .id_ref, .quantifier = .required },
18101 .{ .kind = .id_ref, .quantifier = .required },
18102 .{ .kind = .id_ref, .quantifier = .required },
18103 .{ .kind = .id_ref, .quantifier = .optional },
18104 },15395 },
18105 },15396 },
18106 .{15397 .{
18107 .name = "DebugTypeInheritance",15398 .name = "s_mul_hi",
18108 .opcode = 12,15399 .opcode = 160,
18109 .operands = &.{15400 .operands = &.{
18110 .{ .kind = .id_ref, .quantifier = .required },15401 .{ .kind = .id_ref, .quantifier = .required },
18111 .{ .kind = .id_ref, .quantifier = .required },15402 .{ .kind = .id_ref, .quantifier = .required },
18112 .{ .kind = .id_ref, .quantifier = .required },
18113 .{ .kind = .id_ref, .quantifier = .required },
18114 },15403 },
18115 },15404 },
18116 .{15405 .{
18117 .name = "DebugTypePtrToMember",15406 .name = "rotate",
18118 .opcode = 13,15407 .opcode = 161,
18119 .operands = &.{15408 .operands = &.{
18120 .{ .kind = .id_ref, .quantifier = .required },15409 .{ .kind = .id_ref, .quantifier = .required },
18121 .{ .kind = .id_ref, .quantifier = .required },15410 .{ .kind = .id_ref, .quantifier = .required },
18122 },15411 },
18123 },15412 },
18124 .{15413 .{
18125 .name = "DebugTypeTemplate",15414 .name = "s_sub_sat",
18126 .opcode = 14,15415 .opcode = 162,
18127 .operands = &.{15416 .operands = &.{
18128 .{ .kind = .id_ref, .quantifier = .required },15417 .{ .kind = .id_ref, .quantifier = .required },
18129 .{ .kind = .id_ref, .quantifier = .variadic },15418 .{ .kind = .id_ref, .quantifier = .required },
18130 },15419 },
18131 },15420 },
18132 .{15421 .{
18133 .name = "DebugTypeTemplateParameter",15422 .name = "u_sub_sat",
18134 .opcode = 15,15423 .opcode = 163,
18135 .operands = &.{15424 .operands = &.{
18136 .{ .kind = .id_ref, .quantifier = .required },15425 .{ .kind = .id_ref, .quantifier = .required },
18137 .{ .kind = .id_ref, .quantifier = .required },15426 .{ .kind = .id_ref, .quantifier = .required },
18138 .{ .kind = .id_ref, .quantifier = .required },
18139 .{ .kind = .id_ref, .quantifier = .required },
18140 .{ .kind = .id_ref, .quantifier = .required },
18141 .{ .kind = .id_ref, .quantifier = .required },
18142 },15427 },
18143 },15428 },
18144 .{15429 .{
18145 .name = "DebugTypeTemplateTemplateParameter",15430 .name = "u_upsample",
18146 .opcode = 16,15431 .opcode = 164,
18147 .operands = &.{15432 .operands = &.{
18148 .{ .kind = .id_ref, .quantifier = .required },15433 .{ .kind = .id_ref, .quantifier = .required },
18149 .{ .kind = .id_ref, .quantifier = .required },15434 .{ .kind = .id_ref, .quantifier = .required },
18150 .{ .kind = .id_ref, .quantifier = .required },
18151 .{ .kind = .id_ref, .quantifier = .required },
18152 .{ .kind = .id_ref, .quantifier = .required },
18153 },15435 },
18154 },15436 },
18155 .{15437 .{
18156 .name = "DebugTypeTemplateParameterPack",15438 .name = "s_upsample",
18157 .opcode = 17,15439 .opcode = 165,
18158 .operands = &.{15440 .operands = &.{
18159 .{ .kind = .id_ref, .quantifier = .required },15441 .{ .kind = .id_ref, .quantifier = .required },
18160 .{ .kind = .id_ref, .quantifier = .required },15442 .{ .kind = .id_ref, .quantifier = .required },
18161 .{ .kind = .id_ref, .quantifier = .required },
18162 .{ .kind = .id_ref, .quantifier = .required },
18163 .{ .kind = .id_ref, .quantifier = .variadic },
18164 },15443 },
18165 },15444 },
18166 .{15445 .{
18167 .name = "DebugGlobalVariable",15446 .name = "popcount",
18168 .opcode = 18,15447 .opcode = 166,
18169 .operands = &.{15448 .operands = &.{
18170 .{ .kind = .id_ref, .quantifier = .required },15449 .{ .kind = .id_ref, .quantifier = .required },
18171 .{ .kind = .id_ref, .quantifier = .required },
18172 .{ .kind = .id_ref, .quantifier = .required },
18173 .{ .kind = .id_ref, .quantifier = .required },
18174 .{ .kind = .id_ref, .quantifier = .required },
18175 .{ .kind = .id_ref, .quantifier = .required },
18176 .{ .kind = .id_ref, .quantifier = .required },
18177 .{ .kind = .id_ref, .quantifier = .required },
18178 .{ .kind = .id_ref, .quantifier = .required },
18179 .{ .kind = .id_ref, .quantifier = .optional },
18180 },15450 },
18181 },15451 },
18182 .{15452 .{
18183 .name = "DebugFunctionDeclaration",15453 .name = "s_mad24",
18184 .opcode = 19,15454 .opcode = 167,
18185 .operands = &.{15455 .operands = &.{
18186 .{ .kind = .id_ref, .quantifier = .required },15456 .{ .kind = .id_ref, .quantifier = .required },
18187 .{ .kind = .id_ref, .quantifier = .required },15457 .{ .kind = .id_ref, .quantifier = .required },
18188 .{ .kind = .id_ref, .quantifier = .required },15458 .{ .kind = .id_ref, .quantifier = .required },
18189 .{ .kind = .id_ref, .quantifier = .required },
18190 .{ .kind = .id_ref, .quantifier = .required },
18191 .{ .kind = .id_ref, .quantifier = .required },
18192 .{ .kind = .id_ref, .quantifier = .required },
18193 .{ .kind = .id_ref, .quantifier = .required },
18194 },15459 },
18195 },15460 },
18196 .{15461 .{
18197 .name = "DebugFunction",15462 .name = "u_mad24",
18198 .opcode = 20,15463 .opcode = 168,
18199 .operands = &.{15464 .operands = &.{
18200 .{ .kind = .id_ref, .quantifier = .required },15465 .{ .kind = .id_ref, .quantifier = .required },
18201 .{ .kind = .id_ref, .quantifier = .required },15466 .{ .kind = .id_ref, .quantifier = .required },
18202 .{ .kind = .id_ref, .quantifier = .required },15467 .{ .kind = .id_ref, .quantifier = .required },
15468 },
15469 },
15470 .{
15471 .name = "s_mul24",
15472 .opcode = 169,
15473 .operands = &.{
18203 .{ .kind = .id_ref, .quantifier = .required },15474 .{ .kind = .id_ref, .quantifier = .required },
18204 .{ .kind = .id_ref, .quantifier = .required },15475 .{ .kind = .id_ref, .quantifier = .required },
18205 .{ .kind = .id_ref, .quantifier = .required },
18206 .{ .kind = .id_ref, .quantifier = .required },
18207 .{ .kind = .id_ref, .quantifier = .required },
18208 .{ .kind = .id_ref, .quantifier = .required },
18209 .{ .kind = .id_ref, .quantifier = .optional },
18210 },15476 },
18211 },15477 },
18212 .{15478 .{
18213 .name = "DebugLexicalBlock",15479 .name = "u_mul24",
18214 .opcode = 21,15480 .opcode = 170,
18215 .operands = &.{15481 .operands = &.{
18216 .{ .kind = .id_ref, .quantifier = .required },15482 .{ .kind = .id_ref, .quantifier = .required },
18217 .{ .kind = .id_ref, .quantifier = .required },15483 .{ .kind = .id_ref, .quantifier = .required },
15484 },
15485 },
15486 .{
15487 .name = "vloadn",
15488 .opcode = 171,
15489 .operands = &.{
18218 .{ .kind = .id_ref, .quantifier = .required },15490 .{ .kind = .id_ref, .quantifier = .required },
18219 .{ .kind = .id_ref, .quantifier = .required },15491 .{ .kind = .id_ref, .quantifier = .required },
18220 .{ .kind = .id_ref, .quantifier = .optional },15492 .{ .kind = .literal_integer, .quantifier = .required },
18221 },15493 },
18222 },15494 },
18223 .{15495 .{
18224 .name = "DebugLexicalBlockDiscriminator",15496 .name = "vstoren",
18225 .opcode = 22,15497 .opcode = 172,
18226 .operands = &.{15498 .operands = &.{
18227 .{ .kind = .id_ref, .quantifier = .required },15499 .{ .kind = .id_ref, .quantifier = .required },
18228 .{ .kind = .id_ref, .quantifier = .required },15500 .{ .kind = .id_ref, .quantifier = .required },
...@@ -18230,183 +15502,165 @@ pub const InstructionSet = enum {...@@ -18230,183 +15502,165 @@ pub const InstructionSet = enum {
18230 },15502 },
18231 },15503 },
18232 .{15504 .{
18233 .name = "DebugScope",15505 .name = "vload_half",
18234 .opcode = 23,15506 .opcode = 173,
18235 .operands = &.{15507 .operands = &.{
18236 .{ .kind = .id_ref, .quantifier = .required },15508 .{ .kind = .id_ref, .quantifier = .required },
18237 .{ .kind = .id_ref, .quantifier = .optional },15509 .{ .kind = .id_ref, .quantifier = .required },
18238 },15510 },
18239 },15511 },
18240 .{15512 .{
18241 .name = "DebugNoScope",15513 .name = "vload_halfn",
18242 .opcode = 24,15514 .opcode = 174,
18243 .operands = &.{},
18244 },
18245 .{
18246 .name = "DebugInlinedAt",
18247 .opcode = 25,
18248 .operands = &.{15515 .operands = &.{
18249 .{ .kind = .id_ref, .quantifier = .required },15516 .{ .kind = .id_ref, .quantifier = .required },
18250 .{ .kind = .id_ref, .quantifier = .required },15517 .{ .kind = .id_ref, .quantifier = .required },
18251 .{ .kind = .id_ref, .quantifier = .optional },15518 .{ .kind = .literal_integer, .quantifier = .required },
18252 },15519 },
18253 },15520 },
18254 .{15521 .{
18255 .name = "DebugLocalVariable",15522 .name = "vstore_half",
18256 .opcode = 26,15523 .opcode = 175,
18257 .operands = &.{15524 .operands = &.{
18258 .{ .kind = .id_ref, .quantifier = .required },15525 .{ .kind = .id_ref, .quantifier = .required },
18259 .{ .kind = .id_ref, .quantifier = .required },15526 .{ .kind = .id_ref, .quantifier = .required },
18260 .{ .kind = .id_ref, .quantifier = .required },15527 .{ .kind = .id_ref, .quantifier = .required },
18261 .{ .kind = .id_ref, .quantifier = .required },
18262 .{ .kind = .id_ref, .quantifier = .required },
18263 .{ .kind = .id_ref, .quantifier = .required },
18264 .{ .kind = .id_ref, .quantifier = .required },
18265 .{ .kind = .id_ref, .quantifier = .optional },
18266 },15528 },
18267 },15529 },
18268 .{15530 .{
18269 .name = "DebugInlinedVariable",15531 .name = "vstore_half_r",
18270 .opcode = 27,15532 .opcode = 176,
18271 .operands = &.{15533 .operands = &.{
18272 .{ .kind = .id_ref, .quantifier = .required },15534 .{ .kind = .id_ref, .quantifier = .required },
18273 .{ .kind = .id_ref, .quantifier = .required },15535 .{ .kind = .id_ref, .quantifier = .required },
15536 .{ .kind = .id_ref, .quantifier = .required },
15537 .{ .kind = .fp_rounding_mode, .quantifier = .required },
18274 },15538 },
18275 },15539 },
18276 .{15540 .{
18277 .name = "DebugDeclare",15541 .name = "vstore_halfn",
18278 .opcode = 28,15542 .opcode = 177,
18279 .operands = &.{15543 .operands = &.{
18280 .{ .kind = .id_ref, .quantifier = .required },15544 .{ .kind = .id_ref, .quantifier = .required },
18281 .{ .kind = .id_ref, .quantifier = .required },15545 .{ .kind = .id_ref, .quantifier = .required },
18282 .{ .kind = .id_ref, .quantifier = .required },15546 .{ .kind = .id_ref, .quantifier = .required },
18283 .{ .kind = .id_ref, .quantifier = .variadic },
18284 },15547 },
18285 },15548 },
18286 .{15549 .{
18287 .name = "DebugValue",15550 .name = "vstore_halfn_r",
18288 .opcode = 29,15551 .opcode = 178,
18289 .operands = &.{15552 .operands = &.{
18290 .{ .kind = .id_ref, .quantifier = .required },15553 .{ .kind = .id_ref, .quantifier = .required },
18291 .{ .kind = .id_ref, .quantifier = .required },15554 .{ .kind = .id_ref, .quantifier = .required },
18292 .{ .kind = .id_ref, .quantifier = .required },15555 .{ .kind = .id_ref, .quantifier = .required },
18293 .{ .kind = .id_ref, .quantifier = .variadic },15556 .{ .kind = .fp_rounding_mode, .quantifier = .required },
18294 },15557 },
18295 },15558 },
18296 .{15559 .{
18297 .name = "DebugOperation",15560 .name = "vloada_halfn",
18298 .opcode = 30,15561 .opcode = 179,
18299 .operands = &.{15562 .operands = &.{
18300 .{ .kind = .id_ref, .quantifier = .required },15563 .{ .kind = .id_ref, .quantifier = .required },
18301 .{ .kind = .id_ref, .quantifier = .variadic },15564 .{ .kind = .id_ref, .quantifier = .required },
15565 .{ .kind = .literal_integer, .quantifier = .required },
18302 },15566 },
18303 },15567 },
18304 .{15568 .{
18305 .name = "DebugExpression",15569 .name = "vstorea_halfn",
18306 .opcode = 31,15570 .opcode = 180,
18307 .operands = &.{15571 .operands = &.{
18308 .{ .kind = .id_ref, .quantifier = .variadic },15572 .{ .kind = .id_ref, .quantifier = .required },
15573 .{ .kind = .id_ref, .quantifier = .required },
15574 .{ .kind = .id_ref, .quantifier = .required },
18309 },15575 },
18310 },15576 },
18311 .{15577 .{
18312 .name = "DebugMacroDef",15578 .name = "vstorea_halfn_r",
18313 .opcode = 32,15579 .opcode = 181,
18314 .operands = &.{15580 .operands = &.{
18315 .{ .kind = .id_ref, .quantifier = .required },15581 .{ .kind = .id_ref, .quantifier = .required },
18316 .{ .kind = .id_ref, .quantifier = .required },15582 .{ .kind = .id_ref, .quantifier = .required },
18317 .{ .kind = .id_ref, .quantifier = .required },15583 .{ .kind = .id_ref, .quantifier = .required },
18318 .{ .kind = .id_ref, .quantifier = .optional },15584 .{ .kind = .fp_rounding_mode, .quantifier = .required },
18319 },15585 },
18320 },15586 },
18321 .{15587 .{
18322 .name = "DebugMacroUndef",15588 .name = "shuffle",
18323 .opcode = 33,15589 .opcode = 182,
18324 .operands = &.{15590 .operands = &.{
18325 .{ .kind = .id_ref, .quantifier = .required },15591 .{ .kind = .id_ref, .quantifier = .required },
18326 .{ .kind = .id_ref, .quantifier = .required },15592 .{ .kind = .id_ref, .quantifier = .required },
18327 .{ .kind = .id_ref, .quantifier = .required },
18328 },15593 },
18329 },15594 },
18330 .{15595 .{
18331 .name = "DebugImportedEntity",15596 .name = "shuffle2",
18332 .opcode = 34,15597 .opcode = 183,
18333 .operands = &.{15598 .operands = &.{
18334 .{ .kind = .id_ref, .quantifier = .required },15599 .{ .kind = .id_ref, .quantifier = .required },
18335 .{ .kind = .id_ref, .quantifier = .required },15600 .{ .kind = .id_ref, .quantifier = .required },
18336 .{ .kind = .id_ref, .quantifier = .required },15601 .{ .kind = .id_ref, .quantifier = .required },
18337 .{ .kind = .id_ref, .quantifier = .required },
18338 .{ .kind = .id_ref, .quantifier = .required },
18339 .{ .kind = .id_ref, .quantifier = .required },
18340 .{ .kind = .id_ref, .quantifier = .required },
18341 },15602 },
18342 },15603 },
18343 .{15604 .{
18344 .name = "DebugSource",15605 .name = "printf",
18345 .opcode = 35,15606 .opcode = 184,
18346 .operands = &.{15607 .operands = &.{
18347 .{ .kind = .id_ref, .quantifier = .required },15608 .{ .kind = .id_ref, .quantifier = .required },
18348 .{ .kind = .id_ref, .quantifier = .optional },15609 .{ .kind = .id_ref, .quantifier = .variadic },
18349 },15610 },
18350 },15611 },
18351 .{15612 .{
18352 .name = "DebugFunctionDefinition",15613 .name = "prefetch",
18353 .opcode = 101,15614 .opcode = 185,
18354 .operands = &.{15615 .operands = &.{
18355 .{ .kind = .id_ref, .quantifier = .required },15616 .{ .kind = .id_ref, .quantifier = .required },
18356 .{ .kind = .id_ref, .quantifier = .required },15617 .{ .kind = .id_ref, .quantifier = .required },
18357 },15618 },
18358 },15619 },
18359 .{15620 .{
18360 .name = "DebugSourceContinued",15621 .name = "bitselect",
18361 .opcode = 102,15622 .opcode = 186,
18362 .operands = &.{15623 .operands = &.{
18363 .{ .kind = .id_ref, .quantifier = .required },15624 .{ .kind = .id_ref, .quantifier = .required },
15625 .{ .kind = .id_ref, .quantifier = .required },
15626 .{ .kind = .id_ref, .quantifier = .required },
18364 },15627 },
18365 },15628 },
18366 .{15629 .{
18367 .name = "DebugLine",15630 .name = "select",
18368 .opcode = 103,15631 .opcode = 187,
18369 .operands = &.{15632 .operands = &.{
18370 .{ .kind = .id_ref, .quantifier = .required },15633 .{ .kind = .id_ref, .quantifier = .required },
18371 .{ .kind = .id_ref, .quantifier = .required },15634 .{ .kind = .id_ref, .quantifier = .required },
18372 .{ .kind = .id_ref, .quantifier = .required },15635 .{ .kind = .id_ref, .quantifier = .required },
18373 .{ .kind = .id_ref, .quantifier = .required },
18374 .{ .kind = .id_ref, .quantifier = .required },
18375 },15636 },
18376 },15637 },
18377 .{15638 .{
18378 .name = "DebugNoLine",15639 .name = "u_abs",
18379 .opcode = 104,15640 .opcode = 201,
18380 .operands = &.{},
18381 },
18382 .{
18383 .name = "DebugBuildIdentifier",
18384 .opcode = 105,
18385 .operands = &.{15641 .operands = &.{
18386 .{ .kind = .id_ref, .quantifier = .required },15642 .{ .kind = .id_ref, .quantifier = .required },
18387 .{ .kind = .id_ref, .quantifier = .required },
18388 },15643 },
18389 },15644 },
18390 .{15645 .{
18391 .name = "DebugStoragePath",15646 .name = "u_abs_diff",
18392 .opcode = 106,15647 .opcode = 202,
18393 .operands = &.{15648 .operands = &.{
18394 .{ .kind = .id_ref, .quantifier = .required },15649 .{ .kind = .id_ref, .quantifier = .required },
15650 .{ .kind = .id_ref, .quantifier = .required },
18395 },15651 },
18396 },15652 },
18397 .{15653 .{
18398 .name = "DebugEntryPoint",15654 .name = "u_mul_hi",
18399 .opcode = 107,15655 .opcode = 203,
18400 .operands = &.{15656 .operands = &.{
18401 .{ .kind = .id_ref, .quantifier = .required },15657 .{ .kind = .id_ref, .quantifier = .required },
18402 .{ .kind = .id_ref, .quantifier = .required },15658 .{ .kind = .id_ref, .quantifier = .required },
18403 .{ .kind = .id_ref, .quantifier = .required },
18404 .{ .kind = .id_ref, .quantifier = .required },
18405 },15659 },
18406 },15660 },
18407 .{15661 .{
18408 .name = "DebugTypeMatrix",15662 .name = "u_mad_hi",
18409 .opcode = 108,15663 .opcode = 204,
18410 .operands = &.{15664 .operands = &.{
18411 .{ .kind = .id_ref, .quantifier = .required },15665 .{ .kind = .id_ref, .quantifier = .required },
18412 .{ .kind = .id_ref, .quantifier = .required },15666 .{ .kind = .id_ref, .quantifier = .required },
src/link/SpirV.zig+31-7
...@@ -23,6 +23,7 @@ const Linker = @This();...@@ -23,6 +23,7 @@ const Linker = @This();
2323
24base: link.File,24base: link.File,
25module: Module,25module: Module,
26cg: CodeGen,
2627
27pub fn createEmpty(28pub fn createEmpty(
28 arena: Allocator,29 arena: Allocator,
...@@ -63,6 +64,16 @@ pub fn createEmpty(...@@ -63,6 +64,16 @@ pub fn createEmpty(
63 .arena = arena,64 .arena = arena,
64 .zcu = comp.zcu.?,65 .zcu = comp.zcu.?,
65 },66 },
67 .cg = .{
68 // These fields are populated in generate()
69 .pt = undefined,
70 .air = undefined,
71 .liveness = undefined,
72 .owner_nav = undefined,
73 .module = undefined,
74 .control_flow = .{ .structured = .{} },
75 .base_line = undefined,
76 },
66 };77 };
67 errdefer linker.deinit();78 errdefer linker.deinit();
6879
...@@ -84,6 +95,7 @@ pub fn open(...@@ -84,6 +95,7 @@ pub fn open(
84}95}
8596
86pub fn deinit(linker: *Linker) void {97pub fn deinit(linker: *Linker) void {
98 linker.cg.deinit();
87 linker.module.deinit();99 linker.module.deinit();
88}100}
89101
...@@ -99,29 +111,41 @@ fn generate(...@@ -99,29 +111,41 @@ fn generate(
99 const gpa = zcu.gpa;111 const gpa = zcu.gpa;
100 const structured_cfg = zcu.navFileScope(nav_index).mod.?.structured_cfg;112 const structured_cfg = zcu.navFileScope(nav_index).mod.?.structured_cfg;
101113
102 var cg: CodeGen = .{114 linker.cg.control_flow.deinit(gpa);
115 linker.cg.args.clearRetainingCapacity();
116 linker.cg.inst_results.clearRetainingCapacity();
117 linker.cg.id_scratch.clearRetainingCapacity();
118 linker.cg.prologue.reset();
119 linker.cg.body.reset();
120
121 linker.cg = .{
103 .pt = pt,122 .pt = pt,
104 .module = &linker.module,
105 .owner_nav = nav_index,
106 .air = air,123 .air = air,
107 .liveness = liveness,124 .liveness = liveness,
125 .owner_nav = nav_index,
126 .module = &linker.module,
108 .control_flow = switch (structured_cfg) {127 .control_flow = switch (structured_cfg) {
109 true => .{ .structured = .{} },128 true => .{ .structured = .{} },
110 false => .{ .unstructured = .{} },129 false => .{ .unstructured = .{} },
111 },130 },
112 .base_line = zcu.navSrcLine(nav_index),131 .base_line = zcu.navSrcLine(nav_index),
132
133 .args = linker.cg.args,
134 .inst_results = linker.cg.inst_results,
135 .id_scratch = linker.cg.id_scratch,
136 .prologue = linker.cg.prologue,
137 .body = linker.cg.body,
113 };138 };
114 defer cg.deinit();
115139
116 cg.genNav(do_codegen) catch |err| switch (err) {140 linker.cg.genNav(do_codegen) catch |err| switch (err) {
117 error.CodegenFail => switch (zcu.codegenFailMsg(nav_index, cg.error_msg.?)) {141 error.CodegenFail => switch (zcu.codegenFailMsg(nav_index, linker.cg.error_msg.?)) {
118 error.CodegenFail => {},142 error.CodegenFail => {},
119 error.OutOfMemory => |e| return e,143 error.OutOfMemory => |e| return e,
120 },144 },
121 else => |other| {145 else => |other| {
122 // There might be an error that happened *after* linker.error_msg146 // There might be an error that happened *after* linker.error_msg
123 // was already allocated, so be sure to free it.147 // was already allocated, so be sure to free it.
124 if (cg.error_msg) |error_msg| {148 if (linker.cg.error_msg) |error_msg| {
125 error_msg.deinit(gpa);149 error_msg.deinit(gpa);
126 }150 }
127151
tools/gen_spirv_spec.zig+81-60
...@@ -12,6 +12,7 @@ const ExtendedStructSet = std.StringHashMap(void);...@@ -12,6 +12,7 @@ const ExtendedStructSet = std.StringHashMap(void);
1212
13const Extension = struct {13const Extension = struct {
14 name: []const u8,14 name: []const u8,
15 opcode_name: []const u8,
15 spec: ExtensionRegistry,16 spec: ExtensionRegistry,
16};17};
1718
...@@ -44,23 +45,11 @@ const OperandKindMap = std.ArrayHashMap(StringPair, OperandKind, StringPairConte...@@ -44,23 +45,11 @@ const OperandKindMap = std.ArrayHashMap(StringPair, OperandKind, StringPairConte
4445
45/// Khronos made it so that these names are not defined explicitly, so46/// Khronos made it so that these names are not defined explicitly, so
46/// we need to hardcode it (like they did).47/// we need to hardcode it (like they did).
47/// See https://github.com/KhronosGroup/SPIRV-Registry/48/// See https://github.com/KhronosGroup/SPIRV-Registry
48const set_names = std.StaticStringMap([]const u8).initComptime(.{49const set_names = std.StaticStringMap(struct { []const u8, []const u8 }).initComptime(.{
49 .{ "opencl.std.100", "OpenCL.std" },50 .{ "opencl.std.100", .{ "OpenCL.std", "OpenClOpcode" } },
50 .{ "glsl.std.450", "GLSL.std.450" },51 .{ "glsl.std.450", .{ "GLSL.std.450", "GlslOpcode" } },
51 .{ "opencl.debuginfo.100", "OpenCL.DebugInfo.100" },52 .{ "zig", .{ "zig", "Zig" } },
52 .{ "spv-amd-shader-ballot", "SPV_AMD_shader_ballot" },
53 .{ "nonsemantic.shader.debuginfo.100", "NonSemantic.Shader.DebugInfo.100" },
54 .{ "nonsemantic.vkspreflection", "NonSemantic.VkspReflection" },
55 .{ "nonsemantic.clspvreflection", "NonSemantic.ClspvReflection.6" }, // This version needs to be handled manually
56 .{ "spv-amd-gcn-shader", "SPV_AMD_gcn_shader" },
57 .{ "spv-amd-shader-trinary-minmax", "SPV_AMD_shader_trinary_minmax" },
58 .{ "debuginfo", "DebugInfo" },
59 .{ "nonsemantic.debugprintf", "NonSemantic.DebugPrintf" },
60 .{ "spv-amd-shader-explicit-vertex-parameter", "SPV_AMD_shader_explicit_vertex_parameter" },
61 .{ "nonsemantic.debugbreak", "NonSemantic.DebugBreak" },
62 .{ "tosa.001000.1", "SPV_EXT_INST_TYPE_TOSA_001000_1" },
63 .{ "zig", "zig" },
64});53});
6554
66var arena = std.heap.ArenaAllocator.init(std.heap.smp_allocator);55var arena = std.heap.ArenaAllocator.init(std.heap.smp_allocator);
...@@ -78,7 +67,7 @@ pub fn main() !void {...@@ -78,7 +67,7 @@ pub fn main() !void {
78 const dir = try std.fs.cwd().openDir(json_path, .{ .iterate = true });67 const dir = try std.fs.cwd().openDir(json_path, .{ .iterate = true });
7968
80 const core_spec = try readRegistry(CoreRegistry, dir, "spirv.core.grammar.json");69 const core_spec = try readRegistry(CoreRegistry, dir, "spirv.core.grammar.json");
81 std.sort.block(Instruction, core_spec.instructions, CmpInst{}, CmpInst.lt);70 std.mem.sortUnstable(Instruction, core_spec.instructions, CmpInst{}, CmpInst.lt);
8271
83 var exts = std.ArrayList(Extension).init(allocator);72 var exts = std.ArrayList(Extension).init(allocator);
8473
...@@ -134,14 +123,24 @@ fn readExtRegistry(exts: *std.ArrayList(Extension), dir: std.fs.Dir, sub_path: [...@@ -134,14 +123,24 @@ fn readExtRegistry(exts: *std.ArrayList(Extension), dir: std.fs.Dir, sub_path: [
134 const name = filename["extinst.".len .. filename.len - ".grammar.json".len];123 const name = filename["extinst.".len .. filename.len - ".grammar.json".len];
135 const spec = try readRegistry(ExtensionRegistry, dir, sub_path);124 const spec = try readRegistry(ExtensionRegistry, dir, sub_path);
136125
126 const set_name = set_names.get(name) orelse {
127 std.log.info("ignored instruction set '{s}'", .{name});
128 return;
129 };
130
137 std.sort.block(Instruction, spec.instructions, CmpInst{}, CmpInst.lt);131 std.sort.block(Instruction, spec.instructions, CmpInst{}, CmpInst.lt);
138132
139 try exts.append(.{ .name = set_names.get(name).?, .spec = spec });133 try exts.append(.{
134 .name = set_name.@"0",
135 .opcode_name = set_name.@"1",
136 .spec = spec,
137 });
140}138}
141139
142fn readRegistry(comptime RegistryType: type, dir: std.fs.Dir, path: []const u8) !RegistryType {140fn readRegistry(comptime RegistryType: type, dir: std.fs.Dir, path: []const u8) !RegistryType {
143 const spec = try dir.readFileAlloc(allocator, path, std.math.maxInt(usize));141 const spec = try dir.readFileAlloc(allocator, path, std.math.maxInt(usize));
144 // Required for json parsing.142 // Required for json parsing.
143 // TODO: ALI
145 @setEvalBranchQuota(10000);144 @setEvalBranchQuota(10000);
146145
147 var scanner = std.json.Scanner.initCompleteInput(allocator, spec);146 var scanner = std.json.Scanner.initCompleteInput(allocator, spec);
...@@ -191,7 +190,11 @@ fn tagPriorityScore(tag: []const u8) usize {...@@ -191,7 +190,11 @@ fn tagPriorityScore(tag: []const u8) usize {
191 }190 }
192}191}
193192
194fn render(writer: *std.io.Writer, registry: CoreRegistry, extensions: []const Extension) !void {193fn render(
194 writer: *std.io.Writer,
195 registry: CoreRegistry,
196 extensions: []const Extension,
197) !void {
195 try writer.writeAll(198 try writer.writeAll(
196 \\//! This file is auto-generated by tools/gen_spirv_spec.zig.199 \\//! This file is auto-generated by tools/gen_spirv_spec.zig.
197 \\200 \\
...@@ -317,13 +320,18 @@ fn render(writer: *std.io.Writer, registry: CoreRegistry, extensions: []const Ex...@@ -317,13 +320,18 @@ fn render(writer: *std.io.Writer, registry: CoreRegistry, extensions: []const Ex
317 // Note: extensions don't seem to have class.320 // Note: extensions don't seem to have class.
318 try renderClass(writer, registry.instructions);321 try renderClass(writer, registry.instructions);
319 try renderOperandKind(writer, all_operand_kinds.values());322 try renderOperandKind(writer, all_operand_kinds.values());
320 try renderOpcodes(writer, registry.instructions, extended_structs);323
324 try renderOpcodes(writer, "Opcode", true, registry.instructions, extended_structs);
325 for (extensions) |ext| {
326 try renderOpcodes(writer, ext.opcode_name, false, ext.spec.instructions, extended_structs);
327 }
328
321 try renderOperandKinds(writer, all_operand_kinds.values(), extended_structs);329 try renderOperandKinds(writer, all_operand_kinds.values(), extended_structs);
322 try renderInstructionSet(writer, registry, extensions, all_operand_kinds);330 try renderInstructionSet(writer, registry, extensions, all_operand_kinds);
323}331}
324332
325fn renderInstructionSet(333fn renderInstructionSet(
326 writer: anytype,334 writer: *std.io.Writer,
327 core: CoreRegistry,335 core: CoreRegistry,
328 extensions: []const Extension,336 extensions: []const Extension,
329 all_operand_kinds: OperandKindMap,337 all_operand_kinds: OperandKindMap,
...@@ -358,7 +366,7 @@ fn renderInstructionSet(...@@ -358,7 +366,7 @@ fn renderInstructionSet(
358}366}
359367
360fn renderInstructionsCase(368fn renderInstructionsCase(
361 writer: anytype,369 writer: *std.io.Writer,
362 set_name: []const u8,370 set_name: []const u8,
363 instructions: []const Instruction,371 instructions: []const Instruction,
364 all_operand_kinds: OperandKindMap,372 all_operand_kinds: OperandKindMap,
...@@ -405,7 +413,7 @@ fn renderInstructionsCase(...@@ -405,7 +413,7 @@ fn renderInstructionsCase(
405 );413 );
406}414}
407415
408fn renderClass(writer: anytype, instructions: []const Instruction) !void {416fn renderClass(writer: *std.io.Writer, instructions: []const Instruction) !void {
409 var class_map = std.StringArrayHashMap(void).init(allocator);417 var class_map = std.StringArrayHashMap(void).init(allocator);
410418
411 for (instructions) |inst| {419 for (instructions) |inst| {
...@@ -454,7 +462,7 @@ fn formatId(identifier: []const u8) std.fmt.Alt(Formatter, Formatter.format) {...@@ -454,7 +462,7 @@ fn formatId(identifier: []const u8) std.fmt.Alt(Formatter, Formatter.format) {
454 return .{ .data = .{ .data = identifier } };462 return .{ .data = .{ .data = identifier } };
455}463}
456464
457fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void {465fn renderOperandKind(writer: *std.io.Writer, operands: []const OperandKind) !void {
458 try writer.writeAll(466 try writer.writeAll(
459 \\pub const OperandKind = enum {467 \\pub const OperandKind = enum {
460 \\ opcode,468 \\ opcode,
...@@ -510,7 +518,7 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void {...@@ -510,7 +518,7 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void {
510 try writer.writeAll("};\n}\n};\n");518 try writer.writeAll("};\n}\n};\n");
511}519}
512520
513fn renderEnumerant(writer: anytype, enumerant: Enumerant) !void {521fn renderEnumerant(writer: *std.io.Writer, enumerant: Enumerant) !void {
514 try writer.print(".{{.name = \"{s}\", .value = ", .{enumerant.enumerant});522 try writer.print(".{{.name = \"{s}\", .value = ", .{enumerant.enumerant});
515 switch (enumerant.value) {523 switch (enumerant.value) {
516 .bitflag => |flag| try writer.writeAll(flag),524 .bitflag => |flag| try writer.writeAll(flag),
...@@ -527,7 +535,9 @@ fn renderEnumerant(writer: anytype, enumerant: Enumerant) !void {...@@ -527,7 +535,9 @@ fn renderEnumerant(writer: anytype, enumerant: Enumerant) !void {
527}535}
528536
529fn renderOpcodes(537fn renderOpcodes(
530 writer: anytype,538 writer: *std.io.Writer,
539 opcode_type_name: []const u8,
540 want_operands: bool,
531 instructions: []const Instruction,541 instructions: []const Instruction,
532 extended_structs: ExtendedStructSet,542 extended_structs: ExtendedStructSet,
533) !void {543) !void {
...@@ -538,7 +548,9 @@ fn renderOpcodes(...@@ -538,7 +548,9 @@ fn renderOpcodes(
538 try aliases.ensureTotalCapacity(instructions.len);548 try aliases.ensureTotalCapacity(instructions.len);
539549
540 for (instructions, 0..) |inst, i| {550 for (instructions, 0..) |inst, i| {
541 if (std.mem.eql(u8, inst.class.?, "@exclude")) continue;551 if (inst.class) |class| {
552 if (std.mem.eql(u8, class, "@exclude")) continue;
553 }
542554
543 const result = inst_map.getOrPutAssumeCapacity(inst.opcode);555 const result = inst_map.getOrPutAssumeCapacity(inst.opcode);
544 if (!result.found_existing) {556 if (!result.found_existing) {
...@@ -562,58 +574,67 @@ fn renderOpcodes(...@@ -562,58 +574,67 @@ fn renderOpcodes(
562574
563 const instructions_indices = inst_map.values();575 const instructions_indices = inst_map.values();
564576
565 try writer.writeAll("pub const Opcode = enum(u16) {\n");577 try writer.print("\npub const {f} = enum(u16) {{\n", .{std.zig.fmtId(opcode_type_name)});
566 for (instructions_indices) |i| {578 for (instructions_indices) |i| {
567 const inst = instructions[i];579 const inst = instructions[i];
568 try writer.print("{f} = {},\n", .{ std.zig.fmtId(inst.opname), inst.opcode });580 try writer.print("{f} = {},\n", .{ std.zig.fmtId(inst.opname), inst.opcode });
569 }581 }
570582
571 try writer.writeAll(583 try writer.writeAll("\n");
572 \\
573 );
574584
575 for (aliases.items) |alias| {585 for (aliases.items) |alias| {
576 try writer.print("pub const {f} = Opcode.{f};\n", .{586 try writer.print("pub const {f} = {f}.{f};\n", .{
577 formatId(instructions[alias.inst].opname),587 formatId(instructions[alias.inst].opname),
588 std.zig.fmtId(opcode_type_name),
578 formatId(instructions[alias.alias].opname),589 formatId(instructions[alias.alias].opname),
579 });590 });
580 }591 }
581592
582 try writer.writeAll(593 if (want_operands) {
583 \\594 try writer.print(
584 \\pub fn Operands(comptime self: Opcode) type {595 \\
585 \\ return switch (self) {596 \\pub fn Operands(comptime self: {f}) type {{
586 \\597 \\ return switch (self) {{
587 );598 \\
599 , .{std.zig.fmtId(opcode_type_name)});
588600
589 for (instructions_indices) |i| {601 for (instructions_indices) |i| {
590 const inst = instructions[i];602 const inst = instructions[i];
591 try renderOperand(writer, .instruction, inst.opname, inst.operands, extended_structs, false);603 try renderOperand(writer, .instruction, inst.opname, inst.operands, extended_structs, false);
592 }604 }
593605
594 try writer.writeAll(606 try writer.writeAll(
595 \\ };607 \\ };
596 \\}608 \\}
597 \\pub fn class(self: Opcode) Class {609 \\
598 \\ return switch (self) {610 );
599 \\
600 );
601611
602 for (instructions_indices) |i| {612 try writer.print(
603 const inst = instructions[i];613 \\pub fn class(self: {f}) Class {{
604 try writer.print(".{f} => .{f},\n", .{ std.zig.fmtId(inst.opname), formatId(inst.class.?) });614 \\ return switch (self) {{
615 \\
616 , .{std.zig.fmtId(opcode_type_name)});
617
618 for (instructions_indices) |i| {
619 const inst = instructions[i];
620 try writer.print(".{f} => .{f},\n", .{ std.zig.fmtId(inst.opname), formatId(inst.class.?) });
621 }
622
623 try writer.writeAll(
624 \\ };
625 \\}
626 \\
627 );
605 }628 }
606629
607 try writer.writeAll(630 try writer.writeAll(
608 \\ };
609 \\}
610 \\};631 \\};
611 \\632 \\
612 );633 );
613}634}
614635
615fn renderOperandKinds(636fn renderOperandKinds(
616 writer: anytype,637 writer: *std.io.Writer,
617 kinds: []const OperandKind,638 kinds: []const OperandKind,
618 extended_structs: ExtendedStructSet,639 extended_structs: ExtendedStructSet,
619) !void {640) !void {
...@@ -627,7 +648,7 @@ fn renderOperandKinds(...@@ -627,7 +648,7 @@ fn renderOperandKinds(
627}648}
628649
629fn renderValueEnum(650fn renderValueEnum(
630 writer: anytype,651 writer: *std.io.Writer,
631 enumeration: OperandKind,652 enumeration: OperandKind,
632 extended_structs: ExtendedStructSet,653 extended_structs: ExtendedStructSet,
633) !void {654) !void {
...@@ -705,7 +726,7 @@ fn renderValueEnum(...@@ -705,7 +726,7 @@ fn renderValueEnum(
705}726}
706727
707fn renderBitEnum(728fn renderBitEnum(
708 writer: anytype,729 writer: *std.io.Writer,
709 enumeration: OperandKind,730 enumeration: OperandKind,
710 extended_structs: ExtendedStructSet,731 extended_structs: ExtendedStructSet,
711) !void {732) !void {
...@@ -788,7 +809,7 @@ fn renderBitEnum(...@@ -788,7 +809,7 @@ fn renderBitEnum(
788}809}
789810
790fn renderOperand(811fn renderOperand(
791 writer: anytype,812 writer: *std.io.Writer,
792 kind: enum {813 kind: enum {
793 @"union",814 @"union",
794 instruction,815 instruction,
...@@ -872,7 +893,7 @@ fn renderOperand(...@@ -872,7 +893,7 @@ fn renderOperand(
872 try writer.writeAll(",\n");893 try writer.writeAll(",\n");
873}894}
874895
875fn renderFieldName(writer: anytype, operands: []const Operand, field_index: usize) !void {896fn renderFieldName(writer: *std.io.Writer, operands: []const Operand, field_index: usize) !void {
876 const operand = operands[field_index];897 const operand = operands[field_index];
877898
878 derive_from_kind: {899 derive_from_kind: {