1const std = @import("std"); 2 3pub const Tag = enum { 4 add_with_overflow, 5 align_cast, 6 align_of, 7 as, 8 async_call, 9 atomic_load, 10 atomic_rmw, 11 atomic_store, 12 bit_cast, 13 bit_offset_of, 14 bool_to_int, 15 bit_size_of, 16 breakpoint, 17 mul_add, 18 byte_swap, 19 bit_reverse, 20 offset_of, 21 call, 22 c_define, 23 c_import, 24 c_include, 25 clz, 26 cmpxchg_strong, 27 cmpxchg_weak, 28 compile_error, 29 compile_log, 30 ctz, 31 c_undef, 32 div_exact, 33 div_floor, 34 div_trunc, 35 embed_file, 36 enum_to_int, 37 error_name, 38 error_return_trace, 39 error_to_int, 40 err_set_cast, 41 @"export", 42 @"extern", 43 fence, 44 field, 45 field_parent_ptr, 46 float_cast, 47 float_to_int, 48 frame, 49 Frame, 50 frame_address, 51 frame_size, 52 has_decl, 53 has_field, 54 import, 55 int_cast, 56 int_to_enum, 57 int_to_error, 58 int_to_float, 59 int_to_ptr, 60 maximum, 61 memcpy, 62 memset, 63 minimum, 64 wasm_memory_size, 65 wasm_memory_grow, 66 mod, 67 mul_with_overflow, 68 panic, 69 pop_count, 70 prefetch, 71 ptr_cast, 72 ptr_to_int, 73 rem, 74 return_address, 75 select, 76 set_align_stack, 77 set_cold, 78 set_eval_branch_quota, 79 set_float_mode, 80 set_runtime_safety, 81 shl_exact, 82 shl_with_overflow, 83 shr_exact, 84 shuffle, 85 size_of, 86 splat, 87 reduce, 88 src, 89 sqrt, 90 sin, 91 cos, 92 exp, 93 exp2, 94 log, 95 log2, 96 log10, 97 fabs, 98 floor, 99 ceil, 100 trunc, 101 round, 102 sub_with_overflow, 103 tag_name, 104 This, 105 truncate, 106 Type, 107 type_info, 108 type_name, 109 TypeOf, 110 union_init, 111 Vector, 112}; 113 114pub const MemLocRequirement = enum { 115 /// The builtin never needs a memory location. 116 never, 117 /// The builtin always needs a memory location. 118 always, 119 /// The builtin forwards the question to argument at index 1. 120 forward1, 121}; 122 123pub const EvalToError = enum { 124 /// The builtin cannot possibly evaluate to an error. 125 never, 126 /// The builtin will always evaluate to an error. 127 always, 128 /// The builtin may or may not evaluate to an error depending on the parameters. 129 maybe, 130}; 131 132tag: Tag, 133 134/// Info about the builtin call's ability to take advantage of a result location pointer. 135needs_mem_loc: MemLocRequirement = .never, 136/// Info about the builtin call's possibility of returning an error. 137eval_to_error: EvalToError = .never, 138/// `true` if the builtin call can be the left-hand side of an expression (assigned to). 139allows_lvalue: bool = false, 140/// The number of parameters to this builtin function. `null` means variable number 141/// of parameters. 142param_count: ?u8, 143 144pub const list = list: { 145 @setEvalBranchQuota(3000); 146 break :list std.ComptimeStringMap(@This(), .{ 147 .{ 148 "@addWithOverflow", 149 .{ 150 .tag = .add_with_overflow, 151 .param_count = 4, 152 }, 153 }, 154 .{ 155 "@alignCast", 156 .{ 157 .tag = .align_cast, 158 .param_count = 2, 159 }, 160 }, 161 .{ 162 "@alignOf", 163 .{ 164 .tag = .align_of, 165 .param_count = 1, 166 }, 167 }, 168 .{ 169 "@as", 170 .{ 171 .tag = .as, 172 .needs_mem_loc = .forward1, 173 .eval_to_error = .maybe, 174 .param_count = 2, 175 }, 176 }, 177 .{ 178 "@asyncCall", 179 .{ 180 .tag = .async_call, 181 .param_count = 4, 182 }, 183 }, 184 .{ 185 "@atomicLoad", 186 .{ 187 .tag = .atomic_load, 188 .param_count = 3, 189 }, 190 }, 191 .{ 192 "@atomicRmw", 193 .{ 194 .tag = .atomic_rmw, 195 .param_count = 5, 196 }, 197 }, 198 .{ 199 "@atomicStore", 200 .{ 201 .tag = .atomic_store, 202 .param_count = 4, 203 }, 204 }, 205 .{ 206 "@bitCast", 207 .{ 208 .tag = .bit_cast, 209 .needs_mem_loc = .forward1, 210 .param_count = 2, 211 }, 212 }, 213 .{ 214 "@bitOffsetOf", 215 .{ 216 .tag = .bit_offset_of, 217 .param_count = 2, 218 }, 219 }, 220 .{ 221 "@boolToInt", 222 .{ 223 .tag = .bool_to_int, 224 .param_count = 1, 225 }, 226 }, 227 .{ 228 "@bitSizeOf", 229 .{ 230 .tag = .bit_size_of, 231 .param_count = 1, 232 }, 233 }, 234 .{ 235 "@breakpoint", 236 .{ 237 .tag = .breakpoint, 238 .param_count = 0, 239 }, 240 }, 241 .{ 242 "@mulAdd", 243 .{ 244 .tag = .mul_add, 245 .param_count = 4, 246 }, 247 }, 248 .{ 249 "@byteSwap", 250 .{ 251 .tag = .byte_swap, 252 .param_count = 2, 253 }, 254 }, 255 .{ 256 "@bitReverse", 257 .{ 258 .tag = .bit_reverse, 259 .param_count = 2, 260 }, 261 }, 262 .{ 263 "@offsetOf", 264 .{ 265 .tag = .offset_of, 266 .param_count = 2, 267 }, 268 }, 269 .{ 270 "@call", 271 .{ 272 .tag = .call, 273 .needs_mem_loc = .always, 274 .eval_to_error = .maybe, 275 .param_count = 3, 276 }, 277 }, 278 .{ 279 "@cDefine", 280 .{ 281 .tag = .c_define, 282 .param_count = 2, 283 }, 284 }, 285 .{ 286 "@cImport", 287 .{ 288 .tag = .c_import, 289 .param_count = 1, 290 }, 291 }, 292 .{ 293 "@cInclude", 294 .{ 295 .tag = .c_include, 296 .param_count = 1, 297 }, 298 }, 299 .{ 300 "@clz", 301 .{ 302 .tag = .clz, 303 .param_count = 2, 304 }, 305 }, 306 .{ 307 "@cmpxchgStrong", 308 .{ 309 .tag = .cmpxchg_strong, 310 .param_count = 6, 311 }, 312 }, 313 .{ 314 "@cmpxchgWeak", 315 .{ 316 .tag = .cmpxchg_weak, 317 .param_count = 6, 318 }, 319 }, 320 .{ 321 "@compileError", 322 .{ 323 .tag = .compile_error, 324 .param_count = 1, 325 }, 326 }, 327 .{ 328 "@compileLog", 329 .{ 330 .tag = .compile_log, 331 .param_count = null, 332 }, 333 }, 334 .{ 335 "@ctz", 336 .{ 337 .tag = .ctz, 338 .param_count = 2, 339 }, 340 }, 341 .{ 342 "@cUndef", 343 .{ 344 .tag = .c_undef, 345 .param_count = 1, 346 }, 347 }, 348 .{ 349 "@divExact", 350 .{ 351 .tag = .div_exact, 352 .param_count = 2, 353 }, 354 }, 355 .{ 356 "@divFloor", 357 .{ 358 .tag = .div_floor, 359 .param_count = 2, 360 }, 361 }, 362 .{ 363 "@divTrunc", 364 .{ 365 .tag = .div_trunc, 366 .param_count = 2, 367 }, 368 }, 369 .{ 370 "@embedFile", 371 .{ 372 .tag = .embed_file, 373 .param_count = 1, 374 }, 375 }, 376 .{ 377 "@enumToInt", 378 .{ 379 .tag = .enum_to_int, 380 .param_count = 1, 381 }, 382 }, 383 .{ 384 "@errorName", 385 .{ 386 .tag = .error_name, 387 .param_count = 1, 388 }, 389 }, 390 .{ 391 "@errorReturnTrace", 392 .{ 393 .tag = .error_return_trace, 394 .param_count = 0, 395 }, 396 }, 397 .{ 398 "@errorToInt", 399 .{ 400 .tag = .error_to_int, 401 .param_count = 1, 402 }, 403 }, 404 .{ 405 "@errSetCast", 406 .{ 407 .tag = .err_set_cast, 408 .eval_to_error = .always, 409 .param_count = 2, 410 }, 411 }, 412 .{ 413 "@export", 414 .{ 415 .tag = .@"export", 416 .param_count = 2, 417 }, 418 }, 419 .{ 420 "@extern", 421 .{ 422 .tag = .@"extern", 423 .param_count = 2, 424 }, 425 }, 426 .{ 427 "@fence", 428 .{ 429 .tag = .fence, 430 .param_count = 1, 431 }, 432 }, 433 .{ 434 "@field", 435 .{ 436 .tag = .field, 437 .needs_mem_loc = .always, 438 .eval_to_error = .maybe, 439 .param_count = 2, 440 .allows_lvalue = true, 441 }, 442 }, 443 .{ 444 "@fieldParentPtr", 445 .{ 446 .tag = .field_parent_ptr, 447 .param_count = 3, 448 }, 449 }, 450 .{ 451 "@floatCast", 452 .{ 453 .tag = .float_cast, 454 .param_count = 2, 455 }, 456 }, 457 .{ 458 "@floatToInt", 459 .{ 460 .tag = .float_to_int, 461 .param_count = 2, 462 }, 463 }, 464 .{ 465 "@frame", 466 .{ 467 .tag = .frame, 468 .param_count = 0, 469 }, 470 }, 471 .{ 472 "@Frame", 473 .{ 474 .tag = .Frame, 475 .param_count = 1, 476 }, 477 }, 478 .{ 479 "@frameAddress", 480 .{ 481 .tag = .frame_address, 482 .param_count = 0, 483 }, 484 }, 485 .{ 486 "@frameSize", 487 .{ 488 .tag = .frame_size, 489 .param_count = 1, 490 }, 491 }, 492 .{ 493 "@hasDecl", 494 .{ 495 .tag = .has_decl, 496 .param_count = 2, 497 }, 498 }, 499 .{ 500 "@hasField", 501 .{ 502 .tag = .has_field, 503 .param_count = 2, 504 }, 505 }, 506 .{ 507 "@import", 508 .{ 509 .tag = .import, 510 .param_count = 1, 511 }, 512 }, 513 .{ 514 "@intCast", 515 .{ 516 .tag = .int_cast, 517 .param_count = 2, 518 }, 519 }, 520 .{ 521 "@intToEnum", 522 .{ 523 .tag = .int_to_enum, 524 .param_count = 2, 525 }, 526 }, 527 .{ 528 "@intToError", 529 .{ 530 .tag = .int_to_error, 531 .eval_to_error = .always, 532 .param_count = 1, 533 }, 534 }, 535 .{ 536 "@intToFloat", 537 .{ 538 .tag = .int_to_float, 539 .param_count = 2, 540 }, 541 }, 542 .{ 543 "@intToPtr", 544 .{ 545 .tag = .int_to_ptr, 546 .param_count = 2, 547 }, 548 }, 549 .{ 550 "@maximum", 551 .{ 552 .tag = .maximum, 553 .param_count = 2, 554 }, 555 }, 556 .{ 557 "@memcpy", 558 .{ 559 .tag = .memcpy, 560 .param_count = 3, 561 }, 562 }, 563 .{ 564 "@memset", 565 .{ 566 .tag = .memset, 567 .param_count = 3, 568 }, 569 }, 570 .{ 571 "@minimum", 572 .{ 573 .tag = .minimum, 574 .param_count = 2, 575 }, 576 }, 577 .{ 578 "@wasmMemorySize", 579 .{ 580 .tag = .wasm_memory_size, 581 .param_count = 1, 582 }, 583 }, 584 .{ 585 "@wasmMemoryGrow", 586 .{ 587 .tag = .wasm_memory_grow, 588 .param_count = 2, 589 }, 590 }, 591 .{ 592 "@mod", 593 .{ 594 .tag = .mod, 595 .param_count = 2, 596 }, 597 }, 598 .{ 599 "@mulWithOverflow", 600 .{ 601 .tag = .mul_with_overflow, 602 .param_count = 4, 603 }, 604 }, 605 .{ 606 "@panic", 607 .{ 608 .tag = .panic, 609 .param_count = 1, 610 }, 611 }, 612 .{ 613 "@popCount", 614 .{ 615 .tag = .pop_count, 616 .param_count = 2, 617 }, 618 }, 619 .{ 620 "@prefetch", 621 .{ 622 .tag = .prefetch, 623 .param_count = 2, 624 }, 625 }, 626 .{ 627 "@ptrCast", 628 .{ 629 .tag = .ptr_cast, 630 .param_count = 2, 631 }, 632 }, 633 .{ 634 "@ptrToInt", 635 .{ 636 .tag = .ptr_to_int, 637 .param_count = 1, 638 }, 639 }, 640 .{ 641 "@rem", 642 .{ 643 .tag = .rem, 644 .param_count = 2, 645 }, 646 }, 647 .{ 648 "@returnAddress", 649 .{ 650 .tag = .return_address, 651 .param_count = 0, 652 }, 653 }, 654 .{ 655 "@select", 656 .{ 657 .tag = .select, 658 .param_count = 4, 659 }, 660 }, 661 .{ 662 "@setAlignStack", 663 .{ 664 .tag = .set_align_stack, 665 .param_count = 1, 666 }, 667 }, 668 .{ 669 "@setCold", 670 .{ 671 .tag = .set_cold, 672 .param_count = 1, 673 }, 674 }, 675 .{ 676 "@setEvalBranchQuota", 677 .{ 678 .tag = .set_eval_branch_quota, 679 .param_count = 1, 680 }, 681 }, 682 .{ 683 "@setFloatMode", 684 .{ 685 .tag = .set_float_mode, 686 .param_count = 1, 687 }, 688 }, 689 .{ 690 "@setRuntimeSafety", 691 .{ 692 .tag = .set_runtime_safety, 693 .param_count = 1, 694 }, 695 }, 696 .{ 697 "@shlExact", 698 .{ 699 .tag = .shl_exact, 700 .param_count = 2, 701 }, 702 }, 703 .{ 704 "@shlWithOverflow", 705 .{ 706 .tag = .shl_with_overflow, 707 .param_count = 4, 708 }, 709 }, 710 .{ 711 "@shrExact", 712 .{ 713 .tag = .shr_exact, 714 .param_count = 2, 715 }, 716 }, 717 .{ 718 "@shuffle", 719 .{ 720 .tag = .shuffle, 721 .param_count = 4, 722 }, 723 }, 724 .{ 725 "@sizeOf", 726 .{ 727 .tag = .size_of, 728 .param_count = 1, 729 }, 730 }, 731 .{ 732 "@splat", 733 .{ 734 .tag = .splat, 735 .param_count = 2, 736 }, 737 }, 738 .{ 739 "@reduce", 740 .{ 741 .tag = .reduce, 742 .param_count = 2, 743 }, 744 }, 745 .{ 746 "@src", 747 .{ 748 .tag = .src, 749 .needs_mem_loc = .always, 750 .param_count = 0, 751 }, 752 }, 753 .{ 754 "@sqrt", 755 .{ 756 .tag = .sqrt, 757 .param_count = 1, 758 }, 759 }, 760 .{ 761 "@sin", 762 .{ 763 .tag = .sin, 764 .param_count = 1, 765 }, 766 }, 767 .{ 768 "@cos", 769 .{ 770 .tag = .cos, 771 .param_count = 1, 772 }, 773 }, 774 .{ 775 "@exp", 776 .{ 777 .tag = .exp, 778 .param_count = 1, 779 }, 780 }, 781 .{ 782 "@exp2", 783 .{ 784 .tag = .exp2, 785 .param_count = 1, 786 }, 787 }, 788 .{ 789 "@log", 790 .{ 791 .tag = .log, 792 .param_count = 1, 793 }, 794 }, 795 .{ 796 "@log2", 797 .{ 798 .tag = .log2, 799 .param_count = 1, 800 }, 801 }, 802 .{ 803 "@log10", 804 .{ 805 .tag = .log10, 806 .param_count = 1, 807 }, 808 }, 809 .{ 810 "@fabs", 811 .{ 812 .tag = .fabs, 813 .param_count = 1, 814 }, 815 }, 816 .{ 817 "@floor", 818 .{ 819 .tag = .floor, 820 .param_count = 1, 821 }, 822 }, 823 .{ 824 "@ceil", 825 .{ 826 .tag = .ceil, 827 .param_count = 1, 828 }, 829 }, 830 .{ 831 "@trunc", 832 .{ 833 .tag = .trunc, 834 .param_count = 1, 835 }, 836 }, 837 .{ 838 "@round", 839 .{ 840 .tag = .round, 841 .param_count = 1, 842 }, 843 }, 844 .{ 845 "@subWithOverflow", 846 .{ 847 .tag = .sub_with_overflow, 848 .param_count = 4, 849 }, 850 }, 851 .{ 852 "@tagName", 853 .{ 854 .tag = .tag_name, 855 .param_count = 1, 856 }, 857 }, 858 .{ 859 "@This", 860 .{ 861 .tag = .This, 862 .param_count = 0, 863 }, 864 }, 865 .{ 866 "@truncate", 867 .{ 868 .tag = .truncate, 869 .param_count = 2, 870 }, 871 }, 872 .{ 873 "@Type", 874 .{ 875 .tag = .Type, 876 .param_count = 1, 877 }, 878 }, 879 .{ 880 "@typeInfo", 881 .{ 882 .tag = .type_info, 883 .param_count = 1, 884 }, 885 }, 886 .{ 887 "@typeName", 888 .{ 889 .tag = .type_name, 890 .param_count = 1, 891 }, 892 }, 893 .{ 894 "@TypeOf", 895 .{ 896 .tag = .TypeOf, 897 .param_count = null, 898 }, 899 }, 900 .{ 901 "@unionInit", 902 .{ 903 .tag = .union_init, 904 .needs_mem_loc = .always, 905 .param_count = 3, 906 }, 907 }, 908 .{ 909 "@Vector", 910 .{ 911 .tag = .Vector, 912 .param_count = 2, 913 }, 914 }, 915 }); 916}; 917