Update tests to use llvm_asm!

This commit is contained in:
Amanieu d'Antras 2020-02-14 16:54:40 +00:00
parent d162d096dd
commit 1cc521ef9d
74 changed files with 421 additions and 401 deletions

View File

@ -7,7 +7,7 @@ assembly call.
In particular, it can happen if you forgot the closing bracket of a register
constraint (see issue #51430):
```compile_fail,E0668
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
let rax: u64;

View File

@ -1,6 +1,6 @@
// compile-flags: -O
#![feature(asm)]
#![feature(llvm_asm)]
#![crate_type = "lib"]
// Check that inline assembly expressions without any outputs
@ -9,6 +9,6 @@
// CHECK-LABEL: @assembly
#[no_mangle]
pub fn assembly() {
unsafe { asm!("") }
unsafe { llvm_asm!("") }
// CHECK: tail call void asm sideeffect "", {{.*}}
}

View File

@ -3,10 +3,10 @@
// compile-flags: -C codegen-units=2
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
unsafe {
asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
}
}

View File

@ -1,9 +1,9 @@
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
unsafe {
asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
}
}

View File

@ -11,7 +11,7 @@
#![allow(warnings)]
#![feature(rustc_attrs)]
#![feature(asm)]
#![feature(llvm_asm)]
#![crate_type="rlib"]
@ -22,12 +22,12 @@
pub fn change_template(a: i32) -> i32 {
let c: i32;
unsafe {
asm!("add 1, $0"
: "=r"(c)
: "0"(a)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(c)
: "0"(a)
:
:
);
}
c
}
@ -39,12 +39,12 @@ pub fn change_template(a: i32) -> i32 {
pub fn change_template(a: i32) -> i32 {
let c: i32;
unsafe {
asm!("add 2, $0"
: "=r"(c)
: "0"(a)
:
:
);
llvm_asm!("add 2, $0"
: "=r"(c)
: "0"(a)
:
:
);
}
c
}
@ -58,12 +58,12 @@ pub fn change_output(a: i32) -> i32 {
let mut _out1: i32 = 0;
let mut _out2: i32 = 0;
unsafe {
asm!("add 1, $0"
: "=r"(_out1)
: "0"(a)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out1)
: "0"(a)
:
:
);
}
_out1
}
@ -76,12 +76,12 @@ pub fn change_output(a: i32) -> i32 {
let mut _out1: i32 = 0;
let mut _out2: i32 = 0;
unsafe {
asm!("add 1, $0"
: "=r"(_out2)
: "0"(a)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out2)
: "0"(a)
:
:
);
}
_out1
}
@ -94,12 +94,12 @@ pub fn change_output(a: i32) -> i32 {
pub fn change_input(_a: i32, _b: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
:
);
}
_out
}
@ -111,12 +111,12 @@ pub fn change_input(_a: i32, _b: i32) -> i32 {
pub fn change_input(_a: i32, _b: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "0"(_b)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "0"(_b)
:
:
);
}
_out
}
@ -129,12 +129,12 @@ pub fn change_input(_a: i32, _b: i32) -> i32 {
pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "0"(_a), "r"(_b)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "0"(_a), "r"(_b)
:
:
);
}
_out
}
@ -146,12 +146,12 @@ pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "r"(_a), "0"(_b)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "r"(_a), "0"(_b)
:
:
);
}
_out
}
@ -164,12 +164,12 @@ pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
pub fn change_clobber(_a: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
:
);
}
_out
}
@ -181,12 +181,12 @@ pub fn change_clobber(_a: i32) -> i32 {
pub fn change_clobber(_a: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
: "eax"
:
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
: "eax"
:
);
}
_out
}
@ -199,12 +199,12 @@ pub fn change_clobber(_a: i32) -> i32 {
pub fn change_options(_a: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
:
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
:
);
}
_out
}
@ -216,12 +216,12 @@ pub fn change_options(_a: i32) -> i32 {
pub fn change_options(_a: i32) -> i32 {
let _out;
unsafe {
asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
: "volatile"
);
llvm_asm!("add 1, $0"
: "=r"(_out)
: "0"(_a)
:
: "volatile"
);
}
_out
}

View File

@ -1,5 +1,5 @@
// ignore-tidy-linelength
#![feature(asm)]
#![feature(llvm_asm)]
enum Empty {}
@ -18,7 +18,7 @@ fn main() {
}
// asm instruction stops unreachable propagation to if else blocks bb4 and bb5.
unsafe { asm!("NOP"); }
unsafe { llvm_asm!("NOP"); }
match _x { }
}
}
@ -39,7 +39,7 @@ fn main() {
// StorageDead(_6);
// StorageDead(_5);
// StorageLive(_7);
// asm!(InlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// _7 = ();
// StorageDead(_7);
// StorageLive(_8);
@ -62,7 +62,7 @@ fn main() {
// StorageDead(_6);
// StorageDead(_5);
// StorageLive(_7);
// asm!(InlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// _7 = ();
// StorageDead(_7);
// StorageLive(_8);

View File

@ -1,5 +1,5 @@
// ignore-tidy-linelength
#![feature(asm)]
#![feature(llvm_asm)]
enum Empty {}
@ -13,11 +13,11 @@ fn main() {
if true {
// asm instruction stops unreachable propagation to block bb3.
unsafe { asm!("NOP"); }
unsafe { llvm_asm!("NOP"); }
_y = 21;
} else {
// asm instruction stops unreachable propagation to block bb3.
unsafe { asm!("NOP"); }
unsafe { llvm_asm!("NOP"); }
_y = 42;
}
@ -33,7 +33,7 @@ fn main() {
// }
// bb4: {
// StorageLive(_8);
// asm!(InlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// _8 = ();
// StorageDead(_8);
// _4 = const 42i32;
@ -42,7 +42,7 @@ fn main() {
// }
// bb5: {
// StorageLive(_7);
// asm!(InlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// _7 = ();
// StorageDead(_7);
// _4 = const 21i32;
@ -64,7 +64,7 @@ fn main() {
// }
// bb4: {
// StorageLive(_8);
// asm!(InlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// _8 = ();
// StorageDead(_8);
// _4 = const 42i32;
@ -73,7 +73,7 @@ fn main() {
// }
// bb5: {
// StorageLive(_7);
// asm!(InlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
// _7 = ();
// StorageDead(_7);
// _4 = const 21i32;

View File

@ -1,3 +1,3 @@
#![feature(asm)]
#![feature(llvm_asm)]
pub fn main() { unsafe { asm!("" : : : "hello", "world") }; }
pub fn main() { unsafe { llvm_asm!("" : : : "hello", "world") }; }

View File

@ -1,11 +1,11 @@
#![feature(asm)]
#![feature(llvm_asm)]
// pp-exact
pub fn main() {
unsafe {
asm!("" : : : : "volatile");
asm!("" : : : : "alignstack");
asm!("" : : : : "intel");
llvm_asm!("" : : : : "volatile");
llvm_asm!("" : : : : "alignstack");
llvm_asm!("" : : : : "intel");
}
}

View File

@ -1,8 +1,8 @@
// pp-exact
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(foo = r#"just parse this"#)]
extern crate blah as blah;
fn main() { unsafe { asm!(r###"blah"###); } }
fn main() { unsafe { llvm_asm!(r###"blah"###); } }

View File

@ -1,11 +1,11 @@
#![feature(asm)]
#![feature(llvm_asm)]
#![crate_type="lib"]
#[deny(unreachable_code)]
pub fn exit(n: usize) -> i32 {
unsafe {
// Pretend this asm is an exit() syscall.
asm!("" :: "r"(n) :: "volatile");
llvm_asm!("" :: "r"(n) :: "volatile");
// Can't actually reach this point, but rustc doesn't know that.
}
// This return value is just here to generate some extra code for a return

View File

@ -1,4 +1,4 @@
#![feature(asm, core_intrinsics)]
#![feature(llvm_asm, core_intrinsics)]
#![crate_type="lib"]
use std::intrinsics;
@ -7,7 +7,7 @@ use std::intrinsics;
pub fn exit(n: usize) -> i32 {
unsafe {
// Pretend this asm is an exit() syscall.
asm!("" :: "r"(n) :: "volatile");
llvm_asm!("" :: "r"(n) :: "volatile");
intrinsics::unreachable()
}
// This return value is just here to generate some extra code for a return

View File

@ -6,7 +6,7 @@
// ignore-arm
// ignore-aarch64
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(target_arch = "x86_64")]
pub extern "sysv64" fn all_the_registers(rdi: i64, rsi: i64, rdx: i64,
@ -54,34 +54,34 @@ pub extern "sysv64" fn large_struct_by_val(mut foo: LargeStruct) -> LargeStruct
pub fn main() {
let result: i64;
unsafe {
asm!("mov rdi, 1;
mov rsi, 2;
mov rdx, 3;
mov rcx, 4;
mov r8, 5;
mov r9, 6;
mov eax, 0x3F800000;
movd xmm0, eax;
mov eax, 0x40000000;
movd xmm1, eax;
mov eax, 0x40800000;
movd xmm2, eax;
mov eax, 0x41000000;
movd xmm3, eax;
mov eax, 0x41800000;
movd xmm4, eax;
mov eax, 0x42000000;
movd xmm5, eax;
mov eax, 0x42800000;
movd xmm6, eax;
mov eax, 0x43000000;
movd xmm7, eax;
call r10
"
: "={rax}"(result)
: "{r10}"(all_the_registers as usize)
: "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11", "cc", "memory"
: "intel", "alignstack"
llvm_asm!("mov rdi, 1;
mov rsi, 2;
mov rdx, 3;
mov rcx, 4;
mov r8, 5;
mov r9, 6;
mov eax, 0x3F800000;
movd xmm0, eax;
mov eax, 0x40000000;
movd xmm1, eax;
mov eax, 0x40800000;
movd xmm2, eax;
mov eax, 0x41000000;
movd xmm3, eax;
mov eax, 0x41800000;
movd xmm4, eax;
mov eax, 0x42000000;
movd xmm5, eax;
mov eax, 0x42800000;
movd xmm6, eax;
mov eax, 0x43000000;
movd xmm7, eax;
call r10
"
: "={rax}"(result)
: "{r10}"(all_the_registers as usize)
: "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11", "cc", "memory"
: "intel", "alignstack"
)
}
assert_eq!(result, 42);

View File

@ -2,8 +2,8 @@
// pretty-expanded FIXME #23616
// ignore-emscripten no asm
#![feature(asm)]
#![feature(llvm_asm)]
pub fn main() {
unsafe { asm!(concat!("", "")) };
unsafe { llvm_asm!(concat!("", "")) };
}

View File

@ -1,6 +1,6 @@
// run-pass
#![feature(asm)]
#![feature(llvm_asm)]
#![allow(dead_code)]
use std::cell::Cell;
@ -20,7 +20,7 @@ fn main() {
let _y: Box<NoisyDrop>;
let x = Box::new(NoisyDrop(&status));
unsafe {
asm!("mov $1, $0" : "=r"(_y) : "r"(x));
llvm_asm!("mov $1, $0" : "=r"(_y) : "r"(x));
}
assert_eq!(status.get(), "alive");
}

View File

@ -1,21 +1,21 @@
// run-pass
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
unsafe fn next_power_of_2(n: u32) -> u32 {
let mut tmp = n;
asm!("dec $0" : "+rm"(tmp) :: "cc");
llvm_asm!("dec $0" : "+rm"(tmp) :: "cc");
let mut shift = 1_u32;
while shift <= 16 {
asm!(
llvm_asm!(
"shr %cl, $2
or $2, $0
shl $$1, $1"
: "+&rm"(tmp), "+{ecx}"(shift) : "r"(tmp) : "cc"
);
}
asm!("inc $0" : "+rm"(tmp) :: "cc");
llvm_asm!("inc $0" : "+rm"(tmp) :: "cc");
return tmp;
}
@ -30,7 +30,7 @@ pub fn main() {
let x: isize;
unsafe {
// Treat the output as initialization.
asm!(
llvm_asm!(
"shl $2, $1
add $3, $1
mov $1, $0"
@ -47,7 +47,7 @@ pub fn main() {
// Assignment to mutable.
// Early clobber "&":
// Forbids the use of a single register by both operands.
asm!("shr $$2, $1; add $1, $0" : "+&r"(x) : "r"(x) : "cc");
llvm_asm!("shr $$2, $1; add $1, $0" : "+&r"(x) : "r"(x) : "cc");
}
assert_eq!(x, 60);
}

View File

@ -1,12 +1,12 @@
// run-pass
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn read(ptr: &u32) -> u32 {
let out: u32;
unsafe {
asm!("mov $1, $0" : "=r" (out) : "*m" (ptr));
llvm_asm!("mov $1, $0" : "=r" (out) : "*m" (ptr));
}
out
}
@ -14,7 +14,7 @@ fn read(ptr: &u32) -> u32 {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn write(ptr: &mut u32, val: u32) {
unsafe {
asm!("mov $1, $0" : "=*m" (ptr) : "r" (val));
llvm_asm!("mov $1, $0" : "=*m" (ptr) : "r" (val));
}
}
@ -22,7 +22,7 @@ fn write(ptr: &mut u32, val: u32) {
fn replace(ptr: &mut u32, val: u32) -> u32 {
let out: u32;
unsafe {
asm!("mov $0, $1; mov $2, $0" : "+*m" (ptr), "=&r" (out) : "r" (val));
llvm_asm!("mov $0, $1; mov $2, $0" : "+*m" (ptr), "=&r" (out) : "r" (val));
}
out
}

View File

@ -1,13 +1,13 @@
// run-pass
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn main() {
let x: isize;
unsafe {
// Treat the output as initialization.
asm!("mov $1, $0" : "=r"(x) : "r"(5_usize));
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5_usize));
}
assert_eq!(x, 5);
@ -16,7 +16,7 @@ pub fn main() {
unsafe {
// Assignment to mutable.
asm!("mov $1, $0" : "=r"(x) : "r"(x + 7));
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(x + 7));
}
assert_eq!(x, 13);
}

View File

@ -11,7 +11,7 @@
// ignore-mips
// ignore-mips64
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
@ -19,7 +19,7 @@
pub fn main() {
unsafe {
// clobber formatted as register input/output
asm!("xor %eax, %eax" : : : "{eax}");
llvm_asm!("xor %eax, %eax" : : : "{eax}");
//~^ ERROR clobber should not be surrounded by braces
}
}

View File

@ -1,8 +1,8 @@
error[E0664]: clobber should not be surrounded by braces
--> $DIR/asm-bad-clobber.rs:22:37
--> $DIR/asm-bad-clobber.rs:22:42
|
LL | asm!("xor %eax, %eax" : : : "{eax}");
| ^^^^^^^
LL | llvm_asm!("xor %eax, %eax" : : : "{eax}");
| ^^^^^^^
error: aborting due to previous error

View File

@ -8,7 +8,7 @@
// ignore-mips
// ignore-mips64
#![feature(asm)]
#![feature(llvm_asm)]
fn foo(x: isize) { println!("{}", x); }
@ -20,8 +20,8 @@ pub fn main() {
let x: isize;
let y: isize;
unsafe {
asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '='
asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+'
llvm_asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '='
llvm_asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+'
}
foo(x);
foo(y);

View File

@ -1,14 +1,14 @@
error[E0662]: input operand constraint contains '='
--> $DIR/asm-in-bad-modifier.rs:23:39
--> $DIR/asm-in-bad-modifier.rs:23:44
|
LL | asm!("mov $1, $0" : "=r"(x) : "=r"(5));
| ^^^^
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "=r"(5));
| ^^^^
error[E0663]: input operand constraint contains '+'
--> $DIR/asm-in-bad-modifier.rs:24:39
--> $DIR/asm-in-bad-modifier.rs:24:44
|
LL | asm!("mov $1, $0" : "=r"(y) : "+r"(5));
| ^^^^
LL | llvm_asm!("mov $1, $0" : "=r"(y) : "+r"(5));
| ^^^^
error: aborting due to 2 previous errors

View File

@ -1,12 +1,12 @@
// build-pass
// only-x86_64
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
unsafe {
// "nop" :: "r"(x) : "eax" : "volatile"
let x = 10;
asm!("\x6Eop" :: "\x72"(x) : "\x65ax" : "\x76olatile");
llvm_asm!("\x6Eop" :: "\x72"(x) : "\x65ax" : "\x76olatile");
}
}

View File

@ -12,7 +12,7 @@
// ignore-mips
// ignore-mips64
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
@ -21,14 +21,14 @@ fn main() {
let mut x: isize = 0;
unsafe {
// extra colon
asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
//~^ WARNING unrecognized option
}
assert_eq!(x, 5);
unsafe {
// comma in place of a colon
asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
llvm_asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
//~^ WARNING expected a clobber, found an option
}
assert_eq!(x, 13);

View File

@ -1,12 +1,12 @@
warning: unrecognized option
--> $DIR/asm-misplaced-option.rs:24:64
--> $DIR/asm-misplaced-option.rs:24:69
|
LL | asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
| ^^^^
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
| ^^^^
warning: expected a clobber, found an option
--> $DIR/asm-misplaced-option.rs:31:80
--> $DIR/asm-misplaced-option.rs:31:85
|
LL | asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
| ^^^^^^^^^^
LL | llvm_asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
| ^^^^^^^^^^

View File

@ -8,7 +8,7 @@
// ignore-mips
// ignore-mips64
#![feature(asm)]
#![feature(llvm_asm)]
fn foo(x: isize) { println!("{}", x); }
@ -21,7 +21,7 @@ pub fn main() {
x = 1;
foo(x);
unsafe {
asm!("mov $1, $0" : "=r"(x) : "r"(5));
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5));
//~^ ERROR cannot assign twice to immutable variable `x`
}
foo(x);

View File

@ -1,13 +1,13 @@
error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/asm-out-assign-imm.rs:24:34
--> $DIR/asm-out-assign-imm.rs:24:39
|
LL | let x: isize;
| - help: make this binding mutable: `mut x`
LL | x = 1;
| ----- first assignment to `x`
...
LL | asm!("mov $1, $0" : "=r"(x) : "r"(5));
| ^ cannot assign twice to immutable variable
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5));
| ^ cannot assign twice to immutable variable
error: aborting due to previous error

View File

@ -8,7 +8,7 @@
// ignore-mips
// ignore-mips64
#![feature(asm)]
#![feature(llvm_asm)]
fn foo(x: isize) { println!("{}", x); }
@ -19,7 +19,7 @@ fn foo(x: isize) { println!("{}", x); }
pub fn main() {
let x: isize;
unsafe {
asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
llvm_asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
}
foo(x);
}

View File

@ -1,8 +1,8 @@
error[E0661]: output operand constraint lacks '=' or '+'
--> $DIR/asm-out-no-modifier.rs:22:29
--> $DIR/asm-out-no-modifier.rs:22:34
|
LL | asm!("mov $1, $0" : "r"(x) : "r"(5));
| ^^^
LL | llvm_asm!("mov $1, $0" : "r"(x) : "r"(5));
| ^^^
error: aborting due to previous error

View File

@ -8,7 +8,7 @@
// ignore-mips
// ignore-mips64
#![feature(asm)]
#![feature(llvm_asm)]
fn foo(x: isize) { println!("{}", x); }
@ -19,7 +19,7 @@ fn foo(x: isize) { println!("{}", x); }
pub fn main() {
let x: isize;
unsafe {
asm!("mov $1, $0" : "=r"(x) : "r"(x));
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(x));
//~^ ERROR use of possibly-uninitialized variable: `x`
}
foo(x);

View File

@ -1,8 +1,8 @@
error[E0381]: use of possibly-uninitialized variable: `x`
--> $DIR/asm-out-read-uninit.rs:22:43
--> $DIR/asm-out-read-uninit.rs:22:48
|
LL | asm!("mov $1, $0" : "=r"(x) : "r"(x));
| ^ use of possibly-uninitialized `x`
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "r"(x));
| ^ use of possibly-uninitialized `x`
error: aborting due to previous error

View File

@ -1,15 +1,15 @@
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
asm!(); //~ ERROR requires a string literal as an argument
asm!("nop" : struct); //~ ERROR expected string literal
asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal
asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(`
asm!("mov %eax, $$0x2" : "={eax}"(struct)); //~ ERROR expected expression
asm!("in %dx, %al" : "={al}"(result) : struct); //~ ERROR expected string literal
asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct); //~ ERROR expected `(`
asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct)); //~ ERROR expected expression
asm!("mov $$0x200, %eax" : : : struct); //~ ERROR expected string literal
asm!("mov eax, 2" : "={eax}"(foo) : : : struct); //~ ERROR expected string literal
asm!(123); //~ ERROR inline assembly must be a string literal
llvm_asm!(); //~ ERROR requires a string literal as an argument
llvm_asm!("nop" : struct); //~ ERROR expected string literal
llvm_asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal
llvm_asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(`
llvm_asm!("mov %eax, $$0x2" : "={eax}"(struct)); //~ ERROR expected expression
llvm_asm!("in %dx, %al" : "={al}"(result) : struct); //~ ERROR expected string literal
llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct); //~ ERROR expected `(`
llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct)); //~ ERROR expected expression
llvm_asm!("mov $$0x200, %eax" : : : struct); //~ ERROR expected string literal
llvm_asm!("mov eax, 2" : "={eax}"(foo) : : : struct); //~ ERROR expected string literal
llvm_asm!(123); //~ ERROR inline assembly must be a string literal
}

View File

@ -1,68 +1,68 @@
error: macro requires a string literal as an argument
--> $DIR/asm-parse-errors.rs:4:5
|
LL | asm!();
| ^^^^^^^ string literal required
LL | llvm_asm!();
| ^^^^^^^^^^^^ string literal required
error: expected string literal
--> $DIR/asm-parse-errors.rs:5:18
--> $DIR/asm-parse-errors.rs:5:23
|
LL | asm!("nop" : struct);
| ^^^^^^ not a string literal
LL | llvm_asm!("nop" : struct);
| ^^^^^^ not a string literal
error: expected string literal
--> $DIR/asm-parse-errors.rs:6:30
--> $DIR/asm-parse-errors.rs:6:35
|
LL | asm!("mov %eax, $$0x2" : struct);
| ^^^^^^ not a string literal
LL | llvm_asm!("mov %eax, $$0x2" : struct);
| ^^^^^^ not a string literal
error: expected `(`, found keyword `struct`
--> $DIR/asm-parse-errors.rs:7:39
--> $DIR/asm-parse-errors.rs:7:44
|
LL | asm!("mov %eax, $$0x2" : "={eax}" struct);
| ^^^^^^ expected `(`
LL | llvm_asm!("mov %eax, $$0x2" : "={eax}" struct);
| ^^^^^^ expected `(`
error: expected expression, found keyword `struct`
--> $DIR/asm-parse-errors.rs:8:39
--> $DIR/asm-parse-errors.rs:8:44
|
LL | asm!("mov %eax, $$0x2" : "={eax}"(struct));
| ^^^^^^ expected expression
LL | llvm_asm!("mov %eax, $$0x2" : "={eax}"(struct));
| ^^^^^^ expected expression
error: expected string literal
--> $DIR/asm-parse-errors.rs:9:44
--> $DIR/asm-parse-errors.rs:9:49
|
LL | asm!("in %dx, %al" : "={al}"(result) : struct);
| ^^^^^^ not a string literal
LL | llvm_asm!("in %dx, %al" : "={al}"(result) : struct);
| ^^^^^^ not a string literal
error: expected `(`, found keyword `struct`
--> $DIR/asm-parse-errors.rs:10:51
--> $DIR/asm-parse-errors.rs:10:56
|
LL | asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct);
| ^^^^^^ expected `(`
LL | llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct);
| ^^^^^^ expected `(`
error: expected expression, found keyword `struct`
--> $DIR/asm-parse-errors.rs:11:51
--> $DIR/asm-parse-errors.rs:11:56
|
LL | asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct));
| ^^^^^^ expected expression
LL | llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct));
| ^^^^^^ expected expression
error: expected string literal
--> $DIR/asm-parse-errors.rs:12:36
--> $DIR/asm-parse-errors.rs:12:41
|
LL | asm!("mov $$0x200, %eax" : : : struct);
| ^^^^^^ not a string literal
LL | llvm_asm!("mov $$0x200, %eax" : : : struct);
| ^^^^^^ not a string literal
error: expected string literal
--> $DIR/asm-parse-errors.rs:13:45
--> $DIR/asm-parse-errors.rs:13:50
|
LL | asm!("mov eax, 2" : "={eax}"(foo) : : : struct);
| ^^^^^^ not a string literal
LL | llvm_asm!("mov eax, 2" : "={eax}"(foo) : : : struct);
| ^^^^^^ not a string literal
error: inline assembly must be a string literal
--> $DIR/asm-parse-errors.rs:14:10
--> $DIR/asm-parse-errors.rs:14:15
|
LL | asm!(123);
| ^^^
LL | llvm_asm!(123);
| ^^^
error: aborting due to 11 previous errors

View File

@ -1,11 +1,11 @@
// build-fail
// ignore-emscripten no asm! support
// ignore-emscripten no llvm_asm! support
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
unsafe {
asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
llvm_asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
//~^ ERROR: invalid value for constraint in inline assembly
}
}

View File

@ -1,8 +1,8 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/issue-51431.rs:8:32
--> $DIR/issue-51431.rs:8:37
|
LL | asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
| ^^^^
LL | llvm_asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
| ^^^^
error: aborting due to previous error

View File

@ -1,11 +1,11 @@
// build-fail
// ignore-emscripten no asm! support
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
unsafe {
asm!("nop" : "+r"("r15"));
llvm_asm!("nop" : "+r"("r15"));
//~^ malformed inline assembly
}
}

View File

@ -1,8 +1,8 @@
error[E0668]: malformed inline assembly
--> $DIR/issue-62046.rs:8:9
|
LL | asm!("nop" : "+r"("r15"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | llvm_asm!("nop" : "+r"("r15"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -2,9 +2,9 @@
// ignore-emscripten no asm! support
// Regression test for #69092
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
unsafe { asm!(".ascii \"Xen\0\""); }
unsafe { llvm_asm!(".ascii \"Xen\0\""); }
//~^ ERROR: <inline asm>:1:9: error: expected string in '.ascii' directive
}

View File

@ -4,8 +4,8 @@ error: <inline asm>:1:9: error: expected string in '.ascii' directive
--> $DIR/issue-69092.rs:8:14
|
LL | unsafe { asm!(".ascii \"Xen\0\""); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | unsafe { llvm_asm!(".ascii \"Xen\0\""); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -8,7 +8,7 @@
// check-pass
// dont-check-compiler-stdout - don't check for any AST change.
#![feature(asm)]
#![feature(llvm_asm)]
enum V {
A(i32),
@ -30,7 +30,7 @@ fn main() {
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"))]
unsafe { asm!(""::::); }
unsafe { llvm_asm!(""::::); }
let x: (i32) = 35;
let y = x as i64<> + 5;

View File

@ -6,7 +6,7 @@
// ignore-sparc
// ignore-sparc64
#![feature(asm)]
#![feature(llvm_asm)]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
@ -19,7 +19,7 @@ mod test_cases {
let y: &mut isize;
let x = &mut 0isize;
unsafe {
asm!("nop" : : "r"(x));
llvm_asm!("nop" : : "r"(x));
}
let z = x; //~ ERROR use of moved value: `x`
}
@ -28,7 +28,7 @@ mod test_cases {
let mut x = 3;
let y = &mut x;
unsafe {
asm!("nop" : : "r"(x)); //~ ERROR cannot use
llvm_asm!("nop" : : "r"(x)); //~ ERROR cannot use
}
let z = y;
}
@ -36,12 +36,12 @@ mod test_cases {
fn out_is_assign() {
let x = 3;
unsafe {
asm!("nop" : "=r"(x)); //~ ERROR cannot assign twice
llvm_asm!("nop" : "=r"(x)); //~ ERROR cannot assign twice
}
let mut a = &mut 3;
let b = &*a;
unsafe {
asm!("nop" : "=r"(a)); // OK, Shallow write to `a`
llvm_asm!("nop" : "=r"(a)); // OK, Shallow write to `a`
}
let c = b;
let d = *a;
@ -50,14 +50,14 @@ mod test_cases {
fn rw_is_assign() {
let x = 3;
unsafe {
asm!("nop" : "+r"(x)); //~ ERROR cannot assign twice
llvm_asm!("nop" : "+r"(x)); //~ ERROR cannot assign twice
}
}
fn indirect_is_not_init() {
let x: i32;
unsafe {
asm!("nop" : "=*r"(x)); //~ ERROR use of possibly-uninitialized variable
llvm_asm!("nop" : "=*r"(x)); //~ ERROR use of possibly-uninitialized variable
}
}
@ -65,7 +65,7 @@ mod test_cases {
let mut x = &mut 3;
let y = &*x;
unsafe {
asm!("nop" : "+r"(x)); //~ ERROR cannot assign to `x` because it is borrowed
llvm_asm!("nop" : "+r"(x)); //~ ERROR cannot assign to `x` because it is borrowed
}
let z = y;
}
@ -73,7 +73,7 @@ mod test_cases {
fn two_moves() {
let x = &mut 2;
unsafe {
asm!("nop" : : "r"(x), "r"(x) ); //~ ERROR use of moved value
llvm_asm!("nop" : : "r"(x), "r"(x) ); //~ ERROR use of moved value
}
}
}

View File

@ -4,26 +4,26 @@ error[E0382]: use of moved value: `x`
LL | let x = &mut 0isize;
| - move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait
LL | unsafe {
LL | asm!("nop" : : "r"(x));
| - value moved here
LL | llvm_asm!("nop" : : "r"(x));
| - value moved here
LL | }
LL | let z = x;
| ^ value used here after move
error[E0503]: cannot use `x` because it was mutably borrowed
--> $DIR/borrowck-asm.rs:31:32
--> $DIR/borrowck-asm.rs:31:37
|
LL | let y = &mut x;
| ------ borrow of `x` occurs here
LL | unsafe {
LL | asm!("nop" : : "r"(x));
| ^ use of borrowed `x`
LL | llvm_asm!("nop" : : "r"(x));
| ^ use of borrowed `x`
LL | }
LL | let z = y;
| - borrow later used here
error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/borrowck-asm.rs:39:31
--> $DIR/borrowck-asm.rs:39:36
|
LL | let x = 3;
| -
@ -31,11 +31,11 @@ LL | let x = 3;
| first assignment to `x`
| help: make this binding mutable: `mut x`
LL | unsafe {
LL | asm!("nop" : "=r"(x));
| ^ cannot assign twice to immutable variable
LL | llvm_asm!("nop" : "=r"(x));
| ^ cannot assign twice to immutable variable
error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/borrowck-asm.rs:53:31
--> $DIR/borrowck-asm.rs:53:36
|
LL | let x = 3;
| -
@ -43,37 +43,37 @@ LL | let x = 3;
| first assignment to `x`
| help: make this binding mutable: `mut x`
LL | unsafe {
LL | asm!("nop" : "+r"(x));
| ^ cannot assign twice to immutable variable
LL | llvm_asm!("nop" : "+r"(x));
| ^ cannot assign twice to immutable variable
error[E0381]: use of possibly-uninitialized variable: `x`
--> $DIR/borrowck-asm.rs:60:32
--> $DIR/borrowck-asm.rs:60:37
|
LL | asm!("nop" : "=*r"(x));
| ^ use of possibly-uninitialized `x`
LL | llvm_asm!("nop" : "=*r"(x));
| ^ use of possibly-uninitialized `x`
error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/borrowck-asm.rs:68:31
--> $DIR/borrowck-asm.rs:68:36
|
LL | let y = &*x;
| --- borrow of `x` occurs here
LL | unsafe {
LL | asm!("nop" : "+r"(x));
| ^ assignment to borrowed `x` occurs here
LL | llvm_asm!("nop" : "+r"(x));
| ^ assignment to borrowed `x` occurs here
LL | }
LL | let z = y;
| - borrow later used here
error[E0382]: use of moved value: `x`
--> $DIR/borrowck-asm.rs:76:40
--> $DIR/borrowck-asm.rs:76:45
|
LL | let x = &mut 2;
| - move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait
LL | unsafe {
LL | asm!("nop" : : "r"(x), "r"(x) );
| - ^ value used here after move
| |
| value moved here
LL | llvm_asm!("nop" : : "r"(x), "r"(x) );
| - ^ value used here after move
| |
| value moved here
error: aborting due to 7 previous errors

View File

@ -1,9 +1,9 @@
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
let a;
asm!("nop" "nop");
llvm_asm!("nop" "nop");
//~^ ERROR E0660
asm!("nop" "nop" : "=r"(a));
llvm_asm!("nop" "nop" : "=r"(a));
//~^ ERROR E0660
}

View File

@ -1,14 +1,14 @@
error[E0660]: malformed inline assembly
--> $DIR/E0660.rs:5:5
|
LL | asm!("nop" "nop");
| ^^^^^^^^^^^^^^^^^^
LL | llvm_asm!("nop" "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0660]: malformed inline assembly
--> $DIR/E0660.rs:7:5
|
LL | asm!("nop" "nop" : "=r"(a));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | llvm_asm!("nop" "nop" : "=r"(a));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -1,9 +1,9 @@
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
let a; //~ ERROR type annotations needed
asm!("nop" : "r"(a));
llvm_asm!("nop" : "r"(a));
//~^ ERROR E0661
}

View File

@ -1,8 +1,8 @@
error[E0661]: output operand constraint lacks '=' or '+'
--> $DIR/E0661.rs:7:18
--> $DIR/E0661.rs:7:23
|
LL | asm!("nop" : "r"(a));
| ^^^
LL | llvm_asm!("nop" : "r"(a));
| ^^^
error[E0282]: type annotations needed
--> $DIR/E0661.rs:6:9

View File

@ -1,10 +1,10 @@
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
asm!("xor %eax, %eax"
:
: "=test"("a") //~ ERROR E0662
);
llvm_asm!("xor %eax, %eax"
:
: "=test"("a") //~ ERROR E0662
);
}

View File

@ -1,8 +1,8 @@
error[E0662]: input operand constraint contains '='
--> $DIR/E0662.rs:8:12
--> $DIR/E0662.rs:8:17
|
LL | : "=test"("a")
| ^^^^^^^
LL | : "=test"("a")
| ^^^^^^^
error: aborting due to previous error

View File

@ -1,10 +1,10 @@
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
asm!("xor %eax, %eax"
:
: "+test"("a") //~ ERROR E0663
);
llvm_asm!("xor %eax, %eax"
:
: "+test"("a") //~ ERROR E0663
);
}

View File

@ -1,8 +1,8 @@
error[E0663]: input operand constraint contains '+'
--> $DIR/E0663.rs:8:12
--> $DIR/E0663.rs:8:17
|
LL | : "+test"("a")
| ^^^^^^^
LL | : "+test"("a")
| ^^^^^^^
error: aborting due to previous error

View File

@ -1,11 +1,11 @@
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
asm!("mov $$0x200, %eax"
:
:
: "{eax}" //~ ERROR E0664
);
llvm_asm!("mov $$0x200, %eax"
:
:
: "{eax}" //~ ERROR E0664
);
}

View File

@ -1,8 +1,8 @@
error[E0664]: clobber should not be surrounded by braces
--> $DIR/E0664.rs:9:12
--> $DIR/E0664.rs:9:17
|
LL | : "{eax}"
| ^^^^^^^
LL | : "{eax}"
| ^^^^^^^
error: aborting due to previous error

View File

@ -3,5 +3,6 @@
fn main() {
unsafe {
asm!(""); //~ ERROR inline assembly is not stable enough
llvm_asm!(""); //~ ERROR inline assembly is not stable enough
}
}

View File

@ -7,6 +7,15 @@ LL | asm!("");
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
= help: add `#![feature(asm)]` to the crate attributes to enable
error: aborting due to previous error
error[E0658]: use of unstable library feature 'llvm_asm': inline assembly is not stable enough for use and is subject to change
--> $DIR/feature-gate-asm.rs:6:9
|
LL | llvm_asm!("");
| ^^^^^^^^
|
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
= help: add `#![feature(llvm_asm)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -3,5 +3,6 @@
fn main() {
unsafe {
println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable
println!("{:?}", llvm_asm!("")); //~ ERROR inline assembly is not stable
}
}

View File

@ -7,6 +7,15 @@ LL | println!("{:?}", asm!(""));
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
= help: add `#![feature(asm)]` to the crate attributes to enable
error: aborting due to previous error
error[E0658]: use of unstable library feature 'llvm_asm': inline assembly is not stable enough for use and is subject to change
--> $DIR/feature-gate-asm2.rs:6:26
|
LL | println!("{:?}", llvm_asm!(""));
| ^^^^^^^^
|
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
= help: add `#![feature(llvm_asm)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -3,7 +3,7 @@
// build-fail
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
extern "C" {
fn foo(a: usize);
@ -19,7 +19,7 @@ fn main() {
fn bad_register_constraint() {
let rax: u64;
unsafe {
asm!("" :"={rax"(rax)) //~ ERROR E0668
llvm_asm!("" :"={rax"(rax)) //~ ERROR E0668
};
println!("Accumulator is: {}", rax);
}
@ -27,14 +27,14 @@ fn bad_register_constraint() {
// Issue #54376
fn bad_input() {
unsafe {
asm!("callq $0" : : "0"(foo)) //~ ERROR E0668
llvm_asm!("callq $0" : : "0"(foo)) //~ ERROR E0668
};
}
fn wrong_size_output() {
let rax: u64 = 0;
unsafe {
asm!("addb $1, $0" : "={rax}"((0i32, rax))); //~ ERROR E0668
llvm_asm!("addb $1, $0" : "={rax}"((0i32, rax))); //~ ERROR E0668
}
println!("rax: {}", rax);
}

View File

@ -1,24 +1,24 @@
error[E0668]: malformed inline assembly
--> $DIR/inline-asm-bad-constraint.rs:22:9
|
LL | asm!("" :"={rax"(rax))
| ^^^^^^^^^^^^^^^^^^^^^^
LL | llvm_asm!("" :"={rax"(rax))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0668]: malformed inline assembly
--> $DIR/inline-asm-bad-constraint.rs:30:9
|
LL | asm!("callq $0" : : "0"(foo))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | llvm_asm!("callq $0" : : "0"(foo))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0668]: malformed inline assembly
--> $DIR/inline-asm-bad-constraint.rs:37:9
|
LL | asm!("addb $1, $0" : "={rax}"((0i32, rax)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | llvm_asm!("addb $1, $0" : "={rax}"((0i32, rax)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -4,7 +4,7 @@
// build-fail
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
#[repr(C)]
struct MyPtr(usize);
@ -19,41 +19,41 @@ fn main() {
fn issue_37433() {
unsafe {
asm!("" :: "r"("")); //~ ERROR E0669
llvm_asm!("" :: "r"("")); //~ ERROR E0669
}
unsafe {
let target = MyPtr(0);
asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669
llvm_asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669
}
}
fn issue_37437() {
let hello: &str = "hello";
// this should fail...
unsafe { asm!("" :: "i"(hello)) }; //~ ERROR E0669
unsafe { llvm_asm!("" :: "i"(hello)) }; //~ ERROR E0669
// but this should succeed.
unsafe { asm!("" :: "r"(hello.as_ptr())) };
unsafe { llvm_asm!("" :: "r"(hello.as_ptr())) };
}
fn issue_40187() {
let arr: [u8; 1] = [0; 1];
unsafe {
asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669
llvm_asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669
}
}
fn issue_54067() {
let addr: Option<u32> = Some(123);
unsafe {
asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669
llvm_asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669
}
}
fn multiple_errors() {
let addr: (u32, u32) = (1, 2);
unsafe {
asm!("mov sp, $0"::"r"(addr), //~ ERROR E0669
"r"("hello e0669")); //~ ERROR E0669
llvm_asm!("mov sp, $0"::"r"(addr), //~ ERROR E0669
"r"("hello e0669")); //~ ERROR E0669
}
}

View File

@ -1,41 +1,41 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:22:24
--> $DIR/inline-asm-bad-operand.rs:22:29
|
LL | asm!("" :: "r"(""));
| ^^
LL | llvm_asm!("" :: "r"(""));
| ^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:27:32
--> $DIR/inline-asm-bad-operand.rs:27:37
|
LL | asm!("ret" : : "{rdi}"(target));
| ^^^^^^
LL | llvm_asm!("ret" : : "{rdi}"(target));
| ^^^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:34:29
--> $DIR/inline-asm-bad-operand.rs:34:34
|
LL | unsafe { asm!("" :: "i"(hello)) };
| ^^^^^
LL | unsafe { llvm_asm!("" :: "i"(hello)) };
| ^^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:42:38
--> $DIR/inline-asm-bad-operand.rs:42:43
|
LL | asm!("movups $1, %xmm0"::"m"(arr));
| ^^^
LL | llvm_asm!("movups $1, %xmm0"::"m"(arr));
| ^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:49:32
--> $DIR/inline-asm-bad-operand.rs:49:37
|
LL | asm!("mov sp, $0"::"r"(addr));
| ^^^^
LL | llvm_asm!("mov sp, $0"::"r"(addr));
| ^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:56:32
--> $DIR/inline-asm-bad-operand.rs:56:37
|
LL | asm!("mov sp, $0"::"r"(addr),
| ^^^^
LL | llvm_asm!("mov sp, $0"::"r"(addr),
| ^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:57:32
--> $DIR/inline-asm-bad-operand.rs:57:37
|
LL | ... "r"("hello e0669"));
| ^^^^^^^^^^^^^

View File

@ -1,7 +1,7 @@
// build-pass
#![allow(unused_macros)]
#![allow(dead_code)]
#![feature(asm)]
#![feature(llvm_asm)]
type History = Vec<&'static str>;
@ -18,10 +18,10 @@ macro_rules! demo {
let mut history: History = vec![];
unsafe {
asm!("mov ($1), $0"
: $output_constraint (*wrap(&mut x, "out", &mut history))
: "r"(&wrap(y, "in", &mut history))
:: "volatile");
llvm_asm!("mov ($1), $0"
: $output_constraint (*wrap(&mut x, "out", &mut history))
: "r"(&wrap(y, "in", &mut history))
:: "volatile");
}
assert_eq!((x,y), (1,1));
let b: &[_] = &["out", "in"];

View File

@ -1,11 +1,11 @@
#![feature(asm)]
#![feature(llvm_asm)]
// build-fail
// only-x86_64
fn main() {
unsafe {
asm!("int $3"); //~ ERROR too few operands for instruction
//~| ERROR invalid operand in inline asm
llvm_asm!("int $3"); //~ ERROR too few operands for instruction
//~| ERROR invalid operand in inline asm
}
}

View File

@ -1,8 +1,8 @@
error: invalid operand in inline asm: 'int $3'
--> $DIR/issue-23458.rs:8:9
|
LL | asm!("int $3");
| ^^^^^^^^^^^^^^^
LL | llvm_asm!("int $3");
| ^^^^^^^^^^^^^^^^^^^^
error: <inline asm>:1:2: error: too few operands for instruction
int
@ -10,8 +10,8 @@ error: <inline asm>:1:2: error: too few operands for instruction
--> $DIR/issue-23458.rs:8:9
|
LL | asm!("int $3");
| ^^^^^^^^^^^^^^^
LL | llvm_asm!("int $3");
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -2,7 +2,7 @@
// only-x86_64
#![allow(dead_code, non_upper_case_globals)]
#![feature(asm)]
#![feature(llvm_asm)]
#[repr(C)]
pub struct D32x4(f32,f32,f32,f32);
@ -11,16 +11,16 @@ impl D32x4 {
fn add(&self, vec: Self) -> Self {
unsafe {
let ret: Self;
asm!("
movaps $1, %xmm1
movaps $2, %xmm2
addps %xmm1, %xmm2
movaps $xmm1, $0
"
: "=r"(ret)
: "1"(self), "2"(vec)
: "xmm1", "xmm2"
);
llvm_asm!("
movaps $1, %xmm1
movaps $2, %xmm2
addps %xmm1, %xmm2
movaps $xmm1, $0
"
: "=r"(ret)
: "1"(self), "2"(vec)
: "xmm1", "xmm2"
);
ret
}
}

View File

@ -1,12 +1,12 @@
// check-pass
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
macro_rules! interrupt_handler {
() => {
unsafe fn _interrupt_handler() {
asm!("pop eax" :::: "intel");
llvm_asm!("pop eax" :::: "intel");
}
}
}

View File

@ -1,11 +1,11 @@
// build-fail
// ignore-emscripten no asm! support
// ignore-emscripten no llvm_asm! support
#![feature(asm)]
#![feature(llvm_asm)]
fn main() {
unsafe {
asm!("" :: "r"(""));
llvm_asm!("" :: "r"(""));
//~^ ERROR: invalid value for constraint in inline assembly
}
}

View File

@ -1,8 +1,8 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/issue-37433.rs:8:24
--> $DIR/issue-37433.rs:8:29
|
LL | asm!("" :: "r"(""));
| ^^
LL | llvm_asm!("" :: "r"(""));
| ^^
error: aborting due to previous error

View File

@ -3,12 +3,12 @@
// build-fail
// ignore-emscripten
#![feature(asm)]
#![feature(llvm_asm)]
macro_rules! fake_jump {
($id:expr) => {
unsafe {
asm!(
llvm_asm!(
"
jmp $0
lea eax, [ebx]

View File

@ -12,7 +12,7 @@ impl bomb for S { fn boom(&self, _: Ident) { } }
pub struct Ident { name: usize }
// macro_rules! int3 { () => ( unsafe { asm!( "int3" ); } ) }
// macro_rules! int3 { () => ( unsafe { llvm_asm!( "int3" ); } ) }
macro_rules! int3 { () => ( { } ) }
fn Ident_new() -> Ident {

View File

@ -5,5 +5,5 @@ macro_rules! m {
}
macro_rules! n {
() => { unsafe { asm!(include_str!("file.txt")); } }
() => { unsafe { llvm_asm!(include_str!("file.txt")); } }
}

View File

@ -1,6 +1,6 @@
// ignore-emscripten no asm! support
// ignore-emscripten no llvm_asm! support
// build-pass (FIXME(62277): could be check-pass?)
#![feature(asm)]
#![feature(llvm_asm)]
#![allow(unused)]
#[macro_use]

View File

@ -3,14 +3,14 @@
// test that errors in a (selection) of macros don't kill compilation
// immediately, so that we get more errors listed at a time.
#![feature(asm)]
#![feature(llvm_asm)]
#![feature(trace_macros, concat_idents)]
#[derive(Default)] //~ ERROR
enum OrDeriveThis {}
fn main() {
asm!(invalid); //~ ERROR
llvm_asm!(invalid); //~ ERROR
concat_idents!("not", "idents"); //~ ERROR

View File

@ -7,10 +7,10 @@ LL | #[derive(Default)]
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: inline assembly must be a string literal
--> $DIR/macros-nonfatal-errors.rs:13:10
--> $DIR/macros-nonfatal-errors.rs:13:15
|
LL | asm!(invalid);
| ^^^^^^^
LL | llvm_asm!(invalid);
| ^^^^^^^
error: concat_idents! requires ident args.
--> $DIR/macros-nonfatal-errors.rs:15:5

View File

@ -8,7 +8,7 @@
// ignore-emscripten no processes
// ignore-sgx no processes
#![feature(asm)]
#![feature(llvm_asm)]
#![feature(rustc_private)]
#[cfg(unix)]
@ -22,7 +22,7 @@ use std::thread;
// Inlining to avoid llvm turning the recursive functions into tail calls,
// which doesn't consume stack.
#[inline(always)]
pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
pub fn black_box<T>(dummy: T) { unsafe { llvm_asm!("" : : "r"(&dummy)) } }
fn silent_recurse() {
let buf = [0u8; 1000];