Skip to content

Commit

Permalink
Update tests on aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed May 27, 2022
1 parent 6ba8da6 commit 4332c2f
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 127 deletions.
2 changes: 2 additions & 0 deletions src/test/ui/asm/aarch64/bad-reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ fn main() {

asm!("", in("p0") foo);
//~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
//~| ERROR type `i32` cannot be used with this register class
asm!("", out("p0") _);
asm!("{}", in(preg) foo);
//~^ ERROR register class `preg` can only be used as a clobber, not as an input or output
//~| ERROR type `i32` cannot be used with this register class
asm!("{}", out(preg) _);
//~^ ERROR register class `preg` can only be used as a clobber, not as an input or output

Expand Down
34 changes: 25 additions & 9 deletions src/test/ui/asm/aarch64/bad-reg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -87,60 +87,76 @@ LL | asm!("", in("p0") foo);
| ^^^^^^^^^^^^

error: register class `preg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:40:20
--> $DIR/bad-reg.rs:41:20
|
LL | asm!("{}", in(preg) foo);
| ^^^^^^^^^^^^

error: register class `preg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:42:20
--> $DIR/bad-reg.rs:44:20
|
LL | asm!("{}", out(preg) _);
| ^^^^^^^^^^^

error: register `x0` conflicts with register `x0`
--> $DIR/bad-reg.rs:48:32
--> $DIR/bad-reg.rs:50:32
|
LL | asm!("", in("x0") foo, in("w0") bar);
| ------------ ^^^^^^^^^^^^ register `x0`
| |
| register `x0`

error: register `x0` conflicts with register `x0`
--> $DIR/bad-reg.rs:50:32
--> $DIR/bad-reg.rs:52:32
|
LL | asm!("", in("x0") foo, out("x0") bar);
| ------------ ^^^^^^^^^^^^^ register `x0`
| |
| register `x0`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:50:18
--> $DIR/bad-reg.rs:52:18
|
LL | asm!("", in("x0") foo, out("x0") bar);
| ^^^^^^^^^^^^

error: register `v0` conflicts with register `v0`
--> $DIR/bad-reg.rs:53:32
--> $DIR/bad-reg.rs:55:32
|
LL | asm!("", in("v0") foo, in("q0") bar);
| ------------ ^^^^^^^^^^^^ register `v0`
| |
| register `v0`

error: register `v0` conflicts with register `v0`
--> $DIR/bad-reg.rs:55:32
--> $DIR/bad-reg.rs:57:32
|
LL | asm!("", in("v0") foo, out("q0") bar);
| ------------ ^^^^^^^^^^^^^ register `v0`
| |
| register `v0`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:55:18
--> $DIR/bad-reg.rs:57:18
|
LL | asm!("", in("v0") foo, out("q0") bar);
| ^^^^^^^^^^^^

error: aborting due to 18 previous errors
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:37:27
|
LL | asm!("", in("p0") foo);
| ^^^
|
= note: register class `preg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:41:29
|
LL | asm!("{}", in(preg) foo);
| ^^^
|
= note: register class `preg` supports these types:

error: aborting due to 20 previous errors

37 changes: 37 additions & 0 deletions src/test/ui/asm/aarch64/type-check-2-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// only-aarch64

#![feature(repr_simd, never_type, asm_sym)]

use std::arch::{asm, global_asm};

#[repr(simd)]
#[derive(Clone, Copy)]
struct SimdType(f32, f32, f32, f32);

#[repr(simd)]
struct SimdNonCopy(f32, f32, f32, f32);

fn main() {
unsafe {
// Inputs must be initialized

let x: u64;
asm!("{}", in(reg) x);
//~^ ERROR use of possibly-uninitialized variable: `x`
let mut y: u64;
asm!("{}", inout(reg) y);
//~^ ERROR use of possibly-uninitialized variable: `y`
let _ = y;

// Outputs require mutable places

let v: Vec<u64> = vec![0, 1, 2];
asm!("{}", in(reg) v[0]);
asm!("{}", out(reg) v[0]);
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
asm!("{}", inout(reg) v[0]);
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable

// Sym operands must point to a function or static
}
}
34 changes: 34 additions & 0 deletions src/test/ui/asm/aarch64/type-check-2-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
error[E0381]: use of possibly-uninitialized variable: `x`
--> $DIR/type-check-2-2.rs:19:28
|
LL | asm!("{}", in(reg) x);
| ^ use of possibly-uninitialized `x`

error[E0381]: use of possibly-uninitialized variable: `y`
--> $DIR/type-check-2-2.rs:22:9
|
LL | asm!("{}", inout(reg) y);
| ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`

error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
--> $DIR/type-check-2-2.rs:30:29
|
LL | let v: Vec<u64> = vec![0, 1, 2];
| - help: consider changing this to be mutable: `mut v`
LL | asm!("{}", in(reg) v[0]);
LL | asm!("{}", out(reg) v[0]);
| ^ cannot borrow as mutable

error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
--> $DIR/type-check-2-2.rs:32:31
|
LL | let v: Vec<u64> = vec![0, 1, 2];
| - help: consider changing this to be mutable: `mut v`
...
LL | asm!("{}", inout(reg) v[0]);
| ^ cannot borrow as mutable

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0381, E0596.
For more information about an error, try `rustc --explain E0381`.
17 changes: 0 additions & 17 deletions src/test/ui/asm/aarch64/type-check-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@ fn main() {
unsafe {
// Inputs must be initialized

let x: u64;
asm!("{}", in(reg) x);
//~^ ERROR use of possibly-uninitialized variable: `x`
let mut y: u64;
asm!("{}", inout(reg) y);
//~^ ERROR use of possibly-uninitialized variable: `y`
let _ = y;

// Outputs require mutable places

let v: Vec<u64> = vec![0, 1, 2];
asm!("{}", in(reg) v[0]);
asm!("{}", out(reg) v[0]);
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
asm!("{}", inout(reg) v[0]);
//~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable

// Sym operands must point to a function or static

const C: i32 = 0;
Expand Down
82 changes: 25 additions & 57 deletions src/test/ui/asm/aarch64/type-check-2.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
error: invalid `sym` operand
--> $DIR/type-check-2.rs:75:19
|
LL | global_asm!("{}", sym C);
| ^^^^^ is an `i32`
|
= help: `sym` operands must refer to either a function or a static

error: invalid `sym` operand
--> $DIR/type-check-2.rs:24:20
|
LL | asm!("{}", sym C);
| ^^^^^ is an `i32`
|
= help: `sym` operands must refer to either a function or a static

error: arguments for inline assembly must be copyable
--> $DIR/type-check-2.rs:46:31
--> $DIR/type-check-2.rs:29:31
|
LL | asm!("{:v}", in(vreg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `SimdNonCopy` does not implement the Copy trait

error: cannot use value of type `[closure@$DIR/type-check-2.rs:58:28: 58:38]` for inline assembly
--> $DIR/type-check-2.rs:58:28
error: cannot use value of type `[closure@$DIR/type-check-2.rs:41:28: 41:38]` for inline assembly
--> $DIR/type-check-2.rs:41:28
|
LL | asm!("{}", in(reg) |x: i32| x);
| ^^^^^^^^^^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: cannot use value of type `Vec<i32>` for inline assembly
--> $DIR/type-check-2.rs:60:28
--> $DIR/type-check-2.rs:43:28
|
LL | asm!("{}", in(reg) vec![0]);
| ^^^^^^^
Expand All @@ -24,84 +40,36 @@ LL | asm!("{}", in(reg) vec![0]);
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot use value of type `(i32, i32, i32)` for inline assembly
--> $DIR/type-check-2.rs:62:28
--> $DIR/type-check-2.rs:45:28
|
LL | asm!("{}", in(reg) (1, 2, 3));
| ^^^^^^^^^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: cannot use value of type `[i32; 3]` for inline assembly
--> $DIR/type-check-2.rs:64:28
--> $DIR/type-check-2.rs:47:28
|
LL | asm!("{}", in(reg) [1, 2, 3]);
| ^^^^^^^^^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: cannot use value of type `fn() {main}` for inline assembly
--> $DIR/type-check-2.rs:72:31
--> $DIR/type-check-2.rs:55:31
|
LL | asm!("{}", inout(reg) f);
| ^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: cannot use value of type `&mut i32` for inline assembly
--> $DIR/type-check-2.rs:75:31
--> $DIR/type-check-2.rs:58:31
|
LL | asm!("{}", inout(reg) r);
| ^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: invalid `sym` operand
--> $DIR/type-check-2.rs:41:20
|
LL | asm!("{}", sym C);
| ^^^^^ is an `i32`
|
= help: `sym` operands must refer to either a function or a static

error: invalid `sym` operand
--> $DIR/type-check-2.rs:92:19
|
LL | global_asm!("{}", sym C);
| ^^^^^ is an `i32`
|
= help: `sym` operands must refer to either a function or a static

error[E0381]: use of possibly-uninitialized variable: `x`
--> $DIR/type-check-2.rs:19:28
|
LL | asm!("{}", in(reg) x);
| ^ use of possibly-uninitialized `x`

error[E0381]: use of possibly-uninitialized variable: `y`
--> $DIR/type-check-2.rs:22:9
|
LL | asm!("{}", inout(reg) y);
| ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`

error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
--> $DIR/type-check-2.rs:30:29
|
LL | let v: Vec<u64> = vec![0, 1, 2];
| - help: consider changing this to be mutable: `mut v`
LL | asm!("{}", in(reg) v[0]);
LL | asm!("{}", out(reg) v[0]);
| ^ cannot borrow as mutable

error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
--> $DIR/type-check-2.rs:32:31
|
LL | let v: Vec<u64> = vec![0, 1, 2];
| - help: consider changing this to be mutable: `mut v`
...
LL | asm!("{}", inout(reg) v[0]);
| ^ cannot borrow as mutable

error: aborting due to 13 previous errors
error: aborting due to 9 previous errors

Some errors have detailed explanations: E0381, E0596.
For more information about an error, try `rustc --explain E0381`.
18 changes: 0 additions & 18 deletions src/test/ui/asm/aarch64/type-check-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,3 @@ fn main() {
asm!("{:x}", inout(reg) main => val_u64);
}
}

// Constants must be... constant

static S: i32 = 1;
const fn const_foo(x: i32) -> i32 {
x
}
const fn const_bar<T>(x: T) -> T {
x
}
global_asm!("{}", const S);
//~^ ERROR constants cannot refer to statics
global_asm!("{}", const const_foo(0));
global_asm!("{}", const const_foo(S));
//~^ ERROR constants cannot refer to statics
global_asm!("{}", const const_bar(0));
global_asm!("{}", const const_bar(S));
//~^ ERROR constants cannot refer to statics
27 changes: 1 addition & 26 deletions src/test/ui/asm/aarch64/type-check-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,5 @@ LL | asm!("{:x}", inout(reg) main => val_u32);
|
= note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size

error[E0013]: constants cannot refer to statics
--> $DIR/type-check-3.rs:108:25
|
LL | global_asm!("{}", const S);
| ^
|
= help: consider extracting the value of the `static` to a `const`, and referring to that

error[E0013]: constants cannot refer to statics
--> $DIR/type-check-3.rs:111:35
|
LL | global_asm!("{}", const const_foo(S));
| ^
|
= help: consider extracting the value of the `static` to a `const`, and referring to that

error[E0013]: constants cannot refer to statics
--> $DIR/type-check-3.rs:114:35
|
LL | global_asm!("{}", const const_bar(S));
| ^
|
= help: consider extracting the value of the `static` to a `const`, and referring to that

error: aborting due to 9 previous errors; 10 warnings emitted
error: aborting due to 6 previous errors; 10 warnings emitted

For more information about this error, try `rustc --explain E0013`.
Loading

0 comments on commit 4332c2f

Please sign in to comment.