Skip to content

Commit ea310d9

Browse files
committed
Reserve x18 on AArch64 and un-reserve x16
1 parent 09cfb24 commit ea310d9

File tree

3 files changed

+9
-10
lines changed
  • compiler/rustc_target/src/asm
  • library/std/src/sys/sgx/ext
  • src/doc/unstable-book/src/library-features

3 files changed

+9
-10
lines changed

compiler/rustc_target/src/asm/aarch64.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def_regs! {
8383
x13: reg = ["x13", "w13"],
8484
x14: reg = ["x14", "w14"],
8585
x15: reg = ["x15", "w15"],
86+
x16: reg = ["x16", "w16"],
8687
x17: reg = ["x17", "w17"],
87-
x18: reg = ["x18", "w18"],
8888
x20: reg = ["x20", "w20"],
8989
x21: reg = ["x21", "w21"],
9090
x22: reg = ["x22", "w22"],
@@ -127,8 +127,8 @@ def_regs! {
127127
v29: vreg = ["v29", "b29", "h29", "s29", "d29", "q29"],
128128
v30: vreg = ["v30", "b30", "h30", "s30", "d30", "q30"],
129129
v31: vreg = ["v31", "b31", "h31", "s31", "d31", "q31"],
130-
#error = ["x16", "w16"] =>
131-
"x16 is used internally by LLVM and cannot be used as an operand for inline asm",
130+
#error = ["x18", "w18"] =>
131+
"x18 is used as a reserved register on some targets and cannot be used as an operand for inline asm",
132132
#error = ["x19", "w19"] =>
133133
"x19 is used internally by LLVM and cannot be used as an operand for inline asm",
134134
#error = ["x29", "w29", "fp", "wfp"] =>

library/std/src/sys/sgx/ext/arch.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32>
3333

3434
asm!(
3535
// rbx is reserved by LLVM
36-
"xchg {}, rbx",
36+
"xchg {0}, rbx",
3737
"enclu",
38-
"mov rbx, {}",
38+
"mov rbx, {0}",
3939
inout(reg) request => _,
4040
inlateout("eax") ENCLU_EGETKEY => error,
4141
in("rcx") out.as_mut_ptr(),
@@ -64,9 +64,9 @@ pub fn ereport(
6464

6565
asm!(
6666
// rbx is reserved by LLVM
67-
"xchg {}, rbx",
67+
"xchg {0}, rbx",
6868
"enclu",
69-
"mov rbx, {}",
69+
"mov rbx, {0}",
7070
inout(reg) targetinfo => _,
7171
in("eax") ENCLU_EREPORT,
7272
in("rcx") reportdata,

src/doc/unstable-book/src/library-features/asm.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ Some registers cannot be used for input or output operands:
681681
| x86 | `mm[0-7]` | MMX registers are not currently supported (but may be in the future). |
682682
| x86 | `st([0-7])` | x87 registers are not currently supported (but may be in the future). |
683683
| AArch64 | `xzr` | This is a constant zero register which can't be modified. |
684-
| AArch64 | `x16` | This is used internally by LLVM for speculative load hardening. |
685684
| ARM | `pc` | This is the program counter, not a real register. |
686685
| ARM | `r9` | This is a reserved register on some ARM targets. |
687686
| MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. |
@@ -695,8 +694,8 @@ Some registers cannot be used for input or output operands:
695694

696695
In some cases LLVM will allocate a "reserved register" for `reg` operands even though this register cannot be explicitly specified. Assembly code making use of reserved registers should be careful since `reg` operands may alias with those registers. Reserved registers are the frame pointer and base pointer
697696
- The frame pointer and LLVM base pointer on all architectures.
698-
- `x16` on AArch64.
699-
- `r6` and `r9` on ARM.
697+
- `r9` on ARM.
698+
- `x18` on AArch64.
700699

701700
## Template modifiers
702701

0 commit comments

Comments
 (0)