aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-04-28 14:53:50 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-04-28 14:57:38 -0700
commitdf24ce52b1059232db66e9af425a02df558aa1ca (patch)
treebf314eace4c7acd533c5c9532b330ecd8ae65686 /src/stage1/analyze.cpp
parenteb9c29eb817a24e5326b9a63ebf7265d3b2bad2c (diff)
parent55c58f226d06d3708a82878a67f3800e0ce5810b (diff)
downloadzig-df24ce52b1059232db66e9af425a02df558aa1ca.tar.gz
zig-df24ce52b1059232db66e9af425a02df558aa1ca.zip
Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted to take advantage of the new hex float parsing code.
Diffstat (limited to 'src/stage1/analyze.cpp')
-rw-r--r--src/stage1/analyze.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp
index 21ad55b8f7..8ca845d2cf 100644
--- a/src/stage1/analyze.cpp
+++ b/src/stage1/analyze.cpp
@@ -974,6 +974,7 @@ const char *calling_convention_name(CallingConvention cc) {
case CallingConventionAAPCS: return "AAPCS";
case CallingConventionAAPCSVFP: return "AAPCSVFP";
case CallingConventionInline: return "Inline";
+ case CallingConventionSysV: return "SysV";
}
zig_unreachable();
}
@@ -995,6 +996,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
case CallingConventionAPCS:
case CallingConventionAAPCS:
case CallingConventionAAPCSVFP:
+ case CallingConventionSysV:
return false;
}
zig_unreachable();
@@ -1969,6 +1971,10 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_
case CallingConventionAAPCSVFP:
if (!target_is_arm(g->zig_target))
allowed_platforms = "ARM";
+ break;
+ case CallingConventionSysV:
+ if (g->zig_target->arch != ZigLLVM_x86_64)
+ allowed_platforms = "x86_64";
}
if (allowed_platforms != nullptr) {
add_node_error(g, source_node, buf_sprintf(
@@ -3805,6 +3811,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
case CallingConventionAPCS:
case CallingConventionAAPCS:
case CallingConventionAAPCSVFP:
+ case CallingConventionSysV:
add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
GlobalLinkageIdStrong, fn_cc);
break;
@@ -4769,11 +4776,11 @@ Error type_is_nonnull_ptr2(CodeGen *g, ZigType *type, bool *result) {
return ErrorNone;
}
-static uint32_t get_async_frame_align_bytes(CodeGen *g) {
- uint32_t a = g->pointer_size_bytes * 2;
- // promises have at least alignment 8 so that we can have 3 extra bits when doing atomicrmw
- if (a < 8) a = 8;
- return a;
+uint32_t get_async_frame_align_bytes(CodeGen *g) {
+ // Due to how the frame structure is built the minimum alignment is the one
+ // of a usize (or pointer).
+ // label (grep this): [fn_frame_struct_layout]
+ return max(g->builtin_types.entry_usize->abi_align, target_fn_align(g->zig_target));
}
uint32_t get_ptr_align(CodeGen *g, ZigType *type) {
@@ -4789,11 +4796,8 @@ uint32_t get_ptr_align(CodeGen *g, ZigType *type) {
return (ptr_type->data.pointer.explicit_alignment == 0) ?
get_abi_alignment(g, ptr_type->data.pointer.child_type) : ptr_type->data.pointer.explicit_alignment;
} else if (ptr_type->id == ZigTypeIdFn) {
- // I tried making this use LLVMABIAlignmentOfType but it trips this assertion in LLVM:
- // "Cannot getTypeInfo() on a type that is unsized!"
- // when getting the alignment of `?fn() callconv(.C) void`.
- // See http://lists.llvm.org/pipermail/llvm-dev/2018-September/126142.html
- return (ptr_type->data.fn.fn_type_id.alignment == 0) ? 1 : ptr_type->data.fn.fn_type_id.alignment;
+ return (ptr_type->data.fn.fn_type_id.alignment == 0) ?
+ target_fn_ptr_align(g->zig_target) : ptr_type->data.fn.fn_type_id.alignment;
} else if (ptr_type->id == ZigTypeIdAnyFrame) {
return get_async_frame_align_bytes(g);
} else {