aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-11-19 22:18:56 +0100
committerJakub Konka <kubkon@jakubkonka.com>2021-11-19 22:18:56 +0100
commitad5533fdfb37a04f3fa938673dff931225457708 (patch)
tree3908e080ee1fd9fee22ab20a4e651f48eba5da87 /src
parent18a909f61d87d6b8e89147b7b46d8d0785b24b4d (diff)
downloadzig-ad5533fdfb37a04f3fa938673dff931225457708.tar.gz
zig-ad5533fdfb37a04f3fa938673dff931225457708.zip
stage2,x86_64: revert fixing callee preserved regs
This will require further rework in the codegen so reverting for now.
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/bits.zig15
-rw-r--r--src/arch/x86_64/bits.zig21
2 files changed, 16 insertions, 20 deletions
diff --git a/src/arch/x86/bits.zig b/src/arch/x86/bits.zig
index 8231908956..9af71b8a78 100644
--- a/src/arch/x86/bits.zig
+++ b/src/arch/x86/bits.zig
@@ -32,9 +32,11 @@ pub const Register = enum(u8) {
/// Returns the index into `callee_preserved_regs`.
pub fn allocIndex(self: Register) ?u4 {
return switch (self) {
- .ebx, .bx, .bl => 0,
- .esi, .si => 1,
- .edi, .di => 2,
+ .eax, .ax, .al => 0,
+ .ecx, .cx, .cl => 1,
+ .edx, .dx, .dl => 2,
+ .esi, .si => 3,
+ .edi, .di => 4,
else => null,
};
}
@@ -72,11 +74,8 @@ pub const Register = enum(u8) {
// zig fmt: on
-/// These registers need to be preserved (saved on the stack) and restored by the callee before getting clobbered
-/// and when the callee returns.
-/// Note that .esp and .ebp also belong to this set, however, we never expect to use them
-/// for anything else but stack offset tracking therefore we exclude them from this set.
-pub const callee_preserved_regs = [_]Register{ .ebx, .esi, .edi };
+/// TODO this set is actually a set of caller-saved registers.
+pub const callee_preserved_regs = [_]Register{ .eax, .ecx, .edx, .esi, .edi };
// TODO add these to Register enum and corresponding dwarfLocOp
// // Return Address register. This is stored in `0(%esp, "")` and is not a physical register.
diff --git a/src/arch/x86_64/bits.zig b/src/arch/x86_64/bits.zig
index 73c3abc8db..46da8a247e 100644
--- a/src/arch/x86_64/bits.zig
+++ b/src/arch/x86_64/bits.zig
@@ -84,11 +84,13 @@ pub const Register = enum(u7) {
/// Returns the index into `callee_preserved_regs`.
pub fn allocIndex(self: Register) ?u4 {
return switch (self) {
- .rbx, .ebx, .bx, .bl => 0,
- .r12, .r12d, .r12w, .r12b => 1,
- .r13, .r13d, .r13w, .r13b => 2,
- .r14, .r14d, .r14w, .r14b => 3,
- .r15, .r15d, .r15w, .r15b => 4,
+ .rcx, .ecx, .cx, .cl => 0,
+ .rsi, .esi, .si => 1,
+ .rdi, .edi, .di => 2,
+ .r8, .r8d, .r8w, .r8b => 3,
+ .r9, .r9d, .r9w, .r9b => 4,
+ .r10, .r10d, .r10w, .r10b => 5,
+ .r11, .r11d, .r11w, .r11b => 6,
else => null,
};
}
@@ -140,15 +142,10 @@ pub const Register = enum(u7) {
// zig fmt: on
+/// TODO this set is actually a set of caller-saved registers.
/// These registers need to be preserved (saved on the stack) and restored by the callee before getting clobbered
/// and when the callee returns.
-/// Note that .rsp and .rbp also belong to this set, however, we never expect to use them
-/// for anything else but stack offset tracking therefore we exclude them from this set.
-pub const callee_preserved_regs = [_]Register{ .rbx, .r12, .r13, .r14, .r15 };
-/// These registers need to be preserved (saved on the stack) and restored by the caller before
-/// the caller relinquishes control to a subroutine via call instruction (or similar).
-/// In other words, these registers are free to use by the callee.
-pub const caller_preserved_regs = [_]Register{ .rax, .rcx, .rdx, .rsi, .rdi, .r8, .r9, .r10, .r11 };
+pub const callee_preserved_regs = [_]Register{ .rcx, .rsi, .rdi, .r8, .r9, .r10, .r11 };
pub const c_abi_int_param_regs = [_]Register{ .rdi, .rsi, .rdx, .rcx, .r8, .r9 };
pub const c_abi_int_return_regs = [_]Register{ .rax, .rdx };