From 682cdeceaa7f55a14ad88ce01030888a9c18960e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 15 Oct 2021 18:37:09 -0700 Subject: stage2: optional comparison and 0-bit payloads * Sema: implement peer type resolution for optionals and null. * Rename `Module.optionalType` to `Type.optional`. * LLVM backend: re-use anonymous values. This is especially useful when isByRef()=true because it means re-using the same generated LLVM globals. * LLVM backend: rework the implementation of is_null and is_non_null AIR instructions. Generate slightly better LLVM code, and also fix the behavior for optionals whose payload type is 0-bit. * LLVM backend: improve `cmp` AIR instruction lowering to support pointer-like optionals. * `Value`: implement support for equality-checking optionals. --- src/Module.zig | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 5436071fc1..43c0178863 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4249,20 +4249,6 @@ pub fn errNoteNonLazy( }; } -pub fn optionalType(arena: *Allocator, child_type: Type) Allocator.Error!Type { - switch (child_type.tag()) { - .single_const_pointer => return Type.Tag.optional_single_const_pointer.create( - arena, - child_type.elemType(), - ), - .single_mut_pointer => return Type.Tag.optional_single_mut_pointer.create( - arena, - child_type.elemType(), - ), - else => return Type.Tag.optional.create(arena, child_type), - } -} - pub fn errorUnionType( arena: *Allocator, error_set: Type, -- cgit v1.2.3