authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-01 22:23:19+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-14 22:18:06+07:00
log71cd3466ec129404a9cc6679f25b0dde8623b094
treee3323629e7f9ed640f60a576989e609996f5937f
parent18c98eb4293ced51689ad67f15575afc120ceee1

stage2: sparcv9: Adjust RegisterManager settings


2 files changed, 20 insertions(+), 4 deletions(-)

src/arch/sparcv9/CodeGen.zig+4-1
......@@ -16,6 +16,8 @@ const Type = @import("../../type.zig").Type;
1616const GenerateSymbolError = @import("../../codegen.zig").GenerateSymbolError;
1717const FnResult = @import("../../codegen.zig").FnResult;
1818const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput;
19const RegisterManagerFn = @import("../../register_manager.zig").RegisterManager;
20const RegisterManager = RegisterManagerFn(Self, Register, &abi.allocatable_regs);
1921
2022const build_options = @import("build_options");
2123
......@@ -73,6 +75,8 @@ branch_stack: *std.ArrayList(Branch),
7375// Key is the block instruction
7476blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, BlockData) = .{},
7577
78register_manager: RegisterManager = .{},
79
7680/// Maps offset to what is stored there.
7781stack: std.AutoHashMapUnmanaged(u32, StackAllocation) = .{},
7882
......@@ -380,7 +384,6 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, is_caller: bool) !Ca
380384 return result;
381385}
382386
383/// Caller must call `CallMCValues.deinit`.
384387fn gen(self: *Self) !void {
385388 const cc = self.fn_type.fnCallingConvention();
386389 if (cc != .Naked) {
src/arch/sparcv9/abi.zig+16-3
......@@ -1,9 +1,22 @@
11const bits = @import("bits.zig");
22const Register = bits.Register;
33
4// Register windowing mechanism will take care of preserving registers
5// so no need to do it manually
6pub const callee_preserved_regs = [_]Register{};
4// There are no callee-preserved registers since the windowing
5// mechanism already takes care of them.
6// We still need to preserve %o0-%o5, %g1, %g4, and %g5 before calling
7// something, though, as those are shared with the callee and might be
8// thrashed by it.
9pub const caller_preserved_regs = [_]Register{ .o0, .o1, .o2, .o3, .o4, .o5, .g1, .g4, .g5 };
10
11// Try to allocate i, l, o, then g sets of registers, in order of priority.
12pub const allocatable_regs = [_]Register{
13 // zig fmt: off
14 .@"i0", .@"i1", .@"i2", .@"i3", .@"i4", .@"i5",
15 .l0, .l1, .l2, .l3, .l4, .l5, .l6, .l7,
16 .o0, .o1, .o2, .o3, .o4, .o5,
17 .g1, .g4, .g5,
18 // zig fmt: on
19};
720
821pub const c_abi_int_param_regs_caller_view = [_]Register{ .o0, .o1, .o2, .o3, .o4, .o5 };
922pub const c_abi_int_param_regs_callee_view = [_]Register{ .@"i0", .@"i1", .@"i2", .@"i3", .@"i4", .@"i5" };