Skip to content

Commit 99cd446

Browse files
committed
Use AT&T syntax to support LLVM 10
1 parent 3019fd7 commit 99cd446

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

crates/core_arch/src/x86/bt.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ use stdarch_test::assert_instr;
88
pub unsafe fn _bittest(p: *const i32, b: i32) -> u8 {
99
let r: u8;
1010
asm!(
11-
"bt [{p}], {b:e}",
11+
"btl {b:e}, ({p})",
1212
"setc {r}",
1313
p = in(reg) p,
1414
b = in(reg) b,
1515
r = out(reg_byte) r,
16-
options(readonly, nostack, pure)
16+
options(readonly, nostack, pure, att_syntax)
1717
);
1818
r
1919
}
@@ -25,12 +25,12 @@ pub unsafe fn _bittest(p: *const i32, b: i32) -> u8 {
2525
pub unsafe fn _bittestandset(p: *mut i32, b: i32) -> u8 {
2626
let r: u8;
2727
asm!(
28-
"bts [{p}], {b:e}",
28+
"btsl {b:e}, ({p})",
2929
"setc {r}",
3030
p = in(reg) p,
3131
b = in(reg) b,
3232
r = out(reg_byte) r,
33-
options(nostack)
33+
options(nostack, att_syntax)
3434
);
3535
r
3636
}
@@ -42,12 +42,12 @@ pub unsafe fn _bittestandset(p: *mut i32, b: i32) -> u8 {
4242
pub unsafe fn _bittestandreset(p: *mut i32, b: i32) -> u8 {
4343
let r: u8;
4444
asm!(
45-
"btr [{p}], {b:e}",
45+
"btrl {b:e}, ({p})",
4646
"setc {r}",
4747
p = in(reg) p,
4848
b = in(reg) b,
4949
r = out(reg_byte) r,
50-
options(nostack)
50+
options(nostack, att_syntax)
5151
);
5252
r
5353
}
@@ -59,12 +59,12 @@ pub unsafe fn _bittestandreset(p: *mut i32, b: i32) -> u8 {
5959
pub unsafe fn _bittestandcomplement(p: *mut i32, b: i32) -> u8 {
6060
let r: u8;
6161
asm!(
62-
"btc [{p}], {b:e}",
62+
"btcl {b:e}, ({p})",
6363
"setc {r}",
6464
p = in(reg) p,
6565
b = in(reg) b,
6666
r = out(reg_byte) r,
67-
options(nostack)
67+
options(nostack, att_syntax)
6868
);
6969
r
7070
}

crates/core_arch/src/x86/cpuid.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,27 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult {
6161
#[cfg(target_arch = "x86")]
6262
{
6363
asm!(
64-
"mov {0}, ebx",
64+
"movl %ebx, {0}",
6565
"cpuid",
66-
"xchg {0}, ebx",
66+
"xchgl %ebx, {0}",
6767
lateout(reg) ebx,
6868
inlateout("eax") leaf => eax,
6969
inlateout("ecx") sub_leaf => ecx,
7070
lateout("edx") edx,
71-
options(nostack, preserves_flags),
71+
options(nostack, preserves_flags, att_syntax),
7272
);
7373
}
7474
#[cfg(target_arch = "x86_64")]
7575
{
7676
asm!(
77-
"mov {0:r}, rbx",
77+
"movq %rbx, {0:r}",
7878
"cpuid",
79-
"xchg {0:r}, rbx",
79+
"xchgq %rbx, {0:r}",
8080
lateout(reg) ebx,
8181
inlateout("eax") leaf => eax,
8282
inlateout("ecx") sub_leaf => ecx,
8383
lateout("edx") edx,
84-
options(nostack, preserves_flags),
84+
options(nostack, preserves_flags, att_syntax),
8585
);
8686
}
8787
CpuidResult { eax, ebx, ecx, edx }
@@ -130,20 +130,20 @@ pub fn has_cpuid() -> bool {
130130
// Read eflags and save a copy of it
131131
"pushfd",
132132
"pop {result}",
133-
"mov {saved_flags}, {result}",
133+
"mov {result}, {saved_flags}",
134134
// Flip 21st bit of the flags
135-
"xor {result}, 0x200000",
135+
"xor $0x200000, {result}",
136136
// Load the modified flags and read them back.
137137
// Bit 21 can only be modified if cpuid is available.
138138
"push {result}",
139139
"popfd",
140140
"pushfd",
141141
"pop {result}",
142142
// Use xor to find out whether bit 21 has changed
143-
"xor {result}, {saved_flags}",
143+
"xor {saved_flags}, {result}",
144144
result = out(reg) result,
145145
saved_flags = out(reg) _,
146-
options(nomem),
146+
options(nomem, att_syntax),
147147
);
148148
// There is a race between popfd (A) and pushfd (B)
149149
// where other bits beyond 21st may have been modified due to

crates/core_arch/src/x86/eflags.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#[doc(hidden)]
1414
pub unsafe fn __readeflags() -> u32 {
1515
let eflags: u32;
16-
asm!("pushfd", "pop {}", out(reg) eflags, options(nomem));
16+
asm!("pushfd", "pop {}", out(reg) eflags, options(nomem, att_syntax));
1717
eflags
1818
}
1919

@@ -30,7 +30,7 @@ pub unsafe fn __readeflags() -> u32 {
3030
#[doc(hidden)]
3131
pub unsafe fn __readeflags() -> u64 {
3232
let eflags: u64;
33-
asm!("pushfq", "pop {}", out(reg) eflags, options(nomem));
33+
asm!("pushfq", "pop {}", out(reg) eflags, options(nomem, att_syntax));
3434
eflags
3535
}
3636

@@ -46,7 +46,7 @@ pub unsafe fn __readeflags() -> u64 {
4646
)]
4747
#[doc(hidden)]
4848
pub unsafe fn __writeeflags(eflags: u32) {
49-
asm!("push {}", "popfd", in(reg) eflags, options(nomem));
49+
asm!("push {}", "popfd", in(reg) eflags, options(nomem, att_syntax));
5050
}
5151

5252
/// Write EFLAGS.
@@ -61,7 +61,7 @@ pub unsafe fn __writeeflags(eflags: u32) {
6161
)]
6262
#[doc(hidden)]
6363
pub unsafe fn __writeeflags(eflags: u64) {
64-
asm!("push {}", "popfq", in(reg) eflags, options(nomem));
64+
asm!("push {}", "popfq", in(reg) eflags, options(nomem, att_syntax));
6565
}
6666

6767
#[cfg(test)]

crates/core_arch/src/x86_64/bt.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ use stdarch_test::assert_instr;
88
pub unsafe fn _bittest64(p: *const i64, b: i64) -> u8 {
99
let r: u8;
1010
asm!(
11-
"bt [{p}], {b}",
11+
"btq {b}, ({p})",
1212
"setc {r}",
1313
p = in(reg) p,
1414
b = in(reg) b,
1515
r = out(reg_byte) r,
16-
options(readonly, nostack, pure)
16+
options(readonly, nostack, pure, att_syntax)
1717
);
1818
r
1919
}
@@ -25,12 +25,12 @@ pub unsafe fn _bittest64(p: *const i64, b: i64) -> u8 {
2525
pub unsafe fn _bittestandset64(p: *mut i64, b: i64) -> u8 {
2626
let r: u8;
2727
asm!(
28-
"bts [{p}], {b}",
28+
"btsq {b}, ({p})",
2929
"setc {r}",
3030
p = in(reg) p,
3131
b = in(reg) b,
3232
r = out(reg_byte) r,
33-
options(nostack)
33+
options(nostack, att_syntax)
3434
);
3535
r
3636
}
@@ -42,12 +42,12 @@ pub unsafe fn _bittestandset64(p: *mut i64, b: i64) -> u8 {
4242
pub unsafe fn _bittestandreset64(p: *mut i64, b: i64) -> u8 {
4343
let r: u8;
4444
asm!(
45-
"btr [{p}], {b}",
45+
"btrq {b}, ({p})",
4646
"setc {r}",
4747
p = in(reg) p,
4848
b = in(reg) b,
4949
r = out(reg_byte) r,
50-
options(nostack)
50+
options(nostack, att_syntax)
5151
);
5252
r
5353
}
@@ -59,12 +59,12 @@ pub unsafe fn _bittestandreset64(p: *mut i64, b: i64) -> u8 {
5959
pub unsafe fn _bittestandcomplement64(p: *mut i64, b: i64) -> u8 {
6060
let r: u8;
6161
asm!(
62-
"btc [{p}], {b}",
62+
"btcq {b}, ({p})",
6363
"setc {r}",
6464
p = in(reg) p,
6565
b = in(reg) b,
6666
r = out(reg_byte) r,
67-
options(nostack)
67+
options(nostack, att_syntax)
6868
);
6969
r
7070
}

0 commit comments

Comments
 (0)