authorgravatar for sreeharisreedev1@gmail.comSreehari S <sreeharisreedev1@gmail.com> 2021-04-08 21:00:53-07:00
committergravatar for sreeharisreedev1@gmail.comSreehari S <sreeharisreedev1@gmail.com> 2021-04-08 21:00:53-07:00
log9ebdbca379fb71da7236e7534e1d3465f7fb151f
tree2dc10ac2490a756c8c568259ee0984e053da2d71
parent9f744f19e7036df9a410f780f3394f6669b8079e

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 case CallingConventionSysV:
1975 if (g->zig_target->arch != ZigLLVM_x86_64)
1976 allowed_platforms = "x86_64";
1977 break;
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:
......@@ -9101,6 +9105,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
91019105 static_assert(CallingConventionAPCS == 11, "");
91029106 static_assert(CallingConventionAAPCS == 12, "");
91039107 static_assert(CallingConventionAAPCSVFP == 13, "");
9108 static_assert(CallingConventionSysV == 14, "");
91049109
91059110 static_assert(BuiltinPtrSizeOne == 0, "");
91069111 static_assert(BuiltinPtrSizeMany == 1, "");
src/stage1/ir.cpp+1
......@@ -19223,6 +19223,7 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport
1922319223 case CallingConventionAPCS:
1922419224 case CallingConventionAAPCS:
1922519225 case CallingConventionAAPCSVFP:
19226 case CallingConventionSysV:
1922619227 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc);
1922719228 fn_entry->section_name = section_name;
1922819229 break;
src/translate_c.zig+1
......@@ -4381,6 +4381,7 @@ fn transCC(
43814381 .X86ThisCall => return CallingConvention.Thiscall,
43824382 .AAPCS => return CallingConvention.AAPCS,
43834383 .AAPCS_VFP => return CallingConvention.AAPCSVFP,
4384 .X86_64SysV => return CallingConvention.SysV,
43844385 else => return fail(
43854386 c,
43864387 error.UnsupportedType,