diff options
| author | Camelid <camelidcamel@gmail.com> | 2020-06-12 12:12:36 -0700 |
|---|---|---|
| committer | Camelid <camelidcamel@gmail.com> | 2020-06-20 11:12:42 -0700 |
| commit | 820bba1c467aa5aa54d6db2869b15c643e5c350c (patch) | |
| tree | a4ba25c662c26a5a6362cf8ea040aed5f259f128 | |
| parent | 27cc7c7d9fb8a25cce9ab73ece034a9282406ce3 (diff) | |
| download | rust-820bba1c467aa5aa54d6db2869b15c643e5c350c.tar.gz rust-820bba1c467aa5aa54d6db2869b15c643e5c350c.zip | |
Add codegen test for multiple `asm!` options
| -rw-r--r-- | src/test/codegen/asm-multiple-options.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/test/codegen/asm-multiple-options.rs b/src/test/codegen/asm-multiple-options.rs new file mode 100644 index 00000000000..c702742bf1a --- /dev/null +++ b/src/test/codegen/asm-multiple-options.rs @@ -0,0 +1,53 @@ +// compile-flags: -O +// only-x86_64 + +#![crate_type = "rlib"] +#![feature(asm)] + +// CHECK-LABEL: @pure +// CHECK-NOT: asm +// CHECK: ret void +#[no_mangle] +pub unsafe fn pure(x: i32) { + let y: i32; + asm!("", out("ax") y, in("bx") x, options(pure), options(nomem)); +} + +pub static mut VAR: i32 = 0; +pub static mut DUMMY_OUTPUT: i32 = 0; + +// CHECK-LABEL: @readonly +// CHECK: call i32 asm +// CHECK: ret i32 1 +#[no_mangle] +pub unsafe fn readonly() -> i32 { + VAR = 1; + asm!("", out("ax") DUMMY_OUTPUT, options(pure), options(readonly)); + VAR +} + +// CHECK-LABEL: @nomem +// CHECK-NOT: store +// CHECK: call i32 asm +// CHECK: store +// CHECK: ret i32 2 +#[no_mangle] +pub unsafe fn nomem() -> i32 { + VAR = 1; + asm!("", out("ax") DUMMY_OUTPUT, options(pure), options(nomem)); + VAR = 2; + VAR +} + +// CHECK-LABEL: @not_nomem +// CHECK: store +// CHECK: call i32 asm +// CHECK: store +// CHECK: ret i32 2 +#[no_mangle] +pub unsafe fn not_nomem() -> i32 { + VAR = 1; + asm!("", out("ax") DUMMY_OUTPUT, options(pure), options(readonly)); + VAR = 2; + VAR +} |
