about summary refs log tree commit diff
path: root/tests/codegen/asm/goto.rs
diff options
context:
space:
mode:
authorTaiki Endo <te316e89@gmail.com>2024-11-01 22:12:55 +0900
committerTaiki Endo <te316e89@gmail.com>2024-11-01 22:12:55 +0900
commit96e7eaf478f53cdf417ad681d2afa07b00abbdfd (patch)
treeac8bbc17410f3a71f96f8325955b59ae5730c20c /tests/codegen/asm/goto.rs
parenta8e1186e3c14a54f7a38cc1183117dc7e77f4f82 (diff)
downloadrust-96e7eaf478f53cdf417ad681d2afa07b00abbdfd.tar.gz
rust-96e7eaf478f53cdf417ad681d2afa07b00abbdfd.zip
Move remaining inline assembly test files into asm directory
Diffstat (limited to 'tests/codegen/asm/goto.rs')
-rw-r--r--tests/codegen/asm/goto.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/codegen/asm/goto.rs b/tests/codegen/asm/goto.rs
new file mode 100644
index 00000000000..e522d0da5b4
--- /dev/null
+++ b/tests/codegen/asm/goto.rs
@@ -0,0 +1,51 @@
+//@ compile-flags: -O
+//@ only-x86_64
+
+#![crate_type = "rlib"]
+#![feature(asm_goto)]
+
+use std::arch::asm;
+
+#[no_mangle]
+pub extern "C" fn panicky() {}
+
+struct Foo;
+
+impl Drop for Foo {
+    fn drop(&mut self) {
+        println!();
+    }
+}
+
+// CHECK-LABEL: @asm_goto
+#[no_mangle]
+pub unsafe fn asm_goto() {
+    // CHECK: callbr void asm sideeffect alignstack inteldialect "
+    // CHECK-NEXT: to label %[[FALLTHROUGHBB:[a-b0-9]+]] [label %[[JUMPBB:[a-b0-9]+]]]
+    asm!("jmp {}", label {});
+}
+
+// CHECK-LABEL: @asm_goto_with_outputs
+#[no_mangle]
+pub unsafe fn asm_goto_with_outputs() -> u64 {
+    let out: u64;
+    // CHECK: [[RES:%[0-9]+]] = callbr i64 asm sideeffect alignstack inteldialect "
+    // CHECK-NEXT: to label %[[FALLTHROUGHBB:[a-b0-9]+]] [label %[[JUMPBB:[a-b0-9]+]]]
+    asm!("{} /* {} */", out(reg) out, label { return 1; });
+    // CHECK: [[JUMPBB]]:
+    // CHECK-NEXT: [[RET:%.+]] = phi i64 [ [[RES]], %[[FALLTHROUGHBB]] ], [ 1, %start ]
+    // CHECK-NEXT: ret i64 [[RET]]
+    out
+}
+
+// CHECK-LABEL: @asm_goto_noreturn
+#[no_mangle]
+pub unsafe fn asm_goto_noreturn() -> u64 {
+    let out: u64;
+    // CHECK: callbr void asm sideeffect alignstack inteldialect "
+    // CHECK-NEXT: to label %unreachable [label %[[JUMPBB:[a-b0-9]+]]]
+    asm!("jmp {}", label { return 1; }, options(noreturn));
+    // CHECK: [[JUMPBB]]:
+    // CHECK-NEXT: ret i64 1
+    out
+}