Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / gcc.dg / special / mips-abi.exp
blobeb5157e8d0dd9f531869cbd944c401e10540c0bc
1 # Copyright (C) 2002, 2004 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # This test checks whether MIPS ELF configurations pass the right
18 # ABI flags to the assembler. An ABI flag should always be passed
19 # unless MEABI is selected.
21 load_lib gcc-dg.exp
23 # Only run this test on MIPS ELF targets
24 if {![istarget mips*-*-*] || [gcc_target_object_format] != "elf"} {
25 return
28 # A list of all assembler ABI flags.
29 set asm_abi_flags {-mabi=32 -mabi=n32 -mabi=64 -mabi=o64 -mabi=eabi}
31 # Try to assemble mips-abi.s (an empty file), passing -v in order to
32 # get the assembler command line. Check whether an appropriate ABI
33 # flag is passed.
35 # NAME is a name for the pass/fail line.
36 # ABIS is a list of acceptable assembler ABI flags, or "" if no
37 # ABI flag is expected.
38 # FLAGS is a list of options for gcc.
39 proc check_mips_abi {name abis flags} {
40 global srcdir subdir
42 lappend flags "-v"
43 set lines [gcc_target_compile "$srcdir/$subdir/mips-abi.s" \
44 "mips-abi.o" object \
45 [list "additional_flags=$flags"]]
46 set good 0
47 set bad 0
48 foreach line [split $lines "\n"] {
49 # Find the assembler command line.
50 if {[string first "$srcdir/$subdir/mips-abi.s" $line] >= 0} {
51 foreach arg [split $line " "] {
52 # Count the number of matching and non-matching
53 # ABI options.
54 if {[lsearch -exact $abis $arg] >= 0} {
55 incr good
56 } elseif {[string match "-mabi=*" $arg]} {
57 incr bad
62 if {$good == ($abis != "") && $bad == 0} {
63 pass "mips-abi $name"
64 } else {
65 fail "mips-abi $name"
69 # Collect the default target flags.
70 set default_flags ""
71 set target [target_info name]
72 if {[info exists CFLAGS_FOR_TARGET]} {
73 append default_flags " $CFLAGS_FOR_TARGET"
75 if {[board_info $target exists cflags]} {
76 append default_flags " [board_info $target cflags]"
78 if {[board_info $target exists multilib_flags]} {
79 append default_flags " [board_info $target multilib_flags]"
82 # See whether the default command line specifies an ABI.
83 set default_abi ""
84 foreach flag $default_flags {
85 if {[string match "-mabi=*" $flag]} {
86 set default_abi $flag
90 # If the command line does specify an ABI, just check for the
91 # appropriate assembler flag.
92 if {$default_abi != ""} {
93 check_mips_abi "command line" $default_abi ""
94 } else {
95 # An ABI should be passed to the assembler by default.
96 # It doesn't seem worthwhile to duplicate the
97 # configuration to ABI logic here, so just accept any ABI.
98 check_mips_abi "default" $asm_abi_flags ""
100 # See whether passing a -mabi flag does the right thing.
101 foreach abi $asm_abi_flags {
102 check_mips_abi $abi $abi $abi