refine returned match errors
This commit is contained in:
+14
-6
@@ -287,7 +287,7 @@ valid_value :: proc(
|
||||
.Load_Global, .Function_Address, .Address_Of, .Load, .Union_Tag, .Slice, .Length, .Slice_Ptr,
|
||||
.Fallible_Error, .Extract, .Select, .Unwrap,
|
||||
.Optional_Is_Some, .Optional_Value, .Orelse,
|
||||
.Widen, .Sum_Widen, .C_Coerce, .C_Vararg_Promote, .Retype, .Scalar_Cast, .Pointer_Cast, .Const_Cast, .Weaken_Pointer, .Weaken_Slice, .Decay_Array_Pointer,
|
||||
.Widen, .Sum_Widen, .Sum_Project, .C_Coerce, .C_Vararg_Promote, .Retype, .Scalar_Cast, .Pointer_Cast, .Const_Cast, .Weaken_Pointer, .Weaken_Slice, .Decay_Array_Pointer,
|
||||
.Neg_Checked, .Add_Checked, .Sub_Checked, .Mul_Checked, .Div_Checked,
|
||||
.Div_Trunc_Checked, .Div_Floor_Checked, .Div_Exact_Checked, .Div_Ceil_Checked,
|
||||
.Rem_Checked, .Mod_Checked,
|
||||
@@ -1748,10 +1748,14 @@ emit_instruction_stream :: proc(
|
||||
fmt.sbprintf(&emitter.builder, " %%v%d = %s %s ", instruction_index, operation, llvm_type(from_type, &emitter.module.types))
|
||||
write_operand(&emitter.builder, instructions, instruction.a, from_type, &emitter.module.types)
|
||||
fmt.sbprintf(&emitter.builder, " to %s\n", llvm_type(instruction.type, &emitter.module.types))
|
||||
case .Sum_Widen:
|
||||
if !valid_instruction(instructions, instruction.a) ||
|
||||
!types.can_sum_widen(instructions[instruction.a].type, instruction.type, &emitter.module.types) {
|
||||
emit_recovery_value(emitter, instruction_index, instruction, "invalid sum widening operand")
|
||||
case .Sum_Widen, .Sum_Project:
|
||||
project := instruction.op == .Sum_Project
|
||||
valid_conversion := valid_instruction(instructions, instruction.a) &&
|
||||
(types.can_sum_project(instructions[instruction.a].type, instruction.type, &emitter.module.types) if project else
|
||||
types.can_sum_widen(instructions[instruction.a].type, instruction.type, &emitter.module.types))
|
||||
if !valid_conversion {
|
||||
emit_recovery_value(emitter, instruction_index, instruction,
|
||||
"invalid sum projection operand" if project else "invalid sum widening operand")
|
||||
continue
|
||||
}
|
||||
from_type := instructions[instruction.a].type
|
||||
@@ -1799,6 +1803,9 @@ emit_instruction_stream :: proc(
|
||||
from_payload_offset := types.union_payload_offset(from_type, &emitter.module.types, emitter.module.target)
|
||||
to_payload_offset := types.union_payload_offset(instruction.type, &emitter.module.types, emitter.module.target)
|
||||
payload_size := types.sum_payload_size(from_type, &emitter.module.types, emitter.module.target)
|
||||
if project {
|
||||
payload_size = min(payload_size, types.sum_payload_size(instruction.type, &emitter.module.types, emitter.module.target))
|
||||
}
|
||||
if payload_size > 0 {
|
||||
fmt.sbprintf(&emitter.builder, " %%sum_from_payload%d = getelementptr i8, ptr %%sum_from_slot%d, i64 %d\n", instruction_index, instruction_index, from_payload_offset)
|
||||
fmt.sbprintf(&emitter.builder, " %%sum_to_payload%d = getelementptr i8, ptr %%sum_to_slot%d, i64 %d\n", instruction_index, instruction_index, to_payload_offset)
|
||||
@@ -1807,7 +1814,8 @@ emit_instruction_stream :: proc(
|
||||
fmt.sbprintf(&emitter.builder, " %%v%d = load %s, ptr %%sum_to_slot%d\n", instruction_index, to_name, instruction_index)
|
||||
continue
|
||||
}
|
||||
emit_recovery_value(emitter, instruction_index, instruction, "unsupported sum widening operand")
|
||||
emit_recovery_value(emitter, instruction_index, instruction,
|
||||
"unsupported sum projection operand" if project else "unsupported sum widening operand")
|
||||
case .C_Coerce:
|
||||
if !valid_instruction(instructions, instruction.a) ||
|
||||
!(types.can_coerce_c_integer(instructions[instruction.a].type, instruction.type, emitter.module.target) ||
|
||||
|
||||
Reference in New Issue
Block a user