diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-08-28 02:35:53 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-08-28 08:39:59 +0100 |
| commit | 0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9 (patch) | |
| tree | 2c07fddf2b6230360fe618c4de192bc2d24eeaf7 /src/codegen/spirv/Section.zig | |
| parent | 1a178d499537b922ff05c5d0186ed5a00dbb1a9b (diff) | |
| download | zig-0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9.tar.gz zig-0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9.zip | |
std: update `std.builtin.Type` fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.
This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
Diffstat (limited to 'src/codegen/spirv/Section.zig')
| -rw-r--r-- | src/codegen/spirv/Section.zig | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/codegen/spirv/Section.zig b/src/codegen/spirv/Section.zig index d857ce7f46..20abf8ab70 100644 --- a/src/codegen/spirv/Section.zig +++ b/src/codegen/spirv/Section.zig @@ -98,7 +98,7 @@ pub fn emitSpecConstantOp( section.writeOperand(spec.IdRef, operands.id_result); section.writeOperand(Opcode, opcode); - const fields = @typeInfo(opcode.Operands()).Struct.fields; + const fields = @typeInfo(opcode.Operands()).@"struct".fields; // First 2 fields are always id_result_type and id_result. inline for (fields[2..]) |field| { section.writeOperand(field.type, @field(operands, field.name)); @@ -122,8 +122,8 @@ pub fn writeDoubleWord(section: *Section, dword: DoubleWord) void { fn writeOperands(section: *Section, comptime Operands: type, operands: Operands) void { const fields = switch (@typeInfo(Operands)) { - .Struct => |info| info.fields, - .Void => return, + .@"struct" => |info| info.fields, + .void => return, else => unreachable, }; @@ -154,24 +154,24 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand) spec.PairIdRefIdRef => section.writeWords(&.{ @intFromEnum(operand[0]), @intFromEnum(operand[1]) }), else => switch (@typeInfo(Operand)) { - .Enum => section.writeWord(@intFromEnum(operand)), - .Optional => |info| if (operand) |child| { + .@"enum" => section.writeWord(@intFromEnum(operand)), + .optional => |info| if (operand) |child| { section.writeOperand(info.child, child); }, - .Pointer => |info| { + .pointer => |info| { std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec. for (operand) |item| { section.writeOperand(info.child, item); } }, - .Struct => |info| { + .@"struct" => |info| { if (info.layout == .@"packed") { section.writeWord(@as(Word, @bitCast(operand))); } else { section.writeExtendedMask(Operand, operand); } }, - .Union => section.writeExtendedUnion(Operand, operand), + .@"union" => section.writeExtendedUnion(Operand, operand), else => unreachable, }, } @@ -207,12 +207,12 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void { var mask: Word = 0; - inline for (@typeInfo(Operand).Struct.fields, 0..) |field, bit| { + inline for (@typeInfo(Operand).@"struct".fields, 0..) |field, bit| { switch (@typeInfo(field.type)) { - .Optional => if (@field(operand, field.name) != null) { + .optional => if (@field(operand, field.name) != null) { mask |= 1 << @as(u5, @intCast(bit)); }, - .Bool => if (@field(operand, field.name)) { + .bool => if (@field(operand, field.name)) { mask |= 1 << @as(u5, @intCast(bit)); }, else => unreachable, @@ -221,12 +221,12 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand section.writeWord(mask); - inline for (@typeInfo(Operand).Struct.fields) |field| { + inline for (@typeInfo(Operand).@"struct".fields) |field| { switch (@typeInfo(field.type)) { - .Optional => |info| if (@field(operand, field.name)) |child| { + .optional => |info| if (@field(operand, field.name)) |child| { section.writeOperands(info.child, child); }, - .Bool => {}, + .bool => {}, else => unreachable, } } @@ -236,7 +236,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan const tag = std.meta.activeTag(operand); section.writeWord(@intFromEnum(tag)); - inline for (@typeInfo(Operand).Union.fields) |field| { + inline for (@typeInfo(Operand).@"union".fields) |field| { if (@field(Operand, field.name) == tag) { section.writeOperands(field.type, @field(operand, field.name)); return; @@ -251,8 +251,8 @@ fn instructionSize(comptime opcode: spec.Opcode, operands: opcode.Operands()) us fn operandsSize(comptime Operands: type, operands: Operands) usize { const fields = switch (@typeInfo(Operands)) { - .Struct => |info| info.fields, - .Void => return 0, + .@"struct" => |info| info.fields, + .void => return 0, else => unreachable, }; @@ -289,9 +289,9 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { => 2, else => switch (@typeInfo(Operand)) { - .Enum => 1, - .Optional => |info| if (operand) |child| operandSize(info.child, child) else 0, - .Pointer => |info| blk: { + .@"enum" => 1, + .optional => |info| if (operand) |child| operandSize(info.child, child) else 0, + .pointer => |info| blk: { std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec. var total: usize = 0; for (operand) |item| { @@ -299,8 +299,8 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { } break :blk total; }, - .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand), - .Union => extendedUnionSize(Operand, operand), + .@"struct" => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand), + .@"union" => extendedUnionSize(Operand, operand), else => unreachable, }, }; @@ -309,13 +309,13 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { var total: usize = 0; var any_set = false; - inline for (@typeInfo(Operand).Struct.fields) |field| { + inline for (@typeInfo(Operand).@"struct".fields) |field| { switch (@typeInfo(field.type)) { - .Optional => |info| if (@field(operand, field.name)) |child| { + .optional => |info| if (@field(operand, field.name)) |child| { total += operandsSize(info.child, child); any_set = true; }, - .Bool => if (@field(operand, field.name)) { + .bool => if (@field(operand, field.name)) { any_set = true; }, else => unreachable, @@ -326,7 +326,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { fn extendedUnionSize(comptime Operand: type, operand: Operand) usize { const tag = std.meta.activeTag(operand); - inline for (@typeInfo(Operand).Union.fields) |field| { + inline for (@typeInfo(Operand).@"union".fields) |field| { if (@field(Operand, field.name) == tag) { // Add one for the tag itself. return 1 + operandsSize(field.type, @field(operand, field.name)); |
