Commit 080d545
committed
Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa
Implement sym operands for global_asm!
Tracking issue: #93333
This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are:
- At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`.
- At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails).
- `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`.
- `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to.
- The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression.
- At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details.
- On Mach-O, all symbols have a leading underscore.
- On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall.
- No mangling is needed on other platforms.
r? `@nagisa`
cc `@eddyb`File tree
50 files changed
+654
-245
lines changed- compiler
- rustc_ast_lowering/src
- rustc_ast_pretty/src/pprust
- rustc_ast/src
- rustc_builtin_macros/src
- rustc_codegen_gcc/src
- rustc_codegen_llvm/src
- llvm
- rustc_codegen_ssa/src
- traits
- rustc_hir_pretty/src
- rustc_hir/src
- rustc_llvm/llvm-wrapper
- rustc_middle/src
- thir
- rustc_mir_build/src
- build/expr
- thir/cx
- rustc_monomorphize/src
- rustc_passes/src
- rustc_resolve/src
- rustc_typeck/src
- check
- collect
- src
- test
- assembly/asm
- ui/asm
- aarch64
- x86_64
- tools/clippy
- clippy_lints/src
- loops
- utils
- clippy_utils/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
50 files changed
+654
-245
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2061 | 2061 | | |
2062 | 2062 | | |
2063 | 2063 | | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
2064 | 2078 | | |
2065 | 2079 | | |
2066 | 2080 | | |
| |||
2090 | 2104 | | |
2091 | 2105 | | |
2092 | 2106 | | |
2093 | | - | |
| 2107 | + | |
2094 | 2108 | | |
2095 | 2109 | | |
2096 | 2110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
283 | 291 | | |
284 | 292 | | |
285 | 293 | | |
| |||
1019 | 1027 | | |
1020 | 1028 | | |
1021 | 1029 | | |
1022 | | - | |
| 1030 | + | |
1023 | 1031 | | |
1024 | 1032 | | |
1025 | 1033 | | |
| |||
1237 | 1245 | | |
1238 | 1246 | | |
1239 | 1247 | | |
1240 | | - | |
| 1248 | + | |
1241 | 1249 | | |
1242 | 1250 | | |
1243 | 1251 | | |
1244 | 1252 | | |
1245 | | - | |
1246 | | - | |
| 1253 | + | |
1247 | 1254 | | |
1248 | 1255 | | |
1249 | 1256 | | |
1250 | 1257 | | |
1251 | 1258 | | |
1252 | 1259 | | |
1253 | 1260 | | |
1254 | | - | |
| 1261 | + | |
| 1262 | + | |
1255 | 1263 | | |
1256 | 1264 | | |
1257 | 1265 | | |
1258 | 1266 | | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
1259 | 1276 | | |
1260 | 1277 | | |
1261 | 1278 | | |
| |||
1374 | 1391 | | |
1375 | 1392 | | |
1376 | 1393 | | |
1377 | | - | |
| 1394 | + | |
1378 | 1395 | | |
1379 | 1396 | | |
1380 | 1397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
217 | 223 | | |
218 | 224 | | |
219 | 225 | | |
| |||
717 | 723 | | |
718 | 724 | | |
719 | 725 | | |
720 | | - | |
| 726 | + | |
721 | 727 | | |
722 | 728 | | |
723 | 729 | | |
724 | 730 | | |
725 | | - | |
726 | | - | |
| 731 | + | |
727 | 732 | | |
728 | 733 | | |
729 | 734 | | |
| |||
732 | 737 | | |
733 | 738 | | |
734 | 739 | | |
| 740 | + | |
735 | 741 | | |
736 | 742 | | |
737 | 743 | | |
738 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
739 | 752 | | |
740 | 753 | | |
741 | 754 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| 11 | + | |
| 12 | + | |
8 | 13 | | |
9 | | - | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
191 | | - | |
| 196 | + | |
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
| |||
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
201 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
202 | 254 | | |
203 | 255 | | |
204 | 256 | | |
| |||
260 | 312 | | |
261 | 313 | | |
262 | 314 | | |
263 | | - | |
| 315 | + | |
| 316 | + | |
264 | 317 | | |
265 | 318 | | |
266 | 319 | | |
| |||
308 | 361 | | |
309 | 362 | | |
310 | 363 | | |
311 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
312 | 367 | | |
313 | 368 | | |
314 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1266 | 1266 | | |
1267 | 1267 | | |
1268 | 1268 | | |
1269 | | - | |
| 1269 | + | |
1270 | 1270 | | |
1271 | 1271 | | |
1272 | | - | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
1273 | 1277 | | |
1274 | 1278 | | |
1275 | 1279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
168 | 170 | | |
169 | 171 | | |
170 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
261 | 264 | | |
262 | 265 | | |
263 | 266 | | |
| 267 | + | |
| 268 | + | |
264 | 269 | | |
265 | 270 | | |
266 | 271 | | |
| |||
412 | 417 | | |
413 | 418 | | |
414 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
415 | 423 | | |
416 | 424 | | |
417 | 425 | | |
418 | 426 | | |
419 | 427 | | |
420 | | - | |
421 | | - | |
| 428 | + | |
| 429 | + | |
422 | 430 | | |
423 | 431 | | |
424 | 432 | | |
| |||
656 | 664 | | |
657 | 665 | | |
658 | 666 | | |
659 | | - | |
660 | | - | |
| 667 | + | |
| 668 | + | |
661 | 669 | | |
662 | 670 | | |
663 | 671 | | |
| |||
690 | 698 | | |
691 | 699 | | |
692 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
693 | 717 | | |
694 | 718 | | |
695 | 719 | | |
| |||
0 commit comments