Commit | Line | Data |
---|---|---|
2571583a | 1 | # Copyright (C) 2016-2017 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 | ||
55 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $disas_flags \ | |
56 | $objfile"] | |
57 | ||
58 | if [regexp $expected $got] then { | |
59 | pass $testname | |
60 | } else { | |
61 | fail $testname | |
62 | } | |
37fd5ef3 CZ |
63 | } |
64 | ||
65 | # Make sure that a warning message is generated (because the disassembly does | |
66 | # not match the assembled instructions, which has happened because the user | |
67 | # has not specified a -M option on the disassembler command line, and so the | |
68 | # disassembler has had to guess as the instruction class in use). | |
ee881e5d | 69 | set want "Warning: disassembly.*vmac2hnfr\[ \t\]*r0,r2,r4.*dmulh12.f\[ \t\]*r0,r2,r4.*dmulh11.f" |
e1e94c49 AK |
70 | check_assembly "Warning test" [do_objfile dsp.s] $want |
71 | ||
72 | set double_store_hs_expected {std\s*r0r1,\[r3\]} | |
73 | set objfile [do_objfile double_store.s] | |
74 | check_assembly "arc double_store default -M" $objfile \ | |
75 | $double_store_hs_expected | |
76 | check_assembly "arc double_store -Mcpu=hs" $objfile \ | |
77 | $double_store_hs_expected "-Mcpu=hs" | |
78 | check_assembly "arc double_store -Mcpu=hs38_linux" $objfile \ | |
79 | $double_store_hs_expected "-Mcpu=hs38_linux" | |
80 | set double_store_em_expected ".long 0x1b000006" | |
81 | check_assembly "arc double_store -Mcpu=em" $objfile \ | |
82 | $double_store_em_expected "-Mcpu=em" | |
83 | check_assembly "arc double_store -Mcpu=em4_dmips" $objfile \ | |
84 | $double_store_em_expected "-Mcpu=em4_dmips" | |
85 | # Test to ensure that only value up to the next `,' is checked. There used to | |
86 | # be a bug, where whole `em,fpus' was compared against known CPU values, and | |
87 | # that comparison would fail. When this bug is present, whole cpu= option will | |
88 | # be ignored and instruction will be disassembled as ARC HS. | |
89 | check_assembly "arc double_store -Mcpu=em,fpus" $objfile \ | |
90 | $double_store_em_expected "-Mcpu=em,fpus" | |
91 | # Make sure that the last cpu= value is used. | |
92 | check_assembly "arc double_store -Mcpu=hs,cpu=em" $objfile \ | |
93 | $double_store_em_expected "-Mcpu=hs,cpu=em" | |
fdddd290 | 94 | # Check the hex printing for short immediates. |
95 | set thexobj [do_objfile hexprint.s] | |
96 | check_assembly "arc hex printing" $thexobj \ | |
97 | {st\s*r0,\[r1,0xfffffff7\]} "-Mhex" | |
98 | check_assembly "arc normal printing" $thexobj \ | |
99 | {st\s*r0,\[r1,-9\]} |