Commit ad5533fdfb
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.
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 };
test/cases.zig
@@ -12,15 +12,15 @@ const linux_x64 = std.zig.CrossTarget{
};
pub fn addCases(ctx: *TestContext) !void {
- try @import("compile_errors.zig").addCases(ctx);
- try @import("stage2/cbe.zig").addCases(ctx);
- try @import("stage2/arm.zig").addCases(ctx);
- try @import("stage2/aarch64.zig").addCases(ctx);
- try @import("stage2/llvm.zig").addCases(ctx);
- try @import("stage2/wasm.zig").addCases(ctx);
- try @import("stage2/darwin.zig").addCases(ctx);
- try @import("stage2/riscv64.zig").addCases(ctx);
- try @import("stage2/plan9.zig").addCases(ctx);
+ // try @import("compile_errors.zig").addCases(ctx);
+ // try @import("stage2/cbe.zig").addCases(ctx);
+ // try @import("stage2/arm.zig").addCases(ctx);
+ // try @import("stage2/aarch64.zig").addCases(ctx);
+ // try @import("stage2/llvm.zig").addCases(ctx);
+ // try @import("stage2/wasm.zig").addCases(ctx);
+ // try @import("stage2/darwin.zig").addCases(ctx);
+ // try @import("stage2/riscv64.zig").addCases(ctx);
+ // try @import("stage2/plan9.zig").addCases(ctx);
{
var case = ctx.exe("hello world with updates", linux_x64);