aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTadeo Kondrak <me@tadeo.ca>2020-09-26 12:00:41 -0600
committerTadeo Kondrak <me@tadeo.ca>2020-10-01 18:01:41 -0600
commit183d1d4ba1a855cc85ac93f51dec5f4b2301ce1d (patch)
tree6a6096eb39d715dc8f4321fc0ab453113eb3bff6
parent96a151d4b83ea4148db4d13b5576897645209f46 (diff)
downloadzig-183d1d4ba1a855cc85ac93f51dec5f4b2301ce1d.tar.gz
zig-183d1d4ba1a855cc85ac93f51dec5f4b2301ce1d.zip
Switch TypeInfo.Fn.alignment to comptime_int from u29
All integers in TypeInfo are intentionally comptime_int: https://github.com/ziglang/zig/issues/1683
-rw-r--r--lib/std/builtin.zig2
-rw-r--r--src/stage1/ir.cpp19
2 files changed, 5 insertions, 16 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig
index 34452bee09..92fa78bc39 100644
--- a/lib/std/builtin.zig
+++ b/lib/std/builtin.zig
@@ -343,7 +343,7 @@ pub const TypeInfo = union(enum) {
/// therefore must be kept in sync with the compiler implementation.
pub const Fn = struct {
calling_convention: CallingConvention,
- alignment: u29,
+ alignment: comptime_int,
is_generic: bool,
is_var_args: bool,
return_type: ?type,
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp
index 162fa1bea5..045f1ad784 100644
--- a/src/stage1/ir.cpp
+++ b/src/stage1/ir.cpp
@@ -25575,7 +25575,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
// alignment: u29
ensure_field_index(result->type, "alignment", 1);
fields[1]->special = ConstValSpecialStatic;
- fields[1]->type = ira->codegen->builtin_types.entry_u29;
+ fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
bigint_init_unsigned(&fields[1]->data.x_bigint, type_entry->data.fn.fn_type_id.alignment);
// is_generic: bool
ensure_field_index(result->type, "is_generic", 2);
@@ -25756,17 +25756,6 @@ static Error get_const_field_bool(IrAnalyze *ira, AstNode *source_node, ZigValue
return ErrorNone;
}
-static Error get_const_field_u29(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value,
- const char *name, size_t field_index, uint32_t *out)
-{
- ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index);
- if (value == nullptr)
- return ErrorSemanticAnalyzeFail;
- assert(value->type == ira->codegen->builtin_types.entry_u29);
- *out = bigint_as_u32(&value->data.x_bigint);
- return ErrorNone;
-}
-
static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index)
{
ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index);
@@ -26353,8 +26342,8 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
assert(cc_value->type == get_builtin_type(ira->codegen, "CallingConvention"));
CallingConvention cc = (CallingConvention)bigint_as_u32(&cc_value->data.x_enum_tag);
- uint32_t alignment;
- if ((err = get_const_field_u29(ira, source_instr->source_node, payload, "alignment", 1, &alignment)))
+ BigInt *alignment = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 1);
+ if (alignment == nullptr)
return ira->codegen->invalid_inst_gen->value->type;
Error err;
@@ -26396,7 +26385,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
fn_type_id.next_param_index = args_len;
fn_type_id.is_var_args = is_var_args;
fn_type_id.cc = cc;
- fn_type_id.alignment = alignment;
+ fn_type_id.alignment = bigint_as_u32(alignment);
assert(args_ptr->data.x_ptr.special == ConstPtrSpecialBaseArray);
assert(args_ptr->data.x_ptr.data.base_array.elem_index == 0);