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