diff options
| author | vegecode <justin.b.alexander1@gmail.com> | 2020-07-04 10:04:15 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-10-16 20:04:42 -0700 |
| commit | 0456b2145de52bf0da3a18cfa3313ca42d7afd29 (patch) | |
| tree | e623e22a62324c65606d49945554c35c34108227 /src/stage1 | |
| parent | 79ef96b6a4af3fff751d5d7ad679634643c4fc6e (diff) | |
| download | zig-0456b2145de52bf0da3a18cfa3313ca42d7afd29.tar.gz zig-0456b2145de52bf0da3a18cfa3313ca42d7afd29.zip | |
byteOffsetOf rounds up using bit offset in host integer
Diffstat (limited to 'src/stage1')
| -rw-r--r-- | src/stage1/ir.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index dc74fb9c14..ea9bf6ee8b 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -24646,7 +24646,7 @@ static IrInstGen *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, return ir_build_field_parent_ptr_gen(ira, &instruction->base.base, casted_field_ptr, field, result_type); } -static TypeStructField *validate_byte_offset(IrAnalyze *ira, +static TypeStructField *validate_host_int_byte_offset(IrAnalyze *ira, IrInstGen *type_value, IrInstGen *field_name_value, size_t *byte_offset) @@ -24694,11 +24694,12 @@ static IrInstGen *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, IrInstSr return ira->codegen->invalid_inst_gen; IrInstGen *field_name_value = instruction->field_name->child; - size_t byte_offset = 0; - if (!validate_byte_offset(ira, type_value, field_name_value, &byte_offset)) + size_t host_int_byte_offset = 0; + TypeStructField *field = nullptr; + if (!(field = validate_host_int_byte_offset(ira, type_value, field_name_value, &host_int_byte_offset))) return ira->codegen->invalid_inst_gen; - + size_t byte_offset = host_int_byte_offset + (field->bit_offset_in_host / 8); return ir_const_unsigned(ira, &instruction->base.base, byte_offset); } @@ -24707,12 +24708,12 @@ static IrInstGen *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, IrInstSrc if (type_is_invalid(type_value->value->type)) return ira->codegen->invalid_inst_gen; IrInstGen *field_name_value = instruction->field_name->child; - size_t byte_offset = 0; + size_t host_int_byte_offset = 0; TypeStructField *field = nullptr; - if (!(field = validate_byte_offset(ira, type_value, field_name_value, &byte_offset))) + if (!(field = validate_host_int_byte_offset(ira, type_value, field_name_value, &host_int_byte_offset))) return ira->codegen->invalid_inst_gen; - size_t bit_offset = byte_offset * 8 + field->bit_offset_in_host; + size_t bit_offset = host_int_byte_offset * 8 + field->bit_offset_in_host; return ir_const_unsigned(ira, &instruction->base.base, bit_offset); } |
