]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add execute test for variable and identifiers
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 29 Jul 2025 13:15:31 +0000 (15:15 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:36:58 +0000 (16:36 +0200)
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>
gcc/testsuite/rust/execute/inline_asm_inout_ident.rs [new file with mode: 0644]
gcc/testsuite/rust/execute/inline_asm_inout_var.rs [new file with mode: 0644]

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 (file)
index 0000000..b0a3d25
--- /dev/null
@@ -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 (file)
index 0000000..ff101b8
--- /dev/null
@@ -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
+}