]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Add testsuites for FMV.
authorLulu Cheng <chenglulu@loongson.cn>
Tue, 23 Sep 2025 06:17:30 +0000 (14:17 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Tue, 11 Nov 2025 07:33:38 +0000 (15:33 +0800)
gcc/testsuite/ChangeLog:

* g++.target/loongarch/mv-symbols1.C: New test.
* g++.target/loongarch/mv-symbols2.C: New test.
* g++.target/loongarch/mv-symbols3.C: New test.
* g++.target/loongarch/mv-symbols4.C: New test.
* g++.target/loongarch/mv-symbols5.C: New test.
* g++.target/loongarch/mv-symbols6.C: New test.
* g++.target/loongarch/mvc-symbols1.C: New test.
* g++.target/loongarch/mvc-symbols2.C: New test.
* g++.target/loongarch/mvc-symbols3.C: New test.
* g++.target/loongarch/mvc-symbols4.C: New test.
* g++.target/loongarch/mvc-symbols5.C: New test.
* gcc.target/loongarch/attr-check-error-message1.c: New test.
* gcc.target/loongarch/attr-check-error-message2.c: New test.
* gcc.target/loongarch/attr-check-error-message3.c: New test.
* gcc.target/loongarch/attr-check-error-message4.c: New test.
* gcc.target/loongarch/attr-check-error-message5.c: New test.
* gcc.target/loongarch/attr-check-error-message6.c: New test.
* gcc.target/loongarch/attr-check-error-message7.c: New test.
* gcc.target/loongarch/attr-check-error-message8.c: New test.
* gcc.target/loongarch/attr-check-error-message9.c: New test.

20 files changed:
gcc/testsuite/g++.target/loongarch/mv-symbols1.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mv-symbols2.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mv-symbols3.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mv-symbols4.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mv-symbols5.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mv-symbols6.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mvc-symbols1.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mvc-symbols2.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mvc-symbols3.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mvc-symbols4.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/mvc-symbols5.C [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.target/loongarch/mv-symbols1.C b/gcc/testsuite/g++.target/loongarch/mv-symbols1.C
new file mode 100644 (file)
index 0000000..4703f27
--- /dev/null
@@ -0,0 +1,62 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.arch_la64v1_0:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.strict_align:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3foov, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3foov,_Z3foov\.resolver" 1 } } */
+
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch_la64v1_0:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.strict_align:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3fooi, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3fooi,_Z3fooi\.resolver" 1 } } */
+
+int foo ()
+{
+  return 1;
+}
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo ()
+{
+  return 3;
+}
+__attribute__((target_version("strict-align")))
+int foo ()
+{
+  return 5;
+}
+
+int foo (int)
+{
+  return 2;
+}
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo (int)
+{
+  return 6;
+}
+
+__attribute__((target_version("strict-align")))
+int foo (int)
+{
+  return 4;
+}
+
+
+int bar()
+{
+  return foo ();
+}
+
+int bar(int x)
+{
+  return foo (x);
+}
diff --git a/gcc/testsuite/g++.target/loongarch/mv-symbols2.C b/gcc/testsuite/g++.target/loongarch/mv-symbols2.C
new file mode 100644 (file)
index 0000000..ab4934b
--- /dev/null
@@ -0,0 +1,53 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.arch_la64v1_0:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.strict_align:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } }*/
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3foov, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3foov,_Z3foov\.resolver" 1 } } */
+
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch_la64v1_0:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.strict_align:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3fooi, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3fooi,_Z3fooi\.resolver" 1 } } */
+
+
+int foo ()
+{
+  return 1;
+}
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo ()
+{
+  return 3;
+}
+
+__attribute__((target_version("strict-align")))
+int foo ()
+{
+  return 5;
+}
+
+int foo (int)
+{
+  return 2;
+}
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo (int)
+{
+  return 6;
+}
+
+__attribute__((target_version("strict-align")))
+int foo (int)
+{
+  return 4;
+}
diff --git a/gcc/testsuite/g++.target/loongarch/mv-symbols3.C b/gcc/testsuite/g++.target/loongarch/mv-symbols3.C
new file mode 100644 (file)
index 0000000..1fa4736
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.default:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.arch_la64v1_0:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.strict_align:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.resolver:\n" } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3foov, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3foov,_Z3foov\.resolver" } } */
+
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.default:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.arch_la64v1_0:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.strict_align:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.resolver:\n" } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3fooi, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3fooi,_Z3fooi\.resolver" } } */
+
+__attribute__((target_version("default")))
+int foo ();
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo ();
+
+__attribute__((target_version("strict-align")))
+int foo ();
+
+__attribute__((target_version("default")))
+int foo (int);
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo (int);
+
+__attribute__((target_version("strict-align")))
+int foo (int);
+
+int bar()
+{
+  return foo ();
+}
+
diff --git a/gcc/testsuite/g++.target/loongarch/mv-symbols4.C b/gcc/testsuite/g++.target/loongarch/mv-symbols4.C
new file mode 100644 (file)
index 0000000..8a0274e
--- /dev/null
@@ -0,0 +1,48 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.arch_la64v1_0:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.strict_align:\n" } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3foov, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3foov,_Z3foov\.resolver" 1 } } */
+
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.arch_la64v1_0:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.strict_align:\n" } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3fooi, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3fooi,_Z3fooi\.resolver" 1 } } */
+
+__attribute__((target_version("default")))
+int foo ()
+{
+  return 1;
+}
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo ();
+
+__attribute__((target_version("strict-align")))
+int foo ();
+
+__attribute__((target_version("default")))
+int foo (int)
+{
+  return 2;
+}
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo (int);
+
+__attribute__((target_version("strict-align")))
+int foo (int);
+
+
+int bar()
+{
+  return foo ();
+}
diff --git a/gcc/testsuite/g++.target/loongarch/mv-symbols5.C b/gcc/testsuite/g++.target/loongarch/mv-symbols5.C
new file mode 100644 (file)
index 0000000..67caab1
--- /dev/null
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.default:\n" } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.arch_la64v1_0:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.strict_align:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.resolver:\n" } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3foov, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3foov,_Z3foov\.resolver" } } */
+
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.default:\n" } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch_la64v1_0:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.strict_align:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.resolver:\n" } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3fooi, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3fooi,_Z3fooi\.resolver" } } */
+
+
+__attribute__((target_version("default")))
+int foo ();
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo ()
+{
+  return 3;
+}
+__attribute__((target_version("strict-align")))
+int foo ()
+{
+  return 5;
+}
+
+__attribute__((target_version("default")))
+int foo (int);
+
+__attribute__((target_version("arch=la64v1.0")))
+int foo (int)
+{
+  return 6;
+}
+
+__attribute__((target_version("strict-align")))
+int foo (int)
+{
+  return 4;
+}
+
+
+int bar()
+{
+  return foo ();
+}
+
diff --git a/gcc/testsuite/g++.target/loongarch/mv-symbols6.C b/gcc/testsuite/g++.target/loongarch/mv-symbols6.C
new file mode 100644 (file)
index 0000000..1c79652
--- /dev/null
@@ -0,0 +1,63 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.arch_la64v1_0_priority_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.strict_align_priority_2:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3foov, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3foov,_Z3foov\.resolver" 1 } } */
+
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch_la64v1_0_priority_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.strict_align_priority_2:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3fooi, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3fooi,_Z3fooi\.resolver" 1 } } */
+
+int foo ()
+{
+  return 1;
+}
+
+__attribute__((target_version("arch=la64v1.0;priority=1")))
+int foo ()
+{
+  return 3;
+}
+__attribute__((target_version("strict-align;priority=2")))
+int foo ()
+{
+  return 5;
+}
+
+int foo (int)
+{
+  return 2;
+}
+
+__attribute__((target_version("arch=la64v1.0;priority=1")))
+int foo (int)
+{
+  return 6;
+}
+
+__attribute__((target_version("strict-align;priority=2")))
+int foo (int)
+{
+  return 4;
+}
+
+
+int bar()
+{
+  return foo ();
+}
+
+int bar(int x)
+{
+  return foo (x);
+}
+
diff --git a/gcc/testsuite/g++.target/loongarch/mvc-symbols1.C b/gcc/testsuite/g++.target/loongarch/mvc-symbols1.C
new file mode 100644 (file)
index 0000000..a6fcfed
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.arch_la64v1_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.lsx:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3foov, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3foov,_Z3foov\.resolver" 1 } } */
+
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch_la64v1_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.lsx:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3fooi, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3fooi,_Z3fooi\.resolver" 1 } } */
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo ()
+{
+  return 1;
+}
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo (int)
+{
+  return 2;
+}
+
+
+int bar()
+{
+  return foo ();
+}
+
+int bar(int x)
+{
+  return foo (x);
+}
+
diff --git a/gcc/testsuite/g++.target/loongarch/mvc-symbols2.C b/gcc/testsuite/g++.target/loongarch/mvc-symbols2.C
new file mode 100644 (file)
index 0000000..ff5dc66
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.arch_la64v1_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.lsx:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3foov, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3foov,_Z3foov\.resolver" 1 } } */
+
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch_la64v1_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.lsx:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3fooi, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3fooi,_Z3fooi\.resolver" 1 } } */
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo ()
+{
+  return 1;
+}
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo (int)
+{
+  return 2;
+}
diff --git a/gcc/testsuite/g++.target/loongarch/mvc-symbols3.C b/gcc/testsuite/g++.target/loongarch/mvc-symbols3.C
new file mode 100644 (file)
index 0000000..da21111
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.default:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.arch_la64v1_1:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.lsx:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.resolver:\n" } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3foov, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3foov,_Z3foov\.resolver" } } */
+
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.default:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.arch_la64v1_1:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.lsx:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.resolver:\n" } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3fooi, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3fooi,_Z3fooi\.resolver" } } */
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo ();
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo (int);
+
+
+int bar()
+{
+  return foo ();
+}
+
+int bar(int x)
+{
+  return foo (x);
+}
+
diff --git a/gcc/testsuite/g++.target/loongarch/mvc-symbols4.C b/gcc/testsuite/g++.target/loongarch/mvc-symbols4.C
new file mode 100644 (file)
index 0000000..898a021
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.default:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.arch_la64v1_1:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.lsx:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3foov\.resolver:\n" } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3foov, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3foov,_Z3foov\.resolver" } } */
+
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.default:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.arch_la64v1_1:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.lsx:\n" } } */
+/* { dg-final { scan-assembler-not "\n_Z3fooi\.resolver:\n" } } */
+/* { dg-final { scan-assembler-not "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" } } */
+/* { dg-final { scan-assembler-not "\t\.type\t_Z3fooi, @gnu_indirect_function" } } */
+/* { dg-final { scan-assembler-not "\t\.set\t_Z3fooi,_Z3fooi\.resolver" } } */
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo ();
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx")))
+int foo (int);
+
+
diff --git a/gcc/testsuite/g++.target/loongarch/mvc-symbols5.C b/gcc/testsuite/g++.target/loongarch/mvc-symbols5.C
new file mode 100644 (file)
index 0000000..2d93dfb
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d -mcmodel=normal" } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.arch_la64v1_1_priority_3:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.lsx:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3foov\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3foov, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3foov,_Z3foov\.resolver" 1 } } */
+
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch_la64v1_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.lsx_priority_1:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */
+/* { dg-final { scan-assembler-times "\tbl\t\\\%plt\\\(_Z3fooi\\\)\n" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.type\t_Z3fooi, @gnu_indirect_function" 1 } } */
+/* { dg-final { scan-assembler-times "\t\.set\t_Z3fooi,_Z3fooi\.resolver" 1 } } */
+
+__attribute__((target_clones("default", "arch=la64v1.1;priority=3", "lsx")))
+int foo ()
+{
+  return 1;
+}
+
+__attribute__((target_clones("default", "arch=la64v1.1", "lsx;priority=1")))
+int foo (int)
+{
+  return 2;
+}
+
+
+int bar()
+{
+  return foo ();
+}
+
+int bar(int x)
+{
+  return foo (x);
+}
+
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message1.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message1.c
new file mode 100644 (file)
index 0000000..2435b87
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default;priority=1","lsx"))) void
+test (void)    /* { dg-error "\\\"default\\\" cannot be set together with other features in \\\'default;priority=1\\\'" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message2.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message2.c
new file mode 100644 (file)
index 0000000..ea79059
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default","lsx;"))) void
+test (void)    /* { dg-error "in attribute \\\'lsx;\\\' priority cannot be empty" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message3.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message3.c
new file mode 100644 (file)
index 0000000..663e641
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default",";priority=1"))) void
+test (void)    /* { dg-error "characher before \\\';\\\' in attribute \\\';priority=1\\\' cannot be empty" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message4.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message4.c
new file mode 100644 (file)
index 0000000..27565e9
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default","lsx;priority=1;lasx"))) void
+test (void)    /* { dg-error "in attribute \\\'lsx;priority=1;lasx\\\' the number of reatures cannot exceed two" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message5.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message5.c
new file mode 100644 (file)
index 0000000..03a774e
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default","lsx;priority=-1"))) void
+test (void)    /* { dg-error "Setting the priority value to \\\'-1\\\' is illegal in attribute \\\'lsx;priority=-1\\\'" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message6.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message6.c
new file mode 100644 (file)
index 0000000..88188a6
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default","lsx;lasx"))) void
+test (void)    /* { dg-error "in attribute \\\'lsx;lasx\\\', the second feature should be \\\"priority=\\\'num\\\'\\\" instead of \\\'lasx\\\'" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message7.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message7.c
new file mode 100644 (file)
index 0000000..80d4831
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default","arch="))) void
+test (void)    /* { dg-error "in attribute \\\'arch=\\\' you need to set a legal value for \\\"arch\\\"" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c
new file mode 100644 (file)
index 0000000..f27712b
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default","cmodel=normal"))) void
+test (void)    /* { dg-error "attribute \\\'cmodel=normal\\\' is not supported in \\\'target_version\\\' or \\\'target_clones\\\'" } */
+{}
diff --git a/gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c
new file mode 100644 (file)
index 0000000..4e02579
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-attributes" } */
+
+__attribute__ ((target_clones ("default","123456"))) void
+test (void)    /* { dg-error "\\\'123456\\\' is not supported in target attribute" } */
+{}