authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-11-24 17:04:52-08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-11-24 17:04:52-08:00
log84d58aaa1fc8508cb6ec9a455e8127ff13f17e16
tree025aaf90e48385639d69a15e7eabda20bfee8b2c
parent2b2c13926de2702db939c005d8aaa6f9656af626

frontend: move BuiltinFn to std.zig namespace


7 files changed, 1022 insertions(+), 1021 deletions(-)

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