Skip to content

Commit

Permalink
spirv: support enum integer values in Assembler
Browse files Browse the repository at this point in the history
  • Loading branch information
alichraghi committed Feb 3, 2024
1 parent 9481f57 commit 17442d3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/codegen/spirv/Assembler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,13 @@ fn parseValueEnum(self: *Assembler, kind: spec.OperandKind) !void {
try self.expectToken(.value);

const text = self.tokenText(tok);
const int_value = std.fmt.parseInt(u32, text, 0) catch null;
const enumerant = for (kind.enumerants()) |enumerant| {
if (std.mem.eql(u8, enumerant.name, text))
break enumerant;
if (int_value) |v| {
if (v == enumerant.value) break enumerant;
} else {
if (std.mem.eql(u8, enumerant.name, text)) break enumerant;
}
} else {
return self.fail(tok.start, "'{s}' is not a valid value for enumeration {s}", .{ text, @tagName(kind) });
};
Expand Down

0 comments on commit 17442d3

Please sign in to comment.