@@ -779,6 +779,40 @@ fn parseValueEnum(self: *Assembler, kind: spec.OperandKind) !void {
779
779
780
780
fn parseRefId (self : * Assembler ) ! void {
781
781
const tok = self .currentToken ();
782
+
783
+ // Handle placeholders that need to be converted to result IDs
784
+ if (self .eatToken (.placeholder )) {
785
+ const name = self .tokenText (tok )[1.. ];
786
+ const value = self .value_map .get (name ) orelse {
787
+ return self .fail (tok .start , "invalid placeholder '${s}'" , .{name });
788
+ };
789
+ switch (value ) {
790
+ .string = > | str | {
791
+ // Create a global string constant and use its result ID directly
792
+ const string_id = try self .spv .constStringGlobal (str );
793
+ // Create a new entry in the value map with the resolved ID
794
+ const entry = try self .value_map .getOrPut (self .gpa , name );
795
+ entry .value_ptr .* = .{ .value = string_id };
796
+ const index : AsmValue.Ref = @intCast (entry .index );
797
+ try self .inst .operands .append (self .gpa , .{ .ref_id = index });
798
+ return ;
799
+ },
800
+ .constant = > {
801
+ // TODO: Create a constant instruction for the integer
802
+ return self .fail (tok .start , "integer constants as result IDs not yet supported" , .{});
803
+ },
804
+ .value = > {
805
+ // This is an argument value - use its result ID directly
806
+ const entry = try self .value_map .getOrPut (self .gpa , name );
807
+ // The value should already be resolved, so just use the index
808
+ const index : AsmValue.Ref = @intCast (entry .index );
809
+ try self .inst .operands .append (self .gpa , .{ .ref_id = index });
810
+ return ;
811
+ },
812
+ else = > return self .fail (tok .start , "value '{s}' cannot be used as result-id" , .{name }),
813
+ }
814
+ }
815
+
782
816
try self .expectToken (.result_id );
783
817
784
818
const name = self .tokenText (tok )[1.. ];
0 commit comments