Skip to content
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

Replace asm with llvm_asm #26

Merged
merged 3 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#![deny(warnings)]
#![feature(asm)]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this feature can be removed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

#![feature(llvm_asm)]
#![no_std]

#[cfg(test)]
Expand Down
14 changes: 7 additions & 7 deletions src/platform/freebsd-x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(n: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -24,7 +24,7 @@ pub unsafe fn syscall0(n: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -34,7 +34,7 @@ pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -44,7 +44,7 @@ pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall3(n: usize, a1: usize, a2: usize, a3: usize) -> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3)
: "rcx", "r11", "memory"
: "volatile");
Expand All @@ -59,7 +59,7 @@ pub unsafe fn syscall4(n: usize,
a4: usize)
-> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
"{r10}"(a4)
: "rcx", "r11", "memory"
Expand All @@ -76,7 +76,7 @@ pub unsafe fn syscall5(n: usize,
a5: usize)
-> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
"{r10}"(a4), "{r8}"(a5)
: "rcx", "r11", "memory"
Expand All @@ -94,7 +94,7 @@ pub unsafe fn syscall6(n: usize,
a6: usize)
-> usize {
let ret: usize;
asm!("syscall" : "={rax}"(ret)
llvm_asm!("syscall" : "={rax}"(ret)
: "{rax}"(n), "{rdi}"(a1), "{rsi}"(a2), "{rdx}"(a3),
"{r10}"(a4), "{r8}"(a5), "{r9}"(a6)
: "rcx", "r11", "memory"
Expand Down
14 changes: 7 additions & 7 deletions src/platform/linux-aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(n: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n)
: "memory" "cc"
Expand All @@ -25,7 +25,7 @@ pub unsafe fn syscall0(n: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1)
: "memory" "cc"
Expand All @@ -36,7 +36,7 @@ pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2)
: "memory" "cc"
Expand All @@ -47,7 +47,7 @@ pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall3(n: usize, a1: usize, a2: usize, a3: usize) -> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3)
: "memory" "cc"
Expand All @@ -63,7 +63,7 @@ pub unsafe fn syscall4(n: usize,
a4: usize)
-> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3) "{x3}"(a4)
: "memory" "cc"
Expand All @@ -80,7 +80,7 @@ pub unsafe fn syscall5(n: usize,
a5: usize)
-> usize {
let ret: usize;
asm!("svc 0" : "={x0}"(ret)
llvm_asm!("svc 0" : "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3) "{x3}"(a4) "{x4}"(a5)
: "memory" "cc"
: "volatile");
Expand All @@ -97,7 +97,7 @@ pub unsafe fn syscall6(n: usize,
a6: usize)
-> usize {
let ret: usize;
asm!("svc 0"
llvm_asm!("svc 0"
: "={x0}"(ret)
: "{x8}"(n) "{x0}"(a1) "{x1}"(a2) "{x2}"(a3) "{x3}"(a4) "{x4}"(a5)
"{x5}"(a6)
Expand Down
16 changes: 8 additions & 8 deletions src/platform/linux-armeabi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(n: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n)
: "memory" "cc"
Expand All @@ -25,7 +25,7 @@ pub unsafe fn syscall0(n: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1)
: "memory" "cc"
Expand All @@ -36,7 +36,7 @@ pub unsafe fn syscall1(n: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2)
: "memory" "cc"
Expand All @@ -47,7 +47,7 @@ pub unsafe fn syscall2(n: usize, a1: usize, a2: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall3(n: usize, a1: usize, a2: usize, a3: usize) -> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3)
: "memory" "cc"
Expand All @@ -63,7 +63,7 @@ pub unsafe fn syscall4(n: usize,
a4: usize)
-> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4)
: "memory" "cc"
Expand All @@ -80,7 +80,7 @@ pub unsafe fn syscall5(n: usize,
a5: usize)
-> usize {
let ret: usize;
asm!("swi $$0" : "={r0}"(ret)
llvm_asm!("swi $$0" : "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4) "{r4}"(a5)
: "memory" "cc"
: "volatile");
Expand All @@ -97,7 +97,7 @@ pub unsafe fn syscall6(n: usize,
a6: usize)
-> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4) "{r4}"(a5)
"{r5}"(a6)
Expand All @@ -117,7 +117,7 @@ pub unsafe fn syscall7(n: usize,
a7: usize)
-> usize {
let ret: usize;
asm!("swi $$0"
llvm_asm!("swi $$0"
: "={r0}"(ret)
: "{r7}"(n) "{r0}"(a1) "{r1}"(a2) "{r2}"(a3) "{r3}"(a4) "{r4}"(a5)
"{r5}"(a6) "{r6}"(a7)
Expand Down
14 changes: 7 additions & 7 deletions src/platform/linux-mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(mut nr: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
:
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -35,7 +35,7 @@ pub unsafe fn syscall0(mut nr: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -50,7 +50,7 @@ pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(mut nr: usize, a1: usize, a2: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -69,7 +69,7 @@ pub unsafe fn syscall3(mut nr: usize,
a3: usize)
-> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -88,7 +88,7 @@ pub unsafe fn syscall4(mut nr: usize,
a3: usize,
mut a4: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -104,7 +104,7 @@ pub unsafe fn syscall5(mut nr: usize,
mut a4: usize,
a5: usize)
-> usize {
asm!(".set noat
llvm_asm!(".set noat
subu $$29,20
sw $5, 16($$29)
syscall
Expand All @@ -126,7 +126,7 @@ pub unsafe fn syscall6(mut nr: usize,
a5: usize,
a6: usize)
-> usize {
asm!(".set noat
llvm_asm!(".set noat
subu $$29,24
sw $5, 16($$29)
sw $6, 20($$29)
Expand Down
14 changes: 7 additions & 7 deletions src/platform/linux-mips64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(mut nr: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
:
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -31,7 +31,7 @@ pub unsafe fn syscall0(mut nr: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -46,7 +46,7 @@ pub unsafe fn syscall1(mut nr: usize, a1: usize) -> usize {
#[inline(always)]
pub unsafe fn syscall2(mut nr: usize, a1: usize, a2: usize) -> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -65,7 +65,7 @@ pub unsafe fn syscall3(mut nr: usize,
a3: usize)
-> usize {
let success: usize;
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "={$7}"(success)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -84,7 +84,7 @@ pub unsafe fn syscall4(mut nr: usize,
a3: usize,
mut a4: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3)
: "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -100,7 +100,7 @@ pub unsafe fn syscall5(mut nr: usize,
mut a4: usize,
a5: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3) "{$8}"(a5)
: "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand All @@ -117,7 +117,7 @@ pub unsafe fn syscall6(mut nr: usize,
a5: usize,
a6: usize)
-> usize {
asm!("syscall"
llvm_asm!("syscall"
: "+{$2}"(nr) "+{$7}"(a4)
: "{$4}"(a1) "{$5}"(a2) "{$6}"(a3) "{$8}"(a5) "{$9}"(a6)
: "$10" "$11" "$12" "$13" "$14" "$15" "$24" "$25" "memory"
Expand Down
14 changes: 7 additions & 7 deletions src/platform/linux-powerpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub mod nr;
#[inline(always)]
pub unsafe fn syscall0(mut n: usize) -> usize {
let ret: usize;
asm!("sc
llvm_asm!("sc
bns+ 1f
neg $1, $1
1:"
Expand All @@ -35,7 +35,7 @@ pub unsafe fn syscall0(mut n: usize) -> usize {

#[inline(always)]
pub unsafe fn syscall1(mut n: usize, mut a1: usize) -> usize {
asm!("sc
llvm_asm!("sc
bns+ 1f
neg $1, $1
1:"
Expand All @@ -48,7 +48,7 @@ pub unsafe fn syscall1(mut n: usize, mut a1: usize) -> usize {

#[inline(always)]
pub unsafe fn syscall2(mut n: usize, mut a1: usize, mut a2: usize) -> usize {
asm!("sc
llvm_asm!("sc
bns+ 1f
neg $1, $1
1:"
Expand All @@ -65,7 +65,7 @@ pub unsafe fn syscall3(mut n: usize,
mut a2: usize,
mut a3: usize)
-> usize {
asm!("sc
llvm_asm!("sc
bns+ 1f
neg $1, $1
1:"
Expand All @@ -83,7 +83,7 @@ pub unsafe fn syscall4(mut n: usize,
mut a3: usize,
mut a4: usize)
-> usize {
asm!("sc
llvm_asm!("sc
bns+ 1f
neg $1, $1
1:"
Expand All @@ -102,7 +102,7 @@ pub unsafe fn syscall5(mut n: usize,
mut a4: usize,
mut a5: usize)
-> usize {
asm!("sc
llvm_asm!("sc
bns+ 1f
neg $1, $1
1:"
Expand All @@ -123,7 +123,7 @@ pub unsafe fn syscall6(mut n: usize,
mut a5: usize,
mut a6: usize)
-> usize {
asm!("sc
llvm_asm!("sc
bns+ 1f
neg $1, $1
1:"
Expand Down
Loading