| ... | @@ -84,15 +84,13 @@ pub const Register = enum(u7) { | ... | @@ -84,15 +84,13 @@ pub const Register = enum(u7) { |
| 84 | /// Returns the index into `callee_preserved_regs`. | 84 | /// Returns the index into `callee_preserved_regs`. |
| 85 | pub fn allocIndex(self: Register) ?u4 { | 85 | pub fn allocIndex(self: Register) ?u4 { |
| 86 | return switch (self) { | 86 | return switch (self) { |
| 87 | .rax, .eax, .ax, .al => 0, | 87 | .rcx, .ecx, .cx, .cl => 0, |
| 88 | .rcx, .ecx, .cx, .cl => 1, | 88 | .rsi, .esi, .si => 1, |
| 89 | .rdx, .edx, .dx, .dl => 2, | 89 | .rdi, .edi, .di => 2, |
| 90 | .rsi, .esi, .si => 3, | 90 | .r8, .r8d, .r8w, .r8b => 3, |
| 91 | .rdi, .edi, .di => 4, | 91 | .r9, .r9d, .r9w, .r9b => 4, |
| 92 | .r8, .r8d, .r8w, .r8b => 5, | 92 | .r10, .r10d, .r10w, .r10b => 5, |
| 93 | .r9, .r9d, .r9w, .r9b => 6, | 93 | .r11, .r11d, .r11w, .r11b => 6, |
| 94 | .r10, .r10d, .r10w, .r10b => 7, | | |
| 95 | .r11, .r11d, .r11w, .r11b => 8, | | |
| 96 | else => null, | 94 | else => null, |
| 97 | }; | 95 | }; |
| 98 | } | 96 | } |
| ... | @@ -145,7 +143,8 @@ pub const Register = enum(u7) { | ... | @@ -145,7 +143,8 @@ pub const Register = enum(u7) { |
| 145 | // zig fmt: on | 143 | // zig fmt: on |
| 146 | | 144 | |
| 147 | /// These registers belong to the called function. | 145 | /// These registers belong to the called function. |
| 148 | pub const callee_preserved_regs = [_]Register{ .rax, .rcx, .rdx, .rsi, .rdi, .r8, .r9, .r10, .r11 }; | 146 | /// TODO should the return_regs be in this array? |
| | 147 | pub const callee_preserved_regs = [_]Register{ .rcx, .rsi, .rdi, .r8, .r9, .r10, .r11 }; |
| 149 | pub const c_abi_int_param_regs = [_]Register{ .rdi, .rsi, .rdx, .rcx, .r8, .r9 }; | 148 | pub const c_abi_int_param_regs = [_]Register{ .rdi, .rsi, .rdx, .rcx, .r8, .r9 }; |
| 150 | pub const c_abi_int_return_regs = [_]Register{ .rax, .rdx }; | 149 | pub const c_abi_int_return_regs = [_]Register{ .rax, .rdx }; |
| 151 | | 150 | |