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) {
214214 size: Size,
215215 is_const: bool,
216216 is_volatile: bool,
217 alignment: comptime_int,
217 alignment: u29,
218218 child: type,
219219 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,
2502925029 fields[2]->data.x_bool = attrs_type->data.pointer.is_volatile;
2503025030 // alignment: u32
2503125031 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;
2503325033 if (attrs_type->data.pointer.explicit_alignment != 0) {
2503425034 fields[3]->special = ConstValSpecialStatic;
2503525035 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
2574025740 return ErrorNone;
2574125741}
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
2574325754static BigInt *get_const_field_lit_int(IrAnalyze *ira, AstNode *source_node, ZigValue *struct_value, const char *name, size_t field_index)
2574425755{
2574525756 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
2586825879 buf_sprintf("sentinels are only allowed on slices and unknown-length pointers"));
2586925880 return ira->codegen->invalid_inst_gen->value->type;
2587025881 }
25871 BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 3);
25872 if (bi == nullptr)
25882
25883 uint32_t alignment;
25884 if ((err = get_const_field_u29(ira, source_instr->source_node, payload, "alignment", 3, &alignment)))
2587325885 return ira->codegen->invalid_inst_gen->value->type;
2587425886
2587525887 bool is_const;
......@@ -25896,7 +25908,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
2589625908 is_const,
2589725909 is_volatile,
2589825910 ptr_len,
25899 bigint_as_u32(bi),
25911 alignment,
2590025912 0, // bit_offset_in_host
2590125913 0, // host_int_bytes
2590225914 is_allowzero,