Skip to contentSkip to conversation

tests/tcg: Add MIPS32 Release 6 tests

PATCH Superseded Philippe Mathieu-Daudé 2 participants 20 messages Oct 29 – Oct 30 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tests/tcg: Add MIPS32 Release 6 tests

- Include Bootlin mips32r6el toolchain in debian-all-test container
- Wire it to meson
- Cover all the 32-bit opcodes tested in MIPS64 Rel6 (using TAP)

Based-on: <[email protected]>

Philippe Mathieu-Daudé (12):
tests/docker: Add the mips32r6el toolchain
meson: Add the tcg_tests_cross_cc/cflags options for mips32r6el tests/tcg/mipsel: Add MIPS32R6 logic tests tests/tcg/mipsel: Add MIPS32R6 shift tests tests/tcg/mipsel: Add MIPS32R6 bit operation tests tests/tcg/mipsel: Add MIPS32R6 multiply tests tests/tcg/mipsel: Add MIPS32R6 PC-relative tests tests/tcg/mipsel: Test MIPS32R6 SELEQZ and SELNEZ tests/tcg/mipsel: Test MIPS32R6 DIV, MOD, DIVU and MODU tests/tcg/mipsel: Test MIPS32R6 LSA
tests/tcg/mipsel: Test MIPS32R6 BALC tests/tcg/mipsel: Test MIPS32R6 JIALC and JIC

 tests/tcg/mips/include/wrappers_mips32r6.h    |  91 +++++++++++++
 tests/tcg/mipsel/test_mips32r6_bitops.c       |  82 +++++++++++
 tests/tcg/mipsel/test_mips32r6_branch.c       | 128 ++++++++++++++++++
 tests/tcg/mipsel/test_mips32r6_logic.c        |  68 ++++++++++
 tests/tcg/mipsel/test_mips32r6_multiply.c     | 108 +++++++++++++++
 tests/tcg/mipsel/test_mips32r6_pcrel.c        |  95 +++++++++++++
 tests/tcg/mipsel/test_mips32r6_shift.c        |  84 ++++++++++++
 .../dockerfiles/debian-all-test-cross.docker  |  13 ++
 meson_options.txt                             |   4 +
 scripts/meson-buildoptions.sh                 |   2 +
 tests/tcg/mipsel/meson.build                  |  34 +++++
 11 files changed, 709 insertions(+)
 create mode 100644 tests/tcg/mips/include/wrappers_mips32r6.h
 create mode 100644 tests/tcg/mipsel/test_mips32r6_bitops.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_branch.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_logic.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_multiply.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_pcrel.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_shift.c
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/12 tests/docker: Add the mips32r6el toolchain

Similarly to commit eaba84a5e1c9 ("tests/docker/debian-all-test:
add mips32r5 toolchain"), add the Bootlin mips32r6el glibc toolchain, renaming its mipsel-* binaries as mips32r6el-*.

---
 .../docker/dockerfiles/debian-all-test-cross.docker | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/docker/dockerfiles/debian-all-test-cross.docker +13 -0
index eefc03c49a4f..d0e59df84ebc 100644
@@ -129,6 +129,19 @@ RUN apt update && \
   rename 's/mipsel/mips32r5el/' mipsel*
 ENV PATH="$PATH:/opt/mips32r5el/bin"
 
+# download mips32r6el toolchain from bootlin, and rename binaries who are simply
+# named mipsel-linux-gnu-*
+RUN apt update && \
+  mkdir -p /opt/mips32r6el/ && \
+  cd /opt/mips32r6el/ && \
+  wget -q https://toolchains.bootlin.com/downloads/releases/toolchains/mips32r6el/tarballs/mips32r6el--glibc--stable-2026.08-1.tar.xz && \
+  tar xvf *.tar.xz && \
+  rm *.tar.xz && \
+  mv mips32r6el--glibc--stable-2026.08-1/* . && \
+  cd bin && \
+  rename 's/mipsel/mips32r6el/' mipsel*
+ENV PATH="$PATH:/opt/mips32r6el/bin"
+
 ENV QEMU_CONFIGURE_OPTS=--disable-docs
 ENV DEF_TARGET_LIST=aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
 # As a final step configure the user (if env is defined)
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH 01/12] tests/docker: Add the mips32r6el toolchain

Quoted 23 lines · Philippe Mathieu-Daudé

Similarly to commit eaba84a5e1c9 ("tests/docker/debian-all-test:
add mips32r5 toolchain"), add the Bootlin mips32r6el glibc toolchain, renaming its mipsel-* binaries as mips32r6el-*.

---
 .../docker/dockerfiles/debian-all-test-cross.docker | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/docker/dockerfiles/debian-all-test-cross.docker +6 -0
index eefc03c49a4f..d0e59df84ebc 100644
@@ -129,6 +129,19 @@ RUN apt update && \
   rename 's/mipsel/mips32r5el/' mipsel*
 ENV PATH="$PATH:/opt/mips32r5el/bin"
 
+# download mips32r6el toolchain from bootlin, and rename binaries who are simply
+# named mipsel-linux-gnu-*
+RUN apt update && \
+  mkdir -p /opt/mips32r6el/ && \
+  cd /opt/mips32r6el/ && \
+  wget -q https://toolchains.bootlin.com/downloads/releases/toolchains/mips32r6el/tarballs/mips32r6el--glibc--stable-2026.08-1.tar.xz && \

tests/docker/dockerfiles/debian-all-test-cross.docker RUN apt update && \ · line 147

Quoted 10 lines
tests/docker/dockerfiles/debian-all-test-cross.docker +7 -0
+  tar xvf *.tar.xz && \
+  rm *.tar.xz && \
+  mv mips32r6el--glibc--stable-2026.08-1/* . && \
+  cd bin && \
+  rename 's/mipsel/mips32r6el/' mipsel*
+ENV PATH="$PATH:/opt/mips32r6el/bin"
+
 ENV QEMU_CONFIGURE_OPTS=--disable-docs
 ENV DEF_TARGET_LIST=aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
 # As a final step configure the user (if env is defined)

Would package mipsisa32r6el-linux-gnu (and companion libc) from debian work instead of this one?

I added mips32r5 toolchain from bootlin because there were no matching packages in debian, but I think it's better supported for mips32r6.

Regards,
Pierrick

#3 lore raw

Re: [PATCH 01/12] tests/docker: Add the mips32r6el toolchain

Quoted 38 lines · Pierrick Bouvier
Quoted 23 lines · Philippe Mathieu-Daudé

Similarly to commit eaba84a5e1c9 ("tests/docker/debian-all-test:
add mips32r5 toolchain"), add the Bootlin mips32r6el glibc toolchain, renaming its mipsel-* binaries as mips32r6el-*.

---
  .../docker/dockerfiles/debian-all-test-cross.docker | 13 +++++++++++++
  1 file changed, 13 insertions(+)
tests/docker/dockerfiles/debian-all-test-cross.docker +6 -0
index eefc03c49a4f..d0e59df84ebc 100644
@@ -129,6 +129,19 @@ RUN apt update && \
    rename 's/mipsel/mips32r5el/' mipsel*
  ENV PATH="$PATH:/opt/mips32r5el/bin"
 
+# download mips32r6el toolchain from bootlin, and rename binaries who are simply
+# named mipsel-linux-gnu-*
+RUN apt update && \
+  mkdir -p /opt/mips32r6el/ && \
+  cd /opt/mips32r6el/ && \
+  wget -q https://toolchains.bootlin.com/downloads/releases/toolchains/mips32r6el/tarballs/mips32r6el--glibc--stable-2026.08-1.tar.xz && \

tests/docker/dockerfiles/debian-all-test-cross.docker RUN apt update && \ · line 147

Quoted 10 lines
tests/docker/dockerfiles/debian-all-test-cross.docker +7 -0
+  tar xvf *.tar.xz && \
+  rm *.tar.xz && \
+  mv mips32r6el--glibc--stable-2026.08-1/* . && \
+  cd bin && \
+  rename 's/mipsel/mips32r6el/' mipsel*
+ENV PATH="$PATH:/opt/mips32r6el/bin"
+
  ENV QEMU_CONFIGURE_OPTS=--disable-docs
  ENV DEF_TARGET_LIST=aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
  # As a final step configure the user (if env is defined)

Would package mipsisa32r6el-linux-gnu (and companion libc) from debian work instead of this one?

Quoted 2 lines

I added mips32r5 toolchain from bootlin because there were no matching packages in debian, but I think it's better supported for mips32r6.

Indeed it works with the Debian toolchain, all the tests pass. The only difference is Debian packages older versions (GCC GCC 14.2.0 vs GCC 15.3.0 for Bootlin and glibc 2.40 vs 2.44), not important.

#4 lore raw

Re: [PATCH 01/12] tests/docker: Add the mips32r6el toolchain

Quoted 46 lines · Philippe Mathieu-Daudé
Quoted 45 lines · Pierrick Bouvier
Quoted 33 lines · Philippe Mathieu-Daudé

Similarly to commit eaba84a5e1c9 ("tests/docker/debian-all-test:
add mips32r5 toolchain"), add the Bootlin mips32r6el glibc toolchain, renaming its mipsel-* binaries as mips32r6el-*.

---
  .../docker/dockerfiles/debian-all-test-cross.docker | 13 +++++++++++++

  1 file changed, 13 insertions(+)
(quoted diff) renamed from tests/docker/dockerfiles/debian-all-test-cross.docker +0 -0

tests/docker/dockerfiles/debian-all-test-cross.docker index eefc03c49a4f..d0e59df84ebc 100644

tests/docker/dockerfiles/debian-all-test-cross.docker +0 -0
@@ -129,6 +129,19 @@ RUN apt update && \

    rename 's/mipsel/mips32r5el/' mipsel*
  ENV PATH="$PATH:/opt/mips32r5el/bin"
  +# download mips32r6el toolchain from bootlin, and rename binaries who are simply

tests/docker/dockerfiles/debian-all-test-cross.docker +5 -0
+# named mipsel-linux-gnu-*
+RUN apt update && \
+  mkdir -p /opt/mips32r6el/ && \
+  cd /opt/mips32r6el/ && \
+  wget -q https://toolchains.bootlin.com/downloads/releases/

toolchains/mips32r6el/tarballs/mips32r6el--glibc-- stable-2026.08-1.tar.xz && \
+  tar xvf *.tar.xz && \
+  rm *.tar.xz && \
+  mv mips32r6el--glibc--stable-2026.08-1/* . && \
+  cd bin && \
+  rename 's/mipsel/mips32r6el/' mipsel*

tests/docker/dockerfiles/debian-all-test-cross.docker +2 -0
+ENV PATH="$PATH:/opt/mips32r6el/bin"
+
Quoted 7 lines

  ENV QEMU_CONFIGURE_OPTS=--disable-docs
  ENV DEF_TARGET_LIST=aarch64-linux-user,alpha-linux-user,arm-linux- user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux- user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc- linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux- user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
  # As a final step configure the user (if env is defined)

Would package mipsisa32r6el-linux-gnu (and companion libc) from debian work instead of this one?

Quoted 5 lines
Quoted 2 lines

I added mips32r5 toolchain from bootlin because there were no matching packages in debian, but I think it's better supported for mips32r6.

Indeed it works with the Debian toolchain, all the tests pass. The only difference is Debian packages older versions (GCC GCC 14.2.0 vs GCC 15.3.0 for Bootlin and glibc 2.40 vs 2.44), not important.

No problem with this, that's a better choice since we don't introduce another external dependency.

Regards,
Pierrick

#5 lore raw

PATCH 2/12 meson: Add the tcg_tests_cross_cc/cflags options for mips32r6el

In reply to Philippe Mathieu-Daudé

Add meson tcg_tests_cross_cc/cflags options for mips32r6el, similarly of the previous mips32r5el commit c7b1a7bc9d33 ("tests/tcg/mipsel/mips32r5el: add msa tests"). This allows compiling TCG tests for the mips32r6el-linux-user targets.

---
 meson_options.txt             | 4 ++++
 scripts/meson-buildoptions.sh | 2 ++
 2 files changed, 6 insertions(+)
meson_options.txt +4 -0
index 895c6e63c28a..9ae8e44ab54e 100644
@@ -461,6 +461,10 @@ option('tcg_tests_cross_cc_mips32r5el', type: 'string',
        description: 'cc for mips32r5el tcg tests')
 option('tcg_tests_cross_cflags_mips32r5el', type: 'string',
        description: 'cflags for mips32r5el tcg tests')
+option('tcg_tests_cross_cc_mips32r6el', type: 'string',
+       description: 'cc for mips32r6el tcg tests')
+option('tcg_tests_cross_cflags_mips32r6el', type: 'string',
+       description: 'cflags for mips32r6el tcg tests')
 option('tcg_tests_cross_cc_or1k', type: 'string',
        description: 'cc for or1k tcg tests')
 option('tcg_tests_cross_cflags_or1k', type: 'string',
scripts/meson-buildoptions.sh +2 -0
index 14990966d31d..0f8b56bd7f8c 100644
@@ -539,6 +539,7 @@ _meson_option_parse() {
     --tcg-tests-cross-cc-m68k=*) quote_sh "-Dtcg_tests_cross_cc_m68k=$2" ;;
     --tcg-tests-cross-cc-mips=*) quote_sh "-Dtcg_tests_cross_cc_mips=$2" ;;
     --tcg-tests-cross-cc-mips32r5el=*) quote_sh "-Dtcg_tests_cross_cc_mips32r5el=$2" ;;
+    --tcg-tests-cross-cc-mips32r6el=*) quote_sh "-Dtcg_tests_cross_cc_mips32r6el=$2" ;;
     --tcg-tests-cross-cc-mips64=*) quote_sh "-Dtcg_tests_cross_cc_mips64=$2" ;;
     --tcg-tests-cross-cc-mips64el=*) quote_sh "-Dtcg_tests_cross_cc_mips64el=$2" ;;
     --tcg-tests-cross-cc-mips64r6=*) quote_sh "-Dtcg_tests_cross_cc_mips64r6=$2" ;;
@@ -566,6 +567,7 @@ _meson_option_parse() {
     --tcg-tests-cross-cflags-m68k=*) quote_sh "-Dtcg_tests_cross_cflags_m68k=$2" ;;
     --tcg-tests-cross-cflags-mips=*) quote_sh "-Dtcg_tests_cross_cflags_mips=$2" ;;
     --tcg-tests-cross-cflags-mips32r5el=*) quote_sh "-Dtcg_tests_cross_cflags_mips32r5el=$2" ;;
+    --tcg-tests-cross-cflags-mips32r6el=*) quote_sh "-Dtcg_tests_cross_cflags_mips32r6el=$2" ;;
     --tcg-tests-cross-cflags-mips64=*) quote_sh "-Dtcg_tests_cross_cflags_mips64=$2" ;;
     --tcg-tests-cross-cflags-mips64el=*) quote_sh "-Dtcg_tests_cross_cflags_mips64el=$2" ;;
     --tcg-tests-cross-cflags-mips64r6=*) quote_sh "-Dtcg_tests_cross_cflags_mips64r6=$2" ;;
Signature · 1 line
2.55.0
#6 lore raw

Re: [PATCH 02/12] meson: Add the tcg_tests_cross_cc/cflags options for mips32r6el

Quoted 39 lines · Philippe Mathieu-Daudé

Add meson tcg_tests_cross_cc/cflags options for mips32r6el, similarly of the previous mips32r5el commit c7b1a7bc9d33 ("tests/tcg/mipsel/mips32r5el: add msa tests"). This allows compiling TCG tests for the mips32r6el-linux-user targets.

---
 meson_options.txt             | 4 ++++
 scripts/meson-buildoptions.sh | 2 ++
 2 files changed, 6 insertions(+)
meson_options.txt +4 -0
index 895c6e63c28a..9ae8e44ab54e 100644
@@ -461,6 +461,10 @@ option('tcg_tests_cross_cc_mips32r5el', type: 'string',
        description: 'cc for mips32r5el tcg tests')
 option('tcg_tests_cross_cflags_mips32r5el', type: 'string',
        description: 'cflags for mips32r5el tcg tests')
+option('tcg_tests_cross_cc_mips32r6el', type: 'string',
+       description: 'cc for mips32r6el tcg tests')
+option('tcg_tests_cross_cflags_mips32r6el', type: 'string',
+       description: 'cflags for mips32r6el tcg tests')
 option('tcg_tests_cross_cc_or1k', type: 'string',
        description: 'cc for or1k tcg tests')
 option('tcg_tests_cross_cflags_or1k', type: 'string',
scripts/meson-buildoptions.sh +1 -0
index 14990966d31d..0f8b56bd7f8c 100644
@@ -539,6 +539,7 @@ _meson_option_parse() {
     --tcg-tests-cross-cc-m68k=*) quote_sh "-Dtcg_tests_cross_cc_m68k=$2" ;;
     --tcg-tests-cross-cc-mips=*) quote_sh "-Dtcg_tests_cross_cc_mips=$2" ;;
     --tcg-tests-cross-cc-mips32r5el=*) quote_sh "-Dtcg_tests_cross_cc_mips32r5el=$2" ;;
+    --tcg-tests-cross-cc-mips32r6el=*) quote_sh "-Dtcg_tests_cross_cc_mips32r6el=$2" ;;
     --tcg-tests-cross-cc-mips64=*) quote_sh "-Dtcg_tests_cross_cc_mips64=$2" ;;
     --tcg-tests-cross-cc-mips64el=*) quote_sh "-Dtcg_tests_cross_cc_mips64el=$2" ;;
     --tcg-tests-cross-cc-mips64r6=*) quote_sh "-Dtcg_tests_cross_cc_mips64r6=$2" ;;

scripts/meson-buildoptions.sh _meson_option_parse() { · line 573

Quoted 7 lines
scripts/meson-buildoptions.sh +1 -0
@@ -566,6 +567,7 @@ _meson_option_parse() {
     --tcg-tests-cross-cflags-m68k=*) quote_sh "-Dtcg_tests_cross_cflags_m68k=$2" ;;
     --tcg-tests-cross-cflags-mips=*) quote_sh "-Dtcg_tests_cross_cflags_mips=$2" ;;
     --tcg-tests-cross-cflags-mips32r5el=*) quote_sh "-Dtcg_tests_cross_cflags_mips32r5el=$2" ;;
+    --tcg-tests-cross-cflags-mips32r6el=*) quote_sh "-Dtcg_tests_cross_cflags_mips32r6el=$2" ;;
     --tcg-tests-cross-cflags-mips64=*) quote_sh "-Dtcg_tests_cross_cflags_mips64=$2" ;;
     --tcg-tests-cross-cflags-mips64el=*) quote_sh "-Dtcg_tests_cross_cflags_mips64el=$2" ;;
     --tcg-tests-cross-cflags-mips64r6=*) quote_sh "-Dtcg_tests_cross_cflags_mips64r6=$2" ;;

Need to update also scripts/meson-buildoptions.sh. make or make check-tcg should update it for you.

It's a pain, I know, and TLDR: it's a chicken-egg problem between configure and meson.

Regards,
Pierrick

#7 lore raw

Re: [PATCH 02/12] meson: Add the tcg_tests_cross_cc/cflags options for mips32r6el

Quoted 42 lines · Pierrick Bouvier
Quoted 41 lines · Philippe Mathieu-Daudé

Add meson tcg_tests_cross_cc/cflags options for mips32r6el, similarly of the previous mips32r5el commit c7b1a7bc9d33 ("tests/tcg/mipsel/mips32r5el: add msa tests"). This allows compiling TCG tests for the mips32r6el-linux-user targets.

---
  meson_options.txt             | 4 ++++
  scripts/meson-buildoptions.sh | 2 ++
  2 files changed, 6 insertions(+)
meson_options.txt +4 -0
index 895c6e63c28a..9ae8e44ab54e 100644
@@ -461,6 +461,10 @@ option('tcg_tests_cross_cc_mips32r5el', type: 'string',
         description: 'cc for mips32r5el tcg tests')
  option('tcg_tests_cross_cflags_mips32r5el', type: 'string',
         description: 'cflags for mips32r5el tcg tests')
+option('tcg_tests_cross_cc_mips32r6el', type: 'string',
+       description: 'cc for mips32r6el tcg tests')
+option('tcg_tests_cross_cflags_mips32r6el', type: 'string',
+       description: 'cflags for mips32r6el tcg tests')
  option('tcg_tests_cross_cc_or1k', type: 'string',
         description: 'cc for or1k tcg tests')
  option('tcg_tests_cross_cflags_or1k', type: 'string',
scripts/meson-buildoptions.sh +1 -0
index 14990966d31d..0f8b56bd7f8c 100644
@@ -539,6 +539,7 @@ _meson_option_parse() {
      --tcg-tests-cross-cc-m68k=*) quote_sh "-Dtcg_tests_cross_cc_m68k=$2" ;;
      --tcg-tests-cross-cc-mips=*) quote_sh "-Dtcg_tests_cross_cc_mips=$2" ;;
      --tcg-tests-cross-cc-mips32r5el=*) quote_sh "-Dtcg_tests_cross_cc_mips32r5el=$2" ;;
+    --tcg-tests-cross-cc-mips32r6el=*) quote_sh "-Dtcg_tests_cross_cc_mips32r6el=$2" ;;
      --tcg-tests-cross-cc-mips64=*) quote_sh "-Dtcg_tests_cross_cc_mips64=$2" ;;
      --tcg-tests-cross-cc-mips64el=*) quote_sh "-Dtcg_tests_cross_cc_mips64el=$2" ;;
      --tcg-tests-cross-cc-mips64r6=*) quote_sh "-Dtcg_tests_cross_cc_mips64r6=$2" ;;
@@ -566,6 +567,7 @@ _meson_option_parse() {
      --tcg-tests-cross-cflags-m68k=*) quote_sh "-Dtcg_tests_cross_cflags_m68k=$2" ;;
      --tcg-tests-cross-cflags-mips=*) quote_sh "-Dtcg_tests_cross_cflags_mips=$2" ;;
Quoted 8 lines

scripts/meson-buildoptions.sh _meson_option_parse() { · line 573

Quoted 5 lines
scripts/meson-buildoptions.sh +1 -0
      --tcg-tests-cross-cflags-mips32r5el=*) quote_sh "-Dtcg_tests_cross_cflags_mips32r5el=$2" ;;
+    --tcg-tests-cross-cflags-mips32r6el=*) quote_sh "-Dtcg_tests_cross_cflags_mips32r6el=$2" ;;
      --tcg-tests-cross-cflags-mips64=*) quote_sh "-Dtcg_tests_cross_cflags_mips64=$2" ;;
      --tcg-tests-cross-cflags-mips64el=*) quote_sh "-Dtcg_tests_cross_cflags_mips64el=$2" ;;
      --tcg-tests-cross-cflags-mips64r6=*) quote_sh "-Dtcg_tests_cross_cflags_mips64r6=$2" ;;

Need to update also scripts/meson-buildoptions.sh. make or make check-tcg should update it for you.

I don't understand what is requested here.

I ran that on both macOS and Linux, no change in scripts/meson-buildoptions.sh, could these cross-flags be filtered? What do you want me to add?

Quoted 6 lines

It's a pain, I know, and TLDR: it's a chicken-egg problem between configure and meson.

Regards,
Pierrick

#8 lore raw

Re: [PATCH 02/12] meson: Add the tcg_tests_cross_cc/cflags options for mips32r6el

Quoted 68 lines · Philippe Mathieu-Daudé
Quoted 58 lines · Pierrick Bouvier
Quoted 57 lines · Philippe Mathieu-Daudé

Add meson tcg_tests_cross_cc/cflags options for mips32r6el, similarly of the previous mips32r5el commit c7b1a7bc9d33 ("tests/tcg/mipsel/mips32r5el: add msa tests"). This allows compiling TCG tests for the mips32r6el-linux-user targets.

---
  meson_options.txt             | 4 ++++
  scripts/meson-buildoptions.sh | 2 ++

  2 files changed, 6 insertions(+)
meson_options.txt +4 -0
index 895c6e63c28a..9ae8e44ab54e 100644
@@ -461,6 +461,10 @@ option('tcg_tests_cross_cc_mips32r5el', type:
 'string',
          description: 'cc for mips32r5el tcg tests')
   option('tcg_tests_cross_cflags_mips32r5el', type: 'string',
          description: 'cflags for mips32r5el tcg tests')
+option('tcg_tests_cross_cc_mips32r6el', type: 'string',
+       description: 'cc for mips32r6el tcg tests')
+option('tcg_tests_cross_cflags_mips32r6el', type: 'string',
+       description: 'cflags for mips32r6el tcg tests')
   option('tcg_tests_cross_cc_or1k', type: 'string',
          description: 'cc for or1k tcg tests')

  option('tcg_tests_cross_cflags_or1k', type: 'string',

scripts/meson- renamed from scripts/meson-buildoptions.sh +0 -0

buildoptions.sh
index 14990966d31d..0f8b56bd7f8c 100644

scripts/meson-buildoptions.sh +0 -0
@@ -539,6 +539,7 @@ _meson_option_parse() {

      --tcg-tests-cross-cc-m68k=*) quote_sh "- Dtcg_tests_cross_cc_m68k=$2" ;; --tcg-tests-cross-cc-mips=*) quote_sh "- Dtcg_tests_cross_cc_mips=$2" ;; --tcg-tests-cross-cc-mips32r5el=*) quote_sh "- Dtcg_tests_cross_cc_mips32r5el=$2" ;;
+    --tcg-tests-cross-cc-mips32r6el=*) quote_sh "- Dtcg_tests_cross_cc_mips32r6el=$2" ;; --tcg-tests-cross-cc-mips64=*) quote_sh "- Dtcg_tests_cross_cc_mips64=$2" ;; --tcg-tests-cross-cc-mips64el=*) quote_sh "- Dtcg_tests_cross_cc_mips64el=$2" ;; --tcg-tests-cross-cc-mips64r6=*) quote_sh "- Dtcg_tests_cross_cc_mips64r6=$2" ;;

scripts/meson-buildoptions.sh +0 -0
@@ -566,6 +567,7 @@ _meson_option_parse() {

      --tcg-tests-cross-cflags-m68k=*) quote_sh "- Dtcg_tests_cross_cflags_m68k=$2" ;; --tcg-tests-cross-cflags-mips=*) quote_sh "- Dtcg_tests_cross_cflags_mips=$2" ;; --tcg-tests-cross-cflags-mips32r5el=*) quote_sh "- Dtcg_tests_cross_cflags_mips32r5el=$2" ;;
+    --tcg-tests-cross-cflags-mips32r6el=*) quote_sh "- Dtcg_tests_cross_cflags_mips32r6el=$2" ;; --tcg-tests-cross-cflags-mips64=*) quote_sh "-

Quoted 8 lines
Quoted 5 lines

Dtcg_tests_cross_cflags_mips64=$2" ;; --tcg-tests-cross-cflags-mips64el=*) quote_sh "- Dtcg_tests_cross_cflags_mips64el=$2" ;; --tcg-tests-cross-cflags-mips64r6=*) quote_sh "- Dtcg_tests_cross_cflags_mips64r6=$2" ;;

Need to update also scripts/meson-buildoptions.sh. make or make check-tcg should update it for you.

Quoted 5 lines

I don't understand what is requested here.

I ran that on both macOS and Linux, no change in scripts/meson- buildoptions.sh,
could these cross-flags be filtered? What do you want me to add?

Please ignore my comment, I missed it was already updated in the patch.

Quoted 7 lines
Quoted 6 lines

It's a pain, I know, and TLDR: it's a chicken-egg problem between configure and meson.

Regards,
Pierrick

#9 lore raw

PATCH 3/12 tests/tcg/mipsel: Add MIPS32R6 logic tests

In reply to Philippe Mathieu-Daudé

Add a mips32r6el-linux-user target running, on mips32r6-generic, 32-bit versions of the Release 6 tests that don't need 64-bit registers, starting with and, nor, or and xor. Output is TAP.

---
 tests/tcg/mips/include/wrappers_mips32r6.h | 61 +++++++++++++++++++++
 tests/tcg/mipsel/test_mips32r6_logic.c     | 63 ++++++++++++++++++++++
 tests/tcg/mipsel/meson.build               | 29 ++++++++++
 3 files changed, 153 insertions(+)
 create mode 100644 tests/tcg/mips/include/wrappers_mips32r6.h
 create mode 100644 tests/tcg/mipsel/test_mips32r6_logic.c
tests/tcg/mips/include/wrappers_mips32r6.h new file +61 -0
new file mode 100644
index 000000000000..316aa69ef582
@@ -0,0 +1,61 @@
+/*
+ * Wrappers for MIPS32R6 instructions operating on 32-bit values
+ * (32-bit counterpart of wrappers_mips64r6.h).
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef WRAPPERS_MIPS32R6_H
+#define WRAPPERS_MIPS32R6_H
+
+#include <stdint.h>
+
+#define DO_MIPS32R6__RD__RS(suffix, mnemonic)                          \
+static inline void do_mips32r6_##suffix(const uint32_t *input,         \
+                                        uint32_t *output)              \
+{                                                                      \
+   __asm__ volatile (                                                  \
+      "lw $t1, 0(%0)\n\t"                                              \
+      #mnemonic " $t0, $t1\n\t"                                        \
+      "sw $t0, 0(%1)\n\t"                                              \
+      :                                                                \
+      : "r" (input), "r" (output)                                      \
+      : "t0", "t1", "memory"                                           \
+   );                                                                  \
+}
+
+#define DO_MIPS32R6__RD__RS_RT(suffix, mnemonic)                       \
+static inline void do_mips32r6_##suffix(const uint32_t *input1,        \
+                                        const uint32_t *input2,        \
+                                        uint32_t *output)              \
+{                                                                      \
+   __asm__ volatile (                                                  \
+      "lw $t1, 0(%0)\n\t"                                              \
+      "lw $t2, 0(%1)\n\t"                                              \
+      #mnemonic " $t0, $t1, $t2\n\t"                                   \
+      "sw $t0, 0(%2)\n\t"                                              \
+      :                                                                \
+      : "r" (input1), "r" (input2), "r" (output)                       \
+      : "t0", "t1", "t2", "memory"                                     \
+   );                                                                  \
+}
+
+DO_MIPS32R6__RD__RS(CLO, clo)
+DO_MIPS32R6__RD__RS(CLZ, clz)
+DO_MIPS32R6__RD__RS(BITSWAP, bitswap)
+
+DO_MIPS32R6__RD__RS_RT(SLLV, sllv)
+DO_MIPS32R6__RD__RS_RT(SRLV, srlv)
+DO_MIPS32R6__RD__RS_RT(SRAV, srav)
+
+DO_MIPS32R6__RD__RS_RT(MUL, mul)
+DO_MIPS32R6__RD__RS_RT(MUH, muh)
+DO_MIPS32R6__RD__RS_RT(MULU, mulu)
+DO_MIPS32R6__RD__RS_RT(MUHU, muhu)
+
+DO_MIPS32R6__RD__RS_RT(AND, and)
+DO_MIPS32R6__RD__RS_RT(NOR, nor)
+DO_MIPS32R6__RD__RS_RT(OR, or)
+DO_MIPS32R6__RD__RS_RT(XOR, xor)
+
+#endif
tests/tcg/mipsel/test_mips32r6_logic.c new file +63 -0

63 lines not on this page · raw message

tests/tcg/mipsel/meson.build +29 -0
index f2642e1b20f8..5553ae33aec0 100644
@@ -84,3 +84,32 @@ if 'qemu-mipsel' in emulators
     }
   }
 endif
+
+tests = []
+
+tests_mips32r6 = [
+  'test_mips32r6_logic.c',
+]
+
+foreach src: tests_mips32r6
+  tests += {
+    src: {
+      'cflags': ['-mabi=32', '-march=mips32r6'],
+      'qemu_args': ['-cpu', 'mips32r6-generic'],
+      'protocol': 'tap',
+    }
+  }
+endforeach
+
+if 'qemu-mipsel' in emulators
+  tcg_tests += {
+    'mips32r6el-linux-user': {
+      'cc': 'mips32r6el-buildroot-linux-gnu-gcc',
+      'cc_dockerfile': 'debian-all-test-cross',
+      'folder': 'mipsel',
+      'gdb_arch': 'mipsel',
+      'qemu': emulators['qemu-mipsel'],
+      'tests': tests,
+    }
+  }
+endif
Signature · 1 line
2.55.0
#10 lore raw

PATCH 4/12 tests/tcg/mipsel: Add MIPS32R6 shift tests

In reply to Philippe Mathieu-Daudé

Test SLLV, SRLV and SRAV.

---
 tests/tcg/mipsel/test_mips32r6_shift.c | 74 ++++++++++++++++++++++++++
 tests/tcg/mipsel/meson.build           |  1 +
 2 files changed, 75 insertions(+)
 create mode 100644 tests/tcg/mipsel/test_mips32r6_shift.c
tests/tcg/mipsel/test_mips32r6_shift.c new file +74 -0
new file mode 100644
index 000000000000..c4389b5d232a
@@ -0,0 +1,74 @@
+/*
+ * MIPS32R6 tests: shift instructions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include "../mips/include/wrappers_mips32r6.h"
+#include "../mips/include/test_inputs_32.h"
+
+typedef void (*binary_op_32)(const uint32_t *, const uint32_t *, uint32_t *);
+typedef uint32_t (*ref_op_32)(uint32_t, uint32_t);
+
+/* Only the low 5 bits of the shift amount (rs) are used. */
+static uint32_t ref_sllv(uint32_t a, uint32_t b) { return a << (b & 31); }
+static uint32_t ref_srlv(uint32_t a, uint32_t b) { return a >> (b & 31); }
+static uint32_t ref_srav(uint32_t a, uint32_t b)
+{
+    return (uint32_t)((int32_t)a >> (b & 31));
+}
+
+static int check_one(const char *name, binary_op_32 op, ref_op_32 ref,
+                     uint32_t a, uint32_t b)
+{
+    uint32_t res = 0;
+
+    op(&a, &b, &res);
+    if (res != ref(a, b)) {
+        printf("# %s: %08x, %08x: got %08x expected %08x\n",
+               name, a, b, res, ref(a, b));
+        return 1;
+    }
+    return 0;
+}
+
+static int run(const char *name, binary_op_32 op, ref_op_32 ref)
+{
+    static int count;
+    int ret = 0;
+
+    /* Value/amount pairs from the input tables. */
+    for (size_t i = 0; i < PATTERN_INPUTS_32_SHORT_COUNT; i++) {
+        for (size_t j = 0; j < PATTERN_INPUTS_32_SHORT_COUNT; j++) {
+            ret |= check_one(name, op, ref, b32_pattern[i], b32_pattern[j]);
+        }
+    }
+    for (size_t i = 0; i < RANDOM_INPUTS_32_SHORT_COUNT; i++) {
+        for (size_t j = 0; j < RANDOM_INPUTS_32_SHORT_COUNT; j++) {
+            ret |= check_one(name, op, ref, b32_random[i], b32_random[j]);
+        }
+    }
+    /* Every shift amount (including ones with ignored high bits). */
+    for (size_t i = 0; i < PATTERN_INPUTS_32_SHORT_COUNT; i++) {
+        for (uint32_t sa = 0; sa < 64; sa++) {
+            ret |= check_one(name, op, ref, b32_pattern[i], sa);
+        }
+    }
+    printf("%s %d - MIPS32R6 shift %s\n", ret ? "not ok" : "ok", ++count, name);
+    return ret;
+}
+
+int main(void)
+{
+    int ret = 0;
+
+    printf("TAP version 14\n1..3\n");
+    ret |= run("SLLV", do_mips32r6_SLLV, ref_sllv);
+    ret |= run("SRLV", do_mips32r6_SRLV, ref_srlv);
+    ret |= run("SRAV", do_mips32r6_SRAV, ref_srav);
+
+    return ret ? 1 : 0;
+}
tests/tcg/mipsel/meson.build +1 -0
index 5553ae33aec0..7a6dff32cbf4 100644
@@ -89,6 +89,7 @@ tests = []
 
 tests_mips32r6 = [
   'test_mips32r6_logic.c',
+  'test_mips32r6_shift.c',
 ]
 
 foreach src: tests_mips32r6
Signature · 1 line
2.55.0
#11 lore raw

PATCH 5/12 tests/tcg/mipsel: Add MIPS32R6 bit operation tests

In reply to Philippe Mathieu-Daudé

Test CLO, CLZ and bitswap.

---
 tests/tcg/mipsel/test_mips32r6_bitops.c | 82 +++++++++++++++++++++++++
 tests/tcg/mipsel/meson.build            |  1 +
 2 files changed, 83 insertions(+)
 create mode 100644 tests/tcg/mipsel/test_mips32r6_bitops.c
tests/tcg/mipsel/test_mips32r6_bitops.c new file +82 -0
new file mode 100644
index 000000000000..dc55530b3b18
@@ -0,0 +1,82 @@
+/*
+ * MIPS32R6 tests: bit operations instructions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include "../mips/include/wrappers_mips32r6.h"
+#include "../mips/include/test_inputs_32.h"
+
+typedef void (*unary_op_32)(const uint32_t *, uint32_t *);
+typedef uint32_t (*ref_op_32)(uint32_t);
+
+static uint32_t ref_clz(uint32_t a) { return a ? __builtin_clz(a) : 32; }
+static uint32_t ref_clo(uint32_t a) { return ref_clz(~a); }
+
+/* BITSWAP reverses the bit order inside each byte. */
+static uint32_t ref_bitswap(uint32_t a)
+{
+    uint32_t res = 0;
+
+    for (int byte = 0; byte < 4; byte++) {
+        for (int bit = 0; bit < 8; bit++) {
+            if (a & (1u << (byte * 8 + bit))) {
+                res |= 1u << (byte * 8 + 7 - bit);
+            }
+        }
+    }
+    return res;
+}
+
+static int check_all(const char *name, unary_op_32 op, ref_op_32 ref,
+                     const uint32_t *input, size_t count)
+{
+    int fail = 0;
+
+    for (size_t i = 0; i < count; i++) {
+        uint32_t a = input[i], res = 0;
+
+        op(&a, &res);
+        if (res != ref(a)) {
+            printf("# %s: %08x: got %08x expected %08x\n",
+                   name, a, res, ref(a));
+            fail = 1;
+        }
+    }
+    return fail;
+}
+
+static int run(const char *name, unary_op_32 op, ref_op_32 ref)
+{
+    static int count;
+    int ret = 0;
+
+    ret |= check_all(name, op, ref, b32_pattern, PATTERN_INPUTS_32_COUNT);
+    ret |= check_all(name, op, ref, b32_random, RANDOM_INPUTS_32_COUNT);
+    /* Every leading-run length, for both polarities. */
+    for (int n = 0; n < 32; n++) {
+        uint32_t v[2] = { 0xffffffffu >> n, ~(0xffffffffu >> n) };
+
+        ret |= check_all(name, op, ref, v, 2);
+        v[0] = 1u << n;
+        v[1] = ~(1u << n);
+        ret |= check_all(name, op, ref, v, 2);
+    }
+    printf("%s %d - MIPS32R6 bitops %s\n", ret ? "not ok" : "ok", ++count, name);
+    return ret;
+}
+
+int main(void)
+{
+    int ret = 0;
+
+    printf("TAP version 14\n1..3\n");
+    ret |= run("CLO", do_mips32r6_CLO, ref_clo);
+    ret |= run("CLZ", do_mips32r6_CLZ, ref_clz);
+    ret |= run("BITSWAP", do_mips32r6_BITSWAP, ref_bitswap);
+
+    return ret ? 1 : 0;
+}
tests/tcg/mipsel/meson.build +1 -0
index 7a6dff32cbf4..837b26698e06 100644
@@ -88,6 +88,7 @@ endif
 tests = []
 
 tests_mips32r6 = [
+  'test_mips32r6_bitops.c',
   'test_mips32r6_logic.c',
   'test_mips32r6_shift.c',
 ]
Signature · 1 line
2.55.0
#12 lore raw

PATCH 6/12 tests/tcg/mipsel: Add MIPS32R6 multiply tests

In reply to Philippe Mathieu-Daudé

Test MUL[U] and MUH[U].

---
 tests/tcg/mipsel/test_mips32r6_multiply.c | 79 +++++++++++++++++++++++
 tests/tcg/mipsel/meson.build              |  1 +
 2 files changed, 80 insertions(+)
 create mode 100644 tests/tcg/mipsel/test_mips32r6_multiply.c
tests/tcg/mipsel/test_mips32r6_multiply.c new file +79 -0
new file mode 100644
index 000000000000..94c4a3426ba2
@@ -0,0 +1,79 @@
+/*
+ * MIPS32R6 tests: multiply instructions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include "../mips/include/wrappers_mips32r6.h"
+#include "../mips/include/test_inputs_32.h"
+
+typedef void (*binary_op_32)(const uint32_t *, const uint32_t *, uint32_t *);
+typedef uint32_t (*ref_op_32)(uint32_t, uint32_t);
+
+static uint32_t ref_mul(uint32_t a, uint32_t b)
+{
+    return (uint32_t)((int64_t)(int32_t)a * (int32_t)b);
+}
+
+static uint32_t ref_muh(uint32_t a, uint32_t b)
+{
+    return (uint32_t)(((int64_t)(int32_t)a * (int32_t)b) >> 32);
+}
+
+static uint32_t ref_mulu(uint32_t a, uint32_t b)
+{
+    return (uint32_t)((uint64_t)a * b);
+}
+
+static uint32_t ref_muhu(uint32_t a, uint32_t b)
+{
+    return (uint32_t)(((uint64_t)a * b) >> 32);
+}
+
+static int check_op(const char *name, binary_op_32 op, ref_op_32 ref,
+                    const uint32_t *input, size_t count)
+{
+    int fail = 0;
+
+    for (size_t i = 0; i < count; i++) {
+        for (size_t j = 0; j < count; j++) {
+            uint32_t a = input[i], b = input[j], res = 0;
+
+            op(&a, &b, &res);
+            if (res != ref(a, b)) {
+                printf("# %s: %08x, %08x: got %08x expected %08x\n",
+                       name, a, b, res, ref(a, b));
+                fail = 1;
+            }
+        }
+    }
+    return fail;
+}
+
+static int run(const char *name, binary_op_32 op, ref_op_32 ref)
+{
+    static int count;
+    int ret = 0;
+
+    ret |= check_op(name, op, ref, b32_pattern, PATTERN_INPUTS_32_COUNT);
+    ret |= check_op(name, op, ref, b32_random, RANDOM_INPUTS_32_COUNT);
+    printf("%s %d - MIPS32R6 multiply %s\n", ret ? "not ok" : "ok", ++count,
+           name);
+    return ret;
+}
+
+int main(void)
+{
+    int ret = 0;
+
+    printf("TAP version 14\n1..4\n");
+    ret |= run("MUL", do_mips32r6_MUL, ref_mul);
+    ret |= run("MUH", do_mips32r6_MUH, ref_muh);
+    ret |= run("MULU", do_mips32r6_MULU, ref_mulu);
+    ret |= run("MUHU", do_mips32r6_MUHU, ref_muhu);
+
+    return ret ? 1 : 0;
+}
tests/tcg/mipsel/meson.build +1 -0
index 837b26698e06..9d7cfcf1c6a0 100644
@@ -90,6 +90,7 @@ tests = []
 tests_mips32r6 = [
   'test_mips32r6_bitops.c',
   'test_mips32r6_logic.c',
+  'test_mips32r6_multiply.c',
   'test_mips32r6_shift.c',
 ]
 
Signature · 1 line
2.55.0
#13 lore raw

PATCH 7/12 tests/tcg/mipsel: Add MIPS32R6 PC-relative tests

In reply to Philippe Mathieu-Daudé

Test A[L]UIPC opcodes.

---
 tests/tcg/mipsel/test_mips32r6_pcrel.c | 95 ++++++++++++++++++++++++++
 tests/tcg/mipsel/meson.build           |  1 +
 2 files changed, 96 insertions(+)
 create mode 100644 tests/tcg/mipsel/test_mips32r6_pcrel.c
tests/tcg/mipsel/test_mips32r6_pcrel.c new file +95 -0
new file mode 100644
index 000000000000..dd16357953ae
@@ -0,0 +1,95 @@
+/*
+ * MIPS32R6 tests: PC-relative AUIPC and ALUIPC instructions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+/*
+ * Run INSN with the immediate IMM, and probe the address of INSN with a
+ * second AUIPC (which yields its own address, +4 being INSN's size).
+ */
+#define PCREL(insn, imm, res, addr)                                     \
+    __asm__ volatile (                                                  \
+        ".set push\n\t"                                                 \
+        ".set noreorder\n\t"                                            \
+        insn " %0, " #imm "\n\t"                                        \
+        "auipc %1, 0\n\t"                                               \
+        ".set pop\n\t"                                                  \
+        : "=r" (res), "=r" (addr))
+
+static int count;
+
+static int check(const char *name, uint32_t imm, uint32_t res, uint32_t probe,
+                 int aligned)
+{
+    /* The probe AUIPC is the instruction after the tested one. */
+    uint32_t addr = probe - 4;
+    uint32_t expected = addr + (imm << 16);
+    int ok;
+
+    if (aligned) {
+        expected &= ~0xffffu;
+    }
+    ok = res == expected;
+    if (!ok) {
+        printf("# %s imm=0x%04x at 0x%08x: got 0x%08x expected 0x%08x\n",
+               name, imm, addr, res, expected);
+    }
+    return !ok;
+}
+
+#define CHECK_AUIPC(imm)                                                \
+    do {                                                                \
+        uint32_t res, probe;                                            \
+        PCREL("auipc", imm, res, probe);                                \
+        ret |= check("AUIPC", imm, res, probe, 0);                      \
+    } while (0)
+
+#define CHECK_ALUIPC(imm)                                               \
+    do {                                                                \
+        uint32_t res, probe;                                            \
+        PCREL("aluipc", imm, res, probe);                               \
+        ret |= check("ALUIPC", imm, res, probe, 1);                     \
+    } while (0)
+
+static int test_auipc(void)
+{
+    int ret = 0;
+
+    CHECK_AUIPC(0);
+    CHECK_AUIPC(1);
+    CHECK_AUIPC(0x7fff);
+    CHECK_AUIPC(0x8000);
+    CHECK_AUIPC(0xffff);
+    return ret;
+}
+
+static int test_aluipc(void)
+{
+    int ret = 0;
+
+    CHECK_ALUIPC(0);
+    CHECK_ALUIPC(1);
+    CHECK_ALUIPC(0x7fff);
+    CHECK_ALUIPC(0x8000);
+    CHECK_ALUIPC(0xffff);
+    return ret;
+}
+
+int main(void)
+{
+    int ret = 0, r;
+
+    printf("TAP version 14\n1..2\n");
+    r = test_auipc();
+    printf("%s %d - MIPS32R6 AUIPC\n", r ? "not ok" : "ok", ++count);
+    ret |= r;
+    r = test_aluipc();
+    printf("%s %d - MIPS32R6 ALUIPC\n", r ? "not ok" : "ok", ++count);
+    ret |= r;
+
+    return ret ? 1 : 0;
+}
tests/tcg/mipsel/meson.build +1 -0
index 9d7cfcf1c6a0..3425962d3715 100644
@@ -91,6 +91,7 @@ tests_mips32r6 = [
   'test_mips32r6_bitops.c',
   'test_mips32r6_logic.c',
   'test_mips32r6_multiply.c',
+  'test_mips32r6_pcrel.c',
   'test_mips32r6_shift.c',
 ]
 
Signature · 1 line
2.55.0
#14 lore raw

PATCH 8/12 tests/tcg/mipsel: Test MIPS32R6 SELEQZ and SELNEZ

In reply to Philippe Mathieu-Daudé

Test SEL[EQ/NE]Z.

---
 tests/tcg/mips/include/wrappers_mips32r6.h | 3 +++
 tests/tcg/mipsel/test_mips32r6_logic.c     | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
tests/tcg/mips/include/wrappers_mips32r6.h +3 -0
index 316aa69ef582..aaa8afcae95b 100644
@@ -58,4 +58,7 @@ DO_MIPS32R6__RD__RS_RT(NOR, nor)
 DO_MIPS32R6__RD__RS_RT(OR, or)
 DO_MIPS32R6__RD__RS_RT(XOR, xor)
 
+DO_MIPS32R6__RD__RS_RT(SELEQZ, seleqz)
+DO_MIPS32R6__RD__RS_RT(SELNEZ, selnez)
+
 #endif
tests/tcg/mipsel/test_mips32r6_logic.c +6 -1
index 48db7a8bfb15..4ba8827372d4 100644
@@ -17,6 +17,9 @@ static uint32_t ref_and(uint32_t a, uint32_t b) { return a & b; }
 static uint32_t ref_nor(uint32_t a, uint32_t b) { return ~(a | b); }
 static uint32_t ref_or(uint32_t a, uint32_t b) { return a | b; }
 static uint32_t ref_xor(uint32_t a, uint32_t b) { return a ^ b; }
+/* SELEQZ/SELNEZ select rs, or zero, depending on rt. */
+static uint32_t ref_seleqz(uint32_t a, uint32_t b) { return b == 0 ? a : 0; }
+static uint32_t ref_selnez(uint32_t a, uint32_t b) { return b != 0 ? a : 0; }
 
 static int check_op(const char *name, binary_op_32 op, ref_op_32 ref,
                     const uint32_t *input, size_t count)
@@ -53,11 +56,13 @@ int main(void)
 {
     int ret = 0;
 
-    printf("TAP version 14\n1..4\n");
+    printf("TAP version 14\n1..6\n");
     ret |= run("AND", do_mips32r6_AND, ref_and);
     ret |= run("NOR", do_mips32r6_NOR, ref_nor);
     ret |= run("OR", do_mips32r6_OR, ref_or);
     ret |= run("XOR", do_mips32r6_XOR, ref_xor);
+    ret |= run("SELEQZ", do_mips32r6_SELEQZ, ref_seleqz);
+    ret |= run("SELNEZ", do_mips32r6_SELNEZ, ref_selnez);
 
     return ret ? 1 : 0;
 }
Signature · 1 line
2.55.0
#15 lore raw

PATCH 9/12 tests/tcg/mipsel: Test MIPS32R6 DIV, MOD, DIVU and MODU

In reply to Philippe Mathieu-Daudé

Test DIV[U] and MOD[U]. A zero divisor and INT_MIN / -1 are skipped: their result is UNPREDICTABLE.

---
 tests/tcg/mips/include/wrappers_mips32r6.h |  5 +++
 tests/tcg/mipsel/test_mips32r6_multiply.c  | 47 +++++++++++++++++-----
 2 files changed, 43 insertions(+), 9 deletions(-)
tests/tcg/mips/include/wrappers_mips32r6.h +5 -0
index aaa8afcae95b..cbff8450b656 100644
@@ -53,6 +53,11 @@ DO_MIPS32R6__RD__RS_RT(MUH, muh)
 DO_MIPS32R6__RD__RS_RT(MULU, mulu)
 DO_MIPS32R6__RD__RS_RT(MUHU, muhu)
 
+DO_MIPS32R6__RD__RS_RT(DIV, div)
+DO_MIPS32R6__RD__RS_RT(MOD, mod)
+DO_MIPS32R6__RD__RS_RT(DIVU, divu)
+DO_MIPS32R6__RD__RS_RT(MODU, modu)
+
 DO_MIPS32R6__RD__RS_RT(AND, and)
 DO_MIPS32R6__RD__RS_RT(NOR, nor)
 DO_MIPS32R6__RD__RS_RT(OR, or)
tests/tcg/mipsel/test_mips32r6_multiply.c +38 -9

82 lines not on this page · raw message

Signature · 1 line
2.55.0
#16 lore raw

PATCH 10/12 tests/tcg/mipsel: Test MIPS32R6 LSA

In reply to Philippe Mathieu-Daudé

Test LSA opcode.

---
 tests/tcg/mips/include/wrappers_mips32r6.h | 22 ++++++++++++++++++++++
 tests/tcg/mipsel/test_mips32r6_shift.c     | 12 +++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
tests/tcg/mips/include/wrappers_mips32r6.h +22 -0
index cbff8450b656..63b4496b3188 100644
@@ -48,6 +48,28 @@ DO_MIPS32R6__RD__RS_RT(SLLV, sllv)
 DO_MIPS32R6__RD__RS_RT(SRLV, srlv)
 DO_MIPS32R6__RD__RS_RT(SRAV, srav)
 
+/* LSA rd, rs, rt, sa: rd = (rs << sa) + rt, with sa in 1..4. */
+#define DO_MIPS32R6__LSA(suffix, sa)                                   \
+static inline void do_mips32r6_##suffix(const uint32_t *input1,        \
+                                        const uint32_t *input2,        \
+                                        uint32_t *output)              \
+{                                                                      \
+   __asm__ volatile (                                                  \
+      "lw $t1, 0(%0)\n\t"                                              \
+      "lw $t2, 0(%1)\n\t"                                              \
+      "lsa $t0, $t1, $t2, " #sa "\n\t"                                 \
+      "sw $t0, 0(%2)\n\t"                                              \
+      :                                                                \
+      : "r" (input1), "r" (input2), "r" (output)                       \
+      : "t0", "t1", "t2", "memory"                                     \
+   );                                                                  \
+}
+
+DO_MIPS32R6__LSA(LSA1, 1)
+DO_MIPS32R6__LSA(LSA2, 2)
+DO_MIPS32R6__LSA(LSA3, 3)
+DO_MIPS32R6__LSA(LSA4, 4)
+
 DO_MIPS32R6__RD__RS_RT(MUL, mul)
 DO_MIPS32R6__RD__RS_RT(MUH, muh)
 DO_MIPS32R6__RD__RS_RT(MULU, mulu)
tests/tcg/mipsel/test_mips32r6_shift.c +11 -1
index c4389b5d232a..7b419ef05f28 100644
@@ -21,6 +21,12 @@ static uint32_t ref_srav(uint32_t a, uint32_t b)
     return (uint32_t)((int32_t)a >> (b & 31));
 }
 
+/* LSA: shift rs left by 1..4, then add rt. */
+static uint32_t ref_lsa1(uint32_t a, uint32_t b) { return (a << 1) + b; }
+static uint32_t ref_lsa2(uint32_t a, uint32_t b) { return (a << 2) + b; }
+static uint32_t ref_lsa3(uint32_t a, uint32_t b) { return (a << 3) + b; }
+static uint32_t ref_lsa4(uint32_t a, uint32_t b) { return (a << 4) + b; }
+
 static int check_one(const char *name, binary_op_32 op, ref_op_32 ref,
                      uint32_t a, uint32_t b)
 {
@@ -65,10 +71,14 @@ int main(void)
 {
     int ret = 0;
 
-    printf("TAP version 14\n1..3\n");
+    printf("TAP version 14\n1..7\n");
     ret |= run("SLLV", do_mips32r6_SLLV, ref_sllv);
     ret |= run("SRLV", do_mips32r6_SRLV, ref_srlv);
     ret |= run("SRAV", do_mips32r6_SRAV, ref_srav);
+    ret |= run("LSA1", do_mips32r6_LSA1, ref_lsa1);
+    ret |= run("LSA2", do_mips32r6_LSA2, ref_lsa2);
+    ret |= run("LSA3", do_mips32r6_LSA3, ref_lsa3);
+    ret |= run("LSA4", do_mips32r6_LSA4, ref_lsa4);
 
     return ret ? 1 : 0;
 }
Signature · 1 line
2.55.0
#17 lore raw

PATCH 11/12 tests/tcg/mipsel: Test MIPS32R6 BALC

In reply to Philippe Mathieu-Daudé

Add a branch group, starting with BALC.

---
 tests/tcg/mipsel/test_mips32r6_branch.c | 57 +++++++++++++++++++++++++
 tests/tcg/mipsel/meson.build            |  1 +
 2 files changed, 58 insertions(+)
 create mode 100644 tests/tcg/mipsel/test_mips32r6_branch.c
tests/tcg/mipsel/test_mips32r6_branch.c new file +57 -0
new file mode 100644
index 000000000000..73a0036997f9
@@ -0,0 +1,57 @@
+/*
+ * MIPS32R6 tests: compact branches and jumps instructions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+static int count;
+
+/*
+ * BALC: branch and link, no delay slot. The callee records $ra and returns;
+ * $ra must be the address of the instruction following BALC (label 2).
+ */
+static int test_balc(void)
+{
+    uint32_t seen, expected;
+
+    __asm__ volatile (
+        ".set push\n\t"
+        ".set noreorder\n\t"
+        "move %0, $zero\n\t"
+        "balc 1f\n\t"
+        "2: bc 3f\n\t"
+        "1: move %0, $ra\n\t"
+        "jrc $ra\n\t"
+        "3: lapc %1, 2b\n\t"
+        ".set pop\n\t"
+        : "=&r" (seen), "=&r" (expected)
+        :
+        : "ra");
+
+    if (seen != expected) {
+        printf("# BALC: ra 0x%08x expected 0x%08x\n", seen, expected);
+    }
+    return seen != expected;
+}
+
+static int run(const char *name, int (*test)(void))
+{
+    int ret = test();
+
+    printf("%s %d - MIPS32R6 branch %s\n", ret ? "not ok" : "ok", ++count,
+           name);
+    return ret;
+}
+
+int main(void)
+{
+    int ret = 0;
+
+    printf("TAP version 14\n1..1\n");
+    ret |= run("BALC", test_balc);
+
+    return ret ? 1 : 0;
+}
tests/tcg/mipsel/meson.build +1 -0
index 3425962d3715..145d88dda19c 100644
@@ -89,6 +89,7 @@ tests = []
 
 tests_mips32r6 = [
   'test_mips32r6_bitops.c',
+  'test_mips32r6_branch.c',
   'test_mips32r6_logic.c',
   'test_mips32r6_multiply.c',
   'test_mips32r6_pcrel.c',
Signature · 1 line
2.55.0
#18 lore raw

PATCH 12/12 tests/tcg/mipsel: Test MIPS32R6 JIALC and JIC

In reply to Philippe Mathieu-Daudé

Now test JI[AL]C.

---
 tests/tcg/mipsel/test_mips32r6_branch.c | 73 ++++++++++++++++++++++++-
 1 file changed, 72 insertions(+), 1 deletion(-)
tests/tcg/mipsel/test_mips32r6_branch.c +72 -1
index 73a0036997f9..de2812e954b4 100644
@@ -37,6 +37,75 @@ static int test_balc(void)
     return seen != expected;
 }
 
+/* JIALC rt, offset: call to GPR[rt] + offset, link in $ra. */
+#define JIALC(bias, off, seen, expected, tmp)                           \
+    __asm__ volatile (                                                  \
+        ".set push\n\t"                                                 \
+        ".set noreorder\n\t"                                            \
+        "move %0, $zero\n\t"                                            \
+        "lapc %2, 1f\n\t"                                               \
+        "addiu %2, %2, " #bias "\n\t"                                   \
+        "jialc %2, " #off "\n\t"                                        \
+        "2: bc 3f\n\t"                                                  \
+        "1: move %0, $ra\n\t"                                           \
+        "jrc $ra\n\t"                                                   \
+        "3: lapc %1, 2b\n\t"                                            \
+        ".set pop\n\t"                                                  \
+        : "=&r" (seen), "=&r" (expected), "=&r" (tmp)                   \
+        :                                                               \
+        : "ra")
+
+static int test_jialc(void)
+{
+    uint32_t seen, expected, tmp;
+    int ret = 0;
+
+    JIALC(0, 0, seen, expected, tmp);
+    ret |= seen != expected;
+    JIALC(-8, 8, seen, expected, tmp);
+    ret |= seen != expected;
+    JIALC(8, -8, seen, expected, tmp);
+    ret |= seen != expected;
+    if (ret) {
+        printf("# JIALC: last ra 0x%08x expected 0x%08x\n", seen, expected);
+    }
+    return ret;
+}
+
+/* JIC rt, offset: jump to GPR[rt] + offset, no link ($ra unchanged). */
+#define JIC(bias, off, res, ra_before, ra_after, tmp)                   \
+    __asm__ volatile (                                                  \
+        ".set push\n\t"                                                 \
+        ".set noreorder\n\t"                                            \
+        "move %0, $zero\n\t"                                            \
+        "move %1, $ra\n\t"                                              \
+        "lapc %3, 1f\n\t"                                               \
+        "addiu %3, %3, " #bias "\n\t"                                   \
+        "jic %3, " #off "\n\t"                                          \
+        "addiu %0, %0, 2\n\t"                                           \
+        "1: addiu %0, %0, 1\n\t"                                        \
+        "move %2, $ra\n\t"                                              \
+        ".set pop\n\t"                                                  \
+        : "=&r" (res), "=&r" (ra_before), "=&r" (ra_after), "=&r" (tmp))
+
+static int test_jic(void)
+{
+    uint32_t res, ra_before, ra_after, tmp;
+    int ret = 0;
+
+    JIC(0, 0, res, ra_before, ra_after, tmp);
+    ret |= res != 1 || ra_before != ra_after;
+    JIC(-4, 4, res, ra_before, ra_after, tmp);
+    ret |= res != 1 || ra_before != ra_after;
+    JIC(4, -4, res, ra_before, ra_after, tmp);
+    ret |= res != 1 || ra_before != ra_after;
+    if (ret) {
+        printf("# JIC: last res %u (expected 1) ra 0x%08x -> 0x%08x\n",
+               res, ra_before, ra_after);
+    }
+    return ret;
+}
+
 static int run(const char *name, int (*test)(void))
 {
     int ret = test();
@@ -50,8 +119,10 @@ int main(void)
 {
     int ret = 0;
 
-    printf("TAP version 14\n1..1\n");
+    printf("TAP version 14\n1..3\n");
     ret |= run("BALC", test_balc);
+    ret |= run("JIALC", test_jialc);
+    ret |= run("JIC", test_jic);
 
     return ret ? 1 : 0;
 }
Signature · 1 line
2.55.0
#19 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé

- Include Bootlin mips32r6el toolchain in debian-all-test container
- Wire it to meson
- Cover all the 32-bit opcodes tested in MIPS64 Rel6 (using TAP)

Based-on: <[email protected]>

Philippe Mathieu-Daudé (12):
tests/docker: Add the mips32r6el toolchain
meson: Add the tcg_tests_cross_cc/cflags options for mips32r6el tests/tcg/mipsel: Add MIPS32R6 logic tests tests/tcg/mipsel: Add MIPS32R6 shift tests tests/tcg/mipsel: Add MIPS32R6 bit operation tests tests/tcg/mipsel: Add MIPS32R6 multiply tests tests/tcg/mipsel: Add MIPS32R6 PC-relative tests tests/tcg/mipsel: Test MIPS32R6 SELEQZ and SELNEZ tests/tcg/mipsel: Test MIPS32R6 DIV, MOD, DIVU and MODU tests/tcg/mipsel: Test MIPS32R6 LSA
tests/tcg/mipsel: Test MIPS32R6 BALC tests/tcg/mipsel: Test MIPS32R6 JIALC and JIC

 tests/tcg/mips/include/wrappers_mips32r6.h    |  91 +++++++++++++
 tests/tcg/mipsel/test_mips32r6_bitops.c       |  82 +++++++++++
 tests/tcg/mipsel/test_mips32r6_branch.c       | 128 ++++++++++++++++++
 tests/tcg/mipsel/test_mips32r6_logic.c        |  68 ++++++++++
 tests/tcg/mipsel/test_mips32r6_multiply.c     | 108 +++++++++++++++
 tests/tcg/mipsel/test_mips32r6_pcrel.c        |  95 +++++++++++++
 tests/tcg/mipsel/test_mips32r6_shift.c        |  84 ++++++++++++
 .../dockerfiles/debian-all-test-cross.docker  |  13 ++
 meson_options.txt                             |   4 +
 scripts/meson-buildoptions.sh                 |   2 +
 tests/tcg/mipsel/meson.build                  |  34 +++++
Quoted 9 lines
 11 files changed, 709 insertions(+)
 create mode 100644 tests/tcg/mips/include/wrappers_mips32r6.h
 create mode 100644 tests/tcg/mipsel/test_mips32r6_bitops.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_branch.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_logic.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_multiply.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_pcrel.c
 create mode 100644 tests/tcg/mipsel/test_mips32r6_shift.c

Out of the comments on two first patches, the rest looks good to me.

Regards,
Pierrick