2 * Test R5900-specific three-operand MADD and MADD1.
9 int64_t madd(int64_t a
, int32_t rs
, int32_t rt
)
16 __asm__
__volatile__ (
22 : "=r" (rd
), "=r" (lo
), "=r" (hi
)
23 : "r" (rs
), "r" (rt
), "r" (lo
), "r" (hi
));
24 r
= ((int64_t)hi
<< 32) | (uint32_t)lo
;
26 assert(a
+ (int64_t)rs
* rt
== r
);
32 int64_t madd1(int64_t a
, int32_t rs
, int32_t rt
)
39 __asm__
__volatile__ (
45 : "=r" (rd
), "=r" (lo
), "=r" (hi
)
46 : "r" (rs
), "r" (rt
), "r" (lo
), "r" (hi
));
47 r
= ((int64_t)hi
<< 32) | (uint32_t)lo
;
49 assert(a
+ (int64_t)rs
* rt
== r
);
55 static int64_t madd_variants(int64_t a
, int32_t rs
, int32_t rt
)
57 int64_t rd
= madd(a
, rs
, rt
);
58 int64_t rd1
= madd1(a
, rs
, rt
);
65 static void verify_madd(int64_t a
, int32_t rs
, int32_t rt
, int64_t expected
)
67 assert(madd_variants(a
, rs
, rt
) == expected
);
68 assert(madd_variants(a
, -rs
, rt
) == a
+ a
- expected
);
69 assert(madd_variants(a
, rs
, -rt
) == a
+ a
- expected
);
70 assert(madd_variants(a
, -rs
, -rt
) == expected
);
75 verify_madd(13, 17, 19, 336);