aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-02-11 16:01:58 -0800
committerGitHub <noreply@github.com>2021-02-11 16:01:58 -0800
commitd3565ed6b48c9c66128f181e7b90b5348504cb3f (patch)
tree99a03080830c1f9433046427feb18f90cade6c09 /src/Module.zig
parentd98f09e4f67fb2848be6052466db035450326605 (diff)
parentbb4f4c043e7dde4e8b9fcbf0af9329d3fd08ff7b (diff)
downloadzig-d3565ed6b48c9c66128f181e7b90b5348504cb3f.tar.gz
zig-d3565ed6b48c9c66128f181e7b90b5348504cb3f.zip
Merge pull request #7749 from tadeokondrak/6429-callconv-inline
Replace inline fn with callconv(.Inline)
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/Module.zig b/src/Module.zig
index a90998a386..322f190673 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -1087,14 +1087,23 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
if (fn_proto.getSectionExpr()) |sect_expr| {
return self.failNode(&fn_type_scope.base, sect_expr, "TODO implement function section expression", .{});
}
- if (fn_proto.getCallconvExpr()) |callconv_expr| {
- return self.failNode(
- &fn_type_scope.base,
- callconv_expr,
- "TODO implement function calling convention expression",
- .{},
- );
- }
+
+ const enum_literal_type = try astgen.addZIRInstConst(self, &fn_type_scope.base, fn_src, .{
+ .ty = Type.initTag(.type),
+ .val = Value.initTag(.enum_literal_type),
+ });
+ const enum_literal_type_rl: astgen.ResultLoc = .{ .ty = enum_literal_type };
+ const cc = if (fn_proto.getCallconvExpr()) |callconv_expr|
+ try astgen.expr(self, &fn_type_scope.base, enum_literal_type_rl, callconv_expr)
+ else
+ try astgen.addZIRInstConst(self, &fn_type_scope.base, fn_src, .{
+ .ty = Type.initTag(.enum_literal),
+ .val = try Value.Tag.enum_literal.create(
+ &fn_type_scope_arena.allocator,
+ try fn_type_scope_arena.allocator.dupe(u8, "Unspecified"),
+ ),
+ });
+
const return_type_expr = switch (fn_proto.return_type) {
.Explicit => |node| node,
.InferErrorSet => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement inferred error sets", .{}),
@@ -1105,6 +1114,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
const fn_type_inst = try astgen.addZIRInst(self, &fn_type_scope.base, fn_src, zir.Inst.FnType, .{
.return_type = return_type_inst,
.param_types = param_types,
+ .cc = cc,
}, .{});
if (std.builtin.mode == .Debug and self.comp.verbose_ir) {
@@ -1230,14 +1240,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
};
};
- const is_inline = blk: {
- if (fn_proto.getExternExportInlineToken()) |maybe_inline_token| {
- if (tree.token_ids[maybe_inline_token] == .Keyword_inline) {
- break :blk true;
- }
- }
- break :blk false;
- };
+ const is_inline = fn_type.fnCallingConvention() == .Inline;
const anal_state = ([2]Fn.Analysis{ .queued, .inline_only })[@boolToInt(is_inline)];
new_func.* = .{