]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - binutils/testsuite/binutils-all/arc/objdump.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / binutils / testsuite / binutils-all / arc / objdump.exp
1 # Copyright (C) 2016-2021 Free Software Foundation, Inc.
2
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 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
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.
16
17 if {![istarget "arc*-*-*"]} then {
18 return
19 }
20
21 if {[which $OBJDUMP] == 0} then {
22 perror "$OBJDUMP does not exist"
23 return
24 }
25
26 send_user "Version [binutil_version $OBJDUMP]"
27
28 # Helper functions
29
30 # Create object file from the assembly source.
31 proc do_objfile { srcfile } {
32 global srcdir
33 global subdir
34
35 set objfile [regsub -- "\.s$" $srcfile ".o"]
36
37 if {![binutils_assemble $srcdir/$subdir/$srcfile tmpdir/$objfile]} then {
38 return
39 }
40
41 if [is_remote host] {
42 set objfile [remote_download host tmpdir/$objfile]
43 } else {
44 set objfile tmpdir/$objfile
45 }
46
47 return $objfile
48 }
49
50 # Ensure that disassembler output includes EXPECTED lines.
51 proc check_assembly { testname objfile expected { disas_flags "" } } {
52 global OBJDUMP
53 global OBJDUMPFLAGS
54
55 if [string equal "" $objfile] then {
56 fail $testname
57 return
58 }
59 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $disas_flags \
60 $objfile"]
61
62 if [regexp $expected $got] then {
63 pass $testname
64 } else {
65 fail $testname
66 }
67 }
68
69 # Make sure that a warning message is generated (because the disassembly does
70 # not match the assembled instructions, which has happened because the user
71 # has not specified a -M option on the disassembler command line, and so the
72 # disassembler has had to guess as the instruction class in use).
73 set want "Warning: disassembly.*vmac2hnfr\[ \t\]*r0,r2,r4.*dmulh12.f\[ \t\]*r0,r2,r4.*dmulh11.f"
74 check_assembly "Warning test" [do_objfile dsp.s] $want
75 set warn_double_reg "Warning: illegal use of double register pair."
76 check_assembly "Warning faulty double regs" [do_objfile double_regs.s] \
77 $warn_double_reg
78
79 set double_store_hs_expected {std\s*r0r1,\[r3\]}
80 set objfile [do_objfile double_store.s]
81 check_assembly "arc double_store default -M" $objfile \
82 $double_store_hs_expected
83 check_assembly "arc double_store -Mcpu=hs" $objfile \
84 $double_store_hs_expected "-Mcpu=hs"
85 check_assembly "arc double_store -Mcpu=hs38_linux" $objfile \
86 $double_store_hs_expected "-Mcpu=hs38_linux"
87 set double_store_em_expected {word\s*0x1b000006}
88 check_assembly "arc double_store -Mcpu=em" $objfile \
89 $double_store_em_expected "-Mcpu=em"
90 check_assembly "arc double_store -Mcpu=em4_dmips" $objfile \
91 $double_store_em_expected "-Mcpu=em4_dmips"
92 # Test to ensure that only value up to the next `,' is checked. There used to
93 # be a bug, where whole `em,fpus' was compared against known CPU values, and
94 # that comparison would fail. When this bug is present, whole cpu= option will
95 # be ignored and instruction will be disassembled as ARC HS.
96 check_assembly "arc double_store -Mcpu=em,fpus" $objfile \
97 $double_store_em_expected "-Mcpu=em,fpus"
98 # Make sure that the last cpu= value is used.
99 check_assembly "arc double_store -Mcpu=hs,cpu=em" $objfile \
100 $double_store_em_expected "-Mcpu=hs,cpu=em"
101 # Check the hex printing for short immediates.
102 set thexobj [do_objfile hexprint.s]
103 check_assembly "arc hex printing" $thexobj \
104 {st\s*r0,\[r1,0xfffffff7\]} "-Mhex"
105 check_assembly "arc normal printing" $thexobj \
106 {st\s*r0,\[r1,-9\]}