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 {...@@ -394,7 +394,11 @@ fn gen(self: *Self) !void {
394 },394 },
395 });395 });
396396
397 // TODO Find a way to fill this slot397 // 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
398 // nop402 // nop
399 _ = try self.addInst(.{403 _ = try self.addInst(.{
400 .tag = .nop,404 .tag = .nop,
...@@ -895,6 +899,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions....@@ -895,6 +899,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
895 },899 },
896 },900 },
897 });901 });
902
903 // TODO Find a way to fill this delay slot
904 _ = try self.addInst(.{
905 .tag = .nop,
906 .data = .{ .nop = {} },
907 });
898 } else if (func_value.castTag(.extern_fn)) |_| {908 } else if (func_value.castTag(.extern_fn)) |_| {
899 return self.fail("TODO implement calling extern functions", .{});909 return self.fail("TODO implement calling extern functions", .{});
900 } else {910 } else {
...@@ -917,6 +927,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions....@@ -917,6 +927,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
917 },927 },
918 },928 },
919 });929 });
930
931 // TODO Find a way to fill this delay slot
932 _ = try self.addInst(.{
933 .tag = .nop,
934 .data = .{ .nop = {} },
935 });
920 }936 }
921937
922 const result = info.return_value;938 const result = info.return_value;