Re: [PATCH v3 4/4] tests/tcg/s390x: Test CONVERT TO BINARY
On 01/02/2024 00.07, Ilya Leoshkevich wrote: Check the CVB's and CVBG's corner cases. Co-developed-by: Pavel Zbitskiy Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/cvb.c | 47 + 2 files changed, 48 insertions(+) create mode 100644 tests/tcg/s390x/cvb.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 04e4bddd83d..e2aba2ec274 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -46,6 +46,7 @@ TESTS+=laalg TESTS+=add-logical-with-carry TESTS+=lae TESTS+=cvd +TESTS+=cvb cdsg: CFLAGS+=-pthread cdsg: LDFLAGS+=-pthread diff --git a/tests/tcg/s390x/cvb.c b/tests/tcg/s390x/cvb.c new file mode 100644 index 000..47b7a7965f4 --- /dev/null +++ b/tests/tcg/s390x/cvb.c @@ -0,0 +1,47 @@ +/* + * Test the CONVERT TO DECIMAL instruction. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include + +static int32_t cvb(uint64_t x) +{ +uint32_t ret; + +asm("cvb %[ret],%[x]" : [ret] "=r" (ret) : [x] "R" (x)); + +return ret; +} + +static int64_t cvbg(__uint128_t x) +{ +int64_t ret; + +asm("cvbg %[ret],%[x]" : [ret] "=r" (ret) : [x] "T" (x)); + +return ret; +} Just to be on the safe side, could you please add a check for CVBY, too? Thanks, Thomas
Re: [PATCH v3 4/4] tests/tcg/s390x: Test CONVERT TO BINARY
On 01/02/2024 00.07, Ilya Leoshkevich wrote: Check the CVB's and CVBG's corner cases. Co-developed-by: Pavel Zbitskiy Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/cvb.c | 47 + 2 files changed, 48 insertions(+) create mode 100644 tests/tcg/s390x/cvb.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 04e4bddd83d..e2aba2ec274 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -46,6 +46,7 @@ TESTS+=laalg TESTS+=add-logical-with-carry TESTS+=lae TESTS+=cvd +TESTS+=cvb cdsg: CFLAGS+=-pthread cdsg: LDFLAGS+=-pthread diff --git a/tests/tcg/s390x/cvb.c b/tests/tcg/s390x/cvb.c new file mode 100644 index 000..47b7a7965f4 --- /dev/null +++ b/tests/tcg/s390x/cvb.c @@ -0,0 +1,47 @@ +/* + * Test the CONVERT TO DECIMAL instruction. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include + +static int32_t cvb(uint64_t x) +{ +uint32_t ret; + +asm("cvb %[ret],%[x]" : [ret] "=r" (ret) : [x] "R" (x)); + +return ret; +} + +static int64_t cvbg(__uint128_t x) +{ +int64_t ret; + +asm("cvbg %[ret],%[x]" : [ret] "=r" (ret) : [x] "T" (x)); + +return ret; +} + +int main(void) +{ +__uint128_t m = (((__uint128_t)0x9223372036854775) << 16) | 0x8070; + +assert(cvb(0xc) == 0); +assert(cvb(0x1c) == 1); +assert(cvb(0x25594c) == 25594); +assert(cvb(0x1d) == -1); +assert(cvb(0x2147483647c) == 0x7fff); +assert(cvb(0x2147483647d) == -0x7fff); + +assert(cvbg(0xc) == 0); +assert(cvbg(0x1c) == 1); +assert(cvbg(0x25594c) == 25594); +assert(cvbg(0x1d) == -1); +assert(cvbg(m | 0xc) == 0x7fff); +assert(cvbg(m | 0xd) == -0x7fff); + +return EXIT_SUCCESS; +} Reviewed-by: Thomas Huth
[PATCH v3 4/4] tests/tcg/s390x: Test CONVERT TO BINARY
Check the CVB's and CVBG's corner cases. Co-developed-by: Pavel Zbitskiy Signed-off-by: Ilya Leoshkevich --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/cvb.c | 47 + 2 files changed, 48 insertions(+) create mode 100644 tests/tcg/s390x/cvb.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 04e4bddd83d..e2aba2ec274 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -46,6 +46,7 @@ TESTS+=laalg TESTS+=add-logical-with-carry TESTS+=lae TESTS+=cvd +TESTS+=cvb cdsg: CFLAGS+=-pthread cdsg: LDFLAGS+=-pthread diff --git a/tests/tcg/s390x/cvb.c b/tests/tcg/s390x/cvb.c new file mode 100644 index 000..47b7a7965f4 --- /dev/null +++ b/tests/tcg/s390x/cvb.c @@ -0,0 +1,47 @@ +/* + * Test the CONVERT TO DECIMAL instruction. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include + +static int32_t cvb(uint64_t x) +{ +uint32_t ret; + +asm("cvb %[ret],%[x]" : [ret] "=r" (ret) : [x] "R" (x)); + +return ret; +} + +static int64_t cvbg(__uint128_t x) +{ +int64_t ret; + +asm("cvbg %[ret],%[x]" : [ret] "=r" (ret) : [x] "T" (x)); + +return ret; +} + +int main(void) +{ +__uint128_t m = (((__uint128_t)0x9223372036854775) << 16) | 0x8070; + +assert(cvb(0xc) == 0); +assert(cvb(0x1c) == 1); +assert(cvb(0x25594c) == 25594); +assert(cvb(0x1d) == -1); +assert(cvb(0x2147483647c) == 0x7fff); +assert(cvb(0x2147483647d) == -0x7fff); + +assert(cvbg(0xc) == 0); +assert(cvbg(0x1c) == 1); +assert(cvbg(0x25594c) == 25594); +assert(cvbg(0x1d) == -1); +assert(cvbg(m | 0xc) == 0x7fff); +assert(cvbg(m | 0xd) == -0x7fff); + +return EXIT_SUCCESS; +} -- 2.43.0