Skip to content

Commit

Permalink
tests/tcg/loongarch64: Add fp comparison instructions test
Browse files Browse the repository at this point in the history
Choose some instructions to test:
- FCMP.cond.S
- cond: ceq clt cle cne seq slt sle sne

Signed-off-by: Song Gao <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
  • Loading branch information
gaosong-loongson authored and rth7680 committed Jul 19, 2022
1 parent 65cb15f commit 500cd33
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/tcg/loongarch64/Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ LDFLAGS+=-lm
LOONGARCH64_TESTS = test_bit
LOONGARCH64_TESTS += test_div
LOONGARCH64_TESTS += test_fclass
LOONGARCH64_TESTS += test_fpcom

TESTS += $(LOONGARCH64_TESTS)
37 changes: 37 additions & 0 deletions tests/tcg/loongarch64/test_fpcom.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <assert.h>

#define TEST_COMP(N) \
void test_##N(float fj, float fk) \
{ \
int rd = 0; \
\
asm volatile("fcmp."#N".s $fcc6,%1,%2\n" \
"movcf2gr %0, $fcc6\n" \
: "=r"(rd) \
: "f"(fj), "f"(fk) \
: ); \
assert(rd == 1); \
}

TEST_COMP(ceq)
TEST_COMP(clt)
TEST_COMP(cle)
TEST_COMP(cne)
TEST_COMP(seq)
TEST_COMP(slt)
TEST_COMP(sle)
TEST_COMP(sne)

int main()
{
test_ceq(0xff700102, 0xff700102);
test_clt(0x00730007, 0xff730007);
test_cle(0xff70130a, 0xff70130b);
test_cne(0x1238acde, 0xff71111f);
test_seq(0xff766618, 0xff766619);
test_slt(0xff78881c, 0xff78901d);
test_sle(0xff780b22, 0xff790b22);
test_sne(0xff7bcd25, 0xff7a26cf);

return 0;
}

0 comments on commit 500cd33

Please sign in to comment.