File: s390x-backchain-toggle.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (46 lines) | stat: -rw-r--r-- 1,450 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//@ revisions: enable-backchain disable-backchain
//@ assembly-output: emit-asm
//@ compile-flags: -O --crate-type=lib --target=s390x-unknown-linux-gnu
//@ needs-llvm-components: systemz
//@[enable-backchain] compile-flags: -Ctarget-feature=+backchain
//@[disable-backchain] compile-flags: -Ctarget-feature=-backchain
#![feature(no_core, lang_items)]
#![no_std]
#![no_core]

#[lang = "sized"]
trait Sized {}

extern "C" {
    fn extern_func();
}

// CHECK-LABEL: test_backchain
#[no_mangle]
extern "C" fn test_backchain() -> i32 {
    // Here we try to match if backchain register is saved to the parameter area (stored in r15/sp)
    // And also if a new parameter area (160 bytes) is allocated for the upcoming function call
    // enable-backchain: lgr [[REG1:.*]], %r15
    // enable-backchain-NEXT: aghi %r15, -160
    // enable-backchain: stg [[REG1]], 0(%r15)
    // disable-backchain: aghi %r15, -160
    // disable-backchain-NOT: stg %r{{.*}}, 0(%r15)
    unsafe {
        extern_func();
    }
    // enable-backchain-NEXT: brasl %r{{.*}}, extern_func@PLT
    // disable-backchain: brasl %r{{.*}}, extern_func@PLT

    // Make sure that the expected return value is written into %r2 (return register):
    // enable-backchain-NEXT: lghi %r2, 1
    // disable-backchain: lghi %r2, 0
    #[cfg(target_feature = "backchain")]
    {
        1
    }
    #[cfg(not(target_feature = "backchain"))]
    {
        0
    }
    // CHECK: br %r{{.*}}
}