diff options
| author | bors <bors@rust-lang.org> | 2020-09-30 05:27:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-30 05:27:16 +0000 |
| commit | c0127e4dbf3a9d3a67ddb1da19f8441019aab8f8 (patch) | |
| tree | 3541ee41b1ac70c506defbfd17e95f517c77a28b /library/std/src | |
| parent | 6ac6c675744ecce378b13a34686bc3095e9ebc72 (diff) | |
| parent | d4772014d97d9d1e1da4a8228fee2dd969f56e0f (diff) | |
| download | rust-c0127e4dbf3a9d3a67ddb1da19f8441019aab8f8.tar.gz rust-c0127e4dbf3a9d3a67ddb1da19f8441019aab8f8.zip | |
Auto merge of #77292 - lzutao:std_asm, r=Amanieu
Prefer asm! in std - all in sgx module Similar to the change in #76669 but all `llvm_asm!` is gate in x86/x86_64 target. Godbolt: - https://rust.godbolt.org/z/h7nG1h - https://rust.godbolt.org/z/xx39hW
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/sgx/abi/mem.rs | 11 | ||||
| -rw-r--r-- | library/std/src/sys/sgx/ext/arch.rs | 29 |
2 files changed, 24 insertions, 16 deletions
diff --git a/library/std/src/sys/sgx/abi/mem.rs b/library/std/src/sys/sgx/abi/mem.rs index 57fd7efdd49..ffa234fccfe 100644 --- a/library/std/src/sys/sgx/abi/mem.rs +++ b/library/std/src/sys/sgx/abi/mem.rs @@ -21,8 +21,15 @@ extern "C" { #[inline(always)] #[unstable(feature = "sgx_platform", issue = "56975")] pub fn image_base() -> u64 { - let base; - unsafe { llvm_asm!("lea IMAGE_BASE(%rip),$0":"=r"(base)) }; + let base: u64; + unsafe { + asm!( + "lea IMAGE_BASE(%rip), {}", + lateout(reg) base, + // NOTE(#76738): ATT syntax is used to support LLVM 8 and 9. + options(att_syntax, nostack, preserves_flags, nomem, pure), + ) + }; base } diff --git a/library/std/src/sys/sgx/ext/arch.rs b/library/std/src/sys/sgx/ext/arch.rs index 0c97a87e2e4..7488e7e5dc9 100644 --- a/library/std/src/sys/sgx/ext/arch.rs +++ b/library/std/src/sys/sgx/ext/arch.rs @@ -31,13 +31,13 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32> let mut out = MaybeUninit::uninit(); let error; - llvm_asm!( - "enclu" - : "={eax}"(error) - : "{eax}"(ENCLU_EGETKEY), - "{rbx}"(request), - "{rcx}"(out.as_mut_ptr()) - : "flags" + asm!( + "enclu", + inlateout("eax") ENCLU_EGETKEY => error, + in("rbx") request, + in("rcx") out.as_mut_ptr(), + // NOTE(#76738): ATT syntax is used to support LLVM 8 and 9. + options(att_syntax, nostack), ); match error { @@ -60,13 +60,14 @@ pub fn ereport( unsafe { let mut report = MaybeUninit::uninit(); - llvm_asm!( - "enclu" - : /* no output registers */ - : "{eax}"(ENCLU_EREPORT), - "{rbx}"(targetinfo), - "{rcx}"(reportdata), - "{rdx}"(report.as_mut_ptr()) + asm!( + "enclu", + in("eax") ENCLU_EREPORT, + in("rbx") targetinfo, + in("rcx") reportdata, + in("rdx") report.as_mut_ptr(), + // NOTE(#76738): ATT syntax is used to support LLVM 8 and 9. + options(att_syntax, preserves_flags, nostack), ); report.assume_init() |
