Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 1 | From df38540af411564f428079335c8d1e695dc1d723 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 3 | Date: Wed, 18 Jan 2017 12:42:10 +0530 |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 4 | Subject: [PATCH 30/58] [Patch, microblaze]: Fix bug in MB version calculation |
| 5 | |
| 6 | This patch fixes the bug in microblaze_version_to_int function. |
| 7 | Earlier the conversion of vXX.YY.Z to int has a bug which is |
| 8 | fixed now. |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 9 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 10 | Signed-off-by : Mahesh Bodapati <mbodapat@xilinx.com> |
| 11 | Nagaraju Mekala <nmekala@xilix.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 12 | --- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 13 | gcc/config/microblaze/microblaze.c | 145 ++++++++++++++--------------- |
| 14 | 1 file changed, 69 insertions(+), 76 deletions(-) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 15 | |
| 16 | diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 17 | index 0a73a6c32b4..4b5699671e8 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 18 | --- a/gcc/config/microblaze/microblaze.c |
| 19 | +++ b/gcc/config/microblaze/microblaze.c |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 20 | @@ -242,6 +242,63 @@ section *sdata2_section; |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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) |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 84 | @@ -1341,8 +1398,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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); |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 94 | @@ -1403,8 +1459,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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); |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 104 | @@ -1677,65 +1732,6 @@ function_arg_partial_bytes (cumulative_args_t cum_v, |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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 | { |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 170 | @@ -1763,13 +1759,13 @@ microblaze_option_override (void) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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 | { |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 179 | error ("%qs is an invalid argument to %<-mcpu=%>", microblaze_select_cpu); |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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. */ |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 187 | @@ -1780,8 +1776,7 @@ microblaze_option_override (void) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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); |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 197 | @@ -1798,11 +1793,9 @@ microblaze_option_override (void) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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'. */ |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 212 | @@ -1810,7 +1803,7 @@ microblaze_option_override (void) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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) |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 221 | @@ -1819,7 +1812,7 @@ microblaze_option_override (void) |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 222 | "%<-mcpu=v6.00.a%> or greater"); |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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 | { |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 230 | @@ -1828,7 +1821,7 @@ microblaze_option_override (void) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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 | -- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 240 | 2.17.1 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 241 | |