Commit | Line | Data |
---|---|---|
b3adc24a | 1 | # Copyright (C) 2016-2020 Free Software Foundation, Inc. |
37fd5ef3 CZ |
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 | ||
e1e94c49 | 28 | # Helper functions |
37fd5ef3 | 29 | |
e1e94c49 AK |
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 | |
37fd5ef3 CZ |
48 | } |
49 | ||
e1e94c49 AK |
50 | # Ensure that disassembler output includes EXPECTED lines. |
51 | proc check_assembly { testname objfile expected { disas_flags "" } } { | |
52 | global OBJDUMP | |
53 | global OBJDUMPFLAGS | |
54 | ||
f795c494 AM |
55 | if [string equal "" $objfile] then { |
56 | fail $testname | |
57 | return | |
58 | } | |
e1e94c49 AK |
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 | } | |
37fd5ef3 CZ |
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). | |
ee881e5d | 73 | set want "Warning: disassembly.*vmac2hnfr\[ \t\]*r0,r2,r4.*dmulh12.f\[ \t\]*r0,r2,r4.*dmulh11.f" |
e1e94c49 AK |
74 | check_assembly "Warning test" [do_objfile dsp.s] $want |
75 | ||
76 | set double_store_hs_expected {std\s*r0r1,\[r3\]} | |
77 | set objfile [do_objfile double_store.s] | |
78 | check_assembly "arc double_store default -M" $objfile \ | |
79 | $double_store_hs_expected | |
80 | check_assembly "arc double_store -Mcpu=hs" $objfile \ | |
81 | $double_store_hs_expected "-Mcpu=hs" | |
82 | check_assembly "arc double_store -Mcpu=hs38_linux" $objfile \ | |
83 | $double_store_hs_expected "-Mcpu=hs38_linux" | |
bd560f57 | 84 | set double_store_em_expected {word\s*0x1b000006} |
e1e94c49 AK |
85 | check_assembly "arc double_store -Mcpu=em" $objfile \ |
86 | $double_store_em_expected "-Mcpu=em" | |
87 | check_assembly "arc double_store -Mcpu=em4_dmips" $objfile \ | |
88 | $double_store_em_expected "-Mcpu=em4_dmips" | |
89 | # Test to ensure that only value up to the next `,' is checked. There used to | |
90 | # be a bug, where whole `em,fpus' was compared against known CPU values, and | |
91 | # that comparison would fail. When this bug is present, whole cpu= option will | |
92 | # be ignored and instruction will be disassembled as ARC HS. | |
93 | check_assembly "arc double_store -Mcpu=em,fpus" $objfile \ | |
94 | $double_store_em_expected "-Mcpu=em,fpus" | |
95 | # Make sure that the last cpu= value is used. | |
96 | check_assembly "arc double_store -Mcpu=hs,cpu=em" $objfile \ | |
97 | $double_store_em_expected "-Mcpu=hs,cpu=em" | |
fdddd290 | 98 | # Check the hex printing for short immediates. |
99 | set thexobj [do_objfile hexprint.s] | |
100 | check_assembly "arc hex printing" $thexobj \ | |
101 | {st\s*r0,\[r1,0xfffffff7\]} "-Mhex" | |
102 | check_assembly "arc normal printing" $thexobj \ | |
103 | {st\s*r0,\[r1,-9\]} |