Commit | Line | Data |
---|---|---|
e0001a05 NC |
1 | # Test Xtensa longcall optimization. |
2 | # By David Heine, Tensilica, Inc. | |
f96b4a7b | 3 | # Copyright 2002, 2003, 2007 |
e0001a05 NC |
4 | # Free Software Foundation, Inc. |
5 | # | |
f96b4a7b NC |
6 | # This file is part of the GNU Binutils. |
7 | # | |
8 | # This program is free software; you can redistribute it and/or modify | |
e0001a05 | 9 | # it under the terms of the GNU General Public License as published by |
f96b4a7b | 10 | # the Free Software Foundation; either version 3 of the License, or |
e0001a05 NC |
11 | # (at your option) any later version. |
12 | # | |
13 | # This program is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with this program; if not, write to the Free Software | |
f96b4a7b NC |
20 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
21 | # MA 02110-1301, USA. | |
e0001a05 | 22 | |
8fdeb6e3 BW |
23 | if ![istarget "xtensa-*-*"] { |
24 | return | |
25 | } | |
26 | ||
e0001a05 NC |
27 | set testname "LCALL" |
28 | ||
29 | set OBJDUMPFLAGS "-dr" | |
30 | ||
31 | # | |
32 | # default_ld_objdump | |
33 | # run objdump on a file | |
34 | # | |
35 | proc default_ld_objdump { objdump object outputfile } { | |
36 | global OBJDUMPFLAGS | |
37 | global objdump_output | |
38 | global host_triplet | |
39 | ||
40 | if {[which $objdump] == 0} then { | |
41 | perror "$objdump does not exist" | |
42 | return 0 | |
43 | } | |
44 | ||
45 | if ![info exists OBJDUMPFLAGS] { set OBJDUMPFLAGS "" } | |
46 | ||
47 | verbose -log "$objdump $OBJDUMPFLAGS $object >$outputfile" | |
48 | ||
49 | catch "exec $objdump $OBJDUMPFLAGS $object >$outputfile" exec_output | |
50 | set exec_output [prune_warnings $exec_output] | |
51 | if [string match "" $exec_output] then { | |
52 | return 1 | |
53 | } else { | |
54 | verbose -log "$exec_output" | |
55 | perror "$object: objdump failed" | |
56 | return 0 | |
57 | } | |
58 | } | |
59 | ||
60 | ||
61 | if ![ld_assemble $as $srcdir/$subdir/lcall1.s tmpdir/lcall1.o] { | |
62 | unresolved $testname | |
63 | return | |
64 | } | |
65 | if ![ld_assemble $as $srcdir/$subdir/lcall2.s tmpdir/lcall2.o] { | |
66 | unresolved $testname | |
67 | return | |
68 | } | |
69 | ||
70 | set object "tmpdir/lcall" | |
71 | set outputfile "$object.txt" | |
72 | ||
73 | if ![ld_simple_link $ld $object "-T $srcdir/$subdir/lcall.t tmpdir/lcall1.o tmpdir/lcall2.o"] { | |
74 | verbose -log "failure in ld" | |
75 | fail $testname | |
76 | return | |
77 | } | |
78 | ||
79 | if ![default_ld_objdump $objdump $object $outputfile ] { | |
80 | verbose -log "failure in objdump" | |
81 | fail $testname | |
82 | return | |
83 | } | |
84 | ||
85 | set file [open $outputfile r] | |
86 | while { [gets $file line] != -1 } { | |
87 | # verbose "$line" 2 | |
88 | if [regexp "l32r" $line] { | |
89 | verbose -log "Found an l32r in the linked object" | |
90 | verbose -log "$line" | |
91 | fail $testname | |
92 | } | |
93 | } | |
94 | close $file | |
95 | pass $testname | |
96 | ||
97 | ||
98 | set testname "LCALL2" | |
99 | set file [open $outputfile r] | |
100 | set found 0 | |
101 | ||
102 | while { [gets $file line] != -1 } { | |
103 | # verbose "$line" 2 | |
104 | if [regexp "^00000004 <label1>:" $line] { | |
105 | set found 1 | |
106 | } | |
107 | } | |
108 | close $file | |
109 | if $found { | |
110 | pass $testname | |
111 | } else { | |
112 | fail $testname | |
113 | } | |
114 |