1 /** 2 * Compiler implementation of the 3 * $(LINK2 http://www.dlang.org, D programming language). 4 * 5 * Copyright: Copyright (c) 1999-2016 by Digital Mars, All Rights Reserved 6 * Authors: $(LINK2 http://www.digitalmars.com, Walter Bright) 7 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 * Source: $(DMDSRC _impcnvtab.d) 9 */ 10 11 module ddmd.impcnvtab; 12 13 import ddmd.mtype; 14 15 immutable ENUMTY[TMAX][TMAX] impcnvResult = impCnvTab.impcnvResultTab; 16 immutable ENUMTY[TMAX][TMAX] impcnvType1 = impCnvTab.impcnvType1Tab; 17 immutable ENUMTY[TMAX][TMAX] impcnvType2 = impCnvTab.impcnvType2Tab; 18 19 private: 20 21 struct ImpCnvTab 22 { 23 ENUMTY[TMAX][TMAX] impcnvResultTab; 24 ENUMTY[TMAX][TMAX] impcnvType1Tab; 25 ENUMTY[TMAX][TMAX] impcnvType2Tab; 26 } 27 28 enum ImpCnvTab impCnvTab = generateImpCnvTab(); 29 30 ImpCnvTab generateImpCnvTab() 31 { 32 ImpCnvTab impCnvTab; 33 34 // Set conversion tables 35 foreach (i; 0 .. cast(size_t)TMAX) 36 { 37 foreach (j; 0 .. cast(size_t)TMAX) 38 { 39 impCnvTab.impcnvResultTab[i][j] = Terror; 40 impCnvTab.impcnvType1Tab[i][j] = Terror; 41 impCnvTab.impcnvType2Tab[i][j] = Terror; 42 } 43 } 44 45 void X(ENUMTY t1, ENUMTY t2, ENUMTY nt1, ENUMTY nt2, ENUMTY rt) 46 { 47 impCnvTab.impcnvResultTab[t1][t2] = rt; 48 impCnvTab.impcnvType1Tab[t1][t2] = nt1; 49 impCnvTab.impcnvType2Tab[t1][t2] = nt2; 50 } 51 52 /* ======================= */ 53 54 X(Tbool,Tbool, Tbool,Tbool, Tbool); 55 X(Tbool,Tint8, Tint32,Tint32, Tint32); 56 X(Tbool,Tuns8, Tint32,Tint32, Tint32); 57 X(Tbool,Tint16, Tint32,Tint32, Tint32); 58 X(Tbool,Tuns16, Tint32,Tint32, Tint32); 59 X(Tbool,Tint32, Tint32,Tint32, Tint32); 60 X(Tbool,Tuns32, Tuns32,Tuns32, Tuns32); 61 X(Tbool,Tint64, Tint64,Tint64, Tint64); 62 X(Tbool,Tuns64, Tuns64,Tuns64, Tuns64); 63 X(Tbool,Tint128, Tint128,Tint128, Tint128); 64 X(Tbool,Tuns128, Tuns128,Tuns128, Tuns128); 65 66 X(Tbool,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 67 X(Tbool,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 68 X(Tbool,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 69 X(Tbool,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 70 X(Tbool,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 71 X(Tbool,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 72 X(Tbool,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 73 X(Tbool,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 74 X(Tbool,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 75 76 /* ======================= */ 77 78 X(Tint8,Tint8, Tint32,Tint32, Tint32); 79 X(Tint8,Tuns8, Tint32,Tint32, Tint32); 80 X(Tint8,Tint16, Tint32,Tint32, Tint32); 81 X(Tint8,Tuns16, Tint32,Tint32, Tint32); 82 X(Tint8,Tint32, Tint32,Tint32, Tint32); 83 X(Tint8,Tuns32, Tuns32,Tuns32, Tuns32); 84 X(Tint8,Tint64, Tint64,Tint64, Tint64); 85 X(Tint8,Tuns64, Tuns64,Tuns64, Tuns64); 86 X(Tint8,Tint128, Tint128,Tint128, Tint128); 87 X(Tint8,Tuns128, Tuns128,Tuns128, Tuns128); 88 89 X(Tint8,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 90 X(Tint8,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 91 X(Tint8,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 92 X(Tint8,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 93 X(Tint8,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 94 X(Tint8,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 95 X(Tint8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 96 X(Tint8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 97 X(Tint8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 98 99 /* ======================= */ 100 101 X(Tuns8,Tuns8, Tint32,Tint32, Tint32); 102 X(Tuns8,Tint16, Tint32,Tint32, Tint32); 103 X(Tuns8,Tuns16, Tint32,Tint32, Tint32); 104 X(Tuns8,Tint32, Tint32,Tint32, Tint32); 105 X(Tuns8,Tuns32, Tuns32,Tuns32, Tuns32); 106 X(Tuns8,Tint64, Tint64,Tint64, Tint64); 107 X(Tuns8,Tuns64, Tuns64,Tuns64, Tuns64); 108 X(Tuns8,Tint128, Tint128,Tint128, Tint128); 109 X(Tuns8,Tuns128, Tuns128,Tuns128, Tuns128); 110 111 X(Tuns8,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 112 X(Tuns8,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 113 X(Tuns8,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 114 X(Tuns8,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 115 X(Tuns8,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 116 X(Tuns8,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 117 X(Tuns8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 118 X(Tuns8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 119 X(Tuns8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 120 121 /* ======================= */ 122 123 X(Tint16,Tint16, Tint32,Tint32, Tint32); 124 X(Tint16,Tuns16, Tint32,Tint32, Tint32); 125 X(Tint16,Tint32, Tint32,Tint32, Tint32); 126 X(Tint16,Tuns32, Tuns32,Tuns32, Tuns32); 127 X(Tint16,Tint64, Tint64,Tint64, Tint64); 128 X(Tint16,Tuns64, Tuns64,Tuns64, Tuns64); 129 X(Tint16,Tint128, Tint128,Tint128, Tint128); 130 X(Tint16,Tuns128, Tuns128,Tuns128, Tuns128); 131 132 X(Tint16,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 133 X(Tint16,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 134 X(Tint16,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 135 X(Tint16,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 136 X(Tint16,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 137 X(Tint16,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 138 X(Tint16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 139 X(Tint16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 140 X(Tint16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 141 142 /* ======================= */ 143 144 X(Tuns16,Tuns16, Tint32,Tint32, Tint32); 145 X(Tuns16,Tint32, Tint32,Tint32, Tint32); 146 X(Tuns16,Tuns32, Tuns32,Tuns32, Tuns32); 147 X(Tuns16,Tint64, Tint64,Tint64, Tint64); 148 X(Tuns16,Tuns64, Tuns64,Tuns64, Tuns64); 149 X(Tuns16,Tint128, Tint128,Tint128, Tint128); 150 X(Tuns16,Tuns128, Tuns128,Tuns128, Tuns128); 151 152 X(Tuns16,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 153 X(Tuns16,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 154 X(Tuns16,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 155 X(Tuns16,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 156 X(Tuns16,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 157 X(Tuns16,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 158 X(Tuns16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 159 X(Tuns16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 160 X(Tuns16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 161 162 /* ======================= */ 163 164 X(Tint32,Tint32, Tint32,Tint32, Tint32); 165 X(Tint32,Tuns32, Tuns32,Tuns32, Tuns32); 166 X(Tint32,Tint64, Tint64,Tint64, Tint64); 167 X(Tint32,Tuns64, Tuns64,Tuns64, Tuns64); 168 X(Tint32,Tint128, Tint128,Tint128, Tint128); 169 X(Tint32,Tuns128, Tuns128,Tuns128, Tuns128); 170 171 X(Tint32,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 172 X(Tint32,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 173 X(Tint32,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 174 X(Tint32,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 175 X(Tint32,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 176 X(Tint32,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 177 X(Tint32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 178 X(Tint32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 179 X(Tint32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 180 181 /* ======================= */ 182 183 X(Tuns32,Tuns32, Tuns32,Tuns32, Tuns32); 184 X(Tuns32,Tint64, Tint64,Tint64, Tint64); 185 X(Tuns32,Tuns64, Tuns64,Tuns64, Tuns64); 186 X(Tuns32,Tint128, Tint128,Tint128, Tint128); 187 X(Tuns32,Tuns128, Tuns128,Tuns128, Tuns128); 188 189 X(Tuns32,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 190 X(Tuns32,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 191 X(Tuns32,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 192 X(Tuns32,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 193 X(Tuns32,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 194 X(Tuns32,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 195 X(Tuns32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 196 X(Tuns32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 197 X(Tuns32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 198 199 /* ======================= */ 200 201 X(Tint64,Tint64, Tint64,Tint64, Tint64); 202 X(Tint64,Tuns64, Tuns64,Tuns64, Tuns64); 203 X(Tint64,Tint128, Tint128,Tint128, Tint128); 204 X(Tint64,Tuns128, Tuns128,Tuns128, Tuns128); 205 206 X(Tint64,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 207 X(Tint64,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 208 X(Tint64,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 209 X(Tint64,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 210 X(Tint64,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 211 X(Tint64,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 212 X(Tint64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 213 X(Tint64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 214 X(Tint64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 215 216 /* ======================= */ 217 218 X(Tuns64,Tuns64, Tuns64,Tuns64, Tuns64); 219 X(Tuns64,Tint128, Tint128,Tint128, Tint128); 220 X(Tuns64,Tuns128, Tuns128,Tuns128, Tuns128); 221 222 X(Tuns64,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 223 X(Tuns64,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 224 X(Tuns64,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 225 X(Tuns64,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 226 X(Tuns64,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 227 X(Tuns64,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 228 X(Tuns64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 229 X(Tuns64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 230 X(Tuns64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 231 232 /* ======================= */ 233 234 X(Tint128,Tint128, Tint128,Tint128, Tint128); 235 X(Tint128,Tuns128, Tuns128,Tuns128, Tuns128); 236 237 X(Tint128,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 238 X(Tint128,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 239 X(Tint128,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 240 X(Tint128,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 241 X(Tint128,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 242 X(Tint128,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 243 X(Tint128,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 244 X(Tint128,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 245 X(Tint128,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 246 247 /* ======================= */ 248 249 X(Tuns128,Tuns128, Tuns128,Tuns128, Tuns128); 250 251 X(Tuns128,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 252 X(Tuns128,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 253 X(Tuns128,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 254 X(Tuns128,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 255 X(Tuns128,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 256 X(Tuns128,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 257 X(Tuns128,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 258 X(Tuns128,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 259 X(Tuns128,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 260 261 /* ======================= */ 262 263 X(Tfloat32,Tfloat32, Tfloat32,Tfloat32, Tfloat32); 264 X(Tfloat32,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 265 X(Tfloat32,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 266 267 X(Tfloat32,Timaginary32, Tfloat32,Timaginary32, Tfloat32); 268 X(Tfloat32,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 269 X(Tfloat32,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 270 271 X(Tfloat32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32); 272 X(Tfloat32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 273 X(Tfloat32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 274 275 /* ======================= */ 276 277 X(Tfloat64,Tfloat64, Tfloat64,Tfloat64, Tfloat64); 278 X(Tfloat64,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 279 280 X(Tfloat64,Timaginary32, Tfloat64,Timaginary64, Tfloat64); 281 X(Tfloat64,Timaginary64, Tfloat64,Timaginary64, Tfloat64); 282 X(Tfloat64,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 283 284 X(Tfloat64,Tcomplex32, Tfloat64,Tcomplex64, Tcomplex64); 285 X(Tfloat64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64); 286 X(Tfloat64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 287 288 /* ======================= */ 289 290 X(Tfloat80,Tfloat80, Tfloat80,Tfloat80, Tfloat80); 291 292 X(Tfloat80,Timaginary32, Tfloat80,Timaginary80, Tfloat80); 293 X(Tfloat80,Timaginary64, Tfloat80,Timaginary80, Tfloat80); 294 X(Tfloat80,Timaginary80, Tfloat80,Timaginary80, Tfloat80); 295 296 X(Tfloat80,Tcomplex32, Tfloat80,Tcomplex80, Tcomplex80); 297 X(Tfloat80,Tcomplex64, Tfloat80,Tcomplex80, Tcomplex80); 298 X(Tfloat80,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80); 299 300 /* ======================= */ 301 302 X(Timaginary32,Timaginary32, Timaginary32,Timaginary32, Timaginary32); 303 X(Timaginary32,Timaginary64, Timaginary64,Timaginary64, Timaginary64); 304 X(Timaginary32,Timaginary80, Timaginary80,Timaginary80, Timaginary80); 305 306 X(Timaginary32,Tcomplex32, Timaginary32,Tcomplex32, Tcomplex32); 307 X(Timaginary32,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64); 308 X(Timaginary32,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80); 309 310 /* ======================= */ 311 312 X(Timaginary64,Timaginary64, Timaginary64,Timaginary64, Timaginary64); 313 X(Timaginary64,Timaginary80, Timaginary80,Timaginary80, Timaginary80); 314 315 X(Timaginary64,Tcomplex32, Timaginary64,Tcomplex64, Tcomplex64); 316 X(Timaginary64,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64); 317 X(Timaginary64,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80); 318 319 /* ======================= */ 320 321 X(Timaginary80,Timaginary80, Timaginary80,Timaginary80, Timaginary80); 322 323 X(Timaginary80,Tcomplex32, Timaginary80,Tcomplex80, Tcomplex80); 324 X(Timaginary80,Tcomplex64, Timaginary80,Tcomplex80, Tcomplex80); 325 X(Timaginary80,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80); 326 327 /* ======================= */ 328 329 X(Tcomplex32,Tcomplex32, Tcomplex32,Tcomplex32, Tcomplex32); 330 X(Tcomplex32,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64); 331 X(Tcomplex32,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80); 332 333 /* ======================= */ 334 335 X(Tcomplex64,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64); 336 X(Tcomplex64,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80); 337 338 /* ======================= */ 339 340 X(Tcomplex80,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80); 341 342 foreach (i; 0 .. cast(size_t)TMAX) 343 { 344 foreach (j; 0 .. cast(size_t)TMAX) 345 { 346 if (impCnvTab.impcnvResultTab[i][j] == Terror) 347 { 348 impCnvTab.impcnvResultTab[i][j] = impCnvTab.impcnvResultTab[j][i]; 349 impCnvTab.impcnvType1Tab[i][j] = impCnvTab.impcnvType2Tab[j][i]; 350 impCnvTab.impcnvType2Tab[i][j] = impCnvTab.impcnvType1Tab[j][i]; 351 } 352 } 353 } 354 355 return impCnvTab; 356 }