aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-06-08 16:29:05 +0100
committerGinger Bill <bill@gingerbill.org>2017-06-08 16:29:05 +0100
commitaf2736daec0e6579a006bd8d4567c977c8e56c45 (patch)
tree11ea26e912c6fab9002d9e04e8f3297ff9c187a8 /src/ir.cpp
parent5cad7d44a6f51afe97b3176a6c55d53d96cc40b7 (diff)
Fix bit field bug
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index e94f84e3b..bcea8a515 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1902,12 +1902,14 @@ irValue *ir_addr_load(irProcedure *proc, irAddr addr) {
return v;
}
+ GB_ASSERT(8 > bit_inset);
+ irValue *shift_amount = ir_value_constant(a, int_type, exact_value_i64(bit_inset));
irValue *first_byte = ir_emit_load(proc, bytes);
- irValue *res = ir_emit_arith(proc, Token_Shr, first_byte, ir_const_int(a, 8 - bit_inset), int_type);
+ irValue *res = ir_emit_arith(proc, Token_Shr, first_byte, shift_amount, int_type);
irValue *remaining_bytes = ir_emit_load(proc, ir_emit_conv(proc, ir_emit_ptr_offset(proc, bytes, v_one), int_ptr));
- remaining_bytes = ir_emit_arith(proc, Token_Shl, remaining_bytes, ir_const_int(a, bit_inset), int_type);
+ remaining_bytes = ir_emit_arith(proc, Token_Shl, remaining_bytes, shift_amount, int_type);
return ir_emit_arith(proc, Token_Or, res, remaining_bytes, int_type);
}