]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/x86_64/multiple-clobber-abi.rs
Rollup merge of #97325 - tmiasko:capture-enum-field, r=arora-aman
[rust.git] / src / test / ui / asm / x86_64 / multiple-clobber-abi.rs
1 // run-pass
2 // needs-asm-support
3 // only-x86_64
4
5 // Checks that multiple clobber_abi options can be used
6
7 #![feature(asm_sym)]
8
9 use std::arch::asm;
10
11 extern "sysv64" fn foo(x: i32) -> i32 {
12     x + 16
13 }
14
15 extern "win64" fn bar(x: i32) -> i32 {
16     x / 2
17 }
18
19 fn main() {
20     let x = 8;
21     let y: i32;
22     // call `foo` with `x` as the input, and then `bar` with the output of `foo`
23     // and output that to `y`
24     unsafe {
25         asm!(
26             "call {}; mov rcx, rax; call {}",
27             sym foo,
28             sym bar,
29             in("rdi") x,
30             out("rax") y,
31             clobber_abi("sysv64", "win64"),
32         );
33     }
34     assert_eq!((x, y), (8, 12));
35 }