3 #![feature(repr_simd, never_type, asm_sym)]
5 use std::arch::{asm, global_asm};
8 struct SimdNonCopy(f32, f32, f32, f32);
12 // Inputs must be initialized
15 asm!("{}", in(reg) x);
17 asm!("{}", inout(reg) y);
20 // Outputs require mutable places
22 let v: Vec<u64> = vec![0, 1, 2];
23 asm!("{}", in(reg) v[0]);
24 asm!("{}", out(reg) v[0]);
25 asm!("{}", inout(reg) v[0]);
27 // Sym operands must point to a function or static
34 //~^ ERROR invalid `sym` operand
36 //~^ ERROR invalid `sym` operand
38 // Register operands must be Copy
40 asm!("{}", in(xmm_reg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
41 //~^ ERROR arguments for inline assembly must be copyable
43 // Register operands must be integers, floats, SIMD vectors, pointers or
46 asm!("{}", in(reg) 0i64);
47 asm!("{}", in(reg) 0f64);
48 asm!("{}", in(xmm_reg) std::arch::x86_64::_mm_setzero_ps());
49 asm!("{}", in(reg) 0 as *const u8);
50 asm!("{}", in(reg) 0 as *mut u8);
51 asm!("{}", in(reg) main as fn());
52 asm!("{}", in(reg) |x: i32| x);
53 //~^ ERROR cannot use value of type
54 asm!("{}", in(reg) vec![0]);
55 //~^ ERROR cannot use value of type `Vec<i32>` for inline assembly
56 asm!("{}", in(reg) (1, 2, 3));
57 //~^ ERROR cannot use value of type `(i32, i32, i32)` for inline assembly
58 asm!("{}", in(reg) [1, 2, 3]);
59 //~^ ERROR cannot use value of type `[i32; 3]` for inline assembly
61 // Register inputs (but not outputs) allow references and function types
65 asm!("{}", in(reg) f);
66 asm!("{}", inout(reg) f);
67 //~^ ERROR cannot use value of type `fn() {main}` for inline assembly
68 asm!("{}", in(reg) r);
69 asm!("{}", inout(reg) r);
70 //~^ ERROR cannot use value of type `&mut i32` for inline assembly
73 // Type checks ignore never type
75 let u: ! = unreachable!();
76 asm!("{}", in(reg) u);
80 // Sym operands must point to a function or static
84 global_asm!("{}", sym S);
85 global_asm!("{}", sym main);
86 global_asm!("{}", sym C);
87 //~^ ERROR invalid `sym` operand