ir/tests/debug/call2.irt
Dmitry Stogov 09829a9e69 Fixed x86_64 calling convention for vararg functions
%al is used as a hidden register to specify the number of passed vector registers
2023-09-27 10:23:34 +03:00

47 lines
866 B
Plaintext

--TEST--
CALL with parallel argument passing
--TARGET--
x86_64
--ARGS--
-S
--CODE--
{
uintptr_t c_1 = 0;
bool c_2 = 0;
bool c_3 = 1;
int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4);
uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4);
int32_t p_1 = PARAM(l_1, "p1", 1);
int32_t p_2 = PARAM(l_1, "p2", 1);
int32_t p_3 = PARAM(l_1, "p3", 1);
int32_t p_4 = PARAM(l_1, "p4", 1);
int32_t d_2, l_2 = CALL/4(l_1, c_5, c_6, p_3, p_4, p_2);
int32_t d_3 = ADD(d_2, p_1);
l_4 = RETURN(l_2, d_3);
}
--EXPECT--
test:
subq $8, %rsp
movq %rbx, (%rsp)
movl %edi, %ebx
movl %ecx, %eax
movl %esi, %ecx
movl %edx, %esi
movl %eax, %edx
leaq .L1(%rip), %rdi
movl $0, %eax
movabsq $printf, %r11
callq *%r11
addl %ebx, %eax
movq (%rsp), %rbx
addq $8, %rsp
retq
.rodata
.db 0x90, 0x90
.L1:
.db 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x25, 0x64, 0x21, 0x0a, 0x00