authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-03-29 20:37:32+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-14 22:18:05+07:00
logcf13356dabd79219499bddb63551f61a67a510bb
tree00143bc1f15f62d7a55418d5bea0b6587fe32a87
parent1ba52272167b12ea14f688df7d0d34940d98ff5b

stage2: sparcv9: Mir extraData implementation


2 files changed, 21 insertions(+), 0 deletions(-)

src/arch/riscv64/Mir.zig+1
......@@ -144,3 +144,4 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end
144144 .end = i,
145145 };
146146}
147
src/arch/sparcv9/Mir.zig+20
......@@ -58,3 +58,23 @@ pub fn deinit(mir: *Mir, gpa: std.mem.Allocator) void {
5858 mir.* = undefined;
5959}
6060
61/// Returns the requested data, as well as the new index which is at the start of the
62/// trailers for the object.
63pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end: usize } {
64 const fields = std.meta.fields(T);
65 var i: usize = index;
66 var result: T = undefined;
67 inline for (fields) |field| {
68 @field(result, field.name) = switch (field.field_type) {
69 u32 => mir.extra[i],
70 i32 => @bitCast(i32, mir.extra[i]),
71 else => @compileError("bad field type"),
72 };
73 i += 1;
74 }
75 return .{
76 .data = result,
77 .end = i,
78 };
79}
80