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) {...@@ -343,7 +343,7 @@ pub const TypeInfo = union(enum) {
343 /// therefore must be kept in sync with the compiler implementation.343 /// therefore must be kept in sync with the compiler implementation.
344 pub const Fn = struct {344 pub const Fn = struct {
345 calling_convention: CallingConvention,345 calling_convention: CallingConvention,
346 alignment: u29,346 alignment: comptime_int,
347 is_generic: bool,347 is_generic: bool,
348 is_var_args: bool,348 is_var_args: bool,
349 return_type: ?type,349 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...@@ -25575,7 +25575,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
25575 // alignment: u2925575 // alignment: u29
25576 ensure_field_index(result->type, "alignment", 1);25576 ensure_field_index(result->type, "alignment", 1);
25577 fields[1]->special = ConstValSpecialStatic;25577 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;
25579 bigint_init_unsigned(&fields[1]->data.x_bigint, type_entry->data.fn.fn_type_id.alignment);25579 bigint_init_unsigned(&fields[1]->data.x_bigint, type_entry->data.fn.fn_type_id.alignment);
25580 // is_generic: bool25580 // is_generic: bool
25581 ensure_field_index(result->type, "is_generic", 2);25581 ensure_field_index(result->type, "is_generic", 2);
...@@ -25756,17 +25756,6 @@ static Error get_const_field_bool(IrAnalyze *ira, AstNode *source_node, ZigValue...@@ -25756,17 +25756,6 @@ static Error get_const_field_bool(IrAnalyze *ira, AstNode *source_node, ZigValue
25756 return ErrorNone;25756 return ErrorNone;
25757}25757}
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
25770static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index)25759static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index)
25771{25760{
25772 ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index);25761 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...@@ -26353,8 +26342,8 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
26353 assert(cc_value->type == get_builtin_type(ira->codegen, "CallingConvention"));26342 assert(cc_value->type == get_builtin_type(ira->codegen, "CallingConvention"));
26354 CallingConvention cc = (CallingConvention)bigint_as_u32(&cc_value->data.x_enum_tag);26343 CallingConvention cc = (CallingConvention)bigint_as_u32(&cc_value->data.x_enum_tag);
2635526344
26356 uint32_t alignment;26345 BigInt *alignment = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 1);
26357 if ((err = get_const_field_u29(ira, source_instr->source_node, payload, "alignment", 1, &alignment)))26346 if (alignment == nullptr)
26358 return ira->codegen->invalid_inst_gen->value->type;26347 return ira->codegen->invalid_inst_gen->value->type;
2635926348
26360 Error err;26349 Error err;
...@@ -26396,7 +26385,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -26396,7 +26385,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
26396 fn_type_id.next_param_index = args_len;26385 fn_type_id.next_param_index = args_len;
26397 fn_type_id.is_var_args = is_var_args;26386 fn_type_id.is_var_args = is_var_args;
26398 fn_type_id.cc = cc;26387 fn_type_id.cc = cc;
26399 fn_type_id.alignment = alignment;26388 fn_type_id.alignment = bigint_as_u32(alignment);
2640026389
26401 assert(args_ptr->data.x_ptr.special == ConstPtrSpecialBaseArray);26390 assert(args_ptr->data.x_ptr.special == ConstPtrSpecialBaseArray);
26402 assert(args_ptr->data.x_ptr.data.base_array.elem_index == 0);26391 assert(args_ptr->data.x_ptr.data.base_array.elem_index == 0);