1 // Checks that we correctly codegen extern "C" functions returning structs.
2 // See issues #52638 and #86163.
4 // compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
5 // needs-llvm-components: sparc
6 #![feature(no_core, lang_items)]
21 // CHECK: define i64 @structbool()
23 // CHECK-NEXT: ret i64 72057594037927936
25 pub extern "C" fn structbool() -> Bool {
31 pub struct BoolFloat {
36 // CHECK: define inreg { i32, float } @structboolfloat()
38 // CHECK-NEXT: ret { i32, float } { i32 16777216, float 0x40091EB860000000 }
40 pub extern "C" fn structboolfloat() -> BoolFloat {
41 BoolFloat { b: true, f: 3.14 }
44 // CHECK: define void @structboolfloat_input({ i32, float } inreg %0)
47 pub extern "C" fn structboolfloat_input(a: BoolFloat) { }
51 pub struct ShortDouble {
56 // CHECK: define { i64, double } @structshortdouble()
58 // CHECK-NEXT: ret { i64, double } { i64 34621422135410688, double 3.140000e+00 }
60 pub extern "C" fn structshortdouble() -> ShortDouble {
61 ShortDouble { s: 123, d: 3.14 }
64 // CHECK: define void @structshortdouble_input({ i64, double } %0)
67 pub extern "C" fn structshortdouble_input(a: ShortDouble) { }
71 pub struct FloatLongFloat {
77 // CHECK: define inreg { float, i32, i64, float, i32 } @structfloatlongfloat()
79 // CHECK-NEXT: ret { float, i32, i64, float, i32 } { float 0x3FB99999A0000000, i32 undef, i64 123, float 0x40091EB860000000, i32 undef }
81 pub extern "C" fn structfloatlongfloat() -> FloatLongFloat {
82 FloatLongFloat { f: 0.1, i: 123, g: 3.14 }
86 pub struct FloatFloat {
92 pub struct NestedStructs {
97 // CHECK: define inreg { float, float, float, float } @structnestestructs()
99 // CHECK-NEXT: ret { float, float, float, float } { float 0x3FB99999A0000000, float 0x3FF19999A0000000, float 0x40019999A0000000, float 0x400A666660000000 }
101 pub extern "C" fn structnestestructs() -> NestedStructs {
102 NestedStructs { a: FloatFloat { f: 0.1, g: 1.1 }, b: FloatFloat { f: 2.2, g: 3.3 } }