Skip to content

Commit 9bf5fd9

Browse files
committed
Add __chkstk for arm64ec-pc-windows-msvc
1 parent 18c3592 commit 9bf5fd9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

compiler-builtins/src/arm.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,25 @@ intrinsics! {
162162
pub unsafe extern "aapcs" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
163163
__aeabi_memset4(dest, n, 0);
164164
}
165+
166+
// NOTE This function is implemented using assembly because they are using
167+
// a custom calling convention
168+
#[naked]
169+
#[cfg(all(target_arch = "arm64ec", target_env = "msvc", not(feature = "no-asm")))]
170+
pub unsafe extern "C" fn __chkstk() {
171+
core::arch::naked_asm!(
172+
".p2align 2",
173+
"lsl r4, r4, #2",
174+
"mov r12, sp",
175+
"push {{ r5, r6 }}",
176+
"mov r5, r4",
177+
"1:",
178+
"sub r12, r12, 4096",
179+
"subs r5, r5, 4096",
180+
"ldr r6, [r12]",
181+
"bgt 1b",
182+
"pop {{ r5, r6 }}",
183+
"bx lr",
184+
);
185+
}
165186
}

0 commit comments

Comments
 (0)