Skip to content

Various changes #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 33 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ See [rust-lang/rust#35437][0].
- [x] arm/aeabi_memcpy.S
- [x] arm/aeabi_memmove.S
- [x] arm/aeabi_memset.S
- [ ] arm/aeabi_uidivmod.S
- [ ] arm/aeabi_uldivmod.S
- [x] arm/aeabi_uidivmod.S
- [x] arm/aeabi_uldivmod.S
- [ ] arm/divdf3vfp.S
- [ ] arm/divmodsi4.S
- [ ] arm/divsf3vfp.S
Expand Down Expand Up @@ -78,41 +78,30 @@ See [rust-lang/rust#35437][0].
- [ ] arm/umodsi3.S
- [ ] arm/unorddf2vfp.S
- [ ] arm/unordsf2vfp.S
- [ ] ashldi3.c
- [ ] ashlti3.c
- [ ] ashrdi3.c
- [ ] ashrti3.c
- [x] ashldi3.c
- [x] ashrdi3.c
- [ ] divdf3.c
- [ ] divdi3.c
- [ ] divsf3.c
- [ ] divsi3.c
- [ ] divti3.c
- [ ] extendhfsf2.c
- [ ] extendsfdf2.c
- [ ] fixdfdi.c
- [ ] fixdfsi.c
- [ ] fixdfti.c
- [ ] fixsfdi.c
- [ ] fixsfsi.c
- [ ] fixsfti.c
- [ ] fixunsdfdi.c
- [ ] fixunsdfsi.c
- [ ] fixunsdfti.c
- [ ] fixunssfdi.c
- [ ] fixunssfsi.c
- [ ] fixunssfti.c
- [ ] floatdidf.c
- [ ] floatdisf.c
- [ ] floatsidf.c
- [ ] floatsisf.c
- [ ] floattidf.c
- [ ] floattisf.c
- [ ] floatundidf.c
- [ ] floatundisf.c
- [ ] floatunsidf.c
- [ ] floatunsisf.c
- [ ] floatuntidf.c
- [ ] floatuntisf.c
- [ ] i386/ashldi3.S
- [ ] i386/ashrdi3.S
- [ ] i386/chkstk.S
Expand All @@ -123,36 +112,51 @@ See [rust-lang/rust#35437][0].
- [ ] i386/muldi3.S
- [ ] i386/udivdi3.S
- [ ] i386/umoddi3.S
- [ ] lshrdi3.c
- [ ] lshrti3.c
- [x] lshrdi3.c
- [ ] moddi3.c
- [ ] modsi3.c
- [ ] modti3.c
- [ ] muldf3.c
- [ ] muldi3.c
- [ ] mulodi4.c
- [ ] mulosi4.c
- [ ] muloti4.c
- [x] muldi3.c
- [x] mulodi4.c
- [x] mulosi4.c
- [ ] mulsf3.c
- [ ] multi3.c
- [ ] powidf2.c
- [ ] powisf2.c
- [ ] subdf3.c
- [ ] subsf3.c
- [ ] truncdfhf2.c
- [ ] truncdfsf2.c
- [ ] truncsfhf2.c
- [ ] udivdi3.c
- [x] udivdi3.c
- [x] udivmoddi4.c
- [x] udivmodsi4.c
- [ ] udivsi3.c
- [ ] udivti3.c
- [ ] umoddi3.c
- [ ] umodsi3.c
- [ ] umodti3.c
- [x] udivsi3.c
- [x] umoddi3.c
- [x] umodsi3.c
- [ ] x86_64/chkstk.S
- [ ] x86_64/chkstk2.S

These builtins are needed to support 128-bit integers, which are in the process of being added to Rust.

- [ ] ashlti3.c
- [ ] ashrti3.c
- [ ] divti3.c
- [ ] fixdfti.c
- [ ] fixsfti.c
- [ ] fixunsdfti.c
- [ ] fixunssfti.c
- [ ] floattidf.c
- [ ] floattisf.c
- [ ] floatuntidf.c
- [ ] floatuntisf.c
- [ ] lshrti3.c
- [ ] modti3.c
- [ ] muloti4.c
- [ ] multi3.c
- [ ] udivmodti4.c
- [ ] udivti3.c
- [ ] umodti3.c

## Unimplemented functions

These builtins involve floating-point types ("`f128`", "`f80`" and complex numbers) that are not supported by Rust.
Expand Down
87 changes: 41 additions & 46 deletions src/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,28 @@ use core::intrinsics;

// NOTE This function and the one below are implemented using assembly because they using a custom
// calling convention which can't be implemented using a normal Rust function
// TODO use `global_asm!`
#[naked]
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_uidivmod() {
asm!("push { lr }
sub sp, sp, #4
mov r2, sp
bl __udivmodsi4
ldr r1, [sp]
add sp, sp, #4
pop { pc }");
#[cfg_attr(not(test), no_mangle)]
pub unsafe fn __aeabi_uidivmod() {
asm!("push {lr}
sub sp, sp, #4
mov r2, sp
bl __udivmodsi4
ldr r1, [sp], #4
pop {pc}");
intrinsics::unreachable();
}

// TODO use `global_asm!`
#[naked]
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_uldivmod() {
asm!("push {r11, lr}
sub sp, sp, #16
add r12, sp, #8
str r12, [sp]
bl __udivmoddi4
ldr r2, [sp, #8]
ldr r3, [sp, #12]
add sp, sp, #16
pop {r11, pc}");
#[cfg_attr(not(test), no_mangle)]
pub unsafe fn __aeabi_uldivmod() {
asm!("push {lr}
sub r12, sp, #12
str r12, [sp, #-20]!
bl __udivmoddi4
ldrd r2, r3, [sp, #8]
add sp, sp, #20
pop {pc}");
intrinsics::unreachable();
}

Expand All @@ -40,55 +35,55 @@ extern "C" {

// FIXME: The `*4` and `*8` variants should be defined as aliases.

#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) {
memcpy(dest, src, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) {
memcpy(dest, src, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) {
memcpy(dest, src, n);
}

#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) {
memmove(dest, src, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) {
memmove(dest, src, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) {
memmove(dest, src, n);
}

// Note the different argument order
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) {
memset(dest, c, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) {
memset(dest, c, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) {
memset(dest, c, n);
}

#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memclr(dest: *mut u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memclr(dest: *mut u8, n: usize) {
memset(dest, 0, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
memset(dest, 0, n);
}
#[no_mangle]
pub unsafe extern "aapcs" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
#[cfg_attr(not(test), no_mangle)]
pub unsafe extern "C" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
memset(dest, 0, n);
}
Loading