aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/stage1/ir.cpp15
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);
}