ir/tests/run/vaarg_003.irt
2023-11-30 21:10:41 +03:00

64 lines
1.5 KiB
Plaintext

--TEST--
VA_ARG 003: va_arg(float)
--ARGS--
--run
--CODE--
extern func printf(uintptr_t, ...): int32_t;
func sum(int32_t, ...): float
{
int32_t c_4 = 32;
int32_t c_5 = 1;
int32_t c_6 = 0;
float c_7 = 0;
l_1 = START(l_25);
int32_t d_2 = PARAM(l_1, "arg_1", 1);
uintptr_t d_3, l_3 = ALLOCA(l_1, c_4);
l_4 = VA_START(l_3, d_3);
bool d_5 = GT(d_2, c_6);
l_6 = IF(l_4, d_5);
l_7 = IF_FALSE(l_6, 1);
l_8 = END(l_7);
l_9 = IF_TRUE(l_6);
l_10 = END(l_9);
l_11 = LOOP_BEGIN(l_10, l_19);
int32_t d_12 = PHI(l_11, d_2, d_16);
float d_13 = PHI(l_11, c_7, d_15);
float d_14, l_14 = VA_ARG(l_11, d_3);
float d_15 = ADD(d_14, d_13);
int32_t d_16 = SUB(d_12, c_5);
l_17 = IF(l_14, d_16);
l_18 = IF_TRUE(l_17);
l_19 = LOOP_END(l_18);
l_20 = IF_FALSE(l_17);
l_21 = END(l_20);
l_22 = MERGE(l_8, l_21);
float d_23 = PHI(l_22, c_7, d_15);
l_24 = VA_END(l_22, d_3);
l_25 = RETURN(l_24, d_23);
}
func main(void): int32_t
{
int32_t c_4 = 10;
float c_5 = 1.0;
float c_6 = 2.0;
float c_7 = 3.0;
float c_8 = 4.0;
float c_9 = 5.0;
float c_10 = 6.0;
float c_11 = 7.0;
float c_12 = 8.0;
float c_13 = 9.0;
float c_14 = 10.0;
uintptr_t sum = func sum(int32_t, ...): float;
uintptr_t str = "sum %g\n";
uintptr_t printf = func printf(uintptr_t, ...): int32_t;
int32_t ret = 0;
l_1 = START(l_8);
float d_2, l_2 = CALL/11(l_1, sum, c_4, c_5, c_6, c_7, c_8, c_9, c_10, c_11, c_12, c_13, c_14);
double d_5 = FP2FP(d_2);
int32_t d_6, l_6 = CALL/2(l_2, printf, str, d_5);
l_8 = RETURN(l_6, ret);
}
--EXPECT--
sum 55