authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-02-13 19:06:47+01:00
committergravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-04-07 14:47:11+02:00
log4c393c7468a4f6a62ba8251cdeeddc47b5b2b73d
treeb33be9336c6351c68ea13381b1283a078d1666a7
parentd8e7eda5f4a894fe8fec8c53f7bcc3d475dd55c9

Update usages of `fmtId`/`isValidId`

`{}` for decls `{p}` for enum fields `{p_}` for struct fields and in contexts following a `.` Elsewhere, `{p}` was used since it's equivalent to the old behavior.

11 files changed, 77 insertions(+), 78 deletions(-)

lib/compiler/aro_translate_c/ast.zig+3-3
......@@ -828,7 +828,7 @@ const Context = struct {
828828 fn addIdentifier(c: *Context, bytes: []const u8) Allocator.Error!TokenIndex {
829829 if (std.zig.primitives.isPrimitive(bytes))
830830 return c.addTokenFmt(.identifier, "@\"{s}\"", .{bytes});
831 return c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(bytes)});
831 return c.addTokenFmt(.identifier, "{p}", .{std.zig.fmtId(bytes)});
832832 }
833833
834834 fn listToSpan(c: *Context, list: []const NodeIndex) Allocator.Error!NodeSubRange {
......@@ -2106,7 +2106,7 @@ fn renderRecord(c: *Context, node: Node) !NodeIndex {
21062106 members[1] = 0;
21072107
21082108 for (payload.fields, 0..) |field, i| {
2109 const name_tok = try c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(field.name)});
2109 const name_tok = try c.addTokenFmt(.identifier, "{p}", .{std.zig.fmtId(field.name)});
21102110 _ = try c.addToken(.colon, ":");
21112111 const type_expr = try renderNode(c, field.type);
21122112
......@@ -2199,7 +2199,7 @@ fn renderFieldAccess(c: *Context, lhs: NodeIndex, field_name: []const u8) !NodeI
21992199 .main_token = try c.addToken(.period, "."),
22002200 .data = .{
22012201 .lhs = lhs,
2202 .rhs = try c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(field_name)}),
2202 .rhs = try c.addTokenFmt(.identifier, "{p}", .{std.zig.fmtId(field_name)}),
22032203 },
22042204 });
22052205}
lib/std/Build/Step/Options.zig+6-6
......@@ -234,7 +234,7 @@ fn printType(self: *Options, out: anytype, comptime T: type, value: T, indent: u
234234 try printEnum(self, out, T, info, indent);
235235
236236 if (name) |some| {
237 try out.print("pub const {}: {s} = .{s};\n", .{
237 try out.print("pub const {}: {} = .{p_};\n", .{
238238 std.zig.fmtId(some),
239239 std.zig.fmtId(@typeName(T)),
240240 std.zig.fmtId(@tagName(value)),
......@@ -246,7 +246,7 @@ fn printType(self: *Options, out: anytype, comptime T: type, value: T, indent: u
246246 try printStruct(self, out, T, info, indent);
247247
248248 if (name) |some| {
249 try out.print("pub const {}: {s} = ", .{
249 try out.print("pub const {}: {} = ", .{
250250 std.zig.fmtId(some),
251251 std.zig.fmtId(@typeName(T)),
252252 });
......@@ -279,7 +279,7 @@ fn printEnum(self: *Options, out: anytype, comptime T: type, comptime val: std.b
279279
280280 inline for (val.fields) |field| {
281281 try out.writeByteNTimes(' ', indent);
282 try out.print(" {} = {d},\n", .{ std.zig.fmtId(field.name), field.value });
282 try out.print(" {p} = {d},\n", .{ std.zig.fmtId(field.name), field.value });
283283 }
284284
285285 if (!val.is_exhaustive) {
......@@ -313,9 +313,9 @@ fn printStruct(self: *Options, out: anytype, comptime T: type, comptime val: std
313313
314314 // If the type name doesn't contains a '.' the type is from zig builtins.
315315 if (std.mem.containsAtLeast(u8, type_name, 1, ".")) {
316 try out.print(" {}: {}", .{ std.zig.fmtId(field.name), std.zig.fmtId(type_name) });
316 try out.print(" {p_}: {}", .{ std.zig.fmtId(field.name), std.zig.fmtId(type_name) });
317317 } else {
318 try out.print(" {}: {s}", .{ std.zig.fmtId(field.name), type_name });
318 try out.print(" {p_}: {s}", .{ std.zig.fmtId(field.name), type_name });
319319 }
320320
321321 if (field.default_value != null) {
......@@ -355,7 +355,7 @@ fn printStructValue(self: *Options, out: anytype, comptime struct_val: std.built
355355 } else {
356356 inline for (struct_val.fields) |field| {
357357 try out.writeByteNTimes(' ', indent);
358 try out.print(" .{} = ", .{std.zig.fmtId(field.name)});
358 try out.print(" .{p_} = ", .{std.zig.fmtId(field.name)});
359359
360360 const field_name = @field(val, field.name);
361361 switch (@typeInfo(@TypeOf(field_name))) {
lib/std/zig/render.zig+2-2
......@@ -2847,8 +2847,8 @@ fn renderIdentifier(r: *Render, token_index: Ast.TokenIndex, space: Space, quote
28472847 return renderQuotedIdentifier(r, token_index, space, false);
28482848 }
28492849
2850 // Special case for _ which would incorrectly be rejected by isValidId below.
2851 if (contents.len == 1 and contents[0] == '_') switch (quote) {
2850 // Special case for _.
2851 if (std.zig.isUnderscore(contents)) switch (quote) {
28522852 .eagerly_unquote => return renderQuotedIdentifier(r, token_index, space, true),
28532853 .eagerly_unquote_except_underscore,
28542854 .preserve_when_shadowing,
src/Builtin.zig+14-15
......@@ -35,17 +35,17 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {
3535 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
3636 \\pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;
3737 \\pub const zig_version_string = "{s}";
38 \\pub const zig_backend = std.builtin.CompilerBackend.{};
38 \\pub const zig_backend = std.builtin.CompilerBackend.{p_};
3939 \\
40 \\pub const output_mode = std.builtin.OutputMode.{};
41 \\pub const link_mode = std.builtin.LinkMode.{};
40 \\pub const output_mode = std.builtin.OutputMode.{p_};
41 \\pub const link_mode = std.builtin.LinkMode.{p_};
4242 \\pub const is_test = {};
4343 \\pub const single_threaded = {};
44 \\pub const abi = std.Target.Abi.{};
44 \\pub const abi = std.Target.Abi.{p_};
4545 \\pub const cpu: std.Target.Cpu = .{{
46 \\ .arch = .{},
47 \\ .model = &std.Target.{}.cpu.{},
48 \\ .features = std.Target.{}.featureSet(&[_]std.Target.{}.Feature{{
46 \\ .arch = .{p_},
47 \\ .model = &std.Target.{p_}.cpu.{p_},
48 \\ .features = std.Target.{p_}.featureSet(&[_]std.Target.{p_}.Feature{{
4949 \\
5050 , .{
5151 build_options.version,
......@@ -66,14 +66,14 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {
6666 const index = @as(std.Target.Cpu.Feature.Set.Index, @intCast(index_usize));
6767 const is_enabled = target.cpu.features.isEnabled(index);
6868 if (is_enabled) {
69 try buffer.writer().print(" .{},\n", .{std.zig.fmtId(feature.name)});
69 try buffer.writer().print(" .{p_},\n", .{std.zig.fmtId(feature.name)});
7070 }
7171 }
7272 try buffer.writer().print(
7373 \\ }}),
7474 \\}};
7575 \\pub const os = std.Target.Os{{
76 \\ .tag = .{},
76 \\ .tag = .{p_},
7777 \\ .version_range = .{{
7878 ,
7979 .{std.zig.fmtId(@tagName(target.os.tag))},
......@@ -180,8 +180,8 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {
180180 const link_libc = opts.link_libc;
181181
182182 try buffer.writer().print(
183 \\pub const object_format = std.Target.ObjectFormat.{};
184 \\pub const mode = std.builtin.OptimizeMode.{};
183 \\pub const object_format = std.Target.ObjectFormat.{p_};
184 \\pub const mode = std.builtin.OptimizeMode.{p_};
185185 \\pub const link_libc = {};
186186 \\pub const link_libcpp = {};
187187 \\pub const have_error_return_tracing = {};
......@@ -190,7 +190,7 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {
190190 \\pub const position_independent_code = {};
191191 \\pub const position_independent_executable = {};
192192 \\pub const strip_debug_info = {};
193 \\pub const code_model = std.builtin.CodeModel.{};
193 \\pub const code_model = std.builtin.CodeModel.{p_};
194194 \\pub const omit_frame_pointer = {};
195195 \\
196196 , .{
......@@ -209,11 +209,10 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {
209209 });
210210
211211 if (target.os.tag == .wasi) {
212 const wasi_exec_model_fmt = std.zig.fmtId(@tagName(opts.wasi_exec_model));
213212 try buffer.writer().print(
214 \\pub const wasi_exec_model = std.builtin.WasiExecModel.{};
213 \\pub const wasi_exec_model = std.builtin.WasiExecModel.{p_};
215214 \\
216 , .{wasi_exec_model_fmt});
215 , .{std.zig.fmtId(@tagName(opts.wasi_exec_model))});
217216 }
218217
219218 if (opts.is_test) {
src/InternPool.zig+1-1
......@@ -488,7 +488,7 @@ pub const NullTerminatedString = enum(u32) {
488488 if (comptime std.mem.eql(u8, specifier, "")) {
489489 try writer.writeAll(s);
490490 } else if (comptime std.mem.eql(u8, specifier, "i")) {
491 try writer.print("{}", .{std.zig.fmtId(s)});
491 try writer.print("{p}", .{std.zig.fmtId(s)});
492492 } else @compileError("invalid format string '" ++ specifier ++ "' for '" ++ @typeName(NullTerminatedString) ++ "'");
493493 }
494494
src/main.zig+1-1
......@@ -6943,7 +6943,7 @@ fn cmdFetch(
69436943 std.zig.fmtEscapes(&hex_digest),
69446944 });
69456945
6946 const new_node_text = try std.fmt.allocPrint(arena, ".{} = {s},\n", .{
6946 const new_node_text = try std.fmt.allocPrint(arena, ".{p_} = {s},\n", .{
69476947 std.zig.fmtId(name), new_node_init,
69486948 });
69496949
src/print_zir.zig+8-8
......@@ -1005,7 +1005,7 @@ const Writer = struct {
10051005 const decl_name = self.code.nullTerminatedString(extra.decl_name);
10061006
10071007 try self.writeInstRef(stream, extra.namespace);
1008 try stream.print(", {}, ", .{std.zig.fmtId(decl_name)});
1008 try stream.print(", {p}, ", .{std.zig.fmtId(decl_name)});
10091009 try self.writeInstRef(stream, extra.options);
10101010 try stream.writeAll(") ");
10111011 try self.writeSrc(stream, inst_data.src());
......@@ -1243,7 +1243,7 @@ const Writer = struct {
12431243
12441244 const name = self.code.nullTerminatedString(output.data.name);
12451245 const constraint = self.code.nullTerminatedString(output.data.constraint);
1246 try stream.print("output({}, \"{}\", ", .{
1246 try stream.print("output({p}, \"{}\", ", .{
12471247 std.zig.fmtId(name), std.zig.fmtEscapes(constraint),
12481248 });
12491249 try self.writeFlag(stream, "->", is_type);
......@@ -1262,7 +1262,7 @@ const Writer = struct {
12621262
12631263 const name = self.code.nullTerminatedString(input.data.name);
12641264 const constraint = self.code.nullTerminatedString(input.data.constraint);
1265 try stream.print("input({}, \"{}\", ", .{
1265 try stream.print("input({p}, \"{}\", ", .{
12661266 std.zig.fmtId(name), std.zig.fmtEscapes(constraint),
12671267 });
12681268 try self.writeInstRef(stream, input.data.operand);
......@@ -1278,7 +1278,7 @@ const Writer = struct {
12781278 const str_index = self.code.extra[extra_i];
12791279 extra_i += 1;
12801280 const clobber = self.code.nullTerminatedString(@enumFromInt(str_index));
1281 try stream.print("{}", .{std.zig.fmtId(clobber)});
1281 try stream.print("{p}", .{std.zig.fmtId(clobber)});
12821282 if (i + 1 < clobbers_len) {
12831283 try stream.writeAll(", ");
12841284 }
......@@ -1559,7 +1559,7 @@ const Writer = struct {
15591559 try self.writeFlag(stream, "comptime ", field.is_comptime);
15601560 if (field.name != .empty) {
15611561 const field_name = self.code.nullTerminatedString(field.name);
1562 try stream.print("{}: ", .{std.zig.fmtId(field_name)});
1562 try stream.print("{p}: ", .{std.zig.fmtId(field_name)});
15631563 } else {
15641564 try stream.print("@\"{d}\": ", .{i});
15651565 }
......@@ -1738,7 +1738,7 @@ const Writer = struct {
17381738
17391739 try self.writeDocComment(stream, doc_comment_index);
17401740 try stream.writeByteNTimes(' ', self.indent);
1741 try stream.print("{}", .{std.zig.fmtId(field_name)});
1741 try stream.print("{p}", .{std.zig.fmtId(field_name)});
17421742
17431743 if (has_type) {
17441744 const field_type = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index]));
......@@ -1891,7 +1891,7 @@ const Writer = struct {
18911891 try self.writeDocComment(stream, doc_comment_index);
18921892
18931893 try stream.writeByteNTimes(' ', self.indent);
1894 try stream.print("{}", .{std.zig.fmtId(field_name)});
1894 try stream.print("{p}", .{std.zig.fmtId(field_name)});
18951895
18961896 if (has_tag_value) {
18971897 const tag_value_ref = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index]));
......@@ -1986,7 +1986,7 @@ const Writer = struct {
19861986 const doc_comment_index: Zir.NullTerminatedString = @enumFromInt(self.code.extra[extra_index + 1]);
19871987 try self.writeDocComment(stream, doc_comment_index);
19881988 try stream.writeByteNTimes(' ', self.indent);
1989 try stream.print("{},\n", .{std.zig.fmtId(name)});
1989 try stream.print("{p},\n", .{std.zig.fmtId(name)});
19901990 }
19911991
19921992 self.indent -= 2;
tools/gen_spirv_spec.zig+20-20
......@@ -311,7 +311,7 @@ fn renderInstructionSet(
311311 );
312312
313313 for (extensions) |ext| {
314 try writer.print("{},\n", .{std.zig.fmtId(ext.name)});
314 try writer.print("{p},\n", .{std.zig.fmtId(ext.name)});
315315 }
316316
317317 try writer.writeAll(
......@@ -344,7 +344,7 @@ fn renderInstructionsCase(
344344 // but there aren't so many total aliases and that would add more overhead in total. We will
345345 // just filter those out when needed.
346346
347 try writer.print(".{} => &[_]Instruction{{\n", .{std.zig.fmtId(set_name)});
347 try writer.print(".{p_} => &[_]Instruction{{\n", .{std.zig.fmtId(set_name)});
348348
349349 for (instructions) |inst| {
350350 try writer.print(
......@@ -366,7 +366,7 @@ fn renderInstructionsCase(
366366
367367 const kind = all_operand_kinds.get(.{ set_name, operand.kind }) orelse
368368 all_operand_kinds.get(.{ "core", operand.kind }).?;
369 try writer.print(".{{.kind = .{}, .quantifier = .{s}}},\n", .{ std.zig.fmtId(kind.kind), quantifier });
369 try writer.print(".{{.kind = .{p_}, .quantifier = .{s}}},\n", .{ std.zig.fmtId(kind.kind), quantifier });
370370 }
371371
372372 try writer.writeAll(
......@@ -423,7 +423,7 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void {
423423 \\
424424 );
425425 for (operands) |operand| {
426 try writer.print("{},\n", .{std.zig.fmtId(operand.kind)});
426 try writer.print("{p},\n", .{std.zig.fmtId(operand.kind)});
427427 }
428428 try writer.writeAll(
429429 \\
......@@ -440,7 +440,7 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void {
440440 .Literal => "literal",
441441 .Composite => "composite",
442442 };
443 try writer.print(".{} => .{s},\n", .{ std.zig.fmtId(operand.kind), cat });
443 try writer.print(".{p_} => .{s},\n", .{ std.zig.fmtId(operand.kind), cat });
444444 }
445445 try writer.writeAll(
446446 \\ };
......@@ -454,12 +454,12 @@ fn renderOperandKind(writer: anytype, operands: []const OperandKind) !void {
454454 switch (operand.category) {
455455 .BitEnum, .ValueEnum => {},
456456 else => {
457 try writer.print(".{} => unreachable,\n", .{std.zig.fmtId(operand.kind)});
457 try writer.print(".{p_} => unreachable,\n", .{std.zig.fmtId(operand.kind)});
458458 continue;
459459 },
460460 }
461461
462 try writer.print(".{} => &[_]Enumerant{{", .{std.zig.fmtId(operand.kind)});
462 try writer.print(".{p_} => &[_]Enumerant{{", .{std.zig.fmtId(operand.kind)});
463463 for (operand.enumerants.?) |enumerant| {
464464 if (enumerant.value == .bitflag and std.mem.eql(u8, enumerant.enumerant, "None")) {
465465 continue;
......@@ -483,7 +483,7 @@ fn renderEnumerant(writer: anytype, enumerant: Enumerant) !void {
483483 if (i != 0)
484484 try writer.writeAll(", ");
485485 // Note, param.quantifier will always be one.
486 try writer.print(".{}", .{std.zig.fmtId(param.kind)});
486 try writer.print(".{p_}", .{std.zig.fmtId(param.kind)});
487487 }
488488 try writer.writeAll("}}");
489489}
......@@ -529,7 +529,7 @@ fn renderOpcodes(
529529 try writer.writeAll("pub const Opcode = enum(u16) {\n");
530530 for (instructions_indices) |i| {
531531 const inst = instructions[i];
532 try writer.print("{} = {},\n", .{ std.zig.fmtId(inst.opname), inst.opcode });
532 try writer.print("{p} = {},\n", .{ std.zig.fmtId(inst.opname), inst.opcode });
533533 }
534534
535535 try writer.writeAll(
......@@ -537,7 +537,7 @@ fn renderOpcodes(
537537 );
538538
539539 for (aliases.items) |alias| {
540 try writer.print("pub const {} = Opcode.{};\n", .{
540 try writer.print("pub const {} = Opcode.{p_};\n", .{
541541 std.zig.fmtId(instructions[alias.inst].opname),
542542 std.zig.fmtId(instructions[alias.alias].opname),
543543 });
......@@ -565,7 +565,7 @@ fn renderOpcodes(
565565
566566 for (instructions_indices) |i| {
567567 const inst = instructions[i];
568 try writer.print(".{} => .", .{std.zig.fmtId(inst.opname)});
568 try writer.print(".{p_} => .", .{std.zig.fmtId(inst.opname)});
569569 try renderInstructionClass(writer, inst.class.?);
570570 try writer.writeAll(",\n");
571571 }
......@@ -636,22 +636,22 @@ fn renderValueEnum(
636636
637637 const enum_indices = enum_map.values();
638638
639 try writer.print("pub const {s} = enum(u32) {{\n", .{std.zig.fmtId(enumeration.kind)});
639 try writer.print("pub const {} = enum(u32) {{\n", .{std.zig.fmtId(enumeration.kind)});
640640
641641 for (enum_indices) |i| {
642642 const enumerant = enumerants[i];
643643 // if (enumerant.value != .int) return error.InvalidRegistry;
644644
645645 switch (enumerant.value) {
646 .int => |value| try writer.print("{} = {},\n", .{ std.zig.fmtId(enumerant.enumerant), value }),
647 .bitflag => |value| try writer.print("{} = {s},\n", .{ std.zig.fmtId(enumerant.enumerant), value }),
646 .int => |value| try writer.print("{p} = {},\n", .{ std.zig.fmtId(enumerant.enumerant), value }),
647 .bitflag => |value| try writer.print("{p} = {s},\n", .{ std.zig.fmtId(enumerant.enumerant), value }),
648648 }
649649 }
650650
651651 try writer.writeByte('\n');
652652
653653 for (aliases.items) |alias| {
654 try writer.print("pub const {} = {}.{};\n", .{
654 try writer.print("pub const {} = {}.{p_};\n", .{
655655 std.zig.fmtId(enumerants[alias.enumerant].enumerant),
656656 std.zig.fmtId(enumeration.kind),
657657 std.zig.fmtId(enumerants[alias.alias].enumerant),
......@@ -679,7 +679,7 @@ fn renderBitEnum(
679679 enumeration: OperandKind,
680680 extended_structs: ExtendedStructSet,
681681) !void {
682 try writer.print("pub const {s} = packed struct {{\n", .{std.zig.fmtId(enumeration.kind)});
682 try writer.print("pub const {} = packed struct {{\n", .{std.zig.fmtId(enumeration.kind)});
683683
684684 var flags_by_bitpos = [_]?usize{null} ** 32;
685685 const enumerants = enumeration.enumerants orelse return error.InvalidRegistry;
......@@ -719,7 +719,7 @@ fn renderBitEnum(
719719
720720 for (flags_by_bitpos, 0..) |maybe_flag_index, bitpos| {
721721 if (maybe_flag_index) |flag_index| {
722 try writer.print("{}", .{std.zig.fmtId(enumerants[flag_index].enumerant)});
722 try writer.print("{p_}", .{std.zig.fmtId(enumerants[flag_index].enumerant)});
723723 } else {
724724 try writer.print("_reserved_bit_{}", .{bitpos});
725725 }
......@@ -730,7 +730,7 @@ fn renderBitEnum(
730730 try writer.writeByte('\n');
731731
732732 for (aliases.items) |alias| {
733 try writer.print("pub const {}: {} = .{{.{} = true}};\n", .{
733 try writer.print("pub const {}: {} = .{{.{p_} = true}};\n", .{
734734 std.zig.fmtId(enumerants[alias.flag].enumerant),
735735 std.zig.fmtId(enumeration.kind),
736736 std.zig.fmtId(enumerants[flags_by_bitpos[alias.alias].?].enumerant),
......@@ -858,7 +858,7 @@ fn renderFieldName(writer: anytype, operands: []const Operand, field_index: usiz
858858 }
859859
860860 // Assume there are no duplicate 'name' fields.
861 try writer.print("{}", .{std.zig.fmtId(name_buffer.items)});
861 try writer.print("{p_}", .{std.zig.fmtId(name_buffer.items)});
862862 return;
863863 }
864864
......@@ -876,7 +876,7 @@ fn renderFieldName(writer: anytype, operands: []const Operand, field_index: usiz
876876 }
877877 }
878878
879 try writer.print("{}", .{std.zig.fmtId(name_buffer.items)});
879 try writer.print("{p_}", .{std.zig.fmtId(name_buffer.items)});
880880
881881 // For fields derived from type name, there could be any amount.
882882 // Simply check against all other fields, and if another similar one exists, add a number.
tools/generate_linux_syscalls.zig+12-12
......@@ -61,7 +61,7 @@ pub fn main() !void {
6161 _ = fields.next() orelse return error.Incomplete;
6262 const name = fields.next() orelse return error.Incomplete;
6363
64 try writer.print(" {s} = {s},\n", .{ zig.fmtId(name), number });
64 try writer.print(" {p} = {s},\n", .{ zig.fmtId(name), number });
6565 }
6666
6767 try writer.writeAll("};\n\n");
......@@ -82,7 +82,7 @@ pub fn main() !void {
8282 const name = fields.next() orelse return error.Incomplete;
8383
8484 const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name;
85 try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
85 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
8686 }
8787
8888 try writer.writeAll("};\n\n");
......@@ -107,7 +107,7 @@ pub fn main() !void {
107107 const name = fields.next() orelse return error.Incomplete;
108108
109109 const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name;
110 try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
110 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
111111 }
112112
113113 // TODO: maybe extract these from arch/arm/include/uapi/asm/unistd.h
......@@ -137,7 +137,7 @@ pub fn main() !void {
137137 if (mem.eql(u8, abi, "32")) continue;
138138 const name = fields.next() orelse return error.Incomplete;
139139
140 try writer.print(" {s} = {s},\n", .{ zig.fmtId(name), number });
140 try writer.print(" {p} = {s},\n", .{ zig.fmtId(name), number });
141141 }
142142
143143 try writer.writeAll("};\n\n");
......@@ -162,7 +162,7 @@ pub fn main() !void {
162162 const name = fields.next() orelse return error.Incomplete;
163163 if (mem.startsWith(u8, name, "unused")) continue;
164164
165 try writer.print(" {s} = Linux + {s},\n", .{ zig.fmtId(name), number });
165 try writer.print(" {p} = Linux + {s},\n", .{ zig.fmtId(name), number });
166166 }
167167
168168 try writer.writeAll("};\n\n");
......@@ -187,7 +187,7 @@ pub fn main() !void {
187187 const name = fields.next() orelse return error.Incomplete;
188188 const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name;
189189
190 try writer.print(" {s} = Linux + {s},\n", .{ zig.fmtId(fixed_name), number });
190 try writer.print(" {p} = Linux + {s},\n", .{ zig.fmtId(fixed_name), number });
191191 }
192192
193193 try writer.writeAll("};\n\n");
......@@ -210,12 +210,12 @@ pub fn main() !void {
210210 if (mem.eql(u8, abi, "spu")) {
211211 continue;
212212 } else if (mem.eql(u8, abi, "32")) {
213 try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
213 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
214214 } else if (mem.eql(u8, abi, "64")) {
215 try list_64.writer().print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
215 try list_64.writer().print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
216216 } else { // common/nospu
217 try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
218 try list_64.writer().print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
217 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
218 try list_64.writer().print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
219219 }
220220 }
221221
......@@ -291,7 +291,7 @@ pub fn main() !void {
291291 if (mem.eql(u8, name, "syscalls")) break :loop;
292292
293293 const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name;
294 try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
294 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
295295 }
296296
297297 try writer.writeAll("};\n\n");
......@@ -352,7 +352,7 @@ pub fn main() !void {
352352 if (mem.eql(u8, name, "syscalls")) break :loop;
353353
354354 const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name;
355 try writer.print(" {s} = {s},\n", .{ zig.fmtId(fixed_name), number });
355 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
356356 }
357357
358358 try writer.writeAll(
tools/update_cpu_features.zig+5-5
......@@ -1314,7 +1314,7 @@ fn processOneTarget(job: Job) anyerror!void {
13141314 );
13151315
13161316 for (all_features.items) |feature| {
1317 try w.print(" {},\n", .{std.zig.fmtId(feature.zig_name)});
1317 try w.print(" {p},\n", .{std.zig.fmtId(feature.zig_name)});
13181318 }
13191319
13201320 try w.writeAll(
......@@ -1341,7 +1341,7 @@ fn processOneTarget(job: Job) anyerror!void {
13411341 for (all_features.items) |feature| {
13421342 if (feature.llvm_name) |llvm_name| {
13431343 try w.print(
1344 \\ result[@intFromEnum(Feature.{})] = .{{
1344 \\ result[@intFromEnum(Feature.{p_})] = .{{
13451345 \\ .llvm_name = "{}",
13461346 \\ .description = "{}",
13471347 \\ .dependencies = featureSet(&[_]Feature{{
......@@ -1354,7 +1354,7 @@ fn processOneTarget(job: Job) anyerror!void {
13541354 );
13551355 } else {
13561356 try w.print(
1357 \\ result[@intFromEnum(Feature.{})] = .{{
1357 \\ result[@intFromEnum(Feature.{p_})] = .{{
13581358 \\ .llvm_name = null,
13591359 \\ .description = "{}",
13601360 \\ .dependencies = featureSet(&[_]Feature{{
......@@ -1388,7 +1388,7 @@ fn processOneTarget(job: Job) anyerror!void {
13881388 } else {
13891389 try w.writeAll("\n");
13901390 for (dependencies.items) |dep| {
1391 try w.print(" .{},\n", .{std.zig.fmtId(dep)});
1391 try w.print(" .{p_},\n", .{std.zig.fmtId(dep)});
13921392 }
13931393 try w.writeAll(
13941394 \\ }),
......@@ -1454,7 +1454,7 @@ fn processOneTarget(job: Job) anyerror!void {
14541454 } else {
14551455 try w.writeAll("\n");
14561456 for (cpu_features.items) |feature_zig_name| {
1457 try w.print(" .{},\n", .{std.zig.fmtId(feature_zig_name)});
1457 try w.print(" .{p_},\n", .{std.zig.fmtId(feature_zig_name)});
14581458 }
14591459 try w.writeAll(
14601460 \\ }),
tools/update_spirv_features.zig+5-5
......@@ -112,11 +112,11 @@ pub fn main() !void {
112112 }
113113
114114 for (extensions) |ext| {
115 try w.print(" {},\n", .{std.zig.fmtId(ext)});
115 try w.print(" {p},\n", .{std.zig.fmtId(ext)});
116116 }
117117
118118 for (capabilities) |cap| {
119 try w.print(" {},\n", .{std.zig.fmtId(cap.enumerant)});
119 try w.print(" {p},\n", .{std.zig.fmtId(cap.enumerant)});
120120 }
121121
122122 try w.writeAll(
......@@ -163,7 +163,7 @@ pub fn main() !void {
163163 // TODO: Extension dependencies.
164164 for (extensions) |ext| {
165165 try w.print(
166 \\ result[@intFromEnum(Feature.{s})] = .{{
166 \\ result[@intFromEnum(Feature.{p_})] = .{{
167167 \\ .llvm_name = null,
168168 \\ .description = "SPIR-V extension {s}",
169169 \\ .dependencies = featureSet(&[_]Feature{{}}),
......@@ -178,7 +178,7 @@ pub fn main() !void {
178178 // TODO: Capability extension dependencies.
179179 for (capabilities) |cap| {
180180 try w.print(
181 \\ result[@intFromEnum(Feature.{s})] = .{{
181 \\ result[@intFromEnum(Feature.{p_})] = .{{
182182 \\ .llvm_name = null,
183183 \\ .description = "Enable SPIR-V capability {s}",
184184 \\ .dependencies = featureSet(&[_]Feature{{
......@@ -196,7 +196,7 @@ pub fn main() !void {
196196 }
197197
198198 for (cap.capabilities) |cap_dep| {
199 try w.print(" .{},\n", .{std.zig.fmtId(cap_dep)});
199 try w.print(" .{p_},\n", .{std.zig.fmtId(cap_dep)});
200200 }
201201
202202 try w.writeAll(