diff options
| author | linux1 <tmaloney@pdx.edu> | 2021-08-18 11:25:50 -0400 |
|---|---|---|
| committer | linux1 <tmaloney@pdx.edu> | 2021-08-22 17:55:03 -0400 |
| commit | 5f5afba5fbb869db26c4f9e88c29bad94007dfd1 (patch) | |
| tree | 358d424aa497babd9a70e8664e42318d84d8cdfb /src/test/assembly/asm | |
| parent | f28793dd13e8a8132d559629728e6ca9514dbe36 (diff) | |
| download | rust-5f5afba5fbb869db26c4f9e88c29bad94007dfd1.tar.gz rust-5f5afba5fbb869db26c4f9e88c29bad94007dfd1.zip | |
Feat: added s390x reg-definitions, constraint codes, and tests
Diffstat (limited to 'src/test/assembly/asm')
| -rw-r--r-- | src/test/assembly/asm/s390x-types.rs | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/test/assembly/asm/s390x-types.rs b/src/test/assembly/asm/s390x-types.rs new file mode 100644 index 00000000000..5f1a5f2de56 --- /dev/null +++ b/src/test/assembly/asm/s390x-types.rs @@ -0,0 +1,86 @@ +// min-llvm-version: 10.0.1 +// revisions: s390x +// assembly-output: emit-asm +//[s390x] compile-flags: --target s390x-unknown-linux-gnu +//[s390x] needs-llvm-components: systemz + +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] +#![crate_type = "rlib"] +#![no_core] +#![allow(asm_sub_register, non_camel_case_types)] + +#[rustc_builtin_macro] +macro_rules! asm { + () => {}; +} +#[rustc_builtin_macro] +macro_rules! concat { + () => {}; +} +#[rustc_builtin_macro] +macro_rules! stringify { + () => {}; +} + +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} + +type ptr = *const i32; + +impl Copy for i8 {} +impl Copy for u8 {} +impl Copy for i16 {} +impl Copy for i32 {} +impl Copy for i64 {} +impl Copy for f32 {} +impl Copy for f64 {} +impl Copy for ptr {} + +extern "C" { + fn extern_func(); + static extern_static: u8; +} + +// Hack to avoid function merging +extern "Rust" { + fn dont_merge(s: &str); +} + +macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { + + pub unsafe fn $func(x: $ty) -> $ty { + dont_merge(stringify!(func)); + + let y; + asm!(concat!($mov," {}, {}"), out($class) y, in($class) x); + y + } +};} + +macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => { + + pub unsafe fn $func(x: $ty) -> $ty { + dont_merge(stringify!(func)); + + let y; + asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); + y + } +};} + +// systemz-LABEL: sym_fn_32: +// systemz: #APP +// systemz: brasl %r14, extern_func@PLT +// systemz: #NO_APP +#[cfg(s390x)] +pub unsafe fn sym_fn_32() { + asm!("brasl %r14, {}", sym extern_func); +} + +// CHECK-LABEL: reg_i32: +// CHECK: #APP +// CHECK: lgr r{{[0-15]+}}, r{{[0-15]+}} +// CHECK: #NO_APP +check!(reg_i32, i32, reg, "lgr"); |
