Skip to content

Commit 07be5d5

Browse files
authored
Merge pull request #396 from JohnTitor/intel-to-att
Use the AT&T syntax to support old LLVM on rust-lang/rust
2 parents 793465e + 4d5ca5b commit 07be5d5

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

src/int/specialized_div_rem/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,13 @@ unsafe fn u128_by_u64_div_rem(duo: u128, div: u64) -> (u64, u64) {
169169
unsafe {
170170
// divides the combined registers rdx:rax (`duo` is split into two 64 bit parts to do this)
171171
// by `div`. The quotient is stored in rax and the remainder in rdx.
172+
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
172173
asm!(
173174
"div {0}",
174175
in(reg) div,
175176
inlateout("rax") duo_lo => quo,
176177
inlateout("rdx") duo_hi => rem,
177-
options(pure, nomem, nostack)
178+
options(att_syntax, pure, nomem, nostack)
178179
);
179180
}
180181
(quo, rem)
@@ -255,12 +256,13 @@ unsafe fn u64_by_u32_div_rem(duo: u64, div: u32) -> (u32, u32) {
255256
unsafe {
256257
// divides the combined registers rdx:rax (`duo` is split into two 32 bit parts to do this)
257258
// by `div`. The quotient is stored in rax and the remainder in rdx.
259+
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
258260
asm!(
259261
"div {0}",
260262
in(reg) div,
261263
inlateout("rax") duo_lo => quo,
262264
inlateout("rdx") duo_hi => rem,
263-
options(pure, nomem, nostack)
265+
options(att_syntax, pure, nomem, nostack)
264266
);
265267
}
266268
(quo, rem)

src/mem/x86_64.rs

+23-18
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
#[inline(always)]
2020
#[cfg(target_feature = "ermsb")]
2121
pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, count: usize) {
22+
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
2223
asm!(
23-
"rep movsb [rdi], [rsi]",
24+
"repe movsb (%rsi), (%rdi)",
2425
inout("rcx") count => _,
2526
inout("rdi") dest => _,
2627
inout("rsi") src => _,
27-
options(nostack, preserves_flags)
28+
options(att_syntax, nostack, preserves_flags)
2829
);
2930
}
3031

@@ -33,47 +34,50 @@ pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, count: usize) {
3334
pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, count: usize) {
3435
let qword_count = count >> 3;
3536
let byte_count = count & 0b111;
37+
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
3638
asm!(
37-
"rep movsq [rdi], [rsi]",
38-
"mov ecx, {byte_count:e}",
39-
"rep movsb [rdi], [rsi]",
39+
"repe movsq (%rsi), (%rdi)",
40+
"mov {byte_count:e}, %ecx",
41+
"repe movsb (%rsi), (%rdi)",
4042
byte_count = in(reg) byte_count,
4143
inout("rcx") qword_count => _,
4244
inout("rdi") dest => _,
4345
inout("rsi") src => _,
44-
options(nostack, preserves_flags)
46+
options(att_syntax, nostack, preserves_flags)
4547
);
4648
}
4749

4850
#[inline(always)]
4951
pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) {
5052
let qword_count = count >> 3;
5153
let byte_count = count & 0b111;
54+
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
5255
asm!(
5356
"std",
54-
"rep movsq [rdi], [rsi]",
55-
"mov ecx, {byte_count:e}",
56-
"add rdi, 7",
57-
"add rsi, 7",
58-
"rep movsb [rdi], [rsi]",
57+
"repe movsq (%rsi), (%rdi)",
58+
"movl {byte_count:e}, %ecx",
59+
"addq $7, %rdi",
60+
"addq $7, %rsi",
61+
"repe movsb (%rsi), (%rdi)",
5962
"cld",
6063
byte_count = in(reg) byte_count,
6164
inout("rcx") qword_count => _,
6265
inout("rdi") dest.add(count).wrapping_sub(8) => _,
6366
inout("rsi") src.add(count).wrapping_sub(8) => _,
64-
options(nostack)
67+
options(att_syntax, nostack)
6568
);
6669
}
6770

6871
#[inline(always)]
6972
#[cfg(target_feature = "ermsb")]
7073
pub unsafe fn set_bytes(dest: *mut u8, c: u8, count: usize) {
74+
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
7175
asm!(
72-
"rep stosb [rdi], al",
76+
"repe stosb %al, (%rdi)",
7377
inout("rcx") count => _,
7478
inout("rdi") dest => _,
7579
inout("al") c => _,
76-
options(nostack, preserves_flags)
80+
options(att_syntax, nostack, preserves_flags)
7781
)
7882
}
7983

@@ -82,14 +86,15 @@ pub unsafe fn set_bytes(dest: *mut u8, c: u8, count: usize) {
8286
pub unsafe fn set_bytes(dest: *mut u8, c: u8, count: usize) {
8387
let qword_count = count >> 3;
8488
let byte_count = count & 0b111;
89+
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
8590
asm!(
86-
"rep stosq [rdi], rax",
87-
"mov ecx, {byte_count:e}",
88-
"rep stosb [rdi], al",
91+
"repe stosq %rax, (%rdi)",
92+
"mov {byte_count:e}, %ecx",
93+
"repe stosb %al, (%rdi)",
8994
byte_count = in(reg) byte_count,
9095
inout("rcx") qword_count => _,
9196
inout("rdi") dest => _,
9297
in("rax") (c as u64) * 0x0101010101010101,
93-
options(nostack, preserves_flags)
98+
options(att_syntax, nostack, preserves_flags)
9499
);
95100
}

0 commit comments

Comments
 (0)