1 # Copyright 2023-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
16 # Support routines for aarch64-specific tests
19 # Return a regular expression that matches what gdb would print for a
20 # 1-dimension vector containing ELEMENTS elements of value BYTE.
22 # The pattern is of the form "{BYTE <repeats ELEMENTS times>".
24 proc 1d_array_value_pattern { byte elements } {
28 append data $brace_open $byte
30 append data " <repeats $elements times>"
32 append data $brace_close
34 verbose -log "1d_array_value_pattern Pattern string is..."
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
44 # The pattern is of the form
45 # "{{BYTE <repeats COLUMNS times>} <repeats ROWS times>}".
47 proc 2d_array_value_pattern { byte rows columns } {
51 append data $brace_open [1d_array_value_pattern $byte $columns]
53 append data " <repeats $rows times>"
55 append data $brace_close
57 verbose -log "2d_array_value_pattern Pattern string is..."
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
67 # The initialization is of the form "{BYTE, BYTE, BYTE ...}".
69 proc initialize_1d_array { name byte elements } {
73 append data $brace_open
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.
80 # If this isn't the last element, add a comma.
81 if {[expr $element + 1] < $elements} {
85 append data $brace_close
87 verbose -log "initialization string is..."
89 gdb_test_no_output "set $name = $data" "write to $name"
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.
96 # COLUMNS is limited to 256 elements for memory usage purposes.
98 # The initialization is of the form "{{BYTE, BYTE}, ..., {BYTE, BYTE}}}".
100 proc initialize_2d_array { name byte rows columns } {
104 if {[expr $rows * $columns] <= 256} {
105 # Build the assignment in a single shot, as we have a maximum of 256
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.
113 # If this isn't the last column, add a comma.
114 if {[expr $column + 1] < $columns} {
119 append data $brace_close
121 # If this isn't the last row, add a comma.
122 if {[expr $row + 1] < $rows} {
127 set data $brace_open$data
128 set data $data$brace_close
130 verbose -log "initialization string is..."
132 gdb_test_no_output "set $name = $data" "write to $name"
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
143 # Validate the values of the FPSIMD registers.
145 proc check_fpsimd_regs { byte state vl svl} {
146 set fpsimd_pattern [string_to_regexp [1d_array_value_pattern $byte 16]]
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