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