@@ -130,6 +130,8 @@ ConstExprValue *const_ptr_pointee(CodeGen *g, ConstExprValue *const_val) {
130
130
zig_unreachable();
131
131
case ConstPtrSpecialDiscard:
132
132
zig_unreachable();
133
+ case ConstPtrSpecialFunction:
134
+ zig_unreachable();
133
135
}
134
136
zig_unreachable();
135
137
}
@@ -875,7 +877,9 @@ static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *
875
877
IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
876
878
const_instruction->base.value.type = fn_entry->type_entry;
877
879
const_instruction->base.value.special = ConstValSpecialStatic;
878
- const_instruction->base.value.data.x_fn.fn_entry = fn_entry;
880
+ const_instruction->base.value.data.x_ptr.data.fn.fn_entry = fn_entry;
881
+ const_instruction->base.value.data.x_ptr.mut = ConstPtrMutComptimeConst;
882
+ const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialFunction;
879
883
return &const_instruction->base;
880
884
}
881
885
@@ -8723,7 +8727,8 @@ static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
8723
8727
if (!const_val)
8724
8728
return nullptr;
8725
8729
8726
- return const_val->data.x_fn.fn_entry;
8730
+ assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction);
8731
+ return const_val->data.x_ptr.data.fn.fn_entry;
8727
8732
}
8728
8733
8729
8734
static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type) {
@@ -11311,7 +11316,8 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
11311
11316
case TypeTableEntryIdUnreachable:
11312
11317
zig_unreachable();
11313
11318
case TypeTableEntryIdFn: {
11314
- FnTableEntry *fn_entry = target->value.data.x_fn.fn_entry;
11319
+ assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction);
11320
+ FnTableEntry *fn_entry = target->value.data.x_ptr.data.fn.fn_entry;
11315
11321
CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc;
11316
11322
switch (cc) {
11317
11323
case CallingConventionUnspecified: {
@@ -12852,6 +12858,8 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
12852
12858
zig_panic("TODO elem ptr on a const inner struct");
12853
12859
case ConstPtrSpecialHardCodedAddr:
12854
12860
zig_unreachable();
12861
+ case ConstPtrSpecialFunction:
12862
+ zig_panic("TODO element ptr of a function casted to a ptr");
12855
12863
}
12856
12864
if (new_index >= mem_size) {
12857
12865
ir_add_error_node(ira, elem_ptr_instruction->base.source_node,
@@ -12901,6 +12909,8 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
12901
12909
zig_panic("TODO elem ptr on a slice backed by const inner struct");
12902
12910
case ConstPtrSpecialHardCodedAddr:
12903
12911
zig_unreachable();
12912
+ case ConstPtrSpecialFunction:
12913
+ zig_panic("TODO elem ptr on a slice that was ptrcast from a function");
12904
12914
}
12905
12915
return return_type;
12906
12916
} else if (array_type->id == TypeTableEntryIdArray) {
@@ -13101,7 +13111,9 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source
13101
13111
ConstExprValue *const_val = create_const_vals(1);
13102
13112
const_val->special = ConstValSpecialStatic;
13103
13113
const_val->type = fn_entry->type_entry;
13104
- const_val->data.x_fn.fn_entry = fn_entry;
13114
+ const_val->data.x_ptr.data.fn.fn_entry = fn_entry;
13115
+ const_val->data.x_ptr.special = ConstPtrSpecialFunction;
13116
+ const_val->data.x_ptr.mut = ConstPtrMutComptimeConst;
13105
13117
13106
13118
if (tld_fn->extern_lib_name != nullptr) {
13107
13119
add_link_lib_symbol(ira, tld_fn->extern_lib_name, &fn_entry->symbol_name, source_instruction->source_node);
@@ -13771,7 +13783,8 @@ static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
13771
13783
fast_math_off_ptr = &block_scope->fast_math_off;
13772
13784
fast_math_set_node_ptr = &block_scope->fast_math_set_node;
13773
13785
} else if (target_type->id == TypeTableEntryIdFn) {
13774
- FnTableEntry *target_fn = target_val->data.x_fn.fn_entry;
13786
+ assert(target_val->data.x_ptr.special == ConstPtrSpecialFunction);
13787
+ FnTableEntry *target_fn = target_val->data.x_ptr.data.fn.fn_entry;
13775
13788
assert(target_fn->def_scope);
13776
13789
fast_math_off_ptr = &target_fn->def_scope->fast_math_off;
13777
13790
fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node;
@@ -15673,6 +15686,8 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi
15673
15686
zig_panic("TODO memset on const inner struct");
15674
15687
case ConstPtrSpecialHardCodedAddr:
15675
15688
zig_unreachable();
15689
+ case ConstPtrSpecialFunction:
15690
+ zig_panic("TODO memset on ptr cast from function");
15676
15691
}
15677
15692
15678
15693
size_t count = bigint_as_unsigned(&casted_count->value.data.x_bigint);
@@ -15769,6 +15784,8 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
15769
15784
zig_panic("TODO memcpy on const inner struct");
15770
15785
case ConstPtrSpecialHardCodedAddr:
15771
15786
zig_unreachable();
15787
+ case ConstPtrSpecialFunction:
15788
+ zig_panic("TODO memcpy on ptr cast from function");
15772
15789
}
15773
15790
15774
15791
if (dest_start + count > dest_end) {
@@ -15803,6 +15820,8 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
15803
15820
zig_panic("TODO memcpy on const inner struct");
15804
15821
case ConstPtrSpecialHardCodedAddr:
15805
15822
zig_unreachable();
15823
+ case ConstPtrSpecialFunction:
15824
+ zig_panic("TODO memcpy on ptr cast from function");
15806
15825
}
15807
15826
15808
15827
if (src_start + count > src_end) {
@@ -15925,6 +15944,8 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
15925
15944
abs_offset = 0;
15926
15945
rel_end = SIZE_MAX;
15927
15946
break;
15947
+ case ConstPtrSpecialFunction:
15948
+ zig_panic("TODO slice of ptr cast from function");
15928
15949
}
15929
15950
} else if (is_slice(array_type)) {
15930
15951
ConstExprValue *slice_ptr = const_ptr_pointee(ira->codegen, &ptr_ptr->value);
@@ -15952,6 +15973,8 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
15952
15973
abs_offset = 0;
15953
15974
rel_end = bigint_as_unsigned(&len_val->data.x_bigint);
15954
15975
break;
15976
+ case ConstPtrSpecialFunction:
15977
+ zig_panic("TODO slice of slice cast from function");
15955
15978
}
15956
15979
} else {
15957
15980
zig_unreachable();
@@ -16021,6 +16044,9 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
16021
16044
parent_ptr->type->data.pointer.child_type,
16022
16045
parent_ptr->data.x_ptr.data.hard_coded_addr.addr + start_scalar,
16023
16046
slice_is_const(return_type));
16047
+ break;
16048
+ case ConstPtrSpecialFunction:
16049
+ zig_panic("TODO");
16024
16050
}
16025
16051
16026
16052
ConstExprValue *len_val = &out_val->data.x_struct.fields[slice_len_index];
0 commit comments