1 /** 2 * Compiler implementation of the 3 * $(LINK2 http://www.dlang.org, D programming language). 4 * 5 * Copyright: Copyright (C) 1985-1998 by Symantec 6 * Copyright (C) 2000-2020 by The D Language Foundation, All Rights Reserved 7 * Authors: $(LINK2 http://www.digitalmars.com, Walter Bright) 8 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 9 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/var.d, backend/var.d) 10 */ 11 12 module dmd.backend.var; 13 14 /* Global variables for PARSER */ 15 16 import core.stdc.stdio; 17 18 import dmd.backend.cc; 19 import dmd.backend.cdef; 20 import dmd.backend.code; 21 import dmd.backend.dlist; 22 import dmd.backend.goh; 23 import dmd.backend.obj; 24 import dmd.backend.oper; 25 import dmd.backend.ty; 26 import dmd.backend.type; 27 28 version (SPP) 29 { 30 import parser; 31 import phstring; 32 } 33 version (SCPP) 34 { 35 import parser; 36 import phstring; 37 } 38 version (HTOD) 39 { 40 import parser; 41 import phstring; 42 } 43 44 extern (C++): 45 46 nothrow: 47 48 __gshared: 49 50 /* Global flags: 51 */ 52 53 char PARSER = 0; // indicate we're in the parser 54 char OPTIMIZER = 0; // indicate we're in the optimizer 55 int structalign; /* alignment for members of structures */ 56 char dbcs = 0; // current double byte character set 57 58 int TYptrdiff = TYint; 59 int TYsize = TYuint; 60 int TYsize_t = TYuint; 61 int TYaarray = TYnptr; 62 int TYdelegate = TYllong; 63 int TYdarray = TYullong; 64 65 char debuga=0,debugb=0,debugc=0,debugd=0,debuge=0,debugf=0,debugr=0,debugs=0,debugt=0,debugu=0,debugw=0,debugx=0,debugy=0; 66 67 version (MARS) { } else 68 { 69 linkage_t linkage; 70 int linkage_spec = 0; /* using the default */ 71 72 /* Function types */ 73 /* LINK_MAXDIM = C,C++,Pascal,FORTRAN,syscall,stdcall,Mars */ 74 static if (MEMMODELS == 1) 75 { 76 tym_t[LINK_MAXDIM] functypetab = 77 [ 78 TYnfunc, 79 TYnpfunc, 80 TYnpfunc, 81 TYnfunc, 82 ]; 83 } 84 else 85 { 86 tym_t[MEMMODELS][LINK_MAXDIM] functypetab = 87 [ 88 [ TYnfunc, TYffunc, TYnfunc, TYffunc, TYffunc ], 89 [ TYnfunc, TYffunc, TYnfunc, TYffunc, TYffunc ], 90 [ TYnpfunc, TYfpfunc, TYnpfunc, TYfpfunc, TYfpfunc ], 91 [ TYnpfunc, TYfpfunc, TYnpfunc, TYfpfunc, TYfpfunc ], 92 [ TYnfunc, TYffunc, TYnfunc, TYffunc, TYffunc ], 93 [ TYnsfunc, TYfsfunc, TYnsfunc, TYfsfunc, TYfsfunc ], 94 [ TYjfunc, TYfpfunc, TYnpfunc, TYfpfunc, TYfpfunc ], 95 ]; 96 } 97 98 /* Function mangling */ 99 /* LINK_MAXDIM = C,C++,Pascal,FORTRAN,syscall,stdcall */ 100 mangle_t[LINK_MAXDIM] funcmangletab = 101 [ 102 mTYman_c, 103 mTYman_cpp, 104 mTYman_pas, 105 mTYman_for, 106 mTYman_sys, 107 mTYman_std, 108 mTYman_d, 109 ]; 110 111 /* Name mangling for global variables */ 112 mangle_t[LINK_MAXDIM] varmangletab = 113 [ 114 mTYman_c, 115 mTYman_cpp, 116 mTYman_pas,mTYman_for,mTYman_sys,mTYman_std,mTYman_d 117 ]; 118 } 119 120 /* File variables: */ 121 122 char *argv0; // argv[0] (program name) 123 extern (C) 124 { 125 FILE *fdep = null; // dependency file stream pointer 126 FILE *flst = null; // list file stream pointer 127 FILE *fin = null; // input file 128 version (SPP) 129 { 130 FILE *fout; 131 } 132 } 133 134 // htod 135 char *fdmodulename = null; 136 extern (C) FILE *fdmodule = null; 137 138 char* foutdir = null, // directory to place output files in 139 finname = null, 140 foutname = null, 141 fsymname = null, 142 fphreadname = null, 143 ftdbname = null, 144 fdepname = null, 145 flstname = null; /* the filename strings */ 146 147 version (SPP) 148 { 149 phstring_t fdeplist; 150 phstring_t pathlist; // include paths 151 } 152 version (SCPP) 153 { 154 phstring_t fdeplist; 155 phstring_t pathlist; // include paths 156 } 157 version (HTOD) 158 { 159 phstring_t fdeplist; 160 phstring_t pathlist; // include paths 161 } 162 163 int pathsysi; // -isystem= index 164 list_t headers; /* pre-include files */ 165 166 /* Data from lexical analyzer: */ 167 168 uint idhash = 0; // hash value of identifier 169 int xc = ' '; // character last read 170 171 /* Data for pragma processor: 172 */ 173 174 int colnumber = 0; /* current column number */ 175 176 /* Other variables: */ 177 178 int level = 0; /* declaration level */ 179 /* 0: top level */ 180 /* 1: function parameter declarations */ 181 /* 2: function local declarations */ 182 /* 3+: compound statement decls */ 183 184 param_t *paramlst = null; /* function parameter list */ 185 tym_t pointertype = TYnptr; /* default data pointer type */ 186 187 /************************ 188 * Bit masks 189 */ 190 191 const uint[32] mask = 192 [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,0x8000, 193 0x10000,0x20000,0x40000,0x80000,0x100000,0x200000,0x400000,0x800000, 194 0x1000000,0x2000000,0x4000000,0x8000000, 195 0x10000000,0x20000000,0x40000000,0x80000000]; 196 197 static if (0) 198 { 199 const uint[32] maskl = 200 [1,2,4,8,0x10,0x20,0x40,0x80, 201 0x100,0x200,0x400,0x800,0x1000,0x2000,0x4000,0x8000, 202 0x10000,0x20000,0x40000,0x80000,0x100000,0x200000,0x400000,0x800000, 203 0x1000000,0x2000000,0x4000000,0x8000000, 204 0x10000000,0x20000000,0x40000000,0x80000000]; 205 } 206 207 208 /* From util.c */ 209 210 /***************************** 211 * SCxxxx types. 212 */ 213 214 version (SPP) { } else 215 { 216 217 char[SCMAX] sytab = 218 [ 219 /* unde */ SCEXP|SCKEP|SCSCT, /* undefined */ 220 /* auto */ SCEXP|SCSS|SCRD , /* automatic (stack) */ 221 /* static */ SCEXP|SCKEP|SCSCT, /* statically allocated */ 222 /* thread */ SCEXP|SCKEP , /* thread local */ 223 /* extern */ SCEXP|SCKEP|SCSCT, /* external */ 224 /* register */ SCEXP|SCSS|SCRD , /* registered variable */ 225 /* pseudo */ SCEXP , /* pseudo register variable */ 226 /* global */ SCEXP|SCKEP|SCSCT, /* top level global definition */ 227 /* comdat */ SCEXP|SCKEP|SCSCT, /* initialized common block */ 228 /* parameter */SCEXP|SCSS , /* function parameter */ 229 /* regpar */ SCEXP|SCSS , /* function register parameter */ 230 /* fastpar */ SCEXP|SCSS , /* function parameter passed in register */ 231 /* shadowreg */SCEXP|SCSS , /* function parameter passed in register, shadowed on stack */ 232 /* typedef */ 0 , /* type definition */ 233 /* explicit */ 0 , /* explicit */ 234 /* mutable */ 0 , /* mutable */ 235 /* label */ 0 , /* goto label */ 236 /* struct */ SCKEP , /* struct/class/union tag name */ 237 /* enum */ 0 , /* enum tag name */ 238 /* field */ SCEXP|SCKEP , /* bit field of struct or union */ 239 /* const */ SCEXP|SCSCT , /* constant integer */ 240 /* member */ SCEXP|SCKEP|SCSCT, /* member of struct or union */ 241 /* anon */ 0 , /* member of anonymous union */ 242 /* inline */ SCEXP|SCKEP , /* for inline functions */ 243 /* sinline */ SCEXP|SCKEP , /* for static inline functions */ 244 /* einline */ SCEXP|SCKEP , /* for extern inline functions */ 245 /* overload */ SCEXP , /* for overloaded function names */ 246 /* friend */ 0 , /* friend of a class */ 247 /* virtual */ 0 , /* virtual function */ 248 /* locstat */ SCEXP|SCSCT , /* static, but local to a function */ 249 /* template */ 0 , /* class template */ 250 /* functempl */0 , /* function template */ 251 /* ftexpspec */0 , /* function template explicit specialization */ 252 /* linkage */ 0 , /* function linkage symbol */ 253 /* public */ SCEXP|SCKEP|SCSCT, /* generate a pubdef for this */ 254 /* comdef */ SCEXP|SCKEP|SCSCT, /* uninitialized common block */ 255 /* bprel */ SCEXP|SCSS , /* variable at fixed offset from frame pointer */ 256 /* namespace */0 , /* namespace */ 257 /* alias */ 0 , /* alias to another symbol */ 258 /* funcalias */0 , /* alias to another function symbol */ 259 /* memalias */ 0 , /* alias to base class member */ 260 /* stack */ SCEXP|SCSS , /* offset from stack pointer (not frame pointer) */ 261 /* adl */ 0 , /* list of ADL symbols for overloading */ 262 ]; 263 264 } 265 266 extern (C) int controlc_saw = 0; /* a control C was seen */ 267 symtab_t globsym; /* global symbol table */ 268 Pstate pstate; // parser state 269 Cstate cstate; // compiler state 270 271 uint 272 maxblks = 0, /* array max for all block stuff */ 273 /* dfoblks <= numblks <= maxblks */ 274 numcse; /* number of common subexpressions */ 275 276 GlobalOptimizer go; 277 278 /* From debug.c */ 279 const(char)*[32] regstring = ["AX","CX","DX","BX","SP","BP","SI","DI", 280 "R8","R9","R10","R11","R12","R13","R14","R15", 281 "XMM0","XMM1","XMM2","XMM3","XMM4","XMM5","XMM6","XMM7", 282 "ES","PSW","STACK","ST0","ST01","NOREG","RMload","RMstore"]; 283 284 /* From nwc.c */ 285 286 type *chartype; /* default 'char' type */ 287 288 Obj objmod = null; 289 290 __gshared uint[256] tytab = 291 () { 292 uint[256] tab; 293 foreach (i; TXptr) { tab[i] |= TYFLptr; } 294 foreach (i; TXptr_nflat) { tab[i] |= TYFLptr; } 295 foreach (i; TXreal) { tab[i] |= TYFLreal; } 296 foreach (i; TXintegral) { tab[i] |= TYFLintegral; } 297 foreach (i; TXimaginary) { tab[i] |= TYFLimaginary; } 298 foreach (i; TXcomplex) { tab[i] |= TYFLcomplex; } 299 foreach (i; TXuns) { tab[i] |= TYFLuns; } 300 foreach (i; TXmptr) { tab[i] |= TYFLmptr; } 301 foreach (i; TXfv) { tab[i] |= TYFLfv; } 302 foreach (i; TXfarfunc) { tab[i] |= TYFLfarfunc; } 303 foreach (i; TXpasfunc) { tab[i] |= TYFLpascal; } 304 foreach (i; TXrevfunc) { tab[i] |= TYFLrevparam; } 305 foreach (i; TXshort) { tab[i] |= TYFLshort; } 306 foreach (i; TXaggregate) { tab[i] |= TYFLaggregate; } 307 foreach (i; TXref) { tab[i] |= TYFLref; } 308 foreach (i; TXfunc) { tab[i] |= TYFLfunc; } 309 foreach (i; TXnullptr) { tab[i] |= TYFLnullptr; } 310 foreach (i; TXpasfunc_nf) { tab[i] |= TYFLpascal; } 311 foreach (i; TXrevfunc_nf) { tab[i] |= TYFLrevparam; } 312 foreach (i; TXref_nflat) { tab[i] |= TYFLref; } 313 foreach (i; TXfunc_nflat) { tab[i] |= TYFLfunc; } 314 foreach (i; TXxmmreg) { tab[i] |= TYFLxmmreg; } 315 foreach (i; TXsimd) { tab[i] |= TYFLsimd; } 316 return tab; 317 } (); 318 319 320 extern (C) __gshared const(char)*[TYMAX] tystring = 321 [ 322 TYbool : "bool", 323 TYchar : "char", 324 TYschar : "signed char", 325 TYuchar : "unsigned char", 326 TYchar8 : "char8_t", 327 TYchar16 : "char16_t", 328 TYshort : "short", 329 TYwchar_t : "wchar_t", 330 TYushort : "unsigned short", 331 332 TYenum : "enum", 333 TYint : "int", 334 TYuint : "unsigned", 335 336 TYlong : "long", 337 TYulong : "unsigned long", 338 TYdchar : "dchar", 339 TYllong : "long long", 340 TYullong : "uns long long", 341 TYcent : "cent", 342 TYucent : "ucent", 343 TYfloat : "float", 344 TYdouble : "double", 345 TYdouble_alias : "double alias", 346 TYldouble : "long double", 347 348 TYifloat : "imaginary float", 349 TYidouble : "imaginary double", 350 TYildouble : "imaginary long double", 351 352 TYcfloat : "complex float", 353 TYcdouble : "complex double", 354 TYcldouble : "complex long double", 355 356 TYfloat4 : "float[4]", 357 TYdouble2 : "double[2]", 358 TYschar16 : "signed char[16]", 359 TYuchar16 : "unsigned char[16]", 360 TYshort8 : "short[8]", 361 TYushort8 : "unsigned short[8]", 362 TYlong4 : "long[4]", 363 TYulong4 : "unsigned long[4]", 364 TYllong2 : "long long[2]", 365 TYullong2 : "unsigned long long[2]", 366 367 TYfloat8 : "float[8]", 368 TYdouble4 : "double[4]", 369 TYschar32 : "signed char[32]", 370 TYuchar32 : "unsigned char[32]", 371 TYshort16 : "short[16]", 372 TYushort16 : "unsigned short[16]", 373 TYlong8 : "long[8]", 374 TYulong8 : "unsigned long[8]", 375 TYllong4 : "long long[4]", 376 TYullong4 : "unsigned long long[4]", 377 378 TYfloat16 : "float[16]", 379 TYdouble8 : "double[8]", 380 TYschar64 : "signed char[64]", 381 TYuchar64 : "unsigned char[64]", 382 TYshort32 : "short[32]", 383 TYushort32 : "unsigned short[32]", 384 TYlong16 : "long[16]", 385 TYulong16 : "unsigned long[16]", 386 TYllong8 : "long long[8]", 387 TYullong8 : "unsigned long long[8]", 388 389 TYnullptr : "nullptr_t", 390 TYnptr : "*", 391 TYref : "&", 392 TYvoid : "void", 393 TYstruct : "struct", 394 TYarray : "array", 395 TYnfunc : "C func", 396 TYnpfunc : "Pascal func", 397 TYnsfunc : "std func", 398 TYptr : "*", 399 TYmfunc : "member func", 400 TYjfunc : "D func", 401 TYhfunc : "C func", 402 TYnref : "__near &", 403 404 TYsptr : "__ss *", 405 TYcptr : "__cs *", 406 TYf16ptr : "__far16 *", 407 TYfptr : "__far *", 408 TYhptr : "__huge *", 409 TYvptr : "__handle *", 410 TYimmutPtr : "__immutable *", 411 TYsharePtr : "__shared *", 412 TYrestrictPtr : "__restrict *", 413 TYfgPtr : "__fg *", 414 TYffunc : "far C func", 415 TYfpfunc : "far Pascal func", 416 TYfsfunc : "far std func", 417 TYf16func : "_far16 Pascal func", 418 TYnsysfunc : "sys func", 419 TYfsysfunc : "far sys func", 420 TYfref : "__far &", 421 422 TYifunc : "interrupt func", 423 TYmemptr : "memptr", 424 TYident : "ident", 425 TYtemplate : "template", 426 TYvtshape : "vtshape", 427 ]; 428 429 /// Map to unsigned version of type 430 __gshared tym_t[256] tytouns = 431 () { 432 tym_t[256] tab; 433 foreach (ty; 0 .. TYMAX) 434 { 435 tym_t tym; 436 switch (ty) 437 { 438 case TYchar: tym = TYuchar; break; 439 case TYschar: tym = TYuchar; break; 440 case TYshort: tym = TYushort; break; 441 case TYushort: tym = TYushort; break; 442 443 case TYenum: tym = TYuint; break; 444 case TYint: tym = TYuint; break; 445 446 case TYlong: tym = TYulong; break; 447 case TYllong: tym = TYullong; break; 448 case TYcent: tym = TYucent; break; 449 450 case TYschar16: tym = TYuchar16; break; 451 case TYshort8: tym = TYushort8; break; 452 case TYlong4: tym = TYulong4; break; 453 case TYllong2: tym = TYullong2; break; 454 455 case TYschar32: tym = TYuchar32; break; 456 case TYshort16: tym = TYushort16; break; 457 case TYlong8: tym = TYulong8; break; 458 case TYllong4: tym = TYullong4; break; 459 460 case TYschar64: tym = TYuchar64; break; 461 case TYshort32: tym = TYushort32; break; 462 case TYlong16: tym = TYulong16; break; 463 case TYllong8: tym = TYullong8; break; 464 465 default: tym = ty; break; 466 } 467 tab[ty] = tym; 468 } 469 return tab; 470 } (); 471 472 /// Map to relaxed version of type 473 __gshared ubyte[TYMAX] _tyrelax = 474 () { 475 ubyte[TYMAX] tab; 476 foreach (ty; 0 .. TYMAX) 477 { 478 tym_t tym; 479 switch (ty) 480 { 481 case TYbool: tym = TYchar; break; 482 case TYschar: tym = TYchar; break; 483 case TYuchar: tym = TYchar; break; 484 case TYchar8: tym = TYchar; break; 485 case TYchar16: tym = TYint; break; 486 487 case TYshort: tym = TYint; break; 488 case TYushort: tym = TYint; break; 489 case TYwchar_t: tym = TYint; break; 490 491 case TYenum: tym = TYint; break; 492 case TYuint: tym = TYint; break; 493 494 case TYulong: tym = TYlong; break; 495 case TYdchar: tym = TYlong; break; 496 case TYullong: tym = TYllong; break; 497 case TYucent: tym = TYcent; break; 498 499 case TYnullptr: tym = TYptr; break; 500 501 default: tym = ty; break; 502 } 503 tab[ty] = cast(ubyte)tym; 504 } 505 return tab; 506 } (); 507 508 /// Map to equivalent version of type 509 __gshared ubyte[TYMAX] tyequiv = 510 () { 511 ubyte[TYMAX] tab; 512 foreach (ty; 0 .. TYMAX) 513 { 514 tym_t tym; 515 switch (ty) 516 { 517 case TYchar: tym = TYschar; break; // chars are signed by default 518 case TYint: tym = TYshort; break; // adjusted in util_set32() 519 case TYuint: tym = TYushort; break; // adjusted in util_set32() 520 521 default: tym = ty; break; 522 } 523 tab[ty] = cast(ubyte)tym; 524 } 525 return tab; 526 } (); 527 528 /// Map to Codeview 1 type in debugger record 529 __gshared ubyte[TYMAX] dttab = 530 [ 531 TYbool : 0x80, 532 TYchar : 0x80, 533 TYschar : 0x80, 534 TYuchar : 0x84, 535 TYchar8 : 0x84, 536 TYchar16 : 0x85, 537 TYshort : 0x81, 538 TYwchar_t : 0x85, 539 TYushort : 0x85, 540 541 TYenum : 0x81, 542 TYint : 0x85, 543 TYuint : 0x85, 544 545 TYlong : 0x82, 546 TYulong : 0x86, 547 TYdchar : 0x86, 548 TYllong : 0x82, 549 TYullong : 0x86, 550 TYcent : 0x82, 551 TYucent : 0x86, 552 TYfloat : 0x88, 553 TYdouble : 0x89, 554 TYdouble_alias : 0x89, 555 TYldouble : 0x89, 556 557 TYifloat : 0x88, 558 TYidouble : 0x89, 559 TYildouble : 0x89, 560 561 TYcfloat : 0x88, 562 TYcdouble : 0x89, 563 TYcldouble : 0x89, 564 565 TYfloat4 : 0x00, 566 TYdouble2 : 0x00, 567 TYschar16 : 0x00, 568 TYuchar16 : 0x00, 569 TYshort8 : 0x00, 570 TYushort8 : 0x00, 571 TYlong4 : 0x00, 572 TYulong4 : 0x00, 573 TYllong2 : 0x00, 574 TYullong2 : 0x00, 575 576 TYfloat8 : 0x00, 577 TYdouble4 : 0x00, 578 TYschar32 : 0x00, 579 TYuchar32 : 0x00, 580 TYshort16 : 0x00, 581 TYushort16 : 0x00, 582 TYlong8 : 0x00, 583 TYulong8 : 0x00, 584 TYllong4 : 0x00, 585 TYullong4 : 0x00, 586 587 TYfloat16 : 0x00, 588 TYdouble8 : 0x00, 589 TYschar64 : 0x00, 590 TYuchar64 : 0x00, 591 TYshort32 : 0x00, 592 TYushort32 : 0x00, 593 TYlong16 : 0x00, 594 TYulong16 : 0x00, 595 TYllong8 : 0x00, 596 TYullong8 : 0x00, 597 598 TYnullptr : 0x20, 599 TYnptr : 0x20, 600 TYref : 0x00, 601 TYvoid : 0x85, 602 TYstruct : 0x00, 603 TYarray : 0x78, 604 TYnfunc : 0x63, 605 TYnpfunc : 0x74, 606 TYnsfunc : 0x63, 607 TYptr : 0x20, 608 TYmfunc : 0x64, 609 TYjfunc : 0x74, 610 TYhfunc : 0x00, 611 TYnref : 0x00, 612 613 TYsptr : 0x20, 614 TYcptr : 0x20, 615 TYf16ptr : 0x40, 616 TYfptr : 0x40, 617 TYhptr : 0x40, 618 TYvptr : 0x40, 619 TYimmutPtr : 0x20, 620 TYsharePtr : 0x20, 621 TYrestrictPtr : 0x20, 622 TYfgPtr : 0x20, 623 TYffunc : 0x64, 624 TYfpfunc : 0x73, 625 TYfsfunc : 0x64, 626 TYf16func : 0x63, 627 TYnsysfunc : 0x63, 628 TYfsysfunc : 0x64, 629 TYfref : 0x00, 630 631 TYifunc : 0x64, 632 TYmemptr : 0x00, 633 TYident : 0x00, 634 TYtemplate : 0x00, 635 TYvtshape : 0x00, 636 ]; 637 638 /// Map to Codeview 4 type in debugger record 639 __gshared ushort[TYMAX] dttab4 = 640 [ 641 TYbool : 0x30, 642 TYchar : 0x70, 643 TYschar : 0x10, 644 TYuchar : 0x20, 645 TYchar8 : 0x20, 646 TYchar16 : 0x21, 647 TYshort : 0x11, 648 TYwchar_t : 0x71, 649 TYushort : 0x21, 650 651 TYenum : 0x72, 652 TYint : 0x72, 653 TYuint : 0x73, 654 655 TYlong : 0x12, 656 TYulong : 0x22, 657 TYdchar : 0x7b, // UTF32 658 TYllong : 0x13, 659 TYullong : 0x23, 660 TYcent : 0x603, 661 TYucent : 0x603, 662 TYfloat : 0x40, 663 TYdouble : 0x41, 664 TYdouble_alias : 0x41, 665 TYldouble : 0x42, 666 667 TYifloat : 0x40, 668 TYidouble : 0x41, 669 TYildouble : 0x42, 670 671 TYcfloat : 0x50, 672 TYcdouble : 0x51, 673 TYcldouble : 0x52, 674 675 TYfloat4 : 0x00, 676 TYdouble2 : 0x00, 677 TYschar16 : 0x00, 678 TYuchar16 : 0x00, 679 TYshort8 : 0x00, 680 TYushort8 : 0x00, 681 TYlong4 : 0x00, 682 TYulong4 : 0x00, 683 TYllong2 : 0x00, 684 TYullong2 : 0x00, 685 686 TYfloat8 : 0x00, 687 TYdouble4 : 0x00, 688 TYschar32 : 0x00, 689 TYuchar32 : 0x00, 690 TYshort16 : 0x00, 691 TYushort16 : 0x00, 692 TYlong8 : 0x00, 693 TYulong8 : 0x00, 694 TYllong4 : 0x00, 695 TYullong4 : 0x00, 696 697 TYfloat16 : 0x00, 698 TYdouble8 : 0x00, 699 TYschar64 : 0x00, 700 TYuchar64 : 0x00, 701 TYshort32 : 0x00, 702 TYushort32 : 0x00, 703 TYlong16 : 0x00, 704 TYulong16 : 0x00, 705 TYllong8 : 0x00, 706 TYullong8 : 0x00, 707 708 TYnullptr : 0x100, 709 TYnptr : 0x100, 710 TYref : 0x00, 711 TYvoid : 0x03, 712 TYstruct : 0x00, 713 TYarray : 0x00, 714 TYnfunc : 0x00, 715 TYnpfunc : 0x00, 716 TYnsfunc : 0x00, 717 TYptr : 0x100, 718 TYmfunc : 0x00, 719 TYjfunc : 0x00, 720 TYhfunc : 0x00, 721 TYnref : 0x00, 722 723 TYsptr : 0x100, 724 TYcptr : 0x100, 725 TYf16ptr : 0x200, 726 TYfptr : 0x200, 727 TYhptr : 0x300, 728 TYvptr : 0x200, 729 TYimmutPtr : 0x100, 730 TYsharePtr : 0x100, 731 TYrestrictPtr : 0x100, 732 TYfgPtr : 0x100, 733 TYffunc : 0x00, 734 TYfpfunc : 0x00, 735 TYfsfunc : 0x00, 736 TYf16func : 0x00, 737 TYnsysfunc : 0x00, 738 TYfsysfunc : 0x00, 739 TYfref : 0x00, 740 741 TYifunc : 0x00, 742 TYmemptr : 0x00, 743 TYident : 0x00, 744 TYtemplate : 0x00, 745 TYvtshape : 0x00, 746 ]; 747 748 /// Size of a type 749 __gshared byte[256] _tysize = 750 [ 751 TYbool : 1, 752 TYchar : 1, 753 TYschar : 1, 754 TYuchar : 1, 755 TYchar8 : 1, 756 TYchar16 : 2, 757 TYshort : SHORTSIZE, 758 TYwchar_t : 2, 759 TYushort : SHORTSIZE, 760 761 TYenum : -1, 762 TYint : 2, 763 TYuint : 2, 764 765 TYlong : LONGSIZE, 766 TYulong : LONGSIZE, 767 TYdchar : 4, 768 TYllong : LLONGSIZE, 769 TYullong : LLONGSIZE, 770 TYcent : 16, 771 TYucent : 16, 772 TYfloat : FLOATSIZE, 773 TYdouble : DOUBLESIZE, 774 TYdouble_alias : 8, 775 TYldouble : -1, 776 777 TYifloat : FLOATSIZE, 778 TYidouble : DOUBLESIZE, 779 TYildouble : -1, 780 781 TYcfloat : 2*FLOATSIZE, 782 TYcdouble : 2*DOUBLESIZE, 783 TYcldouble : -1, 784 785 TYfloat4 : 16, 786 TYdouble2 : 16, 787 TYschar16 : 16, 788 TYuchar16 : 16, 789 TYshort8 : 16, 790 TYushort8 : 16, 791 TYlong4 : 16, 792 TYulong4 : 16, 793 TYllong2 : 16, 794 TYullong2 : 16, 795 796 TYfloat8 : 32, 797 TYdouble4 : 32, 798 TYschar32 : 32, 799 TYuchar32 : 32, 800 TYshort16 : 32, 801 TYushort16 : 32, 802 TYlong8 : 32, 803 TYulong8 : 32, 804 TYllong4 : 32, 805 TYullong4 : 32, 806 807 TYfloat16 : 64, 808 TYdouble8 : 64, 809 TYschar64 : 64, 810 TYuchar64 : 64, 811 TYshort32 : 64, 812 TYushort32 : 64, 813 TYlong16 : 64, 814 TYulong16 : 64, 815 TYllong8 : 64, 816 TYullong8 : 64, 817 818 TYnullptr : 2, 819 TYnptr : 2, 820 TYref : -1, 821 TYvoid : -1, 822 TYstruct : -1, 823 TYarray : -1, 824 TYnfunc : -1, 825 TYnpfunc : -1, 826 TYnsfunc : -1, 827 TYptr : 2, 828 TYmfunc : -1, 829 TYjfunc : -1, 830 TYhfunc : -1, 831 TYnref : 2, 832 833 TYsptr : 2, 834 TYcptr : 2, 835 TYf16ptr : 4, 836 TYfptr : 4, 837 TYhptr : 4, 838 TYvptr : 4, 839 TYimmutPtr : 2, 840 TYsharePtr : 2, 841 TYrestrictPtr : 2, 842 TYfgPtr : 2, 843 TYffunc : -1, 844 TYfpfunc : -1, 845 TYfsfunc : -1, 846 TYf16func : -1, 847 TYnsysfunc : -1, 848 TYfsysfunc : -1, 849 TYfref : 4, 850 851 TYifunc : -1, 852 TYmemptr : -1, 853 TYident : -1, 854 TYtemplate : -1, 855 TYvtshape : -1, 856 ]; 857 858 // Alignment of long doubles varies by target 859 static if (TARGET_OSX) 860 enum LDOUBLE_ALIGN = 16; 861 else static if (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS) 862 enum LDOUBLE_ALIGN = 4; 863 else static if (TARGET_WINDOS) 864 enum LDOUBLE_ALIGN = 2; 865 else 866 static assert(0, "fix this"); 867 868 869 /// Size of a type to use for alignment 870 __gshared byte[256] _tyalignsize = 871 [ 872 TYbool : 1, 873 TYchar : 1, 874 TYschar : 1, 875 TYuchar : 1, 876 TYchar8 : 1, 877 TYchar16 : 2, 878 TYshort : SHORTSIZE, 879 TYwchar_t : 2, 880 TYushort : SHORTSIZE, 881 882 TYenum : -1, 883 TYint : 2, 884 TYuint : 2, 885 886 TYlong : LONGSIZE, 887 TYulong : LONGSIZE, 888 TYdchar : 4, 889 TYllong : LLONGSIZE, 890 TYullong : LLONGSIZE, 891 TYcent : 8, 892 TYucent : 8, 893 TYfloat : FLOATSIZE, 894 TYdouble : DOUBLESIZE, 895 TYdouble_alias : 8, 896 TYldouble : LDOUBLE_ALIGN, 897 898 TYifloat : FLOATSIZE, 899 TYidouble : DOUBLESIZE, 900 TYildouble : LDOUBLE_ALIGN, 901 902 TYcfloat : 2*FLOATSIZE, 903 TYcdouble : 2*DOUBLESIZE, 904 TYcldouble : LDOUBLE_ALIGN, 905 906 TYfloat4 : 16, 907 TYdouble2 : 16, 908 TYschar16 : 16, 909 TYuchar16 : 16, 910 TYshort8 : 16, 911 TYushort8 : 16, 912 TYlong4 : 16, 913 TYulong4 : 16, 914 TYllong2 : 16, 915 TYullong2 : 16, 916 917 TYfloat8 : 32, 918 TYdouble4 : 32, 919 TYschar32 : 32, 920 TYuchar32 : 32, 921 TYshort16 : 32, 922 TYushort16 : 32, 923 TYlong8 : 32, 924 TYulong8 : 32, 925 TYllong4 : 32, 926 TYullong4 : 32, 927 928 TYfloat16 : 64, 929 TYdouble8 : 64, 930 TYschar64 : 64, 931 TYuchar64 : 64, 932 TYshort32 : 64, 933 TYushort32 : 64, 934 TYlong16 : 64, 935 TYulong16 : 64, 936 TYllong8 : 64, 937 TYullong8 : 64, 938 939 TYnullptr : 2, 940 TYnptr : 2, 941 TYref : -1, 942 TYvoid : -1, 943 TYstruct : -1, 944 TYarray : -1, 945 TYnfunc : -1, 946 TYnpfunc : -1, 947 TYnsfunc : -1, 948 TYptr : 2, 949 TYmfunc : -1, 950 TYjfunc : -1, 951 TYhfunc : -1, 952 TYnref : 2, 953 954 TYsptr : 2, 955 TYcptr : 2, 956 TYf16ptr : 4, 957 TYfptr : 4, 958 TYhptr : 4, 959 TYvptr : 4, 960 TYimmutPtr : 2, 961 TYsharePtr : 2, 962 TYrestrictPtr : 2, 963 TYfgPtr : 2, 964 TYffunc : -1, 965 TYfpfunc : -1, 966 TYfsfunc : -1, 967 TYf16func : -1, 968 TYnsysfunc : -1, 969 TYfsysfunc : -1, 970 TYfref : 4, 971 972 TYifunc : -1, 973 TYmemptr : -1, 974 TYident : -1, 975 TYtemplate : -1, 976 TYvtshape : -1, 977 ]; 978 979 980 private: 981 982 enum TXptr = [ TYnptr ]; 983 enum TXptr_nflat = [ TYsptr,TYcptr,TYf16ptr,TYfptr,TYhptr,TYvptr,TYimmutPtr,TYsharePtr,TYrestrictPtr,TYfgPtr ]; 984 enum TXreal = [ TYfloat,TYdouble,TYdouble_alias,TYldouble, 985 TYfloat4,TYdouble2, 986 TYfloat8,TYdouble4, 987 TYfloat16,TYdouble8, 988 ]; 989 enum TXimaginary = [ TYifloat,TYidouble,TYildouble, ]; 990 enum TXcomplex = [ TYcfloat,TYcdouble,TYcldouble, ]; 991 enum TXintegral = [ TYbool,TYchar,TYschar,TYuchar,TYshort, 992 TYwchar_t,TYushort,TYenum,TYint,TYuint, 993 TYlong,TYulong,TYllong,TYullong,TYdchar, 994 TYschar16,TYuchar16,TYshort8,TYushort8, 995 TYlong4,TYulong4,TYllong2,TYullong2, 996 TYschar32,TYuchar32,TYshort16,TYushort16, 997 TYlong8,TYulong8,TYllong4,TYullong4, 998 TYschar64,TYuchar64,TYshort32,TYushort32, 999 TYlong16,TYulong16,TYllong8,TYullong8, 1000 TYchar16,TYcent,TYucent, 1001 ]; 1002 enum TXref = [ TYnref,TYref ]; 1003 enum TXfunc = [ TYnfunc,TYnpfunc,TYnsfunc,TYifunc,TYmfunc,TYjfunc,TYhfunc ]; 1004 enum TXref_nflat = [ TYfref ]; 1005 enum TXfunc_nflat= [ TYffunc,TYfpfunc,TYf16func,TYfsfunc,TYnsysfunc,TYfsysfunc, ]; 1006 enum TXuns = [ TYuchar,TYushort,TYuint,TYulong, 1007 TYwchar_t, 1008 TYuchar16,TYushort8,TYulong4,TYullong2, 1009 TYdchar,TYullong,TYucent,TYchar16 ]; 1010 enum TXmptr = [ TYmemptr ]; 1011 enum TXnullptr = [ TYnullptr ]; 1012 enum TXfv = [ TYfptr, TYvptr ]; 1013 enum TXfarfunc = [ TYffunc,TYfpfunc,TYfsfunc,TYfsysfunc ]; 1014 enum TXpasfunc = [ TYnpfunc,TYnsfunc,TYmfunc,TYjfunc ]; 1015 enum TXpasfunc_nf = [ TYfpfunc,TYf16func,TYfsfunc, ]; 1016 enum TXrevfunc = [ TYnpfunc,TYjfunc ]; 1017 enum TXrevfunc_nf = [ TYfpfunc,TYf16func, ]; 1018 enum TXshort = [ TYbool,TYchar,TYschar,TYuchar,TYshort, 1019 TYwchar_t,TYushort,TYchar16 ]; 1020 enum TXaggregate = [ TYstruct,TYarray ]; 1021 enum TXxmmreg = [ 1022 TYfloat,TYdouble,TYifloat,TYidouble, 1023 TYfloat4,TYdouble2, 1024 TYschar16,TYuchar16,TYshort8,TYushort8, 1025 TYlong4,TYulong4,TYllong2,TYullong2, 1026 TYfloat8,TYdouble4, 1027 TYschar32,TYuchar32,TYshort16,TYushort16, 1028 TYlong8,TYulong8,TYllong4,TYullong4, 1029 TYschar64,TYuchar64,TYshort32,TYushort32, 1030 TYlong16,TYulong16,TYllong8,TYullong8, 1031 TYfloat16,TYdouble8, 1032 ]; 1033 enum TXsimd = [ 1034 TYfloat4,TYdouble2, 1035 TYschar16,TYuchar16,TYshort8,TYushort8, 1036 TYlong4,TYulong4,TYllong2,TYullong2, 1037 TYfloat8,TYdouble4, 1038 TYschar32,TYuchar32,TYshort16,TYushort16, 1039 TYlong8,TYulong8,TYllong4,TYullong4, 1040 TYschar64,TYuchar64,TYshort32,TYushort32, 1041 TYlong16,TYulong16,TYllong8,TYullong8, 1042 TYfloat16,TYdouble8, 1043 ]; 1044