Commit dfa88b3
committed
Auto merge of rust-lang#120500 - oli-obk:intrinsics2.0, r=WaffleLapkin
Implement intrinsics with fallback bodies
fixes rust-lang#93145 (though we can port many more intrinsics)
cc rust-lang#63585
The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for
* codegen_ssa (so llvm and gcc)
* codegen_cranelift
other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body).
cc `@scottmcm` `@WaffleLapkin`
### todo
* [ ] miri support
* [x] default intrinsic name to name of function instead of requiring it to be specified in attribute
* [x] make sure that the bodies are always available (must be collected for metadata)File tree
49 files changed
+620
-451
lines changed- compiler
- rustc_borrowck/src/type_check
- rustc_codegen_cranelift/src
- abi
- intrinsics
- rustc_codegen_gcc/src/intrinsic
- rustc_codegen_llvm/src
- rustc_codegen_ssa/src
- mir
- traits
- rustc_const_eval/src
- const_eval
- interpret
- transform/check_consts
- rustc_feature/src
- rustc_hir_analysis/src
- check
- rustc_hir_typeck/src
- rustc_infer/src/infer/error_reporting
- rustc_lint/src
- rustc_metadata/src/rmeta
- decoder
- rustc_middle/src
- query
- ty
- rustc_mir_dataflow/src
- rustc_mir_transform/src
- rustc_monomorphize/src
- rustc_span/src
- rustc_ty_utils/src
- library/core/src
- src
- doc/unstable-book/src/language-features
- librustdoc/clean
- tools
- clippy/clippy_utils/src
- miri/tests/pass
- tests
- codegen
- ui
- consts
- feature-gates
- intrinsics
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
49 files changed
+620
-451
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1666 | 1666 | | |
1667 | 1667 | | |
1668 | 1668 | | |
1669 | | - | |
1670 | | - | |
1671 | | - | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
1675 | | - | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
1679 | 1672 | | |
1680 | 1673 | | |
1681 | 1674 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
| 390 | + | |
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| |||
430 | 431 | | |
431 | 432 | | |
432 | 433 | | |
433 | | - | |
| 434 | + | |
| 435 | + | |
434 | 436 | | |
435 | 437 | | |
436 | 438 | | |
437 | 439 | | |
438 | 440 | | |
439 | | - | |
| 441 | + | |
440 | 442 | | |
441 | 443 | | |
442 | 444 | | |
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | 448 | | |
453 | 449 | | |
454 | 450 | | |
| |||
697 | 693 | | |
698 | 694 | | |
699 | 695 | | |
700 | | - | |
| 696 | + | |
701 | 697 | | |
702 | 698 | | |
703 | 699 | | |
| |||
792 | 788 | | |
793 | 789 | | |
794 | 790 | | |
795 | | - | |
| 791 | + | |
796 | 792 | | |
797 | 793 | | |
798 | 794 | | |
| |||
802 | 798 | | |
803 | 799 | | |
804 | 800 | | |
805 | | - | |
| 801 | + | |
806 | 802 | | |
807 | 803 | | |
808 | 804 | | |
| |||
823 | 819 | | |
824 | 820 | | |
825 | 821 | | |
826 | | - | |
| 822 | + | |
827 | 823 | | |
828 | 824 | | |
829 | 825 | | |
| |||
833 | 829 | | |
834 | 830 | | |
835 | 831 | | |
836 | | - | |
| 832 | + | |
837 | 833 | | |
838 | 834 | | |
839 | 835 | | |
| |||
850 | 846 | | |
851 | 847 | | |
852 | 848 | | |
853 | | - | |
| 849 | + | |
854 | 850 | | |
855 | 851 | | |
856 | 852 | | |
| |||
872 | 868 | | |
873 | 869 | | |
874 | 870 | | |
875 | | - | |
| 871 | + | |
876 | 872 | | |
877 | 873 | | |
878 | 874 | | |
| |||
895 | 891 | | |
896 | 892 | | |
897 | 893 | | |
898 | | - | |
| 894 | + | |
899 | 895 | | |
900 | 896 | | |
901 | 897 | | |
| |||
917 | 913 | | |
918 | 914 | | |
919 | 915 | | |
920 | | - | |
| 916 | + | |
921 | 917 | | |
922 | 918 | | |
923 | 919 | | |
| |||
939 | 935 | | |
940 | 936 | | |
941 | 937 | | |
942 | | - | |
| 938 | + | |
943 | 939 | | |
944 | 940 | | |
945 | 941 | | |
| |||
960 | 956 | | |
961 | 957 | | |
962 | 958 | | |
963 | | - | |
| 959 | + | |
964 | 960 | | |
965 | 961 | | |
966 | 962 | | |
| |||
981 | 977 | | |
982 | 978 | | |
983 | 979 | | |
984 | | - | |
| 980 | + | |
985 | 981 | | |
986 | 982 | | |
987 | 983 | | |
| |||
1002 | 998 | | |
1003 | 999 | | |
1004 | 1000 | | |
1005 | | - | |
| 1001 | + | |
1006 | 1002 | | |
1007 | 1003 | | |
1008 | 1004 | | |
| |||
1023 | 1019 | | |
1024 | 1020 | | |
1025 | 1021 | | |
1026 | | - | |
| 1022 | + | |
1027 | 1023 | | |
1028 | 1024 | | |
1029 | 1025 | | |
| |||
1044 | 1040 | | |
1045 | 1041 | | |
1046 | 1042 | | |
1047 | | - | |
| 1043 | + | |
1048 | 1044 | | |
1049 | 1045 | | |
1050 | 1046 | | |
| |||
1065 | 1061 | | |
1066 | 1062 | | |
1067 | 1063 | | |
1068 | | - | |
| 1064 | + | |
1069 | 1065 | | |
1070 | 1066 | | |
1071 | 1067 | | |
| |||
1086 | 1082 | | |
1087 | 1083 | | |
1088 | 1084 | | |
1089 | | - | |
| 1085 | + | |
1090 | 1086 | | |
1091 | 1087 | | |
1092 | 1088 | | |
| |||
1233 | 1229 | | |
1234 | 1230 | | |
1235 | 1231 | | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | 1232 | | |
1250 | 1233 | | |
1251 | 1234 | | |
| |||
1261 | 1244 | | |
1262 | 1245 | | |
1263 | 1246 | | |
1264 | | - | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | | - | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
1269 | 1250 | | |
1270 | 1251 | | |
1271 | 1252 | | |
1272 | 1253 | | |
| 1254 | + | |
1273 | 1255 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
| 360 | + | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
| 365 | + | |
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
| |||
376 | 377 | | |
377 | 378 | | |
378 | 379 | | |
| 380 | + | |
379 | 381 | | |
380 | 382 | | |
381 | 383 | | |
| |||
0 commit comments