diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2025-07-29 15:15:31 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-08-05 16:36:58 +0200 |
commit | 71a121c2c65a423beafb370307afcc5163217c1a (patch) | |
tree | 75383dbd804e165809e07a019ce0dcd9b67fe126 /gcc | |
parent | 68287a532c09dca6ef0c473db726ff385d0e7edb (diff) | |
download | gcc-71a121c2c65a423beafb370307afcc5163217c1a.zip gcc-71a121c2c65a423beafb370307afcc5163217c1a.tar.gz gcc-71a121c2c65a423beafb370307afcc5163217c1a.tar.bz2 |
gccrs: Add execute test for variable and identifiers
gcc/testsuite/ChangeLog:
* rust/execute/inline_asm_inout_ident.rs: New test.
* rust/execute/inline_asm_inout_var.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/rust/execute/inline_asm_inout_ident.rs | 23 | ||||
-rw-r--r-- | gcc/testsuite/rust/execute/inline_asm_inout_var.rs | 24 |
2 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/execute/inline_asm_inout_ident.rs b/gcc/testsuite/rust/execute/inline_asm_inout_ident.rs new file mode 100644 index 0000000..b0a3d25 --- /dev/null +++ b/gcc/testsuite/rust/execute/inline_asm_inout_ident.rs @@ -0,0 +1,23 @@ +/* { dg-output "Value is: 5\r*\n" } */ +#![feature(rustc_attrs)] + +extern "C" { + fn printf(s: *const i8, ...); +} + +#[rustc_builtin_macro] +macro_rules! asm { + () => {}; +} + +fn main() -> i32 { + let x: i32; + // `inout` can also move values to different places + unsafe { + asm!("inc {}", inout(reg) 4u64=>x); + } + unsafe { + printf("Value is: %i\n\0" as *const str as *const i8, x); + } + 0 +} diff --git a/gcc/testsuite/rust/execute/inline_asm_inout_var.rs b/gcc/testsuite/rust/execute/inline_asm_inout_var.rs new file mode 100644 index 0000000..ff101b8 --- /dev/null +++ b/gcc/testsuite/rust/execute/inline_asm_inout_var.rs @@ -0,0 +1,24 @@ +/* { dg-output "Value is: 5\r*\n" } */ +#![feature(rustc_attrs)] + +extern "C" { + fn printf(s: *const i8, ...); +} + +#[rustc_builtin_macro] +macro_rules! asm { + () => {}; +} + +fn main() -> i32 { + let y: i32 = 4; + let x: i32; + // `inout` can also move values to different places + unsafe { + asm!("inc {}", inout(reg) y=>x); + } + unsafe { + printf("Value is: %i\n\0" as *const str as *const i8, x); + } + 0 +} |