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-2021 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 TYnoreturn : "noreturn", 371 TYstruct : "struct", 372 TYarray : "array", 373 TYnfunc : "C func", 374 TYnpfunc : "Pascal func", 375 TYnsfunc : "std func", 376 TYptr : "*", 377 TYmfunc : "member func", 378 TYjfunc : "D func", 379 TYhfunc : "C func", 380 TYnref : "__near &", 381 382 TYsptr : "__ss *", 383 TYcptr : "__cs *", 384 TYf16ptr : "__far16 *", 385 TYfptr : "__far *", 386 TYhptr : "__huge *", 387 TYvptr : "__handle *", 388 TYimmutPtr : "__immutable *", 389 TYsharePtr : "__shared *", 390 TYrestrictPtr : "__restrict *", 391 TYfgPtr : "__fg *", 392 TYffunc : "far C func", 393 TYfpfunc : "far Pascal func", 394 TYfsfunc : "far std func", 395 TYf16func : "_far16 Pascal func", 396 TYnsysfunc : "sys func", 397 TYfsysfunc : "far sys func", 398 TYfref : "__far &", 399 400 TYifunc : "interrupt func", 401 TYmemptr : "memptr", 402 TYident : "ident", 403 TYtemplate : "template", 404 TYvtshape : "vtshape", 405 ]; 406 407 /// Map to unsigned version of type 408 __gshared tym_t[256] tytouns = 409 () { 410 tym_t[256] tab; 411 foreach (ty; 0 .. TYMAX) 412 { 413 tym_t tym; 414 switch (ty) 415 { 416 case TYchar: tym = TYuchar; break; 417 case TYschar: tym = TYuchar; break; 418 case TYshort: tym = TYushort; break; 419 case TYushort: tym = TYushort; break; 420 421 case TYenum: tym = TYuint; break; 422 case TYint: tym = TYuint; break; 423 424 case TYlong: tym = TYulong; break; 425 case TYllong: tym = TYullong; break; 426 case TYcent: tym = TYucent; break; 427 428 case TYschar16: tym = TYuchar16; break; 429 case TYshort8: tym = TYushort8; break; 430 case TYlong4: tym = TYulong4; break; 431 case TYllong2: tym = TYullong2; break; 432 433 case TYschar32: tym = TYuchar32; break; 434 case TYshort16: tym = TYushort16; break; 435 case TYlong8: tym = TYulong8; break; 436 case TYllong4: tym = TYullong4; break; 437 438 case TYschar64: tym = TYuchar64; break; 439 case TYshort32: tym = TYushort32; break; 440 case TYlong16: tym = TYulong16; break; 441 case TYllong8: tym = TYullong8; break; 442 443 default: tym = ty; break; 444 } 445 tab[ty] = tym; 446 } 447 return tab; 448 } (); 449 450 /// Map to relaxed version of type 451 __gshared ubyte[TYMAX] _tyrelax = 452 () { 453 ubyte[TYMAX] tab; 454 foreach (ty; 0 .. TYMAX) 455 { 456 tym_t tym; 457 switch (ty) 458 { 459 case TYbool: tym = TYchar; break; 460 case TYschar: tym = TYchar; break; 461 case TYuchar: tym = TYchar; break; 462 case TYchar8: tym = TYchar; break; 463 case TYchar16: tym = TYint; break; 464 465 case TYshort: tym = TYint; break; 466 case TYushort: tym = TYint; break; 467 case TYwchar_t: tym = TYint; break; 468 469 case TYenum: tym = TYint; break; 470 case TYuint: tym = TYint; break; 471 472 case TYulong: tym = TYlong; break; 473 case TYdchar: tym = TYlong; break; 474 case TYullong: tym = TYllong; break; 475 case TYucent: tym = TYcent; break; 476 477 case TYnullptr: tym = TYptr; break; 478 479 default: tym = ty; break; 480 } 481 tab[ty] = cast(ubyte)tym; 482 } 483 return tab; 484 } (); 485 486 /// Map to equivalent version of type 487 __gshared ubyte[TYMAX] tyequiv = 488 () { 489 ubyte[TYMAX] tab; 490 foreach (ty; 0 .. TYMAX) 491 { 492 tym_t tym; 493 switch (ty) 494 { 495 case TYchar: tym = TYschar; break; // chars are signed by default 496 case TYint: tym = TYshort; break; // adjusted in util_set32() 497 case TYuint: tym = TYushort; break; // adjusted in util_set32() 498 499 default: tym = ty; break; 500 } 501 tab[ty] = cast(ubyte)tym; 502 } 503 return tab; 504 } (); 505 506 /// Map to Codeview 1 type in debugger record 507 __gshared ubyte[TYMAX] dttab = 508 [ 509 TYbool : 0x80, 510 TYchar : 0x80, 511 TYschar : 0x80, 512 TYuchar : 0x84, 513 TYchar8 : 0x84, 514 TYchar16 : 0x85, 515 TYshort : 0x81, 516 TYwchar_t : 0x85, 517 TYushort : 0x85, 518 519 TYenum : 0x81, 520 TYint : 0x85, 521 TYuint : 0x85, 522 523 TYlong : 0x82, 524 TYulong : 0x86, 525 TYdchar : 0x86, 526 TYllong : 0x82, 527 TYullong : 0x86, 528 TYcent : 0x82, 529 TYucent : 0x86, 530 TYfloat : 0x88, 531 TYdouble : 0x89, 532 TYdouble_alias : 0x89, 533 TYldouble : 0x89, 534 535 TYifloat : 0x88, 536 TYidouble : 0x89, 537 TYildouble : 0x89, 538 539 TYcfloat : 0x88, 540 TYcdouble : 0x89, 541 TYcldouble : 0x89, 542 543 TYfloat4 : 0x00, 544 TYdouble2 : 0x00, 545 TYschar16 : 0x00, 546 TYuchar16 : 0x00, 547 TYshort8 : 0x00, 548 TYushort8 : 0x00, 549 TYlong4 : 0x00, 550 TYulong4 : 0x00, 551 TYllong2 : 0x00, 552 TYullong2 : 0x00, 553 554 TYfloat8 : 0x00, 555 TYdouble4 : 0x00, 556 TYschar32 : 0x00, 557 TYuchar32 : 0x00, 558 TYshort16 : 0x00, 559 TYushort16 : 0x00, 560 TYlong8 : 0x00, 561 TYulong8 : 0x00, 562 TYllong4 : 0x00, 563 TYullong4 : 0x00, 564 565 TYfloat16 : 0x00, 566 TYdouble8 : 0x00, 567 TYschar64 : 0x00, 568 TYuchar64 : 0x00, 569 TYshort32 : 0x00, 570 TYushort32 : 0x00, 571 TYlong16 : 0x00, 572 TYulong16 : 0x00, 573 TYllong8 : 0x00, 574 TYullong8 : 0x00, 575 576 TYnullptr : 0x20, 577 TYnptr : 0x20, 578 TYref : 0x00, 579 TYvoid : 0x85, 580 TYnoreturn : 0x85, // same as TYvoid 581 TYstruct : 0x00, 582 TYarray : 0x78, 583 TYnfunc : 0x63, 584 TYnpfunc : 0x74, 585 TYnsfunc : 0x63, 586 TYptr : 0x20, 587 TYmfunc : 0x64, 588 TYjfunc : 0x74, 589 TYhfunc : 0x00, 590 TYnref : 0x00, 591 592 TYsptr : 0x20, 593 TYcptr : 0x20, 594 TYf16ptr : 0x40, 595 TYfptr : 0x40, 596 TYhptr : 0x40, 597 TYvptr : 0x40, 598 TYimmutPtr : 0x20, 599 TYsharePtr : 0x20, 600 TYrestrictPtr : 0x20, 601 TYfgPtr : 0x20, 602 TYffunc : 0x64, 603 TYfpfunc : 0x73, 604 TYfsfunc : 0x64, 605 TYf16func : 0x63, 606 TYnsysfunc : 0x63, 607 TYfsysfunc : 0x64, 608 TYfref : 0x00, 609 610 TYifunc : 0x64, 611 TYmemptr : 0x00, 612 TYident : 0x00, 613 TYtemplate : 0x00, 614 TYvtshape : 0x00, 615 ]; 616 617 /// Map to Codeview 4 type in debugger record 618 __gshared ushort[TYMAX] dttab4 = 619 [ 620 TYbool : 0x30, 621 TYchar : 0x70, 622 TYschar : 0x10, 623 TYuchar : 0x20, 624 TYchar8 : 0x20, 625 TYchar16 : 0x21, 626 TYshort : 0x11, 627 TYwchar_t : 0x71, 628 TYushort : 0x21, 629 630 TYenum : 0x72, 631 TYint : 0x72, 632 TYuint : 0x73, 633 634 TYlong : 0x12, 635 TYulong : 0x22, 636 TYdchar : 0x7b, // UTF32 637 TYllong : 0x13, 638 TYullong : 0x23, 639 TYcent : 0x603, 640 TYucent : 0x603, 641 TYfloat : 0x40, 642 TYdouble : 0x41, 643 TYdouble_alias : 0x41, 644 TYldouble : 0x42, 645 646 TYifloat : 0x40, 647 TYidouble : 0x41, 648 TYildouble : 0x42, 649 650 TYcfloat : 0x50, 651 TYcdouble : 0x51, 652 TYcldouble : 0x52, 653 654 TYfloat4 : 0x00, 655 TYdouble2 : 0x00, 656 TYschar16 : 0x00, 657 TYuchar16 : 0x00, 658 TYshort8 : 0x00, 659 TYushort8 : 0x00, 660 TYlong4 : 0x00, 661 TYulong4 : 0x00, 662 TYllong2 : 0x00, 663 TYullong2 : 0x00, 664 665 TYfloat8 : 0x00, 666 TYdouble4 : 0x00, 667 TYschar32 : 0x00, 668 TYuchar32 : 0x00, 669 TYshort16 : 0x00, 670 TYushort16 : 0x00, 671 TYlong8 : 0x00, 672 TYulong8 : 0x00, 673 TYllong4 : 0x00, 674 TYullong4 : 0x00, 675 676 TYfloat16 : 0x00, 677 TYdouble8 : 0x00, 678 TYschar64 : 0x00, 679 TYuchar64 : 0x00, 680 TYshort32 : 0x00, 681 TYushort32 : 0x00, 682 TYlong16 : 0x00, 683 TYulong16 : 0x00, 684 TYllong8 : 0x00, 685 TYullong8 : 0x00, 686 687 TYnullptr : 0x100, 688 TYnptr : 0x100, 689 TYref : 0x00, 690 TYvoid : 0x03, 691 TYnoreturn : 0x03, // same as TYvoid 692 TYstruct : 0x00, 693 TYarray : 0x00, 694 TYnfunc : 0x00, 695 TYnpfunc : 0x00, 696 TYnsfunc : 0x00, 697 TYptr : 0x100, 698 TYmfunc : 0x00, 699 TYjfunc : 0x00, 700 TYhfunc : 0x00, 701 TYnref : 0x00, 702 703 TYsptr : 0x100, 704 TYcptr : 0x100, 705 TYf16ptr : 0x200, 706 TYfptr : 0x200, 707 TYhptr : 0x300, 708 TYvptr : 0x200, 709 TYimmutPtr : 0x100, 710 TYsharePtr : 0x100, 711 TYrestrictPtr : 0x100, 712 TYfgPtr : 0x100, 713 TYffunc : 0x00, 714 TYfpfunc : 0x00, 715 TYfsfunc : 0x00, 716 TYf16func : 0x00, 717 TYnsysfunc : 0x00, 718 TYfsysfunc : 0x00, 719 TYfref : 0x00, 720 721 TYifunc : 0x00, 722 TYmemptr : 0x00, 723 TYident : 0x00, 724 TYtemplate : 0x00, 725 TYvtshape : 0x00, 726 ]; 727 728 /// Size of a type 729 __gshared byte[256] _tysize = 730 [ 731 TYbool : 1, 732 TYchar : 1, 733 TYschar : 1, 734 TYuchar : 1, 735 TYchar8 : 1, 736 TYchar16 : 2, 737 TYshort : SHORTSIZE, 738 TYwchar_t : 2, 739 TYushort : SHORTSIZE, 740 741 TYenum : -1, 742 TYint : 2, 743 TYuint : 2, 744 745 TYlong : LONGSIZE, 746 TYulong : LONGSIZE, 747 TYdchar : 4, 748 TYllong : LLONGSIZE, 749 TYullong : LLONGSIZE, 750 TYcent : 16, 751 TYucent : 16, 752 TYfloat : FLOATSIZE, 753 TYdouble : DOUBLESIZE, 754 TYdouble_alias : 8, 755 TYldouble : -1, 756 757 TYifloat : FLOATSIZE, 758 TYidouble : DOUBLESIZE, 759 TYildouble : -1, 760 761 TYcfloat : 2*FLOATSIZE, 762 TYcdouble : 2*DOUBLESIZE, 763 TYcldouble : -1, 764 765 TYfloat4 : 16, 766 TYdouble2 : 16, 767 TYschar16 : 16, 768 TYuchar16 : 16, 769 TYshort8 : 16, 770 TYushort8 : 16, 771 TYlong4 : 16, 772 TYulong4 : 16, 773 TYllong2 : 16, 774 TYullong2 : 16, 775 776 TYfloat8 : 32, 777 TYdouble4 : 32, 778 TYschar32 : 32, 779 TYuchar32 : 32, 780 TYshort16 : 32, 781 TYushort16 : 32, 782 TYlong8 : 32, 783 TYulong8 : 32, 784 TYllong4 : 32, 785 TYullong4 : 32, 786 787 TYfloat16 : 64, 788 TYdouble8 : 64, 789 TYschar64 : 64, 790 TYuchar64 : 64, 791 TYshort32 : 64, 792 TYushort32 : 64, 793 TYlong16 : 64, 794 TYulong16 : 64, 795 TYllong8 : 64, 796 TYullong8 : 64, 797 798 TYnullptr : 2, 799 TYnptr : 2, 800 TYref : -1, 801 TYvoid : -1, 802 TYnoreturn : 0, 803 TYstruct : -1, 804 TYarray : -1, 805 TYnfunc : -1, 806 TYnpfunc : -1, 807 TYnsfunc : -1, 808 TYptr : 2, 809 TYmfunc : -1, 810 TYjfunc : -1, 811 TYhfunc : -1, 812 TYnref : 2, 813 814 TYsptr : 2, 815 TYcptr : 2, 816 TYf16ptr : 4, 817 TYfptr : 4, 818 TYhptr : 4, 819 TYvptr : 4, 820 TYimmutPtr : 2, 821 TYsharePtr : 2, 822 TYrestrictPtr : 2, 823 TYfgPtr : 2, 824 TYffunc : -1, 825 TYfpfunc : -1, 826 TYfsfunc : -1, 827 TYf16func : -1, 828 TYnsysfunc : -1, 829 TYfsysfunc : -1, 830 TYfref : 4, 831 832 TYifunc : -1, 833 TYmemptr : -1, 834 TYident : -1, 835 TYtemplate : -1, 836 TYvtshape : -1, 837 ]; 838 839 // set alignment after we know the target 840 enum SET_ALIGN = -1; 841 842 /// Size of a type to use for alignment 843 __gshared byte[256] _tyalignsize = 844 [ 845 TYbool : 1, 846 TYchar : 1, 847 TYschar : 1, 848 TYuchar : 1, 849 TYchar8 : 1, 850 TYchar16 : 2, 851 TYshort : SHORTSIZE, 852 TYwchar_t : 2, 853 TYushort : SHORTSIZE, 854 855 TYenum : -1, 856 TYint : 2, 857 TYuint : 2, 858 859 TYlong : LONGSIZE, 860 TYulong : LONGSIZE, 861 TYdchar : 4, 862 TYllong : LLONGSIZE, 863 TYullong : LLONGSIZE, 864 TYcent : 8, 865 TYucent : 8, 866 TYfloat : FLOATSIZE, 867 TYdouble : DOUBLESIZE, 868 TYdouble_alias : 8, 869 TYldouble : SET_ALIGN, 870 871 TYifloat : FLOATSIZE, 872 TYidouble : DOUBLESIZE, 873 TYildouble : SET_ALIGN, 874 875 TYcfloat : 2*FLOATSIZE, 876 TYcdouble : 2*DOUBLESIZE, 877 TYcldouble : SET_ALIGN, 878 879 TYfloat4 : 16, 880 TYdouble2 : 16, 881 TYschar16 : 16, 882 TYuchar16 : 16, 883 TYshort8 : 16, 884 TYushort8 : 16, 885 TYlong4 : 16, 886 TYulong4 : 16, 887 TYllong2 : 16, 888 TYullong2 : 16, 889 890 TYfloat8 : 32, 891 TYdouble4 : 32, 892 TYschar32 : 32, 893 TYuchar32 : 32, 894 TYshort16 : 32, 895 TYushort16 : 32, 896 TYlong8 : 32, 897 TYulong8 : 32, 898 TYllong4 : 32, 899 TYullong4 : 32, 900 901 TYfloat16 : 64, 902 TYdouble8 : 64, 903 TYschar64 : 64, 904 TYuchar64 : 64, 905 TYshort32 : 64, 906 TYushort32 : 64, 907 TYlong16 : 64, 908 TYulong16 : 64, 909 TYllong8 : 64, 910 TYullong8 : 64, 911 912 TYnullptr : 2, 913 TYnptr : 2, 914 TYref : -1, 915 TYvoid : -1, 916 TYnoreturn : 0, 917 TYstruct : -1, 918 TYarray : -1, 919 TYnfunc : -1, 920 TYnpfunc : -1, 921 TYnsfunc : -1, 922 TYptr : 2, 923 TYmfunc : -1, 924 TYjfunc : -1, 925 TYhfunc : -1, 926 TYnref : 2, 927 928 TYsptr : 2, 929 TYcptr : 2, 930 TYf16ptr : 4, 931 TYfptr : 4, 932 TYhptr : 4, 933 TYvptr : 4, 934 TYimmutPtr : 2, 935 TYsharePtr : 2, 936 TYrestrictPtr : 2, 937 TYfgPtr : 2, 938 TYffunc : -1, 939 TYfpfunc : -1, 940 TYfsfunc : -1, 941 TYf16func : -1, 942 TYnsysfunc : -1, 943 TYfsysfunc : -1, 944 TYfref : 4, 945 946 TYifunc : -1, 947 TYmemptr : -1, 948 TYident : -1, 949 TYtemplate : -1, 950 TYvtshape : -1, 951 ]; 952 953 954 private: 955 956 enum TXptr = [ TYnptr ]; 957 enum TXptr_nflat = [ TYsptr,TYcptr,TYf16ptr,TYfptr,TYhptr,TYvptr,TYimmutPtr,TYsharePtr,TYrestrictPtr,TYfgPtr ]; 958 enum TXreal = [ TYfloat,TYdouble,TYdouble_alias,TYldouble, 959 TYfloat4,TYdouble2, 960 TYfloat8,TYdouble4, 961 TYfloat16,TYdouble8, 962 ]; 963 enum TXimaginary = [ TYifloat,TYidouble,TYildouble, ]; 964 enum TXcomplex = [ TYcfloat,TYcdouble,TYcldouble, ]; 965 enum TXintegral = [ TYbool,TYchar,TYschar,TYuchar,TYshort, 966 TYwchar_t,TYushort,TYenum,TYint,TYuint, 967 TYlong,TYulong,TYllong,TYullong,TYdchar, 968 TYschar16,TYuchar16,TYshort8,TYushort8, 969 TYlong4,TYulong4,TYllong2,TYullong2, 970 TYschar32,TYuchar32,TYshort16,TYushort16, 971 TYlong8,TYulong8,TYllong4,TYullong4, 972 TYschar64,TYuchar64,TYshort32,TYushort32, 973 TYlong16,TYulong16,TYllong8,TYullong8, 974 TYchar16,TYcent,TYucent, 975 ]; 976 enum TXref = [ TYnref,TYref ]; 977 enum TXfunc = [ TYnfunc,TYnpfunc,TYnsfunc,TYifunc,TYmfunc,TYjfunc,TYhfunc ]; 978 enum TXref_nflat = [ TYfref ]; 979 enum TXfunc_nflat= [ TYffunc,TYfpfunc,TYf16func,TYfsfunc,TYnsysfunc,TYfsysfunc, ]; 980 enum TXuns = [ TYuchar,TYushort,TYuint,TYulong, 981 TYwchar_t, 982 TYuchar16,TYushort8,TYulong4,TYullong2, 983 TYdchar,TYullong,TYucent,TYchar16 ]; 984 enum TXmptr = [ TYmemptr ]; 985 enum TXnullptr = [ TYnullptr ]; 986 enum TXfv = [ TYfptr, TYvptr ]; 987 enum TXfarfunc = [ TYffunc,TYfpfunc,TYfsfunc,TYfsysfunc ]; 988 enum TXpasfunc = [ TYnpfunc,TYnsfunc,TYmfunc,TYjfunc ]; 989 enum TXpasfunc_nf = [ TYfpfunc,TYf16func,TYfsfunc, ]; 990 enum TXrevfunc = [ TYnpfunc,TYjfunc ]; 991 enum TXrevfunc_nf = [ TYfpfunc,TYf16func, ]; 992 enum TXshort = [ TYbool,TYchar,TYschar,TYuchar,TYshort, 993 TYwchar_t,TYushort,TYchar16 ]; 994 enum TXaggregate = [ TYstruct,TYarray ]; 995 enum TXxmmreg = [ 996 TYfloat,TYdouble,TYifloat,TYidouble, 997 //TYcfloat,TYcdouble, 998 TYfloat4,TYdouble2, 999 TYschar16,TYuchar16,TYshort8,TYushort8, 1000 TYlong4,TYulong4,TYllong2,TYullong2, 1001 TYfloat8,TYdouble4, 1002 TYschar32,TYuchar32,TYshort16,TYushort16, 1003 TYlong8,TYulong8,TYllong4,TYullong4, 1004 TYschar64,TYuchar64,TYshort32,TYushort32, 1005 TYlong16,TYulong16,TYllong8,TYullong8, 1006 TYfloat16,TYdouble8, 1007 ]; 1008 enum TXsimd = [ 1009 TYfloat4,TYdouble2, 1010 TYschar16,TYuchar16,TYshort8,TYushort8, 1011 TYlong4,TYulong4,TYllong2,TYullong2, 1012 TYfloat8,TYdouble4, 1013 TYschar32,TYuchar32,TYshort16,TYushort16, 1014 TYlong8,TYulong8,TYllong4,TYullong4, 1015 TYschar64,TYuchar64,TYshort32,TYushort32, 1016 TYlong16,TYulong16,TYllong8,TYullong8, 1017 TYfloat16,TYdouble8, 1018 ];