]> git.proxmox.com Git - rustc.git/blob - src/test/assembly/static-relocation-model.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / assembly / static-relocation-model.rs
1 // min-llvm-version: 12.0.0
2 // revisions: x64 A64 ppc64le
3 // assembly-output: emit-asm
4 // [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static
5 // [x64] needs-llvm-components: x86
6 // [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static
7 // [A64] needs-llvm-components: aarch64
8 // [ppc64le] compile-flags: --target powerpc64le-unknown-linux-gnu -Crelocation-model=static
9 // [ppc64le] needs-llvm-components: powerpc
10
11 #![feature(no_core, lang_items)]
12 #![no_core]
13 #![crate_type="rlib"]
14
15 #[lang="sized"]
16 trait Sized {}
17
18 #[lang="copy"]
19 trait Copy {}
20
21 #[lang="sync"]
22 trait Sync {}
23
24 #[lang = "drop_in_place"]
25 fn drop_in_place<T>(_: *mut T) {}
26
27 impl Copy for u8 {}
28 impl Sync for u8 {}
29
30 #[no_mangle]
31 pub static PIERIS: u8 = 42;
32
33 extern "C" {
34 static EXOCHORDA: *mut u8;
35
36 fn chaenomeles();
37 }
38
39 // CHECK-LABEL: banana:
40 // x64: movb chaenomeles{{(\(%[a-z0-9]+\))?}}, %{{[a-z0-9]+}}
41 // A64: adrp [[REG:[a-z0-9]+]], chaenomeles
42 // A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles]
43 #[no_mangle]
44 pub fn banana() -> u8 {
45 unsafe {
46 *(chaenomeles as *mut u8)
47 }
48 }
49
50 // CHECK-LABEL: peach:
51 // x64: movb banana{{(\(%[a-z0-9]+\))?}}, %{{[a-z0-9]+}}
52 // A64: adrp [[REG2:[a-z0-9]+]], banana
53 // A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:banana]
54 #[no_mangle]
55 pub fn peach() -> u8 {
56 unsafe {
57 *(banana as *mut u8)
58 }
59 }
60
61 // CHECK-LABEL: mango:
62 // x64: movq EXOCHORDA{{(\(%[a-z0-9]+\))?}}, %[[REG:[a-z0-9]+]]
63 // x64-NEXT: movb (%[[REG]]), %{{[a-z0-9]+}}
64 // A64: adrp [[REG2:[a-z0-9]+]], EXOCHORDA
65 // A64-NEXT: ldr {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:EXOCHORDA]
66 #[no_mangle]
67 pub fn mango() -> u8 {
68 unsafe {
69 *EXOCHORDA
70 }
71 }
72
73 // CHECK-LABEL: orange:
74 // x64: mov{{l|absq}} $PIERIS, %{{[a-z0-9]+}}
75 // A64: adrp [[REG2:[a-z0-9]+]], PIERIS
76 // A64-NEXT: add {{[a-z0-9]+}}, [[REG2]], :lo12:PIERIS
77 #[no_mangle]
78 pub fn orange() -> &'static u8 {
79 &PIERIS
80 }
81
82 // For ppc64 we need to make sure to generate TOC entries even with the static relocation model
83 // ppc64le: .tc chaenomeles[TC],chaenomeles
84 // ppc64le: .tc banana[TC],banana
85 // ppc64le: .tc EXOCHORDA[TC],EXOCHORDA
86 // ppc64le: .tc PIERIS[TC],PIERIS