Skip to content

Commit 275acf2

Browse files
committed
Remove remaining traces of AT&T assembly syntax
1 parent da8b582 commit 275acf2

File tree

4 files changed

+53
-60
lines changed

4 files changed

+53
-60
lines changed

compiler-builtins/src/int/specialized_div_rem/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,12 @@ unsafe fn u128_by_u64_div_rem(duo: u128, div: u64) -> (u64, u64) {
196196
unsafe {
197197
// divides the combined registers rdx:rax (`duo` is split into two 64 bit parts to do this)
198198
// by `div`. The quotient is stored in rax and the remainder in rdx.
199-
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
200199
core::arch::asm!(
201200
"div {0}",
202201
in(reg) div,
203202
inlateout("rax") duo_lo => quo,
204203
inlateout("rdx") duo_hi => rem,
205-
options(att_syntax, pure, nomem, nostack)
204+
options(pure, nomem, nostack),
206205
);
207206
}
208207
(quo, rem)
@@ -283,13 +282,12 @@ unsafe fn u64_by_u32_div_rem(duo: u64, div: u32) -> (u32, u32) {
283282
unsafe {
284283
// divides the combined registers rdx:rax (`duo` is split into two 32 bit parts to do this)
285284
// by `div`. The quotient is stored in rax and the remainder in rdx.
286-
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
287285
core::arch::asm!(
288286
"div {0}",
289287
in(reg) div,
290288
inlateout("rax") duo_lo => quo,
291289
inlateout("rdx") duo_hi => rem,
292-
options(att_syntax, pure, nomem, nostack)
290+
options(pure, nomem, nostack),
293291
);
294292
}
295293
(quo, rem)

compiler-builtins/src/mem/x86_64.rs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ use core::{intrinsics, mem};
2222
#[inline(always)]
2323
#[cfg(target_feature = "ermsb")]
2424
pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, count: usize) {
25-
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
26-
core::arch::asm!(
27-
"repe movsb (%rsi), (%rdi)",
25+
asm!(
26+
"repe movsb [rdi], [rsi]",
2827
inout("rcx") count => _,
2928
inout("rdi") dest => _,
3029
inout("rsi") src => _,
31-
options(att_syntax, nostack, preserves_flags)
30+
options(nostack, preserves_flags)
3231
);
3332
}
3433

@@ -42,21 +41,21 @@ pub unsafe fn copy_forward(mut dest: *mut u8, mut src: *const u8, count: usize)
4241
inout("ecx") pre_byte_count => _,
4342
inout("rdi") dest => dest,
4443
inout("rsi") src => src,
45-
options(att_syntax, nostack, preserves_flags)
44+
options(nostack, preserves_flags)
4645
);
4746
asm!(
4847
"rep movsq",
4948
inout("rcx") qword_count => _,
5049
inout("rdi") dest => dest,
5150
inout("rsi") src => src,
52-
options(att_syntax, nostack, preserves_flags)
51+
options(nostack, preserves_flags)
5352
);
5453
asm!(
5554
"rep movsb",
5655
inout("ecx") byte_count => _,
5756
inout("rdi") dest => _,
5857
inout("rsi") src => _,
59-
options(att_syntax, nostack, preserves_flags)
58+
options(nostack, preserves_flags)
6059
);
6160
}
6261

@@ -67,14 +66,14 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) {
6766
asm!(
6867
"std",
6968
"rep movsb",
70-
"sub $7, %rsi",
71-
"sub $7, %rdi",
72-
"mov {qword_count}, %rcx",
69+
"sub rsi, 7",
70+
"sub rdi, 7",
71+
"mov rcx, {qword_count}",
7372
"rep movsq",
7473
"test {pre_byte_count:e}, {pre_byte_count:e}",
75-
"add $7, %rsi",
76-
"add $7, %rdi",
77-
"mov {pre_byte_count:e}, %ecx",
74+
"add rsi, 7",
75+
"add rdi, 7",
76+
"mov ecx, {pre_byte_count:e}",
7877
"rep movsb",
7978
"cld",
8079
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) {
8382
inout("rdi") dest.add(count - 1) => _,
8483
inout("rsi") src.add(count - 1) => _,
8584
// We modify flags, but we restore it afterwards
86-
options(att_syntax, nostack, preserves_flags)
85+
options(nostack, preserves_flags)
8786
);
8887
}
8988

9089
#[inline(always)]
9190
#[cfg(target_feature = "ermsb")]
9291
pub unsafe fn set_bytes(dest: *mut u8, c: u8, count: usize) {
93-
// FIXME: Use the Intel syntax once we drop LLVM 9 support on rust-lang/rust.
94-
core::arch::asm!(
95-
"repe stosb %al, (%rdi)",
92+
asm!(
93+
"repe stosb [rdi], al",
9694
inout("rcx") count => _,
9795
inout("rdi") dest => _,
9896
inout("al") c => _,
99-
options(att_syntax, nostack, preserves_flags)
97+
options(nostack, preserves_flags)
10098
)
10199
}
102100

@@ -111,21 +109,21 @@ pub unsafe fn set_bytes(mut dest: *mut u8, c: u8, count: usize) {
111109
inout("ecx") pre_byte_count => _,
112110
inout("rdi") dest => dest,
113111
in("rax") c,
114-
options(att_syntax, nostack, preserves_flags)
112+
options(nostack, preserves_flags)
115113
);
116114
asm!(
117115
"rep stosq",
118116
inout("rcx") qword_count => _,
119117
inout("rdi") dest => dest,
120118
in("rax") c,
121-
options(att_syntax, nostack, preserves_flags)
119+
options(nostack, preserves_flags)
122120
);
123121
asm!(
124122
"rep stosb",
125123
inout("ecx") byte_count => _,
126124
inout("rdi") dest => _,
127125
in("rax") c,
128-
options(att_syntax, nostack, preserves_flags)
126+
options(nostack, preserves_flags)
129127
);
130128
}
131129

@@ -212,10 +210,10 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize {
212210
let x = {
213211
let r;
214212
asm!(
215-
"movdqa ({addr}), {dest}",
213+
"movdqa {dest}, [{addr}]",
216214
addr = in(reg) s,
217215
dest = out(xmm_reg) r,
218-
options(att_syntax, nostack),
216+
options(nostack, preserves_flags),
219217
);
220218
r
221219
};
@@ -232,10 +230,10 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize {
232230
let x = {
233231
let r;
234232
asm!(
235-
"movdqa ({addr}), {dest}",
233+
"movdqa {dest}, [{addr}]",
236234
addr = in(reg) s,
237235
dest = out(xmm_reg) r,
238-
options(att_syntax, nostack),
236+
options(nostack, preserves_flags),
239237
);
240238
r
241239
};
@@ -277,10 +275,10 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize {
277275
let mut cs = {
278276
let r: u64;
279277
asm!(
280-
"mov ({addr}), {dest}",
278+
"mov {dest}, [{addr}]",
281279
addr = in(reg) s,
282280
dest = out(reg) r,
283-
options(att_syntax, nostack),
281+
options(nostack, preserves_flags),
284282
);
285283
r
286284
};

compiler-builtins/src/x86.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ intrinsics! {
1616
pub unsafe extern "C" fn __chkstk() {
1717
core::arch::naked_asm!(
1818
"jmp __alloca", // Jump to __alloca since fallthrough may be unreliable"
19-
options(att_syntax)
2019
);
2120
}
2221

@@ -28,26 +27,25 @@ intrinsics! {
2827
pub unsafe extern "C" fn _alloca() {
2928
// __chkstk and _alloca are the same function
3029
core::arch::naked_asm!(
31-
"push %ecx",
32-
"cmp $0x1000,%eax",
33-
"lea 8(%esp),%ecx", // esp before calling this routine -> ecx
30+
"push ecx",
31+
"cmp eax, 0x1000",
32+
"lea ecx, [esp + 8]", // esp before calling this routine -> ecx
3433
"jb 1f",
3534
"2:",
36-
"sub $0x1000,%ecx",
37-
"test %ecx,(%ecx)",
38-
"sub $0x1000,%eax",
39-
"cmp $0x1000,%eax",
35+
"sub ecx, 0x1000",
36+
"test [ecx], ecx",
37+
"sub eax, 0x1000",
38+
"cmp eax, 0x1000",
4039
"ja 2b",
4140
"1:",
42-
"sub %eax,%ecx",
43-
"test %ecx,(%ecx)",
44-
"lea 4(%esp),%eax", // load pointer to the return address into eax
45-
"mov %ecx,%esp", // install the new top of stack pointer into esp
46-
"mov -4(%eax),%ecx", // restore ecx
47-
"push (%eax)", // push return address onto the stack
48-
"sub %esp,%eax", // restore the original value in eax
41+
"sub ecx, eax",
42+
"test [ecx], ecx",
43+
"lea eax, [esp + 4]", // load pointer to the return address into eax
44+
"mov esp, ecx", // install the new top of stack pointer into esp
45+
"mov ecx, [eax - 4]", // restore ecx
46+
"push [eax]", // push return address onto the stack
47+
"sub eax, esp", // restore the original value in eax
4948
"ret",
50-
options(att_syntax)
5149
);
5250
}
5351
}

compiler-builtins/src/x86_64.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,23 @@ intrinsics! {
1919
))]
2020
pub unsafe extern "C" fn ___chkstk_ms() {
2121
core::arch::naked_asm!(
22-
"push %rcx",
23-
"push %rax",
24-
"cmp $0x1000,%rax",
25-
"lea 24(%rsp),%rcx",
22+
"push rcx",
23+
"push rax",
24+
"cmp rax, 0x1000",
25+
"lea rcx, [rsp + 24]",
2626
"jb 1f",
2727
"2:",
28-
"sub $0x1000,%rcx",
29-
"test %rcx,(%rcx)",
30-
"sub $0x1000,%rax",
31-
"cmp $0x1000,%rax",
28+
"sub rcx, 0x1000",
29+
"test [rcx], rcx",
30+
"sub rax, 0x1000",
31+
"cmp rax, 0x1000",
3232
"ja 2b",
3333
"1:",
34-
"sub %rax,%rcx",
35-
"test %rcx,(%rcx)",
36-
"pop %rax",
37-
"pop %rcx",
34+
"sub rcx, rax",
35+
"test [rcx], rcx",
36+
"pop rax",
37+
"pop rcx",
3838
"ret",
39-
options(att_syntax)
4039
);
4140
}
4241
}

0 commit comments

Comments
 (0)