From: Pierre-Emmanuel Patry Date: Tue, 29 Jul 2025 13:15:31 +0000 (+0200) Subject: gccrs: Add execute test for variable and identifiers X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=71a121c2c65a423beafb370307afcc5163217c1a;p=thirdparty%2Fgcc.git 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 --- 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 00000000000..b0a3d25a2a7 --- /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 00000000000..ff101b86b7b --- /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 +}