authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-21 05:29:15+07:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-05-05 19:34:04+02:00
loge03ec51b4b47c6730462bed3f8d703767a7b33d9
tree0d26e76ef15620d344568e05f9868accfb70ee7e
parenta00d69ea4a8c6e21ca99daa10d3b324609f3ef24

stage2: sparcv9: Pad branch delay slots with nops


1 files changed, 17 insertions(+), 1 deletions(-)

src/arch/sparcv9/CodeGen.zig+17-1
......@@ -394,7 +394,11 @@ fn gen(self: *Self) !void {
394394 },
395395 });
396396
397 // TODO Find a way to fill this slot
397 // Branches in SPARC have a delay slot, that is, the instruction
398 // following it will unconditionally be executed.
399 // See: Section 3.2.3 Control Transfer in SPARCv9 manual.
400 // See also: https://arcb.csc.ncsu.edu/~mueller/codeopt/codeopt00/notes/delaybra.html
401 // TODO Find a way to fill this delay slot
398402 // nop
399403 _ = try self.addInst(.{
400404 .tag = .nop,
......@@ -895,6 +899,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
895899 },
896900 },
897901 });
902
903 // TODO Find a way to fill this delay slot
904 _ = try self.addInst(.{
905 .tag = .nop,
906 .data = .{ .nop = {} },
907 });
898908 } else if (func_value.castTag(.extern_fn)) |_| {
899909 return self.fail("TODO implement calling extern functions", .{});
900910 } else {
......@@ -917,6 +927,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
917927 },
918928 },
919929 });
930
931 // TODO Find a way to fill this delay slot
932 _ = try self.addInst(.{
933 .tag = .nop,
934 .data = .{ .nop = {} },
935 });
920936 }
921937
922938 const result = info.return_value;