2 * Test R5900-specific three-operand MULT and MULT1.
9 static int64_t mult(int32_t rs
, int32_t rt
)
14 __asm__
__volatile__ (
18 : "=r" (rd
), "=r" (lo
), "=r" (hi
)
19 : "r" (rs
), "r" (rt
));
20 r
= ((int64_t)hi
<< 32) | (uint32_t)lo
;
22 assert((int64_t)rs
* rt
== r
);
28 static int64_t mult1(int32_t rs
, int32_t rt
)
33 __asm__
__volatile__ (
37 : "=r" (rd
), "=r" (lo
), "=r" (hi
)
38 : "r" (rs
), "r" (rt
));
39 r
= ((int64_t)hi
<< 32) | (uint32_t)lo
;
41 assert((int64_t)rs
* rt
== r
);
47 static int64_t mult_variants(int32_t rs
, int32_t rt
)
49 int64_t rd
= mult(rs
, rt
);
50 int64_t rd1
= mult1(rs
, rt
);
57 static void verify_mult_negations(int32_t rs
, int32_t rt
, int64_t expected
)
59 assert(mult_variants(rs
, rt
) == expected
);
60 assert(mult_variants(-rs
, rt
) == -expected
);
61 assert(mult_variants(rs
, -rt
) == -expected
);
62 assert(mult_variants(-rs
, -rt
) == expected
);
67 verify_mult_negations(17, 19, 323);
68 verify_mult_negations(77773, 99991, 7776600043);
69 verify_mult_negations(12207031, 305175781, 3725290219116211);
71 assert(mult_variants(-0x80000000, 0x7FFFFFFF) == -0x3FFFFFFF80000000);
72 assert(mult_variants(-0x80000000, -0x7FFFFFFF) == 0x3FFFFFFF80000000);
73 assert(mult_variants(-0x80000000, -0x80000000) == 0x4000000000000000);