summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gcc/gcc-13/0024-this-patch-has-1.Fixed-the-bug-in-version-calculatio.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/gcc/gcc-13/0024-this-patch-has-1.Fixed-the-bug-in-version-calculatio.patch')
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-13/0024-this-patch-has-1.Fixed-the-bug-in-version-calculatio.patch373
1 files changed, 373 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-13/0024-this-patch-has-1.Fixed-the-bug-in-version-calculatio.patch b/meta-microblaze/recipes-devtools/gcc/gcc-13/0024-this-patch-has-1.Fixed-the-bug-in-version-calculatio.patch
new file mode 100644
index 00000000..0356657b
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-13/0024-this-patch-has-1.Fixed-the-bug-in-version-calculatio.patch
@@ -0,0 +1,373 @@
1From a8991be91d79cf0bd17b7d303a10ec5edd7408c6 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 12:23:54 +0530
4Subject: [PATCH 24/54] this patch has 1.Fixed the bug in version calculation.
5 2.Add new bitfield instructions.
6
7Signed-off-by :Mahesh Bodapati <mbodapat@xilinx.com>
8---
9 gcc/config/microblaze/microblaze.cc | 154 ++++++++++++++--------------
10 gcc/config/microblaze/microblaze.h | 2 +
11 gcc/config/microblaze/microblaze.md | 69 +++++++++++++
12 3 files changed, 147 insertions(+), 78 deletions(-)
13
14diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
15index 2d516724acc..e28ab593c3e 100644
16--- a/gcc/config/microblaze/microblaze.cc
17+++ b/gcc/config/microblaze/microblaze.cc
18@@ -165,6 +165,9 @@ int microblaze_no_unsafe_delay;
19 /* Set to one if the targeted core has the CLZ insn. */
20 int microblaze_has_clz = 0;
21
22+/* Set to one if the targeted core has barrel-shift and cpu > 10.0 */
23+int microblaze_has_bitfield = 0;
24+
25 /* Which CPU pipeline do we use. We haven't really standardized on a CPU
26 version having only a particular type of pipeline. There can still be
27 options on the CPU to scale pipeline features up or down. :(
28@@ -240,6 +243,63 @@ section *sdata2_section;
29 #define TARGET_HAVE_TLS true
30 #endif
31
32+/* Convert a version number of the form "vX.YY.Z" to an integer encoding
33+ for easier range comparison. */
34+static int
35+microblaze_version_to_int (const char *version)
36+{
37+ const char *p, *v;
38+ const char *tmpl = "vXX.YY.Z";
39+ int iver1 =0, iver2 =0, iver3 =0;
40+
41+ p = version;
42+ v = tmpl;
43+
44+ while (*p)
45+ {
46+ if (*v == 'X')
47+ { /* Looking for major */
48+ if (*p == '.')
49+ {
50+ *v++;
51+ }
52+ else
53+ {
54+ if (!(*p >= '0' && *p <= '9'))
55+ return -1;
56+ iver1 += (int) (*p - '0');
57+ iver1 *= 1000;
58+ }
59+ }
60+ else if (*v == 'Y')
61+ { /* Looking for minor */
62+ if (!(*p >= '0' && *p <= '9'))
63+ return -1;
64+ iver2 += (int) (*p - '0');
65+ iver2 *= 10;
66+ }
67+ else if (*v == 'Z')
68+ { /* Looking for compat */
69+ if (!(*p >= 'a' && *p <= 'z'))
70+ return -1;
71+ iver3 = ((int) (*p)) - 96;
72+ }
73+ else
74+ {
75+ if (*p != *v)
76+ return -1;
77+ }
78+
79+ v++;
80+ p++;
81+ }
82+
83+ if (*p)
84+ return -1;
85+
86+ return iver1 + iver2 + iver3;
87+}
88+
89 /* Return truth value if a CONST_DOUBLE is ok to be a legitimate constant. */
90 static bool
91 microblaze_const_double_ok (rtx op, machine_mode mode)
92@@ -1344,8 +1404,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
93 {
94 if (TARGET_BARREL_SHIFT)
95 {
96- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
97- >= 0)
98+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
99 *total = COSTS_N_INSNS (1);
100 else
101 *total = COSTS_N_INSNS (2);
102@@ -1406,8 +1465,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
103 }
104 else if (!TARGET_SOFT_MUL)
105 {
106- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
107- >= 0)
108+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
109 *total = COSTS_N_INSNS (1);
110 else
111 *total = COSTS_N_INSNS (3);
112@@ -1680,72 +1738,13 @@ function_arg_partial_bytes (cumulative_args_t cum_v,
113 return 0;
114 }
115
116-/* Convert a version number of the form "vX.YY.Z" to an integer encoding
117- for easier range comparison. */
118-static int
119-microblaze_version_to_int (const char *version)
120-{
121- const char *p, *v;
122- const char *tmpl = "vXX.YY.Z";
123- int iver = 0;
124-
125- p = version;
126- v = tmpl;
127-
128- while (*p)
129- {
130- if (*v == 'X')
131- { /* Looking for major */
132- if (*p == '.')
133- {
134- v++;
135- }
136- else
137- {
138- if (!(*p >= '0' && *p <= '9'))
139- return -1;
140- iver += (int) (*p - '0');
141- iver *= 10;
142- }
143- }
144- else if (*v == 'Y')
145- { /* Looking for minor */
146- if (!(*p >= '0' && *p <= '9'))
147- return -1;
148- iver += (int) (*p - '0');
149- iver *= 10;
150- }
151- else if (*v == 'Z')
152- { /* Looking for compat */
153- if (!(*p >= 'a' && *p <= 'z'))
154- return -1;
155- iver *= 10;
156- iver += (int) (*p - 'a');
157- }
158- else
159- {
160- if (*p != *v)
161- return -1;
162- }
163-
164- v++;
165- p++;
166- }
167-
168- if (*p)
169- return -1;
170-
171- return iver;
172-}
173-
174-
175 static void
176 microblaze_option_override (void)
177 {
178 int i, start;
179 int regno;
180 machine_mode mode;
181- int ver;
182+ int ver,ver_int;
183
184 microblaze_section_threshold = (OPTION_SET_P (g_switch_value)
185 ? g_switch_value
186@@ -1766,13 +1765,13 @@ microblaze_option_override (void)
187 /* Check the MicroBlaze CPU version for any special action to be done. */
188 if (microblaze_select_cpu == NULL)
189 microblaze_select_cpu = MICROBLAZE_DEFAULT_CPU;
190- ver = microblaze_version_to_int (microblaze_select_cpu);
191- if (ver == -1)
192+ ver_int = microblaze_version_to_int (microblaze_select_cpu);
193+ if (ver_int == -1)
194 {
195 error ("%qs is an invalid argument to %<-mcpu=%>", microblaze_select_cpu);
196 }
197
198- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v3.00.a");
199+ ver = ver_int - microblaze_version_to_int("v3.00.a");
200 if (ver < 0)
201 {
202 /* No hardware exceptions in earlier versions. So no worries. */
203@@ -1783,8 +1782,7 @@ microblaze_option_override (void)
204 microblaze_pipe = MICROBLAZE_PIPE_3;
205 }
206 else if (ver == 0
207- || (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v4.00.b")
208- == 0))
209+ || (ver_int == microblaze_version_to_int("v4.00.b")))
210 {
211 #if 0
212 microblaze_select_flags |= (MICROBLAZE_MASK_NO_UNSAFE_DELAY);
213@@ -1801,11 +1799,9 @@ microblaze_option_override (void)
214 #endif
215 microblaze_no_unsafe_delay = 0;
216 microblaze_pipe = MICROBLAZE_PIPE_5;
217- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a") == 0
218- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
219- "v5.00.b") == 0
220- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
221- "v5.00.c") == 0)
222+ if ((ver_int == microblaze_version_to_int("v5.00.a"))
223+ || (ver_int == microblaze_version_to_int("v5.00.b"))
224+ || (ver_int == microblaze_version_to_int("v5.00.c")))
225 {
226 /* Pattern compares are to be turned on by default only when
227 compiling for MB v5.00.'z'. */
228@@ -1813,7 +1809,7 @@ microblaze_option_override (void)
229 }
230 }
231
232- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v6.00.a");
233+ ver = ver_int - microblaze_version_to_int("v6.00.a");
234 if (ver < 0)
235 {
236 if (TARGET_MULTIPLY_HIGH)
237@@ -1822,7 +1818,7 @@ microblaze_option_override (void)
238 "%<-mcpu=v6.00.a%> or greater");
239 }
240
241- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.10.a");
242+ ver = ver_int - microblaze_version_to_int("v8.10.a");
243 microblaze_has_clz = 1;
244 if (ver < 0)
245 {
246@@ -1831,7 +1827,7 @@ microblaze_option_override (void)
247 }
248
249 /* TARGET_REORDER defaults to 2 if -mxl-reorder not specified. */
250- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.30.a");
251+ ver = ver_int - microblaze_version_to_int("v8.30.a");
252 if (ver < 0)
253 {
254 if (TARGET_REORDER == 1)
255@@ -1846,7 +1842,7 @@ microblaze_option_override (void)
256 "%<-mcpu=v8.30.a%>");
257 TARGET_REORDER = 0;
258 }
259- ver = microblaze_version_to_int("v10.0");
260+ ver = ver_int - microblaze_version_to_int("v10.0");
261 if (ver < 0)
262 {
263 if (TARGET_AREA_OPTIMIZED_2)
264@@ -1856,6 +1852,8 @@ microblaze_option_override (void)
265 {
266 if (TARGET_AREA_OPTIMIZED_2)
267 microblaze_pipe = MICROBLAZE_PIPE_8;
268+ if (TARGET_BARREL_SHIFT)
269+ microblaze_has_bitfield = 1;
270 }
271
272 if (TARGET_MULTIPLY_HIGH && TARGET_SOFT_MUL)
273diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
274index e4faa9c681f..94d96bf6b5d 100644
275--- a/gcc/config/microblaze/microblaze.h
276+++ b/gcc/config/microblaze/microblaze.h
277@@ -44,6 +44,7 @@ extern int microblaze_debugger_regno[];
278
279 extern int microblaze_no_unsafe_delay;
280 extern int microblaze_has_clz;
281+extern int microblaze_has_bitfield;
282 extern enum pipeline_type microblaze_pipe;
283
284 #define OBJECT_FORMAT_ELF
285@@ -63,6 +64,7 @@ extern enum pipeline_type microblaze_pipe;
286 /* Do we have CLZ? */
287 #define TARGET_HAS_CLZ (TARGET_PATTERN_COMPARE && microblaze_has_clz)
288
289+#define TARGET_HAS_BITFIELD (TARGET_BARREL_SHIFT && microblaze_has_bitfield)
290 /* The default is to support PIC. */
291 #define TARGET_SUPPORTS_PIC 1
292
293diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
294index 7a01b28d8f0..a76287ab4fd 100644
295--- a/gcc/config/microblaze/microblaze.md
296+++ b/gcc/config/microblaze/microblaze.md
297@@ -2491,4 +2491,73 @@
298 DONE;
299 }")
300
301+(define_expand "extvsi"
302+ [(set (match_operand:SI 0 "register_operand" "r")
303+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
304+ (match_operand:SI 2 "immediate_operand" "I")
305+ (match_operand:SI 3 "immediate_operand" "I")))]
306+"TARGET_HAS_BITFIELD"
307+"
308+{
309+ unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
310+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
311+
312+ if ((len == 0) || (pos + len > 32) )
313+ FAIL;
314+
315+ ;;if (!register_operand (operands[1], VOIDmode))
316+ ;; FAIL;
317+ if (operands[0] == operands[1])
318+ FAIL;
319+ if (GET_CODE (operands[1]) == ASHIFT)
320+ FAIL;
321+;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
322+ emit_insn (gen_extv_32 (operands[0], operands[1],
323+ operands[2], operands[3]));
324+ DONE;
325+}")
326+
327+(define_insn "extv_32"
328+ [(set (match_operand:SI 0 "register_operand" "=r")
329+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
330+ (match_operand:SI 2 "immediate_operand" "I")
331+ (match_operand:SI 3 "immediate_operand" "I")))]
332+ "TARGET_HAS_BITFIELD && (UINTVAL (operands[2]) > 0)
333+ && ((UINTVAL (operands[2]) + UINTVAL (operands[3])) <= 32)"
334+ "bsefi %0,%1,%2,%3"
335+ [(set_attr "type" "bshift")
336+ (set_attr "length" "4")])
337+
338+(define_expand "insvsi"
339+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
340+ (match_operand:SI 1 "immediate_operand" "I")
341+ (match_operand:SI 2 "immediate_operand" "I"))
342+ (match_operand:SI 3 "register_operand" "r"))]
343+ "TARGET_HAS_BITFIELD"
344+ "
345+{
346+ unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
347+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
348+
349+ if (len <= 0 || pos + len > 32)
350+ FAIL;
351+
352+ ;;if (!register_operand (operands[0], VOIDmode))
353+ ;; FAIL;
354+ emit_insn (gen_insv_32 (operands[0], operands[1],
355+ operands[2], operands[3]));
356+ DONE;
357+}")
358+
359+(define_insn "insv_32"
360+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
361+ (match_operand:SI 1 "immediate_operand" "I")
362+ (match_operand:SI 2 "immediate_operand" "I"))
363+ (match_operand:SI 3 "register_operand" "r"))]
364+ "TARGET_HAS_BITFIELD && UINTVAL (operands[1]) > 0
365+ && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
366+ "bsifi %0, %3, %1, %2"
367+ [(set_attr "type" "bshift")
368+ (set_attr "length" "4")])
369+
370 (include "sync.md")
371--
3722.34.1
373