authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-09-26 08:31:08-06:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-10-01 15:01:24-06:00
log77df5dae7f69f0d46c8e229df12f43f33487073f
treead980c8b4224d6307ee1b7ece99c0036cc856e5d
parent5acf2a5068f762d69c406bc61309a9ab349aca72
signature Commit is signed but in an unrecognized format.

Make builtin.TypeInfo.Pointer.alignment u29 instead of comptime_int


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

lib/std/builtin.zig+1-1
...@@ -214,7 +214,7 @@ pub const TypeInfo = union(enum) {...@@ -214,7 +214,7 @@ pub const TypeInfo = union(enum) {
214 size: Size,214 size: Size,
215 is_const: bool,215 is_const: bool,
216 is_volatile: bool,216 is_volatile: bool,
217 alignment: comptime_int,217 alignment: u29,
218 child: type,218 child: type,
219 is_allowzero: bool,219 is_allowzero: bool,
220220
src/stage1/ir.cpp+16-4
...@@ -25029,7 +25029,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, IrInst *source_instr,...@@ -25029,7 +25029,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, IrInst *source_instr,
25029 fields[2]->data.x_bool = attrs_type->data.pointer.is_volatile;25029 fields[2]->data.x_bool = attrs_type->data.pointer.is_volatile;
25030 // alignment: u3225030 // alignment: u32
25031 ensure_field_index(result->type, "alignment", 3);25031 ensure_field_index(result->type, "alignment", 3);
25032 fields[3]->type = ira->codegen->builtin_types.entry_num_lit_int;25032 fields[3]->type = ira->codegen->builtin_types.entry_u29;
25033 if (attrs_type->data.pointer.explicit_alignment != 0) {25033 if (attrs_type->data.pointer.explicit_alignment != 0) {
25034 fields[3]->special = ConstValSpecialStatic;25034 fields[3]->special = ConstValSpecialStatic;
25035 bigint_init_unsigned(&fields[3]->data.x_bigint, attrs_type->data.pointer.explicit_alignment);25035 bigint_init_unsigned(&fields[3]->data.x_bigint, attrs_type->data.pointer.explicit_alignment);
...@@ -25740,6 +25740,17 @@ static Error get_const_field_bool(IrAnalyze *ira, AstNode *source_node, ZigValue...@@ -25740,6 +25740,17 @@ static Error get_const_field_bool(IrAnalyze *ira, AstNode *source_node, ZigValue
25740 return ErrorNone;25740 return ErrorNone;
25741}25741}
2574225742
25743static Error get_const_field_u29(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value,
25744 const char *name, size_t field_index, uint32_t *out)
25745{
25746 ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index);
25747 if (value == nullptr)
25748 return ErrorSemanticAnalyzeFail;
25749 assert(value->type == ira->codegen->builtin_types.entry_u29);
25750 *out = bigint_as_u32(&value->data.x_bigint);
25751 return ErrorNone;
25752}
25753
25743static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index)25754static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index)
25744{25755{
25745 ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index);25756 ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index);
...@@ -25868,8 +25879,9 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -25868,8 +25879,9 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
25868 buf_sprintf("sentinels are only allowed on slices and unknown-length pointers"));25879 buf_sprintf("sentinels are only allowed on slices and unknown-length pointers"));
25869 return ira->codegen->invalid_inst_gen->value->type;25880 return ira->codegen->invalid_inst_gen->value->type;
25870 }25881 }
25871 BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 3);25882
25872 if (bi == nullptr)25883 uint32_t alignment;
25884 if ((err = get_const_field_u29(ira, source_instr->source_node, payload, "alignment", 3, &alignment)))
25873 return ira->codegen->invalid_inst_gen->value->type;25885 return ira->codegen->invalid_inst_gen->value->type;
2587425886
25875 bool is_const;25887 bool is_const;
...@@ -25896,7 +25908,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -25896,7 +25908,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
25896 is_const,25908 is_const,
25897 is_volatile,25909 is_volatile,
25898 ptr_len,25910 ptr_len,
25899 bigint_as_u32(bi),25911 alignment,
25900 0, // bit_offset_in_host25912 0, // bit_offset_in_host
25901 0, // host_int_bytes25913 0, // host_int_bytes
25902 is_allowzero,25914 is_allowzero,