From b24ceb9e4e9a78926047922987c13e7ec6614213 Mon Sep 17 00:00:00 2001 From: Taylor Hillegeist Date: Thu, 3 Oct 2024 11:37:27 -0500 Subject: [PATCH 1/4] Update gen.zig to produce just enums --- tools/regz/src/gen.zig | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/regz/src/gen.zig b/tools/regz/src/gen.zig index d03883c8..40cfecae 100644 --- a/tools/regz/src/gen.zig +++ b/tools/regz/src/gen.zig @@ -824,10 +824,12 @@ fn write_fields( } else if (db.attrs.@"enum".get(fields[i].id)) |enum_id| { if (db.attrs.name.get(enum_id)) |enum_name| { try writer.print( - \\{}: packed union {{ - \\ raw: u{}, - \\ value: {}, - \\}}, + // These were phased out in favor of using new builtins + // \\{}: packed union {{ + // \\ raw: u{}, + // \\ value: {}, + // \\}}, + \\{}: {}, \\ , .{ std.zig.fmtId(name), @@ -836,9 +838,10 @@ fn write_fields( }); } else { try writer.print( - \\{}: packed union {{ - \\ raw: u{}, - \\ value: enum(u{}) {{ + // \\{}: packed union {{ + // \\ raw: u{}, + // \\ value: enum(u{}) {{ + \\{}: enum(u{}) {{ \\ , .{ std.zig.fmtId(name), From 3f8ff18a8843f8f08f76fdbc29ebc575a36ef0cc Mon Sep 17 00:00:00 2001 From: Taylor Hillegeist Date: Thu, 3 Oct 2024 12:54:43 -0500 Subject: [PATCH 2/4] Update gen.zig Fixing mistakes on number of items included, in print and removed comments. --- tools/regz/src/gen.zig | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tools/regz/src/gen.zig b/tools/regz/src/gen.zig index 40cfecae..94f5782f 100644 --- a/tools/regz/src/gen.zig +++ b/tools/regz/src/gen.zig @@ -824,29 +824,19 @@ fn write_fields( } else if (db.attrs.@"enum".get(fields[i].id)) |enum_id| { if (db.attrs.name.get(enum_id)) |enum_name| { try writer.print( - // These were phased out in favor of using new builtins - // \\{}: packed union {{ - // \\ raw: u{}, - // \\ value: {}, - // \\}}, \\{}: {}, \\ , .{ std.zig.fmtId(name), - next.size, std.zig.fmtId(enum_name), }); } else { try writer.print( - // \\{}: packed union {{ - // \\ raw: u{}, - // \\ value: enum(u{}) {{ \\{}: enum(u{}) {{ \\ , .{ std.zig.fmtId(name), next.size, - next.size, }); try write_enum_fields(db, enum_id, writer); try writer.writeAll("},\n},\n"); From ace078d76d4ffb8fa5e6ff9a05745c20fc15cd40 Mon Sep 17 00:00:00 2001 From: Taylor Hillegeist Date: Thu, 3 Oct 2024 17:08:14 -0500 Subject: [PATCH 3/4] Update gen.zig Redid test cases. --- tools/regz/src/gen.zig | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tools/regz/src/gen.zig b/tools/regz/src/gen.zig index 94f5782f..5007e679 100644 --- a/tools/regz/src/gen.zig +++ b/tools/regz/src/gen.zig @@ -1113,10 +1113,7 @@ test "gen.field with named enum" { \\ }; \\ \\ TEST_REGISTER: mmio.Mmio(packed struct(u8) { - \\ TEST_FIELD: packed union { - \\ raw: u4, - \\ value: TEST_ENUM, - \\ }, + \\ TEST_FIELD: TEST_ENUM, \\ padding: u4, \\ }), \\ }; @@ -1142,13 +1139,10 @@ test "gen.field with anonymous enum" { \\ pub const peripherals = struct { \\ pub const TEST_PERIPHERAL = extern struct { \\ TEST_REGISTER: mmio.Mmio(packed struct(u8) { - \\ TEST_FIELD: packed union { - \\ raw: u4, - \\ value: enum(u4) { - \\ TEST_ENUM_FIELD1 = 0x0, - \\ TEST_ENUM_FIELD2 = 0x1, - \\ _, - \\ }, + \\ TEST_FIELD: enum(u4) { + \\ TEST_ENUM_FIELD1 = 0x0, + \\ TEST_ENUM_FIELD2 = 0x1, + \\ _, \\ }, \\ padding: u4, \\ }), From 02456c59688b158fa96cbc22c8e5dbc01267bb1d Mon Sep 17 00:00:00 2001 From: Taylor Hillegeist Date: Mon, 21 Oct 2024 09:48:34 -0500 Subject: [PATCH 4/4] Update gen.zig Unmatched closing bracket. --- tools/regz/src/gen.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/regz/src/gen.zig b/tools/regz/src/gen.zig index 5007e679..a85b9602 100644 --- a/tools/regz/src/gen.zig +++ b/tools/regz/src/gen.zig @@ -839,7 +839,7 @@ fn write_fields( next.size, }); try write_enum_fields(db, enum_id, writer); - try writer.writeAll("},\n},\n"); + try writer.writeAll("},\n"); } } else { try writer.print("{}: u{},\n", .{ std.zig.fmtId(name), next.size });