-#
+# Copyright (C) 2012-2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
# Some generic SPARC and SPARC64 tests
-#
-if [istarget sparc*-*-*] then {
- set sparc64 [istarget sparc64*-*-*]
- if $sparc64 { run_dump_test "asi" }
+# FIXME: The tests here aren't really bullet proof. A mistake in the opcode
+# table can slip through since we use the same table for assembly and
+# disassembly. The way to fix this is to include a hex dump of the insns
+# and test that as well. Later.
+
+# Find out if these binutils are either sparc64*-*-* or
+# sparc*-*-* with --enable-targets=sparc64-*-*
+proc gas_64_check { } {
+ global NM
+ global NMFLAGS
+
+ set status [gas_host_run "$NM $NMFLAGS --help" ""]
+ return [regexp "elf64\[_-\]sparc" [lindex $status 1]]
+}
+
+proc sparc_elf_setup { } {
+ setup_xfail "sparc*-*-*aout*" "sparc*-*-sunos4*"
+ setup_xfail "sparc*-fujitsu-none" "sparc*-*-*n*bsd*"
+ setup_xfail "sparc*-*-coff" "sparc*-*-lynxos*"
+ clear_xfail "sparc64*-*-*n*bsd*"
+ clear_xfail "sparc*-*-netbsdelf*"
+}
+
+if [istarget sparc*-*-*] {
+ run_dump_test "synth"
+ # The next four tests are ELF only.
+ sparc_elf_setup
+ run_dump_test "unalign"
+ sparc_elf_setup
+ run_dump_test "pcrel"
+ sparc_elf_setup
+ run_dump_test "plt"
+ sparc_elf_setup
+ run_dump_test "gotop32"
+ if [gas_64_check] {
+ run_dump_test "asi"
+ run_dump_test "membar"
+ run_dump_test "prefetch"
+ run_dump_test "set64"
+ run_dump_test "synth64"
+ run_dump_test "rdpr"
+ run_dump_test "rdhpr"
+ run_dump_test "wrpr"
+ run_dump_test "wrhpr"
+ run_dump_test "window"
+ run_dump_test "reloc64"
+ run_dump_test "pcrel64"
+ run_dump_test "plt64"
+ run_dump_test "gotop64"
+ }
+ run_dump_test "imm-plus-rreg"
+ run_dump_test "ticc-imm-reg"
+ run_dump_test "v8-movwr-imm"
+ run_dump_test "save-args"
+ run_dump_test "v9branch1"
+ run_dump_test "v9branch2"
+ run_dump_test "v9branch3"
+ run_dump_test "v9branch4"
+ run_dump_test "v9branch5"
+ run_dump_test "pc2210"
+ run_dump_test "hpcvis3"
+ run_dump_test "ima"
+ run_dump_test "crypto"
+ run_dump_test "xcrypto"
+ run_dump_test "cbcond"
+ run_dump_test "pause"
+ run_dump_test "cfr"
+ run_dump_test "ldtw_sttw"
+ run_dump_test "ldd_std"
+ run_dump_test "ldx_stx"
+ run_dump_test "ldx_efsr"
+ run_dump_test "ld_st_fsr"
+ run_dump_test "edge"
+ run_dump_test "flush"
+ run_dump_test "mwait"
+ run_dump_test "mcdper"
+ run_dump_test "sparc5vis4"
+ run_dump_test "natural"
+ run_dump_test "natural-32"
+
+ run_list_test "pr4587" ""
+}
+
+if [istarget sparc-*-vxworks*] {
+ run_dump_test "vxworks-pic"
+}
+
+if [istarget sparclet*-*-*] {
+ run_dump_test "splet"
+ run_dump_test "splet-2"
}