@@ -160,134 +160,82 @@ pub const OptimizeMode = enum {
160
160
/// Deprecated; use OptimizeMode.
161
161
pub const Mode = OptimizeMode ;
162
162
163
- /// This data structure is used by the Zig language code generation and
164
- /// therefore must be kept in sync with the compiler implementation.
165
- pub const CallingConvention = enum (u8 ) {
166
- /// This is the default Zig calling convention used when not using `export` on `fn`
167
- /// and no other calling convention is specified.
168
- Unspecified ,
169
- /// Matches the C ABI for the target.
170
- /// This is the default calling convention when using `export` on `fn`
171
- /// and no other calling convention is specified.
172
- C ,
173
- /// This makes a function not have any function prologue or epilogue,
174
- /// making the function itself uncallable in regular Zig code.
175
- /// This can be useful when integrating with assembly.
176
- Naked ,
177
- /// Functions with this calling convention are called asynchronously,
178
- /// as if called as `async function()`.
179
- Async ,
180
- /// Functions with this calling convention are inlined at all call sites.
181
- Inline ,
182
- /// x86-only.
183
- Interrupt ,
184
- Signal ,
185
- /// x86-only.
186
- Stdcall ,
187
- /// x86-only.
188
- Fastcall ,
189
- /// x86-only.
190
- Vectorcall ,
191
- /// x86-only.
192
- Thiscall ,
193
- /// ARM Procedure Call Standard (obsolete)
194
- /// ARM-only.
195
- APCS ,
196
- /// ARM Architecture Procedure Call Standard (current standard)
197
- /// ARM-only.
198
- AAPCS ,
199
- /// ARM Architecture Procedure Call Standard Vector Floating-Point
200
- /// ARM-only.
201
- AAPCSVFP ,
202
- /// x86-64-only.
203
- SysV ,
204
- /// x86-64-only.
205
- Win64 ,
206
- /// AMD GPU, NVPTX, or SPIR-V kernel
207
- Kernel ,
208
- // Vulkan-only
209
- Fragment ,
210
- Vertex ,
211
- };
212
-
213
163
/// The calling convention of a function defines how arguments and return values are passed, as well
214
164
/// as any other requirements which callers and callees must respect, such as register preservation
215
165
/// and stack alignment.
216
166
///
217
167
/// This data structure is used by the Zig language code generation and
218
168
/// therefore must be kept in sync with the compiler implementation.
219
- ///
220
- /// TODO: this will be renamed `CallingConvention` after an initial zig1.wasm update.
221
- pub const NewCallingConvention = union (enum (u8 )) {
222
- pub const Tag = @typeInfo (NewCallingConvention ).@"union" .tag_type .? ;
169
+ pub const CallingConvention = union (enum (u8 )) {
170
+ pub const Tag = @typeInfo (CallingConvention ).@"union" .tag_type .? ;
223
171
224
172
/// This is an alias for the default C calling convention for this target.
225
173
/// Functions marked as `extern` or `export` are given this calling convention by default.
226
174
pub const c = builtin .target .defaultCCallingConvention ().? ;
227
175
228
- pub const winapi : NewCallingConvention = switch (builtin .target .arch ) {
176
+ pub const winapi : CallingConvention = switch (builtin .target .arch ) {
229
177
.x86_64 = > .{ .x86_64_win = .{} },
230
178
.x86 = > .{ .x86_stdcall = .{} },
231
179
.aarch64 , .aarch64_be = > .{ .aarch64_aapcs_win = .{} },
232
180
.arm , .armeb , .thumb , .thumbeb = > .{ .arm_aapcs_vfp = .{} },
233
181
else = > unreachable ,
234
182
};
235
183
236
- pub const kernel : NewCallingConvention = switch (builtin .target .cpu .arch ) {
184
+ pub const kernel : CallingConvention = switch (builtin .target .cpu .arch ) {
237
185
.amdgcn = > .amdgcn_kernel ,
238
186
.nvptx , .nvptx64 = > .nvptx_kernel ,
239
187
.spirv , .spirv32 , .spirv64 = > .spirv_kernel ,
240
188
else = > unreachable ,
241
189
};
242
190
243
191
/// Deprecated; use `.auto`.
244
- pub const Unspecified : NewCallingConvention = .auto ;
192
+ pub const Unspecified : CallingConvention = .auto ;
245
193
/// Deprecated; use `.c`.
246
- pub const C : NewCallingConvention = .c ;
194
+ pub const C : CallingConvention = .c ;
247
195
/// Deprecated; use `.naked`.
248
- pub const Naked : NewCallingConvention = .naked ;
196
+ pub const Naked : CallingConvention = .naked ;
249
197
/// Deprecated; use `.@"async"`.
250
- pub const Async : NewCallingConvention = .@"async" ;
198
+ pub const Async : CallingConvention = .@"async" ;
251
199
/// Deprecated; use `.@"inline"`.
252
- pub const Inline : NewCallingConvention = .@"inline" ;
200
+ pub const Inline : CallingConvention = .@"inline" ;
253
201
/// Deprecated; use `.x86_64_interrupt`, `.x86_interrupt`, or `.avr_interrupt`.
254
- pub const Interrupt : NewCallingConvention = switch (builtin .target .cpu .arch ) {
202
+ pub const Interrupt : CallingConvention = switch (builtin .target .cpu .arch ) {
255
203
.x86_64 = > .{ .x86_64_interrupt = .{} },
256
204
.x86 = > .{ .x86_interrupt = .{} },
257
205
.avr = > .avr_interrupt ,
258
206
else = > unreachable ,
259
207
};
260
208
/// Deprecated; use `.avr_signal`.
261
- pub const Signal : NewCallingConvention = .avr_signal ;
209
+ pub const Signal : CallingConvention = .avr_signal ;
262
210
/// Deprecated; use `.x86_stdcall`.
263
- pub const Stdcall : NewCallingConvention = .{ .x86_stdcall = .{} };
211
+ pub const Stdcall : CallingConvention = .{ .x86_stdcall = .{} };
264
212
/// Deprecated; use `.x86_fastcall`.
265
- pub const Fastcall : NewCallingConvention = .{ .x86_fastcall = .{} };
213
+ pub const Fastcall : CallingConvention = .{ .x86_fastcall = .{} };
266
214
/// Deprecated; use `.x86_64_vectorcall`, `.x86_vectorcall`, or `aarch64_vfabi`.
267
- pub const Vectorcall : NewCallingConvention = switch (builtin .target .cpu .arch ) {
215
+ pub const Vectorcall : CallingConvention = switch (builtin .target .cpu .arch ) {
268
216
.x86_64 = > .{ .x86_64_vectorcall = .{} },
269
217
.x86 = > .{ .x86_vectorcall = .{} },
270
218
.aarch64 , .aarch64_be = > .{ .aarch64_vfabi = .{} },
271
219
else = > unreachable ,
272
220
};
273
221
/// Deprecated; use `.x86_thiscall`.
274
- pub const Thiscall : NewCallingConvention = .{ .x86_thiscall = .{} };
222
+ pub const Thiscall : CallingConvention = .{ .x86_thiscall = .{} };
275
223
/// Deprecated; use `.arm_apcs`.
276
- pub const APCS : NewCallingConvention = .{ .arm_apcs = .{} };
224
+ pub const APCS : CallingConvention = .{ .arm_apcs = .{} };
277
225
/// Deprecated; use `.arm_aapcs`.
278
- pub const AAPCS : NewCallingConvention = .{ .arm_aapcs = .{} };
226
+ pub const AAPCS : CallingConvention = .{ .arm_aapcs = .{} };
279
227
/// Deprecated; use `.arm_aapcs_vfp`.
280
- pub const AAPCSVFP : NewCallingConvention = .{ .arm_aapcs_vfp = .{} };
228
+ pub const AAPCSVFP : CallingConvention = .{ .arm_aapcs_vfp = .{} };
281
229
/// Deprecated; use `.x86_64_sysv`.
282
- pub const SysV : NewCallingConvention = .{ .x86_64_sysv = .{} };
230
+ pub const SysV : CallingConvention = .{ .x86_64_sysv = .{} };
283
231
/// Deprecated; use `.x86_64_win`.
284
- pub const Win64 : NewCallingConvention = .{ .x86_64_win = .{} };
232
+ pub const Win64 : CallingConvention = .{ .x86_64_win = .{} };
285
233
/// Deprecated; use `.kernel`.
286
- pub const Kernel : NewCallingConvention = .kernel ;
234
+ pub const Kernel : CallingConvention = .kernel ;
287
235
/// Deprecated; use `.spirv_fragment`.
288
- pub const Fragment : NewCallingConvention = .spirv_fragment ;
236
+ pub const Fragment : CallingConvention = .spirv_fragment ;
289
237
/// Deprecated; use `.spirv_vertex`.
290
- pub const Vertex : NewCallingConvention = .spirv_vertex ;
238
+ pub const Vertex : CallingConvention = .spirv_vertex ;
291
239
292
240
/// The default Zig calling convention when neither `export` nor `inline` is specified.
293
241
/// This calling convention makes no guarantees about stack alignment, registers, etc.
@@ -535,9 +483,16 @@ pub const NewCallingConvention = union(enum(u8)) {
535
483
/// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.
536
484
pub const archs = std .Target .Cpu .Arch .fromCallconv ;
537
485
538
- pub fn eql (a : NewCallingConvention , b : NewCallingConvention ) bool {
486
+ pub fn eql (a : CallingConvention , b : CallingConvention ) bool {
539
487
return std .meta .eql (a , b );
540
488
}
489
+
490
+ pub fn withStackAlign (cc : CallingConvention , incoming_stack_alignment : u64 ) CallingConvention {
491
+ const tag : CallingConvention.Tag = cc ;
492
+ var result = cc ;
493
+ @field (result , tag ).incoming_stack_alignment = incoming_stack_alignment ;
494
+ return result ;
495
+ }
541
496
};
542
497
543
498
/// This data structure is used by the Zig language code generation and
0 commit comments