4
4
//@ compile-flags: -Copt-level=1
5
5
6
6
//@ add-core-stubs
7
- //@ revisions: MSVC MINGW
7
+ //@ revisions: MSVC MINGW softfloat
8
8
//@ [MSVC] needs-llvm-components: x86
9
- //@ [MINGW] needs-llvm-components: x86
10
9
//@ [MSVC] compile-flags: --target x86_64-pc-windows-msvc
11
- //@ [ MINGW] compile-flags: --target x86_64-pc-windows-gnu
10
+ // Use `WIN` as a common prefix for MSVC and MINGW but *not* the softfloat test.
12
11
//@ [MSVC] filecheck-flags: --check-prefix=WIN
12
+ //@ [MINGW] needs-llvm-components: x86
13
+ //@ [MINGW] compile-flags: --target x86_64-pc-windows-gnu
13
14
//@ [MINGW] filecheck-flags: --check-prefix=WIN
15
+ // The `x86_64-unknown-uefi` target also uses the Windows calling convention,
16
+ // but does not have SSE registers available.
17
+ //@ [softfloat] needs-llvm-components: x86
18
+ //@ [softfloat] compile-flags: --target x86_64-unknown-uefi
14
19
15
20
#![ crate_type = "lib" ]
16
21
#![ no_std]
@@ -28,24 +33,26 @@ extern "C" {
28
33
pub extern "C" fn pass ( _arg0 : u32 , arg1 : i128 ) {
29
34
// CHECK-LABEL: @pass(
30
35
// i128 is passed indirectly on Windows. It should load the pointer to the stack and pass
31
- // a pointer to that allocation.
32
- // WIN -SAME: %_arg0, ptr{{.*}} %arg1)
33
- // WIN : [[PASS:%[_0-9]+]] = alloca [16 x i8], align 16
34
- // WIN : [[LOADED:%[_0-9]+]] = load i128, ptr %arg1
35
- // WIN : store i128 [[LOADED]], ptr [[PASS]]
36
- // WIN : call void @extern_call
36
+ // a pointer to that allocation. The softfloat ABI works the same.
37
+ // CHECK -SAME: %_arg0, ptr{{.*}} %arg1)
38
+ // CHECK : [[PASS:%[_0-9]+]] = alloca [16 x i8], align 16
39
+ // CHECK : [[LOADED:%[_0-9]+]] = load i128, ptr %arg1
40
+ // CHECK : store i128 [[LOADED]], ptr [[PASS]]
41
+ // CHECK : call void @extern_call
37
42
unsafe { extern_call ( arg1) } ;
38
43
}
39
44
40
45
// Check that we produce the correct return ABI
41
46
#[ no_mangle]
42
47
pub extern "C" fn ret ( _arg0 : u32 , arg1 : i128 ) -> i128 {
43
- // CHECK -LABEL: @ret(
48
+ // WIN -LABEL: @ret(
44
49
// i128 is returned in xmm0 on Windows
45
50
// FIXME(#134288): This may change for the `-msvc` targets in the future.
46
51
// WIN-SAME: i32{{.*}} %_arg0, ptr{{.*}} %arg1)
47
52
// WIN: [[LOADED:%[_0-9]+]] = load <16 x i8>, ptr %arg1
48
53
// WIN-NEXT: ret <16 x i8> [[LOADED]]
54
+ // The softfloat ABI returns this indirectly.
55
+ // softfloat-LABEL: i128 @ret(i32{{.*}} %_arg0, ptr{{.*}} %arg1)
49
56
arg1
50
57
}
51
58
@@ -57,6 +64,7 @@ pub extern "C" fn forward(dst: *mut i128) {
57
64
// WIN: [[RETURNED:%[_0-9]+]] = tail call <16 x i8> @extern_ret()
58
65
// WIN: store <16 x i8> [[RETURNED]], ptr %dst
59
66
// WIN: ret void
67
+ // softfloat: [[RETURNED:%[_0-9]+]] = tail call {{.*}}i128 @extern_ret()
60
68
unsafe { * dst = extern_ret ( ) } ;
61
69
}
62
70
@@ -70,10 +78,10 @@ struct RetAggregate {
70
78
pub extern "C" fn ret_aggregate ( _arg0 : u32 , arg1 : i128 ) -> RetAggregate {
71
79
// CHECK-LABEL: @ret_aggregate(
72
80
// Aggregates should also be returned indirectly
73
- // WIN -SAME: ptr{{.*}}sret([32 x i8]){{.*}}[[RET:%[_0-9]+]], i32{{.*}}%_arg0, ptr{{.*}}%arg1)
74
- // WIN : [[LOADED:%[_0-9]+]] = load i128, ptr %arg1
75
- // WIN : [[GEP:%[_0-9]+]] = getelementptr{{.*}}, ptr [[RET]]
76
- // WIN : store i128 [[LOADED]], ptr [[GEP]]
77
- // WIN : ret void
81
+ // CHECK -SAME: ptr{{.*}}sret([32 x i8]){{.*}}[[RET:%[_0-9]+]], i32{{.*}}%_arg0, ptr{{.*}}%arg1)
82
+ // CHECK : [[LOADED:%[_0-9]+]] = load i128, ptr %arg1
83
+ // CHECK : [[GEP:%[_0-9]+]] = getelementptr{{.*}}, ptr [[RET]]
84
+ // CHECK : store i128 [[LOADED]], ptr [[GEP]]
85
+ // CHECK : ret void
78
86
RetAggregate { a : 1 , b : arg1 }
79
87
}
0 commit comments