distinct type aliasing
This commit is contained in:
@@ -38,11 +38,12 @@ clone_args :: proc(values: []ir.Instruction_Id, allocator: mem.Allocator) -> []i
|
||||
return result
|
||||
}
|
||||
|
||||
sentinel :: proc(value_type: types.Type, selected := target.DEFAULT) -> i64 {
|
||||
if types.is_float(value_type, selected) {
|
||||
return i64(0x7fc0_0000) if types.bits(value_type, selected) == 32 else transmute(i64)u64(0x7ff8_0000_0000_0000)
|
||||
sentinel :: proc(value_type: types.Type, store: ^types.Store, selected := target.DEFAULT) -> i64 {
|
||||
repr := types.runtime_representation(value_type, store)
|
||||
if types.is_float(repr, selected) {
|
||||
return i64(0x7fc0_0000) if types.bits(repr, selected) == 32 else transmute(i64)u64(0x7ff8_0000_0000_0000)
|
||||
}
|
||||
switch types.bits(value_type, selected) {
|
||||
switch types.bits(repr, selected) {
|
||||
case 8: return -86
|
||||
case 16: return -21846
|
||||
case 32: return -1431655766
|
||||
@@ -73,7 +74,7 @@ append_recovery_value :: proc(
|
||||
op=.Const,
|
||||
span=span,
|
||||
type=fallback,
|
||||
integer=sentinel(fallback, state.hir_module.target),
|
||||
integer=sentinel(fallback, &state.hir_module.types, state.hir_module.target),
|
||||
target=ir.INVALID_REF,
|
||||
a=ir.INVALID_INSTRUCTION,
|
||||
b=ir.INVALID_INSTRUCTION,
|
||||
@@ -466,7 +467,7 @@ lower_expr :: proc(state: ^State, expr_id: hir.Expr_Id) -> ir.Instruction_Id {
|
||||
})
|
||||
}
|
||||
_ = pop(&stack)
|
||||
case .Widen, .C_Vararg_Promote, .Weaken_Pointer, .Weaken_Slice, .Decay_Array_Pointer:
|
||||
case .Widen, .C_Vararg_Promote, .Retype, .Weaken_Pointer, .Weaken_Slice, .Decay_Array_Pointer:
|
||||
stack[frame_index].stage = 1
|
||||
append(&stack, Lower_Expr_Frame{expr=expr.left})
|
||||
case .Negate:
|
||||
@@ -524,6 +525,7 @@ lower_expr :: proc(state: ^State, expr_id: hir.Expr_Id) -> ir.Instruction_Id {
|
||||
case .Weaken_Slice: op = .Weaken_Slice
|
||||
case .Decay_Array_Pointer: op = .Decay_Array_Pointer
|
||||
case .C_Vararg_Promote: op = .C_Vararg_Promote
|
||||
case .Retype: op = .Retype
|
||||
case: op = .Widen
|
||||
}
|
||||
last = append_instruction(state, ir.Instruction{
|
||||
@@ -1286,7 +1288,7 @@ lower_body :: proc(hir_module: ^hir.Module, function: hir.Function, allocator: m
|
||||
value := append_instruction(&state, ir.Instruction{
|
||||
op=.Const,
|
||||
type=function.result,
|
||||
integer=sentinel(function.result, hir_module.target),
|
||||
integer=sentinel(function.result, &hir_module.types, hir_module.target),
|
||||
target=ir.INVALID_REF,
|
||||
a=ir.INVALID_INSTRUCTION,
|
||||
b=ir.INVALID_INSTRUCTION,
|
||||
|
||||
Reference in New Issue
Block a user