Skip to content

Commit 5eb4de1

Browse files
committed
Update the comments for Win64 ABI in tests.
1 parent 3c31841 commit 5eb4de1

File tree

2 files changed

+38
-54
lines changed

2 files changed

+38
-54
lines changed

src/test/run-make/extern-fn-struct-passing-abi/test.c

+37-14
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ struct Huge {
3838
int32_t e;
3939
};
4040

41-
// SysV ABI:
41+
// System V x86_64 ABI:
4242
// a, b, c, d, e should be in registers
4343
// s should be byval pointer
44+
//
45+
// Win64 ABI:
46+
// a, b, c, d should be in registers
47+
// e should be on the stack
48+
// s should be byval pointer
4449
void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) {
4550
assert(a == 1);
4651
assert(b == 2);
@@ -53,10 +58,16 @@ void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Re
5358
assert(s.d == 556);
5459
}
5560

56-
// SysV ABI:
61+
// System V x86_64 ABI:
5762
// a, b, c, d, e, f, g should be in sse registers
5863
// s should be split across 2 registers
5964
// t should be byval pointer
65+
//
66+
// Win64 ABI:
67+
// a, b, c, d should be in sse registers
68+
// e, f, g should be on the stack
69+
// s should be on the stack (treated as 2 i64's)
70+
// t should be on the stack (treated as an i64 and a double)
6071
void byval_rect_floats(float a, float b, double c, float d, float e,
6172
float f, double g, struct Rect s, struct FloatRect t) {
6273
assert(a == 1.);
@@ -75,9 +86,15 @@ void byval_rect_floats(float a, float b, double c, float d, float e,
7586
assert(t.c == 8.);
7687
}
7788

78-
// SysV ABI:
79-
// a, b, d, e should be in registers
89+
// System V x86_64 ABI:
90+
// a, b, d, e, f should be in registers
91+
// c passed via sse registers
92+
// s should be byval pointer
93+
//
94+
// Win64 ABI:
95+
// a, b, d should be in registers
8096
// c passed via sse registers
97+
// e, f should be on the stack
8198
// s should be byval pointer
8299
void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d,
83100
int32_t e, int32_t f, struct Rect s) {
@@ -93,9 +110,9 @@ void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d,
93110
assert(s.d == 556);
94111
}
95112

96-
// SysV ABI:
113+
// System V x86_64 & Win64 ABI:
97114
// a, b should be in registers
98-
// s should be split across 2 registers
115+
// s should be split across 2 integer registers
99116
void split_rect(int32_t a, int32_t b, struct Rect s) {
100117
assert(a == 1);
101118
assert(b == 2);
@@ -105,9 +122,9 @@ void split_rect(int32_t a, int32_t b, struct Rect s) {
105122
assert(s.d == 556);
106123
}
107124

108-
// SysV ABI:
125+
// System V x86_64 & Win64 ABI:
109126
// a, b should be in sse registers
110-
// s should be split across int32_t & sse registers
127+
// s should be split across integer & sse registers
111128
void split_rect_floats(float a, float b, struct FloatRect s) {
112129
assert(a == 1.);
113130
assert(b == 2.);
@@ -116,10 +133,16 @@ void split_rect_floats(float a, float b, struct FloatRect s) {
116133
assert(s.c == 8.);
117134
}
118135

119-
// SysV ABI:
136+
// System V x86_64 ABI:
120137
// a, b, d, f should be in registers
121138
// c, e passed via sse registers
122139
// s should be split across 2 registers
140+
//
141+
// Win64 ABI:
142+
// a, b, d should be in registers
143+
// c passed via sse registers
144+
// e, f should be on the stack
145+
// s should be on the stack (treated as 2 i64's)
123146
void split_rect_with_floats(int32_t a, int32_t b, float c,
124147
int32_t d, float e, int32_t f, struct Rect s) {
125148
assert(a == 1);
@@ -134,7 +157,7 @@ void split_rect_with_floats(int32_t a, int32_t b, float c,
134157
assert(s.d == 556);
135158
}
136159

137-
// SysV ABI:
160+
// System V x86_64 & Win64 ABI:
138161
// a, b, c should be in registers
139162
// s should be split across 2 registers
140163
// t should be a byval pointer
@@ -152,7 +175,7 @@ void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct
152175
assert(t.d == 556);
153176
}
154177

155-
// SysV ABI:
178+
// System V x86_64 & Win64 ABI:
156179
// a, b should in registers
157180
// s and return should be split across 2 registers
158181
struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) {
@@ -165,7 +188,7 @@ struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) {
165188
return s;
166189
}
167190

168-
// SysV ABI:
191+
// System V x86_64 & Win64 ABI:
169192
// a, b, c, d should be in registers
170193
// return should be in a hidden sret pointer
171194
// s should be a byval pointer
@@ -184,7 +207,7 @@ struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d,
184207
return t;
185208
}
186209

187-
// SysV ABI:
210+
// System V x86_64 & Win64 ABI:
188211
// a, b should be in registers
189212
// return should be in a hidden sret pointer
190213
// s should be split across 2 registers
@@ -201,7 +224,7 @@ struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) {
201224
return t;
202225
}
203226

204-
// SysV ABI:
227+
// System V x86_64 & Win64 ABI:
205228
// s should be byval pointer (since sizeof(s) > 16)
206229
// return should in a hidden sret pointer
207230
struct Huge huge_struct(struct Huge s) {

src/test/run-make/extern-fn-struct-passing-abi/test.rs

+1-40
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// Passing structs via FFI should work regardless of whether
12-
// the functions gets passed in multiple registers or is a hidden pointer
12+
// they get passed in multiple registers, byval pointers or the stack
1313

1414
#[derive(Clone, Copy, Debug, PartialEq)]
1515
#[repr(C)]
@@ -48,66 +48,27 @@ struct Huge {
4848

4949
#[link(name = "test", kind = "static")]
5050
extern {
51-
// SysV ABI:
52-
// a, b, c, d, e should be in registers
53-
// s should be byval pointer
5451
fn byval_rect(a: i32, b: i32, c: i32, d: i32, e: i32, s: Rect);
5552

56-
// SysV ABI:
57-
// a, b, c, d, e, f, g should be in sse registers
58-
// s should be split across 2 registers
59-
// t should be byval pointer
6053
fn byval_rect_floats(a: f32, b: f32, c: f64, d: f32, e: f32,
6154
f: f32, g: f64, s: Rect, t: FloatRect);
6255

63-
// SysV ABI:
64-
// a, b, d, e should be in registers
65-
// c passed via sse registers
66-
// s should be byval pointer
6756
fn byval_rect_with_float(a: i32, b: i32, c: f32, d: i32, e: i32, f: i32, s: Rect);
6857

69-
// SysV ABI:
70-
// a, b should be in registers
71-
// s should be split across 2 registers
7258
fn split_rect(a: i32, b: i32, s: Rect);
7359

74-
// SysV ABI:
75-
// a, b should be in sse registers
76-
// s should be split across int & sse registers
7760
fn split_rect_floats(a: f32, b: f32, s: FloatRect);
7861

79-
// SysV ABI:
80-
// a, b, d, f should be in registers
81-
// c, e passed via sse registers
82-
// s should be split across 2 registers
8362
fn split_rect_with_floats(a: i32, b: i32, c: f32, d: i32, e: f32, f: i32, s: Rect);
8463

85-
// SysV ABI:
86-
// a, b, c should be in registers
87-
// s should be split across 2 registers
88-
// t should be a byval pointer
8964
fn split_and_byval_rect(a: i32, b: i32, c: i32, s: Rect, t: Rect);
9065

91-
// SysV ABI:
92-
// a, b should in registers
93-
// s and return should be split across 2 registers
9466
fn split_ret_byval_struct(a: i32, b: i32, s: Rect) -> Rect;
9567

96-
// SysV ABI:
97-
// a, b, c, d should be in registers
98-
// return should be in a hidden sret pointer
99-
// s should be a byval pointer
10068
fn sret_byval_struct(a: i32, b: i32, c: i32, d: i32, s: Rect) -> BiggerRect;
10169

102-
// SysV ABI:
103-
// a, b should be in registers
104-
// return should be in a hidden sret pointer
105-
// s should be split across 2 registers
10670
fn sret_split_struct(a: i32, b: i32, s: Rect) -> BiggerRect;
10771

108-
// SysV ABI:
109-
// s should be byval pointer (since sizeof(s) > 16)
110-
// return should in a hidden sret pointer
11172
fn huge_struct(s: Huge) -> Huge;
11273
}
11374

0 commit comments

Comments
 (0)