]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/lib/aarch64.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / aarch64.exp
1 # Copyright 2023-2024 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, see <http://www.gnu.org/licenses/>. */
15
16 # Support routines for aarch64-specific tests
17
18 #
19 # Return a regular expression that matches what gdb would print for a
20 # 1-dimension vector containing ELEMENTS elements of value BYTE.
21 #
22 # The pattern is of the form "{BYTE <repeats ELEMENTS times>".
23 #
24 proc 1d_array_value_pattern { byte elements } {
25 set brace_open "{"
26 set brace_close "}"
27
28 append data $brace_open $byte
29 if {$elements > 1} {
30 append data " <repeats $elements times>"
31 }
32 append data $brace_close
33
34 verbose -log "1d_array_value_pattern Pattern string is..."
35 verbose -log $data
36 return $data
37 }
38
39 #
40 # Return a regular expression that matches what gdb would print for a
41 # 2-dimension vector containing ROWS rows and COLUMNS columns of elements
42 # of value BYTE.
43 #
44 # The pattern is of the form
45 # "{{BYTE <repeats COLUMNS times>} <repeats ROWS times>}".
46 #
47 proc 2d_array_value_pattern { byte rows columns } {
48 set brace_open "{"
49 set brace_close "}"
50
51 append data $brace_open [1d_array_value_pattern $byte $columns]
52 if {$rows > 1} {
53 append data " <repeats $rows times>"
54 }
55 append data $brace_close
56
57 verbose -log "2d_array_value_pattern Pattern string is..."
58 verbose -log $data
59 return $data
60 }
61
62 #
63 # Initialize register NAME, a 1-dimension vector, with ELEMENTS elements
64 # by setting all elements to BYTE. ELEMENTS is limited at 256 for memory
65 # usage purposes.
66 #
67 # The initialization is of the form "{BYTE, BYTE, BYTE ...}".
68 #
69 proc initialize_1d_array { name byte elements } {
70 set brace_open "{"
71 set brace_close "}"
72
73 append data $brace_open
74
75 # Build the assignment in a single shot.
76 for {set element 0} {$element < $elements} {incr element} {
77 # Construct the initializer by appending elements to it.
78 append data $byte
79
80 # If this isn't the last element, add a comma.
81 if {[expr $element + 1] < $elements} {
82 append data ", "
83 }
84 }
85 append data $brace_close
86
87 verbose -log "initialization string is..."
88 verbose -log $data
89 gdb_test_no_output "set $name = $data" "write to $name"
90 }
91
92 #
93 # Return an initializer string for a 2-dimension vector with ROWS rows and
94 # COLUMNS columns, initializing all elements to BYTE for register NAME.
95 #
96 # COLUMNS is limited to 256 elements for memory usage purposes.
97 #
98 # The initialization is of the form "{{BYTE, BYTE}, ..., {BYTE, BYTE}}}".
99 #
100 proc initialize_2d_array { name byte rows columns } {
101 set brace_open "{"
102 set brace_close "}"
103
104 if {[expr $rows * $columns] <= 256} {
105 # Build the assignment in a single shot, as we have a maximum of 256
106 # elements.
107 for {set row 0} {$row < $rows} {incr row} {
108 append data $brace_open
109 for {set column 0} {$column < $columns} {incr column} {
110 # Construct the initializer by appending elements to it.
111 append data $byte
112
113 # If this isn't the last column, add a comma.
114 if {[expr $column + 1] < $columns} {
115 append data ", "
116 }
117 }
118
119 append data $brace_close
120
121 # If this isn't the last row, add a comma.
122 if {[expr $row + 1] < $rows} {
123 append data ","
124 }
125 }
126
127 set data $brace_open$data
128 set data $data$brace_close
129
130 verbose -log "initialization string is..."
131 verbose -log $data
132 gdb_test_no_output "set $name = $data" "write to $name"
133 } else {
134 # There are too many elements to initialize (more than 256), so we
135 # will do the initialization row by row.
136 for {set row 0} {$row < $rows} {incr row} {
137 initialize_1d_array "$name\[$row\]" $byte $columns
138 }
139 }
140 }
141
142 #
143 # Validate the values of the FPSIMD registers.
144 #
145 proc check_fpsimd_regs { byte state vl svl} {
146 set fpsimd_pattern [string_to_regexp [1d_array_value_pattern $byte 16]]
147
148 for {set number 0} {$number < 32} {incr number} {
149 set register_name "\$v${number}\.b\.u"
150 gdb_test "print sizeof $register_name" " = 16"
151 gdb_test "print $register_name" $fpsimd_pattern
152 }
153 }