summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gcc/gcc-10/0030-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/gcc/gcc-10/0030-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch')
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-10/0030-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch241
1 files changed, 241 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-10/0030-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch b/meta-microblaze/recipes-devtools/gcc/gcc-10/0030-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch
new file mode 100644
index 00000000..bb773239
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-10/0030-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch
@@ -0,0 +1,241 @@
1From df38540af411564f428079335c8d1e695dc1d723 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 12:42:10 +0530
4Subject: [PATCH 30/58] [Patch, microblaze]: Fix bug in MB version calculation
5
6This patch fixes the bug in microblaze_version_to_int function.
7Earlier the conversion of vXX.YY.Z to int has a bug which is
8fixed now.
9
10Signed-off-by : Mahesh Bodapati <mbodapat@xilinx.com>
11 Nagaraju Mekala <nmekala@xilix.com>
12---
13 gcc/config/microblaze/microblaze.c | 145 ++++++++++++++---------------
14 1 file changed, 69 insertions(+), 76 deletions(-)
15
16diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
17index 0a73a6c32b4..4b5699671e8 100644
18--- a/gcc/config/microblaze/microblaze.c
19+++ b/gcc/config/microblaze/microblaze.c
20@@ -242,6 +242,63 @@ section *sdata2_section;
21 #define TARGET_HAVE_TLS true
22 #endif
23
24+/* Convert a version number of the form "vX.YY.Z" to an integer encoding
25+ for easier range comparison. */
26+static int
27+microblaze_version_to_int (const char *version)
28+{
29+ const char *p, *v;
30+ const char *tmpl = "vXX.YY.Z";
31+ int iver1 =0, iver2 =0, iver3 =0;
32+
33+ p = version;
34+ v = tmpl;
35+
36+ while (*p)
37+ {
38+ if (*v == 'X')
39+ { /* Looking for major */
40+ if (*p == '.')
41+ {
42+ *v++;
43+ }
44+ else
45+ {
46+ if (!(*p >= '0' && *p <= '9'))
47+ return -1;
48+ iver1 += (int) (*p - '0');
49+ iver1 *= 1000;
50+ }
51+ }
52+ else if (*v == 'Y')
53+ { /* Looking for minor */
54+ if (!(*p >= '0' && *p <= '9'))
55+ return -1;
56+ iver2 += (int) (*p - '0');
57+ iver2 *= 10;
58+ }
59+ else if (*v == 'Z')
60+ { /* Looking for compat */
61+ if (!(*p >= 'a' && *p <= 'z'))
62+ return -1;
63+ iver3 = ((int) (*p)) - 96;
64+ }
65+ else
66+ {
67+ if (*p != *v)
68+ return -1;
69+ }
70+
71+ v++;
72+ p++;
73+ }
74+
75+ if (*p)
76+ return -1;
77+
78+ return iver1 + iver2 + iver3;
79+}
80+
81 /* Return truth value if a CONST_DOUBLE is ok to be a legitimate constant. */
82 static bool
83 microblaze_const_double_ok (rtx op, machine_mode mode)
84@@ -1341,8 +1398,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
85 {
86 if (TARGET_BARREL_SHIFT)
87 {
88- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
89- >= 0)
90+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
91 *total = COSTS_N_INSNS (1);
92 else
93 *total = COSTS_N_INSNS (2);
94@@ -1403,8 +1459,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
95 }
96 else if (!TARGET_SOFT_MUL)
97 {
98- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
99- >= 0)
100+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
101 *total = COSTS_N_INSNS (1);
102 else
103 *total = COSTS_N_INSNS (3);
104@@ -1677,65 +1732,6 @@ function_arg_partial_bytes (cumulative_args_t cum_v,
105 return 0;
106 }
107
108-/* Convert a version number of the form "vX.YY.Z" to an integer encoding
109- for easier range comparison. */
110-static int
111-microblaze_version_to_int (const char *version)
112-{
113- const char *p, *v;
114- const char *tmpl = "vXX.YY.Z";
115- int iver = 0;
116-
117- p = version;
118- v = tmpl;
119-
120- while (*p)
121- {
122- if (*v == 'X')
123- { /* Looking for major */
124- if (*p == '.')
125- {
126- v++;
127- }
128- else
129- {
130- if (!(*p >= '0' && *p <= '9'))
131- return -1;
132- iver += (int) (*p - '0');
133- iver *= 10;
134- }
135- }
136- else if (*v == 'Y')
137- { /* Looking for minor */
138- if (!(*p >= '0' && *p <= '9'))
139- return -1;
140- iver += (int) (*p - '0');
141- iver *= 10;
142- }
143- else if (*v == 'Z')
144- { /* Looking for compat */
145- if (!(*p >= 'a' && *p <= 'z'))
146- return -1;
147- iver *= 10;
148- iver += (int) (*p - 'a');
149- }
150- else
151- {
152- if (*p != *v)
153- return -1;
154- }
155-
156- v++;
157- p++;
158- }
159-
160- if (*p)
161- return -1;
162-
163- return iver;
164-}
165-
166-
167 static void
168 microblaze_option_override (void)
169 {
170@@ -1763,13 +1759,13 @@ microblaze_option_override (void)
171 /* Check the MicroBlaze CPU version for any special action to be done. */
172 if (microblaze_select_cpu == NULL)
173 microblaze_select_cpu = MICROBLAZE_DEFAULT_CPU;
174- ver = microblaze_version_to_int (microblaze_select_cpu);
175- if (ver == -1)
176+ ver_int = microblaze_version_to_int (microblaze_select_cpu);
177+ if (ver_int == -1)
178 {
179 error ("%qs is an invalid argument to %<-mcpu=%>", microblaze_select_cpu);
180 }
181
182- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v3.00.a");
183+ ver = ver_int - microblaze_version_to_int("v3.00.a");
184 if (ver < 0)
185 {
186 /* No hardware exceptions in earlier versions. So no worries. */
187@@ -1780,8 +1776,7 @@ microblaze_option_override (void)
188 microblaze_pipe = MICROBLAZE_PIPE_3;
189 }
190 else if (ver == 0
191- || (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v4.00.b")
192- == 0))
193+ || (ver_int == microblaze_version_to_int("v4.00.b")))
194 {
195 #if 0
196 microblaze_select_flags |= (MICROBLAZE_MASK_NO_UNSAFE_DELAY);
197@@ -1798,11 +1793,9 @@ microblaze_option_override (void)
198 #endif
199 microblaze_no_unsafe_delay = 0;
200 microblaze_pipe = MICROBLAZE_PIPE_5;
201- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a") == 0
202- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
203- "v5.00.b") == 0
204- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
205- "v5.00.c") == 0)
206+ if ((ver_int == microblaze_version_to_int("v5.00.a"))
207+ || (ver_int == microblaze_version_to_int("v5.00.b"))
208+ || (ver_int == microblaze_version_to_int("v5.00.c")))
209 {
210 /* Pattern compares are to be turned on by default only when
211 compiling for MB v5.00.'z'. */
212@@ -1810,7 +1803,7 @@ microblaze_option_override (void)
213 }
214 }
215
216- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v6.00.a");
217+ ver = ver_int - microblaze_version_to_int("v6.00.a");
218 if (ver < 0)
219 {
220 if (TARGET_MULTIPLY_HIGH)
221@@ -1819,7 +1812,7 @@ microblaze_option_override (void)
222 "%<-mcpu=v6.00.a%> or greater");
223 }
224
225- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.10.a");
226+ ver = ver_int - microblaze_version_to_int("v8.10.a");
227 microblaze_has_clz = 1;
228 if (ver < 0)
229 {
230@@ -1828,7 +1821,7 @@ microblaze_option_override (void)
231 }
232
233 /* TARGET_REORDER defaults to 2 if -mxl-reorder not specified. */
234- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.30.a");
235+ ver = ver_int - microblaze_version_to_int("v8.30.a");
236 if (ver < 0)
237 {
238 if (TARGET_REORDER == 1)
239--
2402.17.1
241