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.

Change-Id: Ia4081109d2df5474299b21a1dc3bbb82808cc05c
---
 .../g++.target/loongarch/mv-symbols1.C        | 62 ++++++++++++++++++
 .../g++.target/loongarch/mv-symbols2.C        | 53 ++++++++++++++++
 .../g++.target/loongarch/mv-symbols3.C        | 42 +++++++++++++
 .../g++.target/loongarch/mv-symbols4.C        | 48 ++++++++++++++
 .../g++.target/loongarch/mv-symbols5.C        | 55 ++++++++++++++++
 .../g++.target/loongarch/mv-symbols6.C        | 63 +++++++++++++++++++
 .../g++.target/loongarch/mvc-symbols1.C       | 42 +++++++++++++
 .../g++.target/loongarch/mvc-symbols2.C       | 30 +++++++++
 .../g++.target/loongarch/mvc-symbols3.C       | 36 +++++++++++
 .../g++.target/loongarch/mvc-symbols4.C       | 26 ++++++++
 .../g++.target/loongarch/mvc-symbols5.C       | 42 +++++++++++++
 .../loongarch/attr-check-error-message1.c     |  6 ++
 .../loongarch/attr-check-error-message2.c     |  6 ++
 .../loongarch/attr-check-error-message3.c     |  6 ++
 .../loongarch/attr-check-error-message4.c     |  6 ++
 .../loongarch/attr-check-error-message5.c     |  6 ++
 .../loongarch/attr-check-error-message6.c     |  6 ++
 .../loongarch/attr-check-error-message7.c     |  6 ++
 .../loongarch/attr-check-error-message8.c     |  6 ++
 .../loongarch/attr-check-error-message9.c     |  6 ++
 20 files changed, 553 insertions(+)
 create mode 100644 gcc/testsuite/g++.target/loongarch/mv-symbols1.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mv-symbols2.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mv-symbols3.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mv-symbols4.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mv-symbols5.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mv-symbols6.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mvc-symbols1.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mvc-symbols2.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mvc-symbols3.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mvc-symbols4.C
 create mode 100644 gcc/testsuite/g++.target/loongarch/mvc-symbols5.C
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message1.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message2.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message3.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message4.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message5.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message6.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message7.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c
 create mode 100644 
gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c

diff --git a/gcc/testsuite/g++.target/loongarch/mv-symbols1.C 
b/gcc/testsuite/g++.target/loongarch/mv-symbols1.C
new file mode 100644
index 00000000000..b5094fc3e73
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mv-symbols1.C
@@ -0,0 +1,62 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..313b2834d62
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mv-symbols2.C
@@ -0,0 +1,53 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..867b547abee
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mv-symbols3.C
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..acf32c4d50e
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mv-symbols4.C
@@ -0,0 +1,48 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..a6bbca41213
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mv-symbols5.C
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..23b847692f6
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mv-symbols6.C
@@ -0,0 +1,63 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..e2c28e4ee42
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mvc-symbols1.C
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..a87aa4ad89c
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mvc-symbols2.C
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..e56fd7a4183
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mvc-symbols3.C
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..87dc138e9be
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mvc-symbols4.C
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..4f73a839025
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/mvc-symbols5.C
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+/* { dg-options "-O0 -march=loongarch64 -mabi=lp64d" } */
+/* { 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
index 00000000000..2435b87d2a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message1.c
@@ -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
index 00000000000..ea7905937d5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message2.c
@@ -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
index 00000000000..663e6411939
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message3.c
@@ -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
index 00000000000..27565e99428
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message4.c
@@ -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
index 00000000000..03a774ed49d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message5.c
@@ -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
index 00000000000..88188a687aa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message6.c
@@ -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
index 00000000000..80d4831d2b6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message7.c
@@ -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
index 00000000000..f27712bf5df
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message8.c
@@ -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
index 00000000000..4e02579942f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/attr-check-error-message9.c
@@ -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" } */
+{}
-- 
2.34.1

Reply via email to