@@ -542,7 +542,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
542
542
543
543
if (!type_has_bits (return_type)) {
544
544
// nothing to do
545
- } else if (return_type-> id == TypeTableEntryIdPointer || return_type-> id == TypeTableEntryIdFn ) {
545
+ } else if (type_is_codegen_pointer ( return_type) ) {
546
546
addLLVMAttr (fn_table_entry->llvm_value , 0 , " nonnull" );
547
547
} else if (handle_is_ptr (return_type) &&
548
548
calling_convention_does_first_arg_return (fn_type->data .fn .fn_type_id .cc ))
@@ -2789,7 +2789,7 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLV
2789
2789
if (child_type->zero_bits ) {
2790
2790
return maybe_handle;
2791
2791
} else {
2792
- bool maybe_is_ptr = (child_type-> id == TypeTableEntryIdPointer || child_type-> id == TypeTableEntryIdFn );
2792
+ bool maybe_is_ptr = type_is_codegen_pointer (child_type);
2793
2793
if (maybe_is_ptr) {
2794
2794
return LLVMBuildICmp (g->builder , LLVMIntNE, maybe_handle, LLVMConstNull (maybe_type->type_ref ), " " );
2795
2795
} else {
@@ -2829,7 +2829,7 @@ static LLVMValueRef ir_render_unwrap_maybe(CodeGen *g, IrExecutable *executable,
2829
2829
if (child_type->zero_bits ) {
2830
2830
return nullptr ;
2831
2831
} else {
2832
- bool maybe_is_ptr = (child_type-> id == TypeTableEntryIdPointer || child_type-> id == TypeTableEntryIdFn );
2832
+ bool maybe_is_ptr = type_is_codegen_pointer (child_type);
2833
2833
if (maybe_is_ptr) {
2834
2834
return maybe_ptr;
2835
2835
} else {
@@ -3052,6 +3052,10 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
3052
3052
{
3053
3053
align_bytes = target_type->data .maybe .child_type ->data .fn .fn_type_id .alignment ;
3054
3054
ptr_val = target_val;
3055
+ } else if (target_type->id == TypeTableEntryIdMaybe &&
3056
+ target_type->data .maybe .child_type ->id == TypeTableEntryIdPromise)
3057
+ {
3058
+ zig_panic (" TODO audit this function" );
3055
3059
} else if (target_type->id == TypeTableEntryIdStruct && target_type->data .structure .is_slice ) {
3056
3060
TypeTableEntry *slice_ptr_type = target_type->data .structure .fields [slice_ptr_index].type_entry ;
3057
3061
align_bytes = slice_ptr_type->data .pointer .alignment ;
@@ -3522,9 +3526,7 @@ static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, I
3522
3526
}
3523
3527
3524
3528
LLVMValueRef payload_val = ir_llvm_value (g, instruction->value );
3525
- if (child_type->id == TypeTableEntryIdPointer ||
3526
- child_type->id == TypeTableEntryIdFn)
3527
- {
3529
+ if (type_is_codegen_pointer (child_type)) {
3528
3530
return payload_val;
3529
3531
}
3530
3532
@@ -3716,6 +3718,22 @@ static LLVMValueRef ir_render_coro_alloc_fail(CodeGen *g, IrExecutable *executab
3716
3718
zig_panic (" TODO ir_render_coro_alloc_fail" );
3717
3719
}
3718
3720
3721
+ static LLVMValueRef ir_render_coro_suspend (CodeGen *g, IrExecutable *executable, IrInstructionCoroSuspend *instruction) {
3722
+ zig_panic (" TODO ir_render_coro_suspend" );
3723
+ }
3724
+
3725
+ static LLVMValueRef ir_render_coro_end (CodeGen *g, IrExecutable *executable, IrInstructionCoroEnd *instruction) {
3726
+ zig_panic (" TODO ir_render_coro_end" );
3727
+ }
3728
+
3729
+ static LLVMValueRef ir_render_coro_free (CodeGen *g, IrExecutable *executable, IrInstructionCoroFree *instruction) {
3730
+ zig_panic (" TODO ir_render_coro_free" );
3731
+ }
3732
+
3733
+ static LLVMValueRef ir_render_coro_resume (CodeGen *g, IrExecutable *executable, IrInstructionCoroResume *instruction) {
3734
+ zig_panic (" TODO ir_render_coro_resume" );
3735
+ }
3736
+
3719
3737
static void set_debug_location (CodeGen *g, IrInstruction *instruction) {
3720
3738
AstNode *source_node = instruction->source_node ;
3721
3739
Scope *scope = instruction->scope ;
@@ -3911,6 +3929,14 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
3911
3929
return ir_render_coro_begin (g, executable, (IrInstructionCoroBegin *)instruction);
3912
3930
case IrInstructionIdCoroAllocFail:
3913
3931
return ir_render_coro_alloc_fail (g, executable, (IrInstructionCoroAllocFail *)instruction);
3932
+ case IrInstructionIdCoroSuspend:
3933
+ return ir_render_coro_suspend (g, executable, (IrInstructionCoroSuspend *)instruction);
3934
+ case IrInstructionIdCoroEnd:
3935
+ return ir_render_coro_end (g, executable, (IrInstructionCoroEnd *)instruction);
3936
+ case IrInstructionIdCoroFree:
3937
+ return ir_render_coro_free (g, executable, (IrInstructionCoroFree *)instruction);
3938
+ case IrInstructionIdCoroResume:
3939
+ return ir_render_coro_resume (g, executable, (IrInstructionCoroResume *)instruction);
3914
3940
}
3915
3941
zig_unreachable ();
3916
3942
}
@@ -4155,9 +4181,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
4155
4181
TypeTableEntry *child_type = type_entry->data .maybe .child_type ;
4156
4182
if (child_type->zero_bits ) {
4157
4183
return LLVMConstInt (LLVMInt1Type (), const_val->data .x_maybe ? 1 : 0 , false );
4158
- } else if (child_type->id == TypeTableEntryIdPointer ||
4159
- child_type->id == TypeTableEntryIdFn)
4160
- {
4184
+ } else if (type_is_codegen_pointer (child_type)) {
4161
4185
if (const_val->data .x_maybe ) {
4162
4186
return gen_const_val (g, const_val->data .x_maybe , " " );
4163
4187
} else {
@@ -6085,9 +6109,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf
6085
6109
if (child_type->zero_bits ) {
6086
6110
buf_init_from_str (out_buf, " bool" );
6087
6111
return ;
6088
- } else if (child_type->id == TypeTableEntryIdPointer ||
6089
- child_type->id == TypeTableEntryIdFn)
6090
- {
6112
+ } else if (type_is_codegen_pointer (child_type)) {
6091
6113
return get_c_type (g, gen_h, child_type, out_buf);
6092
6114
} else {
6093
6115
zig_unreachable ();
0 commit comments