summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc/0025-gcc-testsuite-tweaks-for-mips-OE.patch
blob: e4d57c27ef10bf6ff3ba17554fb4da46fdaea4fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
From f12acc6a383546d48da3bdfb2f25ca2adb7976d7 Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Sun, 13 Aug 2023 10:24:05 +0100
Subject: [PATCH] gcc testsuite tweaks for mips/OE

Disable loongson-mmi runtine, qemu doesn't appear to fully support them even if some
of the instruction decoding is there.

Also disable MSA mips runtime extensions. For some reason qemu appears to accept the test
code when it shouldn't. Our selected MIPS cpu for QEMU doesn't support them.

MIPS is unusual in the gcc testsuite as it uses EFFECTIVE_TARGETS and loops
multiple times through the vector testsuite. In the case of the two above, we can
compile/link them but not run them. Even with the runtime disabled, if the code
marks it as a runtime test, it will elevate itself to that. Setting the default
target to compile therefore isn't enough.

Therefore add code to downgrade runtime tests to link tests if the hardware
support isn't there to run them. This avoids thousands of test failures. To do
this we have to hook downgrade code into the main test runner.

Enable that downgrading for other cases where hardware to run vector extensions is
unavailable to remove test failures on other architectures too.

Also, for gcc.target tests, add checks on wheter loongson or msa code can
be run before trying that, allowing downgrading of tests there to work too.

Upstream-Status: Pending
[Parts of the patch may be able to be split off and acceptable to upstream with
discussion. Need to investigate why qemu-user passes the 'bad' instructions']

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 gcc/testsuite/gcc.target/mips/mips.exp | 16 +++++++++
 gcc/testsuite/lib/gcc-dg.exp           | 11 +++++++
 gcc/testsuite/lib/target-supports.exp  | 45 ++++++++------------------
 3 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
index 15d574202d3..2cef9709774 100644
--- a/gcc/testsuite/gcc.target/mips/mips.exp
+++ b/gcc/testsuite/gcc.target/mips/mips.exp
@@ -709,7 +709,23 @@ proc mips_first_unsupported_option { upstatus } {
     global mips_option_tests
     upvar $upstatus status
 
+    if { [mips_have_test_option_p status "-mmsa"] } {
+        verbose -log "Found -mmsa"
+	if { ![check_mips_msa_hw_available] } {
+	    verbose -log "No MSA avail"
+	    return "-mmsa"
+	}
+    }
+    if { [mips_have_test_option_p status "-mloongson-mmi"] } {
+        verbose -log "Found -mloonson-mmi"
+        if { ![check_mips_loongson_mmi_hw_available] } {
+	    verbose -log "No MMI avail"
+   	    return "-mloonson-mmi"
+	}
+    }
+
     foreach { option code } [array get mips_option_tests] {
+
 	if { [mips_have_test_option_p status $option] } {
 	    regsub -all "\n" $code "\\n\\\n" asm
 	    # Use check_runtime from target-supports.exp, which caches
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 9d79b9402e9..e0e5cbb1af8 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -240,9 +240,20 @@ proc schedule-cleanups { opts } {
 
 proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
     # Set up the compiler flags, based on what we're going to do.
+    global do-what-limit
 
     set options [list]
 
+    if [info exists do-what-limit] then {
+        # Demote run tests to $do-what-limit if set
+	switch $do_what {
+	    run {
+    	        set do_what ${do-what-limit}
+  		set dg-do-what ${do-what-limit}
+	    }
+        }
+    }
+
     switch $do_what {
 	"preprocess" {
 	    set compile_type "preprocess"
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 40f71e9ed8b..10e267fa16d 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2155,14 +2155,7 @@ proc check_mips_loongson_mmi_hw_available { } {
 	if { !([istarget mips*-*-*]) } {
 	    expr 0
 	} else {
-	    check_runtime_nocache mips_loongson_mmi_hw_available {
-	      #include <loongson-mmiintrin.h>
-	      int main()
-	      {
-		asm volatile ("paddw $f2,$f4,$f6");
-		return 0;
-	      }
-	    } "-mloongson-mmi"
+	    expr 0
 	}
     }]
 }
@@ -2176,29 +2169,7 @@ proc check_mips_msa_hw_available { } {
     if { !([istarget mips*-*-*]) } {
       expr 0
     } else {
-      check_runtime_nocache mips_msa_hw_available {
-	#if !defined(__mips_msa)
-	#error "MSA NOT AVAIL"
-	#else
-	#if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
-	#error "MSA NOT AVAIL FOR ISA REV < 2"
-	#endif
-	#if !defined(__mips_hard_float)
-	#error "MSA HARD_FLOAT REQUIRED"
-	#endif
-	#if __mips_fpr != 64
-	#error "MSA 64-bit FPR REQUIRED"
-	#endif
-	#include <msa.h>
-
-	int main()
-	{
-	  v8i16 v = __builtin_msa_ldi_h (0);
-	  v[0] = 0;
-	  return v[0];
-	}
-	#endif
-      } "-mmsa"
+      expr 0
     }
   }]
 }
@@ -9187,6 +9158,7 @@ proc is-effective-target-keyword { arg } {
 
 proc et-dg-runtest { runtest testcases flags default-extra-flags } {
     global dg-do-what-default
+    global do-what-limit
     global EFFECTIVE_TARGETS
     global et_index
 
@@ -9194,6 +9166,7 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
 	foreach target $EFFECTIVE_TARGETS {
 	    set target_flags $flags
 	    set dg-do-what-default compile
+            set do-what-limit link
 	    set et_index [lsearch -exact $EFFECTIVE_TARGETS $target]
 	    if { [info procs add_options_for_${target}] != [list] } {
 		set target_flags [add_options_for_${target} "$flags"]
@@ -9201,8 +9174,10 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
 	    if { [info procs check_effective_target_${target}_runtime]
 		 != [list] && [check_effective_target_${target}_runtime] } {
 		set dg-do-what-default run
+		set do-what-limit run
 	    }
 	    $runtest $testcases $target_flags ${default-extra-flags}
+	    unset do-what-limit
 	}
     } else {
 	set et_index 0
@@ -10789,6 +10764,7 @@ proc check_effective_target_sigsetjmp {} {
 proc check_vect_support_and_set_flags { } {
     global DEFAULT_VECTCFLAGS
     global dg-do-what-default
+    global do-what-limit
     global EFFECTIVE_TARGETS
 
     if  [istarget powerpc-*paired*]  {
@@ -10797,6 +10773,7 @@ proc check_vect_support_and_set_flags { } {
             set dg-do-what-default run
         } else {
             set dg-do-what-default compile
+            set do-what-limit link
         }
     } elseif [istarget powerpc*-*-*] {
         # Skip targets not supporting -maltivec.
@@ -10821,6 +10798,7 @@ proc check_vect_support_and_set_flags { } {
                 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
             }
             set dg-do-what-default compile
+            set do-what-limit link
         }
     } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
         lappend DEFAULT_VECTCFLAGS "-msse2"
@@ -10828,6 +10806,7 @@ proc check_vect_support_and_set_flags { } {
             set dg-do-what-default run
         } else {
             set dg-do-what-default compile
+            set do-what-limit link
         }
     } elseif { [istarget mips*-*-*]
 	       && [check_effective_target_nomips16] } {
@@ -10847,6 +10826,7 @@ proc check_vect_support_and_set_flags { } {
             set dg-do-what-default run
         } else {
             set dg-do-what-default compile
+            set do-what-limit link
         }
     } elseif [istarget alpha*-*-*] {
         # Alpha's vectorization capabilities are extremely limited.
@@ -10860,6 +10840,7 @@ proc check_vect_support_and_set_flags { } {
             set dg-do-what-default run
         } else {
             set dg-do-what-default compile
+            set do-what-limit link
         }
     } elseif [istarget ia64-*-*] {
         set dg-do-what-default run
@@ -10873,6 +10854,7 @@ proc check_vect_support_and_set_flags { } {
             set dg-do-what-default run
         } else {
             set dg-do-what-default compile
+            set do-what-limit link
         }
     } elseif [istarget aarch64*-*-*] {
         set dg-do-what-default run
@@ -10897,6 +10879,7 @@ proc check_vect_support_and_set_flags { } {
         } else {
 	    lappend DEFAULT_VECTCFLAGS "-march=z14" "-mzarch"
             set dg-do-what-default compile
+            set do-what-limit link
         }
     } elseif [istarget amdgcn-*-*] {
         set dg-do-what-default run