-
Notifications
You must be signed in to change notification settings - Fork 232
Remove remaining traces of AT&T assembly syntax #911
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,13 +22,12 @@ use core::{intrinsics, mem}; | |||||
#[inline(always)] | ||||||
#[cfg(target_feature = "ermsb")] | ||||||
pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, count: usize) { | ||||||
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust. | ||||||
core::arch::asm!( | ||||||
"repe movsb (%rsi), (%rdi)", | ||||||
asm!( | ||||||
"repe movsb [rdi], [rsi]", | ||||||
inout("rcx") count => _, | ||||||
inout("rdi") dest => _, | ||||||
inout("rsi") src => _, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
); | ||||||
} | ||||||
|
||||||
|
@@ -42,21 +41,21 @@ pub unsafe fn copy_forward(mut dest: *mut u8, mut src: *const u8, count: usize) | |||||
inout("ecx") pre_byte_count => _, | ||||||
inout("rdi") dest => dest, | ||||||
inout("rsi") src => src, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
); | ||||||
asm!( | ||||||
"rep movsq", | ||||||
inout("rcx") qword_count => _, | ||||||
inout("rdi") dest => dest, | ||||||
inout("rsi") src => src, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
); | ||||||
asm!( | ||||||
"rep movsb", | ||||||
inout("ecx") byte_count => _, | ||||||
inout("rdi") dest => _, | ||||||
inout("rsi") src => _, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
); | ||||||
} | ||||||
|
||||||
|
@@ -67,14 +66,14 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) { | |||||
asm!( | ||||||
"std", | ||||||
"rep movsb", | ||||||
"sub $7, %rsi", | ||||||
"sub $7, %rdi", | ||||||
"mov {qword_count}, %rcx", | ||||||
"sub rsi, 7", | ||||||
"sub rdi, 7", | ||||||
"mov rcx, {qword_count}", | ||||||
"rep movsq", | ||||||
"test {pre_byte_count:e}, {pre_byte_count:e}", | ||||||
"add $7, %rsi", | ||||||
"add $7, %rdi", | ||||||
"mov {pre_byte_count:e}, %ecx", | ||||||
"add rsi, 7", | ||||||
"add rdi, 7", | ||||||
"mov ecx, {pre_byte_count:e}", | ||||||
"rep movsb", | ||||||
"cld", | ||||||
pre_byte_count = in(reg) pre_byte_count, | ||||||
|
@@ -83,20 +82,19 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) { | |||||
inout("rdi") dest.add(count - 1) => _, | ||||||
inout("rsi") src.add(count - 1) => _, | ||||||
// We modify flags, but we restore it afterwards | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
Comment on lines
84
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This definitely shouldn't have Actually, what is the point of the |
||||||
); | ||||||
} | ||||||
|
||||||
#[inline(always)] | ||||||
#[cfg(target_feature = "ermsb")] | ||||||
pub unsafe fn set_bytes(dest: *mut u8, c: u8, count: usize) { | ||||||
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust. | ||||||
core::arch::asm!( | ||||||
"repe stosb %al, (%rdi)", | ||||||
asm!( | ||||||
"repe stosb [rdi], al", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
inout("rcx") count => _, | ||||||
inout("rdi") dest => _, | ||||||
inout("al") c => _, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
) | ||||||
} | ||||||
|
||||||
|
@@ -111,21 +109,21 @@ pub unsafe fn set_bytes(mut dest: *mut u8, c: u8, count: usize) { | |||||
inout("ecx") pre_byte_count => _, | ||||||
inout("rdi") dest => dest, | ||||||
in("rax") c, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
); | ||||||
asm!( | ||||||
"rep stosq", | ||||||
inout("rcx") qword_count => _, | ||||||
inout("rdi") dest => dest, | ||||||
in("rax") c, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
); | ||||||
asm!( | ||||||
"rep stosb", | ||||||
inout("ecx") byte_count => _, | ||||||
inout("rdi") dest => _, | ||||||
in("rax") c, | ||||||
options(att_syntax, nostack, preserves_flags) | ||||||
options(nostack, preserves_flags) | ||||||
); | ||||||
} | ||||||
|
||||||
|
@@ -212,10 +210,10 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize { | |||||
let x = { | ||||||
let r; | ||||||
asm!( | ||||||
"movdqa ({addr}), {dest}", | ||||||
"movdqa {dest}, [{addr}]", | ||||||
addr = in(reg) s, | ||||||
dest = out(xmm_reg) r, | ||||||
options(att_syntax, nostack), | ||||||
options(nostack, preserves_flags), | ||||||
); | ||||||
r | ||||||
}; | ||||||
|
@@ -232,10 +230,10 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize { | |||||
let x = { | ||||||
let r; | ||||||
asm!( | ||||||
"movdqa ({addr}), {dest}", | ||||||
"movdqa {dest}, [{addr}]", | ||||||
addr = in(reg) s, | ||||||
dest = out(xmm_reg) r, | ||||||
options(att_syntax, nostack), | ||||||
options(nostack, preserves_flags), | ||||||
); | ||||||
r | ||||||
}; | ||||||
|
@@ -277,10 +275,10 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize { | |||||
let mut cs = { | ||||||
let r: u64; | ||||||
asm!( | ||||||
"mov ({addr}), {dest}", | ||||||
"mov {dest}, [{addr}]", | ||||||
addr = in(reg) s, | ||||||
dest = out(reg) r, | ||||||
options(att_syntax, nostack), | ||||||
options(nostack, preserves_flags), | ||||||
); | ||||||
r | ||||||
}; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
repe
mnemonic is for "repeat while equal" and only makes sense for the string comparison operationshttps://www.felixcloutier.com/x86/rep:repe:repz:repne:repnz
(but the encoding is the same so I guess assemblers don't care)