authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-28 13:11:40-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-04-28 13:11:40-04:00
log2c9ed6daee002d759332b74bcb875c946e4a02e0
tree3da50d4ec3ed65e786b3e574997d2fdb0ca0e200
parentbc06e19828428ed9c2fc3698f418d46e62e327f5
parent906ac7b2f9ef9a485c45884d71b6e30379084641
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #8472 from sreehax/master

callconv: add SysV

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

lib/std/builtin.zig+1
......@@ -165,6 +165,7 @@ pub const CallingConvention = enum {
165165 APCS,
166166 AAPCS,
167167 AAPCSVFP,
168 SysV
168169};
169170
170171/// This data structure is used by the Zig language code generation and
src/stage1/all_types.hpp+1
......@@ -84,6 +84,7 @@ enum CallingConvention {
8484 CallingConventionAPCS,
8585 CallingConventionAAPCS,
8686 CallingConventionAAPCSVFP,
87 CallingConventionSysV
8788};
8889
8990// This one corresponds to the builtin.zig enum.
src/stage1/analyze.cpp+7
......@@ -974,6 +974,7 @@ const char *calling_convention_name(CallingConvention cc) {
974974 case CallingConventionAAPCS: return "AAPCS";
975975 case CallingConventionAAPCSVFP: return "AAPCSVFP";
976976 case CallingConventionInline: return "Inline";
977 case CallingConventionSysV: return "SysV";
977978 }
978979 zig_unreachable();
979980}
......@@ -995,6 +996,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
995996 case CallingConventionAPCS:
996997 case CallingConventionAAPCS:
997998 case CallingConventionAAPCSVFP:
999 case CallingConventionSysV:
9981000 return false;
9991001 }
10001002 zig_unreachable();
......@@ -1969,6 +1971,10 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_
19691971 case CallingConventionAAPCSVFP:
19701972 if (!target_is_arm(g->zig_target))
19711973 allowed_platforms = "ARM";
1974 break;
1975 case CallingConventionSysV:
1976 if (g->zig_target->arch != ZigLLVM_x86_64)
1977 allowed_platforms = "x86_64";
19721978 }
19731979 if (allowed_platforms != nullptr) {
19741980 add_node_error(g, source_node, buf_sprintf(
......@@ -3805,6 +3811,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
38053811 case CallingConventionAPCS:
38063812 case CallingConventionAAPCS:
38073813 case CallingConventionAAPCSVFP:
3814 case CallingConventionSysV:
38083815 add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
38093816 GlobalLinkageIdStrong, fn_cc);
38103817 break;
src/stage1/codegen.cpp+5
......@@ -204,6 +204,9 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
204204 case CallingConventionSignal:
205205 assert(g->zig_target->arch == ZigLLVM_avr);
206206 return ZigLLVM_AVR_SIGNAL;
207 case CallingConventionSysV:
208 assert(g->zig_target->arch == ZigLLVM_x86_64);
209 return ZigLLVM_X86_64_SysV;
207210 }
208211 zig_unreachable();
209212}
......@@ -348,6 +351,7 @@ static bool cc_want_sret_attr(CallingConvention cc) {
348351 case CallingConventionAPCS:
349352 case CallingConventionAAPCS:
350353 case CallingConventionAAPCSVFP:
354 case CallingConventionSysV:
351355 return true;
352356 case CallingConventionAsync:
353357 case CallingConventionUnspecified:
......@@ -9077,6 +9081,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
90779081 static_assert(CallingConventionAPCS == 11, "");
90789082 static_assert(CallingConventionAAPCS == 12, "");
90799083 static_assert(CallingConventionAAPCSVFP == 13, "");
9084 static_assert(CallingConventionSysV == 14, "");
90809085
90819086 static_assert(BuiltinPtrSizeOne == 0, "");
90829087 static_assert(BuiltinPtrSizeMany == 1, "");
src/stage1/ir.cpp+1
......@@ -19216,6 +19216,7 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport
1921619216 case CallingConventionAPCS:
1921719217 case CallingConventionAAPCS:
1921819218 case CallingConventionAAPCSVFP:
19219 case CallingConventionSysV:
1921919220 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc);
1922019221 fn_entry->section_name = section_name;
1922119222 break;
src/translate_c.zig+1
......@@ -4416,6 +4416,7 @@ fn transCC(
44164416 .X86ThisCall => return CallingConvention.Thiscall,
44174417 .AAPCS => return CallingConvention.AAPCS,
44184418 .AAPCS_VFP => return CallingConvention.AAPCSVFP,
4419 .X86_64SysV => return CallingConvention.SysV,
44194420 else => return fail(
44204421 c,
44214422 error.UnsupportedType,