aboutsummaryrefslogtreecommitdiff
path: root/src-self-hosted
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-01-06 14:07:56 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-01-06 14:07:56 -0500
commit0a9daeb37e997ff75dcd16d1fc3b4cc143314e85 (patch)
tree05ca7f6b64b1e40fc16a595816f3a632a986617c /src-self-hosted
parentc30106c90665079f525129e344cc1c13e4db162b (diff)
parentd09bd3d86c4d36ad608a91b36c9a6eb6208c9626 (diff)
downloadzig-0a9daeb37e997ff75dcd16d1fc3b4cc143314e85.tar.gz
zig-0a9daeb37e997ff75dcd16d1fc3b4cc143314e85.zip
Merge branch 'cc-work' of https://github.com/LemonBoy/zig into LemonBoy-cc-work
Diffstat (limited to 'src-self-hosted')
-rw-r--r--src-self-hosted/translate_c.zig21
-rw-r--r--src-self-hosted/type.zig3
2 files changed, 20 insertions, 4 deletions
diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig
index 730c93e037..11db898de4 100644
--- a/src-self-hosted/translate_c.zig
+++ b/src-self-hosted/translate_c.zig
@@ -11,7 +11,7 @@ const CToken = ctok.CToken;
const mem = std.mem;
const math = std.math;
-const CallingConvention = std.builtin.TypeInfo.CallingConvention;
+const CallingConvention = std.builtin.CallingConvention;
pub const ClangErrMsg = Stage2ErrorMsg;
@@ -3690,6 +3690,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
.lib_name = null,
.align_expr = null,
.section_expr = null,
+ .callconv_expr = null,
};
const block = try transCreateNodeBlock(c, null);
@@ -4141,6 +4142,11 @@ fn transCC(
switch (clang_cc) {
.C => return CallingConvention.C,
.X86StdCall => return CallingConvention.Stdcall,
+ .X86FastCall => return CallingConvention.Fastcall,
+ .X86VectorCall, .AArch64VectorCall => return CallingConvention.Vectorcall,
+ .X86ThisCall => return CallingConvention.Thiscall,
+ .AAPCS => return CallingConvention.AAPCS,
+ .AAPCS_VFP => return CallingConvention.AAPCSVFP,
else => return revertAndWarn(
rp,
error.UnsupportedType,
@@ -4196,7 +4202,6 @@ fn finishTransFnProto(
// pub extern fn name(...) T
const pub_tok = if (is_pub) try appendToken(rp.c, .Keyword_pub, "pub") else null;
- const cc_tok = if (cc == .Stdcall) try appendToken(rp.c, .Keyword_stdcallcc, "stdcallcc") else null;
const extern_export_inline_tok = if (is_export)
try appendToken(rp.c, .Keyword_export, "export")
else if (cc == .C and is_extern)
@@ -4303,6 +4308,14 @@ fn finishTransFnProto(
break :blk null;
};
+ const callconv_expr = if (extern_export_inline_tok != null) null else blk: {
+ _ = try appendToken(rp.c, .Keyword_callconv, "callconv");
+ _ = try appendToken(rp.c, .LParen, "(");
+ const expr = try transCreateNodeEnumLiteral(rp.c, @tagName(cc));
+ _ = try appendToken(rp.c, .RParen, ")");
+ break :blk expr;
+ };
+
const return_type_node = blk: {
if (ZigClangFunctionType_getNoReturnAttr(fn_ty)) {
break :blk try transCreateNodeIdentifier(rp.c, "noreturn");
@@ -4333,11 +4346,12 @@ fn finishTransFnProto(
.return_type = .{ .Explicit = return_type_node },
.var_args_token = null, // TODO this field is broken in the AST data model
.extern_export_inline_token = extern_export_inline_tok,
- .cc_token = cc_tok,
+ .cc_token = null,
.body_node = null,
.lib_name = null,
.align_expr = align_expr,
.section_expr = linksection_expr,
+ .callconv_expr = callconv_expr,
};
return fn_proto;
}
@@ -4686,6 +4700,7 @@ fn transMacroFnDefine(c: *Context, it: *ctok.TokenList.Iterator, name: []const u
.lib_name = null,
.align_expr = null,
.section_expr = null,
+ .callconv_expr = null,
};
const block = try transCreateNodeBlock(c, null);
diff --git a/src-self-hosted/type.zig b/src-self-hosted/type.zig
index d3f3ba746a..d4ffc355c0 100644
--- a/src-self-hosted/type.zig
+++ b/src-self-hosted/type.zig
@@ -337,7 +337,7 @@ pub const Type = struct {
}
};
- const CallingConvention = builtin.TypeInfo.CallingConvention;
+ const CallingConvention = builtin.CallingConvention;
pub const Param = struct {
is_noalias: bool,
@@ -352,6 +352,7 @@ pub const Type = struct {
.Naked => "nakedcc ",
.Stdcall => "stdcallcc ",
.Async => "async ",
+ else => unreachable,
};
}