aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Section.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-06-22 18:46:56 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-06-24 16:56:39 -0700
commitf26dda21171e26f44aeec8c59a75bbb3331eeb2e (patch)
treec935248861ae2693b314f2c8bc78fe38d9961b6d /src/codegen/spirv/Section.zig
parent447ca4e3fff021f471b748187b53f0a4744ad0bc (diff)
downloadzig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.tar.gz
zig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.zip
all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
Diffstat (limited to 'src/codegen/spirv/Section.zig')
-rw-r--r--src/codegen/spirv/Section.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/codegen/spirv/Section.zig b/src/codegen/spirv/Section.zig
index b35dc489e4..ae88dc7c8a 100644
--- a/src/codegen/spirv/Section.zig
+++ b/src/codegen/spirv/Section.zig
@@ -50,7 +50,7 @@ pub fn emitRaw(
) !void {
const word_count = 1 + operand_words;
try section.instructions.ensureUnusedCapacity(allocator, word_count);
- section.writeWord((@intCast(Word, word_count << 16)) | @intFromEnum(opcode));
+ section.writeWord((@as(Word, @intCast(word_count << 16))) | @intFromEnum(opcode));
}
pub fn emit(
@@ -61,7 +61,7 @@ pub fn emit(
) !void {
const word_count = instructionSize(opcode, operands);
try section.instructions.ensureUnusedCapacity(allocator, word_count);
- section.writeWord(@intCast(Word, word_count << 16) | @intFromEnum(opcode));
+ section.writeWord(@as(Word, @intCast(word_count << 16)) | @intFromEnum(opcode));
section.writeOperands(opcode.Operands(), operands);
}
@@ -94,8 +94,8 @@ pub fn writeWords(section: *Section, words: []const Word) void {
pub fn writeDoubleWord(section: *Section, dword: DoubleWord) void {
section.writeWords(&.{
- @truncate(Word, dword),
- @truncate(Word, dword >> @bitSizeOf(Word)),
+ @as(Word, @truncate(dword)),
+ @as(Word, @truncate(dword >> @bitSizeOf(Word))),
});
}
@@ -145,7 +145,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
},
.Struct => |info| {
if (info.layout == .Packed) {
- section.writeWord(@bitCast(Word, operand));
+ section.writeWord(@as(Word, @bitCast(operand)));
} else {
section.writeExtendedMask(Operand, operand);
}
@@ -166,7 +166,7 @@ fn writeString(section: *Section, str: []const u8) void {
var j: usize = 0;
while (j < @sizeOf(Word) and i + j < str.len) : (j += 1) {
- word |= @as(Word, str[i + j]) << @intCast(Log2Word, j * @bitSizeOf(u8));
+ word |= @as(Word, str[i + j]) << @as(Log2Word, @intCast(j * @bitSizeOf(u8)));
}
section.instructions.appendAssumeCapacity(word);
@@ -175,12 +175,12 @@ fn writeString(section: *Section, str: []const u8) void {
fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDependentNumber) void {
switch (operand) {
- .int32 => |int| section.writeWord(@bitCast(Word, int)),
- .uint32 => |int| section.writeWord(@bitCast(Word, int)),
- .int64 => |int| section.writeDoubleWord(@bitCast(DoubleWord, int)),
- .uint64 => |int| section.writeDoubleWord(@bitCast(DoubleWord, int)),
- .float32 => |float| section.writeWord(@bitCast(Word, float)),
- .float64 => |float| section.writeDoubleWord(@bitCast(DoubleWord, float)),
+ .int32 => |int| section.writeWord(@as(Word, @bitCast(int))),
+ .uint32 => |int| section.writeWord(@as(Word, @bitCast(int))),
+ .int64 => |int| section.writeDoubleWord(@as(DoubleWord, @bitCast(int))),
+ .uint64 => |int| section.writeDoubleWord(@as(DoubleWord, @bitCast(int))),
+ .float32 => |float| section.writeWord(@as(Word, @bitCast(float))),
+ .float64 => |float| section.writeDoubleWord(@as(DoubleWord, @bitCast(float))),
}
}
@@ -189,10 +189,10 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand
inline for (@typeInfo(Operand).Struct.fields, 0..) |field, bit| {
switch (@typeInfo(field.type)) {
.Optional => if (@field(operand, field.name) != null) {
- mask |= 1 << @intCast(u5, bit);
+ mask |= 1 << @as(u5, @intCast(bit));
},
.Bool => if (@field(operand, field.name)) {
- mask |= 1 << @intCast(u5, bit);
+ mask |= 1 << @as(u5, @intCast(bit));
},
else => unreachable,
}
@@ -392,7 +392,7 @@ test "SPIR-V Section emit() - extended mask" {
(@as(Word, 5) << 16) | @intFromEnum(Opcode.OpLoopMerge),
10,
20,
- @bitCast(Word, spec.LoopControl{ .Unroll = true, .DependencyLength = true }),
+ @as(Word, @bitCast(spec.LoopControl{ .Unroll = true, .DependencyLength = true })),
2,
}, section.instructions.items);
}