mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 08:33:06 +00:00
Switch TypeInfo alignment fields from u29 to comptime_int
This commit is contained in:
parent
70c507911a
commit
a12203d2be
@ -214,7 +214,7 @@ pub const TypeInfo = union(enum) {
|
||||
size: Size,
|
||||
is_const: bool,
|
||||
is_volatile: bool,
|
||||
alignment: u29,
|
||||
alignment: comptime_int,
|
||||
child: type,
|
||||
is_allowzero: bool,
|
||||
|
||||
@ -262,7 +262,7 @@ pub const TypeInfo = union(enum) {
|
||||
field_type: type,
|
||||
default_value: anytype,
|
||||
is_comptime: bool,
|
||||
alignment: u29,
|
||||
alignment: comptime_int,
|
||||
};
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
@ -319,7 +319,7 @@ pub const TypeInfo = union(enum) {
|
||||
pub const UnionField = struct {
|
||||
name: []const u8,
|
||||
field_type: type,
|
||||
alignment: u29,
|
||||
alignment: comptime_int,
|
||||
};
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
|
@ -25027,9 +25027,9 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, IrInst *source_instr,
|
||||
fields[2]->special = ConstValSpecialStatic;
|
||||
fields[2]->type = ira->codegen->builtin_types.entry_bool;
|
||||
fields[2]->data.x_bool = attrs_type->data.pointer.is_volatile;
|
||||
// alignment: u32
|
||||
// alignment: comptime_int
|
||||
ensure_field_index(result->type, "alignment", 3);
|
||||
fields[3]->type = ira->codegen->builtin_types.entry_u29;
|
||||
fields[3]->type = ira->codegen->builtin_types.entry_num_lit_int;
|
||||
if (attrs_type->data.pointer.explicit_alignment != 0) {
|
||||
fields[3]->special = ConstValSpecialStatic;
|
||||
bigint_init_unsigned(&fields[3]->data.x_bigint, attrs_type->data.pointer.explicit_alignment);
|
||||
@ -25432,12 +25432,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
|
||||
union_field_val->type = type_info_union_field_type;
|
||||
|
||||
ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 3);
|
||||
// field_type: type
|
||||
inner_fields[1]->special = ConstValSpecialStatic;
|
||||
inner_fields[1]->type = ira->codegen->builtin_types.entry_type;
|
||||
inner_fields[1]->data.x_type = union_field->type_entry;
|
||||
|
||||
// alignment: comptime_int
|
||||
inner_fields[2]->special = ConstValSpecialStatic;
|
||||
inner_fields[2]->type = ira->codegen->builtin_types.entry_u29;
|
||||
inner_fields[2]->type = ira->codegen->builtin_types.entry_num_lit_int;
|
||||
bigint_init_unsigned(&inner_fields[2]->data.x_bigint, union_field->align);
|
||||
|
||||
ZigValue *name = create_const_str_lit(ira->codegen, union_field->name)->data.x_ptr.data.ref.pointee;
|
||||
@ -25522,12 +25524,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
|
||||
}
|
||||
set_optional_payload(inner_fields[2], struct_field->init_val);
|
||||
|
||||
// is_comptime: bool
|
||||
inner_fields[3]->special = ConstValSpecialStatic;
|
||||
inner_fields[3]->type = ira->codegen->builtin_types.entry_bool;
|
||||
inner_fields[3]->data.x_bool = struct_field->is_comptime;
|
||||
|
||||
// alignment: comptime_int
|
||||
inner_fields[4]->special = ConstValSpecialStatic;
|
||||
inner_fields[4]->type = ira->codegen->builtin_types.entry_u29;
|
||||
inner_fields[4]->type = ira->codegen->builtin_types.entry_num_lit_int;
|
||||
bigint_init_unsigned(&inner_fields[4]->data.x_bigint, struct_field->align);
|
||||
|
||||
ZigValue *name = create_const_str_lit(ira->codegen, struct_field->name)->data.x_ptr.data.ref.pointee;
|
||||
@ -25748,17 +25752,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);
|
||||
@ -25888,8 +25881,8 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
|
||||
return ira->codegen->invalid_inst_gen->value->type;
|
||||
}
|
||||
|
||||
uint32_t alignment;
|
||||
if ((err = get_const_field_u29(ira, source_instr->source_node, payload, "alignment", 3, &alignment)))
|
||||
BigInt *alignment = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 3);
|
||||
if (alignment == nullptr)
|
||||
return ira->codegen->invalid_inst_gen->value->type;
|
||||
|
||||
bool is_const;
|
||||
@ -25916,7 +25909,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
|
||||
is_const,
|
||||
is_volatile,
|
||||
ptr_len,
|
||||
alignment,
|
||||
bigint_as_u32(alignment),
|
||||
0, // bit_offset_in_host
|
||||
0, // host_int_bytes
|
||||
is_allowzero,
|
||||
@ -26153,8 +26146,10 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
|
||||
}
|
||||
if ((err = get_const_field_bool(ira, source_instr->source_node, field_value, "is_comptime", 3, &field->is_comptime)))
|
||||
return ira->codegen->invalid_inst_gen->value->type;
|
||||
if ((err = get_const_field_u29(ira, source_instr->source_node, field_value, "alignment", 4, &field->align)))
|
||||
BigInt *alignment = get_const_field_lit_int(ira, source_instr->source_node, field_value, "alignment", 4);
|
||||
if (alignment == nullptr)
|
||||
return ira->codegen->invalid_inst_gen->value->type;
|
||||
field->align = bigint_as_u32(alignment);
|
||||
}
|
||||
|
||||
return entry;
|
||||
@ -26324,8 +26319,10 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
|
||||
return ira->codegen->invalid_inst_gen->value->type;
|
||||
field->type_val = type_value;
|
||||
field->type_entry = type_value->data.x_type;
|
||||
if ((err = get_const_field_u29(ira, source_instr->source_node, field_value, "alignment", 2, &field->align)))
|
||||
BigInt *alignment = get_const_field_lit_int(ira, source_instr->source_node, field_value, "alignment", 2);
|
||||
if (alignment == nullptr)
|
||||
return ira->codegen->invalid_inst_gen->value->type;
|
||||
field->align = bigint_as_u32(alignment);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user