authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-09-26 12:00:41-06:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-10-01 18:01:41-06:00
log183d1d4ba1a855cc85ac93f51dec5f4b2301ce1d
tree6a6096eb39d715dc8f4321fc0ab453113eb3bff6
parent96a151d4b83ea4148db4d13b5576897645209f46
signaturelock-open Commit is signed but in an unrecognized format.

Switch TypeInfo.Fn.alignment to comptime_int from u29

All integers in TypeInfo are intentionally comptime_int: https://github.com/ziglang/zig/issues/1683

2 files changed, 5 insertions(+), 16 deletions(-)

lib/std/builtin.zig+1-1
......@@ -343,7 +343,7 @@ pub const TypeInfo = union(enum) {
343343 /// therefore must be kept in sync with the compiler implementation.
344344 pub const Fn = struct {
345345 calling_convention: CallingConvention,
346 alignment: u29,
346 alignment: comptime_int,
347347 is_generic: bool,
348348 is_var_args: bool,
349349 return_type: ?type,
src/stage1/ir.cpp+4-15
......@@ -25575,7 +25575,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
2557525575 // alignment: u29
2557625576 ensure_field_index(result->type, "alignment", 1);
2557725577 fields[1]->special = ConstValSpecialStatic;
25578 fields[1]->type = ira->codegen->builtin_types.entry_u29;
25578 fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
2557925579 bigint_init_unsigned(&fields[1]->data.x_bigint, type_entry->data.fn.fn_type_id.alignment);
2558025580 // is_generic: bool
2558125581 ensure_field_index(result->type, "is_generic", 2);
......@@ -25756,17 +25756,6 @@ static Error get_const_field_bool(IrAnalyze *ira, AstNode *source_node, ZigValue
2575625756 return ErrorNone;
2575725757}
2575825758
25759static Error get_const_field_u29(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value,
25760 const char *name, size_t field_index, uint32_t *out)
25761{
25762 ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index);
25763 if (value == nullptr)
25764 return ErrorSemanticAnalyzeFail;
25765 assert(value->type == ira->codegen->builtin_types.entry_u29);
25766 *out = bigint_as_u32(&value->data.x_bigint);
25767 return ErrorNone;
25768}
25769
2577025759static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index)
2577125760{
2577225761 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
2635326342 assert(cc_value->type == get_builtin_type(ira->codegen, "CallingConvention"));
2635426343 CallingConvention cc = (CallingConvention)bigint_as_u32(&cc_value->data.x_enum_tag);
2635526344
26356 uint32_t alignment;
26357 if ((err = get_const_field_u29(ira, source_instr->source_node, payload, "alignment", 1, &alignment)))
26345 BigInt *alignment = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 1);
26346 if (alignment == nullptr)
2635826347 return ira->codegen->invalid_inst_gen->value->type;
2635926348
2636026349 Error err;
......@@ -26396,7 +26385,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
2639626385 fn_type_id.next_param_index = args_len;
2639726386 fn_type_id.is_var_args = is_var_args;
2639826387 fn_type_id.cc = cc;
26399 fn_type_id.alignment = alignment;
26388 fn_type_id.alignment = bigint_as_u32(alignment);
2640026389
2640126390 assert(args_ptr->data.x_ptr.special == ConstPtrSpecialBaseArray);
2640226391 assert(args_ptr->data.x_ptr.data.base_array.elem_index == 0);