forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsparc-types.rs
145 lines (124 loc) · 3.61 KB
/
sparc-types.rs
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//@ add-core-stubs
//@ revisions: sparc sparcv8plus sparc64
//@ assembly-output: emit-asm
//@[sparc] compile-flags: --target sparc-unknown-none-elf
//@[sparc] needs-llvm-components: sparc
//@[sparcv8plus] compile-flags: --target sparc-unknown-linux-gnu
//@[sparcv8plus] needs-llvm-components: sparc
//@[sparc64] compile-flags: --target sparc64-unknown-linux-gnu
//@[sparc64] needs-llvm-components: sparc
//@ compile-flags: -Zmerge-functions=disabled
#![feature(no_core, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
extern crate minicore;
use minicore::*;
type ptr = *const i32;
extern "C" {
fn extern_func();
static extern_static: u8;
}
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
#[no_mangle]
pub unsafe fn $func(x: $ty) -> $ty {
let y;
asm!(concat!($mov," {}, {}"), in($class) x, out($class) y);
y
}
};}
macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
#[no_mangle]
pub unsafe fn $func(x: $ty) -> $ty {
let y;
asm!(concat!($mov, " %", $reg, ", %", $reg), in($reg) x, lateout($reg) y);
y
}
};}
// CHECK-LABEL: sym_fn_32:
// CHECK: !APP
// CHECK-NEXT: call extern_func
// CHECK-NEXT: !NO_APP
#[no_mangle]
pub unsafe fn sym_fn_32() {
asm!("call {}", sym extern_func);
}
// CHECK-LABEL: sym_static:
// CHECK: !APP
// CHECK-NEXT: call extern_static
// CHECK-NEXT: !NO_APP
#[no_mangle]
pub unsafe fn sym_static() {
asm!("call {}", sym extern_static);
}
// CHECK-LABEL: reg_i8:
// CHECK: !APP
// CHECK-NEXT: mov %{{[goli]}}{{[0-9]+}}, %{{[goli]}}{{[0-9]+}}
// CHECK-NEXT: !NO_APP
check!(reg_i8, i8, reg, "mov");
// CHECK-LABEL: reg_i16:
// CHECK: !APP
// CHECK-NEXT: mov %{{[goli]}}{{[0-9]+}}, %{{[goli]}}{{[0-9]+}}
// CHECK-NEXT: !NO_APP
check!(reg_i16, i16, reg, "mov");
// CHECK-LABEL: reg_i32:
// CHECK: !APP
// CHECK-NEXT: mov %{{[goli]}}{{[0-9]+}}, %{{[goli]}}{{[0-9]+}}
// CHECK-NEXT: !NO_APP
check!(reg_i32, i32, reg, "mov");
// FIXME: should be allowed for sparcv8plus but not yet supported in LLVM
// sparc64-LABEL: reg_i64:
// sparc64: !APP
// sparc64-NEXT: mov %{{[goli]}}{{[0-9]+}}, %{{[goli]}}{{[0-9]+}}
// sparc64-NEXT: !NO_APP
#[cfg(sparc64)]
check!(reg_i64, i64, reg, "mov");
// CHECK-LABEL: reg_ptr:
// CHECK: !APP
// CHECK-NEXT: mov %{{[goli]}}{{[0-9]+}}, %{{[goli]}}{{[0-9]+}}
// CHECK-NEXT: !NO_APP
check!(reg_ptr, ptr, reg, "mov");
// CHECK-LABEL: o0_i8:
// CHECK: !APP
// CHECK-NEXT: mov %o0, %o0
// CHECK-NEXT: !NO_APP
check_reg!(o0_i8, i8, "o0", "mov");
// CHECK-LABEL: o0_i16:
// CHECK: !APP
// CHECK-NEXT: mov %o0, %o0
// CHECK-NEXT: !NO_APP
check_reg!(o0_i16, i16, "o0", "mov");
// CHECK-LABEL: o0_i32:
// CHECK: !APP
// CHECK-NEXT: mov %o0, %o0
// CHECK-NEXT: !NO_APP
check_reg!(o0_i32, i32, "o0", "mov");
// FIXME: should be allowed for sparcv8plus but not yet supported in LLVM
// sparc64-LABEL: o0_i64:
// sparc64: !APP
// sparc64-NEXT: mov %o0, %o0
// sparc64-NEXT: !NO_APP
#[cfg(sparc64)]
check_reg!(o0_i64, i64, "o0", "mov");
// CHECK-LABEL: r9_i8:
// CHECK: !APP
// CHECK-NEXT: mov %o1, %o1
// CHECK-NEXT: !NO_APP
check_reg!(r9_i8, i8, "r9", "mov");
// CHECK-LABEL: r9_i16:
// CHECK: !APP
// CHECK-NEXT: mov %o1, %o1
// CHECK-NEXT: !NO_APP
check_reg!(r9_i16, i16, "r9", "mov");
// CHECK-LABEL: r9_i32:
// CHECK: !APP
// CHECK-NEXT: mov %o1, %o1
// CHECK-NEXT: !NO_APP
check_reg!(r9_i32, i32, "r9", "mov");
// FIXME: should be allowed for sparcv8plus but not yet supported in LLVM
// sparc64-LABEL: r9_i64:
// sparc64: !APP
// sparc64-NEXT: mov %o1, %o1
// sparc64-NEXT: !NO_APP
#[cfg(sparc64)]
check_reg!(r9_i64, i64, "r9", "mov");