authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-11-02 12:34:02+01:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-11-08 20:38:21+01:00
log4fbc100959c05ba10e4bfeeca9c7b5cd8216cc57
tree2b81a6931b173370124f709978beada77cf03f30
parent08ad7afc1e90c68409e9dc869d9dc1dceb3e8564
signaturebadge-check Signed by SSH key SHA256:ZS52FNyUv2WUXvO4njmVaFVO46RHojFuOrxRc4LuKzg

spirv: properly resolve type inputs in assembly

For now the frontend still allows type inputs in assembly. We might as well resolve them properly in the SPIR-V backend.

1 files changed, 11 insertions(+), 3 deletions(-)

src/codegen/spirv.zig+11-3
...@@ -1662,7 +1662,7 @@ const NavGen = struct {...@@ -1662,7 +1662,7 @@ const NavGen = struct {
1662 else => unreachable,1662 else => unreachable,
1663 }1663 }
16641664
1665 // Guaranteed by callConvSupportsVarArgs, there are nog SPIR-V CCs which support1665 // Guaranteed by callConvSupportsVarArgs, there are no SPIR-V CCs which support
1666 // varargs.1666 // varargs.
1667 assert(!fn_info.is_var_args);1667 assert(!fn_info.is_var_args);
16681668
...@@ -6580,8 +6580,16 @@ const NavGen = struct {...@@ -6580,8 +6580,16 @@ const NavGen = struct {
6580 // for the string, we still use the next u32 for the null terminator.6580 // for the string, we still use the next u32 for the null terminator.
6581 input_extra_i += (constraint.len + name.len + (2 + 3)) / 4;6581 input_extra_i += (constraint.len + name.len + (2 + 3)) / 4;
65826582
6583 const value = try self.resolve(input);6583 if (self.typeOf(input).zigTypeTag(zcu) == .type) {
6584 try as.value_map.put(as.gpa, name, .{ .value = value });6584 // This assembly input is a type instead of a value.
6585 // That's fine for now, just make sure to resolve it as such.
6586 const val = (try self.air.value(input, self.pt)).?;
6587 const ty_id = try self.resolveType(val.toType(), .direct);
6588 try as.value_map.put(as.gpa, name, .{ .ty = ty_id });
6589 } else {
6590 const val_id = try self.resolve(input);
6591 try as.value_map.put(as.gpa, name, .{ .value = val_id });
6592 }
6585 }6593 }
65866594
6587 as.assemble() catch |err| switch (err) {6595 as.assemble() catch |err| switch (err) {