]>
git.proxmox.com Git - rustc.git/blob - vendor/compiler_builtins/src/x86_64.rs
1 #![allow(unused_imports)]
5 // NOTE These functions are implemented using assembly because they using a custom
6 // calling convention which can't be implemented using a normal Rust function
8 // NOTE These functions are never mangled as they are not tested against compiler-rt
9 // and mangling ___chkstk would break the `jmp ___chkstk` instruction in __alloca
14 not(feature
= "no-asm"),
15 not(feature
= "mangled-names")
19 pub unsafe fn ___chkstk_ms() {
37 ret" ::: "memory" : "volatile");
38 intrinsics
::unreachable();
44 not(feature
= "no-asm"),
45 not(feature
= "mangled-names")
49 pub unsafe fn __alloca() {
50 llvm_asm
!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx
51 jmp ___chkstk // Jump to ___chkstk since fallthrough may be unreliable"
52 ::: "memory" : "volatile");
53 intrinsics
::unreachable();
59 not(feature
= "no-asm"),
60 not(feature
= "mangled-names")
64 pub unsafe fn ___chkstk() {
69 lea 16(%rsp),%rcx // rsp before calling this routine -> rcx
81 lea 8(%rsp),%rax // load pointer to the return address into rax
82 mov %rcx,%rsp // install the new top of stack pointer into rsp
83 mov -8(%rax),%rcx // restore rcx
84 push (%rax) // push return address onto the stack
85 sub %rsp,%rax // restore the original value in rax
87 ::: "memory" : "volatile"
89 intrinsics
::unreachable();
92 // HACK(https://github.com/rust-lang/rust/issues/62785): x86_64-unknown-uefi needs special LLVM
93 // support unless we emit the _fltused
96 #[cfg(target_os = "uefi")]
97 static _fltused
: i32 = 0;