From bb91e601992a664920df0dc0ff62e17283c503be Mon Sep 17 00:00:00 2001 From: veclav talica Date: Wed, 20 Sep 2023 12:44:50 +0500 Subject: [PATCH] test coverage for integers on stack for sys --- src/arch/x86-64/ve-sistema.zig | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/arch/x86-64/ve-sistema.zig b/src/arch/x86-64/ve-sistema.zig index 280024b..98a7f63 100644 --- a/src/arch/x86-64/ve-sistema.zig +++ b/src/arch/x86-64/ve-sistema.zig @@ -208,14 +208,28 @@ fn addInt6(a: u64, b: u32, c: u16, d: u8, e: u64, f: i32) callconv(.SysV) void { @panic("addInt6"); } +fn addInt7(a: u64, b: u32, c: u16, d: u8, e: u64, f: i32, sa: u32) callconv(.SysV) void { + @setAlignStack(16); + if ((a + b + c + d + e + @as(u64, @intCast(f)) + sa) != 30) + @panic("addInt7"); +} + +fn addInt8(a: u64, b: u32, c: u16, d: u8, e: u64, f: i32, sa: u32, sb: u8) callconv(.SysV) void { + @setAlignStack(16); + if ((a + b + c + d + e + @as(u64, @intCast(f)) + sa + sb) != 40) + @panic("addInt8"); +} + const opZov1Int = generateOpZovSysvFromPrototype(addInt1) catch unreachable; const opZov2Ints = generateOpZovSysvFromPrototype(addInt2) catch unreachable; const opZov3Ints = generateOpZovSysvFromPrototype(addInt3) catch unreachable; const opZov4Ints = generateOpZovSysvFromPrototype(addInt4) catch unreachable; const opZov5Ints = generateOpZovSysvFromPrototype(addInt5) catch unreachable; const opZov6Ints = generateOpZovSysvFromPrototype(addInt6) catch unreachable; +const opZov7Ints = generateOpZovSysvFromPrototype(addInt7) catch unreachable; +const opZov8Ints = generateOpZovSysvFromPrototype(addInt8) catch unreachable; -test "integer register passing" { +test "integer parameter passing" { const code = [_]tolmac.Word{ @as(tolmac.Word, @intFromPtr(&tolmac.opPushWord)), 1, @@ -241,6 +255,16 @@ test "integer register passing" { 4, @as(tolmac.Word, @intFromPtr(opZov6Ints)), @as(tolmac.Word, @intFromPtr(&addInt6)), + @as(tolmac.Word, @intFromPtr(&tolmac.opPushWord)), + 15, + @as(tolmac.Word, @intFromPtr(opZov7Ints)), + @as(tolmac.Word, @intFromPtr(&addInt7)), + @as(tolmac.Word, @intFromPtr(&tolmac.opPushWord)), + 10, + @as(tolmac.Word, @intFromPtr(opZov8Ints)), + @as(tolmac.Word, @intFromPtr(&addInt8)), + @as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)), + @as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)), @as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)), @as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)), @as(tolmac.Word, @intFromPtr(&tolmac.opSinkWord)),