]> git.proxmox.com Git - rustc.git/blob - src/test/ui/llvm-asm/issue-14936.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / llvm-asm / issue-14936.rs
1 // build-pass
2 #![allow(unused_macros)]
3 #![allow(dead_code)]
4 #![allow(deprecated)] // llvm_asm!
5 #![feature(llvm_asm)]
6
7 type History = Vec<&'static str>;
8
9 fn wrap<A>(x:A, which: &'static str, history: &mut History) -> A {
10 history.push(which);
11 x
12 }
13
14 macro_rules! demo {
15 ( $output_constraint:tt ) => {
16 {
17 let mut x: isize = 0;
18 let y: isize = 1;
19
20 let mut history: History = vec![];
21 unsafe {
22 llvm_asm!("mov ($1), $0"
23 : $output_constraint (*wrap(&mut x, "out", &mut history))
24 : "r"(&wrap(y, "in", &mut history))
25 :: "volatile");
26 }
27 assert_eq!((x,y), (1,1));
28 let b: &[_] = &["out", "in"];
29 assert_eq!(history, b);
30 }
31 }
32 }
33
34 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
35 fn main() {
36 fn out_write_only_expr_then_in_expr() {
37 demo!("=r")
38 }
39
40 fn out_read_write_expr_then_in_expr() {
41 demo!("+r")
42 }
43
44 out_write_only_expr_then_in_expr();
45 out_read_write_expr_then_in_expr();
46 }
47
48 #[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))]
49 pub fn main() {}