authorgravatar for hannesbredberg@gmail.comHannes Bredberg <hannesbredberg@gmail.com> 2022-05-06 21:32:22+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-08 16:28:10-04:00
logea3f5905f0635d0c0cb3983ba5ca6c92859e9d81
tree8a6005d4eea0b538141a7620236debfcf914b709
parent9416b4d993e5e386c9208e9a52e4e881eee8cf72

Add Win64 calling convention

Closes ziglang/zig#11585

6 files changed, 13 insertions(+), 0 deletions(-)

lib/std/builtin.zig+1
......@@ -147,6 +147,7 @@ pub const CallingConvention = enum {
147147 AAPCS,
148148 AAPCSVFP,
149149 SysV,
150 Win64,
150151 PtxKernel,
151152};
152153
src/codegen/llvm.zig+1
......@@ -7940,6 +7940,7 @@ fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) llvm.Ca
79407940 },
79417941 .Signal => .AVR_SIGNAL,
79427942 .SysV => .X86_64_SysV,
7943 .Win64 => .Win64,
79437944 .PtxKernel => return switch (target.cpu.arch) {
79447945 .nvptx, .nvptx64 => .PTX_Kernel,
79457946 else => unreachable,
src/stage1/all_types.hpp+1
......@@ -84,6 +84,7 @@ enum CallingConvention {
8484 CallingConventionAAPCS,
8585 CallingConventionAAPCSVFP,
8686 CallingConventionSysV,
87 CallingConventionWin64,
8788 CallingConventionPtxKernel
8889};
8990
src/stage1/analyze.cpp+4
......@@ -991,6 +991,7 @@ const char *calling_convention_name(CallingConvention cc) {
991991 case CallingConventionAAPCSVFP: return "AAPCSVFP";
992992 case CallingConventionInline: return "Inline";
993993 case CallingConventionSysV: return "SysV";
994 case CallingConventionWin64: return "Win64";
994995 case CallingConventionPtxKernel: return "PtxKernel";
995996 }
996997 zig_unreachable();
......@@ -1015,6 +1016,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
10151016 case CallingConventionAAPCS:
10161017 case CallingConventionAAPCSVFP:
10171018 case CallingConventionSysV:
1019 case CallingConventionWin64:
10181020 return false;
10191021 }
10201022 zig_unreachable();
......@@ -2006,6 +2008,7 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_
20062008 allowed_platforms = "ARM";
20072009 break;
20082010 case CallingConventionSysV:
2011 case CallingConventionWin64:
20092012 if (g->zig_target->arch != ZigLLVM_x86_64)
20102013 allowed_platforms = "x86_64";
20112014 break;
......@@ -3846,6 +3849,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
38463849 case CallingConventionAAPCS:
38473850 case CallingConventionAAPCSVFP:
38483851 case CallingConventionSysV:
3852 case CallingConventionWin64:
38493853 case CallingConventionPtxKernel:
38503854 add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
38513855 GlobalLinkageIdStrong, fn_cc);
src/stage1/codegen.cpp+5
......@@ -209,6 +209,9 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
209209 case CallingConventionSysV:
210210 assert(g->zig_target->arch == ZigLLVM_x86_64);
211211 return ZigLLVM_X86_64_SysV;
212 case CallingConventionWin64:
213 assert(g->zig_target->arch == ZigLLVM_x86_64);
214 return ZigLLVM_Win64;
212215 case CallingConventionPtxKernel:
213216 assert(g->zig_target->arch == ZigLLVM_nvptx ||
214217 g->zig_target->arch == ZigLLVM_nvptx64);
......@@ -359,6 +362,7 @@ static bool cc_want_sret_attr(CallingConvention cc) {
359362 case CallingConventionAAPCS:
360363 case CallingConventionAAPCSVFP:
361364 case CallingConventionSysV:
365 case CallingConventionWin64:
362366 case CallingConventionPtxKernel:
363367 return true;
364368 case CallingConventionAsync:
......@@ -10033,6 +10037,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
1003310037 static_assert(CallingConventionAAPCS == 12, "");
1003410038 static_assert(CallingConventionAAPCSVFP == 13, "");
1003510039 static_assert(CallingConventionSysV == 14, "");
10040 static_assert(CallingConventionWin64 == 15, "");
1003610041
1003710042 static_assert(BuiltinPtrSizeOne == 0, "");
1003810043 static_assert(BuiltinPtrSizeMany == 1, "");
src/stage1/ir.cpp+1
......@@ -11743,6 +11743,7 @@ static Stage1AirInst *ir_analyze_instruction_export(IrAnalyze *ira, Stage1ZirIns
1174311743 case CallingConventionAAPCS:
1174411744 case CallingConventionAAPCSVFP:
1174511745 case CallingConventionSysV:
11746 case CallingConventionWin64:
1174611747 case CallingConventionPtxKernel:
1174711748 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc);
1174811749 fn_entry->section_name = section_name;