diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index 791a79ba..f8659b66 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -4219,7 +4219,7 @@ df_value_mode_eval_from_eval(TG_Graph *graph, RDI_Parsed *rdi, DF_CtrlCtx *ctrl_ TG_Key type_key = eval.type_key; TG_Kind type_kind = tg_kind_from_key(type_key); U64 type_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, type_key); - if(!tg_key_match(type_key, tg_key_zero()) && type_byte_size <= 8) + if(!tg_key_match(type_key, tg_key_zero()) && type_byte_size <= sizeof(U64)*2) { Temp scratch = scratch_begin(0, 0); Rng1U64 vaddr_range = r1u64(eval.offset, eval.offset + type_byte_size); @@ -4231,6 +4231,20 @@ df_value_mode_eval_from_eval(TG_Graph *graph, RDI_Parsed *rdi, DF_CtrlCtx *ctrl_ MemoryCopy(eval.imm_u128, data.str, Min(data.size, sizeof(U64)*2)); eval.mode = EVAL_EvalMode_Value; + // rjf: mask&shift, for bitfields + if(type_kind == TG_Kind_Bitfield && type_byte_size <= sizeof(U64)) + { + TG_Type *type = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, type_key); + U64 valid_bits_mask = 0; + for(U64 idx = 0; idx < type->count; idx += 1) + { + valid_bits_mask |= (1<> type->off; + eval.imm_u64 = eval.imm_u64 & valid_bits_mask; + eval.type_key = type->direct_type_key; + } + // rjf: manually sign-extend switch(type_kind) { diff --git a/src/type_graph/type_graph.c b/src/type_graph/type_graph.c index 16558851..4a9af695 100644 --- a/src/type_graph/type_graph.c +++ b/src/type_graph/type_graph.c @@ -1151,8 +1151,11 @@ tg_lhs_string_from_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Key ke case TG_Kind_Bitfield: { - TG_Key direct = tg_direct_from_graph_rdi_key(graph, rdi, key); - tg_lhs_string_from_key(arena, graph, rdi, direct, out, prec, skip_return); + Temp scratch = scratch_begin(&arena, 1); + TG_Type *type = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, key); + tg_lhs_string_from_key(arena, graph, rdi, type->direct_type_key, out, prec, skip_return); + str8_list_pushf(arena, out, ": %I64u", type->count); + scratch_end(scratch); }break; case TG_Kind_Modifier: @@ -1280,11 +1283,8 @@ tg_rhs_string_from_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Key ke case TG_Kind_Bitfield: { - Temp scratch = scratch_begin(&arena, 1); - TG_Type *type = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, key); - tg_rhs_string_from_key(arena, graph, rdi, type->direct_type_key, out, prec); - str8_list_pushf(arena, out, ": %I64u", type->count); - scratch_end(scratch); + TG_Key direct = tg_direct_from_graph_rdi_key(graph, rdi, key); + tg_rhs_string_from_key(arena, graph, rdi, direct, out, prec); }break; case TG_Kind_Modifier: