@@ -7,8 +7,7 @@ const assert = std.debug.assert;
7
7
const spec = @import ("spec.zig" );
8
8
const Opcode = spec .Opcode ;
9
9
const Word = spec .Word ;
10
- const IdRef = spec .IdRef ;
11
- const IdResult = spec .IdResult ;
10
+ const Id = spec .Id ;
12
11
const StorageClass = spec .StorageClass ;
13
12
14
13
const SpvModule = @import ("Module.zig" );
@@ -127,10 +126,10 @@ const AsmValue = union(enum) {
127
126
unresolved_forward_reference ,
128
127
129
128
/// This result-value is a normal result produced by a different instruction.
130
- value : IdRef ,
129
+ value : Id ,
131
130
132
131
/// This result-value represents a type registered into the module's type system.
133
- ty : IdRef ,
132
+ ty : Id ,
134
133
135
134
/// This is a pre-supplied constant integer value.
136
135
constant : u32 ,
@@ -141,7 +140,7 @@ const AsmValue = union(enum) {
141
140
/// Retrieve the result-id of this AsmValue. Asserts that this AsmValue
142
141
/// is of a variant that allows the result to be obtained (not an unresolved
143
142
/// forward declaration, not in the process of being declared, etc).
144
- pub fn resultId (self : AsmValue ) IdRef {
143
+ pub fn resultId (self : AsmValue ) Id {
145
144
return switch (self ) {
146
145
.just_declared ,
147
146
.unresolved_forward_reference ,
@@ -314,7 +313,7 @@ fn processInstruction(self: *Assembler) !void {
314
313
return ;
315
314
},
316
315
else = > switch (self .inst .opcode .class ()) {
317
- .TypeDeclaration = > try self .processTypeInstruction (),
316
+ .type_declaration = > try self .processTypeInstruction (),
318
317
else = > (try self .processGenericInstruction ()) orelse return ,
319
318
},
320
319
};
@@ -392,7 +391,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
392
391
break :blk result_id ;
393
392
},
394
393
.OpTypeStruct = > blk : {
395
- const ids = try self .gpa .alloc (IdRef , operands [1.. ].len );
394
+ const ids = try self .gpa .alloc (Id , operands [1.. ].len );
396
395
defer self .gpa .free (ids );
397
396
for (operands [1.. ], ids ) | op , * id | id .* = try self .resolveRefId (op .ref_id );
398
397
const result_id = self .spv .allocId ();
@@ -429,7 +428,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
429
428
const param_operands = operands [2.. ];
430
429
const return_type = try self .resolveRefId (operands [1 ].ref_id );
431
430
432
- const param_types = try self .spv .gpa .alloc (IdRef , param_operands .len );
431
+ const param_types = try self .spv .gpa .alloc (Id , param_operands .len );
433
432
defer self .spv .gpa .free (param_types );
434
433
for (param_types , param_operands ) | * param , operand | {
435
434
param .* = try self .resolveRefId (operand .ref_id );
@@ -457,17 +456,17 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {
457
456
const operands = self .inst .operands .items ;
458
457
var maybe_spv_decl_index : ? SpvModule.Decl.Index = null ;
459
458
const section = switch (self .inst .opcode .class ()) {
460
- .ConstantCreation = > & self .spv .sections .types_globals_constants ,
461
- .Annotation = > & self .spv .sections .annotations ,
462
- .TypeDeclaration = > unreachable , // Handled elsewhere.
459
+ .constant_creation = > & self .spv .sections .types_globals_constants ,
460
+ .annotation = > & self .spv .sections .annotations ,
461
+ .type_declaration = > unreachable , // Handled elsewhere.
463
462
else = > switch (self .inst .opcode ) {
464
463
.OpEntryPoint = > unreachable ,
465
464
.OpExecutionMode , .OpExecutionModeId = > & self .spv .sections .execution_modes ,
466
465
.OpVariable = > section : {
467
466
const storage_class : spec.StorageClass = @enumFromInt (operands [2 ].value );
468
- if (storage_class == .Function ) break :section & self .func .prologue ;
467
+ if (storage_class == .function ) break :section & self .func .prologue ;
469
468
maybe_spv_decl_index = try self .spv .allocDecl (.global );
470
- if (self .spv .version .minor < 4 and storage_class != .Input and storage_class != .Output ) {
469
+ if (self .spv .version .minor < 4 and storage_class != .input and storage_class != .output ) {
471
470
// Before version 1.4, the interface’s storage classes are limited to the Input and Output
472
471
break :section & self .spv .sections .types_globals_constants ;
473
472
}
@@ -481,7 +480,7 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {
481
480
},
482
481
};
483
482
484
- var maybe_result_id : ? IdResult = null ;
483
+ var maybe_result_id : ? Id = null ;
485
484
const first_word = section .instructions .items .len ;
486
485
// At this point we're not quite sure how many operands this instruction is going to have,
487
486
// so insert 0 and patch up the actual opcode word later.
@@ -504,12 +503,12 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {
504
503
else
505
504
self .spv .allocId ();
506
505
try section .ensureUnusedCapacity (self .spv .gpa , 1 );
507
- section .writeOperand (IdResult , maybe_result_id .? );
506
+ section .writeOperand (Id , maybe_result_id .? );
508
507
},
509
508
.ref_id = > | index | {
510
509
const result = try self .resolveRef (index );
511
510
try section .ensureUnusedCapacity (self .spv .gpa , 1 );
512
- section .writeOperand (spec .IdRef , result .resultId ());
511
+ section .writeOperand (spec .Id , result .resultId ());
513
512
},
514
513
.string = > | offset | {
515
514
const text = std .mem .sliceTo (self .inst .string_bytes .items [offset .. ], 0 );
@@ -558,7 +557,7 @@ fn resolveRef(self: *Assembler, ref: AsmValue.Ref) !AsmValue {
558
557
}
559
558
}
560
559
561
- fn resolveRefId (self : * Assembler , ref : AsmValue.Ref ) ! IdRef {
560
+ fn resolveRefId (self : * Assembler , ref : AsmValue.Ref ) ! Id {
562
561
const value = try self .resolveRef (ref );
563
562
return value .resultId ();
564
563
}
@@ -600,7 +599,7 @@ fn parseInstruction(self: *Assembler) !void {
600
599
const expected_operands = inst .operands ;
601
600
// This is a loop because the result-id is not always the first operand.
602
601
const requires_lhs_result = for (expected_operands ) | op | {
603
- if (op .kind == .IdResult ) break true ;
602
+ if (op .kind == .id_result ) break true ;
604
603
} else false ;
605
604
606
605
if (requires_lhs_result and maybe_lhs_result == null ) {
@@ -614,7 +613,7 @@ fn parseInstruction(self: *Assembler) !void {
614
613
}
615
614
616
615
for (expected_operands ) | operand | {
617
- if (operand .kind == .IdResult ) {
616
+ if (operand .kind == .id_result ) {
618
617
try self .inst .operands .append (self .gpa , .{ .result_id = maybe_lhs_result .? });
619
618
continue ;
620
619
}
@@ -646,11 +645,11 @@ fn parseOperand(self: *Assembler, kind: spec.OperandKind) Error!void {
646
645
.value_enum = > try self .parseValueEnum (kind ),
647
646
.id = > try self .parseRefId (),
648
647
else = > switch (kind ) {
649
- .LiteralInteger = > try self .parseLiteralInteger (),
650
- .LiteralString = > try self .parseString (),
651
- .LiteralContextDependentNumber = > try self .parseContextDependentNumber (),
652
- .LiteralExtInstInteger = > try self .parseLiteralExtInstInteger (),
653
- .PairIdRefIdRef = > try self .parsePhiSource (),
648
+ .literal_integer = > try self .parseLiteralInteger (),
649
+ .literal_string = > try self .parseString (),
650
+ .literal_context_dependent_number = > try self .parseContextDependentNumber (),
651
+ .literal_ext_inst_integer = > try self .parseLiteralExtInstInteger (),
652
+ .pair_id_ref_id_ref = > try self .parsePhiSource (),
654
653
else = > return self .todo ("parse operand of type {s}" , .{@tagName (kind )}),
655
654
},
656
655
}
0 commit comments