diff --git a/lib/std/collections/enummap.c3 b/lib/std/collections/enummap.c3 index 1f481f137..85e956129 100644 --- a/lib/std/collections/enummap.c3 +++ b/lib/std/collections/enummap.c3 @@ -13,7 +13,7 @@ fn void EnumMap.init(&self, ValueType init_value) } } -fn usz! EnumMap.to_format(&self, Formatter* formatter) @dynamic +fn usz! EnumMap.to_format(&self, Formatter* formatter) : Printable { usz n = formatter.print("{ ")!; foreach (i, &value : self.values) @@ -25,7 +25,7 @@ fn usz! EnumMap.to_format(&self, Formatter* formatter) @dynamic return n; } -fn String EnumMap.to_string(&self, Allocator* using = mem::heap()) @dynamic +fn String EnumMap.to_string(&self, Allocator* using = mem::heap()) : Printable { return string::printf("%s", *self); } diff --git a/lib/std/collections/enumset.c3 b/lib/std/collections/enumset.c3 index 3175167b4..8c9a53afe 100644 --- a/lib/std/collections/enumset.c3 +++ b/lib/std/collections/enumset.c3 @@ -125,7 +125,7 @@ fn EnumSet EnumSet.xor_of(&self, EnumSet s) $endif } -fn usz! EnumSet.to_format(&set, Formatter* formatter) @dynamic +fn usz! EnumSet.to_format(&set, Formatter* formatter) : Printable { usz n = formatter.print("[")!; bool found; @@ -140,7 +140,7 @@ fn usz! EnumSet.to_format(&set, Formatter* formatter) @dynamic return n; } -fn String EnumSet.to_string(&set, Allocator* using = mem::heap()) @dynamic +fn String EnumSet.to_string(&set, Allocator* using = mem::heap()) : Printable { return string::printf("%s", *set); } diff --git a/lib/std/collections/list.c3 b/lib/std/collections/list.c3 index 4610a95e1..a4173df87 100644 --- a/lib/std/collections/list.c3 +++ b/lib/std/collections/list.c3 @@ -6,7 +6,7 @@ import std::io; import std::math; def ElementPredicate = fn bool(Type *type); -def ElementTest = fn bool(Type *type, any context); +def ElementTest = fn bool(Type *type, any* context); const ELEMENT_IS_EQUATABLE = types::is_equatable_type(Type); const ELEMENT_IS_POINTER = Type.kindof == POINTER; @@ -42,7 +42,7 @@ fn void List.tinit(&self, usz initial_capacity = 16) self.init(initial_capacity, mem::temp()) @inline; } -fn usz! List.to_format(&self, Formatter* formatter) @dynamic +fn usz! List.to_format(&self, Formatter* formatter) : Printable { switch (self.size) { @@ -62,7 +62,7 @@ fn usz! List.to_format(&self, Formatter* formatter) @dynamic } } -fn String List.to_string(&self, Allocator* using = mem::heap()) @dynamic +fn String List.to_string(&self, Allocator* using = mem::heap()) : Printable { return string::printf("%s", *self); } @@ -286,12 +286,12 @@ macro usz List._remove_if(&self, ElementPredicate filter, bool $invert) @local return size - self.size; } -fn usz List.remove_using_test(&self, ElementTest filter, any context) +fn usz List.remove_using_test(&self, ElementTest filter, any* context) { return self._remove_using_test(filter, false, context); } -fn usz List.retain_using_test(&self, ElementTest filter, any context) +fn usz List.retain_using_test(&self, ElementTest filter, any* context) { return self._remove_using_test(filter, true, context); } diff --git a/lib/std/collections/object.c3 b/lib/std/collections/object.c3 index 2b0cc39f0..7d3c99837 100644 --- a/lib/std/collections/object.c3 +++ b/lib/std/collections/object.c3 @@ -27,7 +27,7 @@ struct Object } -fn usz! Object.to_format(&self, Formatter* formatter) @dynamic +fn usz! Object.to_format(&self, Formatter* formatter) : Printable { switch (self.type) { diff --git a/lib/std/collections/priorityqueue.c3 b/lib/std/collections/priorityqueue.c3 index 2360fbfc6..7e8362261 100644 --- a/lib/std/collections/priorityqueue.c3 +++ b/lib/std/collections/priorityqueue.c3 @@ -133,12 +133,12 @@ fn Type PrivatePriorityQueue.peek_at(&self, usz index) @operator([]) return self.heap[index]; } -fn usz! PrivatePriorityQueue.to_format(&self, Formatter* formatter) @dynamic +fn usz! PrivatePriorityQueue.to_format(&self, Formatter* formatter) : Printable { return self.heap.to_format(formatter); } -fn String PrivatePriorityQueue.to_string(&self, Allocator* using = mem::heap()) @dynamic +fn String PrivatePriorityQueue.to_string(&self, Allocator* using = mem::heap()) : Printable { return self.heap.to_string(using); } \ No newline at end of file diff --git a/lib/std/collections/range.c3 b/lib/std/collections/range.c3 index a756f7138..9a21361d6 100644 --- a/lib/std/collections/range.c3 +++ b/lib/std/collections/range.c3 @@ -29,12 +29,12 @@ fn Type Range.get(&self, usz index) @operator([]) return self.start + (Type)index; } -fn String Range.to_string(&self, Allocator* using = mem::heap()) @dynamic +fn String Range.to_string(&self, Allocator* using = mem::heap()) : Printable { return string::printf("[%s..%s]", self.start, self.end); } -fn usz! Range.to_format(&self, Formatter* formatter) @dynamic +fn usz! Range.to_format(&self, Formatter* formatter) : Printable { return formatter.printf("[%s..%s]", self.start, self.end)!; } @@ -56,12 +56,12 @@ fn bool ExclusiveRange.contains(&self, Type value) @inline return value >= self.start && value < self.end; } -fn usz! ExclusiveRange.to_format(&self, Formatter* formatter) @dynamic +fn usz! ExclusiveRange.to_format(&self, Formatter* formatter) : Printable { return formatter.printf("[%s..<%s]", self.start, self.end)!; } -fn String ExclusiveRange.to_string(&self, Allocator* using = mem::heap()) @dynamic +fn String ExclusiveRange.to_string(&self, Allocator* using = mem::heap()) : Printable { return string::printf("[%s..<%s]", self.start, self.end); } diff --git a/lib/std/core/builtin.c3 b/lib/std/core/builtin.c3 index a6373b64a..7103e4f88 100644 --- a/lib/std/core/builtin.c3 +++ b/lib/std/core/builtin.c3 @@ -62,7 +62,7 @@ macro void @swap(&a, &b) @builtin * @ensure @typeis(return, $Type*) * @return! CastResult.TYPE_MISMATCH **/ -macro anycast(any v, $Type) @builtin +macro anycast(any* v, $Type) @builtin { if (v.type != $Type.typeid) return CastResult.TYPE_MISMATCH?; return ($Type*)v.ptr; @@ -190,6 +190,21 @@ macro void unsupported(String string = "Unsupported function invoked") @builtin $$unreachable(); } +macro any_make(void* ptr, typeid type) @builtin +{ + return $$any_make(ptr, type); +} + +macro any.retype_to(&self, typeid type) +{ + return $$any_make(self.ptr, type); +} + +macro any.as_inner(&self) +{ + return $$any_make(self.ptr, self.type.inner); +} + /** * @param expr "the expression to cast" * @param $Type "the type to cast to" diff --git a/lib/std/core/types.c3 b/lib/std/core/types.c3 index 9a99ef487..dedcfd4aa 100644 --- a/lib/std/core/types.c3 +++ b/lib/std/core/types.c3 @@ -11,7 +11,7 @@ fault ConversionResult /** * @require $Type.kindof.is_int() || $Type.kindof == TypeKind.ENUM "Argument was not an integer" **/ -macro any_to_int(any v, $Type) +macro any_to_int(any* v, $Type) { typeid any_type = v.type; TypeKind kind = any_type.kindof; diff --git a/lib/std/io/formatter.c3 b/lib/std/io/formatter.c3 index e0454f5e9..9b55c9bce 100644 --- a/lib/std/io/formatter.c3 +++ b/lib/std/io/formatter.c3 @@ -4,8 +4,11 @@ import libc; const int PRINTF_NTOA_BUFFER_SIZE = 256; -fn String any.to_string(void* value, Allocator *using) @interface; -fn usz! any.to_format(void* value, Formatter* formatter) @interface; +protocol Printable +{ + fn String to_string(&self, Allocator *using); + fn usz! to_format(&self, Formatter* formatter); +} fault PrintFault { @@ -69,7 +72,7 @@ fn usz! Formatter.out(&self, char c) @private return 1; } -macro usz! Formatter.print_with_function(&self, any arg) +fn usz! Formatter.print_with_function(&self, Printable* arg) { if (&arg.to_format) { @@ -104,7 +107,7 @@ macro usz! Formatter.print_with_function(&self, any arg) } -fn usz! Formatter.out_str(&self, any arg) @private +fn usz! Formatter.out_str(&self, any* arg) @private { switch (arg.type.kindof) { @@ -116,7 +119,7 @@ fn usz! Formatter.out_str(&self, any arg) @private case FAULT: return self.out_substr((*(anyfault*)arg.ptr).nameof); case ANY: - return self.out_str(*(any*)arg); + return self.out_str(*(any**)arg); case OPTIONAL: unreachable(); case SIGNED_INT: @@ -146,14 +149,16 @@ fn usz! Formatter.out_str(&self, any arg) @private return self.out_substr(*(bool*)arg.ptr ? "true" : "false"); default: } - usz! n = self.print_with_function(arg); + usz! n = self.print_with_function((Printable*)arg); if (catch err = n) { case SearchResult.MISSING: break; default: return err?; - } else { + } + else + { return n; } switch (arg.type.kindof) @@ -179,7 +184,7 @@ fn usz! Formatter.out_str(&self, any arg) @private { return self.out_substr(((DString*)arg).str_view()); } - return self.out_str(any { arg.ptr, arg.type.inner }); + return self.out_str(arg.as_inner()); case POINTER: PrintFlags flags = self.flags; uint width = self.width; @@ -211,7 +216,7 @@ fn usz! Formatter.out_str(&self, any arg) @private for (usz i = 0; i < alen; i++) { if (i != 0) len += self.out_substr(", ")!; - len += self.out_str(any { ptr, inner })!; + len += self.out_str(any_make(ptr, inner))!; ptr += size; } len += self.out(']')!; @@ -236,7 +241,7 @@ fn usz! Formatter.out_str(&self, any arg) @private for (usz i = 0; i < vlen; i++) { if (i != 0) len += self.out_substr(", ")!; - len += self.out_str(any { ptr, inner })!; + len += self.out_str(any_make(ptr, inner))!; ptr += size; } len += self.out_substr(">]")!; @@ -267,7 +272,7 @@ fn usz! Formatter.out_str(&self, any arg) @private for (usz i = 0; i < slen; i++) { if (i != 0) len += self.out_substr(", ")!; - len += self.out_str(any { ptr, inner })!; + len += self.out_str(any_make(ptr, inner))!; ptr += size; } len += self.out(']')!; @@ -286,7 +291,7 @@ fn void! out_null_fn(void* data @unused, char c @unused) @private -fn usz! Formatter.vprintf(&self, String format, any[] anys) +fn usz! Formatter.vprintf(&self, String format, any*[] anys) { if (!self.out_fn) { @@ -353,7 +358,7 @@ fn usz! Formatter.vprintf(&self, String format, any[] anys) // evaluate specifier uint base = 0; if (variant_index >= anys.len) return PrintFault.MISSING_ARG?; - any current = anys[variant_index++]; + any* current = anys[variant_index++]; switch (c) { case 'd': diff --git a/lib/std/io/formatter_private.c3 b/lib/std/io/formatter_private.c3 index 82d75bc7c..3235e38b5 100644 --- a/lib/std/io/formatter_private.c3 +++ b/lib/std/io/formatter_private.c3 @@ -9,7 +9,7 @@ fn usz! Formatter.adjust(&self, usz len) @local return self.pad(' ', self.width, len); } -fn uint128! int_from_any(any arg, bool *is_neg) @private +fn uint128! int_from_any(any* arg, bool *is_neg) @private { *is_neg = false; if (arg.type.kindof == TypeKind.POINTER) @@ -18,7 +18,7 @@ fn uint128! int_from_any(any arg, bool *is_neg) @private } if (arg.type.kindof == TypeKind.DISTINCT) { - return int_from_any(any { arg.ptr, arg.type.inner }, is_neg); + return int_from_any(arg.as_inner(), is_neg); } switch (arg) { @@ -60,7 +60,7 @@ fn uint128! int_from_any(any arg, bool *is_neg) @private } } -fn FloatType! float_from_any(any arg) @private +fn FloatType! float_from_any(any* arg) @private { $if env::F128_SUPPORT: if (arg.type == float128.typeid) return (FloatType)*((float128*)arg.ptr); @@ -70,7 +70,7 @@ fn FloatType! float_from_any(any arg) @private $endif if (arg.type.kindof == TypeKind.DISTINCT) { - return float_from_any(any { arg.ptr, arg.type.inner }); + return float_from_any(arg.as_inner()); } switch (arg) { @@ -585,14 +585,14 @@ fn usz! Formatter.ntoa_format(&self, String buf, usz len, bool negative, uint ba } -fn usz! Formatter.ntoa_any(&self, any arg, uint base) @private +fn usz! Formatter.ntoa_any(&self, any* arg, uint base) @private { bool is_neg; uint128 val = int_from_any(arg, &is_neg)!!; return self.ntoa(val, is_neg, base) @inline; } -fn usz! Formatter.out_char(&self, any arg) @private +fn usz! Formatter.out_char(&self, any* arg) @private { usz len = 1; uint l = 1; @@ -646,21 +646,21 @@ fn void! printf_advance_format(usz format_len, usz *index_ptr) @inline @private if (val >= format_len) return FormattingFault.UNTERMINATED_FORMAT?; } -fn any! next_any(any* args_ptr, usz args_len, usz* arg_index_ptr) @inline @private +fn any*! next_any(any** args_ptr, usz args_len, usz* arg_index_ptr) @inline @private { if (*arg_index_ptr >= args_len) return FormattingFault.MISSING_ARG?; return args_ptr[(*arg_index_ptr)++]; } fn int! printf_parse_format_field( - any* args_ptr, usz args_len, usz* args_index_ptr, + any** args_ptr, usz args_len, usz* args_index_ptr, char* format_ptr, usz format_len, usz* index_ptr) @inline @private { char c = format_ptr[*index_ptr]; if (c.is_digit()) return simple_atoi(format_ptr, format_len, index_ptr); if (c != '*') return 0; printf_advance_format(format_len, index_ptr)!; - any val = next_any(args_ptr, args_len, args_index_ptr)!; + any* val = next_any(args_ptr, args_len, args_index_ptr)!; if (!val.type.kindof.is_int()) return FormattingFault.INVALID_WIDTH_ARG?; uint! intval = types::any_to_int(val, int); return intval ?? FormattingFault.INVALID_WIDTH_ARG?; diff --git a/lib/std/io/path.c3 b/lib/std/io/path.c3 index 9ac651dd6..4beaf788d 100644 --- a/lib/std/io/path.c3 +++ b/lib/std/io/path.c3 @@ -449,12 +449,12 @@ fn void Path.free(self) } -fn usz! Path.to_format(&self, Formatter* formatter) @dynamic +fn usz! Path.to_format(&self, Formatter* formatter) : Printable { return formatter.print(self.str_view()); } -fn String Path.to_string(&self, Allocator* using = mem::heap()) @dynamic +fn String Path.to_string(&self, Allocator* using = mem::heap()) : Printable { return self.str_view().copy(using); } diff --git a/lib/std/io/stream.c3 b/lib/std/io/stream.c3 index 27da70f92..ca2f00c74 100644 --- a/lib/std/io/stream.c3 +++ b/lib/std/io/stream.c3 @@ -84,7 +84,7 @@ fn usz! Stream.available(&self) @inline return IoError.NOT_SEEKABLE?; } -fn usz! Stream.read_any(&self, any ref) +fn usz! Stream.read_any(&self, any* ref) { return self.read_all(ref.ptr[:ref.type.sizeof]); } @@ -94,7 +94,7 @@ fn usz! Stream.read_any(&self, any ref) * @require ref.ptr != null * @ensure return == ref.type.sizeof */ -fn usz! Stream.write_any(&self, any ref) +fn usz! Stream.write_any(&self, any* ref) { return self.write_all(ref.ptr[:ref.type.sizeof]); } diff --git a/lib/std/net/inetaddr.c3 b/lib/std/net/inetaddr.c3 index 107bce82c..ea0ca243b 100644 --- a/lib/std/net/inetaddr.c3 +++ b/lib/std/net/inetaddr.c3 @@ -45,7 +45,7 @@ struct InetAddress } -fn usz! InetAddress.to_format(InetAddress* addr, Formatter* formatter) @dynamic +fn usz! InetAddress.to_format(InetAddress* addr, Formatter* formatter) : Printable { if (addr.is_ipv6) { @@ -56,7 +56,7 @@ fn usz! InetAddress.to_format(InetAddress* addr, Formatter* formatter) @dynamic return formatter.printf("%d.%d.%d.%d", addr.ipv4.a, addr.ipv4.b, addr.ipv4.c, addr.ipv4.d)!; } -fn String InetAddress.to_string(InetAddress* addr, Allocator* using = mem::heap()) @dynamic +fn String InetAddress.to_string(InetAddress* addr, Allocator* using = mem::heap()) : Printable { if (addr.is_ipv6) { diff --git a/lib/std/net/os/posix.c3 b/lib/std/net/os/posix.c3 index 22c129d85..0fa1ed077 100644 --- a/lib/std/net/os/posix.c3 +++ b/lib/std/net/os/posix.c3 @@ -16,7 +16,7 @@ struct Posix_pollfd def Posix_nfds_t = CUInt; extern fn CInt connect(NativeSocket socket, SockAddrPtr address, Socklen_t address_len); -extern fn NativeSocket socket(AIFamily af, AISockType type, AIProtocol protocol) @extern("socket"); +extern fn NativeSocket socket(AIFamily af, AISockType type, AIProtocol ip_protocol) @extern("socket"); extern fn int fcntl(NativeSocket socket, int cmd, ...) @extern("fcntl"); extern fn CInt bind(NativeSocket socket, SockAddrPtr address, Socklen_t address_len) @extern("bind"); extern fn CInt listen(NativeSocket socket, CInt backlog) @extern("listen"); diff --git a/lib/std/net/os/win32.c3 b/lib/std/net/os/win32.c3 index 385ccb717..83eb96a85 100644 --- a/lib/std/net/os/win32.c3 +++ b/lib/std/net/os/win32.c3 @@ -17,7 +17,7 @@ def NativeSocket = distinct uptr; extern fn CInt ioctlsocket(NativeSocket, CLong cmd, CULong *argp); extern fn WSAError closesocket(NativeSocket); -extern fn NativeSocket socket(AIFamily af, AISockType type, AIProtocol protocol); +extern fn NativeSocket socket(AIFamily af, AISockType type, AIProtocol ip_protocol); extern fn int connect(NativeSocket, SockAddrPtr address, Socklen_t address_len); extern fn int bind(NativeSocket, SockAddrPtr address, Socklen_t address_len); extern fn int listen(NativeSocket, int backlog); diff --git a/lib/std/net/tcp.c3 b/lib/std/net/tcp.c3 index eadf83c86..4a2c6530e 100644 --- a/lib/std/net/tcp.c3 +++ b/lib/std/net/tcp.c3 @@ -5,9 +5,9 @@ import libc; def TcpSocket = distinct inline Socket; def TcpServerSocket = distinct inline Socket; -fn TcpSocket! connect(String host, uint port, Duration timeout = 0, SocketOption... options, IpProtocol protocol = UNSPECIFIED) +fn TcpSocket! connect(String host, uint port, Duration timeout = 0, SocketOption... options, IpProtocol ip_protocol = UNSPECIFIED) { - AddrInfo* ai = net::addrinfo(host, port, protocol.ai_family, os::SOCK_STREAM)!; + AddrInfo* ai = net::addrinfo(host, port, ip_protocol.ai_family, os::SOCK_STREAM)!; defer os::freeaddrinfo(ai); if (timeout > 0) { @@ -16,9 +16,9 @@ fn TcpSocket! connect(String host, uint port, Duration timeout = 0, SocketOption return connect_to(ai, ...options); } -fn TcpSocket! connect_async(String host, uint port, SocketOption... options, IpProtocol protocol = UNSPECIFIED) +fn TcpSocket! connect_async(String host, uint port, SocketOption... options, IpProtocol ip_protocol = UNSPECIFIED) { - AddrInfo* ai = net::addrinfo(host, port, protocol.ai_family, os::SOCK_STREAM)!; + AddrInfo* ai = net::addrinfo(host, port, ip_protocol.ai_family, os::SOCK_STREAM)!; defer os::freeaddrinfo(ai); return connect_async_to(ai, ...options); } @@ -33,9 +33,9 @@ fn TcpSocket! connect_async_to(AddrInfo* ai, SocketOption... options) return (TcpSocket)net::connect_async_from_addrinfo(ai, options); } -fn TcpServerSocket! listen(String host, uint port, uint backlog, SocketOption... options, IpProtocol protocol = UNSPECIFIED) +fn TcpServerSocket! listen(String host, uint port, uint backlog, SocketOption... options, IpProtocol ip_protocol = UNSPECIFIED) { - AddrInfo* ai = net::addrinfo(host, port, protocol.ai_family, os::SOCK_STREAM)!; + AddrInfo* ai = net::addrinfo(host, port, ip_protocol.ai_family, os::SOCK_STREAM)!; defer os::freeaddrinfo(ai); return listen_to(ai, backlog, ...options); } diff --git a/lib/std/net/udp.c3 b/lib/std/net/udp.c3 index 30857f7c9..451205f33 100644 --- a/lib/std/net/udp.c3 +++ b/lib/std/net/udp.c3 @@ -3,9 +3,9 @@ import std::net @public; def UdpSocket = distinct inline Socket; -fn UdpSocket! connect(String host, uint port, SocketOption... options, IpProtocol protocol = UNSPECIFIED) +fn UdpSocket! connect(String host, uint port, SocketOption... options, IpProtocol ip_protocol = UNSPECIFIED) { - AddrInfo* ai = net::addrinfo(host, port, protocol.ai_family, os::SOCK_DGRAM)!; + AddrInfo* ai = net::addrinfo(host, port, ip_protocol.ai_family, os::SOCK_DGRAM)!; defer os::freeaddrinfo(ai); return connect_to(ai, ...options); } @@ -15,9 +15,9 @@ fn UdpSocket! connect_to(AddrInfo* ai, SocketOption... options) return (UdpSocket)net::connect_from_addrinfo(ai, options); } -fn UdpSocket! connect_async(String host, uint port, SocketOption... options, IpProtocol protocol = UNSPECIFIED) +fn UdpSocket! connect_async(String host, uint port, SocketOption... options, IpProtocol ip_protocol = UNSPECIFIED) { - AddrInfo* ai = net::addrinfo(host, port, protocol.ai_family, os::SOCK_DGRAM)!; + AddrInfo* ai = net::addrinfo(host, port, ip_protocol.ai_family, os::SOCK_DGRAM)!; defer os::freeaddrinfo(ai); return connect_async_to(ai, ...options); } diff --git a/lib/std/os/backtrace.c3 b/lib/std/os/backtrace.c3 index 957181ec6..2efaee571 100644 --- a/lib/std/os/backtrace.c3 +++ b/lib/std/os/backtrace.c3 @@ -30,7 +30,7 @@ fn bool Backtrace.is_unknown(&self) return !self.object_file.len; } -fn usz! Backtrace.to_format(&self, Formatter* formatter) @dynamic +fn usz! Backtrace.to_format(&self, Formatter* formatter) : Printable { if (self.has_file()) { diff --git a/lib/std/time/time.c3 b/lib/std/time/time.c3 index 210b9474c..055846e7f 100644 --- a/lib/std/time/time.c3 +++ b/lib/std/time/time.c3 @@ -1,9 +1,9 @@ module std::time; -def Time = distinct long @inline; -def Duration = distinct long @inline; -def Clock = distinct ulong @inline; -def NanoDuration = distinct long @inline; +def Time = distinct long; +def Duration = distinct long; +def Clock = distinct ulong; +def NanoDuration = distinct long; const Duration MS = 1_000; const Duration SEC = 1_000_000; @@ -97,7 +97,7 @@ fn Duration NanoDuration.to_duration(nd) => (Duration)nd / 1_000; fn NanoDuration Duration.to_nano(td) => (NanoDuration)td * 1_000; fn long Duration.to_ms(td) => (long)td / 1_000; -fn usz! NanoDuration.to_format(&self, Formatter* formatter) @dynamic +fn usz! NanoDuration.to_format(&self, Formatter* formatter) : Printable { NanoDuration nd = *self; if (nd == 0) diff --git a/releasenotes.md b/releasenotes.md index 6a7c04ddb..f2425749a 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -34,7 +34,7 @@ - Delete object files after successful linking. - Compile time subscript of constant strings and bytes. - `@if` introduced, other top level conditional compilation removed. -- `@dynamic` and `@interface` for dynamic dispatch. +- Dynamically dispatched interfaces. - `$if` now uses `$if :` syntax. - `$assert` now uses `$assert : ` - `$error` is syntax sugar for `$assert false : "Some message"` diff --git a/src/compiler/abi/c_abi_x64.c b/src/compiler/abi/c_abi_x64.c index a1180170d..1b88308b5 100644 --- a/src/compiler/abi/c_abi_x64.c +++ b/src/compiler/abi/c_abi_x64.c @@ -382,6 +382,8 @@ static void x64_classify(Type *type, ByteSize offset_base, X64Class *lo_class, X { case LOWERED_TYPES: case TYPE_FUNC: + case TYPE_ANY: + case TYPE_PROTOCOL: UNREACHABLE case TYPE_VOID: *current = CLASS_NO_CLASS; @@ -389,7 +391,7 @@ static void x64_classify(Type *type, ByteSize offset_base, X64Class *lo_class, X case TYPE_I128: case TYPE_U128: case TYPE_SUBARRAY: - case TYPE_ANY: + case TYPE_ANYPTR: *lo_class = CLASS_INTEGER; *hi_class = CLASS_INTEGER; break; @@ -560,6 +562,12 @@ AbiType x64_get_int_type_at_offset(Type *type, unsigned offset, Type *source_typ type = type_lowering(type); switch (type->type_kind) { + case LOWERED_TYPES: + case TYPE_VOID: + case TYPE_FUNC: + case TYPE_ANY: + case TYPE_PROTOCOL: + UNREACHABLE case TYPE_U64: case TYPE_I64: case TYPE_POINTER: @@ -589,7 +597,7 @@ AbiType x64_get_int_type_at_offset(Type *type, unsigned offset, Type *source_typ } break; } - case TYPE_ANY: + case TYPE_ANYPTR: if (offset < 8) return abi_type_get(type_ulong); if (offset < 16) return abi_type_get(type_voidptr); break; @@ -606,10 +614,6 @@ AbiType x64_get_int_type_at_offset(Type *type, unsigned offset, Type *source_typ TypeSize element_offset = (offset / element_size) * element_size; return x64_get_int_type_at_offset(element, offset - element_offset, source_type, source_offset); } - case TYPE_VOID: - case LOWERED_TYPES: - case TYPE_FUNC: - UNREACHABLE case TYPE_I128: case TYPE_U128: case ALL_FLOATS: diff --git a/src/compiler/abi/c_abi_x86.c b/src/compiler/abi/c_abi_x86.c index 1e3773199..8387ec499 100644 --- a/src/compiler/abi/c_abi_x86.c +++ b/src/compiler/abi/c_abi_x86.c @@ -120,13 +120,16 @@ static bool x86_should_return_type_in_reg(Type *type) case CT_TYPES: case TYPE_OPTIONAL: case TYPE_FLEXIBLE_ARRAY: + case TYPE_PROTOCOL: + case TYPE_ANY: + case TYPE_PROPTR: UNREACHABLE case ALL_INTS: case ALL_FLOATS: case TYPE_BOOL: case TYPE_POINTER: case TYPE_SUBARRAY: - case TYPE_ANY: + case TYPE_ANYPTR: return true; case TYPE_ARRAY: // Small arrays <= 8 bytes. @@ -456,6 +459,8 @@ static ABIArgInfo *x86_classify_argument(CallABI call, Regs *regs, Type *type) case LOWERED_TYPES: case TYPE_VOID: case TYPE_FUNC: + case TYPE_ANY: + case TYPE_PROTOCOL: case TYPE_FLEXIBLE_ARRAY: UNREACHABLE case ALL_FLOATS: @@ -468,7 +473,7 @@ static ABIArgInfo *x86_classify_argument(CallABI call, Regs *regs, Type *type) case TYPE_STRUCT: case TYPE_UNION: case TYPE_SUBARRAY: - case TYPE_ANY: + case TYPE_ANYPTR: case TYPE_ARRAY: return x86_classify_aggregate(call, regs, type); UNREACHABLE diff --git a/src/compiler/ast.c b/src/compiler/ast.c index 78f79c426..bef954a6b 100644 --- a/src/compiler/ast.c +++ b/src/compiler/ast.c @@ -54,6 +54,9 @@ Decl *decl_new_with_type(const char *name, SourceSpan loc, DeclKind decl_type) case DECL_FNTYPE: case DECL_FUNC: UNREACHABLE + case DECL_PROTOCOL: + kind = TYPE_PROTOCOL; + break; case DECL_UNION: kind = TYPE_UNION; break; @@ -119,6 +122,7 @@ const char *decl_to_a_name(Decl *decl) case DECL_LABEL: return "a label"; case DECL_MACRO: return "a macro"; case DECL_POISONED: return "a poisoned decl"; + case DECL_PROTOCOL: return "a protocol"; case DECL_STRUCT: return "a struct"; case DECL_UNION: return "a union"; case DECL_VAR: diff --git a/src/compiler/codegen_general.c b/src/compiler/codegen_general.c index e2a178eb8..521a088ca 100644 --- a/src/compiler/codegen_general.c +++ b/src/compiler/codegen_general.c @@ -167,36 +167,22 @@ bool type_homogenous_aggregate_small_enough(Type *type, unsigned members) */ bool type_is_homogenous_aggregate(Type *type, Type **base, unsigned *elements) { + assert(type_lowering(type) == type); *elements = 0; - RETRY: switch (type->type_kind) { - case TYPE_OPTIONAL: - type = type->optional; - goto RETRY; - case TYPE_DISTINCT: - type = type->decl->distinct_decl.base_type; - goto RETRY; - case TYPE_BITSTRUCT: - type = type->decl->bitstruct.base_type->type; - goto RETRY; + case LOWERED_TYPES: + case TYPE_ANY: + case TYPE_PROTOCOL: + UNREACHABLE; case TYPE_VOID: - case TYPE_TYPEID: case TYPE_FUNC: case TYPE_SUBARRAY: - case CT_TYPES: return false; - case TYPE_ANY: + case TYPE_ANYPTR: *base = type_iptr->canonical; *elements = 2; return true; - case TYPE_ANYFAULT: - case TYPE_FAULTTYPE: - type = type_iptr; - goto RETRY; - case TYPE_TYPEDEF: - type = type->canonical; - goto RETRY; case TYPE_STRUCT: case TYPE_UNION: if (type->decl->has_variable_array) return false; @@ -218,7 +204,7 @@ bool type_is_homogenous_aggregate(Type *type, Type **base, unsigned *elements) unsigned member_members = 0; // Check recursively if the field member is homogenous - if (!type_is_homogenous_aggregate(member_type, base, &member_members)) return false; + if (!type_is_homogenous_aggregate(type_lowering(member_type), base, &member_members)) return false; member_members *= member_mult; // In the case of a union, grab the bigger set of elements. if (type->type_kind == TYPE_UNION) @@ -244,12 +230,9 @@ bool type_is_homogenous_aggregate(Type *type, Type **base, unsigned *elements) // Empty arrays? Not homogenous. if (type->array.len == 0) return false; // Check the underlying type and multiply by length. - if (!type_is_homogenous_aggregate(type->array.base, base, elements)) return false; + if (!type_is_homogenous_aggregate(type_lowering(type->array.base), base, elements)) return false; *elements *= type->array.len; goto TYPECHECK; - case TYPE_ENUM: - type = type->decl->enums.type_info->type; - goto RETRY; case TYPE_BOOL: // Lower bool to unsigned char type = type_char; diff --git a/src/compiler/codegen_internal.h b/src/compiler/codegen_internal.h index d4d053f25..cd0aa0ce5 100644 --- a/src/compiler/codegen_internal.h +++ b/src/compiler/codegen_internal.h @@ -36,6 +36,8 @@ static inline Type *type_lowering(Type *type) case TYPE_ENUM: type = type->decl->enums.type_info->type; continue; + case TYPE_PROPTR: + return type_anyptr; case TYPE_ANYFAULT: case TYPE_TYPEID: case TYPE_FAULTTYPE: diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 5b638e727..f2c0b5363 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -99,7 +99,16 @@ typedef enum CONST_INIT_ARRAY_VALUE, } ConstInitType; - +typedef enum +{ + RESOLVE_TYPE_DEFAULT, + RESOLVE_TYPE_ALLOW_INFER = 0x01, + RESOLVE_TYPE_ALLOW_ANY = 0x02, + RESOLVE_TYPE_IS_POINTEE = 0x04, + RESOLVE_TYPE_PTR = RESOLVE_TYPE_ALLOW_ANY | RESOLVE_TYPE_IS_POINTEE, + RESOLVE_TYPE_MACRO_METHOD = RESOLVE_TYPE_ALLOW_ANY | RESOLVE_TYPE_ALLOW_INFER, + RESOLVE_TYPE_FUNC_METHOD = RESOLVE_TYPE_ALLOW_ANY +} ResolveTypeKind; struct ConstInitializer_ { @@ -549,15 +558,17 @@ typedef struct bool attr_benchmark : 1; bool attr_test : 1; bool attr_winmain : 1; - bool attr_dynamic : 1; - bool attr_interface : 1; + bool attr_optional : 1; bool attr_init : 1; bool attr_finalizer : 1; + bool attr_protocol_method : 1; bool is_lambda : 1; + bool is_dynamic : 1; union { uint32_t priority; - DeclId any_prototype; + TypeInfoId protocol_unresolved; + DeclId protocol_method; Decl **generated_lambda; Decl **lambda_ct_parameters; }; @@ -629,6 +640,11 @@ typedef struct }; } DefineDecl; +typedef struct +{ + const char **parents; + Decl **protocol_methods; +} ProtocolDecl; typedef struct { AstId defer; @@ -695,6 +711,7 @@ typedef struct Decl_ Decl** decl_list; struct { + Decl **protocols; Decl **methods; union { @@ -720,6 +737,7 @@ typedef struct Decl_ ImportDecl import; IncludeDecl include; LabelDecl label; + ProtocolDecl protocol_decl; TypedefDecl typedef_decl; VarDecl var; }; @@ -813,12 +831,6 @@ typedef struct ExprId right; } ExprSliceAssign; -typedef struct -{ - ExprId ptr; - ExprId type_id; -} ExprAny; - typedef struct { bool raw_offset : 1; @@ -1135,7 +1147,6 @@ struct Expr_ ResolveStatus resolve_status : 4; union { ExprAccess access_expr; // 16 - ExprAny any_expr; // 8 ExprAnySwitch any_switch; // 32 ExprBinary binary_expr; // 12 ExprBodyExpansion body_expansion_expr; // 24 @@ -1862,8 +1873,7 @@ extern Type *type_ichar, *type_short, *type_int, *type_long, *type_isz; extern Type *type_char, *type_ushort, *type_uint, *type_ulong, *type_usz; extern Type *type_iptr, *type_uptr; extern Type *type_u128, *type_i128; -extern Type *type_typeid, *type_anyfault, *type_typeinfo, *type_member; -extern Type *type_any; +extern Type *type_typeid, *type_anyfault, *type_anyptr, *type_typeinfo, *type_member; extern Type *type_untypedlist; extern Type *type_wildcard; extern Type *type_cint; @@ -2307,8 +2317,8 @@ Decl *sema_resolve_symbol(SemaContext *context, const char *symbol, Path *path, bool sema_symbol_is_defined_in_scope(SemaContext *c, const char *symbol); bool sema_resolve_array_like_len(SemaContext *context, TypeInfo *type_info, ArraySize *len_ref); -bool sema_resolve_type_info(SemaContext *context, TypeInfo *type_info); -bool sema_resolve_type_info_maybe_inferred(SemaContext *context, TypeInfo *type_info, bool allow_inferred_type); + +bool sema_resolve_type_info(SemaContext *context, TypeInfo *type_info, ResolveTypeKind kind); void sema_error_at(SourceSpan loc, const char *message, ...); void sema_error_at_after(SourceSpan loc, const char *message, ...); @@ -2586,9 +2596,31 @@ INLINE bool type_is_wildcard(Type *type) return type == type_wildcard || type == type_wildcard_optional; } +INLINE bool type_is_any_raw(Type *type) +{ + switch (type->type_kind) + { + case TYPE_ANY: + case TYPE_PROTOCOL: + return true; + default: + return false; + } +} +INLINE bool type_is_any_protocol_ptr(Type *type) +{ + switch (type->canonical->type_kind) + { + case TYPE_ANYPTR: + case TYPE_PROPTR: + return true; + default: + return false; + } +} INLINE bool type_is_any(Type *type) { - return type->canonical == type_any; + return type->canonical == type_anyptr; } INLINE bool type_is_anyfault(Type *type) diff --git a/src/compiler/context.c b/src/compiler/context.c index f2abf5392..9e1777fda 100644 --- a/src/compiler/context.c +++ b/src/compiler/context.c @@ -148,6 +148,7 @@ void decl_register(Decl *decl) case DECL_MACRO: case DECL_VAR: case DECL_FNTYPE: + case DECL_PROTOCOL: global_context_add_decl(decl); break; } @@ -197,6 +198,7 @@ void unit_register_global_decl(CompilationUnit *unit, Decl *decl) decl_set_external_name(decl); decl_register(decl); break; + case DECL_PROTOCOL: case DECL_DISTINCT: case DECL_STRUCT: case DECL_UNION: diff --git a/src/compiler/copying.c b/src/compiler/copying.c index f4f0426c4..2009088e8 100644 --- a/src/compiler/copying.c +++ b/src/compiler/copying.c @@ -343,10 +343,6 @@ Expr *copy_expr(CopyStruct *c, Expr *source_expr) case EXPR_DECL: MACRO_COPY_DECL(expr->decl_expr); return expr; - case EXPR_ANY: - MACRO_COPY_EXPRID(expr->any_expr.ptr); - MACRO_COPY_EXPRID(expr->any_expr.type_id); - return expr; case EXPR_CT_CALL: MACRO_COPY_EXPR(expr->ct_call_expr.main_var); return expr; @@ -883,6 +879,9 @@ Decl *copy_decl(CopyStruct *c, Decl *decl) break; case DECL_ERASED: break; + case DECL_PROTOCOL: + MACRO_COPY_DECL_LIST(copy->protocol_decl.protocol_methods); + break; case DECL_CT_EXEC: MACRO_COPY_EXPR(copy->exec_decl.filename); MACRO_COPY_EXPR_LIST(copy->exec_decl.args); diff --git a/src/compiler/enums.h b/src/compiler/enums.h index 0fab610d4..5b9ae3c34 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -145,6 +145,7 @@ typedef enum DECL_IMPORT, DECL_LABEL, DECL_MACRO, + DECL_PROTOCOL, DECL_STRUCT, DECL_TYPEDEF, DECL_UNION, @@ -197,6 +198,7 @@ typedef enum INTROSPECT_TYPE_VECTOR = 17, INTROSPECT_TYPE_DISTINCT = 18, INTROSPECT_TYPE_POINTER = 19, + INTROSPECT_TYPE_PROTOCOL = 20, } IntrospectType; typedef enum @@ -261,7 +263,6 @@ typedef enum EXPR_TYPEID_INFO, EXPR_TYPEINFO, EXPR_UNARY, - EXPR_ANY, EXPR_ANYSWITCH, EXPR_VASPLAT, EXPR_MACRO_BODY, @@ -544,6 +545,7 @@ typedef enum TOKEN_MODULE, TOKEN_NEXTCASE, TOKEN_NULL, + TOKEN_PROTOCOL, TOKEN_RETURN, TOKEN_STATIC, TOKEN_STRUCT, @@ -650,6 +652,8 @@ typedef enum TYPE_FLOAT_LAST = TYPE_F128, TYPE_NUM_LAST = TYPE_FLOAT_LAST, TYPE_ANY, + TYPE_ANYPTR, + TYPE_PROPTR, TYPE_ANYFAULT, TYPE_TYPEID, TYPE_POINTER, @@ -657,6 +661,7 @@ typedef enum TYPE_FUNC, TYPE_STRUCT, TYPE_UNION, + TYPE_PROTOCOL, TYPE_BITSTRUCT, TYPE_FAULTTYPE, TYPE_TYPEDEF, @@ -680,7 +685,7 @@ typedef enum #define FLATTENED_TYPES TYPE_DISTINCT: case TYPE_OPTIONAL: case TYPE_TYPEDEF #define LOWERED_TYPES CT_TYPES: case TYPE_ENUM: case TYPE_TYPEDEF: case TYPE_TYPEID: \ case TYPE_DISTINCT: case TYPE_ANYFAULT: case TYPE_FAULTTYPE: case TYPE_BITSTRUCT: \ - case TYPE_OPTIONAL + case TYPE_OPTIONAL: case TYPE_PROPTR #define CT_TYPES TYPE_TYPEINFO: case TYPE_INFERRED_ARRAY: case TYPE_INFERRED_VECTOR: case TYPE_UNTYPED_LIST: \ case TYPE_POISONED: case TYPE_MEMBER: case TYPE_WILDCARD #define ALL_INTS TYPE_I8: case TYPE_I16: case TYPE_I32: case TYPE_I64: case TYPE_I128: \ @@ -749,8 +754,9 @@ typedef enum ATTR_CALL = 1 << 12, ATTR_BITSTRUCT = 1 << 13, ATTR_MACRO = 1 << 14, - ATTR_DEFINE = 1 << 15, + ATTR_DISTINCT = 1 << 15, ATTR_ENUM_VALUE = 1 << 16, + ATTR_PROTOCOL_METHOD = 1 << 17 } AttributeDomain; typedef enum @@ -769,14 +775,12 @@ typedef enum ATTRIBUTE_BUILTIN, ATTRIBUTE_CALLCONV, ATTRIBUTE_DEPRECATED, - ATTRIBUTE_DYNAMIC, ATTRIBUTE_EXPORT, ATTRIBUTE_EXTERN, ATTRIBUTE_FINALIZER, ATTRIBUTE_IF, ATTRIBUTE_INLINE, ATTRIBUTE_INIT, - ATTRIBUTE_INTERFACE, ATTRIBUTE_LITTLEENDIAN, ATTRIBUTE_LOCAL, ATTRIBUTE_MAYDISCARD, @@ -788,6 +792,7 @@ typedef enum ATTRIBUTE_NOSTRIP, ATTRIBUTE_OBFUSCATE, ATTRIBUTE_OPERATOR, + ATTRIBUTE_OPTIONAL, ATTRIBUTE_OVERLAP, ATTRIBUTE_PACKED, ATTRIBUTE_PRIVATE, @@ -835,6 +840,7 @@ typedef enum { BUILTIN_ABS, + BUILTIN_ANY_MAKE, BUILTIN_ATOMIC_LOAD, BUILTIN_ATOMIC_STORE, BUILTIN_ATOMIC_FETCH_EXCHANGE, @@ -1055,6 +1061,7 @@ typedef enum CONV_STRUCT, CONV_UNION, CONV_ANY, + CONV_PROTOCOL, CONV_FAULT, CONV_ENUM, CONV_TYPEID, diff --git a/src/compiler/expr.c b/src/compiler/expr.c index 873398e20..96585b366 100644 --- a/src/compiler/expr.c +++ b/src/compiler/expr.c @@ -119,7 +119,6 @@ bool expr_may_addr(Expr *expr) case EXPR_TRY_UNWRAP_CHAIN: case EXPR_TYPEID: case EXPR_TYPEID_INFO: - case EXPR_ANY: case EXPR_VASPLAT: case EXPR_SWIZZLE: case EXPR_LAMBDA: @@ -184,8 +183,6 @@ bool expr_is_constant_eval(Expr *expr, ConstantEvalKind eval_kind) break; } return exprid_is_constant_eval(expr->builtin_access_expr.inner, eval_kind); - case EXPR_ANY: - return exprid_is_constant_eval(expr->any_expr.type_id, eval_kind) && exprid_is_constant_eval(expr->any_expr.ptr, eval_kind); case EXPR_BINARY: return expr_binary_is_constant_eval(expr, eval_kind); case EXPR_CAST: @@ -564,6 +561,8 @@ void expr_rewrite_to_const_zero(Expr *expr, Type *type) case TYPE_VOID: case TYPE_INFERRED_VECTOR: case TYPE_WILDCARD: + case TYPE_ANY: + case TYPE_PROTOCOL: UNREACHABLE case ALL_INTS: expr_rewrite_const_int(expr, type, 0); @@ -576,7 +575,8 @@ void expr_rewrite_to_const_zero(Expr *expr, Type *type) return; case TYPE_POINTER: case TYPE_FAULTTYPE: - case TYPE_ANY: + case TYPE_ANYPTR: + case TYPE_PROPTR: case TYPE_ANYFAULT: case TYPE_TYPEID: expr_rewrite_const_null(expr, type); @@ -656,8 +656,6 @@ bool expr_is_pure(Expr *expr) return exprid_is_pure(expr->swizzle_expr.parent); case EXPR_BUILTIN_ACCESS: return exprid_is_pure(expr->builtin_access_expr.inner); - case EXPR_ANY: - return exprid_is_pure(expr->any_expr.type_id) && exprid_is_pure(expr->any_expr.ptr); case EXPR_POINTER_OFFSET: return exprid_is_pure(expr->pointer_offset_expr.ptr) && exprid_is_pure(expr->pointer_offset_expr.offset); case EXPR_COMPILER_CONST: diff --git a/src/compiler/headers.c b/src/compiler/headers.c index f90751c9d..b2d389425 100644 --- a/src/compiler/headers.c +++ b/src/compiler/headers.c @@ -47,6 +47,8 @@ static void header_print_type(FILE *file, Type *type) { case CT_TYPES: case TYPE_OPTIONAL: + case TYPE_PROTOCOL: + case TYPE_ANY: UNREACHABLE case TYPE_VOID: OUTPUT("void"); @@ -133,7 +135,8 @@ static void header_print_type(FILE *file, Type *type) header_print_type(file, type->array.base); OUTPUT(" arr[%d]; }", type->array.len); return; - case TYPE_ANY: + case TYPE_ANYPTR: + case TYPE_PROPTR: OUTPUT("c3any_t"); return; case TYPE_SUBARRAY: @@ -311,6 +314,7 @@ static void header_gen_type_decl(FILE *file, int indent, Decl *decl) return; case DECL_TYPEDEF: case DECL_DISTINCT: + case DECL_PROTOCOL: // Ignore return; case DECL_STRUCT: @@ -358,26 +362,28 @@ static void header_gen_maybe_generate_type(FILE *file, HTable *table, Type *type type = type_flatten(type); switch (type->type_kind) { + case FLATTENED_TYPES: case TYPE_POISONED: - case TYPE_TYPEDEF: - case TYPE_DISTINCT: case TYPE_INFERRED_ARRAY: case TYPE_UNTYPED_LIST: case TYPE_TYPEINFO: case TYPE_MEMBER: case TYPE_INFERRED_VECTOR: case TYPE_WILDCARD: + case TYPE_PROTOCOL: + case TYPE_ANY: UNREACHABLE case TYPE_VOID: case TYPE_BOOL: case ALL_FLOATS: case ALL_INTS: - case TYPE_ANY: case TYPE_ANYFAULT: case TYPE_TYPEID: case TYPE_BITSTRUCT: case TYPE_FAULTTYPE: case TYPE_SUBARRAY: + case TYPE_ANYPTR: + case TYPE_PROPTR: return; case TYPE_POINTER: type = type->pointer; @@ -442,10 +448,6 @@ static void header_gen_maybe_generate_type(FILE *file, HTable *table, Type *type case TYPE_FLEXIBLE_ARRAY: type = type->array.base; goto RETRY; - case TYPE_OPTIONAL: - type = type->optional; - goto RETRY; - break; case TYPE_VECTOR: if (htable_get(table, type)) return; OUTPUT("typedef "); diff --git a/src/compiler/json_output.c b/src/compiler/json_output.c index 8f2af292a..1e5e99f44 100644 --- a/src/compiler/json_output.c +++ b/src/compiler/json_output.c @@ -52,6 +52,7 @@ static inline const char *decl_type_to_string(Decl *type) case DECL_GLOBALS: return "global"; case DECL_IMPORT: return "import"; case DECL_MACRO: return "macro"; + case DECL_PROTOCOL: return "protocol"; case DECL_STRUCT: return "struct"; case DECL_UNION: return "union"; case DECL_TYPEDEF: return "typedef"; diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index d3fc2cfb3..cb3e1f236 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -824,6 +824,8 @@ static void llvm_emit_type_decls(GenContext *context, Decl *decl) case DECL_FUNC: // Never directly invoked. UNREACHABLE + case DECL_PROTOCOL: + break; case DECL_DISTINCT: case DECL_STRUCT: case DECL_UNION: @@ -1078,7 +1080,7 @@ LLVMValueRef llvm_get_ref(GenContext *c, Decl *decl) } return decl->backend_ref; case DECL_FUNC: - if (decl->func_decl.attr_interface) + if (decl->func_decl.attr_protocol_method) { size_t name_len = strlen(decl->name); LLVMTypeRef char_array_type = LLVMArrayType(c->byte_type, name_len + 1); @@ -1130,6 +1132,7 @@ LLVMValueRef llvm_get_ref(GenContext *c, Decl *decl) case DECL_CT_EXEC: case DECL_CT_INCLUDE: case DECL_GLOBALS: + case DECL_PROTOCOL: UNREACHABLE; } UNREACHABLE diff --git a/src/compiler/llvm_codegen_builtins.c b/src/compiler/llvm_codegen_builtins.c index ab99dafe4..2324fc8e2 100644 --- a/src/compiler/llvm_codegen_builtins.c +++ b/src/compiler/llvm_codegen_builtins.c @@ -757,6 +757,30 @@ static void llvm_emit_veccomp(GenContext *c, BEValue *value, Expr *expr, Builtin return; } + +static inline void llvm_emit_any_make(GenContext *c, BEValue *value, Expr *expr) +{ + Expr **args = expr->call_expr.arguments; + Expr *typeid = args[1]; + if (expr_is_const(typeid) && typeid->const_expr.typeid == type_void) + { + llvm_value_set(value, llvm_get_zero(c, type_anyptr), type_anyptr); + return; + } + BEValue ptr; + llvm_emit_expr(c, &ptr, args[0]); + llvm_value_rvalue(c, &ptr); + BEValue typeid_value; + llvm_emit_expr(c, &typeid_value, typeid); + llvm_value_rvalue(c, &typeid_value); + LLVMValueRef var = llvm_get_undef(c, type_anyptr); + var = llvm_emit_insert_value(c, var, ptr.value, 0); + var = llvm_emit_insert_value(c, var, typeid_value.value, 1); + assert(!LLVMIsConstant(ptr.value) || !LLVMIsConstant(typeid_value.value) || LLVMIsConstant(var)); + llvm_value_set(value, var, type_anyptr); +} + + void llvm_emit_builtin_call(GenContext *c, BEValue *result_value, Expr *expr) { BuiltinFunction func = exprptr(expr->call_expr.function)->builtin_expr.builtin; @@ -764,6 +788,9 @@ void llvm_emit_builtin_call(GenContext *c, BEValue *result_value, Expr *expr) LLVMValueRef val = NULL; switch (func) { + case BUILTIN_ANY_MAKE: + llvm_emit_any_make(c, result_value, expr); + return; case BUILTIN_UNREACHABLE: llvm_emit_unreachable_stmt(c, result_value, expr); return; diff --git a/src/compiler/llvm_codegen_debug_info.c b/src/compiler/llvm_codegen_debug_info.c index 0d1a269ff..ccfb4f2dc 100644 --- a/src/compiler/llvm_codegen_debug_info.c +++ b/src/compiler/llvm_codegen_debug_info.c @@ -554,6 +554,8 @@ static inline LLVMMetadataRef llvm_get_debug_type_internal(GenContext *c, Type * switch (type->type_kind) { case CT_TYPES: + case TYPE_PROTOCOL: + case TYPE_ANY: UNREACHABLE case TYPE_BITSTRUCT: case TYPE_OPTIONAL: @@ -607,7 +609,8 @@ static inline LLVMMetadataRef llvm_get_debug_type_internal(GenContext *c, Type * return type->backend_debug_type = llvm_debug_subarray_type(c, type); case TYPE_ANYFAULT: return type->backend_debug_type = llvm_debug_errunion_type(c, type); - case TYPE_ANY: + case TYPE_PROPTR: + case TYPE_ANYPTR: return type->backend_debug_type = llvm_debug_any_type(c, type); } UNREACHABLE diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index b39ea17c3..b3bb8c870 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -30,7 +30,6 @@ static inline void llvm_emit_pre_inc_dec(GenContext *c, BEValue *value, Expr *ex static inline void llvm_emit_return_block(GenContext *c, BEValue *be_value, Type *type, AstId current, BlockExit **block_exit, Stacktrace *old_stack_trace); static inline void llvm_emit_subscript_addr_with_base(GenContext *c, BEValue *result, BEValue *parent, BEValue *index, SourceSpan loc); static inline void llvm_emit_try_unwrap(GenContext *c, BEValue *value, Expr *expr); -static inline void llvm_emit_any(GenContext *c, BEValue *value, Expr *expr); static inline void llvm_emit_vector_initializer_list(GenContext *c, BEValue *value, Expr *expr); static inline void llvm_extract_bitvalue_from_array(GenContext *c, BEValue *be_value, Decl *member, Decl *parent_decl); static inline void llvm_emit_type_from_any(GenContext *c, BEValue *be_value); @@ -3759,6 +3758,7 @@ void llvm_emit_lhs_is_subtype(GenContext *c, BEValue *result, BEValue *lhs, BEVa void llvm_emit_comp(GenContext *c, BEValue *result, BEValue *lhs, BEValue *rhs, BinaryOp binary_op) { + assert(type_lowering(lhs->type) == lhs->type); assert(binary_op >= BINARYOP_GT && binary_op <= BINARYOP_EQ); switch (lhs->type->type_kind) { @@ -3781,10 +3781,12 @@ void llvm_emit_comp(GenContext *c, BEValue *result, BEValue *lhs, BEValue *rhs, return; case TYPE_FUNC: break; - case TYPE_ANY: + case TYPE_ANYPTR: llvm_emit_any_comparison(c, result, lhs, rhs, binary_op); return; case LOWERED_TYPES: + case TYPE_ANY: + case TYPE_PROTOCOL: case TYPE_STRUCT: case TYPE_UNION: case TYPE_FLEXIBLE_ARRAY: @@ -4893,6 +4895,8 @@ static void llvm_expand_type_to_args(GenContext *context, Type *param_type, LLVM case LOWERED_TYPES: case TYPE_VOID: case TYPE_FUNC: + case TYPE_ANY: + case TYPE_PROTOCOL: case TYPE_FLEXIBLE_ARRAY: UNREACHABLE break; @@ -4915,7 +4919,7 @@ static void llvm_expand_type_to_args(GenContext *context, Type *param_type, LLVM case TYPE_UNION: case TYPE_SUBARRAY: case TYPE_VECTOR: - case TYPE_ANY: + case TYPE_ANYPTR: TODO break; } @@ -6518,31 +6522,12 @@ void llvm_emit_any_from_value(GenContext *c, BEValue *value, Type *type) BEValue typeid; llvm_emit_typeid(c, &typeid, type); llvm_value_rvalue(c, &typeid); - LLVMValueRef var = llvm_get_undef(c, type_any); + LLVMValueRef var = llvm_get_undef(c, type_anyptr); var = llvm_emit_insert_value(c, var, value->value, 0); var = llvm_emit_insert_value(c, var, typeid.value, 1); - llvm_value_set(value, var, type_any); + llvm_value_set(value, var, type_anyptr); } -static inline void llvm_emit_any(GenContext *c, BEValue *value, Expr *expr) -{ - if (!expr->any_expr.ptr && !expr->any_expr.type_id) - { - llvm_value_set(value, llvm_get_zero(c, type_any), type_any); - return; - } - BEValue ptr; - llvm_emit_exprid(c, &ptr, expr->any_expr.ptr); - llvm_value_rvalue(c, &ptr); - BEValue typeid; - llvm_emit_exprid(c, &typeid, expr->any_expr.type_id); - llvm_value_rvalue(c, &typeid); - LLVMValueRef var = llvm_get_undef(c, type_any); - var = llvm_emit_insert_value(c, var, ptr.value, 0); - var = llvm_emit_insert_value(c, var, typeid.value, 1); - assert(!LLVMIsConstant(ptr.value) || !LLVMIsConstant(typeid.value) || LLVMIsConstant(var)); - llvm_value_set(value, var, type_any); -} static inline void llvm_emit_type_from_any(GenContext *c, BEValue *be_value) { @@ -6551,7 +6536,7 @@ static inline void llvm_emit_type_from_any(GenContext *c, BEValue *be_value) AlignSize alignment = 0; LLVMValueRef pointer_addr = llvm_emit_struct_gep_raw(c, be_value->value, - llvm_get_type(c, type_any), + llvm_get_type(c, type_anyptr), 1, be_value->alignment, &alignment); @@ -6785,9 +6770,6 @@ void llvm_emit_expr(GenContext *c, BEValue *value, Expr *expr) case EXPR_RETVAL: *value = c->retval; return; - case EXPR_ANY: - llvm_emit_any(c, value, expr); - return; case EXPR_TRY_UNWRAP_CHAIN: llvm_emit_try_unwrap_chain(c, value, expr); return; diff --git a/src/compiler/llvm_codegen_function.c b/src/compiler/llvm_codegen_function.c index d4f06180e..fadfa2ba6 100644 --- a/src/compiler/llvm_codegen_function.c +++ b/src/compiler/llvm_codegen_function.c @@ -411,7 +411,7 @@ void llvm_emit_return_implicit(GenContext *c) void llvm_emit_function_body(GenContext *c, Decl *decl, StacktraceType type) { DEBUG_LOG("Generating function %s.", decl->extname); - if (decl->func_decl.attr_dynamic) vec_add(c->dynamic_functions, decl); + if (decl->func_decl.is_dynamic) vec_add(c->dynamic_functions, decl); assert(decl->backend_ref); if (decl->func_decl.attr_init || decl->func_decl.attr_finalizer) { @@ -692,7 +692,7 @@ void llvm_emit_dynamic_functions(GenContext *c, Decl **funcs) scratch_buffer_append("$ct.dyn."); scratch_buffer_append(decl_get_extname(decl)); LLVMValueRef global = llvm_add_global_raw(c, scratch_buffer_to_string(), c->dtable_type, 0); - Decl *proto = declptr(decl->func_decl.any_prototype); + Decl *proto = declptr(decl->func_decl.protocol_method); LLVMValueRef proto_ref = llvm_get_ref(c, proto); LLVMValueRef vals[3] = { llvm_get_ref(c, decl), proto_ref, LLVMConstNull(c->ptr_type) }; LLVMSetInitializer(global, LLVMConstNamedStruct(c->dtable_type, vals, 3)); diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index 0ba372e37..3ceacef82 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -1342,8 +1342,8 @@ void llvm_emit_panic(GenContext *c, const char *message, SourceSpan loc, const c if (panicf) { unsigned elements = vec_size(varargs); - Type *any_subarray = type_get_subarray(type_any); - Type *any_array = type_get_array(type_any, elements); + Type *any_subarray = type_get_subarray(type_anyptr); + Type *any_array = type_get_array(type_anyptr, elements); LLVMTypeRef llvm_array_type = llvm_get_type(c, any_array); AlignSize alignment = type_alloca_alignment(any_array); LLVMValueRef array_ref = llvm_emit_alloca(c, llvm_array_type, alignment, varargslots_name); diff --git a/src/compiler/llvm_codegen_type.c b/src/compiler/llvm_codegen_type.c index 0f224dd7c..9980a5115 100644 --- a/src/compiler/llvm_codegen_type.c +++ b/src/compiler/llvm_codegen_type.c @@ -17,6 +17,7 @@ static inline LLVMTypeRef llvm_type_from_decl(GenContext *c, Decl *decl) case DECL_ERASED: case NON_TYPE_DECLS: case DECL_FNTYPE: + case DECL_PROTOCOL: UNREACHABLE case DECL_BITSTRUCT: return llvm_get_type(c, decl->bitstruct.base_type->type); @@ -314,6 +315,9 @@ LLVMTypeRef llvm_get_type(GenContext *c, Type *any_type) case LOWERED_TYPES: // If this is reachable, then we're not doing the proper lowering. UNREACHABLE + case TYPE_ANY: + case TYPE_PROTOCOL: + UNREACHABLE case TYPE_STRUCT: case TYPE_UNION: return any_type->backend_type = llvm_type_from_decl(c, any_type->decl); @@ -349,7 +353,7 @@ LLVMTypeRef llvm_get_type(GenContext *c, Type *any_type) LLVMStructSetBody(array_type, types, 2, false); return any_type->backend_type = array_type; } - case TYPE_ANY: + case TYPE_ANYPTR: { LLVMTypeRef virtual_type = LLVMStructCreateNamed(c->context, any_type->name); LLVMTypeRef types[2] = { c->ptr_type, c->typeid_type }; @@ -638,6 +642,10 @@ LLVMValueRef llvm_get_typeid(GenContext *c, Type *type) return llvm_generate_introspection_global(c, NULL, type, INTROSPECT_TYPE_ARRAY, type->array.base, type->array.len, NULL, false); case TYPE_SUBARRAY: return llvm_generate_introspection_global(c, NULL, type, INTROSPECT_TYPE_SUBARRAY, type->array.base, 0, NULL, false); + case TYPE_ANYPTR: + return llvm_generate_introspection_global(c, NULL, type, INTROSPECT_TYPE_ANY, NULL, 0, NULL, false); + case TYPE_PROPTR: + return llvm_generate_introspection_global(c, NULL, type, INTROSPECT_TYPE_PROTOCOL, NULL, 0, NULL, false); case TYPE_POINTER: return llvm_generate_introspection_global(c, NULL, type, INTROSPECT_TYPE_POINTER, type->pointer, 0, NULL, false); case TYPE_DISTINCT: @@ -664,6 +672,8 @@ LLVMValueRef llvm_get_typeid(GenContext *c, Type *type) case TYPE_TYPEDEF: return llvm_get_typeid(c, type->canonical); case CT_TYPES: + case TYPE_ANY: + case TYPE_PROTOCOL: UNREACHABLE case TYPE_VOID: return llvm_get_introspection_for_builtin_type(c, type, INTROSPECT_TYPE_VOID, 0); @@ -684,8 +694,6 @@ LLVMValueRef llvm_get_typeid(GenContext *c, Type *type) type_kind_bitsize(type->type_kind)); case TYPE_ANYFAULT: return llvm_get_introspection_for_builtin_type(c, type, INTROSPECT_TYPE_ANYFAULT, 0); - case TYPE_ANY: - return llvm_get_introspection_for_builtin_type(c, type, INTROSPECT_TYPE_ANY, 0); case TYPE_TYPEID: return llvm_get_introspection_for_builtin_type(c, type, INTROSPECT_TYPE_TYPEID, 0); } diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index fb6284ae8..863e9326c 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -1285,7 +1285,7 @@ bool parse_parameters(ParseContext *c, Decl ***params_ref, Decl **body_params, // This is "foo..." *variadic = VARIADIC_ANY; // We generate the type as type_any - type = type_info_new_base(type_any, c->span); + type = type_info_new_base(type_anyptr, c->span); } break; case TOKEN_CT_IDENT: @@ -1612,6 +1612,45 @@ static inline bool parse_bitstruct_body(ParseContext *c, Decl *decl) decl->bitstruct.consecutive = is_consecutive; return true; } + +INLINE bool parse_protocol_body(ParseContext *c, Decl *protocol) +{ + CONSUME_OR_RET(TOKEN_LBRACE, false); + Decl **fns = NULL; + while (!try_consume(c, TOKEN_RBRACE)) + { + AstId contracts = 0; + if (!parse_contracts(c, &contracts)) return poisoned_decl; + ASSIGN_DECL_OR_RET(Decl *protocol_fn, parse_func_definition(c, contracts, true), false); + vec_add(fns, protocol_fn); + } + protocol->protocol_decl.protocol_methods = fns; + return true; +} +/** + * protocol_declaration ::= 'protocol' TYPE_IDENT ':' (TYPE_IDENT (',' TYPE_IDENT) protocol_body + */ +static inline Decl *parse_protocol_declaration(ParseContext *c) +{ + advance_and_verify(c, TOKEN_PROTOCOL); + Decl *decl = decl_new_with_type(symstr(c), c->span, DECL_PROTOCOL); + if (!consume_type_name(c, "protocol")) return poisoned_decl; + const char **parents = NULL; + if (try_consume(c, TOKEN_COLON)) + { + do + { + vec_add(parents, symstr(c)); + if (!try_consume(c, TOKEN_TYPE_IDENT)) + { + RETURN_SEMA_ERROR_HERE("A protocol name was expected here."); + } + } while (try_consume(c, TOKEN_COMMA)); + } + decl->protocol_decl.parents = parents; + if (!parse_protocol_body(c, decl)) return poisoned_decl; + return decl; +} /** * bitstruct_declaration ::= 'bitstruct' TYPE_IDENT ':' type bitstruct_body */ @@ -1792,6 +1831,7 @@ static inline Decl *parse_def_type(ParseContext *c) decl->is_substruct = is_inline; TypedefDecl typedef_decl = decl->typedef_decl; // Ensure value semantics. decl->distinct_decl.typedef_decl = typedef_decl; + decl->protocols = NULL; decl->methods = NULL; decl->type->type_kind = TYPE_DISTINCT; decl->decl_kind = DECL_DISTINCT; @@ -2254,7 +2294,11 @@ static inline Decl *parse_func_definition(ParseContext *c, AstId contracts, bool } if (!parse_fn_parameter_list(c, &(func->func_decl.signature), is_interface)) return poisoned_decl; if (!parse_attributes_for_global(c, func)) return poisoned_decl; - + if (try_consume(c, TOKEN_COLON)) + { + ASSIGN_TYPEID_OR_RET(func->func_decl.protocol_unresolved, parse_type(c), poisoned_decl); + func->func_decl.is_dynamic = true; + } if (is_interface) { if (tok_is(c, TOKEN_LBRACE) || tok_is(c, TOKEN_IMPLIES)) @@ -2641,6 +2685,7 @@ static Decl *parse_exec(ParseContext *c) * | global_declaration | macro_declaration | func_definition | typedef_declaration * | conditional_compilation | define_declaration | import_declaration | module_declaration * | static_declaration | ct_assert_declaration | ct_echo_declaration | bitstruct_declaration + * | protocol_declaration * * @return Decl* or a poison value if parsing failed */ @@ -2757,6 +2802,10 @@ Decl *parse_top_level_statement(ParseContext *c, ParseContext **c_ref) if (contracts) goto CONTRACT_NOT_ALLOWED; decl = parse_bitstruct_declaration(c); break; + case TOKEN_PROTOCOL: + if (contracts) goto CONTRACT_NOT_ALLOWED; + decl = parse_protocol_declaration(c); + break; case TOKEN_CONST: if (contracts) goto CONTRACT_NOT_ALLOWED; decl = parse_top_level_const_declaration(c); diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index 558958870..452a01c97 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -1332,6 +1332,7 @@ Ast *parse_stmt(ParseContext *c) case TOKEN_CT_INCLUDE: case TOKEN_CT_EXEC: case TOKEN_LGENPAR: + case TOKEN_PROTOCOL: SEMA_ERROR_HERE("Unexpected '%s' found when expecting a statement.", token_type_to_string(c->tok)); advance(c); diff --git a/src/compiler/sema_builtins.c b/src/compiler/sema_builtins.c index b4adea753..a0583625f 100644 --- a/src/compiler/sema_builtins.c +++ b/src/compiler/sema_builtins.c @@ -24,6 +24,7 @@ typedef enum BA_NUMVEC, BA_PTRVEC, BA_NUM, + BA_TYPEID, } BuiltinArg; static bool sema_check_builtin_args_match(Expr **args, size_t arg_len); @@ -111,6 +112,9 @@ static bool sema_check_builtin_args(Expr **args, BuiltinArg *arg_type, size_t ar case BA_NUM: if (type_is_number(type)) continue; RETURN_SEMA_ERROR(arg, "Expected an integer or a float."); + case BA_TYPEID: + if (type == type_typeid) continue; + RETURN_SEMA_ERROR(arg, "Expected a typeid."); case BA_NUMLIKE: if (type_flat_is_numlike(type)) continue; RETURN_SEMA_ERROR(arg, "Expected a number or vector."); @@ -411,6 +415,11 @@ bool sema_expr_analyse_builtin_call(SemaContext *context, Expr *expr) if (!sema_check_builtin_args_match(args, 2)) return false; rtype = args[0]->type->canonical; break; + case BUILTIN_ANY_MAKE: + assert(arg_count == 2); + if (!sema_check_builtin_args(args, (BuiltinArg[]) { BA_POINTER, BA_TYPEID }, 2)) return false; + rtype = type_anyptr; + break; case BUILTIN_EXACT_NEG: assert(arg_count == 1); if (!sema_check_builtin_args(args, (BuiltinArg[]) { BA_INTLIKE }, 1)) return false; @@ -950,6 +959,7 @@ static inline int builtin_expected_args(BuiltinFunction func) case BUILTIN_VECCOMPGT: case BUILTIN_VECCOMPEQ: case BUILTIN_WASM_MEMORY_GROW: + case BUILTIN_ANY_MAKE: return 2; case BUILTIN_EXPECT_WITH_PROBABILITY: case BUILTIN_FMA: diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 74ae01e00..0d4ef3396 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -327,6 +327,9 @@ CastKind cast_to_bool_kind(Type *type) { switch (type_flatten(type)->type_kind) { + case FLATTENED_TYPES: + // These are not possible due to flattening. + UNREACHABLE case TYPE_WILDCARD: case TYPE_BOOL: return CAST_BOOLBOOL; @@ -341,10 +344,9 @@ CastKind cast_to_bool_kind(Type *type) return CAST_FPBOOL; case TYPE_POINTER: return CAST_PTRBOOL; - case TYPE_ENUM: - case FLATTENED_TYPES: - // These are not possible due to flattening. - UNREACHABLE + case TYPE_ANYPTR: + case TYPE_PROPTR: + return CAST_ANYBOOL; case TYPE_INFERRED_ARRAY: case TYPE_INFERRED_VECTOR: // These should never be here, type should already be known. @@ -360,9 +362,11 @@ CastKind cast_to_bool_kind(Type *type) case TYPE_VECTOR: case TYPE_BITSTRUCT: case TYPE_UNTYPED_LIST: - case TYPE_ANY: case TYPE_FLEXIBLE_ARRAY: + case TYPE_ENUM: case TYPE_MEMBER: + case TYPE_ANY: + case TYPE_PROTOCOL: // Everything else is an error return CAST_ERROR; } @@ -1889,53 +1893,55 @@ static void cast_typeid_to_bool(Expr *expr, Type *to_type) #define RPTFE &rule_ptr_to_infer /* Ptr -> infer (if pointee may infer) */ CastRule cast_rules[CONV_LAST + 1][CONV_LAST + 1] = { -// void, wildc, bool, int, float, ptr, sarr, vec, bitst, distc, array, strct, union, any, fault, enum, typid, afaul, voidp, arrpt, infer (to) - {_NA__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // VOID (from) - {ROKOK, _NA__, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, _NO__}, // WILDCARD - {REXPL, _NO__, _NA__, REXPL, REXPL, _NO__, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // BOOL - {REXPL, _NO__, REXPL, RIFIF, RINFL, RINPT, _NO__, ROKOK, RINBS, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, RINEN, _NO__, _NO__, RINPT, RINPT, _NO__}, // INT - {REXPL, _NO__, REXPL, REXPL, RIFIF, _NO__, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // FLOAT - {REXPL, _NO__, REXPL, RPTIN, _NO__, RPTPT, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, ROKOK, _NO__, _NO__, _NO__, _NO__, ROKOK, RPTPT, RPTFE}, // PTR - {REXPL, _NO__, REXPL, _NO__, _NO__, RSAPT, RSASA, RSAVA, _NO__, RXXDI, RSAVA, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, ROKOK, RSAPT, RSAFE}, // SARRAY - {REXPL, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RVCVC, _NO__, RXXDI, RVCAR, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RVAFE}, // VECTOR - {REXPL, _NO__, _NO__, RBSIN, _NO__, _NO__, _NO__, _NO__, _NO__, RXXDI, RBSAR, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // BITSTRUCT - {REXPL, _NO__, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX}, // DISTINCT - {REXPL, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RARVC, RARBS, RXXDI, RARAR, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RVAFE}, // ARRAY - {REXPL, _NO__, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTDI, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, _NO__}, // STRUCT - {REXPL, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // UNION - {REXPL, _NO__, REXPL, _NO__, _NO__, REXPL, _NO__, _NO__, _NO__, RXXDI, _NO__, _NO__, _NO__, _NA__, _NO__, _NO__, _NO__, _NO__, REXPL, REXPL, _NO__}, // ANY - {REXPL, _NO__, REXPL, RPTIN, _NO__, REXPL, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, ROKOK, REXPL, REXPL, _NO__}, // FAULT - {REXPL, _NO__, _NO__, REXPL, _NO__, _NO__, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // ENUM - {REXPL, _NO__, REXPL, RPTIN, _NO__, REXPL, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NA__, _NO__, REXPL, REXPL, _NO__}, // TYPEID - {REXPL, _NO__, REXPL, RPTIN, _NO__, REXPL, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, REXPL, _NO__, _NO__, _NA__, REXPL, REXPL, _NO__}, // ANYFAULT - {REXPL, _NO__, REXPL, RPTIN, _NO__, ROKOK, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, ROKOK, _NO__, _NO__, _NO__, _NO__, _NA__, ROKOK, _NO__}, // VOIDPTR - {REXPL, _NO__, REXPL, RPTIN, _NO__, RPTPT, RAPSA, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, ROKOK, _NO__, _NO__, _NO__, _NO__, ROKOK, RPTPT, RPTFE}, // ARRPTR - {_NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // INFERRED +// void, wildc, bool, int, float, ptr, sarr, vec, bitst, distc, array, strct, union, any, prot, fault, enum, typid, afaul, voidp, arrpt, infer (to) + {_NA__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // VOID (from) + {ROKOK, _NA__, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, ROKOK, _NO__}, // WILDCARD + {REXPL, _NO__, _NA__, REXPL, REXPL, _NO__, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // BOOL + {REXPL, _NO__, REXPL, RIFIF, RINFL, RINPT, _NO__, ROKOK, RINBS, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RINEN, _NO__, _NO__, RINPT, RINPT, _NO__}, // INT + {REXPL, _NO__, REXPL, REXPL, RIFIF, _NO__, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // FLOAT + {REXPL, _NO__, REXPL, RPTIN, _NO__, RPTPT, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, ROKOK, ROKOK, _NO__, _NO__, _NO__, _NO__, ROKOK, RPTPT, RPTFE}, // PTR + {REXPL, _NO__, REXPL, _NO__, _NO__, RSAPT, RSASA, RSAVA, _NO__, RXXDI, RSAVA, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, ROKOK, RSAPT, RSAFE}, // SARRAY + {REXPL, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RVCVC, _NO__, RXXDI, RVCAR, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RVAFE}, // VECTOR + {REXPL, _NO__, _NO__, RBSIN, _NO__, _NO__, _NO__, _NO__, _NO__, RXXDI, RBSAR, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // BITSTRUCT + {REXPL, _NO__, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX, RDIXX}, // DISTINCT + {REXPL, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RARVC, RARBS, RXXDI, RARAR, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RVAFE}, // ARRAY + {REXPL, _NO__, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTDI, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, RSTST, _NO__}, // STRUCT + {REXPL, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // UNION + {REXPL, _NO__, REXPL, _NO__, _NO__, REXPL, _NO__, _NO__, _NO__, RXXDI, _NO__, _NO__, _NO__, _NA__, ROKOK, _NO__, _NO__, _NO__, _NO__, REXPL, REXPL, _NO__}, // ANY + {REXPL, _NO__, REXPL, _NO__, _NO__, REXPL, _NO__, _NO__, _NO__, RXXDI, _NO__, _NO__, _NO__, ROKOK, _NA__, _NO__, _NO__, _NO__, _NO__, REXPL, REXPL, _NO__}, // PROTOCOL + {REXPL, _NO__, REXPL, RPTIN, _NO__, REXPL, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, ROKOK, REXPL, REXPL, _NO__}, // FAULT + {REXPL, _NO__, _NO__, REXPL, _NO__, _NO__, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // ENUM + {REXPL, _NO__, REXPL, RPTIN, _NO__, REXPL, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NA__, _NO__, REXPL, REXPL, _NO__}, // TYPEID + {REXPL, _NO__, REXPL, RPTIN, _NO__, REXPL, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, _NO__, _NO__, REXPL, _NO__, _NO__, _NA__, REXPL, REXPL, _NO__}, // ANYFAULT + {REXPL, _NO__, REXPL, RPTIN, _NO__, ROKOK, _NO__, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, ROKOK, ROKOK, _NO__, _NO__, _NO__, _NO__, _NA__, ROKOK, _NO__}, // VOIDPTR + {REXPL, _NO__, REXPL, RPTIN, _NO__, RPTPT, RAPSA, ROKOK, _NO__, RXXDI, _NO__, _NO__, _NO__, ROKOK, ROKOK, _NO__, _NO__, _NO__, _NO__, ROKOK, RPTPT, RPTFE}, // ARRPTR + {_NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__, _NO__}, // INFERRED }; CastFunction cast_function[CONV_LAST + 1][CONV_LAST + 1] = { -//void, wildcd, bool, int, float, ptr, sarr, vec, bitst, dist, array, struct,union, any, fault, enum, typeid,anyfa, vptr, aptr, ulist, infer(to) - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // VOID (from) - {XX2XX, 0, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, 0, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, 0 }, // WILDCARD - {XX2VO, 0, 0, BO2IN, BO2FP, 0, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // BOOL - {XX2VO, 0, IN2BO, IN2IN, IN2FP, IN2PT, 0, EX2VC, XX2XX, 0, 0, 0, 0, 0, 0, IN2EN, 0, 0, IN2PT, IN2PT, 0 }, // INT - {XX2VO, 0, FP2BO, FP2IN, FP2FP, 0, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // FLOAT - {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, 0, EX2VC, 0, 0, 0, 0, 0, PT2AY, 0, 0, 0, 0, PT2PT, PT2PT, PT2FE }, // PTR - {XX2VO, 0, SA2BO, 0, 0, SA2PT, SA2SA, SA2VA, 0, 0, SA2VA, 0, 0, 0, 0, 0, 0, 0, SA2PT, SA2PT, SA2FE }, // SARRAY - {XX2VO, 0, 0, 0, 0, 0, 0, VC2VC, 0, 0, VC2AR, 0, 0, 0, 0, 0, 0, 0, 0, 0, VA2FE }, // VECTOR - {XX2VO, 0, 0, XX2XX, 0, 0, 0, 0, 0, 0, XX2XX, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // BITSTRUCT - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // DISTINCT - {XX2VO, 0, 0, 0, 0, 0, 0, AR2VC, XX2XX, 0, AR2AR, 0, 0, 0, 0, 0, 0, 0, 0, 0, VA2FE }, // ARRAY - {XX2VO, 0, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, 0, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, 0 }, // STRUCT - {XX2VO, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // UNION - {XX2VO, 0, AY2BO, 0, 0, AY2PT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, AY2PT, AY2PT, 0 }, // ANY - {XX2VO, 0, AF2BO, FA2IN, 0, FA2PT, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, FA2AF, FA2PT, FA2PT, 0 }, // FAULT - {XX2VO, 0, 0, EN2IN, 0, 0, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // ENUM - {XX2VO, 0, TI2BO, TI2IN, 0, TI2PT, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TI2PT, TI2PT, 0 }, // TYPEID - {XX2VO, 0, AF2BO, FA2IN, 0, FA2IN, 0, EX2VC, 0, 0, 0, 0, 0, 0, AF2FA, 0, 0, 0, FA2IN, FA2IN, 0 }, // ANYFAULT - {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, 0, EX2VC, 0, 0, 0, 0, 0, PT2AY, 0, 0, 0, 0, 0, PT2PT, 0 }, // VOIDPTR - {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, AP2SA, EX2VC, 0, 0, 0, 0, 0, PT2AY, 0, 0, 0, 0, PT2PT, PT2PT, PT2FE }, // ARRAYPTR - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INFERRED +//void, wildcd, bool, int, float, ptr, sarr, vec, bitst, dist, array, struct,union, any, prot, fault, enum, typeid,anyfa, vptr, aptr, ulist, infer(to) + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // VOID (from) + {XX2XX, 0, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, 0, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, XX2XX, 0 }, // WILDCARD + {XX2VO, 0, 0, BO2IN, BO2FP, 0, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // BOOL + {XX2VO, 0, IN2BO, IN2IN, IN2FP, IN2PT, 0, EX2VC, XX2XX, 0, 0, 0, 0, 0, 0, 0, IN2EN, 0, 0, IN2PT, IN2PT, 0 }, // INT + {XX2VO, 0, FP2BO, FP2IN, FP2FP, 0, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // FLOAT + {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, 0, EX2VC, 0, 0, 0, 0, 0, PT2AY, PT2AY, 0, 0, 0, 0, PT2PT, PT2PT, PT2FE }, // PTR + {XX2VO, 0, SA2BO, 0, 0, SA2PT, SA2SA, SA2VA, 0, 0, SA2VA, 0, 0, 0, 0, 0, 0, 0, 0, SA2PT, SA2PT, SA2FE }, // SARRAY + {XX2VO, 0, 0, 0, 0, 0, 0, VC2VC, 0, 0, VC2AR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VA2FE }, // VECTOR + {XX2VO, 0, 0, XX2XX, 0, 0, 0, 0, 0, 0, XX2XX, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // BITSTRUCT + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // DISTINCT + {XX2VO, 0, 0, 0, 0, 0, 0, AR2VC, XX2XX, 0, AR2AR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VA2FE }, // ARRAY + {XX2VO, 0, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, 0, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, ST2LN, 0 }, // STRUCT + {XX2VO, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // UNION + {XX2VO, 0, AY2BO, 0, 0, AY2PT, 0, 0, 0, 0, 0, 0, 0, PT2PT, PT2PT, 0, 0, 0, 0, AY2PT, AY2PT, 0 }, // ANY + {XX2VO, 0, AY2BO, 0, 0, AY2PT, 0, 0, 0, 0, 0, 0, 0, PT2PT, PT2PT, 0, 0, 0, 0, AY2PT, AY2PT, 0 }, // PROTOCOL + {XX2VO, 0, AF2BO, FA2IN, 0, FA2PT, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FA2AF, FA2PT, FA2PT, 0 }, // FAULT + {XX2VO, 0, 0, EN2IN, 0, 0, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // ENUM + {XX2VO, 0, TI2BO, TI2IN, 0, TI2PT, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TI2PT, TI2PT, 0 }, // TYPEID + {XX2VO, 0, AF2BO, FA2IN, 0, FA2IN, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, AF2FA, 0, 0, 0, FA2IN, FA2IN, 0 }, // ANYFAULT + {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, 0, EX2VC, 0, 0, 0, 0, 0, PT2AY, PT2AY, 0, 0, 0, 0, 0, PT2PT, 0 }, // VOIDPTR + {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, AP2SA, EX2VC, 0, 0, 0, 0, 0, PT2AY, PT2AY, 0, 0, 0, 0, PT2PT, PT2PT, PT2FE }, // ARRAYPTR + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INFERRED }; static ConvGroup group_from_type[TYPE_LAST + 1] = { @@ -1957,7 +1963,8 @@ static ConvGroup group_from_type[TYPE_LAST + 1] = { [TYPE_F32] = CONV_FLOAT, [TYPE_F64] = CONV_FLOAT, [TYPE_F128] = CONV_FLOAT, - [TYPE_ANY] = CONV_ANY, + [TYPE_ANY] = CONV_NO, + [TYPE_PROTOCOL] = CONV_NO, [TYPE_ANYFAULT] = CONV_ANYFAULT, [TYPE_TYPEID] = CONV_TYPEID, [TYPE_POINTER] = CONV_POINTER, @@ -1970,6 +1977,8 @@ static ConvGroup group_from_type[TYPE_LAST + 1] = { [TYPE_TYPEDEF] = CONV_NO, [TYPE_DISTINCT] = CONV_DISTINCT, [TYPE_ARRAY] = CONV_ARRAY, + [TYPE_PROPTR] = CONV_PROTOCOL, + [TYPE_ANYPTR] = CONV_ANY, [TYPE_SUBARRAY] = CONV_SUBARRAY, [TYPE_FLEXIBLE_ARRAY] = CONV_NO, [TYPE_INFERRED_ARRAY] = CONV_NO, diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 9bfda393a..15545b587 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -5,7 +5,7 @@ #include "sema_internal.h" -static inline bool sema_analyse_func_macro(SemaContext *context, Decl *decl, bool is_func, bool *erase_decl); +static inline bool sema_analyse_func_macro(SemaContext *context, Decl *decl, AttributeDomain domain, bool *erase_decl); static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *erase_decl); static inline bool sema_analyse_macro(SemaContext *context, Decl *decl, bool *erase_decl); static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, TypeInfoId type_parent); @@ -13,7 +13,7 @@ static inline bool sema_analyse_main_function(SemaContext *context, Decl *decl); static inline bool sema_check_param_uniqueness_and_type(Decl **decls, Decl *current, unsigned current_index, unsigned count); static inline bool sema_analyse_method(SemaContext *context, Decl *decl); -static inline bool sema_is_valid_method_param(SemaContext *context, Decl *param, Type *parent_type, bool is_dynamic, bool is_interface); +static inline bool sema_is_valid_method_param(SemaContext *context, Decl *param, Type *parent_type, bool is_dynamic); static inline bool sema_analyse_macro_method(SemaContext *context, Decl *decl); static inline bool unit_add_base_extension_method(CompilationUnit *unit, Type *parent_type, Decl *method_like); static inline bool unit_add_method_like(CompilationUnit *unit, Type *parent_type, Decl *method_like); @@ -48,7 +48,7 @@ static inline bool sema_analyse_attribute_decl(SemaContext *c, Decl *decl); static inline bool sema_analyse_typedef(SemaContext *context, Decl *decl, bool *erase_decl); bool sema_analyse_decl_type(SemaContext *context, Type *type, SourceSpan span); static inline bool sema_analyse_define(SemaContext *c, Decl *decl, bool *erase_decl); -static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl); +static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl, bool *erase_decl); static CompilationUnit *unit_copy(Module *module, CompilationUnit *unit); static bool sema_analyse_parameterized_define(SemaContext *c, Decl *decl); @@ -184,7 +184,7 @@ static inline bool sema_analyse_struct_member(SemaContext *context, Decl *parent case DECL_VAR: assert(decl->var.kind == VARDECL_MEMBER); decl->resolve_status = RESOLVE_RUNNING; - if (!sema_resolve_type_info_maybe_inferred(context, type_infoptrzero(decl->var.type_info), true)) return decl_poison(decl); + if (!sema_resolve_type_info(context, type_infoptrzero(decl->var.type_info), RESOLVE_TYPE_ALLOW_INFER)) return decl_poison(decl); decl->type = typeget(decl->var.type_info); decl->resolve_status = RESOLVE_DONE; Type *member_type = type_flatten(decl->type); @@ -542,7 +542,7 @@ static inline bool sema_analyse_bitstruct_member(SemaContext *context, Decl *par bool is_consecutive = parent->bitstruct.consecutive; // Resolve the type. - if (!sema_resolve_type_info(context, type_info)) return false; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false; member->type = type_info->type; // Flatten the distinct and enum types. @@ -689,13 +689,70 @@ static inline bool sema_analyse_bitstruct_member(SemaContext *context, Decl *par member->resolve_status = RESOLVE_DONE; return true; } - +static bool sema_analyse_protocol(SemaContext *context, Decl *decl, bool *erase_decl) +{ + if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_INTERFACE, erase_decl)) return decl_poison(decl); + if (*erase_decl) return true; + Decl **functions = decl->protocol_decl.protocol_methods; + unsigned count = vec_size(functions); + for (unsigned i = 0; i < count; i++) + { + RETRY:; + Decl *method = functions[i]; + if (method->decl_kind != DECL_FUNC) + { + SEMA_ERROR(method, "Only functions are allowed here."); + return decl_poison(decl); + } + if (method->func_decl.type_parent) + { + SEMA_ERROR(type_infoptr(method->func_decl.type_parent), "Protocols should not be declared as methods."); + return decl_poison(decl); + } + method->func_decl.attr_protocol_method = true; + bool erase = false; + Decl **params = method->func_decl.signature.params; + if (!vec_size(params)) + { + SEMA_ERROR(method, "A protocol method needs to contain a `&self` argument."); + return decl_poison(decl); + } + Decl *first = params[0]; + if (first->var.type_info || first->var.kind != VARDECL_PARAM_REF) + { + SEMA_ERROR(first, "The first argument must be `&self`."); + return decl_poison(decl); + } + first->type = type_voidptr; + first->var.kind = VARDECL_PARAM; + first->unit = context->unit; + first->resolve_status = RESOLVE_DONE; + first->alignment = type_abi_alignment(type_voidptr); + method->unit = context->unit; + if (!sema_analyse_func(context, method, &erase)) return decl_poison(decl); + if (!method->extname) + { + scratch_buffer_clear(); + type_mangle_introspect_name_to_buffer(decl->type); + scratch_buffer_printf(".%s", method->name); + method->extname = scratch_buffer_copy(); + } + if (erase) + { + vec_erase_ptr_at(functions, i); + count--; + if (i >= count) break; + goto RETRY; + } + } + return true; +} static bool sema_analyse_bitstruct(SemaContext *context, Decl *decl, bool *erase_decl) { if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_BITSTRUCT, erase_decl)) return decl_poison(decl); if (*erase_decl) return true; DEBUG_LOG("Beginning analysis of %s.", decl->name ? decl->name : ".anon"); - if (!sema_resolve_type_info(context, decl->bitstruct.base_type)) return false; + if (!sema_resolve_type_info(context, decl->bitstruct.base_type, RESOLVE_TYPE_DEFAULT)) return false; Type *type = decl->bitstruct.base_type->type->canonical; Type *base_type = type->type_kind == TYPE_ARRAY ? type->array.base : type; if (!type_is_integer(base_type)) @@ -746,7 +803,9 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, if (sig->rtype) { TypeInfo *rtype_info = type_infoptr(sig->rtype); - if (!sema_resolve_type_info_maybe_inferred(context, type_infoptr(sig->rtype), is_macro)) return false; + if (!sema_resolve_type_info(context, type_infoptr(sig->rtype), + is_macro ? RESOLVE_TYPE_ALLOW_INFER + : RESOLVE_TYPE_DEFAULT)) return false; rtype = rtype_info->type; if (sig->attrs.nodiscard) { @@ -783,7 +842,8 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, if (type_parent && params && params[0] && !params[0]->var.type_info) { TypeInfo *method_parent = type_infoptr(type_parent); - if (!sema_resolve_type_info_maybe_inferred(context, method_parent, true)) return false; + if (!sema_resolve_type_info(context, method_parent, + is_macro ? RESOLVE_TYPE_MACRO_METHOD : RESOLVE_TYPE_FUNC_METHOD)) return false; Decl *param = params[0]; Type *inferred_type = NULL; switch (param->var.kind) @@ -798,6 +858,11 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, default: goto CHECK_PARAMS; } + if (type_is_any_raw(inferred_type)) + { + RETURN_SEMA_ERROR(param, "This would infer to %s, which cannot be passed by value. Use '&%s' instead.", + type_quoted_error_string(inferred_type), param->name); + } param->var.type_info = type_info_id_new_base(inferred_type, param->span); } @@ -829,6 +894,11 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, return decl_poison(param); } } + if (i == 0 && param->resolve_status == RESOLVE_DONE) + { + assert(param->type == type_voidptr && "Expected the first parameter of a protocol method."); + continue; + } assert(param->resolve_status == RESOLVE_NOT_DONE && "The param shouldn't have been resolved yet."); param->resolve_status = RESOLVE_RUNNING; @@ -838,13 +908,15 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, TypeInfo *type_info = type_infoptrzero(param->var.type_info); if (type_info) { - if (!sema_resolve_type_info_maybe_inferred(context, type_info, is_macro)) return decl_poison(param); + if (!sema_resolve_type_info(context, type_info, + is_macro ? RESOLVE_TYPE_ALLOW_INFER + : RESOLVE_TYPE_DEFAULT)) return decl_poison(param); param->type = type_info->type; } switch (var_kind) { case VARDECL_PARAM_REF: - if (type_info && !type_is_pointer(param->type)) + if (type_info && !type_is_pointer(param->type) && !type_is_any_protocol_ptr(param->type)) { RETURN_SEMA_ERROR(type_info, "A pointer type was expected for a ref argument, did you mean %s?", type_quoted_error_string(type_get_ptr(param->type))); @@ -949,7 +1021,7 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, } -bool sema_analyse_function_signature(SemaContext *context, Decl *func_decl, CallABI abi, Signature *signature, bool is_real_function) +bool sema_analyse_function_signature(SemaContext *context, Decl *func_decl, CallABI abi, Signature *signature) { // Get param count and variadic type Decl **params = signature->params; @@ -986,15 +1058,15 @@ bool sema_analyse_function_signature(SemaContext *context, Decl *func_decl, Call static inline bool sema_analyse_fntype(SemaContext *context, Decl *decl, bool *erase_decl) { - if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_DEFINE, erase_decl)) return decl_poison(decl); + if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_DEF, erase_decl)) return decl_poison(decl); if (*erase_decl) return true; Signature *sig = &decl->fntype_decl; - return sema_analyse_function_signature(context, decl, sig->abi, sig, false); + return sema_analyse_function_signature(context, decl, sig->abi, sig); } static inline bool sema_analyse_typedef(SemaContext *context, Decl *decl, bool *erase_decl) { - if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_DEFINE, erase_decl)) return decl_poison(decl); + if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_DEF, erase_decl)) return decl_poison(decl); if (*erase_decl) return true; if (decl->typedef_decl.is_func) @@ -1005,15 +1077,18 @@ static inline bool sema_analyse_typedef(SemaContext *context, Decl *decl, bool * decl->type->canonical = type_get_ptr(fn_decl->type); return true; } - if (!sema_resolve_type_info(context, decl->typedef_decl.type_info)) return false; - Type *type = decl->typedef_decl.type_info->type->canonical; - decl->type->canonical = type; + TypeInfo *info = decl->typedef_decl.type_info; + if (!sema_resolve_type_info(context, info, RESOLVE_TYPE_DEFAULT)) return false; + decl->type->canonical = info->type->canonical; // Do we need anything else? return true; } -static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl) +static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl, bool *erase) { + if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_DISTINCT, erase)) return false; + if (*erase) return true; + if (decl->distinct_decl.typedef_decl.is_func) { Decl *fn_decl = decl->distinct_decl.typedef_decl.decl; @@ -1023,7 +1098,7 @@ static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl) return true; } TypeInfo *info = decl->distinct_decl.typedef_decl.type_info; - if (!sema_resolve_type_info(context, info)) return false; + if (!sema_resolve_type_info(context, info, RESOLVE_TYPE_DEFAULT)) return false; if (type_is_optional(info->type)) { SEMA_ERROR(decl, "You cannot create a distinct type from an optional."); @@ -1037,6 +1112,8 @@ static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl) case TYPE_TYPEDEF: case CT_TYPES: case TYPE_FLEXIBLE_ARRAY: + case TYPE_ANY: + case TYPE_PROTOCOL: UNREACHABLE return false; case TYPE_OPTIONAL: @@ -1047,7 +1124,12 @@ static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl) case TYPE_ANYFAULT: SEMA_ERROR(decl, "You cannot create a distinct type from an error union."); return false; - case TYPE_ANY: + case TYPE_PROPTR: + SEMA_ERROR(decl, "You cannot create a distinct type from a protocol pointer."); + return false; + case TYPE_ANYPTR: + SEMA_ERROR(decl, "You cannot create a distinct type from an 'any*'."); + return false; case TYPE_VOID: case TYPE_TYPEID: SEMA_ERROR(decl, "Cannot create a distinct type from %s.", type_quoted_error_string(base)); @@ -1085,7 +1167,7 @@ static inline bool sema_analyse_enum_param(SemaContext *context, Decl *param, bo return false; } TypeInfo *type_info = type_infoptrzero(param->var.type_info); - if (!sema_resolve_type_info(context, type_info)) return false; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false; if (param->var.vararg) { type_info->type = type_get_subarray(type_info->type); @@ -1130,7 +1212,7 @@ static inline bool sema_analyse_enum(SemaContext *context, Decl *decl, bool *era if (*erase_decl) return true; // Resolve the type of the enum. - if (!sema_resolve_type_info(context, decl->enums.type_info)) return false; + if (!sema_resolve_type_info(context, decl->enums.type_info, RESOLVE_TYPE_DEFAULT)) return false; Type *type = decl->enums.type_info->type; assert(!type_is_optional(type) && "Already stopped when parsing."); @@ -1569,26 +1651,125 @@ static inline bool unit_add_method_like(CompilationUnit *unit, Type *parent_type } +static inline Decl *sema_find_protocol_for_method(SemaContext *context, Decl **protocols, Decl *decl) +{ + const char *name = decl->name; + Decl *first_match = NULL; + Decl *first_protocol = NULL; + FOREACH_BEGIN(Decl *proto, protocols) + FOREACH_BEGIN(Decl *method, proto->protocol_decl.protocol_methods) + if (method->name == name) + { + if (first_match) + { + SEMA_ERROR(decl, "Both '%s' and '%s' protocols have a method matching '%s', which prevents it from being implemented.", + first_protocol->name, proto->name, name); + return NULL; + } + first_match = method; + first_protocol = proto; + } + FOREACH_END(); + FOREACH_END(); + if (!first_match) + { + SEMA_ERROR(decl, "No matching implemented protocol has the method '%s'", name); + return NULL; + } + if (!sema_analyse_decl(context, first_protocol)) return NULL; + return first_match; +} + static inline bool sema_analyse_method(SemaContext *context, Decl *decl) { + if (decl->func_decl.attr_init | decl->func_decl.attr_finalizer) + { + SEMA_ERROR(decl, "Methods may not have '@init' or '@finalizer' attributes."); + return decl_poison(decl); + } + if (decl->func_decl.attr_test || decl->func_decl.attr_benchmark) + { + SEMA_ERROR(decl, "Methods may not be annotated %s.", decl->func_decl.attr_test ? "@test" : "@benchmark"); + return decl_poison(decl); + } + TypeInfo *parent_type = type_infoptr(decl->func_decl.type_parent); - if (!sema_resolve_type_info(context, parent_type)) return false; - Type *type = parent_type->type->canonical; + if (!sema_resolve_type_info(context, parent_type, RESOLVE_TYPE_FUNC_METHOD)) return false; + Type *par_type = parent_type->type->canonical; Decl **params = decl->func_decl.signature.params; - bool is_dynamic = decl->func_decl.attr_dynamic; - bool is_interface = decl->func_decl.attr_interface; - if (is_interface && type != type_any) RETURN_SEMA_ERROR(decl, "Only 'any' methods may use '@interface'."); + bool is_dynamic = decl->func_decl.is_dynamic; if (!vec_size(params)) RETURN_SEMA_ERROR(decl, "A method must start with an argument of the type " "it is a method of, e.g. 'fn Foo.test(Foo* foo)'."); - if (!sema_is_valid_method_param(context, params[0], type, is_dynamic, is_interface)) return false; + if (!sema_is_valid_method_param(context, params[0], par_type, is_dynamic)) return false; + if (is_dynamic) { - if (is_interface) RETURN_SEMA_ERROR(decl, "An interface method cannot be '@dynamic'."); - } + TypeInfo *parent = type_infoptr(decl->func_decl.protocol_unresolved); + if (!sema_resolve_type_info(context, parent, RESOLVE_TYPE_ALLOW_ANY)) return false; + Type *protocol = parent->type; + if (protocol->type_kind != TYPE_PROTOCOL) RETURN_SEMA_ERROR(parent, "Expected a protocol not a normal type."); + Decl *proto_decl = protocol->decl; + if (!sema_analyse_decl(context, proto_decl)) return false; + const char *name = decl->name; + Decl *implemented_method = NULL; + FOREACH_BEGIN(Decl *method, proto_decl->protocol_decl.protocol_methods) + if (method->name == name) + { + implemented_method = method; + break; + } + FOREACH_END(); + if (!implemented_method) + { + RETURN_SEMA_ERROR(decl, "No method named '%s' was found in protocol '%s'.", name, proto_decl->name); + } - return unit_add_method_like(context->unit, type, decl); -} + Signature protocol_sig = implemented_method->func_decl.signature; + Signature this_sig = decl->func_decl.signature; + Type *any_rtype = typeget(protocol_sig.rtype); + Type *this_rtype = typeget(this_sig.rtype); + if (any_rtype->canonical != this_rtype->canonical) + { + SEMA_ERROR(type_infoptr(this_sig.rtype), "The prototype method has a return type %s, but this function returns %s, they need to match.", + type_quoted_error_string(any_rtype), type_quoted_error_string(this_rtype)); + SEMA_NOTE(type_infoptr(protocol_sig.rtype), "The interface definition is here."); + return false; + } + Decl **any_params = protocol_sig.params; + Decl **this_params = this_sig.params; + unsigned any_param_count = vec_size(any_params); + unsigned this_param_count = vec_size(this_params); + if (any_param_count != this_param_count) + { + if (any_param_count > this_param_count) + { + SEMA_ERROR(decl, "This function is missing parameters, %d parameters were expected.", any_param_count); + SEMA_NOTE(any_params[this_param_count], "Compare with the interface definition."); + return false; + } + else + { + SEMA_ERROR(this_params[any_param_count], "This function has too many parameters (%d).", this_param_count); + SEMA_NOTE(decl, "Compare with the interface, which has only %d parameter%s.", + any_param_count, any_param_count == 1 ? "" : "s"); + } + return false; + } + FOREACH_BEGIN_IDX(i, Decl *param, this_params) + if (i == 0) continue; + if (param->type->canonical != any_params[i]->type->canonical) + { + SEMA_ERROR(vartype(param), "The prototype argument has type %s, but in this function it has type %s. Please make them match.", + type_quoted_error_string(any_params[i]->type), type_quoted_error_string(param->type)); + SEMA_NOTE(vartype(any_params[i]), "The interface definition is here."); + return false; + } + FOREACH_END(); + decl->func_decl.protocol_method = declid(implemented_method); + } + return unit_add_method_like(context->unit, par_type, decl); +} static const char *attribute_domain_to_string(AttributeDomain domain) { @@ -1626,8 +1807,10 @@ static const char *attribute_domain_to_string(AttributeDomain domain) return "def"; case ATTR_CALL: return "call"; - case ATTR_DEFINE: - return "define"; + case ATTR_DISTINCT: + return "distinct"; + case ATTR_PROTOCOL_METHOD: + return "protocol method"; } UNREACHABLE } @@ -1673,8 +1856,9 @@ static bool update_call_abi_from_string(Decl *decl, Expr *expr) return false; } -#define EXPORTED_USER_DEFINED_TYPES ATTR_ENUM | ATTR_UNION | ATTR_STRUCT | ATTR_FAULT -#define USER_DEFINED_TYPES EXPORTED_USER_DEFINED_TYPES | ATTR_BITSTRUCT +#define EXPORTED_USER_DEFINED_TYPES (ATTR_ENUM | ATTR_UNION | ATTR_STRUCT | ATTR_FAULT) +#define CALLABLE_TYPE (ATTR_FUNC | ATTR_PROTOCOL_METHOD | ATTR_MACRO) +#define USER_DEFINED_TYPES EXPORTED_USER_DEFINED_TYPES | ATTR_BITSTRUCT | ATTR_DISTINCT static bool sema_analyse_attribute(SemaContext *context, Decl *decl, Attr *attr, AttributeDomain domain, bool *erase_decl) { AttributeType type = attr->attr_kind; @@ -1684,31 +1868,29 @@ static bool sema_analyse_attribute(SemaContext *context, Decl *decl, Attr *attr, [ATTRIBUTE_BENCHMARK] = ATTR_FUNC, [ATTRIBUTE_BIGENDIAN] = ATTR_BITSTRUCT, [ATTRIBUTE_BUILTIN] = ATTR_MACRO | ATTR_FUNC | ATTR_GLOBAL | ATTR_CONST, - [ATTRIBUTE_CALLCONV] = ATTR_FUNC, - [ATTRIBUTE_DEPRECATED] = USER_DEFINED_TYPES | ATTR_FUNC | ATTR_MACRO | ATTR_CONST | ATTR_GLOBAL | ATTR_MEMBER | ATTR_BITSTRUCT_MEMBER, - [ATTRIBUTE_DYNAMIC] = ATTR_FUNC, + [ATTRIBUTE_CALLCONV] = ATTR_FUNC | ATTR_PROTOCOL_METHOD, + [ATTRIBUTE_DEPRECATED] = USER_DEFINED_TYPES | CALLABLE_TYPE | ATTR_CONST | ATTR_GLOBAL | ATTR_MEMBER | ATTR_BITSTRUCT_MEMBER, [ATTRIBUTE_EXPORT] = ATTR_FUNC | ATTR_GLOBAL | ATTR_CONST | EXPORTED_USER_DEFINED_TYPES, [ATTRIBUTE_EXTERN] = ATTR_FUNC | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES, [ATTRIBUTE_FINALIZER] = ATTR_FUNC, [ATTRIBUTE_IF] = (AttributeDomain)~(ATTR_CALL | ATTR_LOCAL), [ATTRIBUTE_INIT] = ATTR_FUNC, [ATTRIBUTE_INLINE] = ATTR_FUNC | ATTR_CALL, - [ATTRIBUTE_INTERFACE] = ATTR_FUNC, [ATTRIBUTE_LITTLEENDIAN] = ATTR_BITSTRUCT, - [ATTRIBUTE_LOCAL] = ATTR_FUNC | ATTR_MACRO | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES | ATTR_DEFINE, - [ATTRIBUTE_MAYDISCARD] = ATTR_FUNC | ATTR_MACRO, + [ATTRIBUTE_LOCAL] = ATTR_FUNC | ATTR_MACRO | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES | ATTR_DEF | ATTR_DISTINCT, + [ATTRIBUTE_MAYDISCARD] = CALLABLE_TYPE, [ATTRIBUTE_NAKED] = ATTR_FUNC, - [ATTRIBUTE_NODISCARD] = ATTR_FUNC | ATTR_MACRO, + [ATTRIBUTE_NODISCARD] = CALLABLE_TYPE, [ATTRIBUTE_NOINIT] = ATTR_GLOBAL | ATTR_LOCAL, [ATTRIBUTE_NOINLINE] = ATTR_FUNC | ATTR_CALL, - [ATTRIBUTE_NORETURN] = ATTR_FUNC | ATTR_MACRO, + [ATTRIBUTE_NORETURN] = CALLABLE_TYPE, [ATTRIBUTE_NOSTRIP] = ATTR_FUNC | ATTR_GLOBAL | ATTR_CONST | EXPORTED_USER_DEFINED_TYPES, [ATTRIBUTE_OBFUSCATE] = ATTR_ENUM | ATTR_FAULT, [ATTRIBUTE_OPERATOR] = ATTR_MACRO | ATTR_FUNC, [ATTRIBUTE_OVERLAP] = ATTR_BITSTRUCT, [ATTRIBUTE_PACKED] = ATTR_STRUCT | ATTR_UNION, - [ATTRIBUTE_PRIVATE] = ATTR_FUNC | ATTR_MACRO | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES | ATTR_DEFINE, - [ATTRIBUTE_PUBLIC] = ATTR_FUNC | ATTR_MACRO | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES | ATTR_DEFINE, + [ATTRIBUTE_PRIVATE] = ATTR_FUNC | ATTR_MACRO | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES | ATTR_DEF, + [ATTRIBUTE_PUBLIC] = ATTR_FUNC | ATTR_MACRO | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES | ATTR_DEF, [ATTRIBUTE_PURE] = ATTR_CALL, [ATTRIBUTE_REFLECT] = ATTR_FUNC | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES, [ATTRIBUTE_SECTION] = ATTR_FUNC | ATTR_CONST | ATTR_GLOBAL, @@ -1752,6 +1934,9 @@ static bool sema_analyse_attribute(SemaContext *context, Decl *decl, Attr *attr, } decl->is_deprecated = true; return true; + case ATTRIBUTE_OPTIONAL: + decl->func_decl.attr_optional = true; + return true; case ATTRIBUTE_WINMAIN: if (decl->name != kw_main) { @@ -1772,12 +1957,6 @@ static bool sema_analyse_attribute(SemaContext *context, Decl *decl, Attr *attr, case ATTRIBUTE_TEST: decl->func_decl.attr_test = true; break; - case ATTRIBUTE_INTERFACE: - decl->func_decl.attr_interface = true; - break; - case ATTRIBUTE_DYNAMIC: - decl->func_decl.attr_dynamic = true; - break; case ATTRIBUTE_OPERATOR: { assert(decl->decl_kind == DECL_FUNC || decl->decl_kind == DECL_MACRO); @@ -2466,12 +2645,13 @@ static inline bool sema_analyse_main_function(SemaContext *context, Decl *decl) return true; } -static inline bool sema_analyse_func_macro(SemaContext *context, Decl *decl, bool is_func, bool *erase_decl) +static inline bool sema_analyse_func_macro(SemaContext *context, Decl *decl, AttributeDomain domain, bool *erase_decl) { + assert((domain & CALLABLE_TYPE) == domain); if (!sema_analyse_attributes(context, decl, decl->attributes, - is_func ? ATTR_FUNC : ATTR_MACRO, + domain, erase_decl)) return decl_poison(decl); return true; } @@ -2480,8 +2660,8 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era { DEBUG_LOG("----Analysing function %s", decl->name); - if (!sema_analyse_func_macro(context, decl, true, erase_decl)) return false; - + bool is_protocol_method = decl->func_decl.attr_protocol_method; + if (!sema_analyse_func_macro(context, decl, is_protocol_method ? ATTR_PROTOCOL_METHOD : ATTR_FUNC, erase_decl)) return false; if (*erase_decl) return true; bool is_test = decl->func_decl.attr_test; @@ -2494,6 +2674,7 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era } if (is_test || is_benchmark || is_init_finalizer) { + assert(!is_protocol_method); if (vec_size(sig->params)) { SEMA_ERROR(sig->params[0], "%s functions may not take any parameters.", @@ -2501,7 +2682,7 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era return decl_poison(decl); } TypeInfo *rtype_info = type_infoptr(sig->rtype); - if (!sema_resolve_type_info(context, rtype_info)) return false; + if (!sema_resolve_type_info(context, rtype_info, RESOLVE_TYPE_DEFAULT)) return false; Type *rtype = rtype_info->type; if (is_init_finalizer) { @@ -2526,7 +2707,7 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era } decl->type = type_new_func(decl, sig); - if (!sema_analyse_function_signature(context, decl, sig->abi, sig, true)) return decl_poison(decl); + if (!sema_analyse_function_signature(context, decl, sig->abi, sig)) return decl_poison(decl); TypeInfo *rtype_info = type_infoptr(sig->rtype); assert(rtype_info); Type *rtype = rtype_info->type->canonical; @@ -2548,28 +2729,13 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era } if (decl->func_decl.type_parent) { - if (is_init_finalizer) - { - SEMA_ERROR(decl, "Methods may not have '@init' or '@finalizer' attributes."); - return decl_poison(decl); - } - if (is_test || is_benchmark) - { - SEMA_ERROR(decl, "Methods may not be annotated %s.", is_test ? "@test" : "@benchmark"); - return decl_poison(decl); - } if (!sema_analyse_method(context, decl)) return decl_poison(decl); } - else + else if (!is_protocol_method) { - if (decl->func_decl.attr_dynamic) - { - SEMA_ERROR(decl, "Only methods may be annotated '@dynamic'."); - return decl_poison(decl); - } - if (decl->func_decl.attr_interface) + if (decl->func_decl.is_dynamic) { - SEMA_ERROR(decl, "Only methods to 'any' may be annotated '@interface'."); + SEMA_ERROR(decl, "Only methods may implement protocols."); return decl_poison(decl); } if (decl->name == kw_main) @@ -2584,11 +2750,8 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era decl_set_external_name(decl); } - bool is_any_interface = decl->func_decl.attr_interface && decl->func_decl.type_parent && type_is_any( - typeget(decl->func_decl.type_parent)); // Do we have fn void any.foo(void*) { ... }? - if (decl->func_decl.body && is_any_interface) RETURN_SEMA_ERROR(decl, "Interface methods declarations may not have a body."); - if (!decl->func_decl.body && !decl->is_extern && !decl->unit->is_interface_file && !is_any_interface) + if (!decl->func_decl.body && !decl->is_extern && !decl->unit->is_interface_file && !is_protocol_method) { SEMA_ERROR(decl, "Expected a function body, if you want to declare an extern function use 'extern' or place it in an .c3i file."); return false; @@ -2602,7 +2765,7 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era return true; } -static inline bool sema_is_valid_method_param(SemaContext *context, Decl *param, Type *parent_type, bool is_dynamic, bool is_interface) +static inline bool sema_is_valid_method_param(SemaContext *context, Decl *param, Type *parent_type, bool is_dynamic) { assert(parent_type->canonical == parent_type && "Expected already the canonical version."); Type *param_type = param->type; @@ -2610,12 +2773,6 @@ static inline bool sema_is_valid_method_param(SemaContext *context, Decl *param, if (!param_type) goto ERROR; param_type = param_type->canonical; - if (is_interface) - { - if (param_type != type_voidptr) RETURN_SEMA_ERROR(param, "The first parameter of an interface must be of type 'void*'."); - return true; - } - if (is_dynamic) { if (param_type->type_kind != TYPE_POINTER || param_type->pointer != parent_type) @@ -2628,18 +2785,32 @@ static inline bool sema_is_valid_method_param(SemaContext *context, Decl *param, // 1. Same type ok! if (param_type == parent_type) return true; - // 2. A pointer is ok! - if (param_type->type_kind == TYPE_POINTER && param_type->pointer == parent_type) return true; + switch (param_type->type_kind) + { + case TYPE_ANYPTR: + case TYPE_PROPTR: + case TYPE_POINTER: + if (param_type->pointer == parent_type) return true; + break; + default: + break; + } ERROR: - SEMA_ERROR(param, "The first parameter must be of type %s or %s.", type_quoted_error_string(parent_type), - type_quoted_error_string(type_get_ptr(parent_type))); - return false; + if (type_is_any_raw(parent_type)) + { + RETURN_SEMA_ERROR(param, "The first parameter must have the type %s.", + type_quoted_error_string(type_get_ptr(parent_type))); + + } + RETURN_SEMA_ERROR(param, "The first parameter must be of type %s or %s.", + type_quoted_error_string(parent_type), + type_quoted_error_string(type_get_ptr(parent_type))); } static bool sema_analyse_macro_method(SemaContext *context, Decl *decl) { TypeInfo *parent_type_info = type_infoptr(decl->func_decl.type_parent); - if (!sema_resolve_type_info_maybe_inferred(context, parent_type_info, true)) return false; + if (!sema_resolve_type_info(context, parent_type_info, RESOLVE_TYPE_MACRO_METHOD)) return false; Type *parent_type = parent_type_info->type; if (!type_may_have_method(parent_type)) { @@ -2659,7 +2830,7 @@ static bool sema_analyse_macro_method(SemaContext *context, Decl *decl) SEMA_ERROR(decl, "The first parameter to this method must be of type '%s'.", type_to_error_string(parent_type)); return false; } - if (!sema_is_valid_method_param(context, first_param, parent_type->canonical, false, false)) return false; + if (!sema_is_valid_method_param(context, first_param, parent_type->canonical, false)) return false; if (first_param->var.kind != VARDECL_PARAM_REF && first_param->var.kind != VARDECL_PARAM) { @@ -2673,7 +2844,7 @@ static inline bool sema_analyse_macro(SemaContext *context, Decl *decl, bool *er { decl->func_decl.unit = context->unit; - if (!sema_analyse_func_macro(context, decl, false, erase_decl)) return false; + if (!sema_analyse_func_macro(context, decl, ATTR_MACRO, erase_decl)) return false; if (*erase_decl) return true; if (!sema_analyse_signature(context, &decl->func_decl.signature, decl->func_decl.type_parent)) return decl_poison(decl); @@ -2697,7 +2868,7 @@ static inline bool sema_analyse_macro(SemaContext *context, Decl *decl, bool *er switch (param->var.kind) { case VARDECL_PARAM: - if (type_info && !sema_resolve_type_info(context, type_info)) return decl_poison(decl); + if (type_info && !sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return decl_poison(decl); break; case VARDECL_PARAM_EXPR: case VARDECL_PARAM_CT: @@ -2802,7 +2973,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl) } break; case VARDECL_LOCAL_CT: - if (type_info && !sema_resolve_type_info(context, type_info)) goto FAIL; + if (type_info && !sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) goto FAIL; if (type_info) { decl->type = type_info->type->canonical; @@ -2974,7 +3145,9 @@ bool sema_analyse_var_decl(SemaContext *context, Decl *decl, bool local) } } - if (!sema_resolve_type_info_maybe_inferred(context, type_info, decl->var.init_expr != NULL)) return decl_poison(decl); + if (!sema_resolve_type_info(context, type_info, + decl->var.init_expr ? RESOLVE_TYPE_ALLOW_INFER + : RESOLVE_TYPE_DEFAULT)) return decl_poison(decl); Type *type = decl->type = type_info->type; if (!sema_analyse_decl_type(context, decl->type, type_info->span)) return decl_poison(decl); @@ -3148,7 +3321,7 @@ static bool sema_append_generate_parameterized_name(SemaContext *c, Module *modu if (param->expr_kind == EXPR_TYPEINFO) { TypeInfo *type_info = param->type_expr; - if (!sema_resolve_type_info(c, type_info)) return false; + if (!sema_resolve_type_info(c, type_info, RESOLVE_TYPE_DEFAULT)) return false; Type *type = type_info->type->canonical; if (type->type_kind == TYPE_OPTIONAL) RETURN_SEMA_ERROR(type_info, "Expected a non-optional type."); if (type == type_void) RETURN_SEMA_ERROR(type_info, "A 'void' type cannot be used as a parameter type."); @@ -3397,7 +3570,7 @@ static inline bool sema_analyse_attribute_decl(SemaContext *c, Decl *decl) static inline bool sema_analyse_define(SemaContext *c, Decl *decl, bool *erase_decl) { - if (!sema_analyse_attributes(c, decl, decl->attributes, ATTR_DEFINE, erase_decl)) return decl_poison(decl); + if (!sema_analyse_attributes(c, decl, decl->attributes, ATTR_DEF, erase_decl)) return decl_poison(decl); // 1. The plain define if (decl->define_decl.define_kind == DEFINE_IDENT_ALIAS) @@ -3418,18 +3591,20 @@ bool sema_resolve_type_structure(SemaContext *context, Type *type, SourceSpan sp RETRY: switch (type->type_kind) { + case TYPE_PROTOCOL: + case TYPE_ANY: case TYPE_POISONED: case TYPE_VOID: case TYPE_BOOL: case ALL_INTS: case ALL_FLOATS: - case TYPE_ANY: case TYPE_ANYFAULT: case TYPE_TYPEID: case TYPE_UNTYPED_LIST: case TYPE_WILDCARD: case TYPE_TYPEINFO: case TYPE_MEMBER: + case TYPE_ANYPTR: return true; case TYPE_FUNC: if (!type->decl) return true; @@ -3440,6 +3615,7 @@ bool sema_resolve_type_structure(SemaContext *context, Type *type, SourceSpan sp case TYPE_BITSTRUCT: case TYPE_FAULTTYPE: return sema_analyse_decl(context, type->decl); + case TYPE_PROPTR: case TYPE_POINTER: type = type->pointer; goto RETRY; @@ -3487,6 +3663,10 @@ bool sema_analyse_decl(SemaContext *context, Decl *decl) { case DECL_ERASED: break; + case DECL_PROTOCOL: + if (!sema_analyse_protocol(context, decl, &erase_decl)) goto FAILED; + set_external_name = true; + break; case DECL_BITSTRUCT: if (!sema_analyse_bitstruct(context, decl, &erase_decl)) goto FAILED; set_external_name = true; @@ -3513,7 +3693,7 @@ bool sema_analyse_decl(SemaContext *context, Decl *decl) if (!sema_analyse_attribute_decl(context, decl)) goto FAILED; break; case DECL_DISTINCT: - if (!sema_analyse_distinct(context, decl)) goto FAILED; + if (!sema_analyse_distinct(context, decl, &erase_decl)) goto FAILED; set_external_name = true; break; case DECL_TYPEDEF: diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index dacb0301d..8a0a2781d 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -511,7 +511,6 @@ static bool sema_binary_is_expr_lvalue(Expr *top_expr, Expr *expr) case EXPR_TYPEID: case EXPR_TYPEID_INFO: case EXPR_TYPEINFO: - case EXPR_ANY: case EXPR_ANYSWITCH: case EXPR_VASPLAT: case EXPR_BENCHMARK_HOOK: @@ -625,7 +624,6 @@ static bool expr_may_ref(Expr *expr) case EXPR_TYPEID: case EXPR_TYPEID_INFO: case EXPR_TYPEINFO: - case EXPR_ANY: case EXPR_ANYSWITCH: case EXPR_VASPLAT: case EXPR_BENCHMARK_HOOK: @@ -698,6 +696,9 @@ static inline bool sema_cast_ident_rvalue(SemaContext *context, Expr *expr) case DECL_STRUCT: SEMA_ERROR(expr, "Expected struct followed by {...} or '.'."); return expr_poison(expr); + case DECL_PROTOCOL: + SEMA_ERROR(expr, "Expected a protocol to be followed by '.' when used as an expression."); + return expr_poison(expr); case DECL_UNION: SEMA_ERROR(expr, "Expected union followed by {...} or '.'."); return expr_poison(expr); @@ -1537,7 +1538,7 @@ static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call // &foo if (!sema_analyse_expr_lvalue(context, arg)) return false; if (!sema_expr_check_assign(context, arg)) return false; - expr_insert_addr(arg); + if (!type_is_any_protocol_ptr(arg->type)) expr_insert_addr(arg); *optional |= IS_OPTIONAL(arg); if (!sema_call_check_contract_param_match(context, param, arg)) return false; if (type_is_invalid_storage_type(type) || type == type_void) @@ -1773,7 +1774,7 @@ static inline bool sema_expr_analyse_func_call(SemaContext *context, Expr *expr, sema_display_deprecated_warning_on_use(context, decl, expr->span); // Tag dynamic dispatch. - if (struct_var && decl->func_decl.attr_interface) expr->call_expr.is_dynamic_dispatch = true; + if (struct_var && decl->func_decl.attr_protocol_method) expr->call_expr.is_dynamic_dispatch = true; return sema_call_analyse_func_invocation(context, decl->type, @@ -1872,7 +1873,7 @@ bool sema_expr_analyse_macro_call(SemaContext *context, Expr *call_expr, Expr *s return false; } TypeInfo *type_info = vartype(body_arg); - if (!sema_resolve_type_info(context, type_info)) return false; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false; body_arg->type = type_info->type; if (type_info) { @@ -3907,7 +3908,8 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr) assert(parent->resolve_status == RESOLVE_DONE); // 7. Is this a pointer? If so we insert a deref. - bool is_pointer = type_no_optional(parent->type)->canonical->type_kind == TYPE_POINTER; + Type *underlying_type = type_no_optional(parent->type)->canonical; + bool is_pointer = underlying_type->type_kind == TYPE_POINTER; if (is_pointer) { if (!sema_cast_rvalue(context, parent)) return false; @@ -3923,7 +3925,7 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr) const char *kw = identifier->identifier_expr.ident; if (kw_type == kw) { - if (flat_type->type_kind == TYPE_ANY) + if (flat_type->type_kind == TYPE_ANYPTR) { expr_rewrite_to_builtin_access(expr, parent, ACCESS_TYPEOFANY, type_typeid); return true; @@ -3990,7 +3992,7 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr) expr_rewrite_to_builtin_access(expr, current_parent, ACCESS_PTR, type_get_ptr(flat_type->array.base)); return true; } - if (flat_type->type_kind == TYPE_ANY) + if (flat_type->type_kind == TYPE_ANYPTR) { expr_rewrite_to_builtin_access(expr, current_parent, ACCESS_PTR, type_voidptr); return true; @@ -4050,12 +4052,14 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr) } } - // 9. At this point we may only have distinct, struct, union, error, enum + // 9. At this point we may only have distinct, struct, union, error, enum, protocol if (!type_may_have_sub_elements(type)) { Decl *ambiguous = NULL; Decl *private = NULL; - Decl *method = sema_resolve_type_method(context->unit, type, kw, &ambiguous, &private); + // We look at any for any* and protocol for protocol* + Type *actual = type_is_any_protocol_ptr(type) ? type->pointer : type; + Decl *method = sema_resolve_type_method(context->unit, actual, kw, &ambiguous, &private); if (private) { RETURN_SEMA_ERROR(expr, "The method '%s' has private visibility.", kw); @@ -4068,7 +4072,7 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr) } if (!method) { - RETURN_SEMA_ERROR(expr, "There is no member or method '%s' on '%s'", kw, type_to_error_string(type)); + RETURN_SEMA_ERROR(expr, "There is no member or method '%s' on '%s'", kw, type_to_error_string(actual)); } expr->access_expr.parent = current_parent; expr->type = method->type ? type_add_optional(method->type, optional) : NULL; @@ -4078,7 +4082,7 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr) } // 10. Dump all members and methods into the scope. - Decl *decl = type->decl; + Decl *decl = type->type_kind == TYPE_PROPTR ? type->pointer->decl : type->decl; Decl *member = sema_decl_stack_find_decl_member(decl, kw); @@ -4352,7 +4356,7 @@ static inline bool sema_expr_analyse_cast(SemaContext *context, Expr *expr) { Expr *inner = exprptr(expr->cast_expr.expr); TypeInfo *type_info = type_infoptr(expr->cast_expr.type_info); - bool success = sema_resolve_type_info(context, type_info); + bool success = sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT); if (!sema_analyse_expr(context, inner) || !success) return false; Type *target_type = type_info->type; @@ -5936,7 +5940,7 @@ static const char *sema_addr_check_may_take(Expr *inner) Decl *decl = inner->access_expr.ref; if (decl->decl_kind == DECL_FUNC) { - if (decl->func_decl.attr_interface) return NULL; + if (decl->func_decl.attr_protocol_method) return NULL; return "Taking the address of a method should be done through the type e.g. '&Foo.method' not through the value."; } return sema_addr_check_may_take(inner->access_expr.parent); @@ -6524,7 +6528,7 @@ static inline bool sema_expr_analyse_force_unwrap(SemaContext *context, Expr *ex static inline bool sema_expr_analyse_typeid(SemaContext *context, Expr *expr) { - if (!sema_resolve_type_info(context, expr->typeid_expr)) return expr_poison(expr); + if (!sema_resolve_type_info(context, expr->typeid_expr, RESOLVE_TYPE_DEFAULT)) return expr_poison(expr); Type *type = expr->type_expr->type; expr->expr_kind = EXPR_CONST; expr->const_expr.const_kind = CONST_TYPEID; @@ -7136,11 +7140,11 @@ static Type *sema_expr_check_type_exists(SemaContext *context, TypeInfo *type_in return decl->type->canonical; } case TYPE_INFO_VATYPE: - if (!sema_resolve_type_info(context, type_info)) return poisoned_type; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return poisoned_type; return type_info->type->canonical; case TYPE_INFO_TYPEFROM: case TYPE_INFO_TYPEOF: - if (!sema_resolve_type_info(context, type_info)) return poisoned_type; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return poisoned_type; return type_info->type; case TYPE_INFO_EVALTYPE: { @@ -7236,7 +7240,7 @@ static inline Type *sema_evaluate_type_copy(SemaContext *context, TypeInfo *type { if (type_info->resolve_status == RESOLVE_DONE) return type_info->type; type_info = copy_type_info_single(type_info); - if (!sema_resolve_type_info(context, type_info)) return NULL; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return NULL; return type_info->type; } @@ -7493,7 +7497,7 @@ static inline bool sema_expr_analyse_lambda(SemaContext *context, Type *target_t scratch_buffer_append_unsigned_int(++unit->lambda_count); decl->extname = decl->name = scratch_buffer_copy(); decl->type = type_new_func(decl, sig); - if (!sema_analyse_function_signature(context, decl, sig->abi, sig, true)) return false; + if (!sema_analyse_function_signature(context, decl, sig->abi, sig)) return false; decl->func_decl.lambda_ct_parameters = ct_lambda_parameters; decl->func_decl.is_lambda = true; decl->alignment = type_alloca_alignment(decl->type); @@ -7891,7 +7895,7 @@ static inline bool sema_expr_analyse_builtin(SemaContext *context, Expr *expr, b static inline bool sema_expr_analyse_compound_literal(SemaContext *context, Expr *expr) { TypeInfo *type_info = expr->expr_compound_literal.type_info; - if (!sema_resolve_type_info(context, type_info)) return false; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false; Type *type = type_info->type; if (type_is_optional(type)) { @@ -7941,9 +7945,6 @@ static inline bool sema_analyse_expr_dispatch(SemaContext *context, Expr *expr) return sema_expr_analyse_ct_checks(context, expr); case EXPR_CT_ARG: return sema_expr_analyse_ct_arg(context, expr); - case EXPR_ANY: - // Created from compound statement. - UNREACHABLE; case EXPR_STRINGIFY: if (!sema_expr_analyse_ct_stringify(context, expr)) return false; return true; @@ -7979,7 +7980,7 @@ static inline bool sema_analyse_expr_dispatch(SemaContext *context, Expr *expr) UNREACHABLE case EXPR_TYPEINFO: expr->type = type_typeinfo; - return sema_resolve_type_info(context, expr->type_expr); + return sema_resolve_type_info(context, expr->type_expr, RESOLVE_TYPE_DEFAULT); case EXPR_SLICE: return sema_expr_analyse_slice(context, expr); case EXPR_FORCE_UNWRAP: diff --git a/src/compiler/sema_initializers.c b/src/compiler/sema_initializers.c index fac8345f2..dad487d5d 100644 --- a/src/compiler/sema_initializers.c +++ b/src/compiler/sema_initializers.c @@ -526,42 +526,6 @@ static void sema_create_const_initializer_from_designated_init(ConstInitializer } } -static bool sema_analyse_variant_init(SemaContext *context, Expr *expr) -{ - unsigned elements = expr->expr_kind == EXPR_INITIALIZER_LIST ? vec_size(expr->initializer_list) : (unsigned)-1; - if (elements != 2 && elements != 0) - { - SEMA_ERROR(expr, "Expected an initializer with arguments '{ ptr, typeid }'."); - return false; - } - if (elements == 0) - { - expr->expr_kind = EXPR_ANY; - expr->any_expr = (ExprAny) { 0, 0 }; - expr->type = type_any; - return true; - } - Expr *ptr = expr->initializer_list[0]; - Expr *typeid = expr->initializer_list[1]; - if (!sema_analyse_expr(context, ptr)) return false; - if (!sema_analyse_expr(context, typeid)) return false; - if (!type_is_pointer(ptr->type)) - { - SEMA_ERROR(ptr, "Expected a pointer, but was %s.", type_quoted_error_string(ptr->type)); - return false; - } - if (typeid->type != type_typeid) - { - SEMA_ERROR(ptr, "Expected a 'typeid', but was %s.", type_quoted_error_string(ptr->type)); - return false; - } - expr->expr_kind = EXPR_ANY; - expr->any_expr.ptr = exprid(ptr); - expr->any_expr.type_id = exprid(typeid); - expr->type = type_any; - return true; -} - bool sema_expr_analyse_initializer_list(SemaContext *context, Type *to, Expr *expr) { if (!to) to = type_untypedlist; @@ -571,6 +535,9 @@ bool sema_expr_analyse_initializer_list(SemaContext *context, Type *to, Expr *ex if (!sema_resolve_type_structure(context, to, expr->span)) return false; switch (flattened->type_kind) { + case TYPE_ANY: + case TYPE_PROTOCOL: + UNREACHABLE case TYPE_UNTYPED_LIST: case TYPE_STRUCT: case TYPE_UNION: @@ -614,8 +581,6 @@ bool sema_expr_analyse_initializer_list(SemaContext *context, Type *to, Expr *ex case TYPE_TYPEINFO: case TYPE_MEMBER: break; - case TYPE_ANY: - return sema_analyse_variant_init(context, expr); default: if (is_zero_init) { diff --git a/src/compiler/sema_internal.h b/src/compiler/sema_internal.h index 4500bb2fe..38dc959d9 100644 --- a/src/compiler/sema_internal.h +++ b/src/compiler/sema_internal.h @@ -79,7 +79,7 @@ bool sema_analyse_asm(SemaContext *context, AsmInlineBlock *block, Ast *asm_stmt bool sema_bit_assignment_check(Expr *right, Decl *member); int sema_check_comp_time_bool(SemaContext *context, Expr *expr); bool sema_expr_check_assign(SemaContext *c, Expr *expr); -bool sema_analyse_function_signature(SemaContext *context, Decl *func_decl, CallABI abi, Signature *signature, bool is_real_function); +bool sema_analyse_function_signature(SemaContext *context, Decl *func_decl, CallABI abi, Signature *signature); MemberIndex sema_len_from_const(Expr *expr); diff --git a/src/compiler/sema_liveness.c b/src/compiler/sema_liveness.c index 213e446d8..e98b0d4fd 100644 --- a/src/compiler/sema_liveness.c +++ b/src/compiler/sema_liveness.c @@ -263,7 +263,6 @@ static void sema_trace_expr_liveness(Expr *expr) { case EXPR_SUBSCRIPT_ASSIGN: case EXPR_GROUP: - case EXPR_BUILTIN: case EXPR_OPERATOR_CHARS: case EXPR_VASPLAT: case EXPR_POISONED: @@ -279,6 +278,8 @@ static void sema_trace_expr_liveness(Expr *expr) case EXPR_EMBED: case EXPR_MACRO_BODY: UNREACHABLE + case EXPR_BUILTIN: + TODO case EXPR_DESIGNATOR: sema_trace_expr_liveness(expr->designator_expr.value); return; @@ -488,10 +489,6 @@ static void sema_trace_expr_liveness(Expr *expr) return; case EXPR_TYPEID: return; - case EXPR_ANY: - sema_trace_exprid_liveness(expr->any_expr.ptr); - sema_trace_exprid_liveness(expr->any_expr.type_id); - return; } UNREACHABLE } @@ -505,7 +502,7 @@ void sema_trace_liveness(void) bool keep_tests = active_target.testing; bool keep_benchmarks = active_target.benchmarking; FOREACH_BEGIN(Decl *function, global_context.method_extensions) - if (function->func_decl.attr_dynamic) function->no_strip = true; + if (function->func_decl.is_dynamic) function->no_strip = true; if (function->is_export || function->no_strip) sema_trace_decl_liveness(function); FOREACH_END(); FOREACH_BEGIN(Module *module, global_context.module_list) @@ -537,7 +534,7 @@ INLINE void sema_trace_decl_dynamic_methods(Decl *decl) for (unsigned i = 0; i < method_count; i++) { Decl *method = methods[i]; - if (method->decl_kind == DECL_MACRO || !method->func_decl.attr_dynamic) continue; + if (method->decl_kind == DECL_MACRO || !method->func_decl.is_dynamic) continue; sema_trace_decl_liveness(method); } } @@ -578,6 +575,7 @@ static void sema_trace_decl_liveness(Decl *decl) case DECL_ATTRIBUTE: case DECL_ENUM_CONSTANT: case DECL_FAULTVALUE: + case DECL_PROTOCOL: return; case DECL_CT_ASSERT: case DECL_CT_ECHO: diff --git a/src/compiler/sema_name_resolution.c b/src/compiler/sema_name_resolution.c index 764956e34..396241ce5 100644 --- a/src/compiler/sema_name_resolution.c +++ b/src/compiler/sema_name_resolution.c @@ -709,7 +709,7 @@ bool sema_resolve_type_decl(SemaContext *context, Type *type) case TYPE_BOOL: case ALL_INTS: case ALL_FLOATS: - case TYPE_ANY: + case TYPE_ANYPTR: case TYPE_ANYFAULT: case TYPE_TYPEID: case TYPE_POINTER: @@ -718,6 +718,9 @@ bool sema_resolve_type_decl(SemaContext *context, Type *type) case TYPE_INFERRED_VECTOR: case TYPE_VECTOR: case TYPE_SUBARRAY: + case TYPE_PROPTR: + case TYPE_ANY: + case TYPE_PROTOCOL: return true; case TYPE_OPTIONAL: return sema_resolve_type_decl(context, type->optional); @@ -748,6 +751,10 @@ bool sema_resolve_type_decl(SemaContext *context, Type *type) Decl *sema_resolve_type_method(CompilationUnit *unit, Type *type, const char *method_name, Decl **ambiguous_ref, Decl **private_ref) { assert(type == type->canonical); + if (type->type_kind == TYPE_PROPTR) + { + type = type->pointer; + } Decl *private = NULL; Decl *ambiguous = NULL; Decl *found = sema_find_extension_method_in_list(unit->local_method_extensions, type, method_name); diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index 2a304c42b..0498afc9c 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -645,7 +645,7 @@ static inline bool sema_analyse_try_unwrap(SemaContext *context, Expr *expr) // 2. If we have a type for the variable, resolve it. if (var_type) { - if (!sema_resolve_type_info(context, var_type)) return false; + if (!sema_resolve_type_info(context, var_type, RESOLVE_TYPE_DEFAULT)) return false; if (IS_OPTIONAL(var_type)) { SEMA_ERROR(var_type, "Only non-optional types may be used as types for 'try', please remove the '!'."); @@ -809,7 +809,7 @@ static inline bool sema_analyse_catch_unwrap(SemaContext *context, Expr *expr) { type = type ? type : type_info_new_base(type_anyfault, expr->span); - if (!sema_resolve_type_info(context, type)) return false; + if (!sema_resolve_type_info(context, type, RESOLVE_TYPE_DEFAULT)) return false; if (type->type->canonical != type_anyfault) { @@ -926,13 +926,13 @@ static inline bool sema_analyse_last_cond(SemaContext *context, Expr *expr, Cond if (is_deref) right = right->unary_expr.expr; if (!sema_analyse_expr_rhs(context, NULL, right, false)) return false; Type *type = right->type->canonical; - if (type == type_get_ptr(type_any) && is_deref) + if (type == type_get_ptr(type_anyptr) && is_deref) { is_deref = false; right = exprptr(expr->binary_expr.right); if (!sema_analyse_expr_rhs(context, NULL, right, false)) return false; } - if (type != type_any) goto NORMAL_EXPR; + if (type != type_anyptr) goto NORMAL_EXPR; // Found an expansion here expr->expr_kind = EXPR_ANYSWITCH; expr->any_switch.new_ident = left->identifier_expr.ident; @@ -946,7 +946,7 @@ static inline bool sema_analyse_last_cond(SemaContext *context, Expr *expr, Cond } if (!sema_analyse_expr(context, expr)) return false; Type *type = expr->type->canonical; - if (type != type_any) return true; + if (type != type_anyptr) return true; if (expr->expr_kind == EXPR_IDENTIFIER) { Decl *decl = expr->identifier_expr.decl; @@ -1358,7 +1358,7 @@ static inline bool sema_analyse_foreach_stmt(SemaContext *context, Ast *statemen return SCOPE_POP_ERROR(); } // First infer the type of the variable. - if (!sema_resolve_type_info(context, variable_type_info)) return false; + if (!sema_resolve_type_info(context, variable_type_info, RESOLVE_TYPE_DEFAULT)) return false; // And create the inferred type: inferred_type = type_get_array(variable_type_info->type, (ArraySize)size); } @@ -1447,7 +1447,7 @@ static inline bool sema_analyse_foreach_stmt(SemaContext *context, Ast *statemen type_info = type_info_new_base(value_type, var->span); var->var.type_info = type_infoid(type_info); } - if (!sema_resolve_type_info(context, type_info)) return false; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false; if (type_is_optional(type_info->type)) { @@ -1465,7 +1465,7 @@ static inline bool sema_analyse_foreach_stmt(SemaContext *context, Ast *statemen idx_type_info = type_info_new_base(index_type, enumerator->span); index->var.type_info = type_infoid(idx_type_info); } - if (!sema_resolve_type_info(context, idx_type_info)) return false; + if (!sema_resolve_type_info(context, idx_type_info, RESOLVE_TYPE_DEFAULT)) return false; index_var_type = idx_type_info->type; if (type_is_optional(index_var_type)) { @@ -1942,7 +1942,7 @@ static bool sema_analyse_nextcase_stmt(SemaContext *context, Ast *statement) if (value->expr_kind == EXPR_TYPEINFO) { TypeInfo *type_info = value->type_expr; - if (!sema_resolve_type_info(context, type_info)) return false; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false; statement->nextcase_stmt.defer_id = context_get_defers(context, context->active_scope.defer_last, parent->switch_stmt.defer, true); if (cond->type->canonical != type_typeid) { @@ -2617,7 +2617,7 @@ static inline bool sema_analyse_switch_stmt(SemaContext *context, Ast *statement if (var_switch.is_assign) { inner = expr_new(EXPR_DECL, last->span); - any_decl = decl_new_generated_var(type_any, VARDECL_LOCAL, last->span); + any_decl = decl_new_generated_var(type_anyptr, VARDECL_LOCAL, last->span); any_decl->var.init_expr = var_switch.any_expr; inner->decl_expr = any_decl; if (!sema_analyse_expr(context, inner)) return false; @@ -2627,7 +2627,7 @@ static inline bool sema_analyse_switch_stmt(SemaContext *context, Ast *statement inner = expr_new(EXPR_IDENTIFIER, last->span); any_decl = var_switch.variable; expr_resolve_ident(inner, any_decl); - inner->type = type_any; + inner->type = type_anyptr; } expr_rewrite_to_builtin_access(last, inner, ACCESS_TYPEOFANY, type_typeid); switch_type = type_typeid; @@ -2955,7 +2955,7 @@ static bool sema_analyse_optional_returns(SemaContext *context, Ast *directive) TypeInfo *type_info = ret->contract_fault.type; const char *ident = ret->contract_fault.ident; if (type_info->kind != TYPE_INFO_IDENTIFIER) RETURN_SEMA_ERROR(type_info, "Expected a fault name here."); - if (!sema_resolve_type_info(context, type_info)) return false; + if (!sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false; Type *type = type_info->type; if (type->type_kind != TYPE_FAULTTYPE) RETURN_SEMA_ERROR(type_info, "A fault type is required."); if (!ident) @@ -3053,62 +3053,7 @@ bool sema_analyse_contracts(SemaContext *context, AstId doc, AstId **asserts, So bool sema_analyse_function_body(SemaContext *context, Decl *func) { if (!decl_ok(func)) return false; - if (func->func_decl.attr_dynamic) - { - Decl *ambiguous = NULL; - Decl *private = NULL; - Decl *any = sema_resolve_type_method(context->unit, type_any, func->name, &ambiguous, &private); - if (!any) - { - SEMA_ERROR(func, "To define a '@dynamic' method, the prototype method 'any.%s(...)' must exist. Did you spell the method name right?", - func->name); - return false; - } - - Signature any_sig = any->func_decl.signature; - Signature this_sig = func->func_decl.signature; - Type *any_rtype = typeget(any_sig.rtype); - Type *this_rtype = typeget(this_sig.rtype); - if (any_rtype->canonical != this_rtype->canonical) - { - SEMA_ERROR(type_infoptr(this_sig.rtype), "The prototype method has a return type %s, but this function returns %s, they need to match.", - type_quoted_error_string(any_rtype), type_quoted_error_string(this_rtype)); - SEMA_NOTE(type_infoptr(any_sig.rtype), "The interface definition is here."); - return false; - } - Decl **any_params = any_sig.params; - Decl **this_params = this_sig.params; - unsigned any_param_count = vec_size(any_params); - unsigned this_param_count = vec_size(this_params); - if (any_param_count != this_param_count) - { - if (any_param_count > this_param_count) - { - SEMA_ERROR(func, "This function is missing parameters, %d parameters were expected.", any_param_count); - SEMA_NOTE(any_params[this_param_count], "Compare with the interface definition."); - return false; - } - else - { - SEMA_ERROR(this_params[any_param_count], "This function has too many parameters (%d).", this_param_count); - SEMA_NOTE(any, "Compare with the interface, which has only %d parameter%s.", - any_param_count, any_param_count == 1 ? "" : "s"); - } - return false; - } - FOREACH_BEGIN_IDX(i, Decl *param, this_params) - if (i == 0) continue; - if (param->type->canonical != any_params[i]->type->canonical) - { - SEMA_ERROR(vartype(param), "The prototype argument has type %s, but in this function it has type %s. Please make them match.", - type_quoted_error_string(any_params[i]->type), type_quoted_error_string(param->type)); - SEMA_NOTE(vartype(any_params[i]), "The interface definition is here."); - return false; - } - FOREACH_END(); - func->func_decl.any_prototype = declid(any); - } Signature *signature = &func->func_decl.signature; FunctionPrototype *prototype = func->type->function.prototype; assert(prototype); diff --git a/src/compiler/sema_types.c b/src/compiler/sema_types.c index c2687e678..ba5b58cc5 100644 --- a/src/compiler/sema_types.c +++ b/src/compiler/sema_types.c @@ -4,18 +4,19 @@ #include "sema_internal.h" -static inline bool sema_resolve_ptr_type(SemaContext *context, TypeInfo *type_info, bool allow_inferred); -static inline bool sema_resolve_array_type(SemaContext *context, TypeInfo *type, bool allow_inferred, bool shallow); -static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, bool allow_inferred_type, bool is_pointee); + +static inline bool sema_resolve_ptr_type(SemaContext *context, TypeInfo *type_info, ResolveTypeKind resolve_kind); +static inline bool sema_resolve_array_type(SemaContext *context, TypeInfo *type, ResolveTypeKind resolve_kind); +static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, ResolveTypeKind resolve_kind); INLINE bool sema_resolve_vatype(SemaContext *context, TypeInfo *type_info); -INLINE bool sema_resolve_evaltype(SemaContext *context, TypeInfo *type_info, bool is_pointee); +INLINE bool sema_resolve_evaltype(SemaContext *context, TypeInfo *type_info, ResolveTypeKind resolve_kind); INLINE bool sema_resolve_typefrom(SemaContext *context, TypeInfo *type_info); INLINE bool sema_resolve_typeof(SemaContext *context, TypeInfo *type_info); -static inline bool sema_resolve_ptr_type(SemaContext *context, TypeInfo *type_info, bool allow_inferred) +static inline bool sema_resolve_ptr_type(SemaContext *context, TypeInfo *type_info, ResolveTypeKind resolve_kind) { // Try to resolve this type shallowly. - if (!sema_resolve_type(context, type_info->pointer, allow_inferred, true)) + if (!sema_resolve_type(context, type_info->pointer, resolve_kind | RESOLVE_TYPE_PTR)) { return type_info_poison(type_info); } @@ -25,14 +26,9 @@ static inline bool sema_resolve_ptr_type(SemaContext *context, TypeInfo *type_in return true; } -bool sema_resolve_type_info(SemaContext *context, TypeInfo *type_info) +bool sema_resolve_type_info(SemaContext *context, TypeInfo *type_info, ResolveTypeKind kind) { - return sema_resolve_type_info_maybe_inferred(context, type_info, false); -} - -bool sema_resolve_type_info_maybe_inferred(SemaContext *context, TypeInfo *type_info, bool allow_inferred_type) -{ - return sema_resolve_type(context, type_info, allow_inferred_type, false); + return sema_resolve_type(context, type_info, kind); } bool sema_resolve_array_like_len(SemaContext *context, TypeInfo *type_info, ArraySize *len_ref) @@ -99,21 +95,21 @@ bool sema_resolve_array_like_len(SemaContext *context, TypeInfo *type_info, Arra } // TODO cleanup. -static inline bool sema_resolve_array_type(SemaContext *context, TypeInfo *type, bool allow_inferred, bool shallow) +static inline bool sema_resolve_array_type(SemaContext *context, TypeInfo *type, ResolveTypeKind resolve_type_kind) { TypeInfoKind kind = type->kind; // We can resolve the base type in a shallow way if we don't use it to determine // length and alignment - if (kind == TYPE_INFO_SUBARRAY || shallow) + if (kind == TYPE_INFO_SUBARRAY || (resolve_type_kind & RESOLVE_TYPE_IS_POINTEE)) { - if (!sema_resolve_type(context, type->array.base, allow_inferred, true)) + if (!sema_resolve_type(context, type->array.base, resolve_type_kind)) { return type_info_poison(type); } } else { - if (!sema_resolve_type_info_maybe_inferred(context, type->array.base, allow_inferred)) + if (!sema_resolve_type(context, type->array.base, resolve_type_kind & ~RESOLVE_TYPE_IS_POINTEE)) { return type_info_poison(type); } @@ -234,6 +230,7 @@ static bool sema_resolve_type_identifier(SemaContext *context, TypeInfo *type_in case DECL_UNION: case DECL_FAULT: case DECL_ENUM: + case DECL_PROTOCOL: type_info->type = decl->type; type_info->resolve_status = RESOLVE_DONE; DEBUG_LOG("Resolved %s.", type_info->unresolved.name); @@ -290,7 +287,7 @@ static bool sema_resolve_type_identifier(SemaContext *context, TypeInfo *type_in // $evaltype("Foo") -INLINE bool sema_resolve_evaltype(SemaContext *context, TypeInfo *type_info, bool is_pointee) +INLINE bool sema_resolve_evaltype(SemaContext *context, TypeInfo *type_info, ResolveTypeKind resolve_kind) { Expr *expr = type_info->unresolved_type_expr; Expr *inner = sema_ct_eval_expr(context, "$evaltype", expr, true); @@ -301,7 +298,7 @@ INLINE bool sema_resolve_evaltype(SemaContext *context, TypeInfo *type_info, boo return false; } TypeInfo *inner_type = inner->type_expr; - if (!sema_resolve_type(context, inner_type, false, is_pointee)) return false; + if (!sema_resolve_type(context, inner_type, resolve_kind)) return false; if (type_is_invalid_storage_type(inner_type->type)) { SEMA_ERROR(expr, "Compile-time types may not be used with $evaltype."); @@ -377,10 +374,27 @@ INLINE bool sema_resolve_generic_type(SemaContext *context, TypeInfo *type_info) return true; } -static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, bool allow_inferred_type, bool is_pointee) +static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, ResolveTypeKind resolve_type_kind) { // Ok, already resolved. - if (type_info->resolve_status == RESOLVE_DONE) return type_info_ok(type_info); + if (type_info->resolve_status == RESOLVE_DONE) + { + if (!type_info_ok(type_info)) return false; + if (!(resolve_type_kind & RESOLVE_TYPE_ALLOW_ANY)) + { + switch (type_no_optional(type_info->type)->canonical->type_kind) + { + case TYPE_ANY: + case TYPE_PROTOCOL: + RETURN_SEMA_ERROR(type_info, "%s has no valid runtime size, you should use '%s' instead.", + type_quoted_error_string(type_no_optional(type_info->type)), + type_quoted_error_string(type_get_ptr(type_no_optional(type_info->type)))); + default: + break; + } + } + return true; + } // We might have the resolve already running, if so then that's bad. if (type_info->resolve_status == RESOLVE_RUNNING) @@ -402,9 +416,22 @@ static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, // Type compression means we don't need that many nested type infos. TypeInfoCompressedKind kind = type_info->subtype; - if (kind != TYPE_COMPRESSED_NONE) + switch (kind) { - is_pointee = true; + case TYPE_COMPRESSED_NONE: + break; + case TYPE_COMPRESSED_PTR: + case TYPE_COMPRESSED_PTRPTR: + case TYPE_COMPRESSED_PTRSUB: + resolve_type_kind |= RESOLVE_TYPE_PTR; + break; + case TYPE_COMPRESSED_SUB: + case TYPE_COMPRESSED_SUBPTR: + case TYPE_COMPRESSED_SUBSUB: + resolve_type_kind |= RESOLVE_TYPE_IS_POINTEE; + break; + default: + UNREACHABLE } switch (type_info->kind) @@ -423,7 +450,7 @@ static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, if (!sema_resolve_type_identifier(context, type_info)) return type_info_poison(type_info); goto APPEND_QUALIFIERS; case TYPE_INFO_EVALTYPE: - if (!sema_resolve_evaltype(context, type_info, is_pointee)) return type_info_poison(type_info); + if (!sema_resolve_evaltype(context, type_info, resolve_type_kind)) return type_info_poison(type_info); goto APPEND_QUALIFIERS; case TYPE_INFO_TYPEOF: if (!sema_resolve_typeof(context, type_info)) return type_info_poison(type_info); @@ -433,7 +460,7 @@ static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, goto APPEND_QUALIFIERS; case TYPE_INFO_INFERRED_ARRAY: case TYPE_INFO_INFERRED_VECTOR: - if (!allow_inferred_type) + if (!(resolve_type_kind & RESOLVE_TYPE_ALLOW_INFER)) { SEMA_ERROR(type_info, "Inferred %s types can only be used in declarations with initializers and as macro parameters.", type_info->kind == TYPE_INFO_INFERRED_VECTOR ? "vector" : "array"); @@ -443,16 +470,37 @@ static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, case TYPE_INFO_SUBARRAY: case TYPE_INFO_ARRAY: case TYPE_INFO_VECTOR: - if (!sema_resolve_array_type(context, type_info, allow_inferred_type, is_pointee)) + if (!sema_resolve_array_type(context, type_info, resolve_type_kind)) { return type_info_poison(type_info); } break; case TYPE_INFO_POINTER: - if (!sema_resolve_ptr_type(context, type_info, allow_inferred_type)) return type_info_poison(type_info); + if (!sema_resolve_ptr_type(context, type_info, resolve_type_kind)) return type_info_poison(type_info); break; } APPEND_QUALIFIERS: + switch (type_info->type->type_kind) + { + case TYPE_ANY: + if (!(resolve_type_kind & RESOLVE_TYPE_ALLOW_ANY)) + { + SEMA_ERROR(type_info, "An 'any' has undefined size, please use 'any*' instead."); + return type_info_poison(type_info); + } + break; + case TYPE_PROTOCOL: + if (!(resolve_type_kind & RESOLVE_TYPE_ALLOW_ANY)) + { + SEMA_ERROR(type_info, "%s is a protocol and has undefined size, please use %s instead.", + type_quoted_error_string(type_info->type), + type_quoted_error_string(type_get_ptr(type_info->type))); + return type_info_poison(type_info); + } + break; + default: + break; + } switch (kind) { case TYPE_COMPRESSED_NONE: diff --git a/src/compiler/semantic_analyser.c b/src/compiler/semantic_analyser.c index e6ff34b41..34a88dcc3 100644 --- a/src/compiler/semantic_analyser.c +++ b/src/compiler/semantic_analyser.c @@ -208,6 +208,7 @@ static void register_generic_decls(CompilationUnit *unit, Decl **decls) case DECL_UNION: case DECL_VAR: case DECL_BITSTRUCT: + case DECL_PROTOCOL: break; } htable_set(&unit->module->symbols, (void *)decl->name, decl); @@ -293,7 +294,7 @@ static void assign_panicfn(void) error_exit("'%s' is not a function function.", panicf); } if (!type_func_match(type_get_ptr(panicf_fn_type), type_void, 5, type_string, type_string, type_string, type_uint, - type_get_subarray(type_any))) + type_get_subarray(type_anyptr))) { error_exit("Expected panic function to have the signature fn void(String, String, String, uint, ...)."); } diff --git a/src/compiler/symtab.c b/src/compiler/symtab.c index 2892d3800..0a0bf3c82 100644 --- a/src/compiler/symtab.c +++ b/src/compiler/symtab.c @@ -193,6 +193,7 @@ void symtab_init(uint32_t capacity) type_property_list[TYPE_PROPERTY_VALUES] = KW_DEF("values"); builtin_list[BUILTIN_ABS] = KW_DEF("abs"); + builtin_list[BUILTIN_ANY_MAKE] = KW_DEF("any_make"); builtin_list[BUILTIN_ATOMIC_LOAD] = KW_DEF("atomic_load"); builtin_list[BUILTIN_ATOMIC_STORE] = KW_DEF("atomic_store"); builtin_list[BUILTIN_ATOMIC_FETCH_ADD] = KW_DEF("atomic_fetch_add"); @@ -321,14 +322,12 @@ void symtab_init(uint32_t capacity) attribute_list[ATTRIBUTE_BUILTIN] = KW_DEF("@builtin"); attribute_list[ATTRIBUTE_CALLCONV] = KW_DEF("@callconv"); attribute_list[ATTRIBUTE_DEPRECATED] = KW_DEF("@deprecated"); - attribute_list[ATTRIBUTE_DYNAMIC] = KW_DEF("@dynamic"); attribute_list[ATTRIBUTE_EXPORT] = KW_DEF("@export"); attribute_list[ATTRIBUTE_EXTERN] = KW_DEF("@extern"); attribute_list[ATTRIBUTE_FINALIZER] = KW_DEF("@finalizer"); attribute_list[ATTRIBUTE_IF] = KW_DEF("@if"); attribute_list[ATTRIBUTE_INIT] = KW_DEF("@init"); attribute_list[ATTRIBUTE_INLINE] = KW_DEF("@inline"); - attribute_list[ATTRIBUTE_INTERFACE] = KW_DEF("@interface"); attribute_list[ATTRIBUTE_LITTLEENDIAN] = KW_DEF("@littleendian"); attribute_list[ATTRIBUTE_LOCAL] = KW_DEF("@local"); attribute_list[ATTRIBUTE_MAYDISCARD] = KW_DEF("@maydiscard"); @@ -340,6 +339,7 @@ void symtab_init(uint32_t capacity) attribute_list[ATTRIBUTE_NOSTRIP] = KW_DEF("@nostrip"); attribute_list[ATTRIBUTE_OBFUSCATE] = KW_DEF("@obfuscate"); attribute_list[ATTRIBUTE_OPERATOR] = KW_DEF("@operator"); + attribute_list[ATTRIBUTE_OPTIONAL] = KW_DEF("@optional"); attribute_list[ATTRIBUTE_OVERLAP] = KW_DEF("@overlap"); attribute_list[ATTRIBUTE_PACKED] = KW_DEF("@packed"); attribute_list[ATTRIBUTE_PRIVATE] = KW_DEF("@private"); diff --git a/src/compiler/tokens.c b/src/compiler/tokens.c index 06044f851..5622509c9 100644 --- a/src/compiler/tokens.c +++ b/src/compiler/tokens.c @@ -247,6 +247,8 @@ const char *token_type_to_string(TokenType type) return "nextcase"; case TOKEN_NULL: return "null"; + case TOKEN_PROTOCOL: + return "protocol"; case TOKEN_RETURN: return "return"; case TOKEN_STATIC: diff --git a/src/compiler/types.c b/src/compiler/types.c index 62694980f..5751ebff8 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -14,7 +14,7 @@ static struct Type usz, isz, uptr, iptr; Type string; Type voidstar, typeid, anyfault, member, typeinfo, untyped_list; - Type any, wildcard; + Type any, anyptr, wildcard; } t; Type *type_bool = &t.u1; @@ -26,6 +26,7 @@ Type *type_double = &t.f64; Type *type_f128 = &t.f128; Type *type_typeid = &t.typeid; Type *type_any = &t.any; +Type *type_anyptr = &t.anyptr; Type *type_typeinfo = &t.typeinfo; Type *type_ichar = &t.i8; Type *type_short = &t.i16; @@ -120,8 +121,11 @@ static void type_append_name_to_scratch(Type *type) case TYPE_UNION: case TYPE_DISTINCT: case TYPE_BITSTRUCT: + case TYPE_PROTOCOL: scratch_buffer_append(type->decl->name); break; + case TYPE_PROPTR: + case TYPE_ANYPTR: case TYPE_POINTER: type_append_name_to_scratch(type->pointer); scratch_buffer_append_char('*'); @@ -210,6 +214,7 @@ const char *type_to_error_string(Type *type) case TYPE_ANY: case TYPE_MEMBER: case TYPE_WILDCARD: + case TYPE_ANYPTR: return type->name; case TYPE_ENUM: case TYPE_FAULTTYPE: @@ -218,6 +223,7 @@ const char *type_to_error_string(Type *type) case TYPE_UNION: case TYPE_DISTINCT: case TYPE_BITSTRUCT: + case TYPE_PROTOCOL: { Decl *decl = type->decl; if (!decl || !decl->unit || !decl->unit->module->generic_suffix) return type->name; @@ -240,6 +246,7 @@ const char *type_to_error_string(Type *type) return "typeinfo"; case TYPE_TYPEID: return "typeid"; + case TYPE_PROPTR: case TYPE_POINTER: if (type->pointer->type_kind == TYPE_FUNC) { @@ -306,14 +313,18 @@ TypeSize type_size(Type *type) assert(type->decl->resolve_status == RESOLVE_DONE); return type->decl->strukt.size; case TYPE_VOID: + case TYPE_PROTOCOL: + case TYPE_ANY: return 1; case TYPE_BOOL: case TYPE_TYPEID: case ALL_INTS: case ALL_FLOATS: case TYPE_ANYFAULT: - case TYPE_ANY: return type->builtin.bytesize; + case TYPE_PROPTR: + case TYPE_ANYPTR: + return t.iptr.canonical->builtin.bytesize * 2; case TYPE_FUNC: case TYPE_POINTER: return t.iptr.canonical->builtin.bytesize; @@ -401,12 +412,15 @@ bool type_is_abi_aggregate(Type *type) case TYPE_VECTOR: case TYPE_ANYFAULT: case TYPE_FAULTTYPE: + case TYPE_ANY: + case TYPE_PROTOCOL: return false; case TYPE_STRUCT: case TYPE_UNION: case TYPE_SUBARRAY: case TYPE_ARRAY: - case TYPE_ANY: + case TYPE_ANYPTR: + case TYPE_PROPTR: return true; case CT_TYPES: case TYPE_FLEXIBLE_ARRAY: @@ -473,6 +487,8 @@ bool type_is_comparable(Type *type) case TYPE_FLEXIBLE_ARRAY: case TYPE_OPTIONAL: case TYPE_MEMBER: + case TYPE_ANY: + case TYPE_PROTOCOL: return false; case TYPE_TYPEDEF: type = type->canonical; @@ -488,7 +504,8 @@ bool type_is_comparable(Type *type) case TYPE_BOOL: case ALL_INTS: case ALL_FLOATS: - case TYPE_ANY: + case TYPE_ANYPTR: + case TYPE_PROPTR: case TYPE_ANYFAULT: case TYPE_TYPEID: case TYPE_POINTER: @@ -509,16 +526,20 @@ void type_mangle_introspect_name_to_buffer(Type *type) switch (type->type_kind) { case CT_TYPES: + case TYPE_ANY: UNREACHABLE + case TYPE_ANYPTR: + scratch_buffer_append("any$"); + return; case TYPE_VOID: case TYPE_BOOL: case ALL_INTS: case ALL_FLOATS: - case TYPE_ANY: case TYPE_ANYFAULT: case TYPE_TYPEID: scratch_buffer_append(type->name); return; + case TYPE_PROPTR: case TYPE_POINTER: scratch_buffer_append("p$"); type_mangle_introspect_name_to_buffer(type->pointer); @@ -585,6 +606,7 @@ void type_mangle_introspect_name_to_buffer(Type *type) case TYPE_BITSTRUCT: case TYPE_FAULTTYPE: case TYPE_DISTINCT: + case TYPE_PROTOCOL: scratch_buffer_append(type->decl->extname); return; case TYPE_TYPEDEF: @@ -643,6 +665,8 @@ AlignSize type_abi_alignment(Type *type) return alignment; } case TYPE_VOID: + case TYPE_PROTOCOL: + case TYPE_ANY: return 1; case TYPE_OPTIONAL: type = type->optional; @@ -665,10 +689,11 @@ AlignSize type_abi_alignment(Type *type) case TYPE_BOOL: case ALL_INTS: case ALL_FLOATS: - case TYPE_ANY: case TYPE_ANYFAULT: return type->builtin.abi_alignment; case TYPE_FUNC: + case TYPE_PROPTR: + case TYPE_ANYPTR: case TYPE_POINTER: case TYPE_TYPEID: return t.iptr.canonical->builtin.abi_alignment; @@ -702,7 +727,7 @@ static Type *type_generate_ptr(Type *ptr_type, bool canonical) Type *ptr = ptr_type->type_cache[PTR_OFFSET]; if (ptr == NULL) { - ptr = type_new(TYPE_POINTER, str_printf("%s*", ptr_type->name)); + ptr = type_new(ptr_type->type_kind == TYPE_PROTOCOL ? TYPE_PROPTR : TYPE_POINTER, str_printf("%s*", ptr_type->name)); ptr->pointer = ptr_type; ptr_type->type_cache[PTR_OFFSET] = ptr; if (ptr_type == ptr_type->canonical) @@ -1119,7 +1144,8 @@ bool type_is_valid_for_array(Type *type) assert(!type->decl || type->decl->resolve_status == RESOLVE_DONE); type = type->decl->distinct_decl.base_type; goto RETRY; - case TYPE_ANY: + case TYPE_ANYPTR: + case TYPE_PROPTR: case TYPE_ANYFAULT: case TYPE_TYPEID: case TYPE_POINTER: @@ -1152,6 +1178,8 @@ bool type_is_valid_for_array(Type *type) case TYPE_MEMBER: case TYPE_POISONED: case TYPE_VOID: + case TYPE_ANY: + case TYPE_PROTOCOL: return false; } UNREACHABLE @@ -1510,7 +1538,11 @@ void type_setup(PlatformTarget *target) create_type_cache(type_void); type_void->type_cache[0] = &t.voidstar; t.voidstar.pointer = type_void; - type_init("any", &t.any, TYPE_ANY, target->width_pointer * 2, target->align_pointer); + type_create("any", &t.any, TYPE_ANY, 1, 1, 1); + type_init("any*", &t.anyptr, TYPE_ANYPTR, target->width_pointer * 2, target->align_pointer); + create_type_cache(type_any); + type_any->type_cache[0] = &t.anyptr; + t.anyptr.pointer = type_any; type_create_alias("usz", &t.usz, type_int_unsigned_by_bitsize(target->width_pointer)); type_create_alias("isz", &t.isz, type_int_signed_by_bitsize(target->width_pointer)); @@ -1565,6 +1597,8 @@ bool type_is_scalar(Type *type) switch (type->type_kind) { case CT_TYPES: + case TYPE_PROTOCOL: + case TYPE_ANY: UNREACHABLE case TYPE_VOID: case TYPE_FUNC: @@ -1573,7 +1607,8 @@ bool type_is_scalar(Type *type) case TYPE_ARRAY: case TYPE_SUBARRAY: case TYPE_VECTOR: - case TYPE_ANY: + case TYPE_ANYPTR: + case TYPE_PROPTR: case TYPE_FLEXIBLE_ARRAY: return false; case TYPE_BOOL: @@ -1839,6 +1874,7 @@ bool type_may_have_method(Type *type) case TYPE_FLEXIBLE_ARRAY: case TYPE_VECTOR: case TYPE_BOOL: + case TYPE_PROTOCOL: return true; case TYPE_TYPEDEF: UNREACHABLE @@ -1851,6 +1887,8 @@ bool type_may_have_method(Type *type) case TYPE_TYPEINFO: case TYPE_MEMBER: case TYPE_WILDCARD: + case TYPE_ANYPTR: + case TYPE_PROPTR: return false; } UNREACHABLE @@ -1867,6 +1905,7 @@ bool type_may_have_sub_elements(Type *type) case TYPE_ENUM: case TYPE_FAULTTYPE: case TYPE_BITSTRUCT: + case TYPE_PROPTR: return true; default: return false; @@ -2027,10 +2066,18 @@ Type *type_find_max_type(Type *type, Type *other) case TYPE_OPTIONAL: case TYPE_WILDCARD: UNREACHABLE + case TYPE_PROTOCOL: + case TYPE_ANY: + return NULL; + case TYPE_ANYPTR: + // any + protocol => any + return other->type_kind == TYPE_PROPTR ? type : NULL; + case TYPE_PROPTR: + // protocol + protocol => any + return other->type_kind == TYPE_PROPTR ? type_any : NULL; case TYPE_VOID: case TYPE_BOOL: case TYPE_TYPEINFO: - case TYPE_ANY: case TYPE_BITSTRUCT: case TYPE_FLEXIBLE_ARRAY: return NULL; @@ -2198,9 +2245,13 @@ unsigned type_get_introspection_kind(TypeKind kind) return INTROSPECT_TYPE_ANY; case TYPE_ANYFAULT: return INTROSPECT_TYPE_ANYFAULT; + case TYPE_PROTOCOL: + return INTROSPECT_TYPE_PROTOCOL; case TYPE_TYPEID: return INTROSPECT_TYPE_TYPEID; case TYPE_POINTER: + case TYPE_ANYPTR: + case TYPE_PROPTR: return INTROSPECT_TYPE_POINTER; case TYPE_ENUM: return INTROSPECT_TYPE_ENUM; @@ -2249,10 +2300,12 @@ Module *type_base_module(Type *type) case ALL_FLOATS: case TYPE_BOOL: case TYPE_ANY: + case TYPE_ANYPTR: case TYPE_ANYFAULT: case TYPE_TYPEID: case TYPE_WILDCARD: return NULL; + case TYPE_PROPTR: case TYPE_POINTER: type = type->pointer; goto RETRY; @@ -2264,6 +2317,7 @@ Module *type_base_module(Type *type) case TYPE_BITSTRUCT: case TYPE_FAULTTYPE: case TYPE_DISTINCT: + case TYPE_PROTOCOL: return type->decl->unit ? type->decl->unit->module : NULL; case TYPE_TYPEDEF: type = type->canonical; diff --git a/src/version.h b/src/version.h index 717b976e1..7c646191a 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.668" \ No newline at end of file +#define COMPILER_VERSION "0.4.669" \ No newline at end of file diff --git a/test/test_suite/any/any_in_any.c3t b/test/test_suite/any/any_in_any.c3t new file mode 100644 index 000000000..5b00671b5 --- /dev/null +++ b/test/test_suite/any/any_in_any.c3t @@ -0,0 +1,37 @@ +// #target: macos-x64 +module foo; +fn void main() +{ + any* x; + x = &x; + x = &&(&x); + x = &&(&&(&x)); +} +/* #expect: foo.ll + +%"any*" = type { ptr, i64 } +@"$ct.any$" = linkonce global %.introspect { i8 7, i64 0, ptr null, i64 16, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 +@"$ct.p$any$" = linkonce global %.introspect { i8 19, i64 0, ptr null, i64 8, i64 ptrtoint (ptr @"$ct.any$" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 +@"$ct.p$p$any$" = linkonce global %.introspect { i8 19, i64 0, ptr null, i64 8, i64 ptrtoint (ptr @"$ct.p$any$" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 + +define void @foo.main() #0 { +entry: + %x = alloca %"any*", align 8 + %taddr = alloca ptr, align 8 + %taddr1 = alloca ptr, align 8 + %taddr2 = alloca ptr, align 8 + store %"any*" zeroinitializer, ptr %x, align 8 + %0 = insertvalue %"any*" undef, ptr %x, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.any$" to i64), 1 + store %"any*" %1, ptr %x, align 8 + store ptr %x, ptr %taddr, align 8 + %2 = insertvalue %"any*" undef, ptr %taddr, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.p$any$" to i64), 1 + store %"any*" %3, ptr %x, align 8 + store ptr %x, ptr %taddr1, align 8 + store ptr %taddr1, ptr %taddr2, align 8 + %4 = insertvalue %"any*" undef, ptr %taddr2, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.p$p$any$" to i64), 1 + store %"any*" %5, ptr %x, align 8 + ret void +} diff --git a/test/test_suite/variant/variant_assign.c3t b/test/test_suite/any/variant_assign.c3t similarity index 83% rename from test/test_suite/variant/variant_assign.c3t rename to test/test_suite/any/variant_assign.c3t index ef9eb298d..03369b7e3 100644 --- a/test/test_suite/variant/variant_assign.c3t +++ b/test/test_suite/any/variant_assign.c3t @@ -3,7 +3,7 @@ module foo; extern fn void printf(char*, ...); -fn void test(any z) +fn void test(any* z) { switch (z) { @@ -15,7 +15,7 @@ fn void test(any z) printf("Unknown type.\n"); } } -fn void test2(any y) +fn void test2(any* y) { switch (z = y) { @@ -29,7 +29,7 @@ fn void test2(any y) } } -fn void test3(any y) +fn void test3(any* y) { switch (z = *y) { @@ -64,14 +64,14 @@ fn int main() define void @foo.test(i64 %0, ptr %1) #0 { entry: - %z = alloca %any, align 8 + %z = alloca %"any*", align 8 %switch = alloca i64, align 8 %z1 = alloca ptr, align 8 %z8 = alloca ptr, align 8 store i64 %0, ptr %z, align 8 %ptroffset = getelementptr inbounds ptr, ptr %z, i64 1 store ptr %1, ptr %ptroffset, align 8 - %2 = getelementptr inbounds %any, ptr %z, i32 0, i32 1 + %2 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 1 %3 = load i64, ptr %2, align 8 store i64 %3, ptr %switch, align 8 br label %switch.entry @@ -97,7 +97,7 @@ result_block: ; preds = %parent_type_block, br i1 %9, label %switch.case, label %next_if switch.case: ; preds = %result_block - %10 = getelementptr inbounds %any, ptr %z, i32 0, i32 0 + %10 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 0 %11 = load ptr, ptr %10, align 8 store ptr %11, ptr %z1, align 8 %12 = load ptr, ptr %z1, align 8 @@ -125,7 +125,7 @@ result_block6: ; preds = %parent_type_block4, br i1 %18, label %switch.case7, label %next_if9 switch.case7: ; preds = %result_block6 - %19 = getelementptr inbounds %any, ptr %z, i32 0, i32 0 + %19 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 0 %20 = load ptr, ptr %19, align 8 store ptr %20, ptr %z8, align 8 %21 = load ptr, ptr %z8, align 8 @@ -147,8 +147,8 @@ switch.exit: ; preds = %switch.default, %sw ; Function Attrs: nounwind define void @foo.test2(i64 %0, ptr %1) #0 { entry: - %y = alloca %any, align 8 - %.anon = alloca %any, align 8 + %y = alloca %"any*", align 8 + %.anon = alloca %"any*", align 8 %switch = alloca i64, align 8 %z = alloca ptr, align 8 %taddr = alloca i32, align 4 @@ -157,7 +157,7 @@ entry: %ptroffset = getelementptr inbounds ptr, ptr %y, i64 1 store ptr %1, ptr %ptroffset, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %.anon, ptr align 8 %y, i32 16, i1 false) - %2 = getelementptr inbounds %any, ptr %y, i32 0, i32 1 + %2 = getelementptr inbounds %"any*", ptr %y, i32 0, i32 1 %3 = load i64, ptr %2, align 8 store i64 %3, ptr %switch, align 8 br label %switch.entry @@ -183,13 +183,13 @@ result_block: ; preds = %parent_type_block, br i1 %9, label %switch.case, label %next_if switch.case: ; preds = %result_block - %10 = getelementptr inbounds %any, ptr %.anon, i32 0, i32 0 + %10 = getelementptr inbounds %"any*", ptr %.anon, i32 0, i32 0 %11 = load ptr, ptr %10, align 8 store ptr %11, ptr %z, align 8 store i32 12, ptr %taddr, align 4 - %12 = insertvalue %any undef, ptr %taddr, 0 - %13 = insertvalue %any %12, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %13, ptr %y, align 8 + %12 = insertvalue %"any*" undef, ptr %taddr, 0 + %13 = insertvalue %"any*" %12, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %13, ptr %y, align 8 %14 = load ptr, ptr %z, align 8 %15 = load i32, ptr %14, align 4 call void (ptr, ...) @printf(ptr @.str.3, i32 %15) @@ -215,7 +215,7 @@ result_block5: ; preds = %parent_type_block3, br i1 %20, label %switch.case6, label %next_if8 switch.case6: ; preds = %result_block5 - %21 = getelementptr inbounds %any, ptr %.anon, i32 0, i32 0 + %21 = getelementptr inbounds %"any*", ptr %.anon, i32 0, i32 0 %22 = load ptr, ptr %21, align 8 store ptr %22, ptr %z7, align 8 %23 = load ptr, ptr %z7, align 8 @@ -234,10 +234,11 @@ switch.exit: ; preds = %switch.default, %sw ret void } +; Function Attrs: nounwind define void @foo.test3(i64 %0, ptr %1) #0 { entry: - %y = alloca %any, align 8 - %.anon = alloca %any, align 8 + %y = alloca %"any*", align 8 + %.anon = alloca %"any*", align 8 %switch = alloca i64, align 8 %z = alloca i32, align 4 %z7 = alloca double, align 8 @@ -245,7 +246,7 @@ entry: %ptroffset = getelementptr inbounds ptr, ptr %y, i64 1 store ptr %1, ptr %ptroffset, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %.anon, ptr align 8 %y, i32 16, i1 false) - %2 = getelementptr inbounds %any, ptr %y, i32 0, i32 1 + %2 = getelementptr inbounds %"any*", ptr %y, i32 0, i32 1 %3 = load i64, ptr %2, align 8 store i64 %3, ptr %switch, align 8 br label %switch.entry @@ -271,7 +272,7 @@ result_block: ; preds = %parent_type_block, br i1 %9, label %switch.case, label %next_if switch.case: ; preds = %result_block - %10 = getelementptr inbounds %any, ptr %.anon, i32 0, i32 0 + %10 = getelementptr inbounds %"any*", ptr %.anon, i32 0, i32 0 %11 = load ptr, ptr %10, align 8 %12 = load i32, ptr %11, align 4 store i32 %12, ptr %z, align 4 @@ -299,7 +300,7 @@ result_block5: ; preds = %parent_type_block3, br i1 %18, label %switch.case6, label %next_if8 switch.case6: ; preds = %result_block5 - %19 = getelementptr inbounds %any, ptr %.anon, i32 0, i32 0 + %19 = getelementptr inbounds %"any*", ptr %.anon, i32 0, i32 0 %20 = load ptr, ptr %19, align 8 %21 = load double, ptr %20, align 8 store double %21, ptr %z7, align 8 @@ -321,99 +322,99 @@ switch.exit: ; preds = %switch.default, %sw define i32 @main() #0 { entry: %taddr = alloca double, align 8 - %taddr1 = alloca %any, align 8 + %taddr1 = alloca %"any*", align 8 %taddr2 = alloca i32, align 4 - %taddr3 = alloca %any, align 8 + %taddr3 = alloca %"any*", align 8 %taddr6 = alloca i8, align 1 - %taddr7 = alloca %any, align 8 + %taddr7 = alloca %"any*", align 8 %taddr10 = alloca double, align 8 - %taddr11 = alloca %any, align 8 + %taddr11 = alloca %"any*", align 8 %taddr14 = alloca i32, align 4 - %taddr15 = alloca %any, align 8 + %taddr15 = alloca %"any*", align 8 %taddr18 = alloca i8, align 1 - %taddr19 = alloca %any, align 8 + %taddr19 = alloca %"any*", align 8 %taddr22 = alloca double, align 8 - %taddr23 = alloca %any, align 8 + %taddr23 = alloca %"any*", align 8 %taddr26 = alloca i32, align 4 - %taddr27 = alloca %any, align 8 + %taddr27 = alloca %"any*", align 8 %taddr30 = alloca i8, align 1 - %taddr31 = alloca %any, align 8 + %taddr31 = alloca %"any*", align 8 store double 1.230000e+02, ptr %taddr, align 8 - %0 = insertvalue %any undef, ptr %taddr, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.double" to i64), 1 - store %any %1, ptr %taddr1, align 8 + %0 = insertvalue %"any*" undef, ptr %taddr, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.double" to i64), 1 + store %"any*" %1, ptr %taddr1, align 8 %2 = getelementptr inbounds { i64, ptr }, ptr %taddr1, i32 0, i32 0 %lo = load i64, ptr %2, align 8 %3 = getelementptr inbounds { i64, ptr }, ptr %taddr1, i32 0, i32 1 %hi = load ptr, ptr %3, align 8 call void @foo.test(i64 %lo, ptr %hi) store i32 1, ptr %taddr2, align 4 - %4 = insertvalue %any undef, ptr %taddr2, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %5, ptr %taddr3, align 8 + %4 = insertvalue %"any*" undef, ptr %taddr2, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %5, ptr %taddr3, align 8 %6 = getelementptr inbounds { i64, ptr }, ptr %taddr3, i32 0, i32 0 %lo4 = load i64, ptr %6, align 8 %7 = getelementptr inbounds { i64, ptr }, ptr %taddr3, i32 0, i32 1 %hi5 = load ptr, ptr %7, align 8 call void @foo.test(i64 %lo4, ptr %hi5) store i8 1, ptr %taddr6, align 1 - %8 = insertvalue %any undef, ptr %taddr6, 0 - %9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - store %any %9, ptr %taddr7, align 8 + %8 = insertvalue %"any*" undef, ptr %taddr6, 0 + %9 = insertvalue %"any*" %8, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + store %"any*" %9, ptr %taddr7, align 8 %10 = getelementptr inbounds { i64, ptr }, ptr %taddr7, i32 0, i32 0 %lo8 = load i64, ptr %10, align 8 %11 = getelementptr inbounds { i64, ptr }, ptr %taddr7, i32 0, i32 1 %hi9 = load ptr, ptr %11, align 8 call void @foo.test(i64 %lo8, ptr %hi9) store double 1.235000e+02, ptr %taddr10, align 8 - %12 = insertvalue %any undef, ptr %taddr10, 0 - %13 = insertvalue %any %12, i64 ptrtoint (ptr @"$ct.double" to i64), 1 - store %any %13, ptr %taddr11, align 8 + %12 = insertvalue %"any*" undef, ptr %taddr10, 0 + %13 = insertvalue %"any*" %12, i64 ptrtoint (ptr @"$ct.double" to i64), 1 + store %"any*" %13, ptr %taddr11, align 8 %14 = getelementptr inbounds { i64, ptr }, ptr %taddr11, i32 0, i32 0 %lo12 = load i64, ptr %14, align 8 %15 = getelementptr inbounds { i64, ptr }, ptr %taddr11, i32 0, i32 1 %hi13 = load ptr, ptr %15, align 8 call void @foo.test2(i64 %lo12, ptr %hi13) store i32 1, ptr %taddr14, align 4 - %16 = insertvalue %any undef, ptr %taddr14, 0 - %17 = insertvalue %any %16, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %17, ptr %taddr15, align 8 + %16 = insertvalue %"any*" undef, ptr %taddr14, 0 + %17 = insertvalue %"any*" %16, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %17, ptr %taddr15, align 8 %18 = getelementptr inbounds { i64, ptr }, ptr %taddr15, i32 0, i32 0 %lo16 = load i64, ptr %18, align 8 %19 = getelementptr inbounds { i64, ptr }, ptr %taddr15, i32 0, i32 1 %hi17 = load ptr, ptr %19, align 8 call void @foo.test2(i64 %lo16, ptr %hi17) store i8 1, ptr %taddr18, align 1 - %20 = insertvalue %any undef, ptr %taddr18, 0 - %21 = insertvalue %any %20, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - store %any %21, ptr %taddr19, align 8 + %20 = insertvalue %"any*" undef, ptr %taddr18, 0 + %21 = insertvalue %"any*" %20, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + store %"any*" %21, ptr %taddr19, align 8 %22 = getelementptr inbounds { i64, ptr }, ptr %taddr19, i32 0, i32 0 %lo20 = load i64, ptr %22, align 8 %23 = getelementptr inbounds { i64, ptr }, ptr %taddr19, i32 0, i32 1 %hi21 = load ptr, ptr %23, align 8 call void @foo.test2(i64 %lo20, ptr %hi21) store double 1.240000e+02, ptr %taddr22, align 8 - %24 = insertvalue %any undef, ptr %taddr22, 0 - %25 = insertvalue %any %24, i64 ptrtoint (ptr @"$ct.double" to i64), 1 - store %any %25, ptr %taddr23, align 8 + %24 = insertvalue %"any*" undef, ptr %taddr22, 0 + %25 = insertvalue %"any*" %24, i64 ptrtoint (ptr @"$ct.double" to i64), 1 + store %"any*" %25, ptr %taddr23, align 8 %26 = getelementptr inbounds { i64, ptr }, ptr %taddr23, i32 0, i32 0 %lo24 = load i64, ptr %26, align 8 %27 = getelementptr inbounds { i64, ptr }, ptr %taddr23, i32 0, i32 1 %hi25 = load ptr, ptr %27, align 8 call void @foo.test3(i64 %lo24, ptr %hi25) store i32 2, ptr %taddr26, align 4 - %28 = insertvalue %any undef, ptr %taddr26, 0 - %29 = insertvalue %any %28, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %29, ptr %taddr27, align 8 + %28 = insertvalue %"any*" undef, ptr %taddr26, 0 + %29 = insertvalue %"any*" %28, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %29, ptr %taddr27, align 8 %30 = getelementptr inbounds { i64, ptr }, ptr %taddr27, i32 0, i32 0 %lo28 = load i64, ptr %30, align 8 %31 = getelementptr inbounds { i64, ptr }, ptr %taddr27, i32 0, i32 1 %hi29 = load ptr, ptr %31, align 8 call void @foo.test3(i64 %lo28, ptr %hi29) store i8 1, ptr %taddr30, align 1 - %32 = insertvalue %any undef, ptr %taddr30, 0 - %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - store %any %33, ptr %taddr31, align 8 + %32 = insertvalue %"any*" undef, ptr %taddr30, 0 + %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + store %"any*" %33, ptr %taddr31, align 8 %34 = getelementptr inbounds { i64, ptr }, ptr %taddr31, i32 0, i32 0 %lo32 = load i64, ptr %34, align 8 %35 = getelementptr inbounds { i64, ptr }, ptr %taddr31, i32 0, i32 1 diff --git a/test/test_suite/variant/variant_switch.c3t b/test/test_suite/any/variant_switch.c3t similarity index 85% rename from test/test_suite/variant/variant_switch.c3t rename to test/test_suite/any/variant_switch.c3t index 9a2e75f28..46d8b1676 100644 --- a/test/test_suite/variant/variant_switch.c3t +++ b/test/test_suite/any/variant_switch.c3t @@ -3,7 +3,7 @@ module foo; extern fn void printf(char*, ...); -fn void test(any z) +fn void test(any* z) { switch (z) { @@ -36,14 +36,14 @@ fn int main() define void @foo.test(i64 %0, ptr %1) #0 { entry: - %z = alloca %any, align 8 + %z = alloca %"any*", align 8 %switch = alloca i64, align 8 %z1 = alloca ptr, align 8 %z8 = alloca ptr, align 8 store i64 %0, ptr %z, align 8 %ptroffset = getelementptr inbounds ptr, ptr %z, i64 1 store ptr %1, ptr %ptroffset, align 8 - %2 = getelementptr inbounds %any, ptr %z, i32 0, i32 1 + %2 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 1 %3 = load i64, ptr %2, align 8 store i64 %3, ptr %switch, align 8 br label %switch.entry @@ -69,7 +69,7 @@ result_block: ; preds = %parent_type_block, br i1 %9, label %switch.case, label %next_if switch.case: ; preds = %result_block - %10 = getelementptr inbounds %any, ptr %z, i32 0, i32 0 + %10 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 0 %11 = load ptr, ptr %10, align 8 store ptr %11, ptr %z1, align 8 %12 = load ptr, ptr %z1, align 8 @@ -99,7 +99,7 @@ result_block6: ; preds = %parent_type_block4, br i1 %19, label %switch.case7, label %next_if9 switch.case7: ; preds = %result_block6 - %20 = getelementptr inbounds %any, ptr %z, i32 0, i32 0 + %20 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 0 %21 = load ptr, ptr %20, align 8 store ptr %21, ptr %z8, align 8 %22 = load ptr, ptr %z8, align 8 @@ -115,13 +115,13 @@ switch.default: ; preds = %next_if9 br label %switch.exit switch.exit: ; preds = %switch.default, %switch.case7, %switch.case - %24 = getelementptr inbounds %any, ptr %z, i32 0, i32 1 + %24 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 1 %25 = load i64, ptr %24, align 8 %eq10 = icmp eq i64 %25, ptrtoint (ptr @"$ct.int" to i64) br i1 %eq10, label %if.then, label %if.exit if.then: ; preds = %switch.exit - %26 = getelementptr inbounds %any, ptr %z, i32 0, i32 0 + %26 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 0 %27 = load ptr, ptr %26, align 8 %28 = load i32, ptr %27, align 4 call void (ptr, ...) @printf(ptr @.str.3, i32 %28) @@ -135,33 +135,33 @@ if.exit: ; preds = %if.then, %switch.ex define i32 @main() #0 { entry: %taddr = alloca double, align 8 - %taddr1 = alloca %any, align 8 + %taddr1 = alloca %"any*", align 8 %taddr2 = alloca i32, align 4 - %taddr3 = alloca %any, align 8 + %taddr3 = alloca %"any*", align 8 %taddr6 = alloca i8, align 1 - %taddr7 = alloca %any, align 8 + %taddr7 = alloca %"any*", align 8 store double 1.230000e+02, ptr %taddr, align 8 - %0 = insertvalue %any undef, ptr %taddr, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.double" to i64), 1 - store %any %1, ptr %taddr1, align 8 + %0 = insertvalue %"any*" undef, ptr %taddr, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.double" to i64), 1 + store %"any*" %1, ptr %taddr1, align 8 %2 = getelementptr inbounds { i64, ptr }, ptr %taddr1, i32 0, i32 0 %lo = load i64, ptr %2, align 8 %3 = getelementptr inbounds { i64, ptr }, ptr %taddr1, i32 0, i32 1 %hi = load ptr, ptr %3, align 8 call void @foo.test(i64 %lo, ptr %hi) store i32 1, ptr %taddr2, align 4 - %4 = insertvalue %any undef, ptr %taddr2, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %5, ptr %taddr3, align 8 + %4 = insertvalue %"any*" undef, ptr %taddr2, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %5, ptr %taddr3, align 8 %6 = getelementptr inbounds { i64, ptr }, ptr %taddr3, i32 0, i32 0 %lo4 = load i64, ptr %6, align 8 %7 = getelementptr inbounds { i64, ptr }, ptr %taddr3, i32 0, i32 1 %hi5 = load ptr, ptr %7, align 8 call void @foo.test(i64 %lo4, ptr %hi5) store i8 1, ptr %taddr6, align 1 - %8 = insertvalue %any undef, ptr %taddr6, 0 - %9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - store %any %9, ptr %taddr7, align 8 + %8 = insertvalue %"any*" undef, ptr %taddr6, 0 + %9 = insertvalue %"any*" %8, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + store %"any*" %9, ptr %taddr7, align 8 %10 = getelementptr inbounds { i64, ptr }, ptr %taddr7, i32 0, i32 0 %lo8 = load i64, ptr %10, align 8 %11 = getelementptr inbounds { i64, ptr }, ptr %taddr7, i32 0, i32 1 diff --git a/test/test_suite/variant/variant_test.c3t b/test/test_suite/any/variant_test.c3t similarity index 77% rename from test/test_suite/variant/variant_test.c3t rename to test/test_suite/any/variant_test.c3t index 6df28a180..efedd9674 100644 --- a/test/test_suite/variant/variant_test.c3t +++ b/test/test_suite/any/variant_test.c3t @@ -2,7 +2,7 @@ module foo; extern fn void printf(char*, ...); -fn void test(any x) +fn void test(any* x) { switch (x.type) { @@ -10,7 +10,7 @@ fn void test(any x) printf("Was int\n"); case double: printf("Was double\n"); - case any: + case any*: printf("Was variant\n"); case int*: printf("Was int*\n"); @@ -19,7 +19,7 @@ fn void test(any x) } } -fn void test_all(any... y) +fn void test_all(any*... y) { foreach (element : y) { @@ -29,9 +29,9 @@ fn void test_all(any... y) fn void main() { - any x = &&1; + any* x = &&1; int z; - any y = &z; + any* y = &z; typeid g = y.type; typeid h = x.type; if (y.type == int.typeid) @@ -63,158 +63,131 @@ fn void main() /* #expect: foo.ll -%any = type { ptr, i64 } -%"any[]" = type { ptr, i64 } - +%"any*" = type { ptr, i64 } +%"any*[]" = type { ptr, i64 } @"$ct.int" = linkonce global %.introspect { i8 2, i64 0, ptr null, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 @"$ct.double" = linkonce global %.introspect { i8 4, i64 0, ptr null, i64 8, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"$ct.any" = linkonce global %.introspect { i8 7, i64 0, ptr null, i64 16, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 +@"$ct.any$" = linkonce global %.introspect { i8 7, i64 0, ptr null, i64 16, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 @"$ct.p$int" = linkonce global %.introspect { i8 19, i64 0, ptr null, i64 8, i64 ptrtoint (ptr @"$ct.int" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 @"$ct.bool" = linkonce global %.introspect { i8 1, i64 0, ptr null, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 define void @foo.test(i64 %0, ptr %1) #0 { entry: - %x = alloca %any, align 8 + %x = alloca %"any*", align 8 %switch = alloca i64, align 8 store i64 %0, ptr %x, align 8 %ptroffset = getelementptr inbounds ptr, ptr %x, i64 1 store ptr %1, ptr %ptroffset, align 8 - %2 = getelementptr inbounds %any, ptr %x, i32 0, i32 1 + %2 = getelementptr inbounds %"any*", ptr %x, i32 0, i32 1 %3 = load i64, ptr %2, align 8 store i64 %3, ptr %switch, align 8 br label %switch.entry - switch.entry: ; preds = %entry %4 = load i64, ptr %switch, align 8 br label %check_subtype - check_subtype: ; preds = %parent_type_block, %switch.entry %5 = phi i64 [ %4, %switch.entry ], [ %typeid.parent, %parent_type_block ] %eq = icmp eq i64 ptrtoint (ptr @"$ct.int" to i64), %5 br i1 %eq, label %result_block, label %parent_type_block - parent_type_block: ; preds = %check_subtype %6 = inttoptr i64 %5 to ptr %7 = getelementptr inbounds %.introspect, ptr %6, i32 0, i32 1 %typeid.parent = load i64, ptr %7, align 8 %8 = icmp eq i64 %typeid.parent, 0 br i1 %8, label %result_block, label %check_subtype - result_block: ; preds = %parent_type_block, %check_subtype %9 = phi i1 [ false, %parent_type_block ], [ true, %check_subtype ] br i1 %9, label %switch.case, label %next_if - switch.case: ; preds = %result_block call void (ptr, ...) @printf(ptr @.str) br label %switch.exit - next_if: ; preds = %result_block br label %check_subtype1 - check_subtype1: ; preds = %parent_type_block3, %next_if %10 = phi i64 [ %4, %next_if ], [ %typeid.parent4, %parent_type_block3 ] %eq2 = icmp eq i64 ptrtoint (ptr @"$ct.double" to i64), %10 br i1 %eq2, label %result_block5, label %parent_type_block3 - parent_type_block3: ; preds = %check_subtype1 %11 = inttoptr i64 %10 to ptr %12 = getelementptr inbounds %.introspect, ptr %11, i32 0, i32 1 %typeid.parent4 = load i64, ptr %12, align 8 %13 = icmp eq i64 %typeid.parent4, 0 br i1 %13, label %result_block5, label %check_subtype1 - result_block5: ; preds = %parent_type_block3, %check_subtype1 %14 = phi i1 [ false, %parent_type_block3 ], [ true, %check_subtype1 ] br i1 %14, label %switch.case6, label %next_if7 - switch.case6: ; preds = %result_block5 call void (ptr, ...) @printf(ptr @.str.1) br label %switch.exit - next_if7: ; preds = %result_block5 br label %check_subtype8 - check_subtype8: ; preds = %parent_type_block10, %next_if7 %15 = phi i64 [ %4, %next_if7 ], [ %typeid.parent11, %parent_type_block10 ] - %eq9 = icmp eq i64 ptrtoint (ptr @"$ct.any" to i64), %15 + %eq9 = icmp eq i64 ptrtoint (ptr @"$ct.any$" to i64), %15 br i1 %eq9, label %result_block12, label %parent_type_block10 - parent_type_block10: ; preds = %check_subtype8 %16 = inttoptr i64 %15 to ptr %17 = getelementptr inbounds %.introspect, ptr %16, i32 0, i32 1 %typeid.parent11 = load i64, ptr %17, align 8 %18 = icmp eq i64 %typeid.parent11, 0 br i1 %18, label %result_block12, label %check_subtype8 - result_block12: ; preds = %parent_type_block10, %check_subtype8 %19 = phi i1 [ false, %parent_type_block10 ], [ true, %check_subtype8 ] br i1 %19, label %switch.case13, label %next_if14 - switch.case13: ; preds = %result_block12 call void (ptr, ...) @printf(ptr @.str.2) br label %switch.exit - next_if14: ; preds = %result_block12 br label %check_subtype15 - check_subtype15: ; preds = %parent_type_block17, %next_if14 %20 = phi i64 [ %4, %next_if14 ], [ %typeid.parent18, %parent_type_block17 ] %eq16 = icmp eq i64 ptrtoint (ptr @"$ct.p$int" to i64), %20 br i1 %eq16, label %result_block19, label %parent_type_block17 - parent_type_block17: ; preds = %check_subtype15 %21 = inttoptr i64 %20 to ptr %22 = getelementptr inbounds %.introspect, ptr %21, i32 0, i32 1 %typeid.parent18 = load i64, ptr %22, align 8 %23 = icmp eq i64 %typeid.parent18, 0 br i1 %23, label %result_block19, label %check_subtype15 - result_block19: ; preds = %parent_type_block17, %check_subtype15 %24 = phi i1 [ false, %parent_type_block17 ], [ true, %check_subtype15 ] br i1 %24, label %switch.case20, label %next_if21 - switch.case20: ; preds = %result_block19 call void (ptr, ...) @printf(ptr @.str.3) br label %switch.exit - next_if21: ; preds = %result_block19 br label %switch.default - switch.default: ; preds = %next_if21 call void (ptr, ...) @printf(ptr @.str.4) br label %switch.exit - switch.exit: ; preds = %switch.default, %switch.case20, %switch.case13, %switch.case6, %switch.case ret void } - ; Function Attrs: nounwind define void @foo.test_all(ptr %0, i64 %1) #0 { entry: - %y = alloca %"any[]", align 8 + %y = alloca %"any*[]", align 8 %.anon = alloca i64, align 8 %.anon1 = alloca i64, align 8 - %element = alloca %any, align 8 + %element = alloca %"any*", align 8 store ptr %0, ptr %y, align 8 %ptroffset = getelementptr inbounds i64, ptr %y, i64 1 store i64 %1, ptr %ptroffset, align 8 - %2 = getelementptr inbounds %"any[]", ptr %y, i32 0, i32 1 + %2 = getelementptr inbounds %"any*[]", ptr %y, i32 0, i32 1 %3 = load i64, ptr %2, align 8 store i64 %3, ptr %.anon, align 8 store i64 0, ptr %.anon1, align 8 br label %loop.cond - loop.cond: ; preds = %loop.body, %entry %4 = load i64, ptr %.anon1, align 8 %5 = load i64, ptr %.anon, align 8 %lt = icmp ult i64 %4, %5 br i1 %lt, label %loop.body, label %loop.exit - loop.body: ; preds = %loop.cond - %6 = getelementptr inbounds %"any[]", ptr %y, i32 0, i32 0 + %6 = getelementptr inbounds %"any*[]", ptr %y, i32 0, i32 0 %7 = load ptr, ptr %6, align 8 %8 = load i64, ptr %.anon1, align 8 - %ptroffset2 = getelementptr inbounds %any, ptr %7, i64 %8 + %ptroffset2 = getelementptr inbounds %"any*", ptr %7, i64 %8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %element, ptr align 8 %ptroffset2, i32 16, i1 false) %9 = getelementptr inbounds { i64, ptr }, ptr %element, i32 0, i32 0 %lo = load i64, ptr %9, align 8 @@ -225,90 +198,80 @@ loop.body: ; preds = %loop.cond %add = add i64 %11, 1 store i64 %add, ptr %.anon1, align 8 br label %loop.cond - loop.exit: ; preds = %loop.cond ret void } - ; Function Attrs: nounwind define void @foo.main() #0 { entry: - %x = alloca %any, align 8 + %x = alloca %"any*", align 8 %taddr = alloca i32, align 4 %z = alloca i32, align 4 - %y = alloca %any, align 8 + %y = alloca %"any*", align 8 %g = alloca i64, align 8 %h = alloca i64, align 8 %taddr4 = alloca double, align 8 %taddr11 = alloca double, align 8 - %taddr12 = alloca %any, align 8 + %taddr12 = alloca %"any*", align 8 %taddr15 = alloca i32, align 4 - %taddr16 = alloca %any, align 8 + %taddr16 = alloca %"any*", align 8 %taddr19 = alloca i8, align 1 - %taddr20 = alloca %any, align 8 + %taddr20 = alloca %"any*", align 8 %df = alloca ptr, align 8 - %varargslots = alloca [5 x %any], align 16 + %varargslots = alloca [5 x %"any*"], align 16 %taddr23 = alloca double, align 8 store i32 1, ptr %taddr, align 4 - %0 = insertvalue %any undef, ptr %taddr, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %1, ptr %x, align 8 + %0 = insertvalue %"any*" undef, ptr %taddr, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %1, ptr %x, align 8 store i32 0, ptr %z, align 4 - %2 = insertvalue %any undef, ptr %z, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %3, ptr %y, align 8 - %4 = getelementptr inbounds %any, ptr %y, i32 0, i32 1 + %2 = insertvalue %"any*" undef, ptr %z, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %3, ptr %y, align 8 + %4 = getelementptr inbounds %"any*", ptr %y, i32 0, i32 1 %5 = load i64, ptr %4, align 8 store i64 %5, ptr %g, align 8 - %6 = getelementptr inbounds %any, ptr %x, i32 0, i32 1 + %6 = getelementptr inbounds %"any*", ptr %x, i32 0, i32 1 %7 = load i64, ptr %6, align 8 store i64 %7, ptr %h, align 8 - %8 = getelementptr inbounds %any, ptr %y, i32 0, i32 1 + %8 = getelementptr inbounds %"any*", ptr %y, i32 0, i32 1 %9 = load i64, ptr %8, align 8 %eq = icmp eq i64 %9, ptrtoint (ptr @"$ct.int" to i64) br i1 %eq, label %if.then, label %if.exit - if.then: ; preds = %entry call void (ptr, ...) @printf(ptr @.str.5) br label %if.exit - if.exit: ; preds = %if.then, %entry - %10 = getelementptr inbounds %any, ptr %x, i32 0, i32 1 + %10 = getelementptr inbounds %"any*", ptr %x, i32 0, i32 1 %11 = load i64, ptr %10, align 8 %eq1 = icmp eq i64 %11, ptrtoint (ptr @"$ct.int" to i64) br i1 %eq1, label %if.then2, label %if.exit3 - if.then2: ; preds = %if.exit call void (ptr, ...) @printf(ptr @.str.6) br label %if.exit3 - if.exit3: ; preds = %if.then2, %if.exit store double 1.000000e+00, ptr %taddr4, align 8 - %12 = insertvalue %any undef, ptr %taddr4, 0 - %13 = insertvalue %any %12, i64 ptrtoint (ptr @"$ct.double" to i64), 1 - store %any %13, ptr %y, align 8 - %14 = insertvalue %any undef, ptr %x, 0 - %15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.any" to i64), 1 - store %any %15, ptr %x, align 8 - %16 = getelementptr inbounds %any, ptr %y, i32 0, i32 1 + %12 = insertvalue %"any*" undef, ptr %taddr4, 0 + %13 = insertvalue %"any*" %12, i64 ptrtoint (ptr @"$ct.double" to i64), 1 + store %"any*" %13, ptr %y, align 8 + %14 = insertvalue %"any*" undef, ptr %x, 0 + %15 = insertvalue %"any*" %14, i64 ptrtoint (ptr @"$ct.any$" to i64), 1 + store %"any*" %15, ptr %x, align 8 + %16 = getelementptr inbounds %"any*", ptr %y, i32 0, i32 1 %17 = load i64, ptr %16, align 8 %eq5 = icmp eq i64 %17, ptrtoint (ptr @"$ct.int" to i64) br i1 %eq5, label %if.then6, label %if.exit7 - if.then6: ; preds = %if.exit3 call void (ptr, ...) @printf(ptr @.str.7) br label %if.exit7 - if.exit7: ; preds = %if.then6, %if.exit3 - %18 = getelementptr inbounds %any, ptr %x, i32 0, i32 1 + %18 = getelementptr inbounds %"any*", ptr %x, i32 0, i32 1 %19 = load i64, ptr %18, align 8 %eq8 = icmp eq i64 %19, ptrtoint (ptr @"$ct.int" to i64) br i1 %eq8, label %if.then9, label %if.exit10 - if.then9: ; preds = %if.exit7 call void (ptr, ...) @printf(ptr @.str.8) br label %if.exit10 - if.exit10: ; preds = %if.then9, %if.exit7 %20 = getelementptr inbounds { i64, ptr }, ptr %x, i32 0, i32 0 %lo = load i64, ptr %20, align 8 @@ -316,27 +279,27 @@ if.exit10: ; preds = %if.then9, %if.exit7 %hi = load ptr, ptr %21, align 8 call void @foo.test(i64 %lo, ptr %hi) store double 1.000000e+00, ptr %taddr11, align 8 - %22 = insertvalue %any undef, ptr %taddr11, 0 - %23 = insertvalue %any %22, i64 ptrtoint (ptr @"$ct.double" to i64), 1 - store %any %23, ptr %taddr12, align 8 + %22 = insertvalue %"any*" undef, ptr %taddr11, 0 + %23 = insertvalue %"any*" %22, i64 ptrtoint (ptr @"$ct.double" to i64), 1 + store %"any*" %23, ptr %taddr12, align 8 %24 = getelementptr inbounds { i64, ptr }, ptr %taddr12, i32 0, i32 0 %lo13 = load i64, ptr %24, align 8 %25 = getelementptr inbounds { i64, ptr }, ptr %taddr12, i32 0, i32 1 %hi14 = load ptr, ptr %25, align 8 call void @foo.test(i64 %lo13, ptr %hi14) store i32 1, ptr %taddr15, align 4 - %26 = insertvalue %any undef, ptr %taddr15, 0 - %27 = insertvalue %any %26, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %27, ptr %taddr16, align 8 + %26 = insertvalue %"any*" undef, ptr %taddr15, 0 + %27 = insertvalue %"any*" %26, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %27, ptr %taddr16, align 8 %28 = getelementptr inbounds { i64, ptr }, ptr %taddr16, i32 0, i32 0 %lo17 = load i64, ptr %28, align 8 %29 = getelementptr inbounds { i64, ptr }, ptr %taddr16, i32 0, i32 1 %hi18 = load ptr, ptr %29, align 8 call void @foo.test(i64 %lo17, ptr %hi18) store i8 1, ptr %taddr19, align 1 - %30 = insertvalue %any undef, ptr %taddr19, 0 - %31 = insertvalue %any %30, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - store %any %31, ptr %taddr20, align 8 + %30 = insertvalue %"any*" undef, ptr %taddr19, 0 + %31 = insertvalue %"any*" %30, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + store %"any*" %31, ptr %taddr20, align 8 %32 = getelementptr inbounds { i64, ptr }, ptr %taddr20, i32 0, i32 0 %lo21 = load i64, ptr %32, align 8 %33 = getelementptr inbounds { i64, ptr }, ptr %taddr20, i32 0, i32 1 @@ -344,23 +307,23 @@ if.exit10: ; preds = %if.then9, %if.exit7 call void @foo.test(i64 %lo21, ptr %hi22) call void (ptr, ...) @printf(ptr @.str.9) store ptr null, ptr %df, align 8 - %34 = getelementptr inbounds [5 x %any], ptr %varargslots, i64 0, i64 0 + %34 = getelementptr inbounds [5 x %"any*"], ptr %varargslots, i64 0, i64 0 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %34, ptr align 8 %x, i32 16, i1 false) - %35 = getelementptr inbounds [5 x %any], ptr %varargslots, i64 0, i64 1 + %35 = getelementptr inbounds [5 x %"any*"], ptr %varargslots, i64 0, i64 1 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %35, ptr align 8 %x, i32 16, i1 false) store double 1.000000e+00, ptr %taddr23, align 8 - %36 = insertvalue %any undef, ptr %taddr23, 0 - %37 = insertvalue %any %36, i64 ptrtoint (ptr @"$ct.double" to i64), 1 - %38 = getelementptr inbounds [5 x %any], ptr %varargslots, i64 0, i64 2 - store %any %37, ptr %38, align 16 - %39 = insertvalue %any undef, ptr %x, 0 - %40 = insertvalue %any %39, i64 ptrtoint (ptr @"$ct.any" to i64), 1 - %41 = getelementptr inbounds [5 x %any], ptr %varargslots, i64 0, i64 3 - store %any %40, ptr %41, align 16 - %42 = insertvalue %any undef, ptr %df, 0 - %43 = insertvalue %any %42, i64 ptrtoint (ptr @"$ct.p$int" to i64), 1 - %44 = getelementptr inbounds [5 x %any], ptr %varargslots, i64 0, i64 4 - store %any %43, ptr %44, align 16 + %36 = insertvalue %"any*" undef, ptr %taddr23, 0 + %37 = insertvalue %"any*" %36, i64 ptrtoint (ptr @"$ct.double" to i64), 1 + %38 = getelementptr inbounds [5 x %"any*"], ptr %varargslots, i64 0, i64 2 + store %"any*" %37, ptr %38, align 16 + %39 = insertvalue %"any*" undef, ptr %x, 0 + %40 = insertvalue %"any*" %39, i64 ptrtoint (ptr @"$ct.any$" to i64), 1 + %41 = getelementptr inbounds [5 x %"any*"], ptr %varargslots, i64 0, i64 3 + store %"any*" %40, ptr %41, align 16 + %42 = insertvalue %"any*" undef, ptr %df, 0 + %43 = insertvalue %"any*" %42, i64 ptrtoint (ptr @"$ct.p$int" to i64), 1 + %44 = getelementptr inbounds [5 x %"any*"], ptr %varargslots, i64 0, i64 4 + store %"any*" %43, ptr %44, align 16 call void @foo.test_all(ptr %varargslots, i64 5) ret void } diff --git a/test/test_suite/arrays/global_init.c3t b/test/test_suite/arrays/global_init.c3t index 28f0e067e..3917ec880 100644 --- a/test/test_suite/arrays/global_init.c3t +++ b/test/test_suite/arrays/global_init.c3t @@ -14,8 +14,8 @@ int *bf3 = &abc[2] + 2; fn void main() { int *bf34 = (&abc[2] + 2) + 3; - static any[3] x = { &&42, &&'c', &&"for" }; - any[3] y = { &&42, &&'c', &&"for" }; + static any*[3] x = { &&42, &&'c', &&"for" }; + any*[3] y = { &&42, &&'c', &&"for" }; } /* #expect: test.ll @@ -33,30 +33,30 @@ fn void main() { @.taddr.9 = private global i32 42, align 4 @.taddr.10 = private global i8 99, align 1 @.taddr.11 = private global %"char[]" { ptr @.str, i64 3 }, align 8 -@main.x = internal unnamed_addr global [3 x %any] [%any { ptr @.taddr.9, i64 ptrtoint (ptr @"$ct.int" to i64) }, %any { ptr @.taddr.10, i64 ptrtoint (ptr @"$ct.char" to i64) }, %any { ptr @.taddr.11, i64 ptrtoint (ptr @"$ct.String" to i64) }], align 16 +@main.x = internal unnamed_addr global [3 x %"any*"] [%"any*" { ptr @.taddr.9, i64 ptrtoint (ptr @"$ct.int" to i64) }, %"any*" { ptr @.taddr.10, i64 ptrtoint (ptr @"$ct.char" to i64) }, %"any*" { ptr @.taddr.11, i64 ptrtoint (ptr @"$ct.String" to i64) }], align 16 define void @test.main() #0 { entry: %bf34 = alloca ptr, align 8 - %y = alloca [3 x %any], align 16 + %y = alloca [3 x %"any*"], align 16 %taddr = alloca i32, align 4 %taddr1 = alloca i8, align 1 %taddr2 = alloca %"char[]", align 8 store ptr getelementptr ([3 x i32], ptr @test.abc, i64 2, i64 1), ptr %bf34, align 8 - %0 = getelementptr inbounds [3 x %any], ptr %y, i64 0, i64 0 + %0 = getelementptr inbounds [3 x %"any*"], ptr %y, i64 0, i64 0 store i32 42, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %2, ptr %0, align 16 - %3 = getelementptr inbounds [3 x %any], ptr %y, i64 0, i64 1 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %2, ptr %0, align 16 + %3 = getelementptr inbounds [3 x %"any*"], ptr %y, i64 0, i64 1 store i8 99, ptr %taddr1, align 1 - %4 = insertvalue %any undef, ptr %taddr1, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - store %any %5, ptr %3, align 16 - %6 = getelementptr inbounds [3 x %any], ptr %y, i64 0, i64 2 + %4 = insertvalue %"any*" undef, ptr %taddr1, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + store %"any*" %5, ptr %3, align 16 + %6 = getelementptr inbounds [3 x %"any*"], ptr %y, i64 0, i64 2 store %"char[]" { ptr @.str.12, i64 3 }, ptr %taddr2, align 8 - %7 = insertvalue %any undef, ptr %taddr2, 0 - %8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - store %any %8, ptr %6, align 16 + %7 = insertvalue %"any*" undef, ptr %taddr2, 0 + %8 = insertvalue %"any*" %7, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + store %"any*" %8, ptr %6, align 16 ret void } diff --git a/test/test_suite/assert/assertf.c3t b/test/test_suite/assert/assertf.c3t index 85ce95143..736c76c52 100644 --- a/test/test_suite/assert/assertf.c3t +++ b/test/test_suite/assert/assertf.c3t @@ -16,8 +16,8 @@ define i64 @main.main() #0 { entry: %i = alloca i64, align 8 %taddr = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 - %indirectarg = alloca %"any[]", align 8 + %varargslots = alloca [2 x %"any*"], align 16 + %indirectarg = alloca %"any*[]", align 8 store i64 0, ptr %i, align 8 br label %loop.cond loop.cond: ; preds = %assert_ok, %entry @@ -29,21 +29,21 @@ loop.body: ; preds = %loop.cond %neq = icmp ne i64 2, %1 br i1 %neq, label %assert_ok, label %assert_fail assert_fail: ; preds = %loop.body - %2 = insertvalue %any undef, ptr %i, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %2 = insertvalue %"any*" undef, ptr %i, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 %4 = load i64, ptr %i, align 8 %mul = mul i64 %4, 2 store i64 %mul, ptr %taddr, align 8 - %5 = insertvalue %any undef, ptr %taddr, 0 - %6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %7 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %3, ptr %7, align 16 - %8 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %6, ptr %8, align 16 - %9 = insertvalue %"any[]" undef, ptr %varargslots, 0 - %"#temp#" = insertvalue %"any[]" %9, i64 2, 1 - store %"any[]" %"#temp#", ptr %indirectarg, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 10, ptr @.file, i64 10, ptr @.func, i64 4, i32 7, ptr byval(%"any[]") align 8 %indirectarg) + %5 = insertvalue %"any*" undef, ptr %taddr, 0 + %6 = insertvalue %"any*" %5, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %7 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %3, ptr %7, align 16 + %8 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %6, ptr %8, align 16 + %9 = insertvalue %"any*[]" undef, ptr %varargslots, 0 + %"#temp#" = insertvalue %"any*[]" %9, i64 2, 1 + store %"any*[]" %"#temp#", ptr %indirectarg, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 10, ptr @.file, i64 10, ptr @.func, i64 4, i32 7, ptr byval(%"any*[]") align 8 %indirectarg) unreachable assert_ok: ; preds = %loop.body %10 = load i64, ptr %i, align 8 diff --git a/test/test_suite/assert/unreachable.c3t b/test/test_suite/assert/unreachable.c3t index 7e2485304..f4dc010df 100644 --- a/test/test_suite/assert/unreachable.c3t +++ b/test/test_suite/assert/unreachable.c3t @@ -17,7 +17,7 @@ fn void test() define void @unreachable.test() #0 { entry: %x = alloca i32, align 4 - %indirectarg = alloca %"any[]", align 8 + %indirectarg = alloca %"any*[]", align 8 %0 = call i32 @unreachable.foo() store i32 %0, ptr %x, align 4 %1 = load i32, ptr %x, align 4 @@ -28,7 +28,7 @@ if.then: ; preds = %entry ret void if.exit: ; preds = %entry - store %"any[]" zeroinitializer, ptr %indirectarg, align 8 - call void @std.core.builtin.panicf(ptr @.str, i64 30, ptr @.str.1, i64 14, ptr @.str.2, i64 4, i32 10, ptr byval(%"any[]") align 8 %indirectarg) + store %"any*[]" zeroinitializer, ptr %indirectarg, align 8 + call void @std.core.builtin.panicf(ptr @.str, i64 30, ptr @.str.1, i64 14, ptr @.str.2, i64 4, i32 10, ptr byval(%"any*[]") align 8 %indirectarg) unreachable } \ No newline at end of file diff --git a/test/test_suite/bitstruct/bitstruct_anon_in_struct_ok.c3t b/test/test_suite/bitstruct/bitstruct_anon_in_struct_ok.c3t index 5396f2b62..495897e4d 100644 --- a/test/test_suite/bitstruct/bitstruct_anon_in_struct_ok.c3t +++ b/test/test_suite/bitstruct/bitstruct_anon_in_struct_ok.c3t @@ -32,12 +32,12 @@ define void @foo.main() #0 { entry: %test = alloca %Test, align 2 %retparam = alloca i64, align 8 - %varargslots = alloca [3 x %any], align 16 + %varargslots = alloca [3 x %"any*"], align 16 %taddr = alloca i8, align 1 %taddr2 = alloca i8, align 1 %taddr3 = alloca i16, align 2 %retparam4 = alloca i64, align 8 - %varargslots5 = alloca [4 x %any], align 16 + %varargslots5 = alloca [4 x %"any*"], align 16 %taddr8 = alloca i8, align 1 %taddr11 = alloca i8, align 1 %taddr14 = alloca i8, align 1 @@ -55,26 +55,26 @@ entry: %6 = and i16 255, %lshrl %trunc = trunc i16 %6 to i8 store i8 %trunc, ptr %taddr, align 1 - %7 = insertvalue %any undef, ptr %taddr, 0 - %8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %9 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 0 - store %any %8, ptr %9, align 16 + %7 = insertvalue %"any*" undef, ptr %taddr, 0 + %8 = insertvalue %"any*" %7, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %9 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %8, ptr %9, align 16 %10 = getelementptr inbounds %Test, ptr %test, i32 0, i32 1 %11 = load i16, ptr %10, align 2 %12 = and i16 255, %11 %trunc1 = trunc i16 %12 to i8 store i8 %trunc1, ptr %taddr2, align 1 - %13 = insertvalue %any undef, ptr %taddr2, 0 - %14 = insertvalue %any %13, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %15 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 1 - store %any %14, ptr %15, align 16 + %13 = insertvalue %"any*" undef, ptr %taddr2, 0 + %14 = insertvalue %"any*" %13, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %15 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %14, ptr %15, align 16 %16 = getelementptr inbounds %Test, ptr %test, i32 0, i32 1 %17 = load i16, ptr %16, align 2 store i16 %17, ptr %taddr3, align 2 - %18 = insertvalue %any undef, ptr %taddr3, 0 - %19 = insertvalue %any %18, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 - %20 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 2 - store %any %19, ptr %20, align 16 + %18 = insertvalue %"any*" undef, ptr %taddr3, 0 + %19 = insertvalue %"any*" %18, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 + %20 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 2 + store %"any*" %19, ptr %20, align 16 %21 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 18, ptr %varargslots, i64 3) %22 = getelementptr inbounds %Test, ptr %test, i32 0, i32 1 %23 = load i16, ptr %22, align 2 @@ -82,40 +82,40 @@ entry: %24 = and i16 1, %lshrl6 %trunc7 = trunc i16 %24 to i8 store i8 %trunc7, ptr %taddr8, align 1 - %25 = insertvalue %any undef, ptr %taddr8, 0 - %26 = insertvalue %any %25, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %27 = getelementptr inbounds [4 x %any], ptr %varargslots5, i64 0, i64 0 - store %any %26, ptr %27, align 16 + %25 = insertvalue %"any*" undef, ptr %taddr8, 0 + %26 = insertvalue %"any*" %25, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %27 = getelementptr inbounds [4 x %"any*"], ptr %varargslots5, i64 0, i64 0 + store %"any*" %26, ptr %27, align 16 %28 = getelementptr inbounds %Test, ptr %test, i32 0, i32 1 %29 = load i16, ptr %28, align 2 %lshrl9 = lshr i16 %29, 6 %30 = and i16 1, %lshrl9 %trunc10 = trunc i16 %30 to i8 store i8 %trunc10, ptr %taddr11, align 1 - %31 = insertvalue %any undef, ptr %taddr11, 0 - %32 = insertvalue %any %31, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %33 = getelementptr inbounds [4 x %any], ptr %varargslots5, i64 0, i64 1 - store %any %32, ptr %33, align 16 + %31 = insertvalue %"any*" undef, ptr %taddr11, 0 + %32 = insertvalue %"any*" %31, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %33 = getelementptr inbounds [4 x %"any*"], ptr %varargslots5, i64 0, i64 1 + store %"any*" %32, ptr %33, align 16 %34 = getelementptr inbounds %Test, ptr %test, i32 0, i32 1 %35 = load i16, ptr %34, align 2 %lshrl12 = lshr i16 %35, 5 %36 = and i16 1, %lshrl12 %trunc13 = trunc i16 %36 to i8 store i8 %trunc13, ptr %taddr14, align 1 - %37 = insertvalue %any undef, ptr %taddr14, 0 - %38 = insertvalue %any %37, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %39 = getelementptr inbounds [4 x %any], ptr %varargslots5, i64 0, i64 2 - store %any %38, ptr %39, align 16 + %37 = insertvalue %"any*" undef, ptr %taddr14, 0 + %38 = insertvalue %"any*" %37, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %39 = getelementptr inbounds [4 x %"any*"], ptr %varargslots5, i64 0, i64 2 + store %"any*" %38, ptr %39, align 16 %40 = getelementptr inbounds %Test, ptr %test, i32 0, i32 1 %41 = load i16, ptr %40, align 2 %lshrl15 = lshr i16 %41, 4 %42 = and i16 1, %lshrl15 %trunc16 = trunc i16 %42 to i8 store i8 %trunc16, ptr %taddr17, align 1 - %43 = insertvalue %any undef, ptr %taddr17, 0 - %44 = insertvalue %any %43, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %45 = getelementptr inbounds [4 x %any], ptr %varargslots5, i64 0, i64 3 - store %any %44, ptr %45, align 16 + %43 = insertvalue %"any*" undef, ptr %taddr17, 0 + %44 = insertvalue %"any*" %43, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %45 = getelementptr inbounds [4 x %"any*"], ptr %varargslots5, i64 0, i64 3 + store %"any*" %44, ptr %45, align 16 %46 = call i64 @std.io.printfn(ptr %retparam4, ptr @.str.1, i64 12, ptr %varargslots5, i64 4) ret void } diff --git a/test/test_suite/bitstruct/bitstruct_be.c3t b/test/test_suite/bitstruct/bitstruct_be.c3t index 19e439f42..c8d16f614 100644 --- a/test/test_suite/bitstruct/bitstruct_be.c3t +++ b/test/test_suite/bitstruct/bitstruct_be.c3t @@ -46,17 +46,17 @@ fn void main() %0 = load i32, ptr %x, align 4 %1 = call i32 @llvm.bswap.i32(i32 %0) store i32 2063597568, ptr %x, align 4 - %2 = insertvalue %any undef, ptr %x, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %4 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %3, ptr %4, align 16 + %2 = insertvalue %"any*" undef, ptr %x, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %4 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %3, ptr %4, align 16 %5 = load i32, ptr %x, align 4 %6 = call i32 @llvm.bswap.i32(i32 %5) store i32 %6, ptr %taddr, align 4 - %7 = insertvalue %any undef, ptr %taddr, 0 - %8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %9 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %8, ptr %9, align 16 + %7 = insertvalue %"any*" undef, ptr %taddr, 0 + %8 = insertvalue %"any*" %7, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %9 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %8, ptr %9, align 16 %10 = call i64 @std.io.printf(ptr %retparam, ptr @.str, i64 18, ptr %varargslots, i64 2) store i32 873625686, ptr %abc, align 4 store [4 x i8] c"\124Vx", ptr %abc2, align 1 @@ -78,10 +78,10 @@ loop.body: ; preds = %loop.cond %15 = getelementptr inbounds [4 x i8], ptr %13, i64 0, i64 %14 %16 = load i8, ptr %15, align 1 store i8 %16, ptr %d, align 1 - %17 = insertvalue %any undef, ptr %d, 0 - %18 = insertvalue %any %17, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %19 = getelementptr inbounds [1 x %any], ptr %varargslots3, i64 0, i64 0 - store %any %18, ptr %19, align 16 + %17 = insertvalue %"any*" undef, ptr %d, 0 + %18 = insertvalue %"any*" %17, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %19 = getelementptr inbounds [1 x %"any*"], ptr %varargslots3, i64 0, i64 0 + store %"any*" %18, ptr %19, align 16 %20 = call i64 @std.io.printf(ptr %retparam2, ptr @.str.1, i64 3, ptr %varargslots3, i64 1) %21 = load i64, ptr %.anon1, align 8 %add = add i64 %21, 1 @@ -161,10 +161,10 @@ loop.body23: ; preds = %loop.cond21 %35 = getelementptr inbounds [4 x i8], ptr %33, i64 0, i64 %34 %36 = load i8, ptr %35, align 1 store i8 %36, ptr %d24, align 1 - %37 = insertvalue %any undef, ptr %d24, 0 - %38 = insertvalue %any %37, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %39 = getelementptr inbounds [1 x %any], ptr %varargslots26, i64 0, i64 0 - store %any %38, ptr %39, align 16 + %37 = insertvalue %"any*" undef, ptr %d24, 0 + %38 = insertvalue %"any*" %37, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %39 = getelementptr inbounds [1 x %"any*"], ptr %varargslots26, i64 0, i64 0 + store %"any*" %38, ptr %39, align 16 %40 = call i64 @std.io.printf(ptr %retparam25, ptr @.str.2, i64 3, ptr %varargslots26, i64 1) %41 = load i64, ptr %.anon20, align 8 %add29 = add i64 %41, 1 @@ -233,10 +233,10 @@ voiderr53: ; preds = %noerr_block51, %gua %53 = and i32 65535, %52 %trunc = trunc i32 %53 to i16 store i16 %trunc, ptr %taddr56, align 2 - %54 = insertvalue %any undef, ptr %taddr56, 0 - %55 = insertvalue %any %54, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 - %56 = getelementptr inbounds [1 x %any], ptr %varargslots55, i64 0, i64 0 - store %any %55, ptr %56, align 16 + %54 = insertvalue %"any*" undef, ptr %taddr56, 0 + %55 = insertvalue %"any*" %54, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 + %56 = getelementptr inbounds [1 x %"any*"], ptr %varargslots55, i64 0, i64 0 + store %"any*" %55, ptr %56, align 16 %57 = call i64 @std.io.printfn(ptr %retparam54, ptr @.str.3, i64 10, ptr %varargslots55, i64 1) %58 = load i32, ptr %abc, align 4 %59 = call i32 @llvm.bswap.i32(i32 %58) @@ -255,10 +255,10 @@ voiderr53: ; preds = %noerr_block51, %gua %70 = and i32 65535, %69 %trunc61 = trunc i32 %70 to i16 store i16 %trunc61, ptr %taddr62, align 2 - %71 = insertvalue %any undef, ptr %taddr62, 0 - %72 = insertvalue %any %71, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 - %73 = getelementptr inbounds [1 x %any], ptr %varargslots60, i64 0, i64 0 - store %any %72, ptr %73, align 16 + %71 = insertvalue %"any*" undef, ptr %taddr62, 0 + %72 = insertvalue %"any*" %71, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 + %73 = getelementptr inbounds [1 x %"any*"], ptr %varargslots60, i64 0, i64 0 + store %"any*" %72, ptr %73, align 16 %74 = call i64 @std.io.printfn(ptr %retparam59, ptr @.str.4, i64 12, ptr %varargslots60, i64 1) %75 = load ptr, ptr %z, align 8 store ptr %75, ptr %.anon65, align 8 @@ -276,10 +276,10 @@ loop.body69: ; preds = %loop.cond67 %79 = getelementptr inbounds [4 x i8], ptr %77, i64 0, i64 %78 %80 = load i8, ptr %79, align 1 store i8 %80, ptr %d70, align 1 - %81 = insertvalue %any undef, ptr %d70, 0 - %82 = insertvalue %any %81, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %83 = getelementptr inbounds [1 x %any], ptr %varargslots72, i64 0, i64 0 - store %any %82, ptr %83, align 16 + %81 = insertvalue %"any*" undef, ptr %d70, 0 + %82 = insertvalue %"any*" %81, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %83 = getelementptr inbounds [1 x %"any*"], ptr %varargslots72, i64 0, i64 0 + store %"any*" %82, ptr %83, align 16 %84 = call i64 @std.io.printf(ptr %retparam71, ptr @.str.5, i64 3, ptr %varargslots72, i64 1) %85 = load i64, ptr %.anon66, align 8 %add75 = add i64 %85, 1 @@ -346,16 +346,16 @@ voiderr99: ; preds = %noerr_block97, %gua store i32 0, ptr %y, align 4 %95 = load i32, ptr %y, align 4 store i32 123, ptr %y, align 4 - %96 = insertvalue %any undef, ptr %y, 0 - %97 = insertvalue %any %96, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %98 = getelementptr inbounds [2 x %any], ptr %varargslots101, i64 0, i64 0 - store %any %97, ptr %98, align 16 + %96 = insertvalue %"any*" undef, ptr %y, 0 + %97 = insertvalue %"any*" %96, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %98 = getelementptr inbounds [2 x %"any*"], ptr %varargslots101, i64 0, i64 0 + store %"any*" %97, ptr %98, align 16 %99 = load i32, ptr %y, align 4 store i32 %99, ptr %taddr102, align 4 - %100 = insertvalue %any undef, ptr %taddr102, 0 - %101 = insertvalue %any %100, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %102 = getelementptr inbounds [2 x %any], ptr %varargslots101, i64 0, i64 1 - store %any %101, ptr %102, align 16 + %100 = insertvalue %"any*" undef, ptr %taddr102, 0 + %101 = insertvalue %"any*" %100, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %102 = getelementptr inbounds [2 x %"any*"], ptr %varargslots101, i64 0, i64 1 + store %"any*" %101, ptr %102, align 16 %103 = call i64 @std.io.printf(ptr %retparam100, ptr @.str.6, i64 18, ptr %varargslots101, i64 2) ret void } \ No newline at end of file diff --git a/test/test_suite/bitstruct/bitstruct_initializer.c3t b/test/test_suite/bitstruct/bitstruct_initializer.c3t index 6e01a7ae1..550040203 100644 --- a/test/test_suite/bitstruct/bitstruct_initializer.c3t +++ b/test/test_suite/bitstruct/bitstruct_initializer.c3t @@ -55,32 +55,32 @@ entry: %d = alloca %Abc, align 8 %b = alloca [8 x i8], align 1 %retparam = alloca i64, align 8 - %varargslots = alloca [3 x %any], align 16 + %varargslots = alloca [3 x %"any*"], align 16 %taddr = alloca i32, align 4 %taddr13 = alloca i32, align 4 %taddr16 = alloca i8, align 1 %retparam17 = alloca i64, align 8 - %varargslots18 = alloca [3 x %any], align 16 + %varargslots18 = alloca [3 x %"any*"], align 16 %taddr20 = alloca i32, align 4 %taddr23 = alloca i32, align 4 %taddr26 = alloca i8, align 1 %retparam27 = alloca i64, align 8 - %varargslots28 = alloca [3 x %any], align 16 + %varargslots28 = alloca [3 x %"any*"], align 16 %taddr36 = alloca i32, align 4 %taddr44 = alloca i32, align 4 %taddr46 = alloca i8, align 1 %retparam61 = alloca i64, align 8 - %varargslots62 = alloca [3 x %any], align 16 + %varargslots62 = alloca [3 x %"any*"], align 16 %taddr64 = alloca i32, align 4 %taddr67 = alloca i32, align 4 %taddr70 = alloca i8, align 1 %retparam71 = alloca i64, align 8 - %varargslots72 = alloca [3 x %any], align 16 + %varargslots72 = alloca [3 x %"any*"], align 16 %taddr74 = alloca i32, align 4 %taddr77 = alloca i32, align 4 %taddr80 = alloca i8, align 1 %retparam81 = alloca i64, align 8 - %varargslots82 = alloca [3 x %any], align 16 + %varargslots82 = alloca [3 x %"any*"], align 16 %taddr90 = alloca i32, align 4 %taddr98 = alloca i32, align 4 %taddr100 = alloca i8, align 1 @@ -157,58 +157,58 @@ entry: %32 = and i64 4294967295, %31 %trunc10 = trunc i64 %32 to i32 store i32 %trunc10, ptr %taddr, align 4 - %33 = insertvalue %any undef, ptr %taddr, 0 - %34 = insertvalue %any %33, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %35 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 0 - store %any %34, ptr %35, align 16 + %33 = insertvalue %"any*" undef, ptr %taddr, 0 + %34 = insertvalue %"any*" %33, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %35 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %34, ptr %35, align 16 %36 = load i64, ptr %x, align 8 %lshrl11 = lshr i64 %36, 32 %37 = and i64 2147483647, %lshrl11 %trunc12 = trunc i64 %37 to i32 store i32 %trunc12, ptr %taddr13, align 4 - %38 = insertvalue %any undef, ptr %taddr13, 0 - %39 = insertvalue %any %38, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %40 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 1 - store %any %39, ptr %40, align 16 + %38 = insertvalue %"any*" undef, ptr %taddr13, 0 + %39 = insertvalue %"any*" %38, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %40 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %39, ptr %40, align 16 %41 = load i64, ptr %x, align 8 %lshrl14 = lshr i64 %41, 63 %42 = and i64 1, %lshrl14 %trunc15 = trunc i64 %42 to i8 store i8 %trunc15, ptr %taddr16, align 1 - %43 = insertvalue %any undef, ptr %taddr16, 0 - %44 = insertvalue %any %43, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %45 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 2 - store %any %44, ptr %45, align 16 + %43 = insertvalue %"any*" undef, ptr %taddr16, 0 + %44 = insertvalue %"any*" %43, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %45 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 2 + store %"any*" %44, ptr %45, align 16 %46 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 8, ptr %varargslots, i64 3) %47 = getelementptr inbounds %Abc, ptr %y, i32 0, i32 1 %48 = load i64, ptr %47, align 8 %49 = and i64 4294967295, %48 %trunc19 = trunc i64 %49 to i32 store i32 %trunc19, ptr %taddr20, align 4 - %50 = insertvalue %any undef, ptr %taddr20, 0 - %51 = insertvalue %any %50, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %52 = getelementptr inbounds [3 x %any], ptr %varargslots18, i64 0, i64 0 - store %any %51, ptr %52, align 16 + %50 = insertvalue %"any*" undef, ptr %taddr20, 0 + %51 = insertvalue %"any*" %50, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %52 = getelementptr inbounds [3 x %"any*"], ptr %varargslots18, i64 0, i64 0 + store %"any*" %51, ptr %52, align 16 %53 = getelementptr inbounds %Abc, ptr %y, i32 0, i32 1 %54 = load i64, ptr %53, align 8 %lshrl21 = lshr i64 %54, 32 %55 = and i64 2147483647, %lshrl21 %trunc22 = trunc i64 %55 to i32 store i32 %trunc22, ptr %taddr23, align 4 - %56 = insertvalue %any undef, ptr %taddr23, 0 - %57 = insertvalue %any %56, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %58 = getelementptr inbounds [3 x %any], ptr %varargslots18, i64 0, i64 1 - store %any %57, ptr %58, align 16 + %56 = insertvalue %"any*" undef, ptr %taddr23, 0 + %57 = insertvalue %"any*" %56, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %58 = getelementptr inbounds [3 x %"any*"], ptr %varargslots18, i64 0, i64 1 + store %"any*" %57, ptr %58, align 16 %59 = getelementptr inbounds %Abc, ptr %y, i32 0, i32 1 %60 = load i64, ptr %59, align 8 %lshrl24 = lshr i64 %60, 63 %61 = and i64 1, %lshrl24 %trunc25 = trunc i64 %61 to i8 store i8 %trunc25, ptr %taddr26, align 1 - %62 = insertvalue %any undef, ptr %taddr26, 0 - %63 = insertvalue %any %62, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %64 = getelementptr inbounds [3 x %any], ptr %varargslots18, i64 0, i64 2 - store %any %63, ptr %64, align 16 + %62 = insertvalue %"any*" undef, ptr %taddr26, 0 + %63 = insertvalue %"any*" %62, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %64 = getelementptr inbounds [3 x %"any*"], ptr %varargslots18, i64 0, i64 2 + store %"any*" %63, ptr %64, align 16 %65 = call i64 @std.io.printfn(ptr %retparam17, ptr @.str.2, i64 8, ptr %varargslots18, i64 3) %66 = getelementptr inbounds [8 x i8], ptr %b, i64 0, i64 0 %67 = load i8, ptr %66, align 1 @@ -229,10 +229,10 @@ entry: %shl35 = shl i32 %zext34, 24 %76 = or i32 %shl35, %73 store i32 %76, ptr %taddr36, align 4 - %77 = insertvalue %any undef, ptr %taddr36, 0 - %78 = insertvalue %any %77, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %79 = getelementptr inbounds [3 x %any], ptr %varargslots28, i64 0, i64 0 - store %any %78, ptr %79, align 16 + %77 = insertvalue %"any*" undef, ptr %taddr36, 0 + %78 = insertvalue %"any*" %77, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %79 = getelementptr inbounds [3 x %"any*"], ptr %varargslots28, i64 0, i64 0 + store %"any*" %78, ptr %79, align 16 %80 = getelementptr inbounds [8 x i8], ptr %b, i64 0, i64 4 %81 = load i8, ptr %80, align 1 %zext37 = zext i8 %81 to i32 @@ -253,20 +253,20 @@ entry: %90 = or i32 %shl43, %87 %91 = and i32 2147483647, %90 store i32 %91, ptr %taddr44, align 4 - %92 = insertvalue %any undef, ptr %taddr44, 0 - %93 = insertvalue %any %92, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %94 = getelementptr inbounds [3 x %any], ptr %varargslots28, i64 0, i64 1 - store %any %93, ptr %94, align 16 + %92 = insertvalue %"any*" undef, ptr %taddr44, 0 + %93 = insertvalue %"any*" %92, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %94 = getelementptr inbounds [3 x %"any*"], ptr %varargslots28, i64 0, i64 1 + store %"any*" %93, ptr %94, align 16 %95 = getelementptr inbounds [8 x i8], ptr %b, i64 0, i64 7 %96 = load i8, ptr %95, align 1 %lshrl45 = lshr i8 %96, 7 %97 = trunc i8 %lshrl45 to i1 %98 = zext i1 %97 to i8 store i8 %98, ptr %taddr46, align 1 - %99 = insertvalue %any undef, ptr %taddr46, 0 - %100 = insertvalue %any %99, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %101 = getelementptr inbounds [3 x %any], ptr %varargslots28, i64 0, i64 2 - store %any %100, ptr %101, align 16 + %99 = insertvalue %"any*" undef, ptr %taddr46, 0 + %100 = insertvalue %"any*" %99, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %101 = getelementptr inbounds [3 x %"any*"], ptr %varargslots28, i64 0, i64 2 + store %"any*" %100, ptr %101, align 16 %102 = call i64 @std.io.printfn(ptr %retparam27, ptr @.str.3, i64 8, ptr %varargslots28, i64 3) %add = add i32 %0, 1 %zext47 = zext i32 %add to i64 @@ -338,58 +338,58 @@ entry: %135 = and i64 4294967295, %134 %trunc63 = trunc i64 %135 to i32 store i32 %trunc63, ptr %taddr64, align 4 - %136 = insertvalue %any undef, ptr %taddr64, 0 - %137 = insertvalue %any %136, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %138 = getelementptr inbounds [3 x %any], ptr %varargslots62, i64 0, i64 0 - store %any %137, ptr %138, align 16 + %136 = insertvalue %"any*" undef, ptr %taddr64, 0 + %137 = insertvalue %"any*" %136, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %138 = getelementptr inbounds [3 x %"any*"], ptr %varargslots62, i64 0, i64 0 + store %"any*" %137, ptr %138, align 16 %139 = load i64, ptr %x, align 8 %lshrl65 = lshr i64 %139, 32 %140 = and i64 2147483647, %lshrl65 %trunc66 = trunc i64 %140 to i32 store i32 %trunc66, ptr %taddr67, align 4 - %141 = insertvalue %any undef, ptr %taddr67, 0 - %142 = insertvalue %any %141, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %143 = getelementptr inbounds [3 x %any], ptr %varargslots62, i64 0, i64 1 - store %any %142, ptr %143, align 16 + %141 = insertvalue %"any*" undef, ptr %taddr67, 0 + %142 = insertvalue %"any*" %141, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %143 = getelementptr inbounds [3 x %"any*"], ptr %varargslots62, i64 0, i64 1 + store %"any*" %142, ptr %143, align 16 %144 = load i64, ptr %x, align 8 %lshrl68 = lshr i64 %144, 63 %145 = and i64 1, %lshrl68 %trunc69 = trunc i64 %145 to i8 store i8 %trunc69, ptr %taddr70, align 1 - %146 = insertvalue %any undef, ptr %taddr70, 0 - %147 = insertvalue %any %146, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %148 = getelementptr inbounds [3 x %any], ptr %varargslots62, i64 0, i64 2 - store %any %147, ptr %148, align 16 + %146 = insertvalue %"any*" undef, ptr %taddr70, 0 + %147 = insertvalue %"any*" %146, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %148 = getelementptr inbounds [3 x %"any*"], ptr %varargslots62, i64 0, i64 2 + store %"any*" %147, ptr %148, align 16 %149 = call i64 @std.io.printfn(ptr %retparam61, ptr @.str.4, i64 8, ptr %varargslots62, i64 3) %150 = getelementptr inbounds %Abc, ptr %y, i32 0, i32 1 %151 = load i64, ptr %150, align 8 %152 = and i64 4294967295, %151 %trunc73 = trunc i64 %152 to i32 store i32 %trunc73, ptr %taddr74, align 4 - %153 = insertvalue %any undef, ptr %taddr74, 0 - %154 = insertvalue %any %153, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %155 = getelementptr inbounds [3 x %any], ptr %varargslots72, i64 0, i64 0 - store %any %154, ptr %155, align 16 + %153 = insertvalue %"any*" undef, ptr %taddr74, 0 + %154 = insertvalue %"any*" %153, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %155 = getelementptr inbounds [3 x %"any*"], ptr %varargslots72, i64 0, i64 0 + store %"any*" %154, ptr %155, align 16 %156 = getelementptr inbounds %Abc, ptr %y, i32 0, i32 1 %157 = load i64, ptr %156, align 8 %lshrl75 = lshr i64 %157, 32 %158 = and i64 2147483647, %lshrl75 %trunc76 = trunc i64 %158 to i32 store i32 %trunc76, ptr %taddr77, align 4 - %159 = insertvalue %any undef, ptr %taddr77, 0 - %160 = insertvalue %any %159, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %161 = getelementptr inbounds [3 x %any], ptr %varargslots72, i64 0, i64 1 - store %any %160, ptr %161, align 16 + %159 = insertvalue %"any*" undef, ptr %taddr77, 0 + %160 = insertvalue %"any*" %159, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %161 = getelementptr inbounds [3 x %"any*"], ptr %varargslots72, i64 0, i64 1 + store %"any*" %160, ptr %161, align 16 %162 = getelementptr inbounds %Abc, ptr %y, i32 0, i32 1 %163 = load i64, ptr %162, align 8 %lshrl78 = lshr i64 %163, 63 %164 = and i64 1, %lshrl78 %trunc79 = trunc i64 %164 to i8 store i8 %trunc79, ptr %taddr80, align 1 - %165 = insertvalue %any undef, ptr %taddr80, 0 - %166 = insertvalue %any %165, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %167 = getelementptr inbounds [3 x %any], ptr %varargslots72, i64 0, i64 2 - store %any %166, ptr %167, align 16 + %165 = insertvalue %"any*" undef, ptr %taddr80, 0 + %166 = insertvalue %"any*" %165, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %167 = getelementptr inbounds [3 x %"any*"], ptr %varargslots72, i64 0, i64 2 + store %"any*" %166, ptr %167, align 16 %168 = call i64 @std.io.printfn(ptr %retparam71, ptr @.str.5, i64 8, ptr %varargslots72, i64 3) %169 = getelementptr inbounds [8 x i8], ptr %b, i64 0, i64 0 %170 = load i8, ptr %169, align 1 @@ -410,10 +410,10 @@ entry: %shl89 = shl i32 %zext88, 24 %179 = or i32 %shl89, %176 store i32 %179, ptr %taddr90, align 4 - %180 = insertvalue %any undef, ptr %taddr90, 0 - %181 = insertvalue %any %180, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %182 = getelementptr inbounds [3 x %any], ptr %varargslots82, i64 0, i64 0 - store %any %181, ptr %182, align 16 + %180 = insertvalue %"any*" undef, ptr %taddr90, 0 + %181 = insertvalue %"any*" %180, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %182 = getelementptr inbounds [3 x %"any*"], ptr %varargslots82, i64 0, i64 0 + store %"any*" %181, ptr %182, align 16 %183 = getelementptr inbounds [8 x i8], ptr %b, i64 0, i64 4 %184 = load i8, ptr %183, align 1 %zext91 = zext i8 %184 to i32 @@ -434,20 +434,20 @@ entry: %193 = or i32 %shl97, %190 %194 = and i32 2147483647, %193 store i32 %194, ptr %taddr98, align 4 - %195 = insertvalue %any undef, ptr %taddr98, 0 - %196 = insertvalue %any %195, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %197 = getelementptr inbounds [3 x %any], ptr %varargslots82, i64 0, i64 1 - store %any %196, ptr %197, align 16 + %195 = insertvalue %"any*" undef, ptr %taddr98, 0 + %196 = insertvalue %"any*" %195, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %197 = getelementptr inbounds [3 x %"any*"], ptr %varargslots82, i64 0, i64 1 + store %"any*" %196, ptr %197, align 16 %198 = getelementptr inbounds [8 x i8], ptr %b, i64 0, i64 7 %199 = load i8, ptr %198, align 1 %lshrl99 = lshr i8 %199, 7 %200 = trunc i8 %lshrl99 to i1 %201 = zext i1 %200 to i8 store i8 %201, ptr %taddr100, align 1 - %202 = insertvalue %any undef, ptr %taddr100, 0 - %203 = insertvalue %any %202, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %204 = getelementptr inbounds [3 x %any], ptr %varargslots82, i64 0, i64 2 - store %any %203, ptr %204, align 16 + %202 = insertvalue %"any*" undef, ptr %taddr100, 0 + %203 = insertvalue %"any*" %202, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %204 = getelementptr inbounds [3 x %"any*"], ptr %varargslots82, i64 0, i64 2 + store %"any*" %203, ptr %204, align 16 %205 = call i64 @std.io.printfn(ptr %retparam81, ptr @.str.6, i64 8, ptr %varargslots82, i64 3) ret void } diff --git a/test/test_suite/bitstruct/bitstruct_ops.c3t b/test/test_suite/bitstruct/bitstruct_ops.c3t index e822e272f..33f666f84 100644 --- a/test/test_suite/bitstruct/bitstruct_ops.c3t +++ b/test/test_suite/bitstruct/bitstruct_ops.c3t @@ -48,21 +48,21 @@ entry: %f2 = alloca i32, align 4 %f3 = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 + %varargslots = alloca [2 x %"any*"], align 16 %taddr = alloca i8, align 1 %taddr2 = alloca i8, align 1 %f4 = alloca i32, align 4 %retparam3 = alloca i64, align 8 - %varargslots4 = alloca [2 x %any], align 16 + %varargslots4 = alloca [2 x %"any*"], align 16 %taddr6 = alloca i8, align 1 %taddr9 = alloca i8, align 1 %f5 = alloca i32, align 4 %retparam10 = alloca i64, align 8 - %varargslots11 = alloca [2 x %any], align 16 + %varargslots11 = alloca [2 x %"any*"], align 16 %taddr13 = alloca i8, align 1 %taddr16 = alloca i8, align 1 %retparam18 = alloca i64, align 8 - %varargslots19 = alloca [2 x %any], align 16 + %varargslots19 = alloca [2 x %"any*"], align 16 %taddr21 = alloca i8, align 1 %taddr24 = alloca i8, align 1 %b1 = alloca [13 x i8], align 1 @@ -70,20 +70,20 @@ entry: %b3 = alloca [13 x i8], align 1 %0 = alloca i104, align 1 %retparam26 = alloca i64, align 8 - %varargslots27 = alloca [3 x %any], align 16 + %varargslots27 = alloca [3 x %"any*"], align 16 %taddr28 = alloca i8, align 1 %taddr30 = alloca i8, align 1 %taddr32 = alloca i8, align 1 %1 = alloca i104, align 1 %retparam34 = alloca i64, align 8 - %varargslots35 = alloca [3 x %any], align 16 + %varargslots35 = alloca [3 x %"any*"], align 16 %taddr36 = alloca i8, align 1 %taddr38 = alloca i8, align 1 %taddr40 = alloca i8, align 1 %taddr41 = alloca [13 x i8], align 1 %2 = alloca i104, align 1 %retparam43 = alloca i64, align 8 - %varargslots44 = alloca [3 x %any], align 16 + %varargslots44 = alloca [3 x %"any*"], align 16 %taddr45 = alloca i8, align 1 %taddr47 = alloca i8, align 1 %taddr49 = alloca i8, align 1 @@ -97,19 +97,19 @@ entry: %6 = and i32 1, %5 %trunc = trunc i32 %6 to i8 store i8 %trunc, ptr %taddr, align 1 - %7 = insertvalue %any undef, ptr %taddr, 0 - %8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %9 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %8, ptr %9, align 16 + %7 = insertvalue %"any*" undef, ptr %taddr, 0 + %8 = insertvalue %"any*" %7, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %9 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %8, ptr %9, align 16 %10 = load i32, ptr %f3, align 4 %lshrl = lshr i32 %10, 1 %11 = and i32 1, %lshrl %trunc1 = trunc i32 %11 to i8 store i8 %trunc1, ptr %taddr2, align 1 - %12 = insertvalue %any undef, ptr %taddr2, 0 - %13 = insertvalue %any %12, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %14 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %13, ptr %14, align 16 + %12 = insertvalue %"any*" undef, ptr %taddr2, 0 + %13 = insertvalue %"any*" %12, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %14 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %13, ptr %14, align 16 %15 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 5, ptr %varargslots, i64 2) %16 = load i32, ptr %f1, align 4 %17 = load i32, ptr %f2, align 4 @@ -122,38 +122,38 @@ entry: %20 = and i32 1, %19 %trunc5 = trunc i32 %20 to i8 store i8 %trunc5, ptr %taddr6, align 1 - %21 = insertvalue %any undef, ptr %taddr6, 0 - %22 = insertvalue %any %21, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %23 = getelementptr inbounds [2 x %any], ptr %varargslots4, i64 0, i64 0 - store %any %22, ptr %23, align 16 + %21 = insertvalue %"any*" undef, ptr %taddr6, 0 + %22 = insertvalue %"any*" %21, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %23 = getelementptr inbounds [2 x %"any*"], ptr %varargslots4, i64 0, i64 0 + store %"any*" %22, ptr %23, align 16 %24 = load i32, ptr %f4, align 4 %lshrl7 = lshr i32 %24, 1 %25 = and i32 1, %lshrl7 %trunc8 = trunc i32 %25 to i8 store i8 %trunc8, ptr %taddr9, align 1 - %26 = insertvalue %any undef, ptr %taddr9, 0 - %27 = insertvalue %any %26, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %28 = getelementptr inbounds [2 x %any], ptr %varargslots4, i64 0, i64 1 - store %any %27, ptr %28, align 16 + %26 = insertvalue %"any*" undef, ptr %taddr9, 0 + %27 = insertvalue %"any*" %26, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %28 = getelementptr inbounds [2 x %"any*"], ptr %varargslots4, i64 0, i64 1 + store %"any*" %27, ptr %28, align 16 %29 = call i64 @std.io.printfn(ptr %retparam3, ptr @.str.1, i64 5, ptr %varargslots4, i64 2) store i32 3, ptr %f5, align 4 %30 = load i32, ptr %f5, align 4 %31 = and i32 1, %30 %trunc12 = trunc i32 %31 to i8 store i8 %trunc12, ptr %taddr13, align 1 - %32 = insertvalue %any undef, ptr %taddr13, 0 - %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %34 = getelementptr inbounds [2 x %any], ptr %varargslots11, i64 0, i64 0 - store %any %33, ptr %34, align 16 + %32 = insertvalue %"any*" undef, ptr %taddr13, 0 + %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %34 = getelementptr inbounds [2 x %"any*"], ptr %varargslots11, i64 0, i64 0 + store %"any*" %33, ptr %34, align 16 %35 = load i32, ptr %f5, align 4 %lshrl14 = lshr i32 %35, 1 %36 = and i32 1, %lshrl14 %trunc15 = trunc i32 %36 to i8 store i8 %trunc15, ptr %taddr16, align 1 - %37 = insertvalue %any undef, ptr %taddr16, 0 - %38 = insertvalue %any %37, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %39 = getelementptr inbounds [2 x %any], ptr %varargslots11, i64 0, i64 1 - store %any %38, ptr %39, align 16 + %37 = insertvalue %"any*" undef, ptr %taddr16, 0 + %38 = insertvalue %"any*" %37, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %39 = getelementptr inbounds [2 x %"any*"], ptr %varargslots11, i64 0, i64 1 + store %"any*" %38, ptr %39, align 16 %40 = call i64 @std.io.printfn(ptr %retparam10, ptr @.str.2, i64 5, ptr %varargslots11, i64 2) %41 = load i32, ptr %f5, align 4 %42 = load i32, ptr %f2, align 4 @@ -163,19 +163,19 @@ entry: %44 = and i32 1, %43 %trunc20 = trunc i32 %44 to i8 store i8 %trunc20, ptr %taddr21, align 1 - %45 = insertvalue %any undef, ptr %taddr21, 0 - %46 = insertvalue %any %45, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %47 = getelementptr inbounds [2 x %any], ptr %varargslots19, i64 0, i64 0 - store %any %46, ptr %47, align 16 + %45 = insertvalue %"any*" undef, ptr %taddr21, 0 + %46 = insertvalue %"any*" %45, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %47 = getelementptr inbounds [2 x %"any*"], ptr %varargslots19, i64 0, i64 0 + store %"any*" %46, ptr %47, align 16 %48 = load i32, ptr %f5, align 4 %lshrl22 = lshr i32 %48, 1 %49 = and i32 1, %lshrl22 %trunc23 = trunc i32 %49 to i8 store i8 %trunc23, ptr %taddr24, align 1 - %50 = insertvalue %any undef, ptr %taddr24, 0 - %51 = insertvalue %any %50, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %52 = getelementptr inbounds [2 x %any], ptr %varargslots19, i64 0, i64 1 - store %any %51, ptr %52, align 16 + %50 = insertvalue %"any*" undef, ptr %taddr24, 0 + %51 = insertvalue %"any*" %50, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %52 = getelementptr inbounds [2 x %"any*"], ptr %varargslots19, i64 0, i64 1 + store %"any*" %51, ptr %52, align 16 %53 = call i64 @std.io.printfn(ptr %retparam18, ptr @.str.3, i64 5, ptr %varargslots19, i64 2) store [13 x i8] c"\03\00\00\02\00\00\00\00\00\00\00\00\00", ptr %b1, align 1 store [13 x i8] c"\01\00\00\00\00\00\00\00\00\00\00\00\00", ptr %b2, align 1 @@ -189,30 +189,30 @@ entry: %58 = trunc i8 %57 to i1 %59 = zext i1 %58 to i8 store i8 %59, ptr %taddr28, align 1 - %60 = insertvalue %any undef, ptr %taddr28, 0 - %61 = insertvalue %any %60, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %62 = getelementptr inbounds [3 x %any], ptr %varargslots27, i64 0, i64 0 - store %any %61, ptr %62, align 16 + %60 = insertvalue %"any*" undef, ptr %taddr28, 0 + %61 = insertvalue %"any*" %60, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %62 = getelementptr inbounds [3 x %"any*"], ptr %varargslots27, i64 0, i64 0 + store %"any*" %61, ptr %62, align 16 %63 = getelementptr inbounds [13 x i8], ptr %b3, i64 0, i64 0 %64 = load i8, ptr %63, align 1 %lshrl29 = lshr i8 %64, 1 %65 = trunc i8 %lshrl29 to i1 %66 = zext i1 %65 to i8 store i8 %66, ptr %taddr30, align 1 - %67 = insertvalue %any undef, ptr %taddr30, 0 - %68 = insertvalue %any %67, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %69 = getelementptr inbounds [3 x %any], ptr %varargslots27, i64 0, i64 1 - store %any %68, ptr %69, align 16 + %67 = insertvalue %"any*" undef, ptr %taddr30, 0 + %68 = insertvalue %"any*" %67, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %69 = getelementptr inbounds [3 x %"any*"], ptr %varargslots27, i64 0, i64 1 + store %"any*" %68, ptr %69, align 16 %70 = getelementptr inbounds [13 x i8], ptr %b3, i64 0, i64 3 %71 = load i8, ptr %70, align 1 %lshrl31 = lshr i8 %71, 1 %72 = trunc i8 %lshrl31 to i1 %73 = zext i1 %72 to i8 store i8 %73, ptr %taddr32, align 1 - %74 = insertvalue %any undef, ptr %taddr32, 0 - %75 = insertvalue %any %74, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %76 = getelementptr inbounds [3 x %any], ptr %varargslots27, i64 0, i64 2 - store %any %75, ptr %76, align 16 + %74 = insertvalue %"any*" undef, ptr %taddr32, 0 + %75 = insertvalue %"any*" %74, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %76 = getelementptr inbounds [3 x %"any*"], ptr %varargslots27, i64 0, i64 2 + store %"any*" %75, ptr %76, align 16 %77 = call i64 @std.io.printfn(ptr %retparam26, ptr @.str.4, i64 8, ptr %varargslots27, i64 3) %78 = load i104, ptr %b3, align 1 %bnot33 = xor i104 %78, -1 @@ -223,30 +223,30 @@ entry: %81 = trunc i8 %80 to i1 %82 = zext i1 %81 to i8 store i8 %82, ptr %taddr36, align 1 - %83 = insertvalue %any undef, ptr %taddr36, 0 - %84 = insertvalue %any %83, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %85 = getelementptr inbounds [3 x %any], ptr %varargslots35, i64 0, i64 0 - store %any %84, ptr %85, align 16 + %83 = insertvalue %"any*" undef, ptr %taddr36, 0 + %84 = insertvalue %"any*" %83, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %85 = getelementptr inbounds [3 x %"any*"], ptr %varargslots35, i64 0, i64 0 + store %"any*" %84, ptr %85, align 16 %86 = getelementptr inbounds [13 x i8], ptr %b3, i64 0, i64 0 %87 = load i8, ptr %86, align 1 %lshrl37 = lshr i8 %87, 1 %88 = trunc i8 %lshrl37 to i1 %89 = zext i1 %88 to i8 store i8 %89, ptr %taddr38, align 1 - %90 = insertvalue %any undef, ptr %taddr38, 0 - %91 = insertvalue %any %90, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %92 = getelementptr inbounds [3 x %any], ptr %varargslots35, i64 0, i64 1 - store %any %91, ptr %92, align 16 + %90 = insertvalue %"any*" undef, ptr %taddr38, 0 + %91 = insertvalue %"any*" %90, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %92 = getelementptr inbounds [3 x %"any*"], ptr %varargslots35, i64 0, i64 1 + store %"any*" %91, ptr %92, align 16 %93 = getelementptr inbounds [13 x i8], ptr %b3, i64 0, i64 3 %94 = load i8, ptr %93, align 1 %lshrl39 = lshr i8 %94, 1 %95 = trunc i8 %lshrl39 to i1 %96 = zext i1 %95 to i8 store i8 %96, ptr %taddr40, align 1 - %97 = insertvalue %any undef, ptr %taddr40, 0 - %98 = insertvalue %any %97, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %99 = getelementptr inbounds [3 x %any], ptr %varargslots35, i64 0, i64 2 - store %any %98, ptr %99, align 16 + %97 = insertvalue %"any*" undef, ptr %taddr40, 0 + %98 = insertvalue %"any*" %97, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %99 = getelementptr inbounds [3 x %"any*"], ptr %varargslots35, i64 0, i64 2 + store %"any*" %98, ptr %99, align 16 %100 = call i64 @std.io.printfn(ptr %retparam34, ptr @.str.5, i64 8, ptr %varargslots35, i64 3) store [13 x i8] c"\03\00\00\00\00\00\00\00\00\00\00\00\00", ptr %taddr41, align 1 %101 = load i104, ptr %b3, align 1 @@ -259,30 +259,30 @@ entry: %105 = trunc i8 %104 to i1 %106 = zext i1 %105 to i8 store i8 %106, ptr %taddr45, align 1 - %107 = insertvalue %any undef, ptr %taddr45, 0 - %108 = insertvalue %any %107, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %109 = getelementptr inbounds [3 x %any], ptr %varargslots44, i64 0, i64 0 - store %any %108, ptr %109, align 16 + %107 = insertvalue %"any*" undef, ptr %taddr45, 0 + %108 = insertvalue %"any*" %107, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %109 = getelementptr inbounds [3 x %"any*"], ptr %varargslots44, i64 0, i64 0 + store %"any*" %108, ptr %109, align 16 %110 = getelementptr inbounds [13 x i8], ptr %b3, i64 0, i64 0 %111 = load i8, ptr %110, align 1 %lshrl46 = lshr i8 %111, 1 %112 = trunc i8 %lshrl46 to i1 %113 = zext i1 %112 to i8 store i8 %113, ptr %taddr47, align 1 - %114 = insertvalue %any undef, ptr %taddr47, 0 - %115 = insertvalue %any %114, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %116 = getelementptr inbounds [3 x %any], ptr %varargslots44, i64 0, i64 1 - store %any %115, ptr %116, align 16 + %114 = insertvalue %"any*" undef, ptr %taddr47, 0 + %115 = insertvalue %"any*" %114, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %116 = getelementptr inbounds [3 x %"any*"], ptr %varargslots44, i64 0, i64 1 + store %"any*" %115, ptr %116, align 16 %117 = getelementptr inbounds [13 x i8], ptr %b3, i64 0, i64 3 %118 = load i8, ptr %117, align 1 %lshrl48 = lshr i8 %118, 1 %119 = trunc i8 %lshrl48 to i1 %120 = zext i1 %119 to i8 store i8 %120, ptr %taddr49, align 1 - %121 = insertvalue %any undef, ptr %taddr49, 0 - %122 = insertvalue %any %121, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %123 = getelementptr inbounds [3 x %any], ptr %varargslots44, i64 0, i64 2 - store %any %122, ptr %123, align 16 + %121 = insertvalue %"any*" undef, ptr %taddr49, 0 + %122 = insertvalue %"any*" %121, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %123 = getelementptr inbounds [3 x %"any*"], ptr %varargslots44, i64 0, i64 2 + store %"any*" %122, ptr %123, align 16 %124 = call i64 @std.io.printfn(ptr %retparam43, ptr @.str.6, i64 8, ptr %varargslots44, i64 3) ret void } diff --git a/test/test_suite/compile_time/compile_time_access_subscript.c3t b/test/test_suite/compile_time/compile_time_access_subscript.c3t index 3d675d83e..b910ef16c 100644 --- a/test/test_suite/compile_time/compile_time_access_subscript.c3t +++ b/test/test_suite/compile_time/compile_time_access_subscript.c3t @@ -27,7 +27,7 @@ fn void main() { var $i = int[4] { 1, 2, 3, 4 }; var $b = Abc[2] { Abc {}, Abc { 11, 22, 33, 44 }}; - var $c = any[4] {}; + var $c = any*[4] {}; check_type(int); check_type(Abc); check_type(anyfault); @@ -56,7 +56,7 @@ fn void main() %z9 = alloca [2 x i32], align 4 %z10 = alloca %"int[]", align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %literal = alloca %Abc, align 4 store i32 0, ptr %z, align 4 %0 = getelementptr inbounds %Abc, ptr %z1, i32 0, i32 0 @@ -94,10 +94,10 @@ fn void main() store float 0.000000e+00, ptr %12, align 4 %13 = getelementptr inbounds %Abc, ptr %literal, i32 0, i32 3 store float 0.000000e+00, ptr %13, align 4 - %14 = insertvalue %any undef, ptr %literal, 0 - %15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.test.Abc" to i64), 1 - %16 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %15, ptr %16, align 16 + %14 = insertvalue %"any*" undef, ptr %literal, 0 + %15 = insertvalue %"any*" %14, i64 ptrtoint (ptr @"$ct.test.Abc" to i64), 1 + %16 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %15, ptr %16, align 16 %17 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) ret void } diff --git a/test/test_suite/compile_time/ct_builtin_time_date.c3t b/test/test_suite/compile_time/ct_builtin_time_date.c3t index 18ca03b0a..ad800d0f3 100644 --- a/test/test_suite/compile_time/ct_builtin_time_date.c3t +++ b/test/test_suite/compile_time/ct_builtin_time_date.c3t @@ -29,7 +29,7 @@ fn void main() define void @test.test(i32 %0) #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 %len = alloca i64, align 8 %error_var = alloca i64, align 8 @@ -42,10 +42,10 @@ entry: %error_var24 = alloca i64, align 8 %error_var30 = alloca i64, align 8 %retparam38 = alloca i64, align 8 - %varargslots39 = alloca [1 x %any], align 16 + %varargslots39 = alloca [1 x %"any*"], align 16 %taddr40 = alloca i64, align 8 %retparam43 = alloca i64, align 8 - %varargslots44 = alloca [1 x %any], align 16 + %varargslots44 = alloca [1 x %"any*"], align 16 %taddr45 = alloca i64, align 8 %len48 = alloca i64, align 8 %error_var49 = alloca i64, align 8 @@ -58,10 +58,10 @@ entry: %error_var80 = alloca i64, align 8 %error_var86 = alloca i64, align 8 store i32 %0, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 %4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) %gt = icmp sgt i32 %0, 0 br i1 %gt, label %if.then, label %if.exit @@ -157,16 +157,16 @@ noerr_block35: ; preds = %after_check33 br label %voiderr37 voiderr37: ; preds = %noerr_block35, %guard_block34, %guard_block28, %guard_block22 store i64 14, ptr %taddr40, align 8 - %23 = insertvalue %any undef, ptr %taddr40, 0 - %24 = insertvalue %any %23, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %25 = getelementptr inbounds [1 x %any], ptr %varargslots39, i64 0, i64 0 - store %any %24, ptr %25, align 16 + %23 = insertvalue %"any*" undef, ptr %taddr40, 0 + %24 = insertvalue %"any*" %23, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %25 = getelementptr inbounds [1 x %"any*"], ptr %varargslots39, i64 0, i64 0 + store %"any*" %24, ptr %25, align 16 %26 = call i64 @std.io.printfn(ptr %retparam38, ptr @.str.3, i64 2, ptr %varargslots39, i64 1) store i64 6, ptr %taddr45, align 8 - %27 = insertvalue %any undef, ptr %taddr45, 0 - %28 = insertvalue %any %27, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %29 = getelementptr inbounds [1 x %any], ptr %varargslots44, i64 0, i64 0 - store %any %28, ptr %29, align 16 + %27 = insertvalue %"any*" undef, ptr %taddr45, 0 + %28 = insertvalue %"any*" %27, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %29 = getelementptr inbounds [1 x %"any*"], ptr %varargslots44, i64 0, i64 0 + store %"any*" %28, ptr %29, align 16 %30 = call i64 @std.io.printfn(ptr %retparam43, ptr @.str.4, i64 2, ptr %varargslots44, i64 1) %31 = call ptr @std.io.stdout() %32 = call i64 @std.io.File.write(ptr %retparam51, ptr %31, ptr @.str.5, i64 23) diff --git a/test/test_suite/compile_time/ct_funcptr.c3t b/test/test_suite/compile_time/ct_funcptr.c3t index fe71b50b2..46a7c5a49 100644 --- a/test/test_suite/compile_time/ct_funcptr.c3t +++ b/test/test_suite/compile_time/ct_funcptr.c3t @@ -20,14 +20,14 @@ define void @test.test(i32 %0) #0 { entry: %ptr = alloca ptr, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 store ptr @test.test, ptr %ptr, align 8 store i32 %0, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 %4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) %gt = icmp sgt i32 %0, 0 br i1 %gt, label %if.then, label %if.exit diff --git a/test/test_suite/compile_time/ct_memberof.c3t b/test/test_suite/compile_time/ct_memberof.c3t index bcb9c0c12..50474955a 100644 --- a/test/test_suite/compile_time/ct_memberof.c3t +++ b/test/test_suite/compile_time/ct_memberof.c3t @@ -104,7 +104,7 @@ fn void main() define void @test.hello(i32 %0, double %1, i64 %2, i64 %3, ptr %4, i64 %5) #0 { entry: %d = alloca [4 x i32], align 8 - %args = alloca %"any[]", align 8 + %args = alloca %"any*[]", align 8 store i64 %2, ptr %d, align 8 %ptroffset = getelementptr inbounds i64, ptr %d, i64 1 store i64 %3, ptr %ptroffset, align 8 @@ -152,52 +152,52 @@ entry: %error_var138 = alloca i64, align 8 %error_var144 = alloca i64, align 8 %retparam152 = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca %"char[]", align 8 %retparam155 = alloca i64, align 8 - %varargslots156 = alloca [2 x %any], align 16 + %varargslots156 = alloca [2 x %"any*"], align 16 %taddr157 = alloca %"char[]", align 8 %taddr158 = alloca %"char[]", align 8 %retparam161 = alloca i64, align 8 - %varargslots162 = alloca [2 x %any], align 16 + %varargslots162 = alloca [2 x %"any*"], align 16 %taddr163 = alloca %"char[]", align 8 %taddr164 = alloca %"char[]", align 8 %retparam167 = alloca i64, align 8 - %varargslots168 = alloca [2 x %any], align 16 + %varargslots168 = alloca [2 x %"any*"], align 16 %taddr169 = alloca %"char[]", align 8 %taddr170 = alloca %"char[]", align 8 %retparam173 = alloca i64, align 8 - %varargslots174 = alloca [2 x %any], align 16 + %varargslots174 = alloca [2 x %"any*"], align 16 %taddr175 = alloca %"char[]", align 8 %taddr176 = alloca %"char[]", align 8 %retparam179 = alloca i64, align 8 - %varargslots180 = alloca [1 x %any], align 16 + %varargslots180 = alloca [1 x %"any*"], align 16 %taddr181 = alloca %"char[]", align 8 %retparam184 = alloca i64, align 8 - %varargslots185 = alloca [2 x %any], align 16 + %varargslots185 = alloca [2 x %"any*"], align 16 %taddr186 = alloca %"char[]", align 8 %taddr187 = alloca %"char[]", align 8 %retparam190 = alloca i64, align 8 - %varargslots191 = alloca [2 x %any], align 16 + %varargslots191 = alloca [2 x %"any*"], align 16 %taddr192 = alloca %"char[]", align 8 %taddr193 = alloca %"char[]", align 8 %retparam196 = alloca i64, align 8 - %varargslots197 = alloca [2 x %any], align 16 + %varargslots197 = alloca [2 x %"any*"], align 16 %taddr198 = alloca %"char[]", align 8 %taddr199 = alloca %"char[]", align 8 %retparam202 = alloca i64, align 8 - %varargslots203 = alloca [2 x %any], align 16 + %varargslots203 = alloca [2 x %"any*"], align 16 %taddr204 = alloca %"char[]", align 8 %taddr205 = alloca %"char[]", align 8 %retparam208 = alloca i64, align 8 - %varargslots209 = alloca [1 x %any], align 16 + %varargslots209 = alloca [1 x %"any*"], align 16 %taddr210 = alloca %"char[]", align 8 %retparam213 = alloca i64, align 8 - %varargslots214 = alloca [2 x %any], align 16 + %varargslots214 = alloca [2 x %"any*"], align 16 %taddr215 = alloca %"char[]", align 8 %taddr216 = alloca %"char[]", align 8 %retparam219 = alloca i64, align 8 - %varargslots220 = alloca [2 x %any], align 16 + %varargslots220 = alloca [2 x %"any*"], align 16 %taddr221 = alloca %"char[]", align 8 %taddr222 = alloca %"char[]", align 8 %1 = call ptr @std.io.stdout() @@ -373,7 +373,7 @@ noerr_block80: ; preds = %after_check78 br label %voiderr82 voiderr82: ; preds = %noerr_block80, %guard_block79, %guard_block73, %guard_block67 %37 = call ptr @std.io.stdout() - %38 = call i64 @std.io.File.write(ptr %retparam86, ptr %37, ptr @.str.13, i64 5) + %38 = call i64 @std.io.File.write(ptr %retparam86, ptr %37, ptr @.str.13 %not_err87 = icmp eq i64 %38, 0 %39 = call i1 @llvm.expect.i1(i1 %not_err87, i1 true) br i1 %39, label %after_check89, label %assign_optional88 @@ -502,132 +502,132 @@ noerr_block149: ; preds = %after_check147 br label %voiderr151 voiderr151: ; preds = %noerr_block149, %guard_block148, %guard_block142, %guard_block136 store %"char[]" { ptr @.str.17, i64 3 }, ptr %taddr, align 8 - %64 = insertvalue %any undef, ptr %taddr, 0 - %65 = insertvalue %any %64, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %66 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %65, ptr %66, align 16 + %64 = insertvalue %"any*" undef, ptr %taddr, 0 + %65 = insertvalue %"any*" %64, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %66 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %65, ptr %66, align 16 %67 = call i64 @std.io.printfn(ptr %retparam152, ptr @.str.16, i64 8, ptr %varargslots, i64 1) store %"char[]" { ptr @.str.19, i64 1 }, ptr %taddr157, align 8 - %68 = insertvalue %any undef, ptr %taddr157, 0 - %69 = insertvalue %any %68, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %70 = getelementptr inbounds [2 x %any], ptr %varargslots156, i64 0, i64 0 - store %any %69, ptr %70, align 16 + %68 = insertvalue %"any*" undef, ptr %taddr157, 0 + %69 = insertvalue %"any*" %68, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %70 = getelementptr inbounds [2 x %"any*"], ptr %varargslots156, i64 0, i64 0 + store %"any*" %69, ptr %70, align 16 store %"char[]" { ptr @.str.20, i64 3 }, ptr %taddr158, align 8 - %71 = insertvalue %any undef, ptr %taddr158, 0 - %72 = insertvalue %any %71, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %73 = getelementptr inbounds [2 x %any], ptr %varargslots156, i64 0, i64 1 - store %any %72, ptr %73, align 16 + %71 = insertvalue %"any*" undef, ptr %taddr158, 0 + %72 = insertvalue %"any*" %71, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %73 = getelementptr inbounds [2 x %"any*"], ptr %varargslots156, i64 0, i64 1 + store %"any*" %72, ptr %73, align 16 %74 = call i64 @std.io.printfn(ptr %retparam155, ptr @.str.18, i64 6, ptr %varargslots156, i64 2) store %"char[]" { ptr @.str.22, i64 4 }, ptr %taddr163, align 8 - %75 = insertvalue %any undef, ptr %taddr163, 0 - %76 = insertvalue %any %75, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %77 = getelementptr inbounds [2 x %any], ptr %varargslots162, i64 0, i64 0 - store %any %76, ptr %77, align 16 + %75 = insertvalue %"any*" undef, ptr %taddr163, 0 + %76 = insertvalue %"any*" %75, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %77 = getelementptr inbounds [2 x %"any*"], ptr %varargslots162, i64 0, i64 0 + store %"any*" %76, ptr %77, align 16 store %"char[]" { ptr @.str.23, i64 4 }, ptr %taddr164, align 8 - %78 = insertvalue %any undef, ptr %taddr164, 0 - %79 = insertvalue %any %78, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %80 = getelementptr inbounds [2 x %any], ptr %varargslots162, i64 0, i64 1 - store %any %79, ptr %80, align 16 + %78 = insertvalue %"any*" undef, ptr %taddr164, 0 + %79 = insertvalue %"any*" %78, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %80 = getelementptr inbounds [2 x %"any*"], ptr %varargslots162, i64 0, i64 1 + store %"any*" %79, ptr %80, align 16 %81 = call i64 @std.io.printfn(ptr %retparam161, ptr @.str.21, i64 6, ptr %varargslots162, i64 2) store %"char[]" zeroinitializer, ptr %taddr169, align 8 - %82 = insertvalue %any undef, ptr %taddr169, 0 - %83 = insertvalue %any %82, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %84 = getelementptr inbounds [2 x %any], ptr %varargslots168, i64 0, i64 0 - store %any %83, ptr %84, align 16 + %82 = insertvalue %"any*" undef, ptr %taddr169, 0 + %83 = insertvalue %"any*" %82, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %84 = getelementptr inbounds [2 x %"any*"], ptr %varargslots168, i64 0, i64 0 + store %"any*" %83, ptr %84, align 16 store %"char[]" { ptr @.str.25, i64 5 }, ptr %taddr170, align 8 - %85 = insertvalue %any undef, ptr %taddr170, 0 - %86 = insertvalue %any %85, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %87 = getelementptr inbounds [2 x %any], ptr %varargslots168, i64 0, i64 1 - store %any %86, ptr %87, align 16 + %85 = insertvalue %"any*" undef, ptr %taddr170, 0 + %86 = insertvalue %"any*" %85, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %87 = getelementptr inbounds [2 x %"any*"], ptr %varargslots168, i64 0, i64 1 + store %"any*" %86, ptr %87, align 16 %88 = call i64 @std.io.printfn(ptr %retparam167, ptr @.str.24, i64 6, ptr %varargslots168, i64 2) store %"char[]" { ptr @.str.27, i64 1 }, ptr %taddr175, align 8 - %89 = insertvalue %any undef, ptr %taddr175, 0 - %90 = insertvalue %any %89, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %91 = getelementptr inbounds [2 x %any], ptr %varargslots174, i64 0, i64 0 - store %any %90, ptr %91, align 16 + %89 = insertvalue %"any*" undef, ptr %taddr175, 0 + %90 = insertvalue %"any*" %89, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %91 = getelementptr inbounds [2 x %"any*"], ptr %varargslots174, i64 0, i64 0 + store %"any*" %90, ptr %91, align 16 store %"char[]" { ptr @.str.28, i64 6 }, ptr %taddr176, align 8 - %92 = insertvalue %any undef, ptr %taddr176, 0 - %93 = insertvalue %any %92, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %94 = getelementptr inbounds [2 x %any], ptr %varargslots174, i64 0, i64 1 - store %any %93, ptr %94, align 16 + %92 = insertvalue %"any*" undef, ptr %taddr176, 0 + %93 = insertvalue %"any*" %92, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %94 = getelementptr inbounds [2 x %"any*"], ptr %varargslots174, i64 0, i64 1 + store %"any*" %93, ptr %94, align 16 %95 = call i64 @std.io.printfn(ptr %retparam173, ptr @.str.26, i64 6, ptr %varargslots174, i64 2) store %"char[]" { ptr @.str.30, i64 3 }, ptr %taddr181, align 8 - %96 = insertvalue %any undef, ptr %taddr181, 0 - %97 = insertvalue %any %96, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %98 = getelementptr inbounds [1 x %any], ptr %varargslots180, i64 0, i64 0 - store %any %97, ptr %98, align 16 + %96 = insertvalue %"any*" undef, ptr %taddr181, 0 + %97 = insertvalue %"any*" %96, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %98 = getelementptr inbounds [1 x %"any*"], ptr %varargslots180, i64 0, i64 0 + store %"any*" %97, ptr %98, align 16 %99 = call i64 @std.io.printfn(ptr %retparam179, ptr @.str.29, i64 8, ptr %varargslots180, i64 1) store %"char[]" { ptr @.str.32, i64 1 }, ptr %taddr186, align 8 - %100 = insertvalue %any undef, ptr %taddr186, 0 - %101 = insertvalue %any %100, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %102 = getelementptr inbounds [2 x %any], ptr %varargslots185, i64 0, i64 0 - store %any %101, ptr %102, align 16 + %100 = insertvalue %"any*" undef, ptr %taddr186, 0 + %101 = insertvalue %"any*" %100, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %102 = getelementptr inbounds [2 x %"any*"], ptr %varargslots185, i64 0, i64 0 + store %"any*" %101, ptr %102, align 16 store %"char[]" { ptr @.str.33, i64 4 }, ptr %taddr187, align 8 - %103 = insertvalue %any undef, ptr %taddr187, 0 - %104 = insertvalue %any %103, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %105 = getelementptr inbounds [2 x %any], ptr %varargslots185, i64 0, i64 1 - store %any %104, ptr %105, align 16 + %103 = insertvalue %"any*" undef, ptr %taddr187, 0 + %104 = insertvalue %"any*" %103, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %105 = getelementptr inbounds [2 x %"any*"], ptr %varargslots185, i64 0, i64 1 + store %"any*" %104, ptr %105, align 16 %106 = call i64 @std.io.printfn(ptr %retparam184, ptr @.str.31, i64 6, ptr %varargslots185, i64 2) store %"char[]" { ptr @.str.35, i64 1 }, ptr %taddr192, align 8 - %107 = insertvalue %any undef, ptr %taddr192, 0 - %108 = insertvalue %any %107, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %109 = getelementptr inbounds [2 x %any], ptr %varargslots191, i64 0, i64 0 - store %any %108, ptr %109, align 16 + %107 = insertvalue %"any*" undef, ptr %taddr192, 0 + %108 = insertvalue %"any*" %107, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %109 = getelementptr inbounds [2 x %"any*"], ptr %varargslots191, i64 0, i64 0 + store %"any*" %108, ptr %109, align 16 store %"char[]" { ptr @.str.36, i64 5 }, ptr %taddr193, align 8 - %110 = insertvalue %any undef, ptr %taddr193, 0 - %111 = insertvalue %any %110, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %112 = getelementptr inbounds [2 x %any], ptr %varargslots191, i64 0, i64 1 - store %any %111, ptr %112, align 16 + %110 = insertvalue %"any*" undef, ptr %taddr193, 0 + %111 = insertvalue %"any*" %110, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %112 = getelementptr inbounds [2 x %"any*"], ptr %varargslots191, i64 0, i64 1 + store %"any*" %111, ptr %112, align 16 %113 = call i64 @std.io.printfn(ptr %retparam190, ptr @.str.34, i64 6, ptr %varargslots191, i64 2) store %"char[]" zeroinitializer, ptr %taddr198, align 8 - %114 = insertvalue %any undef, ptr %taddr198, 0 - %115 = insertvalue %any %114, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %116 = getelementptr inbounds [2 x %any], ptr %varargslots197, i64 0, i64 0 - store %any %115, ptr %116, align 16 + %114 = insertvalue %"any*" undef, ptr %taddr198, 0 + %115 = insertvalue %"any*" %114, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %116 = getelementptr inbounds [2 x %"any*"], ptr %varargslots197, i64 0, i64 0 + store %"any*" %115, ptr %116, align 16 store %"char[]" { ptr @.str.38, i64 5 }, ptr %taddr199, align 8 - %117 = insertvalue %any undef, ptr %taddr199, 0 - %118 = insertvalue %any %117, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %119 = getelementptr inbounds [2 x %any], ptr %varargslots197, i64 0, i64 1 - store %any %118, ptr %119, align 16 + %117 = insertvalue %"any*" undef, ptr %taddr199, 0 + %118 = insertvalue %"any*" %117, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %119 = getelementptr inbounds [2 x %"any*"], ptr %varargslots197, i64 0, i64 1 + store %"any*" %118, ptr %119, align 16 %120 = call i64 @std.io.printfn(ptr %retparam196, ptr @.str.37, i64 6, ptr %varargslots197, i64 2) store %"char[]" { ptr @.str.40, i64 3 }, ptr %taddr204, align 8 - %121 = insertvalue %any undef, ptr %taddr204, 0 - %122 = insertvalue %any %121, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %123 = getelementptr inbounds [2 x %any], ptr %varargslots203, i64 0, i64 0 - store %any %122, ptr %123, align 16 + %121 = insertvalue %"any*" undef, ptr %taddr204, 0 + %122 = insertvalue %"any*" %121, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %123 = getelementptr inbounds [2 x %"any*"], ptr %varargslots203, i64 0, i64 0 + store %"any*" %122, ptr %123, align 16 store %"char[]" { ptr @.str.41, i64 3 }, ptr %taddr205, align 8 - %124 = insertvalue %any undef, ptr %taddr205, 0 - %125 = insertvalue %any %124, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %126 = getelementptr inbounds [2 x %any], ptr %varargslots203, i64 0, i64 1 - store %any %125, ptr %126, align 16 + %124 = insertvalue %"any*" undef, ptr %taddr205, 0 + %125 = insertvalue %"any*" %124, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %126 = getelementptr inbounds [2 x %"any*"], ptr %varargslots203, i64 0, i64 1 + store %"any*" %125, ptr %126, align 16 %127 = call i64 @std.io.printfn(ptr %retparam202, ptr @.str.39, i64 6, ptr %varargslots203, i64 2) store %"char[]" { ptr @.str.43, i64 4 }, ptr %taddr210, align 8 - %128 = insertvalue %any undef, ptr %taddr210, 0 - %129 = insertvalue %any %128, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %130 = getelementptr inbounds [1 x %any], ptr %varargslots209, i64 0, i64 0 - store %any %129, ptr %130, align 16 + %128 = insertvalue %"any*" undef, ptr %taddr210, 0 + %129 = insertvalue %"any*" %128, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %130 = getelementptr inbounds [1 x %"any*"], ptr %varargslots209, i64 0, i64 0 + store %"any*" %129, ptr %130, align 16 %131 = call i64 @std.io.printfn(ptr %retparam208, ptr @.str.42, i64 8, ptr %varargslots209, i64 1) store %"char[]" { ptr @.str.45, i64 1 }, ptr %taddr215, align 8 - %132 = insertvalue %any undef, ptr %taddr215, 0 - %133 = insertvalue %any %132, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %134 = getelementptr inbounds [2 x %any], ptr %varargslots214, i64 0, i64 0 - store %any %133, ptr %134, align 16 + %132 = insertvalue %"any*" undef, ptr %taddr215, 0 + %133 = insertvalue %"any*" %132, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %134 = getelementptr inbounds [2 x %"any*"], ptr %varargslots214, i64 0, i64 0 + store %"any*" %133, ptr %134, align 16 store %"char[]" { ptr @.str.46, i64 3 }, ptr %taddr216, align 8 - %135 = insertvalue %any undef, ptr %taddr216, 0 - %136 = insertvalue %any %135, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %137 = getelementptr inbounds [2 x %any], ptr %varargslots214, i64 0, i64 1 - store %any %136, ptr %137, align 16 + %135 = insertvalue %"any*" undef, ptr %taddr216, 0 + %136 = insertvalue %"any*" %135, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %137 = getelementptr inbounds [2 x %"any*"], ptr %varargslots214, i64 0, i64 1 + store %"any*" %136, ptr %137, align 16 %138 = call i64 @std.io.printfn(ptr %retparam213, ptr @.str.44, i64 6, ptr %varargslots214, i64 2) store %"char[]" { ptr @.str.48, i64 1 }, ptr %taddr221, align 8 - %139 = insertvalue %any undef, ptr %taddr221, 0 - %140 = insertvalue %any %139, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %141 = getelementptr inbounds [2 x %any], ptr %varargslots220, i64 0, i64 0 - store %any %140, ptr %141, align 16 + %139 = insertvalue %"any*" undef, ptr %taddr221, 0 + %140 = insertvalue %"any*" %139, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %141 = getelementptr inbounds [2 x %"any*"], ptr %varargslots220, i64 0, i64 0 + store %"any*" %140, ptr %141, align 16 store %"char[]" { ptr @.str.49, i64 5 }, ptr %taddr222, align 8 - %142 = insertvalue %any undef, ptr %taddr222, 0 - %143 = insertvalue %any %142, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %144 = getelementptr inbounds [2 x %any], ptr %varargslots220, i64 0, i64 1 - store %any %143, ptr %144, align 16 + %142 = insertvalue %"any*" undef, ptr %taddr222, 0 + %143 = insertvalue %"any*" %142, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %144 = getelementptr inbounds [2 x %"any*"], ptr %varargslots220, i64 0, i64 1 + store %"any*" %143, ptr %144, align 16 %145 = call i64 @std.io.printfn(ptr %retparam219, ptr @.str.47, i64 6, ptr %varargslots220, i64 2) ret void } @@ -635,151 +635,151 @@ voiderr151: ; preds = %noerr_block149, %gu define void @test.main() #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i64, align 8 %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [1 x %any], align 16 + %varargslots2 = alloca [1 x %"any*"], align 16 %taddr3 = alloca i64, align 8 %retparam4 = alloca i64, align 8 - %varargslots5 = alloca [2 x %any], align 16 + %varargslots5 = alloca [2 x %"any*"], align 16 %taddr6 = alloca i64, align 8 %taddr7 = alloca i64, align 8 %retparam8 = alloca i64, align 8 - %varargslots9 = alloca [2 x %any], align 16 + %varargslots9 = alloca [2 x %"any*"], align 16 %taddr10 = alloca i64, align 8 %taddr11 = alloca i64, align 8 %retparam12 = alloca i64, align 8 - %varargslots13 = alloca [2 x %any], align 16 + %varargslots13 = alloca [2 x %"any*"], align 16 %taddr14 = alloca i64, align 8 %taddr15 = alloca i64, align 8 %retparam16 = alloca i64, align 8 - %varargslots17 = alloca [2 x %any], align 16 + %varargslots17 = alloca [2 x %"any*"], align 16 %taddr18 = alloca i64, align 8 %taddr19 = alloca i64, align 8 %retparam20 = alloca i64, align 8 - %varargslots21 = alloca [2 x %any], align 16 + %varargslots21 = alloca [2 x %"any*"], align 16 %taddr22 = alloca i64, align 8 %taddr23 = alloca i64, align 8 %retparam24 = alloca i64, align 8 - %varargslots25 = alloca [2 x %any], align 16 + %varargslots25 = alloca [2 x %"any*"], align 16 %taddr26 = alloca i64, align 8 %taddr27 = alloca i64, align 8 %retparam28 = alloca i64, align 8 - %varargslots29 = alloca [2 x %any], align 16 + %varargslots29 = alloca [2 x %"any*"], align 16 %taddr30 = alloca i64, align 8 %taddr31 = alloca i64, align 8 %retparam32 = alloca i64, align 8 - %varargslots33 = alloca [1 x %any], align 16 + %varargslots33 = alloca [1 x %"any*"], align 16 %taddr34 = alloca i64, align 8 %retparam35 = alloca i64, align 8 - %varargslots36 = alloca [2 x %any], align 16 + %varargslots36 = alloca [2 x %"any*"], align 16 %taddr37 = alloca i64, align 8 %taddr38 = alloca i64, align 8 store i64 4, ptr %taddr, align 8 - %0 = insertvalue %any undef, ptr %taddr, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %2 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %1, ptr %2, align 16 + %0 = insertvalue %"any*" undef, ptr %taddr, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %2 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %1, ptr %2, align 16 %3 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.50, i64 7, ptr %varargslots, i64 1) store i64 1, ptr %taddr3, align 8 - %4 = insertvalue %any undef, ptr %taddr3, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %6 = getelementptr inbounds [1 x %any], ptr %varargslots2, i64 0, i64 0 - store %any %5, ptr %6, align 16 + %4 = insertvalue %"any*" undef, ptr %taddr3, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %6 = getelementptr inbounds [1 x %"any*"], ptr %varargslots2, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 %7 = call i64 @std.io.printfn(ptr %retparam1, ptr @.str.51, i64 7, ptr %varargslots2, i64 1) store i64 0, ptr %taddr6, align 8 - %8 = insertvalue %any undef, ptr %taddr6, 0 - %9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %10 = getelementptr inbounds [2 x %any], ptr %varargslots5, i64 0, i64 0 - store %any %9, ptr %10, align 16 + %8 = insertvalue %"any*" undef, ptr %taddr6, 0 + %9 = insertvalue %"any*" %8, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %10 = getelementptr inbounds [2 x %"any*"], ptr %varargslots5, i64 0, i64 0 + store %"any*" %9, ptr %10, align 16 store i64 4, ptr %taddr7, align 8 - %11 = insertvalue %any undef, ptr %taddr7, 0 - %12 = insertvalue %any %11, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %13 = getelementptr inbounds [2 x %any], ptr %varargslots5, i64 0, i64 1 - store %any %12, ptr %13, align 16 + %11 = insertvalue %"any*" undef, ptr %taddr7, 0 + %12 = insertvalue %"any*" %11, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %13 = getelementptr inbounds [2 x %"any*"], ptr %varargslots5, i64 0, i64 1 + store %"any*" %12, ptr %13, align 16 %14 = call i64 @std.io.printfn(ptr %retparam4, ptr @.str.52, i64 8, ptr %varargslots5, i64 2) store i64 2, ptr %taddr10, align 8 - %15 = insertvalue %any undef, ptr %taddr10, 0 - %16 = insertvalue %any %15, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %17 = getelementptr inbounds [2 x %any], ptr %varargslots9, i64 0, i64 0 - store %any %16, ptr %17, align 16 + %15 = insertvalue %"any*" undef, ptr %taddr10, 0 + %16 = insertvalue %"any*" %15, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %17 = getelementptr inbounds [2 x %"any*"], ptr %varargslots9, i64 0, i64 0 + store %"any*" %16, ptr %17, align 16 store i64 2, ptr %taddr11, align 8 - %18 = insertvalue %any undef, ptr %taddr11, 0 - %19 = insertvalue %any %18, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %20 = getelementptr inbounds [2 x %any], ptr %varargslots9, i64 0, i64 1 - store %any %19, ptr %20, align 16 + %18 = insertvalue %"any*" undef, ptr %taddr11, 0 + %19 = insertvalue %"any*" %18, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %20 = getelementptr inbounds [2 x %"any*"], ptr %varargslots9, i64 0, i64 1 + store %"any*" %19, ptr %20, align 16 %21 = call i64 @std.io.printfn(ptr %retparam8, ptr @.str.53, i64 8, ptr %varargslots9, i64 2) store i64 4, ptr %taddr14, align 8 - %22 = insertvalue %any undef, ptr %taddr14, 0 - %23 = insertvalue %any %22, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %24 = getelementptr inbounds [2 x %any], ptr %varargslots13, i64 0, i64 0 - store %any %23, ptr %24, align 16 + %22 = insertvalue %"any*" undef, ptr %taddr14, 0 + %23 = insertvalue %"any*" %22, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %24 = getelementptr inbounds [2 x %"any*"], ptr %varargslots13, i64 0, i64 0 + store %"any*" %23, ptr %24, align 16 store i64 4, ptr %taddr15, align 8 - %25 = insertvalue %any undef, ptr %taddr15, 0 - %26 = insertvalue %any %25, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %27 = getelementptr inbounds [2 x %any], ptr %varargslots13, i64 0, i64 1 - store %any %26, ptr %27, align 16 + %25 = insertvalue %"any*" undef, ptr %taddr15, 0 + %26 = insertvalue %"any*" %25, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %27 = getelementptr inbounds [2 x %"any*"], ptr %varargslots13, i64 0, i64 1 + store %"any*" %26, ptr %27, align 16 %28 = call i64 @std.io.printfn(ptr %retparam12, ptr @.str.54, i64 8, ptr %varargslots13, i64 2) store i64 4, ptr %taddr18, align 8 - %29 = insertvalue %any undef, ptr %taddr18, 0 - %30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %31 = getelementptr inbounds [2 x %any], ptr %varargslots17, i64 0, i64 0 - store %any %30, ptr %31, align 16 + %29 = insertvalue %"any*" undef, ptr %taddr18, 0 + %30 = insertvalue %"any*" %29, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %31 = getelementptr inbounds [2 x %"any*"], ptr %varargslots17, i64 0, i64 0 + store %"any*" %30, ptr %31, align 16 store i64 4, ptr %taddr19, align 8 - %32 = insertvalue %any undef, ptr %taddr19, 0 - %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %34 = getelementptr inbounds [2 x %any], ptr %varargslots17, i64 0, i64 1 - store %any %33, ptr %34, align 16 + %32 = insertvalue %"any*" undef, ptr %taddr19, 0 + %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %34 = getelementptr inbounds [2 x %"any*"], ptr %varargslots17, i64 0, i64 1 + store %"any*" %33, ptr %34, align 16 %35 = call i64 @std.io.printfn(ptr %retparam16, ptr @.str.55, i64 8, ptr %varargslots17, i64 2) store i64 4, ptr %taddr22, align 8 - %36 = insertvalue %any undef, ptr %taddr22, 0 - %37 = insertvalue %any %36, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %38 = getelementptr inbounds [2 x %any], ptr %varargslots21, i64 0, i64 0 - store %any %37, ptr %38, align 16 + %36 = insertvalue %"any*" undef, ptr %taddr22, 0 + %37 = insertvalue %"any*" %36, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %38 = getelementptr inbounds [2 x %"any*"], ptr %varargslots21, i64 0, i64 0 + store %"any*" %37, ptr %38, align 16 store i64 4, ptr %taddr23, align 8 - %39 = insertvalue %any undef, ptr %taddr23, 0 - %40 = insertvalue %any %39, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %41 = getelementptr inbounds [2 x %any], ptr %varargslots21, i64 0, i64 1 - store %any %40, ptr %41, align 16 + %39 = insertvalue %"any*" undef, ptr %taddr23, 0 + %40 = insertvalue %"any*" %39, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %41 = getelementptr inbounds [2 x %"any*"], ptr %varargslots21, i64 0, i64 1 + store %"any*" %40, ptr %41, align 16 %42 = call i64 @std.io.printfn(ptr %retparam20, ptr @.str.56, i64 9, ptr %varargslots21, i64 2) store i64 5, ptr %taddr26, align 8 - %43 = insertvalue %any undef, ptr %taddr26, 0 - %44 = insertvalue %any %43, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %45 = getelementptr inbounds [2 x %any], ptr %varargslots25, i64 0, i64 0 - store %any %44, ptr %45, align 16 + %43 = insertvalue %"any*" undef, ptr %taddr26, 0 + %44 = insertvalue %"any*" %43, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %45 = getelementptr inbounds [2 x %"any*"], ptr %varargslots25, i64 0, i64 0 + store %"any*" %44, ptr %45, align 16 store i64 1, ptr %taddr27, align 8 - %46 = insertvalue %any undef, ptr %taddr27, 0 - %47 = insertvalue %any %46, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %48 = getelementptr inbounds [2 x %any], ptr %varargslots25, i64 0, i64 1 - store %any %47, ptr %48, align 16 + %46 = insertvalue %"any*" undef, ptr %taddr27, 0 + %47 = insertvalue %"any*" %46, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %48 = getelementptr inbounds [2 x %"any*"], ptr %varargslots25, i64 0, i64 1 + store %"any*" %47, ptr %48, align 16 %49 = call i64 @std.io.printfn(ptr %retparam24, ptr @.str.57, i64 9, ptr %varargslots25, i64 2) store i64 8, ptr %taddr30, align 8 - %50 = insertvalue %any undef, ptr %taddr30, 0 - %51 = insertvalue %any %50, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %52 = getelementptr inbounds [2 x %any], ptr %varargslots29, i64 0, i64 0 - store %any %51, ptr %52, align 16 + %50 = insertvalue %"any*" undef, ptr %taddr30, 0 + %51 = insertvalue %"any*" %50, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %52 = getelementptr inbounds [2 x %"any*"], ptr %varargslots29, i64 0, i64 0 + store %"any*" %51, ptr %52, align 16 store i64 4, ptr %taddr31, align 8 - %53 = insertvalue %any undef, ptr %taddr31, 0 - %54 = insertvalue %any %53, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %55 = getelementptr inbounds [2 x %any], ptr %varargslots29, i64 0, i64 1 - store %any %54, ptr %55, align 16 + %53 = insertvalue %"any*" undef, ptr %taddr31, 0 + %54 = insertvalue %"any*" %53, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %55 = getelementptr inbounds [2 x %"any*"], ptr %varargslots29, i64 0, i64 1 + store %"any*" %54, ptr %55, align 16 %56 = call i64 @std.io.printfn(ptr %retparam28, ptr @.str.58, i64 10, ptr %varargslots29, i64 2) store i64 4, ptr %taddr34, align 8 - %57 = insertvalue %any undef, ptr %taddr34, 0 - %58 = insertvalue %any %57, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %59 = getelementptr inbounds [1 x %any], ptr %varargslots33, i64 0, i64 0 - store %any %58, ptr %59, align 16 + %57 = insertvalue %"any*" undef, ptr %taddr34, 0 + %58 = insertvalue %"any*" %57, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %59 = getelementptr inbounds [1 x %"any*"], ptr %varargslots33, i64 0, i64 0 + store %"any*" %58, ptr %59, align 16 %60 = call i64 @std.io.printfn(ptr %retparam32, ptr @.str.59, i64 7, ptr %varargslots33, i64 1) store i64 8, ptr %taddr37, align 8 - %61 = insertvalue %any undef, ptr %taddr37, 0 - %62 = insertvalue %any %61, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %63 = getelementptr inbounds [2 x %any], ptr %varargslots36, i64 0, i64 0 - store %any %62, ptr %63, align 16 + %61 = insertvalue %"any*" undef, ptr %taddr37, 0 + %62 = insertvalue %"any*" %61, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %63 = getelementptr inbounds [2 x %"any*"], ptr %varargslots36, i64 0, i64 0 + store %"any*" %62, ptr %63, align 16 store i64 4, ptr %taddr38, align 8 - %64 = insertvalue %any undef, ptr %taddr38, 0 - %65 = insertvalue %any %64, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %66 = getelementptr inbounds [2 x %any], ptr %varargslots36, i64 0, i64 1 - store %any %65, ptr %66, align 16 + %64 = insertvalue %"any*" undef, ptr %taddr38, 0 + %65 = insertvalue %"any*" %64, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %66 = getelementptr inbounds [2 x %"any*"], ptr %varargslots36, i64 0, i64 1 + store %"any*" %65, ptr %66, align 16 %67 = call i64 @std.io.printfn(ptr %retparam35, ptr @.str.60, i64 10, ptr %varargslots36, i64 2) call void @test.test(i32 10) ret void diff --git a/test/test_suite/compile_time/untyped_conversions.c3t b/test/test_suite/compile_time/untyped_conversions.c3t index cee0535eb..a9d52cad2 100644 --- a/test/test_suite/compile_time/untyped_conversions.c3t +++ b/test/test_suite/compile_time/untyped_conversions.c3t @@ -27,7 +27,7 @@ fn void main() %.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] } %Foo = type { i32, i32 } %"int[]" = type { ptr, i64 } -%any = type { ptr, i64 } +%"any*" = type { ptr, i64 } @"$ct.test.Foo" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 @.str = private unnamed_addr constant [9 x i8] c"%s %s %s\00", align 1 @@ -56,24 +56,24 @@ entry: %b = alloca %"int[]", align 8 %c = alloca <2 x i32>, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [3 x %any], align 16 + %varargslots = alloca [3 x %"any*"], align 16 store i64 %0, ptr %a, align 4 store ptr %1, ptr %b, align 8 %ptroffset = getelementptr inbounds i64, ptr %b, i64 1 store i64 %2, ptr %ptroffset, align 8 store double %3, ptr %c, align 8 - %4 = insertvalue %any undef, ptr %a, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.a2$int" to i64), 1 - %6 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 0 - store %any %5, ptr %6, align 16 - %7 = insertvalue %any undef, ptr %b, 0 - %8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.sa$int" to i64), 1 - %9 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 1 - store %any %8, ptr %9, align 16 - %10 = insertvalue %any undef, ptr %c, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.v2$int" to i64), 1 - %12 = getelementptr inbounds [3 x %any], ptr %varargslots, i64 0, i64 2 - store %any %11, ptr %12, align 16 + %4 = insertvalue %"any*" undef, ptr %a, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.a2$int" to i64), 1 + %6 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 + %7 = insertvalue %"any*" undef, ptr %b, 0 + %8 = insertvalue %"any*" %7, i64 ptrtoint (ptr @"$ct.sa$int" to i64), 1 + %9 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %8, ptr %9, align 16 + %10 = insertvalue %"any*" undef, ptr %c, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.v2$int" to i64), 1 + %12 = getelementptr inbounds [3 x %"any*"], ptr %varargslots, i64 0, i64 2 + store %"any*" %11, ptr %12, align 16 %13 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 8, ptr %varargslots, i64 3) ret void } @@ -86,7 +86,7 @@ entry: %y = alloca [1 x [2 x i32]], align 4 %y2 = alloca [1 x [2 x double]], align 16 %retparam = alloca i64, align 8 - %varargslots = alloca [4 x %any], align 16 + %varargslots = alloca [4 x %"any*"], align 16 %literal = alloca [2 x i32], align 4 %literal1 = alloca [2 x i32], align 4 %taddr = alloca <2 x i32>, align 8 @@ -97,24 +97,24 @@ entry: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %defg, ptr align 4 @.__const.1, i32 8, i1 false) call void @llvm.memcpy.p0.p0.i32(ptr align 4 %y, ptr align 4 @.__const.2, i32 8, i1 false) call void @llvm.memcpy.p0.p0.i32(ptr align 16 %y2, ptr align 16 @.__const.3, i32 16, i1 false) - %0 = insertvalue %any undef, ptr %y, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.a1$a2$int" to i64), 1 - %2 = getelementptr inbounds [4 x %any], ptr %varargslots, i64 0, i64 0 - store %any %1, ptr %2, align 16 - %3 = insertvalue %any undef, ptr %y2, 0 - %4 = insertvalue %any %3, i64 ptrtoint (ptr @"$ct.a1$a2$double" to i64), 1 - %5 = getelementptr inbounds [4 x %any], ptr %varargslots, i64 0, i64 1 - store %any %4, ptr %5, align 16 + %0 = insertvalue %"any*" undef, ptr %y, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.a1$a2$int" to i64), 1 + %2 = getelementptr inbounds [4 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %1, ptr %2, align 16 + %3 = insertvalue %"any*" undef, ptr %y2, 0 + %4 = insertvalue %"any*" %3, i64 ptrtoint (ptr @"$ct.a1$a2$double" to i64), 1 + %5 = getelementptr inbounds [4 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %4, ptr %5, align 16 %6 = getelementptr inbounds %Foo, ptr %defg, i32 0, i32 0 - %7 = insertvalue %any undef, ptr %6, 0 - %8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %9 = getelementptr inbounds [4 x %any], ptr %varargslots, i64 0, i64 2 - store %any %8, ptr %9, align 16 + %7 = insertvalue %"any*" undef, ptr %6, 0 + %8 = insertvalue %"any*" %7, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %9 = getelementptr inbounds [4 x %"any*"], ptr %varargslots, i64 0, i64 2 + store %"any*" %8, ptr %9, align 16 %10 = getelementptr inbounds %Foo, ptr %defg, i32 0, i32 1 - %11 = insertvalue %any undef, ptr %10, 0 - %12 = insertvalue %any %11, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %13 = getelementptr inbounds [4 x %any], ptr %varargslots, i64 0, i64 3 - store %any %12, ptr %13, align 16 + %11 = insertvalue %"any*" undef, ptr %10, 0 + %12 = insertvalue %"any*" %11, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %13 = getelementptr inbounds [4 x %"any*"], ptr %varargslots, i64 0, i64 3 + store %"any*" %12, ptr %13, align 16 %14 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.4, i64 14, ptr %varargslots, i64 4) call void @llvm.memcpy.p0.p0.i32(ptr align 4 %literal, ptr align 4 @.__const.5, i32 8, i1 false) %15 = load i64, ptr %literal, align 4 diff --git a/test/test_suite/concurrency/atomic_load_store.c3t b/test/test_suite/concurrency/atomic_load_store.c3t index 3eec6d2e0..bdda5ab96 100644 --- a/test/test_suite/concurrency/atomic_load_store.c3t +++ b/test/test_suite/concurrency/atomic_load_store.c3t @@ -26,7 +26,7 @@ entry: %x = alloca i32, align 4 %y = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 store i32 111, ptr %a, align 4 %0 = load atomic i32, ptr %a seq_cst, align 4 store i32 %0, ptr %x, align 4 @@ -38,10 +38,10 @@ entry: %3 = load i32, ptr %y, align 4 %add1 = add i32 33, %3 store atomic volatile i32 %add1, ptr %a monotonic, align 4 - %4 = insertvalue %any undef, ptr %a, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %6 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %5, ptr %6, align 16 + %4 = insertvalue %"any*" undef, ptr %a, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %6 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 %7 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) ret void } diff --git a/test/test_suite/concurrency/atomic_load_store_debug.c3t b/test/test_suite/concurrency/atomic_load_store_debug.c3t index b9b90b816..081f59368 100644 --- a/test/test_suite/concurrency/atomic_load_store_debug.c3t +++ b/test/test_suite/concurrency/atomic_load_store_debug.c3t @@ -21,7 +21,7 @@ fn void main() /* #expect: test.ll %.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] } -%any = type { ptr, i64 } +%"any*" = type { ptr, i64 } @"$ct.test.Ghh" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 12, i64 0, i64 3, [0 x i64] zeroinitializer }, align 8 @.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 @"$ct.int" = linkonce global %.introspect { i8 2, i64 0, ptr null, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 @@ -32,7 +32,7 @@ entry: %x = alloca i32, align 4 %y = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 call void @llvm.dbg.declare(metadata ptr %a, metadata !9, metadata !DIExpression()), !dbg !11 store i32 111, ptr %a, align 4, !dbg !12 call void @llvm.dbg.declare(metadata ptr %x, metadata !13, metadata !DIExpression()), !dbg !14 @@ -47,10 +47,10 @@ entry: %3 = load i32, ptr %y, align 4, !dbg !26 %add1 = add i32 33, %3, !dbg !27 store atomic volatile i32 %add1, ptr %a monotonic, align 4, !dbg !28 - %4 = insertvalue %any undef, ptr %a, 0, !dbg !30 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1, !dbg !30 - %6 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0, !dbg !30 - store %any %5, ptr %6, align 16, !dbg !30 + %4 = insertvalue %"any*" undef, ptr %a, 0, !dbg !30 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1, !dbg !30 + %6 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0, !dbg !30 + store %"any*" %5, ptr %6, align 16, !dbg !30 %7 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1), !dbg !31 ret void, !dbg !31 } diff --git a/test/test_suite/define/forbidden_defines.c3 b/test/test_suite/define/forbidden_defines.c3 index 67607c812..49f236ec0 100644 --- a/test/test_suite/define/forbidden_defines.c3 +++ b/test/test_suite/define/forbidden_defines.c3 @@ -1,3 +1,3 @@ def Abc = int[*]; // #error: Inferred array types can only def Bcd = anyfault; -def Efd = any; +def Efd = any*; diff --git a/test/test_suite/dynamic/dynamic_mismatch.c3 b/test/test_suite/dynamic/dynamic_mismatch.c3 index e9ad10784..442d3655b 100644 --- a/test/test_suite/dynamic/dynamic_mismatch.c3 +++ b/test/test_suite/dynamic/dynamic_mismatch.c3 @@ -1,21 +1,25 @@ -fn int any.test(void* a, int ag) @interface; +protocol TestProto +{ + fn int test(&self, int ag); +} + struct Foo { int a; } -fn int! Foo.test(Foo* f) @dynamic { return 1; } // #error: The prototype method has a return type 'int' +fn int! Foo.test(Foo* f) : TestProto { return 1; } // #error: The prototype method has a return type 'int' struct Foo1 { int a; } -fn int Foo1.test(Foo1* f, int a) @dynamic { return 1; } +fn int Foo1.test(Foo1* f, int a) : TestProto { return 1; } struct Foo2 { int a; } -fn int Foo2.test(Foo2* f) @dynamic { return 1; } // #error: This function is missing parameters, 2 +fn int Foo2.test(Foo2* f) : TestProto { return 1; } // #error: This function is missing parameters, 2 struct Foo3 { int a; } -fn int Foo3.test(Foo3* f, double a) @dynamic { return 1; } // #error: The prototype argument has type 'int' +fn int Foo3.test(Foo3* f, double a) : TestProto { return 1; } // #error: The prototype argument has type 'int' struct Foo4 { int a; } -fn int Foo4.test(Foo4* f, double a, int x) @dynamic { return 1; } // #error: This function has too many parameters +fn int Foo4.test(Foo4* f, double a, int x) : TestProto { return 1; } // #error: This function has too many parameters diff --git a/test/test_suite/enumerations/enum_associated_values_other.c3t b/test/test_suite/enumerations/enum_associated_values_other.c3t index 8c1e3adce..32643bf66 100644 --- a/test/test_suite/enumerations/enum_associated_values_other.c3t +++ b/test/test_suite/enumerations/enum_associated_values_other.c3t @@ -61,7 +61,7 @@ entry: %a = alloca i32, align 4 %z = alloca %"char[]", align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 store ptr %0, ptr %args, align 8 %ptroffset = getelementptr inbounds i64, ptr %args, i64 1 store i64 %1, ptr %ptroffset, align 8 @@ -71,10 +71,10 @@ entry: %2 = load i32, ptr %a, align 4 %3 = getelementptr inbounds [2 x %"char[]"], ptr @"abc.Foo$val", i32 0, i32 %2 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %z, ptr align 8 %3, i32 16, i1 false) - %4 = insertvalue %any undef, ptr %z, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %6 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %5, ptr %6, align 16 + %4 = insertvalue %"any*" undef, ptr %z, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %6 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 %7 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.2, i64 2, ptr %varargslots, i64 1) ret void } \ No newline at end of file diff --git a/test/test_suite/enumerations/enum_conversions.c3t b/test/test_suite/enumerations/enum_conversions.c3t index 8995c7d15..4454a118f 100644 --- a/test/test_suite/enumerations/enum_conversions.c3t +++ b/test/test_suite/enumerations/enum_conversions.c3t @@ -30,14 +30,14 @@ entry: panic: ; preds = %entry store i32 %0, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 - %4 = insertvalue %"any[]" undef, ptr %varargslots, 0 - %"#temp#" = insertvalue %"any[]" %4, i64 1, 1 - store %"any[]" %"#temp#", ptr %indirectarg, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 7, ptr @.file, i64 19, ptr @.func, i64 4, i32 7, ptr byval(%"any[]") align 8 %indirectarg) + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 + %4 = insertvalue %"any*[]" undef, ptr %varargslots, 0 + %"#temp#" = insertvalue %"any*[]" %4, i64 1, 1 + store %"any*[]" %"#temp#", ptr %indirectarg, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 7, ptr @.file, i64 19, ptr @.func, i64 4, i32 7, ptr byval(%"any*[]") align 8 %indirectarg) br label %checkok checkok: ; preds = %panic, %entry @@ -46,14 +46,14 @@ checkok: ; preds = %panic, %entry panic1: ; preds = %checkok store i32 %0, ptr %taddr2, align 4 - %5 = insertvalue %any undef, ptr %taddr2, 0 - %6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %7 = getelementptr inbounds [1 x %any], ptr %varargslots3, i64 0, i64 0 - store %any %6, ptr %7, align 16 - %8 = insertvalue %"any[]" undef, ptr %varargslots3, 0 - %"#temp#4" = insertvalue %"any[]" %8, i64 1, 1 - store %"any[]" %"#temp#4", ptr %indirectarg5, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 7, ptr byval(%"any[]") align 8 %indirectarg5) + %5 = insertvalue %"any*" undef, ptr %taddr2, 0 + %6 = insertvalue %"any*" %5, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %7 = getelementptr inbounds [1 x %"any*"], ptr %varargslots3, i64 0, i64 0 + store %"any*" %6, ptr %7, align 16 + %8 = insertvalue %"any*[]" undef, ptr %varargslots3, 0 + %"#temp#4" = insertvalue %"any*[]" %8, i64 1, 1 + store %"any*[]" %"#temp#4", ptr %indirectarg5, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 7, ptr byval(%"any*[]") align 8 %indirectarg5) br label %checkok6 checkok6: ; preds = %panic1, %checkok @@ -66,14 +66,14 @@ checkok6: ; preds = %panic1, %checkok panic8: ; preds = %checkok6 store i64 %9, ptr %taddr9, align 8 - %10 = insertvalue %any undef, ptr %taddr9, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %12 = getelementptr inbounds [1 x %any], ptr %varargslots10, i64 0, i64 0 - store %any %11, ptr %12, align 16 - %13 = insertvalue %"any[]" undef, ptr %varargslots10, 0 - %"#temp#11" = insertvalue %"any[]" %13, i64 1, 1 - store %"any[]" %"#temp#11", ptr %indirectarg12, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg.2, i64 8, ptr @.file, i64 19, ptr @.func, i64 4, i32 9, ptr byval(%"any[]") align 8 %indirectarg12) + %10 = insertvalue %"any*" undef, ptr %taddr9, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %12 = getelementptr inbounds [1 x %"any*"], ptr %varargslots10, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 + %13 = insertvalue %"any*[]" undef, ptr %varargslots10, 0 + %"#temp#11" = insertvalue %"any*[]" %13, i64 1, 1 + store %"any*[]" %"#temp#11", ptr %indirectarg12, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg.2, i64 8, ptr @.file, i64 19, ptr @.func, i64 4, i32 9, ptr byval(%"any*[]") align 8 %indirectarg12) br label %checkok13 checkok13: ; preds = %panic8, %checkok6 @@ -82,14 +82,14 @@ checkok13: ; preds = %panic8, %checkok6 panic15: ; preds = %checkok13 store i64 %9, ptr %taddr16, align 8 - %14 = insertvalue %any undef, ptr %taddr16, 0 - %15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %16 = getelementptr inbounds [1 x %any], ptr %varargslots17, i64 0, i64 0 - store %any %15, ptr %16, align 16 - %17 = insertvalue %"any[]" undef, ptr %varargslots17, 0 - %"#temp#18" = insertvalue %"any[]" %17, i64 1, 1 - store %"any[]" %"#temp#18", ptr %indirectarg19, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 9, ptr byval(%"any[]") align 8 %indirectarg19) + %14 = insertvalue %"any*" undef, ptr %taddr16, 0 + %15 = insertvalue %"any*" %14, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %16 = getelementptr inbounds [1 x %"any*"], ptr %varargslots17, i64 0, i64 0 + store %"any*" %15, ptr %16, align 16 + %17 = insertvalue %"any*[]" undef, ptr %varargslots17, 0 + %"#temp#18" = insertvalue %"any*[]" %17, i64 1, 1 + store %"any*[]" %"#temp#18", ptr %indirectarg19, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 9, ptr byval(%"any*[]") align 8 %indirectarg19) br label %checkok20 checkok20: ; preds = %panic15, %checkok13 @@ -102,14 +102,14 @@ checkok20: ; preds = %panic15, %checkok13 panic23: ; preds = %checkok20 store i32 %18, ptr %taddr24, align 4 - %19 = insertvalue %any undef, ptr %taddr24, 0 - %20 = insertvalue %any %19, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %21 = getelementptr inbounds [1 x %any], ptr %varargslots25, i64 0, i64 0 - store %any %20, ptr %21, align 16 - %22 = insertvalue %"any[]" undef, ptr %varargslots25, 0 - %"#temp#26" = insertvalue %"any[]" %22, i64 1, 1 - store %"any[]" %"#temp#26", ptr %indirectarg27, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg.3, i64 62, ptr @.file, i64 19, ptr @.func, i64 4, i32 11, ptr byval(%"any[]") align 8 %indirectarg27) + %19 = insertvalue %"any*" undef, ptr %taddr24, 0 + %20 = insertvalue %"any*" %19, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %21 = getelementptr inbounds [1 x %"any*"], ptr %varargslots25, i64 0, i64 0 + store %"any*" %20, ptr %21, align 16 + %22 = insertvalue %"any*[]" undef, ptr %varargslots25, 0 + %"#temp#26" = insertvalue %"any*[]" %22, i64 1, 1 + store %"any*[]" %"#temp#26", ptr %indirectarg27, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg.3, i64 62, ptr @.file, i64 19, ptr @.func, i64 4, i32 11, ptr byval(%"any*[]") align 8 %indirectarg27) br label %checkok28 checkok28: ; preds = %panic23, %checkok20 @@ -118,14 +118,14 @@ checkok28: ; preds = %panic23, %checkok20 panic30: ; preds = %checkok28 store i32 %18, ptr %taddr31, align 4 - %23 = insertvalue %any undef, ptr %taddr31, 0 - %24 = insertvalue %any %23, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %25 = getelementptr inbounds [1 x %any], ptr %varargslots32, i64 0, i64 0 - store %any %24, ptr %25, align 16 - %26 = insertvalue %"any[]" undef, ptr %varargslots32, 0 - %"#temp#33" = insertvalue %"any[]" %26, i64 1, 1 - store %"any[]" %"#temp#33", ptr %indirectarg34, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 11, ptr byval(%"any[]") align 8 %indirectarg34) + %23 = insertvalue %"any*" undef, ptr %taddr31, 0 + %24 = insertvalue %"any*" %23, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %25 = getelementptr inbounds [1 x %"any*"], ptr %varargslots32, i64 0, i64 0 + store %"any*" %24, ptr %25, align 16 + %26 = insertvalue %"any*[]" undef, ptr %varargslots32, 0 + %"#temp#33" = insertvalue %"any*[]" %26, i64 1, 1 + store %"any*[]" %"#temp#33", ptr %indirectarg34, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 11, ptr byval(%"any*[]") align 8 %indirectarg34) br label %checkok35 checkok35: ; preds = %panic30, %checkok28 @@ -138,14 +138,14 @@ checkok35: ; preds = %panic30, %checkok28 panic38: ; preds = %checkok35 store i32 %27, ptr %taddr39, align 4 - %28 = insertvalue %any undef, ptr %taddr39, 0 - %29 = insertvalue %any %28, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %30 = getelementptr inbounds [1 x %any], ptr %varargslots40, i64 0, i64 0 - store %any %29, ptr %30, align 16 - %31 = insertvalue %"any[]" undef, ptr %varargslots40, 0 - %"#temp#41" = insertvalue %"any[]" %31, i64 1, 1 - store %"any[]" %"#temp#41", ptr %indirectarg42, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg.3, i64 62, ptr @.file, i64 19, ptr @.func, i64 4, i32 13, ptr byval(%"any[]") align 8 %indirectarg42) + %28 = insertvalue %"any*" undef, ptr %taddr39, 0 + %29 = insertvalue %"any*" %28, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %30 = getelementptr inbounds [1 x %"any*"], ptr %varargslots40, i64 0, i64 0 + store %"any*" %29, ptr %30, align 16 + %31 = insertvalue %"any*[]" undef, ptr %varargslots40, 0 + %"#temp#41" = insertvalue %"any*[]" %31, i64 1, 1 + store %"any*[]" %"#temp#41", ptr %indirectarg42, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg.3, i64 62, ptr @.file, i64 19, ptr @.func, i64 4, i32 13, ptr byval(%"any*[]") align 8 %indirectarg42) br label %checkok43 checkok43: ; preds = %panic38, %checkok35 @@ -154,14 +154,14 @@ checkok43: ; preds = %panic38, %checkok35 panic45: ; preds = %checkok43 store i32 %27, ptr %taddr46, align 4 - %32 = insertvalue %any undef, ptr %taddr46, 0 - %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %34 = getelementptr inbounds [1 x %any], ptr %varargslots47, i64 0, i64 0 - store %any %33, ptr %34, align 16 - %35 = insertvalue %"any[]" undef, ptr %varargslots47, 0 - %"#temp#48" = insertvalue %"any[]" %35, i64 1, 1 - store %"any[]" %"#temp#48", ptr %indirectarg49, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 13, ptr byval(%"any[]") align 8 %indirectarg49) + %32 = insertvalue %"any*" undef, ptr %taddr46, 0 + %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %34 = getelementptr inbounds [1 x %"any*"], ptr %varargslots47, i64 0, i64 0 + store %"any*" %33, ptr %34, align 16 + %35 = insertvalue %"any*[]" undef, ptr %varargslots47, 0 + %"#temp#48" = insertvalue %"any*[]" %35, i64 1, 1 + store %"any*[]" %"#temp#48", ptr %indirectarg49, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 87, ptr @.file, i64 19, ptr @.func, i64 4, i32 13, ptr byval(%"any*[]") align 8 %indirectarg49) br label %checkok50 checkok50: ; preds = %panic45, %checkok43 diff --git a/test/test_suite/enumerations/enum_reflect_associated.c3t b/test/test_suite/enumerations/enum_reflect_associated.c3t index eab4167bb..7ce7e4ce9 100644 --- a/test/test_suite/enumerations/enum_reflect_associated.c3t +++ b/test/test_suite/enumerations/enum_reflect_associated.c3t @@ -23,31 +23,31 @@ fn int main() define i32 @main() #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca %"char[]", align 8 %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [1 x %any], align 16 + %varargslots2 = alloca [1 x %"any*"], align 16 %taddr3 = alloca %"char[]", align 8 %retparam4 = alloca i64, align 8 - %varargslots5 = alloca [1 x %any], align 16 + %varargslots5 = alloca [1 x %"any*"], align 16 %taddr6 = alloca %"char[]", align 8 store %"char[]" { ptr @.str.2, i64 3 }, ptr %taddr, align 8 - %0 = insertvalue %any undef, ptr %taddr, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %2 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %1, ptr %2, align 16 + %0 = insertvalue %"any*" undef, ptr %taddr, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %2 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %1, ptr %2, align 16 %3 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.1, i64 2, ptr %varargslots, i64 1) store %"char[]" { ptr @.str.4, i64 6 }, ptr %taddr3, align 8 - %4 = insertvalue %any undef, ptr %taddr3, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %6 = getelementptr inbounds [1 x %any], ptr %varargslots2, i64 0, i64 0 - store %any %5, ptr %6, align 16 + %4 = insertvalue %"any*" undef, ptr %taddr3, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %6 = getelementptr inbounds [1 x %"any*"], ptr %varargslots2, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 %7 = call i64 @std.io.printfn(ptr %retparam1, ptr @.str.3, i64 2, ptr %varargslots2, i64 1) store %"char[]" { ptr @.str.6, i64 6 }, ptr %taddr6, align 8 - %8 = insertvalue %any undef, ptr %taddr6, 0 - %9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %10 = getelementptr inbounds [1 x %any], ptr %varargslots5, i64 0, i64 0 - store %any %9, ptr %10, align 16 + %8 = insertvalue %"any*" undef, ptr %taddr6, 0 + %9 = insertvalue %"any*" %8, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %10 = getelementptr inbounds [1 x %"any*"], ptr %varargslots5, i64 0, i64 0 + store %"any*" %9, ptr %10, align 16 %11 = call i64 @std.io.printfn(ptr %retparam4, ptr @.str.5, i64 2, ptr %varargslots5, i64 1) ret i32 0 } diff --git a/test/test_suite/errors/error_introspect.c3t b/test/test_suite/errors/error_introspect.c3t index 58caf8938..0ea0c8bab 100644 --- a/test/test_suite/errors/error_introspect.c3t +++ b/test/test_suite/errors/error_introspect.c3t @@ -39,33 +39,33 @@ entry: %x = alloca %"char[][]", align 8 %literal = alloca [2 x %"char[]"], align 16 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [1 x %any], align 16 + %varargslots2 = alloca [1 x %"any*"], align 16 %literal3 = alloca [2 x i64], align 16 %retparam4 = alloca i64, align 8 - %varargslots5 = alloca [1 x %any], align 16 + %varargslots5 = alloca [1 x %"any*"], align 16 %taddr = alloca i64, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal, ptr align 16 @.__const, i32 32, i1 false) %0 = insertvalue %"char[][]" undef, ptr %literal, 0 %1 = insertvalue %"char[][]" %0, i64 2, 1 store %"char[][]" %1, ptr %x, align 8 - %2 = insertvalue %any undef, ptr %x, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.sa$String" to i64), 1 - %4 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %3, ptr %4, align 16 + %2 = insertvalue %"any*" undef, ptr %x, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.sa$String" to i64), 1 + %4 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %3, ptr %4, align 16 %5 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.3, i64 13, ptr %varargslots, i64 1) call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal3, ptr align 16 @.__const.5, i32 16, i1 false) - %6 = insertvalue %any undef, ptr %literal3, 0 - %7 = insertvalue %any %6, i64 ptrtoint (ptr @"$ct.a2$foo.Foo" to i64), 1 - %8 = getelementptr inbounds [1 x %any], ptr %varargslots2, i64 0, i64 0 - store %any %7, ptr %8, align 16 + %6 = insertvalue %"any*" undef, ptr %literal3, 0 + %7 = insertvalue %"any*" %6, i64 ptrtoint (ptr @"$ct.a2$foo.Foo" to i64), 1 + %8 = getelementptr inbounds [1 x %"any*"], ptr %varargslots2, i64 0, i64 0 + store %"any*" %7, ptr %8, align 16 %9 = call i64 @std.io.printfn(ptr %retparam1, ptr @.str.4, i64 14, ptr %varargslots2, i64 1) store i64 2, ptr %taddr, align 8 - %10 = insertvalue %any undef, ptr %taddr, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %12 = getelementptr inbounds [1 x %any], ptr %varargslots5, i64 0, i64 0 - store %any %11, ptr %12, align 16 + %10 = insertvalue %"any*" undef, ptr %taddr, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %12 = getelementptr inbounds [1 x %"any*"], ptr %varargslots5, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 %13 = call i64 @std.io.printfn(ptr %retparam4, ptr @.str.6, i64 16, ptr %varargslots5, i64 1) ret void } diff --git a/test/test_suite/errors/error_regression_2.c3t b/test/test_suite/errors/error_regression_2.c3t index b516da7e7..f920cda9a 100644 --- a/test/test_suite/errors/error_regression_2.c3t +++ b/test/test_suite/errors/error_regression_2.c3t @@ -276,8 +276,8 @@ entry: %using12 = alloca ptr, align 8 %allocator = alloca ptr, align 8 %retparam = alloca ptr, align 8 - %varargslots = alloca [1 x %any], align 16 - %indirectarg = alloca %"any[]", align 8 + %varargslots = alloca [1 x %"any*"], align 16 + %indirectarg = alloca %"any*[]", align 8 %reterr22 = alloca i64, align 8 %literal23 = alloca %Doc, align 8 %error_var24 = alloca i64, align 8 @@ -290,8 +290,8 @@ entry: %using31 = alloca ptr, align 8 %allocator33 = alloca ptr, align 8 %retparam35 = alloca ptr, align 8 - %varargslots40 = alloca [1 x %any], align 16 - %indirectarg42 = alloca %"any[]", align 8 + %varargslots40 = alloca [1 x %"any*"], align 16 + %indirectarg42 = alloca %"any*[]", align 8 %value49 = alloca %Head, align 8 %temp50 = alloca ptr, align 8 %using51 = alloca ptr, align 8 @@ -299,8 +299,8 @@ entry: %using53 = alloca ptr, align 8 %allocator55 = alloca ptr, align 8 %retparam57 = alloca ptr, align 8 - %varargslots62 = alloca [1 x %any], align 16 - %indirectarg64 = alloca %"any[]", align 8 + %varargslots62 = alloca [1 x %"any*"], align 16 + %indirectarg64 = alloca %"any*[]", align 8 %len = alloca i64, align 8 %str = alloca ptr, align 8 %using72 = alloca ptr, align 8 @@ -308,8 +308,8 @@ entry: %using74 = alloca ptr, align 8 %allocator75 = alloca ptr, align 8 %retparam77 = alloca ptr, align 8 - %varargslots82 = alloca [1 x %any], align 16 - %indirectarg84 = alloca %"any[]", align 8 + %varargslots82 = alloca [1 x %"any*"], align 16 + %indirectarg84 = alloca %"any*[]", align 8 %reterr91 = alloca i64, align 8 %literal92 = alloca %Doc, align 8 %error_var93 = alloca i64, align 8 @@ -322,8 +322,8 @@ entry: %using101 = alloca ptr, align 8 %allocator103 = alloca ptr, align 8 %retparam105 = alloca ptr, align 8 - %varargslots110 = alloca [1 x %any], align 16 - %indirectarg112 = alloca %"any[]", align 8 + %varargslots110 = alloca [1 x %"any*"], align 16 + %indirectarg112 = alloca %"any*[]", align 8 %value119 = alloca %Head, align 8 %temp120 = alloca ptr, align 8 %using121 = alloca ptr, align 8 @@ -331,8 +331,8 @@ entry: %using123 = alloca ptr, align 8 %allocator125 = alloca ptr, align 8 %retparam127 = alloca ptr, align 8 - %varargslots132 = alloca [1 x %any], align 16 - %indirectarg134 = alloca %"any[]", align 8 + %varargslots132 = alloca [1 x %"any*"], align 16 + %indirectarg134 = alloca %"any*[]", align 8 store ptr %1, ptr %url, align 8 %ptroffset = getelementptr inbounds i64, ptr %url, i64 1 store i64 %2, ptr %ptroffset, align 8 @@ -398,13 +398,13 @@ after_check: ; preds = %if.then7 br label %noerr_block panic_block: ; preds = %assign_optional - %26 = insertvalue %any undef, ptr %error_var11, 0 - %27 = insertvalue %any %26, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %28 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %27, ptr %28, align 16 - %29 = insertvalue %"any[]" undef, ptr %varargslots, 0 - %"#temp#" = insertvalue %"any[]" %29, i64 1, 1 - store %"any[]" %"#temp#", ptr %indirectarg, align 8 + %26 = insertvalue %"any*" undef, ptr %error_var11, 0 + %27 = insertvalue %"any*" %26, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %28 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %27, ptr %28, align 16 + %29 = insertvalue %"any*[]" undef, ptr %varargslots, 0 + %"#temp#" = insertvalue %"any*[]" %29, i64 1, 1 + store %"any*[]" %"#temp#", ptr %indirectarg, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7 unreachable @@ -471,13 +471,13 @@ after_check38: ; preds = %if.then21 br label %noerr_block43 panic_block39: ; preds = %assign_optional37 - %50 = insertvalue %any undef, ptr %error_var30, 0 - %51 = insertvalue %any %50, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %52 = getelementptr inbounds [1 x %any], ptr %varargslots40, i64 0, i64 0 - store %any %51, ptr %52, align 16 - %53 = insertvalue %"any[]" undef, ptr %varargslots40, 0 - %"#temp#41" = insertvalue %"any[]" %53, i64 1, 1 - store %"any[]" %"#temp#41", ptr %indirectarg42, align 8 + %50 = insertvalue %"any*" undef, ptr %error_var30, 0 + %51 = insertvalue %"any*" %50, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %52 = getelementptr inbounds [1 x %"any*"], ptr %varargslots40, i64 0, i64 0 + store %"any*" %51, ptr %52, align 16 + %53 = insertvalue %"any*[]" undef, ptr %varargslots40, 0 + %"#temp#41" = insertvalue %"any*[]" %53, i64 1, 1 + store %"any*[]" %"#temp#41", ptr %indirectarg42, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func unreachable @@ -528,13 +528,13 @@ after_check60: ; preds = %noerr_block48 br label %noerr_block65 panic_block61: ; preds = %assign_optional59 - %68 = insertvalue %any undef, ptr %error_var52, 0 - %69 = insertvalue %any %68, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %70 = getelementptr inbounds [1 x %any], ptr %varargslots62, i64 0, i64 0 - store %any %69, ptr %70, align 16 - %71 = insertvalue %"any[]" undef, ptr %varargslots62, 0 - %"#temp#63" = insertvalue %"any[]" %71, i64 1, 1 - store %"any[]" %"#temp#63", ptr %indirectarg64, align 8 + %68 = insertvalue %"any*" undef, ptr %error_var52, 0 + %69 = insertvalue %"any*" %68, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %70 = getelementptr inbounds [1 x %"any*"], ptr %varargslots62, i64 0, i64 0 + store %"any*" %69, ptr %70, align 16 + %71 = insertvalue %"any*[]" undef, ptr %varargslots62, 0 + %"#temp#63" = insertvalue %"any*[]" %71, i64 1, 1 + store %"any*[]" %"#temp#63", ptr %indirectarg64, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func unreachable @@ -599,13 +599,13 @@ after_check80: ; preds = %if.exit71 br label %noerr_block85 panic_block81: ; preds = %assign_optional79 - %92 = insertvalue %any undef, ptr %error_var73, 0 - %93 = insertvalue %any %92, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %94 = getelementptr inbounds [1 x %any], ptr %varargslots82, i64 0, i64 0 - store %any %93, ptr %94, align 16 - %95 = insertvalue %"any[]" undef, ptr %varargslots82, 0 - %"#temp#83" = insertvalue %"any[]" %95, i64 1, 1 - store %"any[]" %"#temp#83", ptr %indirectarg84, align 8 + %92 = insertvalue %"any*" undef, ptr %error_var73, 0 + %93 = insertvalue %"any*" %92, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %94 = getelementptr inbounds [1 x %"any*"], ptr %varargslots82, i64 0, i64 0 + store %"any*" %93, ptr %94, align 16 + %95 = insertvalue %"any*[]" undef, ptr %varargslots82, 0 + %"#temp#83" = insertvalue %"any*[]" %95, i64 1, 1 + store %"any*[]" %"#temp#83", ptr %indirectarg84, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func unreachable @@ -664,13 +664,13 @@ after_check108: ; preds = %if.exit88 br label %noerr_block113 panic_block109: ; preds = %assign_optional107 - %121 = insertvalue %any undef, ptr %error_var100, 0 - %122 = insertvalue %any %121, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %123 = getelementptr inbounds [1 x %any], ptr %varargslots110, i64 0, i64 0 - store %any %122, ptr %123, align 16 - %124 = insertvalue %"any[]" undef, ptr %varargslots110, 0 - %"#temp#111" = insertvalue %"any[]" %124, i64 1, 1 - store %"any[]" %"#temp#111", ptr %indirectarg112, align 8 + %121 = insertvalue %"any*" undef, ptr %error_var100, 0 + %122 = insertvalue %"any*" %121, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %123 = getelementptr inbounds [1 x %"any*"], ptr %varargslots110, i64 0, i64 0 + store %"any*" %122, ptr %123, align 16 + %124 = insertvalue %"any*[]" undef, ptr %varargslots110, 0 + %"#temp#111" = insertvalue %"any*[]" %124, i64 1, 1 + store %"any*[]" %"#temp#111", ptr %indirectarg112, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func unreachable @@ -721,13 +721,13 @@ after_check130: ; preds = %noerr_block118 br label %noerr_block135 panic_block131: ; preds = %assign_optional129 - %139 = insertvalue %any undef, ptr %error_var122, 0 - %140 = insertvalue %any %139, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %141 = getelementptr inbounds [1 x %any], ptr %varargslots132, i64 0, i64 0 - store %any %140, ptr %141, align 16 - %142 = insertvalue %"any[]" undef, ptr %varargslots132, 0 - %"#temp#133" = insertvalue %"any[]" %142, i64 1, 1 - store %"any[]" %"#temp#133", ptr %indirectarg134, align 8 + %139 = insertvalue %"any*" undef, ptr %error_var122, 0 + %140 = insertvalue %"any*" %139, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %141 = getelementptr inbounds [1 x %"any*"], ptr %varargslots132, i64 0, i64 0 + store %"any*" %140, ptr %141, align 16 + %142 = insertvalue %"any*[]" undef, ptr %varargslots132, 0 + %"#temp#133" = insertvalue %"any*[]" %142, i64 1, 1 + store %"any*[]" %"#temp#133", ptr %indirectarg134, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7 unreachable diff --git a/test/test_suite/errors/multiple_catch.c3t b/test/test_suite/errors/multiple_catch.c3t index 10662d6d1..c08233739 100644 --- a/test/test_suite/errors/multiple_catch.c3t +++ b/test/test_suite/errors/multiple_catch.c3t @@ -47,11 +47,11 @@ entry: %err = alloca i64, align 8 %retparam = alloca i32, align 4 %retparam5 = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %err8 = alloca i64, align 8 %retparam10 = alloca i32, align 4 %retparam21 = alloca i64, align 8 - %varargslots22 = alloca [1 x %any], align 16 + %varargslots22 = alloca [1 x %"any*"], align 16 %temp_err = alloca i64, align 8 %retparam27 = alloca i32, align 4 %len = alloca i64, align 8 @@ -62,7 +62,7 @@ entry: %err56 = alloca i64, align 8 %retparam58 = alloca i32, align 4 %retparam69 = alloca i64, align 8 - %varargslots70 = alloca [1 x %any], align 16 + %varargslots70 = alloca [1 x %"any*"], align 16 br label %testblock testblock: ; preds = %entry @@ -98,10 +98,10 @@ end_block: ; preds = %after_check4, %assi br i1 %neq, label %if.then, label %if.exit if.then: ; preds = %end_block - %5 = insertvalue %any undef, ptr %err, 0 - %6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %7 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %6, ptr %7, align 16 + %5 = insertvalue %"any*" undef, ptr %err, 0 + %6 = insertvalue %"any*" %5, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %7 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %6, ptr %7, align 16 %8 = call i64 @std.io.printfn(ptr %retparam5, ptr @.str.3, i64 8, ptr %varargslots, i64 1) br label %if.exit @@ -141,10 +141,10 @@ end_block18: ; preds = %after_check17, %ass br i1 %neq19, label %if.then20, label %if.exit25 if.then20: ; preds = %end_block18 - %14 = insertvalue %any undef, ptr %err8, 0 - %15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %16 = getelementptr inbounds [1 x %any], ptr %varargslots22, i64 0, i64 0 - store %any %15, ptr %16, align 16 + %14 = insertvalue %"any*" undef, ptr %err8, 0 + %15 = insertvalue %"any*" %14, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %16 = getelementptr inbounds [1 x %"any*"], ptr %varargslots22, i64 0, i64 0 + store %"any*" %15, ptr %16, align 16 %17 = call i64 @std.io.printfn(ptr %retparam21, ptr @.str.4, i64 8, ptr %varargslots22, i64 1) br label %if.exit25 @@ -278,10 +278,10 @@ end_block66: ; preds = %after_check65, %ass br i1 %neq67, label %if.then68, label %if.exit73 if.then68: ; preds = %end_block66 - %37 = insertvalue %any undef, ptr %err56, 0 - %38 = insertvalue %any %37, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %39 = getelementptr inbounds [1 x %any], ptr %varargslots70, i64 0, i64 0 - store %any %38, ptr %39, align 16 + %37 = insertvalue %"any*" undef, ptr %err56, 0 + %38 = insertvalue %"any*" %37, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %39 = getelementptr inbounds [1 x %"any*"], ptr %varargslots70, i64 0, i64 0 + store %"any*" %38, ptr %39, align 16 %40 = call i64 @std.io.printfn(ptr %retparam69, ptr @.str.6, i64 8, ptr %varargslots70, i64 1) br label %if.exit73 diff --git a/test/test_suite/errors/optional_chained_init.c3t b/test/test_suite/errors/optional_chained_init.c3t index a627092b1..500e97bc5 100644 --- a/test/test_suite/errors/optional_chained_init.c3t +++ b/test/test_suite/errors/optional_chained_init.c3t @@ -54,14 +54,14 @@ entry: %b.f = alloca i64, align 8 %err = alloca i64, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %err3 = alloca i64, align 8 %retparam12 = alloca i64, align 8 - %varargslots13 = alloca [1 x %any], align 16 + %varargslots13 = alloca [1 x %"any*"], align 16 %retparam17 = alloca i64, align 8 - %varargslots18 = alloca [1 x %any], align 16 + %varargslots18 = alloca [1 x %"any*"], align 16 %retparam24 = alloca i64, align 8 - %varargslots25 = alloca [1 x %any], align 16 + %varargslots25 = alloca [1 x %"any*"], align 16 store i32 1, ptr %a, align 4 store i64 0, ptr %a.f, align 8 store i64 ptrtoint (ptr @"test.Test$FOO" to i64), ptr %a.f, align 8 @@ -91,10 +91,10 @@ end_block: ; preds = %after_check, %assig br i1 %neq, label %if.then, label %if.exit if.then: ; preds = %end_block - %2 = insertvalue %any undef, ptr %err, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %4 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %3, ptr %4, align 16 + %2 = insertvalue %"any*" undef, ptr %err, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %4 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %3, ptr %4, align 16 %5 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 13, ptr %varargslots, i64 1) br label %if.exit @@ -121,10 +121,10 @@ end_block9: ; preds = %after_check8, %assi br i1 %neq10, label %if.then11, label %if.exit16 if.then11: ; preds = %end_block9 - %8 = insertvalue %any undef, ptr %err3, 0 - %9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %10 = getelementptr inbounds [1 x %any], ptr %varargslots13, i64 0, i64 0 - store %any %9, ptr %10, align 16 + %8 = insertvalue %"any*" undef, ptr %err3, 0 + %9 = insertvalue %"any*" %8, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %10 = getelementptr inbounds [1 x %"any*"], ptr %varargslots13, i64 0, i64 0 + store %"any*" %9, ptr %10, align 16 %11 = call i64 @std.io.printfn(ptr %retparam12, ptr @.str.1, i64 13, ptr %varargslots13, i64 1) br label %if.exit16 @@ -135,10 +135,10 @@ if.exit16: ; preds = %if.then11, %end_blo br i1 %12, label %after_check21, label %after_check23 after_check21: ; preds = %if.exit16 - %13 = insertvalue %any undef, ptr %a, 0 - %14 = insertvalue %any %13, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %15 = getelementptr inbounds [1 x %any], ptr %varargslots18, i64 0, i64 0 - store %any %14, ptr %15, align 16 + %13 = insertvalue %"any*" undef, ptr %a, 0 + %14 = insertvalue %"any*" %13, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %15 = getelementptr inbounds [1 x %"any*"], ptr %varargslots18, i64 0, i64 0 + store %"any*" %14, ptr %15, align 16 %16 = call i64 @std.io.printfn(ptr %retparam17, ptr @.str.2, i64 9, ptr %varargslots18, i64 1) %not_err22 = icmp eq i64 %16, 0 %17 = call i1 @llvm.expect.i1(i1 %not_err22, i1 true) @@ -151,10 +151,10 @@ after_check23: ; preds = %if.exit16, %after_c br i1 %18, label %after_check28, label %after_check30 after_check28: ; preds = %after_check23 - %19 = insertvalue %any undef, ptr %b, 0 - %20 = insertvalue %any %19, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %21 = getelementptr inbounds [1 x %any], ptr %varargslots25, i64 0, i64 0 - store %any %20, ptr %21, align 16 + %19 = insertvalue %"any*" undef, ptr %b, 0 + %20 = insertvalue %"any*" %19, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %21 = getelementptr inbounds [1 x %"any*"], ptr %varargslots25, i64 0, i64 0 + store %"any*" %20, ptr %21, align 16 %22 = call i64 @std.io.printfn(ptr %retparam24, ptr @.str.3, i64 9, ptr %varargslots25, i64 1) %not_err29 = icmp eq i64 %22, 0 %23 = call i1 @llvm.expect.i1(i1 %not_err29, i1 true) @@ -175,14 +175,14 @@ entry: %b.f = alloca i64, align 8 %err = alloca i64, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %err8 = alloca i64, align 8 %retparam17 = alloca i64, align 8 - %varargslots18 = alloca [1 x %any], align 16 + %varargslots18 = alloca [1 x %"any*"], align 16 %retparam22 = alloca i64, align 8 - %varargslots23 = alloca [1 x %any], align 16 + %varargslots23 = alloca [1 x %"any*"], align 16 %retparam29 = alloca i64, align 8 - %varargslots30 = alloca [1 x %any], align 16 + %varargslots30 = alloca [1 x %"any*"], align 16 store i64 ptrtoint (ptr @"test.Test$FOO" to i64), ptr %x.f, align 8 store i32 1, ptr %a, align 4 store i64 0, ptr %a.f, align 8 @@ -234,10 +234,10 @@ end_block: ; preds = %after_check5, %assi br i1 %neq, label %if.then, label %if.exit if.then: ; preds = %end_block - %4 = insertvalue %any undef, ptr %err, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %6 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %5, ptr %6, align 16 + %4 = insertvalue %"any*" undef, ptr %err, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %6 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 %7 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.4, i64 13, ptr %varargslots, i64 1) br label %if.exit @@ -264,10 +264,10 @@ end_block14: ; preds = %after_check13, %ass br i1 %neq15, label %if.then16, label %if.exit21 if.then16: ; preds = %end_block14 - %10 = insertvalue %any undef, ptr %err8, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %12 = getelementptr inbounds [1 x %any], ptr %varargslots18, i64 0, i64 0 - store %any %11, ptr %12, align 16 + %10 = insertvalue %"any*" undef, ptr %err8, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %12 = getelementptr inbounds [1 x %"any*"], ptr %varargslots18, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 %13 = call i64 @std.io.printfn(ptr %retparam17, ptr @.str.5, i64 13, ptr %varargslots18, i64 1) br label %if.exit21 @@ -278,10 +278,10 @@ if.exit21: ; preds = %if.then16, %end_blo br i1 %14, label %after_check26, label %after_check28 after_check26: ; preds = %if.exit21 - %15 = insertvalue %any undef, ptr %a, 0 - %16 = insertvalue %any %15, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %17 = getelementptr inbounds [1 x %any], ptr %varargslots23, i64 0, i64 0 - store %any %16, ptr %17, align 16 + %15 = insertvalue %"any*" undef, ptr %a, 0 + %16 = insertvalue %"any*" %15, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %17 = getelementptr inbounds [1 x %"any*"], ptr %varargslots23, i64 0, i64 0 + store %"any*" %16, ptr %17, align 16 %18 = call i64 @std.io.printfn(ptr %retparam22, ptr @.str.6, i64 9, ptr %varargslots23, i64 1) %not_err27 = icmp eq i64 %18, 0 %19 = call i1 @llvm.expect.i1(i1 %not_err27, i1 true) @@ -294,10 +294,10 @@ after_check28: ; preds = %if.exit21, %after_c br i1 %20, label %after_check33, label %after_check35 after_check33: ; preds = %after_check28 - %21 = insertvalue %any undef, ptr %b, 0 - %22 = insertvalue %any %21, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %23 = getelementptr inbounds [1 x %any], ptr %varargslots30, i64 0, i64 0 - store %any %22, ptr %23, align 16 + %21 = insertvalue %"any*" undef, ptr %b, 0 + %22 = insertvalue %"any*" %21, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %23 = getelementptr inbounds [1 x %"any*"], ptr %varargslots30, i64 0, i64 0 + store %"any*" %22, ptr %23, align 16 %24 = call i64 @std.io.printfn(ptr %retparam29, ptr @.str.7, i64 9, ptr %varargslots30, i64 1) %not_err34 = icmp eq i64 %24, 0 %25 = call i1 @llvm.expect.i1(i1 %not_err34, i1 true) @@ -318,14 +318,14 @@ entry: %b.f = alloca i64, align 8 %err = alloca i64, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %err8 = alloca i64, align 8 %retparam17 = alloca i64, align 8 - %varargslots18 = alloca [1 x %any], align 16 + %varargslots18 = alloca [1 x %"any*"], align 16 %retparam22 = alloca i64, align 8 - %varargslots23 = alloca [1 x %any], align 16 + %varargslots23 = alloca [1 x %"any*"], align 16 %retparam29 = alloca i64, align 8 - %varargslots30 = alloca [1 x %any], align 16 + %varargslots30 = alloca [1 x %"any*"], align 16 store i32 23, ptr %x, align 4 store i64 0, ptr %x.f, align 8 store i32 1, ptr %a, align 4 @@ -378,10 +378,10 @@ end_block: ; preds = %after_check5, %assi br i1 %neq, label %if.then, label %if.exit if.then: ; preds = %end_block - %4 = insertvalue %any undef, ptr %err, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %6 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %5, ptr %6, align 16 + %4 = insertvalue %"any*" undef, ptr %err, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %6 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 %7 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.8, i64 13, ptr %varargslots, i64 1) br label %if.exit @@ -408,10 +408,10 @@ end_block14: ; preds = %after_check13, %ass br i1 %neq15, label %if.then16, label %if.exit21 if.then16: ; preds = %end_block14 - %10 = insertvalue %any undef, ptr %err8, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %12 = getelementptr inbounds [1 x %any], ptr %varargslots18, i64 0, i64 0 - store %any %11, ptr %12, align 16 + %10 = insertvalue %"any*" undef, ptr %err8, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %12 = getelementptr inbounds [1 x %"any*"], ptr %varargslots18, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 %13 = call i64 @std.io.printfn(ptr %retparam17, ptr @.str.9, i64 13, ptr %varargslots18, i64 1) br label %if.exit21 @@ -422,10 +422,10 @@ if.exit21: ; preds = %if.then16, %end_blo br i1 %14, label %after_check26, label %after_check28 after_check26: ; preds = %if.exit21 - %15 = insertvalue %any undef, ptr %a, 0 - %16 = insertvalue %any %15, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %17 = getelementptr inbounds [1 x %any], ptr %varargslots23, i64 0, i64 0 - store %any %16, ptr %17, align 16 + %15 = insertvalue %"any*" undef, ptr %a, 0 + %16 = insertvalue %"any*" %15, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %17 = getelementptr inbounds [1 x %"any*"], ptr %varargslots23, i64 0, i64 0 + store %"any*" %16, ptr %17, align 16 %18 = call i64 @std.io.printfn(ptr %retparam22, ptr @.str.10, i64 9, ptr %varargslots23, i64 1) %not_err27 = icmp eq i64 %18, 0 %19 = call i1 @llvm.expect.i1(i1 %not_err27, i1 true) @@ -438,10 +438,10 @@ after_check28: ; preds = %if.exit21, %after_c br i1 %20, label %after_check33, label %after_check35 after_check33: ; preds = %after_check28 - %21 = insertvalue %any undef, ptr %b, 0 - %22 = insertvalue %any %21, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %23 = getelementptr inbounds [1 x %any], ptr %varargslots30, i64 0, i64 0 - store %any %22, ptr %23, align 16 + %21 = insertvalue %"any*" undef, ptr %b, 0 + %22 = insertvalue %"any*" %21, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %23 = getelementptr inbounds [1 x %"any*"], ptr %varargslots30, i64 0, i64 0 + store %"any*" %22, ptr %23, align 16 %24 = call i64 @std.io.printfn(ptr %retparam29, ptr @.str.11, i64 9, ptr %varargslots30, i64 1) %not_err34 = icmp eq i64 %24, 0 %25 = call i1 @llvm.expect.i1(i1 %not_err34, i1 true) diff --git a/test/test_suite/errors/optional_with_optional.c3t b/test/test_suite/errors/optional_with_optional.c3t index 4a36be0b5..8579ce6bb 100644 --- a/test/test_suite/errors/optional_with_optional.c3t +++ b/test/test_suite/errors/optional_with_optional.c3t @@ -35,38 +35,38 @@ fn int! get_b(int x) define void @test.main() #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %retparam1 = alloca i32, align 4 %retparam2 = alloca i32, align 4 %taddr = alloca i32, align 4 %retparam10 = alloca i64, align 8 - %varargslots11 = alloca [1 x %any], align 16 + %varargslots11 = alloca [1 x %"any*"], align 16 %retparam12 = alloca i32, align 4 %retparam16 = alloca i32, align 4 %taddr24 = alloca i32, align 4 %retparam27 = alloca i64, align 8 - %varargslots28 = alloca [1 x %any], align 16 + %varargslots28 = alloca [1 x %"any*"], align 16 %retparam29 = alloca i32, align 4 %retparam33 = alloca i32, align 4 %taddr41 = alloca i32, align 4 %retparam44 = alloca i64, align 8 - %varargslots45 = alloca [1 x %any], align 16 + %varargslots45 = alloca [1 x %"any*"], align 16 %blockret = alloca i64, align 8 %f = alloca i64, align 8 %retparam48 = alloca i64, align 8 - %varargslots49 = alloca [1 x %any], align 16 + %varargslots49 = alloca [1 x %"any*"], align 16 %taddr50 = alloca i32, align 4 %retparam53 = alloca i64, align 8 - %varargslots54 = alloca [1 x %any], align 16 + %varargslots54 = alloca [1 x %"any*"], align 16 %blockret55 = alloca i64, align 8 %f56 = alloca i64, align 8 %retparam65 = alloca i64, align 8 - %varargslots66 = alloca [1 x %any], align 16 + %varargslots66 = alloca [1 x %"any*"], align 16 %blockret67 = alloca i64, align 8 %f68 = alloca i64, align 8 %x = alloca i64, align 8 %retparam79 = alloca i64, align 8 - %varargslots80 = alloca [1 x %any], align 16 + %varargslots80 = alloca [1 x %"any*"], align 16 %xy = alloca i32, align 4 %xy.f = alloca i64, align 8 %0 = call i64 @test.get_a(ptr %retparam1, i32 1) @@ -98,10 +98,10 @@ phi_block: ; preds = %else_block5, %after phi_block6: ; preds = %phi_block, %after_check %val7 = phi i32 [ %2, %after_check ], [ %val, %phi_block ] store i32 %val7, ptr %taddr, align 4 - %6 = insertvalue %any undef, ptr %taddr, 0 - %7 = insertvalue %any %6, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %8 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %7, ptr %8, align 16 + %6 = insertvalue %"any*" undef, ptr %taddr, 0 + %7 = insertvalue %"any*" %6, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %8 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %7, ptr %8, align 16 %9 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 4, ptr %varargslots, i64 1) %10 = call i64 @test.get_a(ptr %retparam12, i32 2) %not_err13 = icmp eq i64 %10, 0 @@ -132,10 +132,10 @@ phi_block20: ; preds = %else_block19, %afte phi_block22: ; preds = %phi_block20, %after_check14 %val23 = phi i32 [ %12, %after_check14 ], [ %val21, %phi_block20 ] store i32 %val23, ptr %taddr24, align 4 - %16 = insertvalue %any undef, ptr %taddr24, 0 - %17 = insertvalue %any %16, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %18 = getelementptr inbounds [1 x %any], ptr %varargslots11, i64 0, i64 0 - store %any %17, ptr %18, align 16 + %16 = insertvalue %"any*" undef, ptr %taddr24, 0 + %17 = insertvalue %"any*" %16, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %18 = getelementptr inbounds [1 x %"any*"], ptr %varargslots11, i64 0, i64 0 + store %"any*" %17, ptr %18, align 16 %19 = call i64 @std.io.printfn(ptr %retparam10, ptr @.str.2, i64 4, ptr %varargslots11, i64 1) %20 = call i64 @test.get_a(ptr %retparam29, i32 1) %not_err30 = icmp eq i64 %20, 0 @@ -166,10 +166,10 @@ phi_block37: ; preds = %else_block36, %afte phi_block39: ; preds = %phi_block37, %after_check31 %val40 = phi i32 [ %22, %after_check31 ], [ %val38, %phi_block37 ] store i32 %val40, ptr %taddr41, align 4 - %26 = insertvalue %any undef, ptr %taddr41, 0 - %27 = insertvalue %any %26, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %28 = getelementptr inbounds [1 x %any], ptr %varargslots28, i64 0, i64 0 - store %any %27, ptr %28, align 16 + %26 = insertvalue %"any*" undef, ptr %taddr41, 0 + %27 = insertvalue %"any*" %26, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %28 = getelementptr inbounds [1 x %"any*"], ptr %varargslots28, i64 0, i64 0 + store %"any*" %27, ptr %28, align 16 %29 = call i64 @std.io.printfn(ptr %retparam27, ptr @.str.3, i64 4, ptr %varargslots28, i64 1) br label %testblock @@ -192,16 +192,16 @@ if.exit: ; preds = %end_block br label %expr_block.exit expr_block.exit: ; preds = %if.exit, %if.then - %32 = insertvalue %any undef, ptr %blockret, 0 - %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %34 = getelementptr inbounds [1 x %any], ptr %varargslots45, i64 0, i64 0 - store %any %33, ptr %34, align 16 + %32 = insertvalue %"any*" undef, ptr %blockret, 0 + %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %34 = getelementptr inbounds [1 x %"any*"], ptr %varargslots45, i64 0, i64 0 + store %"any*" %33, ptr %34, align 16 %35 = call i64 @std.io.printfn(ptr %retparam44, ptr @.str.4, i64 4, ptr %varargslots45, i64 1) store i32 3, ptr %taddr50, align 4 - %36 = insertvalue %any undef, ptr %taddr50, 0 - %37 = insertvalue %any %36, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %38 = getelementptr inbounds [1 x %any], ptr %varargslots49, i64 0, i64 0 - store %any %37, ptr %38, align 16 + %36 = insertvalue %"any*" undef, ptr %taddr50, 0 + %37 = insertvalue %"any*" %36, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %38 = getelementptr inbounds [1 x %"any*"], ptr %varargslots49, i64 0, i64 0 + store %"any*" %37, ptr %38, align 16 %39 = call i64 @std.io.printfn(ptr %retparam48, ptr @.str.5, i64 4, ptr %varargslots49, i64 1) br label %testblock57 @@ -224,10 +224,10 @@ if.exit61: ; preds = %end_block58 br label %expr_block.exit62 expr_block.exit62: ; preds = %if.exit61, %if.then60 - %42 = insertvalue %any undef, ptr %blockret55, 0 - %43 = insertvalue %any %42, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %44 = getelementptr inbounds [1 x %any], ptr %varargslots54, i64 0, i64 0 - store %any %43, ptr %44, align 16 + %42 = insertvalue %"any*" undef, ptr %blockret55, 0 + %43 = insertvalue %"any*" %42, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %44 = getelementptr inbounds [1 x %"any*"], ptr %varargslots54, i64 0, i64 0 + store %"any*" %43, ptr %44, align 16 %45 = call i64 @std.io.printfn(ptr %retparam53, ptr @.str.6, i64 4, ptr %varargslots54, i64 1) br label %testblock69 @@ -253,16 +253,16 @@ if.exit75: ; preds = %end_block72 br label %expr_block.exit76 expr_block.exit76: ; preds = %if.exit75, %if.then74 - %48 = insertvalue %any undef, ptr %blockret67, 0 - %49 = insertvalue %any %48, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %50 = getelementptr inbounds [1 x %any], ptr %varargslots66, i64 0, i64 0 - store %any %49, ptr %50, align 16 + %48 = insertvalue %"any*" undef, ptr %blockret67, 0 + %49 = insertvalue %"any*" %48, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %50 = getelementptr inbounds [1 x %"any*"], ptr %varargslots66, i64 0, i64 0 + store %"any*" %49, ptr %50, align 16 %51 = call i64 @std.io.printfn(ptr %retparam65, ptr @.str.7, i64 4, ptr %varargslots66, i64 1) store i64 3, ptr %x, align 8 - %52 = insertvalue %any undef, ptr %x, 0 - %53 = insertvalue %any %52, i64 ptrtoint (ptr @"$ct.long" to i64), 1 - %54 = getelementptr inbounds [1 x %any], ptr %varargslots80, i64 0, i64 0 - store %any %53, ptr %54, align 16 + %52 = insertvalue %"any*" undef, ptr %x, 0 + %53 = insertvalue %"any*" %52, i64 ptrtoint (ptr @"$ct.long" to i64), 1 + %54 = getelementptr inbounds [1 x %"any*"], ptr %varargslots80, i64 0, i64 0 + store %"any*" %53, ptr %54, align 16 %55 = call i64 @std.io.printfn(ptr %retparam79, ptr @.str.8, i64 4, ptr %varargslots80, i64 1) store i64 ptrtoint (ptr @"test.Foo$DEF" to i64), ptr %xy.f, align 8 ret void diff --git a/test/test_suite/errors/or_and_rethrow.c3t b/test/test_suite/errors/or_and_rethrow.c3t index 59f209067..0838c3c15 100644 --- a/test/test_suite/errors/or_and_rethrow.c3t +++ b/test/test_suite/errors/or_and_rethrow.c3t @@ -42,7 +42,7 @@ fn void main() define i64 @foo.test(i32 %0) #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 %error_var = alloca i64, align 8 %blockret = alloca i32, align 4 @@ -69,10 +69,10 @@ entry: %error_var83 = alloca i64, align 8 %error_var89 = alloca i64, align 8 store i32 %0, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 %4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.1, i64 8, ptr %varargslots, i64 1) %intbool = icmp ne i32 %0, 0 br i1 %intbool, label %or.phi, label %or.rhs @@ -342,7 +342,7 @@ voiderr96: ; preds = %noerr_block94, %gua define i64 @foo.test2(i32 %0) #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 %error_var = alloca i64, align 8 %blockret = alloca i32, align 4 @@ -359,10 +359,10 @@ entry: %error_var34 = alloca i64, align 8 %error_var40 = alloca i64, align 8 store i32 %0, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 %4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.6, i64 9, ptr %varargslots, i64 1) %intbool = icmp ne i32 %0, 0 br i1 %intbool, label %and.rhs, label %and.phi diff --git a/test/test_suite/errors/printing_errors.c3t b/test/test_suite/errors/printing_errors.c3t index 60e69a80e..21044ac53 100644 --- a/test/test_suite/errors/printing_errors.c3t +++ b/test/test_suite/errors/printing_errors.c3t @@ -19,15 +19,15 @@ define void @test.main() #0 { entry: %x = alloca i64, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 + %varargslots = alloca [2 x %"any*"], align 16 %taddr = alloca %"char[]", align 8 %faultname_zero = alloca %"char[]", align 8 store i64 ptrtoint (ptr @"test.Cde$WORLD" to i64), ptr %x, align 8 store %"char[]" { ptr @.str.2, i64 5 }, ptr %taddr, align 8 - %0 = insertvalue %any undef, ptr %taddr, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %2 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %1, ptr %2, align 16 + %0 = insertvalue %"any*" undef, ptr %taddr, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %2 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %1, ptr %2, align 16 %3 = load i64, ptr %x, align 8 %eq = icmp eq i64 %3, 0 br i1 %eq, label %faultname_no, label %faultname_ok @@ -43,10 +43,10 @@ faultname_ok: ; preds = %entry faultname_exit: ; preds = %faultname_ok, %faultname_no %faultname = phi ptr [ %faultname_zero, %faultname_no ], [ %5, %faultname_ok ] - %6 = insertvalue %any undef, ptr %faultname, 0 - %7 = insertvalue %any %6, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %8 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %7, ptr %8, align 16 + %6 = insertvalue %"any*" undef, ptr %faultname, 0 + %7 = insertvalue %"any*" %6, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %8 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %7, ptr %8, align 16 %9 = call i64 @std.io.printf(ptr %retparam, ptr @.str, i64 6, ptr %varargslots, i64 2) ret void } diff --git a/test/test_suite/functions/func_ptr_conversions_and_names.c3t b/test/test_suite/functions/func_ptr_conversions_and_names.c3t index 73a465060..b4b4536ac 100644 --- a/test/test_suite/functions/func_ptr_conversions_and_names.c3t +++ b/test/test_suite/functions/func_ptr_conversions_and_names.c3t @@ -56,29 +56,29 @@ entry: %a = alloca ptr, align 8 %b = alloca ptr, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [1 x %any], align 16 + %varargslots2 = alloca [1 x %"any*"], align 16 %taddr3 = alloca i32, align 4 %z = alloca ptr, align 8 %retparam4 = alloca i64, align 8 - %varargslots5 = alloca [1 x %any], align 16 + %varargslots5 = alloca [1 x %"any*"], align 16 %taddr6 = alloca i32, align 4 %retparam7 = alloca i64, align 8 - %varargslots8 = alloca [1 x %any], align 16 + %varargslots8 = alloca [1 x %"any*"], align 16 %taddr9 = alloca %"char[]", align 8 %retparam10 = alloca i64, align 8 - %varargslots11 = alloca [1 x %any], align 16 + %varargslots11 = alloca [1 x %"any*"], align 16 %taddr12 = alloca %"char[]", align 8 %retparam13 = alloca i64, align 8 - %varargslots14 = alloca [1 x %any], align 16 + %varargslots14 = alloca [1 x %"any*"], align 16 %taddr15 = alloca %"char[]", align 8 %retparam16 = alloca i64, align 8 - %varargslots17 = alloca [1 x %any], align 16 + %varargslots17 = alloca [1 x %"any*"], align 16 %taddr18 = alloca %"char[]", align 8 %retparam19 = alloca i64, align 8 - %varargslots20 = alloca [1 x %any], align 16 + %varargslots20 = alloca [1 x %"any*"], align 16 %taddr21 = alloca %"char[]", align 8 %y = alloca ptr, align 8 %zfoke = alloca i64, align 8 @@ -87,56 +87,56 @@ entry: %0 = load ptr, ptr %a, align 8 %1 = call i32 %0(i32 123) store i32 %1, ptr %taddr, align 4 - %2 = insertvalue %any undef, ptr %taddr, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %4 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %3, ptr %4, align 16 + %2 = insertvalue %"any*" undef, ptr %taddr, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %4 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %3, ptr %4, align 16 %5 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) %6 = call i32 @test.test2(i32 3) store i32 %6, ptr %taddr3, align 4 - %7 = insertvalue %any undef, ptr %taddr3, 0 - %8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %9 = getelementptr inbounds [1 x %any], ptr %varargslots2, i64 0, i64 0 - store %any %8, ptr %9, align 16 + %7 = insertvalue %"any*" undef, ptr %taddr3, 0 + %8 = insertvalue %"any*" %7, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %9 = getelementptr inbounds [1 x %"any*"], ptr %varargslots2, i64 0, i64 0 + store %"any*" %8, ptr %9, align 16 %10 = call i64 @std.io.printfn(ptr %retparam1, ptr @.str.1, i64 2, ptr %varargslots2, i64 1) store ptr @test.test2, ptr %z, align 8 %11 = load ptr, ptr %z, align 8 %12 = call i32 %11(i32 444) store i32 %12, ptr %taddr6, align 4 - %13 = insertvalue %any undef, ptr %taddr6, 0 - %14 = insertvalue %any %13, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %15 = getelementptr inbounds [1 x %any], ptr %varargslots5, i64 0, i64 0 - store %any %14, ptr %15, align 16 + %13 = insertvalue %"any*" undef, ptr %taddr6, 0 + %14 = insertvalue %"any*" %13, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %15 = getelementptr inbounds [1 x %"any*"], ptr %varargslots5, i64 0, i64 0 + store %"any*" %14, ptr %15, align 16 %16 = call i64 @std.io.printfn(ptr %retparam4, ptr @.str.2, i64 2, ptr %varargslots5, i64 1) store %"char[]" { ptr @.str.4, i64 12 }, ptr %taddr9, align 8 - %17 = insertvalue %any undef, ptr %taddr9, 0 - %18 = insertvalue %any %17, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %19 = getelementptr inbounds [1 x %any], ptr %varargslots8, i64 0, i64 0 - store %any %18, ptr %19, align 16 + %17 = insertvalue %"any*" undef, ptr %taddr9, 0 + %18 = insertvalue %"any*" %17, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %19 = getelementptr inbounds [1 x %"any*"], ptr %varargslots8, i64 0, i64 0 + store %"any*" %18, ptr %19, align 16 %20 = call i64 @std.io.printfn(ptr %retparam7, ptr @.str.3, i64 2, ptr %varargslots8, i64 1) store %"char[]" { ptr @.str.6, i64 12 }, ptr %taddr12, align 8 - %21 = insertvalue %any undef, ptr %taddr12, 0 - %22 = insertvalue %any %21, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %23 = getelementptr inbounds [1 x %any], ptr %varargslots11, i64 0, i64 0 - store %any %22, ptr %23, align 16 + %21 = insertvalue %"any*" undef, ptr %taddr12, 0 + %22 = insertvalue %"any*" %21, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %23 = getelementptr inbounds [1 x %"any*"], ptr %varargslots11, i64 0, i64 0 + store %"any*" %22, ptr %23, align 16 %24 = call i64 @std.io.printfn(ptr %retparam10, ptr @.str.5, i64 2, ptr %varargslots11, i64 1) store %"char[]" { ptr @.str.8, i64 12 }, ptr %taddr15, align 8 - %25 = insertvalue %any undef, ptr %taddr15, 0 - %26 = insertvalue %any %25, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %27 = getelementptr inbounds [1 x %any], ptr %varargslots14, i64 0, i64 0 - store %any %26, ptr %27, align 16 + %25 = insertvalue %"any*" undef, ptr %taddr15, 0 + %26 = insertvalue %"any*" %25, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %27 = getelementptr inbounds [1 x %"any*"], ptr %varargslots14, i64 0, i64 0 + store %"any*" %26, ptr %27, align 16 %28 = call i64 @std.io.printfn(ptr %retparam13, ptr @.str.7, i64 2, ptr %varargslots14, i64 1) store %"char[]" { ptr @.str.10, i64 6 }, ptr %taddr18, align 8 - %29 = insertvalue %any undef, ptr %taddr18, 0 - %30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %31 = getelementptr inbounds [1 x %any], ptr %varargslots17, i64 0, i64 0 - store %any %30, ptr %31, align 16 + %29 = insertvalue %"any*" undef, ptr %taddr18, 0 + %30 = insertvalue %"any*" %29, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %31 = getelementptr inbounds [1 x %"any*"], ptr %varargslots17, i64 0, i64 0 + store %"any*" %30, ptr %31, align 16 %32 = call i64 @std.io.printfn(ptr %retparam16, ptr @.str.9, i64 2, ptr %varargslots17, i64 1) store %"char[]" { ptr @.str.12, i64 13 }, ptr %taddr21, align 8 - %33 = insertvalue %any undef, ptr %taddr21, 0 - %34 = insertvalue %any %33, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %35 = getelementptr inbounds [1 x %any], ptr %varargslots20, i64 0, i64 0 - store %any %34, ptr %35, align 16 + %33 = insertvalue %"any*" undef, ptr %taddr21, 0 + %34 = insertvalue %"any*" %33, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %35 = getelementptr inbounds [1 x %"any*"], ptr %varargslots20, i64 0, i64 0 + store %"any*" %34, ptr %35, align 16 %36 = call i64 @std.io.printfn(ptr %retparam19, ptr @.str.11, i64 2, ptr %varargslots20, i64 1) store ptr @test.test2, ptr %y, align 8 store i64 ptrtoint (ptr @"$ct.p$fn$int$int$" to i64), ptr %zfoke, align 8 diff --git a/test/test_suite/functions/typeless_varargs.c3t b/test/test_suite/functions/typeless_varargs.c3t index d256145ba..8f2f9eb96 100644 --- a/test/test_suite/functions/typeless_varargs.c3t +++ b/test/test_suite/functions/typeless_varargs.c3t @@ -26,13 +26,13 @@ fn int main() define void @test.retest(ptr %0, i64 %1) #0 { entry: - %foo = alloca %"any[]", align 8 + %foo = alloca %"any*[]", align 8 store ptr %0, ptr %foo, align 8 %ptroffset = getelementptr inbounds i64, ptr %foo, i64 1 store i64 %1, ptr %ptroffset, align 8 - %2 = getelementptr inbounds %"any[]", ptr %foo, i32 0, i32 0 + %2 = getelementptr inbounds %"any*[]", ptr %foo, i32 0, i32 0 %lo = load ptr, ptr %2, align 8 - %3 = getelementptr inbounds %"any[]", ptr %foo, i32 0, i32 1 + %3 = getelementptr inbounds %"any*[]", ptr %foo, i32 0, i32 1 %hi = load i64, ptr %3, align 8 call void @test.test(ptr %lo, i64 %hi) ret void @@ -40,14 +40,14 @@ entry: define void @test.test(ptr %0, i64 %1) #0 { entry: - %foo = alloca %"any[]", align 8 + %foo = alloca %"any*[]", align 8 store ptr %0, ptr %foo, align 8 %ptroffset = getelementptr inbounds i64, ptr %foo, i64 1 store i64 %1, ptr %ptroffset, align 8 - %2 = getelementptr inbounds %"any[]", ptr %foo, i32 0, i32 0 + %2 = getelementptr inbounds %"any*[]", ptr %foo, i32 0, i32 0 %3 = load ptr, ptr %2, align 8 - %ptroffset1 = getelementptr inbounds %any, ptr %3, i64 0 - %4 = getelementptr inbounds %any, ptr %ptroffset1, i32 0, i32 0 + %ptroffset1 = getelementptr inbounds %"any*", ptr %3, i64 0 + %4 = getelementptr inbounds %"any*", ptr %ptroffset1, i32 0, i32 0 %5 = load ptr, ptr %4, align 8 %6 = load i32, ptr %5, align 4 call void (ptr, ...) @printf(ptr @.str, i32 %6) @@ -57,22 +57,22 @@ entry: define i32 @main() #0 { entry: %i = alloca i32, align 4 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 - %varargslots1 = alloca [1 x %any], align 16 + %varargslots1 = alloca [1 x %"any*"], align 16 %taddr2 = alloca i32, align 4 store i32 1, ptr %i, align 4 store i32 1, ptr %taddr, align 4 - %0 = insertvalue %any undef, ptr %taddr, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %2 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %1, ptr %2, align 16 + %0 = insertvalue %"any*" undef, ptr %taddr, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %2 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %1, ptr %2, align 16 call void @test.test(ptr %varargslots, i64 1) store i32 1, ptr %taddr2, align 4 - %3 = insertvalue %any undef, ptr %taddr2, 0 - %4 = insertvalue %any %3, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %5 = getelementptr inbounds [1 x %any], ptr %varargslots1, i64 0, i64 0 - store %any %4, ptr %5, align 16 + %3 = insertvalue %"any*" undef, ptr %taddr2, 0 + %4 = insertvalue %"any*" %3, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %5 = getelementptr inbounds [1 x %"any*"], ptr %varargslots1, i64 0, i64 0 + store %"any*" %4, ptr %5, align 16 call void @test.retest(ptr %varargslots1, i64 1) ret i32 1 } \ No newline at end of file diff --git a/test/test_suite/functions/varargs_followed_by_named.c3t b/test/test_suite/functions/varargs_followed_by_named.c3t index 619b60c4a..a0b547a45 100644 --- a/test/test_suite/functions/varargs_followed_by_named.c3t +++ b/test/test_suite/functions/varargs_followed_by_named.c3t @@ -42,11 +42,11 @@ entry: ; Function Attrs: nounwind define void @foo.test2(i32 %0, ptr %1, i64 %2, i32 %3) #0 { entry: - %y = alloca %"any[]", align 8 + %y = alloca %"any*[]", align 8 store ptr %1, ptr %y, align 8 %ptroffset = getelementptr inbounds i64, ptr %y, i64 1 store i64 %2, ptr %ptroffset, align 8 - %4 = getelementptr inbounds %"any[]", ptr %y, i32 0, i32 1 + %4 = getelementptr inbounds %"any*[]", ptr %y, i32 0, i32 1 %5 = load i64, ptr %4, align 8 %trunc = trunc i64 %5 to i32 call void (ptr, ...) @printf(ptr @.str.1, i32 %0, i32 %trunc, i32 %3) @@ -57,11 +57,11 @@ entry: define void @foo.main() #0 { entry: %varargslots = alloca [2 x i32], align 4 - %varargslots1 = alloca [2 x %any], align 16 + %varargslots1 = alloca [2 x %"any*"], align 16 %taddr = alloca i32, align 4 %taddr2 = alloca i32, align 4 %varargslots3 = alloca [2 x i32], align 4 - %varargslots4 = alloca [2 x %any], align 16 + %varargslots4 = alloca [2 x %"any*"], align 16 %taddr5 = alloca i32, align 4 %taddr6 = alloca i32, align 4 %0 = getelementptr inbounds [2 x i32], ptr %varargslots, i64 0, i64 0 @@ -70,15 +70,15 @@ entry: store i32 5, ptr %1, align 4 call void @foo.test(i32 3, ptr %varargslots, i64 2, i32 123) store i32 4, ptr %taddr, align 4 - %2 = insertvalue %any undef, ptr %taddr, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %4 = getelementptr inbounds [2 x %any], ptr %varargslots1, i64 0, i64 0 - store %any %3, ptr %4, align 16 + %2 = insertvalue %"any*" undef, ptr %taddr, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %4 = getelementptr inbounds [2 x %"any*"], ptr %varargslots1, i64 0, i64 0 + store %"any*" %3, ptr %4, align 16 store i32 5, ptr %taddr2, align 4 - %5 = insertvalue %any undef, ptr %taddr2, 0 - %6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %7 = getelementptr inbounds [2 x %any], ptr %varargslots1, i64 0, i64 1 - store %any %6, ptr %7, align 16 + %5 = insertvalue %"any*" undef, ptr %taddr2, 0 + %6 = insertvalue %"any*" %5, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %7 = getelementptr inbounds [2 x %"any*"], ptr %varargslots1, i64 0, i64 1 + store %"any*" %6, ptr %7, align 16 call void @foo.test2(i32 3, ptr %varargslots1, i64 2, i32 123) %8 = getelementptr inbounds [2 x i32], ptr %varargslots3, i64 0, i64 0 store i32 4, ptr %8, align 4 @@ -86,15 +86,15 @@ entry: store i32 5, ptr %9, align 4 call void @foo.test(i32 3, ptr %varargslots3, i64 2, i32 2) store i32 4, ptr %taddr5, align 4 - %10 = insertvalue %any undef, ptr %taddr5, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %12 = getelementptr inbounds [2 x %any], ptr %varargslots4, i64 0, i64 0 - store %any %11, ptr %12, align 16 + %10 = insertvalue %"any*" undef, ptr %taddr5, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %12 = getelementptr inbounds [2 x %"any*"], ptr %varargslots4, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 store i32 5, ptr %taddr6, align 4 - %13 = insertvalue %any undef, ptr %taddr6, 0 - %14 = insertvalue %any %13, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %15 = getelementptr inbounds [2 x %any], ptr %varargslots4, i64 0, i64 1 - store %any %14, ptr %15, align 16 + %13 = insertvalue %"any*" undef, ptr %taddr6, 0 + %14 = insertvalue %"any*" %13, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %15 = getelementptr inbounds [2 x %"any*"], ptr %varargslots4, i64 0, i64 1 + store %"any*" %14, ptr %15, align 16 call void @foo.test2(i32 3, ptr %varargslots4, i64 2, i32 2) ret void } \ No newline at end of file diff --git a/test/test_suite/generic/enum_set_test.c3t b/test/test_suite/generic/enum_set_test.c3t index 9abca4ec1..a09a1fdc6 100644 --- a/test/test_suite/generic/enum_set_test.c3t +++ b/test/test_suite/generic/enum_set_test.c3t @@ -31,63 +31,63 @@ define void @test.main() #0 { entry: %set = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i8, align 1 %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [1 x %any], align 16 + %varargslots2 = alloca [1 x %"any*"], align 16 %taddr3 = alloca i8, align 1 %retparam4 = alloca i64, align 8 - %varargslots5 = alloca [1 x %any], align 16 + %varargslots5 = alloca [1 x %"any*"], align 16 %taddr6 = alloca i8, align 1 %set2 = alloca i32, align 4 %retparam7 = alloca i64, align 8 - %varargslots8 = alloca [1 x %any], align 16 + %varargslots8 = alloca [1 x %"any*"], align 16 %taddr9 = alloca i8, align 1 %retparam10 = alloca i64, align 8 - %varargslots11 = alloca [1 x %any], align 16 + %varargslots11 = alloca [1 x %"any*"], align 16 %taddr12 = alloca i8, align 1 store i32 0, ptr %set, align 4 %0 = call i8 @"std.collections.enumset$test.Abc$.EnumSet.has"(ptr %set, i32 1) store i8 %0, ptr %taddr, align 1 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 %4 = call i64 @std.io.printf(ptr %retparam, ptr @.str, i64 14, ptr %varargslots, i64 1) call void @"std.collections.enumset$test.Abc$.EnumSet.add"(ptr %set, i32 0) %5 = call i8 @"std.collections.enumset$test.Abc$.EnumSet.has"(ptr %set, i32 1) store i8 %5, ptr %taddr3, align 1 - %6 = insertvalue %any undef, ptr %taddr3, 0 - %7 = insertvalue %any %6, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %8 = getelementptr inbounds [1 x %any], ptr %varargslots2, i64 0, i64 0 - store %any %7, ptr %8, align 16 + %6 = insertvalue %"any*" undef, ptr %taddr3, 0 + %7 = insertvalue %"any*" %6, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %8 = getelementptr inbounds [1 x %"any*"], ptr %varargslots2, i64 0, i64 0 + store %"any*" %7, ptr %8, align 16 %9 = call i64 @std.io.printf(ptr %retparam1, ptr @.str.1, i64 14, ptr %varargslots2, i64 1) call void @"std.collections.enumset$test.Abc$.EnumSet.add"(ptr %set, i32 1) %10 = call i8 @"std.collections.enumset$test.Abc$.EnumSet.has"(ptr %set, i32 1) store i8 %10, ptr %taddr6, align 1 - %11 = insertvalue %any undef, ptr %taddr6, 0 - %12 = insertvalue %any %11, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %13 = getelementptr inbounds [1 x %any], ptr %varargslots5, i64 0, i64 0 - store %any %12, ptr %13, align 16 + %11 = insertvalue %"any*" undef, ptr %taddr6, 0 + %12 = insertvalue %"any*" %11, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %13 = getelementptr inbounds [1 x %"any*"], ptr %varargslots5, i64 0, i64 0 + store %"any*" %12, ptr %13, align 16 %14 = call i64 @std.io.printf(ptr %retparam4, ptr @.str.2, i64 14, ptr %varargslots5, i64 1) store i32 0, ptr %set2, align 4 %15 = load i32, ptr %set, align 4 call void @"std.collections.enumset$test.Abc$.EnumSet.add_all"(ptr %set2, i32 %15) %16 = call i8 @"std.collections.enumset$test.Abc$.EnumSet.has"(ptr %set2, i32 1) store i8 %16, ptr %taddr9, align 1 - %17 = insertvalue %any undef, ptr %taddr9, 0 - %18 = insertvalue %any %17, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %19 = getelementptr inbounds [1 x %any], ptr %varargslots8, i64 0, i64 0 - store %any %18, ptr %19, align 16 + %17 = insertvalue %"any*" undef, ptr %taddr9, 0 + %18 = insertvalue %"any*" %17, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %19 = getelementptr inbounds [1 x %"any*"], ptr %varargslots8, i64 0, i64 0 + store %"any*" %18, ptr %19, align 16 %20 = call i64 @std.io.printf(ptr %retparam7, ptr @.str.3, i64 14, ptr %varargslots8, i64 1) %21 = load i32, ptr %set2, align 4 call void @"std.collections.enumset$test.Abc$.EnumSet.remove_all"(ptr %set, i32 %21) %22 = call i8 @"std.collections.enumset$test.Abc$.EnumSet.has"(ptr %set, i32 1) store i8 %22, ptr %taddr12, align 1 - %23 = insertvalue %any undef, ptr %taddr12, 0 - %24 = insertvalue %any %23, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %25 = getelementptr inbounds [1 x %any], ptr %varargslots11, i64 0, i64 0 - store %any %24, ptr %25, align 16 + %23 = insertvalue %"any*" undef, ptr %taddr12, 0 + %24 = insertvalue %"any*" %23, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %25 = getelementptr inbounds [1 x %"any*"], ptr %varargslots11, i64 0, i64 0 + store %"any*" %24, ptr %25, align 16 %26 = call i64 @std.io.printf(ptr %retparam10, ptr @.str.4, i64 14, ptr %varargslots11, i64 1) ret void } diff --git a/test/test_suite/generic/generic_lambda_complex.c3t b/test/test_suite/generic/generic_lambda_complex.c3t index b52c115ef..d67f19604 100644 --- a/test/test_suite/generic/generic_lambda_complex.c3t +++ b/test/test_suite/generic/generic_lambda_complex.c3t @@ -187,8 +187,8 @@ entry: %error_var = alloca i64, align 8 %indirectarg = alloca %"char[]", align 8 %error_var1 = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 - %indirectarg5 = alloca %"any[]", align 8 + %varargslots = alloca [1 x %"any*"], align 16 + %indirectarg5 = alloca %"any*[]", align 8 store %"char[]" { ptr @.str, i64 21 }, ptr %foo_tmpl, align 8 call void @llvm.memset.p0.i64(ptr align 8 %ft, i8 0, i64 64, i1 false) %0 = getelementptr inbounds %"char[]", ptr %foo_tmpl, i32 0, i32 0 @@ -236,14 +236,14 @@ after_check4: ; preds = %noerr_block br label %noerr_block6 panic_block: ; preds = %assign_optional3 - %9 = insertvalue %any undef, ptr %error_var1, 0 - %10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %11 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %10, ptr %11, align 16 - %12 = insertvalue %"any[]" undef, ptr %varargslots, 0 - %"#temp#" = insertvalue %"any[]" %12, i64 1, 1 - store %"any[]" %"#temp#", ptr %indirectarg5, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25, ptr @.func, i64 4, i32 173, ptr byval(%"any[]") align 8 %indirectarg5) + %9 = insertvalue %"any*" undef, ptr %error_var1, 0 + %10 = insertvalue %"any*" %9, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %11 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %10, ptr %11, align 16 + %12 = insertvalue %"any*[]" undef, ptr %varargslots, 0 + %"#temp#" = insertvalue %"any*[]" %12, i64 1, 1 + store %"any*[]" %"#temp#", ptr %indirectarg5, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25, ptr @.func, i64 4, i32 173, ptr byval(%"any*[]") align 8 %indirectarg5) unreachable noerr_block6: ; preds = %after_check4 diff --git a/test/test_suite/generic/generic_num.c3t b/test/test_suite/generic/generic_num.c3t index 84186ea7e..206c23542 100644 --- a/test/test_suite/generic/generic_num.c3t +++ b/test/test_suite/generic/generic_num.c3t @@ -22,14 +22,14 @@ fn void main() define void @test.main() #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 %0 = call i32 @"hello$int$_123$.x"(i32 4) store i32 %0, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 %4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) ret void } diff --git a/test/test_suite/literals/bin_literal.c3t b/test/test_suite/literals/bin_literal.c3t index 5b8bd8c28..0bc9cc6e9 100644 --- a/test/test_suite/literals/bin_literal.c3t +++ b/test/test_suite/literals/bin_literal.c3t @@ -22,10 +22,10 @@ entry: %c = alloca i32, align 4 %d = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 + %varargslots = alloca [2 x %"any*"], align 16 %z = alloca i8, align 1 %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [3 x %any], align 16 + %varargslots2 = alloca [3 x %"any*"], align 16 %self = alloca i8, align 1 %taddr = alloca i8, align 1 %self3 = alloca i8, align 1 @@ -40,40 +40,40 @@ entry: %4 = load i32, ptr %b, align 4 %5 = call i32 @llvm.smax.i32(i32 %3, i32 %4) store i32 %5, ptr %d, align 4 - %6 = insertvalue %any undef, ptr %c, 0 - %7 = insertvalue %any %6, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %8 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %7, ptr %8, align 16 - %9 = insertvalue %any undef, ptr %d, 0 - %10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %11 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %10, ptr %11, align 16 + %6 = insertvalue %"any*" undef, ptr %c, 0 + %7 = insertvalue %"any*" %6, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %8 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %7, ptr %8, align 16 + %9 = insertvalue %"any*" undef, ptr %d, 0 + %10 = insertvalue %"any*" %9, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %11 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %10, ptr %11, align 16 %12 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 5, ptr %varargslots, i64 2) store i8 -35, ptr %z, align 1 - %13 = insertvalue %any undef, ptr %z, 0 - %14 = insertvalue %any %13, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %15 = getelementptr inbounds [3 x %any], ptr %varargslots2, i64 0, i64 0 - store %any %14, ptr %15, align 16 + %13 = insertvalue %"any*" undef, ptr %z, 0 + %14 = insertvalue %"any*" %13, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %15 = getelementptr inbounds [3 x %"any*"], ptr %varargslots2, i64 0, i64 0 + store %"any*" %14, ptr %15, align 16 %16 = load i8, ptr %z, align 1 store i8 %16, ptr %self, align 1 %17 = load i8, ptr %self, align 1 %18 = load i8, ptr %self, align 1 %19 = call i8 @llvm.fshr.i8(i8 %17, i8 %18, i8 1) store i8 %19, ptr %taddr, align 1 - %20 = insertvalue %any undef, ptr %taddr, 0 - %21 = insertvalue %any %20, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %22 = getelementptr inbounds [3 x %any], ptr %varargslots2, i64 0, i64 1 - store %any %21, ptr %22, align 16 + %20 = insertvalue %"any*" undef, ptr %taddr, 0 + %21 = insertvalue %"any*" %20, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %22 = getelementptr inbounds [3 x %"any*"], ptr %varargslots2, i64 0, i64 1 + store %"any*" %21, ptr %22, align 16 %23 = load i8, ptr %z, align 1 store i8 %23, ptr %self3, align 1 %24 = load i8, ptr %self3, align 1 %25 = load i8, ptr %self3, align 1 %26 = call i8 @llvm.fshl.i8(i8 %24, i8 %25, i8 1) store i8 %26, ptr %taddr4, align 1 - %27 = insertvalue %any undef, ptr %taddr4, 0 - %28 = insertvalue %any %27, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - %29 = getelementptr inbounds [3 x %any], ptr %varargslots2, i64 0, i64 2 - store %any %28, ptr %29, align 16 + %27 = insertvalue %"any*" undef, ptr %taddr4, 0 + %28 = insertvalue %"any*" %27, i64 ptrtoint (ptr @"$ct.char" to i64), 1 + %29 = getelementptr inbounds [3 x %"any*"], ptr %varargslots2, i64 0, i64 2 + store %"any*" %28, ptr %29, align 16 %30 = call i64 @std.io.printfn(ptr %retparam1, ptr @.str.1, i64 8, ptr %varargslots2, i64 3) ret void } diff --git a/test/test_suite/macros/macro_failable_return_rethrow.c3t b/test/test_suite/macros/macro_failable_return_rethrow.c3t index 61267e4ac..be9c95366 100644 --- a/test/test_suite/macros/macro_failable_return_rethrow.c3t +++ b/test/test_suite/macros/macro_failable_return_rethrow.c3t @@ -21,8 +21,8 @@ entry: %error_var = alloca i64, align 8 %error_var1 = alloca i64, align 8 %retparam = alloca i32, align 4 - %varargslots = alloca [1 x %any], align 16 - %indirectarg = alloca %"any[]", align 8 + %varargslots = alloca [1 x %"any*"], align 16 + %indirectarg = alloca %"any*[]", align 8 %0 = call i64 @test.xy(ptr %retparam) %not_err = icmp eq i64 %0, 0 %1 = call i1 @llvm.expect.i1(i1 %not_err, i1 true) @@ -39,14 +39,14 @@ guard_block: ; preds = %assign_optional noerr_block: ; preds = %after_check br label %noerr_block2 panic_block: ; preds = %guard_block - %3 = insertvalue %any undef, ptr %error_var, 0 - %4 = insertvalue %any %3, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %5 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %4, ptr %5, align 16 - %6 = insertvalue %"any[]" undef, ptr %varargslots, 0 - %"#temp#" = insertvalue %"any[]" %6, i64 1, 1 - store %"any[]" %"#temp#", ptr %indirectarg, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 32, ptr @.func, i64 4, i32 13, ptr byval(%"any[]") align 8 %indirectarg) + %3 = insertvalue %"any*" undef, ptr %error_var, 0 + %4 = insertvalue %"any*" %3, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %5 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %4, ptr %5, align 16 + %6 = insertvalue %"any*[]" undef, ptr %varargslots, 0 + %"#temp#" = insertvalue %"any*[]" %6, i64 1, 1 + store %"any*[]" %"#temp#", ptr %indirectarg, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 32, ptr @.func, i64 4, i32 13, ptr byval(%"any*[]") align 8 %indirectarg) unreachable noerr_block2: ; preds = %noerr_block ret void diff --git a/test/test_suite/macros/macro_typed_varargs.c3t b/test/test_suite/macros/macro_typed_varargs.c3t index 75e7de1c0..34f70acfb 100644 --- a/test/test_suite/macros/macro_typed_varargs.c3t +++ b/test/test_suite/macros/macro_typed_varargs.c3t @@ -36,18 +36,18 @@ entry: %.anon1 = alloca i64, align 8 %i = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 - %literal2 = alloca [4 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 + %literal2 = alloca [4 x %"any*"], align 16 %taddr = alloca i32, align 4 %taddr3 = alloca i32, align 4 %taddr4 = alloca i32, align 4 %taddr5 = alloca i32, align 4 - %x6 = alloca %"any[]", align 8 + %x6 = alloca %"any*[]", align 8 %.anon7 = alloca i64, align 8 %.anon8 = alloca i64, align 8 - %i12 = alloca %any, align 8 + %i12 = alloca %"any*", align 8 %retparam14 = alloca i64, align 8 - %varargslots15 = alloca [1 x %any], align 16 + %varargslots15 = alloca [1 x %"any*"], align 16 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %literal, ptr align 16 @.__const, i32 16, i1 false) %0 = insertvalue %"int[]" undef, ptr %literal, 0 %1 = insertvalue %"int[]" %0, i64 4, 1 @@ -71,10 +71,10 @@ loop.body: ; preds = %loop.cond %ptroffset = getelementptr inbounds i32, ptr %7, i64 %8 %9 = load i32, ptr %ptroffset, align 4 store i32 %9, ptr %i, align 4 - %10 = insertvalue %any undef, ptr %i, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %12 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %11, ptr %12, align 16 + %10 = insertvalue %"any*" undef, ptr %i, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %12 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 %13 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) %14 = load i64, ptr %.anon1, align 8 %add = add i64 %14, 1 @@ -82,30 +82,30 @@ loop.body: ; preds = %loop.cond br label %loop.cond loop.exit: ; preds = %loop.cond - %15 = getelementptr inbounds [4 x %any], ptr %literal2, i64 0, i64 0 + %15 = getelementptr inbounds [4 x %"any*"], ptr %literal2, i64 0, i64 0 store i32 1, ptr %taddr, align 4 - %16 = insertvalue %any undef, ptr %taddr, 0 - %17 = insertvalue %any %16, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %17, ptr %15, align 8 - %18 = getelementptr inbounds [4 x %any], ptr %literal2, i64 0, i64 1 + %16 = insertvalue %"any*" undef, ptr %taddr, 0 + %17 = insertvalue %"any*" %16, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %17, ptr %15, align 8 + %18 = getelementptr inbounds [4 x %"any*"], ptr %literal2, i64 0, i64 1 store i32 -1, ptr %taddr3, align 4 - %19 = insertvalue %any undef, ptr %taddr3, 0 - %20 = insertvalue %any %19, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %20, ptr %18, align 8 - %21 = getelementptr inbounds [4 x %any], ptr %literal2, i64 0, i64 2 + %19 = insertvalue %"any*" undef, ptr %taddr3, 0 + %20 = insertvalue %"any*" %19, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %20, ptr %18, align 8 + %21 = getelementptr inbounds [4 x %"any*"], ptr %literal2, i64 0, i64 2 store i32 3141, ptr %taddr4, align 4 - %22 = insertvalue %any undef, ptr %taddr4, 0 - %23 = insertvalue %any %22, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %23, ptr %21, align 8 - %24 = getelementptr inbounds [4 x %any], ptr %literal2, i64 0, i64 3 + %22 = insertvalue %"any*" undef, ptr %taddr4, 0 + %23 = insertvalue %"any*" %22, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %23, ptr %21, align 8 + %24 = getelementptr inbounds [4 x %"any*"], ptr %literal2, i64 0, i64 3 store i32 1000, ptr %taddr5, align 4 - %25 = insertvalue %any undef, ptr %taddr5, 0 - %26 = insertvalue %any %25, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %26, ptr %24, align 8 - %27 = insertvalue %"any[]" undef, ptr %literal2, 0 - %28 = insertvalue %"any[]" %27, i64 4, 1 - store %"any[]" %28, ptr %x6, align 8 - %29 = getelementptr inbounds %"any[]", ptr %x6, i32 0, i32 1 + %25 = insertvalue %"any*" undef, ptr %taddr5, 0 + %26 = insertvalue %"any*" %25, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %26, ptr %24, align 8 + %27 = insertvalue %"any*[]" undef, ptr %literal2, 0 + %28 = insertvalue %"any*[]" %27, i64 4, 1 + store %"any*[]" %28, ptr %x6, align 8 + %29 = getelementptr inbounds %"any*[]", ptr %x6, i32 0, i32 1 %30 = load i64, ptr %29, align 8 store i64 %30, ptr %.anon7, align 8 store i64 0, ptr %.anon8, align 8 @@ -118,17 +118,17 @@ loop.cond9: ; preds = %loop.body11, %loop. br i1 %lt10, label %loop.body11, label %loop.exit17 loop.body11: ; preds = %loop.cond9 - %33 = getelementptr inbounds %"any[]", ptr %x6, i32 0, i32 0 + %33 = getelementptr inbounds %"any*[]", ptr %x6, i32 0, i32 0 %34 = load ptr, ptr %33, align 8 %35 = load i64, ptr %.anon8, align 8 - %ptroffset13 = getelementptr inbounds %any, ptr %34, i64 %35 + %ptroffset13 = getelementptr inbounds %"any*", ptr %34, i64 %35 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %i12, ptr align 8 %ptroffset13, i32 16, i1 false) - %36 = getelementptr inbounds %any, ptr %i12, i32 0, i32 0 + %36 = getelementptr inbounds %"any*", ptr %i12, i32 0, i32 0 %37 = load ptr, ptr %36, align 8 - %38 = insertvalue %any undef, ptr %37, 0 - %39 = insertvalue %any %38, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %40 = getelementptr inbounds [1 x %any], ptr %varargslots15, i64 0, i64 0 - store %any %39, ptr %40, align 16 + %38 = insertvalue %"any*" undef, ptr %37, 0 + %39 = insertvalue %"any*" %38, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %40 = getelementptr inbounds [1 x %"any*"], ptr %varargslots15, i64 0, i64 0 + store %"any*" %39, ptr %40, align 16 %41 = call i64 @std.io.printfn(ptr %retparam14, ptr @.str.1, i64 2, ptr %varargslots15, i64 1) %42 = load i64, ptr %.anon8, align 8 %add16 = add i64 %42, 1 diff --git a/test/test_suite/macros/macro_untyped_varargs_2.c3t b/test/test_suite/macros/macro_untyped_varargs_2.c3t index 325544b89..79a7fa1d3 100644 --- a/test/test_suite/macros/macro_untyped_varargs_2.c3t +++ b/test/test_suite/macros/macro_untyped_varargs_2.c3t @@ -63,13 +63,13 @@ fn void main() define i32 @test.ping(i32 %0) #0 { entry: %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 store i32 %0, ptr %taddr, align 4 - %1 = insertvalue %any undef, ptr %taddr, 0 - %2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %3 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %2, ptr %3, align 16 + %1 = insertvalue %"any*" undef, ptr %taddr, 0 + %2 = insertvalue %"any*" %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %3 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %2, ptr %3, align 16 %4 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 8, ptr %varargslots, i64 1) ret i32 %0 } @@ -79,36 +79,36 @@ entry: %i = alloca i32, align 4 %j = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %taddr = alloca i32, align 4 %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [1 x %any], align 16 + %varargslots3 = alloca [1 x %"any*"], align 16 %taddr4 = alloca i32, align 4 %retparam5 = alloca i64, align 8 - %varargslots6 = alloca [1 x %any], align 16 + %varargslots6 = alloca [1 x %"any*"], align 16 %taddr7 = alloca i32, align 4 %retparam8 = alloca i64, align 8 - %varargslots9 = alloca [1 x %any], align 16 + %varargslots9 = alloca [1 x %"any*"], align 16 %taddr10 = alloca i32, align 4 %x = alloca i32, align 4 %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %any], align 16 + %varargslots12 = alloca [1 x %"any*"], align 16 %taddr13 = alloca %"char[]", align 8 %x14 = alloca double, align 8 %retparam15 = alloca i64, align 8 - %varargslots16 = alloca [1 x %any], align 16 + %varargslots16 = alloca [1 x %"any*"], align 16 %taddr17 = alloca %"char[]", align 8 %retparam18 = alloca i64, align 8 - %varargslots19 = alloca [1 x %any], align 16 + %varargslots19 = alloca [1 x %"any*"], align 16 %taddr20 = alloca i32, align 4 %x21 = alloca i32, align 4 %y = alloca i32, align 4 %a = alloca i32, align 4 %retparam22 = alloca i64, align 8 - %varargslots23 = alloca [2 x %any], align 16 + %varargslots23 = alloca [2 x %"any*"], align 16 %a24 = alloca i32, align 4 %retparam25 = alloca i64, align 8 - %varargslots26 = alloca [2 x %any], align 16 + %varargslots26 = alloca [2 x %"any*"], align 16 %0 = call i32 @test.ping(i32 -1) %1 = call i32 @test.ping(i32 1) %2 = call i32 @test.ping(i32 3141) @@ -120,48 +120,48 @@ entry: %add1 = add i32 %4, %5 store i32 %add1, ptr %j, align 4 store i32 %1, ptr %taddr, align 4 - %6 = insertvalue %any undef, ptr %taddr, 0 - %7 = insertvalue %any %6, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %8 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %7, ptr %8, align 16 + %6 = insertvalue %"any*" undef, ptr %taddr, 0 + %7 = insertvalue %"any*" %6, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %8 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %7, ptr %8, align 16 %9 = call i64 @std.io.printfn(ptr %retparam, ptr @.str.1, i64 2, ptr %varargslots, i64 1) store i32 %0, ptr %taddr4, align 4 - %10 = insertvalue %any undef, ptr %taddr4, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %12 = getelementptr inbounds [1 x %any], ptr %varargslots3, i64 0, i64 0 - store %any %11, ptr %12, align 16 + %10 = insertvalue %"any*" undef, ptr %taddr4, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %12 = getelementptr inbounds [1 x %"any*"], ptr %varargslots3, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 %13 = call i64 @std.io.printfn(ptr %retparam2, ptr @.str.2, i64 2, ptr %varargslots3, i64 1) store i32 %2, ptr %taddr7, align 4 - %14 = insertvalue %any undef, ptr %taddr7, 0 - %15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %16 = getelementptr inbounds [1 x %any], ptr %varargslots6, i64 0, i64 0 - store %any %15, ptr %16, align 16 + %14 = insertvalue %"any*" undef, ptr %taddr7, 0 + %15 = insertvalue %"any*" %14, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %16 = getelementptr inbounds [1 x %"any*"], ptr %varargslots6, i64 0, i64 0 + store %"any*" %15, ptr %16, align 16 %17 = call i64 @std.io.printfn(ptr %retparam5, ptr @.str.3, i64 2, ptr %varargslots6, i64 1) store i32 %3, ptr %taddr10, align 4 - %18 = insertvalue %any undef, ptr %taddr10, 0 - %19 = insertvalue %any %18, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %20 = getelementptr inbounds [1 x %any], ptr %varargslots9, i64 0, i64 0 - store %any %19, ptr %20, align 16 + %18 = insertvalue %"any*" undef, ptr %taddr10, 0 + %19 = insertvalue %"any*" %18, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %20 = getelementptr inbounds [1 x %"any*"], ptr %varargslots9, i64 0, i64 0 + store %"any*" %19, ptr %20, align 16 %21 = call i64 @std.io.printfn(ptr %retparam8, ptr @.str.4, i64 2, ptr %varargslots9, i64 1) store i32 0, ptr %x, align 4 store %"char[]" { ptr @.str.6, i64 3 }, ptr %taddr13, align 8 - %22 = insertvalue %any undef, ptr %taddr13, 0 - %23 = insertvalue %any %22, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %24 = getelementptr inbounds [1 x %any], ptr %varargslots12, i64 0, i64 0 - store %any %23, ptr %24, align 16 + %22 = insertvalue %"any*" undef, ptr %taddr13, 0 + %23 = insertvalue %"any*" %22, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %24 = getelementptr inbounds [1 x %"any*"], ptr %varargslots12, i64 0, i64 0 + store %"any*" %23, ptr %24, align 16 %25 = call i64 @std.io.printfn(ptr %retparam11, ptr @.str.5, i64 2, ptr %varargslots12, i64 1) store double 0.000000e+00, ptr %x14, align 8 store %"char[]" { ptr @.str.8, i64 6 }, ptr %taddr17, align 8 - %26 = insertvalue %any undef, ptr %taddr17, 0 - %27 = insertvalue %any %26, i64 ptrtoint (ptr @"$ct.String" to i64), 1 - %28 = getelementptr inbounds [1 x %any], ptr %varargslots16, i64 0, i64 0 - store %any %27, ptr %28, align 16 + %26 = insertvalue %"any*" undef, ptr %taddr17, 0 + %27 = insertvalue %"any*" %26, i64 ptrtoint (ptr @"$ct.String" to i64), 1 + %28 = getelementptr inbounds [1 x %"any*"], ptr %varargslots16, i64 0, i64 0 + store %"any*" %27, ptr %28, align 16 %29 = call i64 @std.io.printfn(ptr %retparam15, ptr @.str.7, i64 2, ptr %varargslots16, i64 1) store i32 105, ptr %taddr20, align 4 - %30 = insertvalue %any undef, ptr %taddr20, 0 - %31 = insertvalue %any %30, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %32 = getelementptr inbounds [1 x %any], ptr %varargslots19, i64 0, i64 0 - store %any %31, ptr %32, align 16 + %30 = insertvalue %"any*" undef, ptr %taddr20, 0 + %31 = insertvalue %"any*" %30, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %32 = getelementptr inbounds [1 x %"any*"], ptr %varargslots19, i64 0, i64 0 + store %"any*" %31, ptr %32, align 16 %33 = call i64 @std.io.printfn(ptr %retparam18, ptr @.str.9, i64 2, ptr %varargslots19, i64 1) store i32 123, ptr %x21, align 4 store i32 33, ptr %y, align 4 @@ -171,14 +171,14 @@ entry: store i32 %35, ptr %x21, align 4 %36 = load i32, ptr %a, align 4 store i32 %36, ptr %y, align 4 - %37 = insertvalue %any undef, ptr %x21, 0 - %38 = insertvalue %any %37, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %39 = getelementptr inbounds [2 x %any], ptr %varargslots23, i64 0, i64 0 - store %any %38, ptr %39, align 16 - %40 = insertvalue %any undef, ptr %y, 0 - %41 = insertvalue %any %40, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %42 = getelementptr inbounds [2 x %any], ptr %varargslots23, i64 0, i64 1 - store %any %41, ptr %42, align 16 + %37 = insertvalue %"any*" undef, ptr %x21, 0 + %38 = insertvalue %"any*" %37, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %39 = getelementptr inbounds [2 x %"any*"], ptr %varargslots23, i64 0, i64 0 + store %"any*" %38, ptr %39, align 16 + %40 = insertvalue %"any*" undef, ptr %y, 0 + %41 = insertvalue %"any*" %40, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %42 = getelementptr inbounds [2 x %"any*"], ptr %varargslots23, i64 0, i64 1 + store %"any*" %41, ptr %42, align 16 %43 = call i64 @std.io.printfn(ptr %retparam22, ptr @.str.10, i64 6, ptr %varargslots23, i64 2) %44 = load i32, ptr %x21, align 4 store i32 %44, ptr %a24, align 4 @@ -186,14 +186,14 @@ entry: store i32 %45, ptr %x21, align 4 %46 = load i32, ptr %a24, align 4 store i32 %46, ptr %y, align 4 - %47 = insertvalue %any undef, ptr %x21, 0 - %48 = insertvalue %any %47, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %49 = getelementptr inbounds [2 x %any], ptr %varargslots26, i64 0, i64 0 - store %any %48, ptr %49, align 16 - %50 = insertvalue %any undef, ptr %y, 0 - %51 = insertvalue %any %50, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %52 = getelementptr inbounds [2 x %any], ptr %varargslots26, i64 0, i64 1 - store %any %51, ptr %52, align 16 + %47 = insertvalue %"any*" undef, ptr %x21, 0 + %48 = insertvalue %"any*" %47, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %49 = getelementptr inbounds [2 x %"any*"], ptr %varargslots26, i64 0, i64 0 + store %"any*" %48, ptr %49, align 16 + %50 = insertvalue %"any*" undef, ptr %y, 0 + %51 = insertvalue %"any*" %50, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %52 = getelementptr inbounds [2 x %"any*"], ptr %varargslots26, i64 0, i64 1 + store %"any*" %51, ptr %52, align 16 %53 = call i64 @std.io.printfn(ptr %retparam25, ptr @.str.11, i64 6, ptr %varargslots26, i64 2) ret void } \ No newline at end of file diff --git a/test/test_suite/macros/macro_vasplat.c3t b/test/test_suite/macros/macro_vasplat.c3t index 9b2f7eb6e..25e5f5666 100644 --- a/test/test_suite/macros/macro_vasplat.c3t +++ b/test/test_suite/macros/macro_vasplat.c3t @@ -69,73 +69,73 @@ entry: %i = alloca i64, align 8 %x = alloca i32, align 4 %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 + %varargslots = alloca [2 x %"any*"], align 16 %a1 = alloca [1 x i32], align 4 %.anon2 = alloca i64, align 8 %i6 = alloca i64, align 8 %x7 = alloca i32, align 4 %retparam8 = alloca i64, align 8 - %varargslots9 = alloca [2 x %any], align 16 + %varargslots9 = alloca [2 x %"any*"], align 16 %a12 = alloca [4 x i32], align 16 %.anon13 = alloca i64, align 8 %i17 = alloca i64, align 8 %x18 = alloca i32, align 4 %retparam19 = alloca i64, align 8 - %varargslots20 = alloca [2 x %any], align 16 + %varargslots20 = alloca [2 x %"any*"], align 16 %a23 = alloca [2 x i32], align 4 %.anon24 = alloca i64, align 8 %i28 = alloca i64, align 8 %x29 = alloca i32, align 4 %retparam30 = alloca i64, align 8 - %varargslots31 = alloca [2 x %any], align 16 + %varargslots31 = alloca [2 x %"any*"], align 16 %a34 = alloca [3 x i32], align 4 %.anon35 = alloca i64, align 8 %i39 = alloca i64, align 8 %x40 = alloca i32, align 4 %retparam41 = alloca i64, align 8 - %varargslots42 = alloca [2 x %any], align 16 + %varargslots42 = alloca [2 x %"any*"], align 16 %a45 = alloca [1 x i32], align 4 %.anon46 = alloca i64, align 8 %i50 = alloca i64, align 8 %x51 = alloca i32, align 4 %retparam52 = alloca i64, align 8 - %varargslots53 = alloca [2 x %any], align 16 + %varargslots53 = alloca [2 x %"any*"], align 16 %a56 = alloca [2 x i32], align 4 %.anon57 = alloca i64, align 8 %i61 = alloca i64, align 8 %x62 = alloca i32, align 4 %retparam63 = alloca i64, align 8 - %varargslots64 = alloca [2 x %any], align 16 + %varargslots64 = alloca [2 x %"any*"], align 16 %a67 = alloca [5 x i32], align 16 %.anon68 = alloca i64, align 8 %i72 = alloca i64, align 8 %x73 = alloca i32, align 4 %retparam74 = alloca i64, align 8 - %varargslots75 = alloca [2 x %any], align 16 + %varargslots75 = alloca [2 x %"any*"], align 16 %a78 = alloca [8 x i32], align 16 %.anon79 = alloca i64, align 8 %i83 = alloca i64, align 8 %x84 = alloca i32, align 4 %retparam85 = alloca i64, align 8 - %varargslots86 = alloca [2 x %any], align 16 + %varargslots86 = alloca [2 x %"any*"], align 16 %b = alloca [7 x i32], align 16 %.anon89 = alloca i64, align 8 %i93 = alloca i64, align 8 %x94 = alloca i32, align 4 %retparam95 = alloca i64, align 8 - %varargslots96 = alloca [2 x %any], align 16 + %varargslots96 = alloca [2 x %"any*"], align 16 %c = alloca [8 x i32], align 16 %.anon99 = alloca i64, align 8 %i103 = alloca i64, align 8 %x104 = alloca i32, align 4 %retparam105 = alloca i64, align 8 - %varargslots106 = alloca [2 x %any], align 16 + %varargslots106 = alloca [2 x %"any*"], align 16 %a109 = alloca [6 x i32], align 16 %.anon110 = alloca i64, align 8 %i114 = alloca i64, align 8 %x115 = alloca i32, align 4 %retparam116 = alloca i64, align 8 - %varargslots117 = alloca [2 x %any], align 16 + %varargslots117 = alloca [2 x %"any*"], align 16 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a, ptr align 4 @.__const, i32 12, i1 false) store i64 0, ptr %.anon, align 8 br label %loop.cond @@ -152,14 +152,14 @@ loop.body: ; preds = %loop.cond %3 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 %2 %4 = load i32, ptr %3, align 4 store i32 %4, ptr %x, align 4 - %5 = insertvalue %any undef, ptr %i, 0 - %6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %7 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %6, ptr %7, align 16 - %8 = insertvalue %any undef, ptr %x, 0 - %9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %10 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %9, ptr %10, align 16 + %5 = insertvalue %"any*" undef, ptr %i, 0 + %6 = insertvalue %"any*" %5, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %7 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %6, ptr %7, align 16 + %8 = insertvalue %"any*" undef, ptr %x, 0 + %9 = insertvalue %"any*" %8, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %10 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %9, ptr %10, align 16 %11 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 8, ptr %varargslots, i64 2) %12 = load i64, ptr %.anon, align 8 %add = add i64 %12, 1 @@ -183,14 +183,14 @@ loop.body5: ; preds = %loop.cond3 %16 = getelementptr inbounds [1 x i32], ptr %a1, i64 0, i64 %15 %17 = load i32, ptr %16, align 4 store i32 %17, ptr %x7, align 4 - %18 = insertvalue %any undef, ptr %i6, 0 - %19 = insertvalue %any %18, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %20 = getelementptr inbounds [2 x %any], ptr %varargslots9, i64 0, i64 0 - store %any %19, ptr %20, align 16 - %21 = insertvalue %any undef, ptr %x7, 0 - %22 = insertvalue %any %21, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %23 = getelementptr inbounds [2 x %any], ptr %varargslots9, i64 0, i64 1 - store %any %22, ptr %23, align 16 + %18 = insertvalue %"any*" undef, ptr %i6, 0 + %19 = insertvalue %"any*" %18, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %20 = getelementptr inbounds [2 x %"any*"], ptr %varargslots9, i64 0, i64 0 + store %"any*" %19, ptr %20, align 16 + %21 = insertvalue %"any*" undef, ptr %x7, 0 + %22 = insertvalue %"any*" %21, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %23 = getelementptr inbounds [2 x %"any*"], ptr %varargslots9, i64 0, i64 1 + store %"any*" %22, ptr %23, align 16 %24 = call i64 @std.io.printfn(ptr %retparam8, ptr @.str.2, i64 8, ptr %varargslots9, i64 2) %25 = load i64, ptr %.anon2, align 8 %add10 = add i64 %25, 1 @@ -214,14 +214,14 @@ loop.body16: ; preds = %loop.cond14 %29 = getelementptr inbounds [4 x i32], ptr %a12, i64 0, i64 %28 %30 = load i32, ptr %29, align 4 store i32 %30, ptr %x18, align 4 - %31 = insertvalue %any undef, ptr %i17, 0 - %32 = insertvalue %any %31, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %33 = getelementptr inbounds [2 x %any], ptr %varargslots20, i64 0, i64 0 - store %any %32, ptr %33, align 16 - %34 = insertvalue %any undef, ptr %x18, 0 - %35 = insertvalue %any %34, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %36 = getelementptr inbounds [2 x %any], ptr %varargslots20, i64 0, i64 1 - store %any %35, ptr %36, align 16 + %31 = insertvalue %"any*" undef, ptr %i17, 0 + %32 = insertvalue %"any*" %31, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %33 = getelementptr inbounds [2 x %"any*"], ptr %varargslots20, i64 0, i64 0 + store %"any*" %32, ptr %33, align 16 + %34 = insertvalue %"any*" undef, ptr %x18, 0 + %35 = insertvalue %"any*" %34, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %36 = getelementptr inbounds [2 x %"any*"], ptr %varargslots20, i64 0, i64 1 + store %"any*" %35, ptr %36, align 16 %37 = call i64 @std.io.printfn(ptr %retparam19, ptr @.str.4, i64 6, ptr %varargslots20, i64 2) %38 = load i64, ptr %.anon13, align 8 %add21 = add i64 %38, 1 @@ -245,14 +245,14 @@ loop.body27: ; preds = %loop.cond25 %42 = getelementptr inbounds [2 x i32], ptr %a23, i64 0, i64 %41 %43 = load i32, ptr %42, align 4 store i32 %43, ptr %x29, align 4 - %44 = insertvalue %any undef, ptr %i28, 0 - %45 = insertvalue %any %44, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %46 = getelementptr inbounds [2 x %any], ptr %varargslots31, i64 0, i64 0 - store %any %45, ptr %46, align 16 - %47 = insertvalue %any undef, ptr %x29, 0 - %48 = insertvalue %any %47, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %49 = getelementptr inbounds [2 x %any], ptr %varargslots31, i64 0, i64 1 - store %any %48, ptr %49, align 16 + %44 = insertvalue %"any*" undef, ptr %i28, 0 + %45 = insertvalue %"any*" %44, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %46 = getelementptr inbounds [2 x %"any*"], ptr %varargslots31, i64 0, i64 0 + store %"any*" %45, ptr %46, align 16 + %47 = insertvalue %"any*" undef, ptr %x29, 0 + %48 = insertvalue %"any*" %47, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %49 = getelementptr inbounds [2 x %"any*"], ptr %varargslots31, i64 0, i64 1 + store %"any*" %48, ptr %49, align 16 %50 = call i64 @std.io.printfn(ptr %retparam30, ptr @.str.6, i64 6, ptr %varargslots31, i64 2) %51 = load i64, ptr %.anon24, align 8 %add32 = add i64 %51, 1 @@ -276,14 +276,14 @@ loop.body38: ; preds = %loop.cond36 %55 = getelementptr inbounds [3 x i32], ptr %a34, i64 0, i64 %54 %56 = load i32, ptr %55, align 4 store i32 %56, ptr %x40, align 4 - %57 = insertvalue %any undef, ptr %i39, 0 - %58 = insertvalue %any %57, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %59 = getelementptr inbounds [2 x %any], ptr %varargslots42, i64 0, i64 0 - store %any %58, ptr %59, align 16 - %60 = insertvalue %any undef, ptr %x40, 0 - %61 = insertvalue %any %60, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %62 = getelementptr inbounds [2 x %any], ptr %varargslots42, i64 0, i64 1 - store %any %61, ptr %62, align 16 + %57 = insertvalue %"any*" undef, ptr %i39, 0 + %58 = insertvalue %"any*" %57, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %59 = getelementptr inbounds [2 x %"any*"], ptr %varargslots42, i64 0, i64 0 + store %"any*" %58, ptr %59, align 16 + %60 = insertvalue %"any*" undef, ptr %x40, 0 + %61 = insertvalue %"any*" %60, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %62 = getelementptr inbounds [2 x %"any*"], ptr %varargslots42, i64 0, i64 1 + store %"any*" %61, ptr %62, align 16 %63 = call i64 @std.io.printfn(ptr %retparam41, ptr @.str.8, i64 8, ptr %varargslots42, i64 2) %64 = load i64, ptr %.anon35, align 8 %add43 = add i64 %64, 1 @@ -307,14 +307,14 @@ loop.body49: ; preds = %loop.cond47 %68 = getelementptr inbounds [1 x i32], ptr %a45, i64 0, i64 %67 %69 = load i32, ptr %68, align 4 store i32 %69, ptr %x51, align 4 - %70 = insertvalue %any undef, ptr %i50, 0 - %71 = insertvalue %any %70, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %72 = getelementptr inbounds [2 x %any], ptr %varargslots53, i64 0, i64 0 - store %any %71, ptr %72, align 16 - %73 = insertvalue %any undef, ptr %x51, 0 - %74 = insertvalue %any %73, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %75 = getelementptr inbounds [2 x %any], ptr %varargslots53, i64 0, i64 1 - store %any %74, ptr %75, align 16 + %70 = insertvalue %"any*" undef, ptr %i50, 0 + %71 = insertvalue %"any*" %70, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %72 = getelementptr inbounds [2 x %"any*"], ptr %varargslots53, i64 0, i64 0 + store %"any*" %71, ptr %72, align 16 + %73 = insertvalue %"any*" undef, ptr %x51, 0 + %74 = insertvalue %"any*" %73, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %75 = getelementptr inbounds [2 x %"any*"], ptr %varargslots53, i64 0, i64 1 + store %"any*" %74, ptr %75, align 16 %76 = call i64 @std.io.printfn(ptr %retparam52, ptr @.str.10, i64 8, ptr %varargslots53, i64 2) %77 = load i64, ptr %.anon46, align 8 %add54 = add i64 %77, 1 @@ -338,14 +338,14 @@ loop.body60: ; preds = %loop.cond58 %81 = getelementptr inbounds [2 x i32], ptr %a56, i64 0, i64 %80 %82 = load i32, ptr %81, align 4 store i32 %82, ptr %x62, align 4 - %83 = insertvalue %any undef, ptr %i61, 0 - %84 = insertvalue %any %83, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %85 = getelementptr inbounds [2 x %any], ptr %varargslots64, i64 0, i64 0 - store %any %84, ptr %85, align 16 - %86 = insertvalue %any undef, ptr %x62, 0 - %87 = insertvalue %any %86, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %88 = getelementptr inbounds [2 x %any], ptr %varargslots64, i64 0, i64 1 - store %any %87, ptr %88, align 16 + %83 = insertvalue %"any*" undef, ptr %i61, 0 + %84 = insertvalue %"any*" %83, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %85 = getelementptr inbounds [2 x %"any*"], ptr %varargslots64, i64 0, i64 0 + store %"any*" %84, ptr %85, align 16 + %86 = insertvalue %"any*" undef, ptr %x62, 0 + %87 = insertvalue %"any*" %86, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %88 = getelementptr inbounds [2 x %"any*"], ptr %varargslots64, i64 0, i64 1 + store %"any*" %87, ptr %88, align 16 %89 = call i64 @std.io.printfn(ptr %retparam63, ptr @.str.12, i64 8, ptr %varargslots64, i64 2) %90 = load i64, ptr %.anon57, align 8 %add65 = add i64 %90, 1 @@ -369,14 +369,14 @@ loop.body71: ; preds = %loop.cond69 %94 = getelementptr inbounds [5 x i32], ptr %a67, i64 0, i64 %93 %95 = load i32, ptr %94, align 4 store i32 %95, ptr %x73, align 4 - %96 = insertvalue %any undef, ptr %i72, 0 - %97 = insertvalue %any %96, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %98 = getelementptr inbounds [2 x %any], ptr %varargslots75, i64 0, i64 0 - store %any %97, ptr %98, align 16 - %99 = insertvalue %any undef, ptr %x73, 0 - %100 = insertvalue %any %99, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %101 = getelementptr inbounds [2 x %any], ptr %varargslots75, i64 0, i64 1 - store %any %100, ptr %101, align 16 + %96 = insertvalue %"any*" undef, ptr %i72, 0 + %97 = insertvalue %"any*" %96, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %98 = getelementptr inbounds [2 x %"any*"], ptr %varargslots75, i64 0, i64 0 + store %"any*" %97, ptr %98, align 16 + %99 = insertvalue %"any*" undef, ptr %x73, 0 + %100 = insertvalue %"any*" %99, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %101 = getelementptr inbounds [2 x %"any*"], ptr %varargslots75, i64 0, i64 1 + store %"any*" %100, ptr %101, align 16 %102 = call i64 @std.io.printfn(ptr %retparam74, ptr @.str.14, i64 8, ptr %varargslots75, i64 2) %103 = load i64, ptr %.anon68, align 8 %add76 = add i64 %103, 1 @@ -400,14 +400,14 @@ loop.body82: ; preds = %loop.cond80 %107 = getelementptr inbounds [8 x i32], ptr %a78, i64 0, i64 %106 %108 = load i32, ptr %107, align 4 store i32 %108, ptr %x84, align 4 - %109 = insertvalue %any undef, ptr %i83, 0 - %110 = insertvalue %any %109, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %111 = getelementptr inbounds [2 x %any], ptr %varargslots86, i64 0, i64 0 - store %any %110, ptr %111, align 16 - %112 = insertvalue %any undef, ptr %x84, 0 - %113 = insertvalue %any %112, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %114 = getelementptr inbounds [2 x %any], ptr %varargslots86, i64 0, i64 1 - store %any %113, ptr %114, align 16 + %109 = insertvalue %"any*" undef, ptr %i83, 0 + %110 = insertvalue %"any*" %109, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %111 = getelementptr inbounds [2 x %"any*"], ptr %varargslots86, i64 0, i64 0 + store %"any*" %110, ptr %111, align 16 + %112 = insertvalue %"any*" undef, ptr %x84, 0 + %113 = insertvalue %"any*" %112, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %114 = getelementptr inbounds [2 x %"any*"], ptr %varargslots86, i64 0, i64 1 + store %"any*" %113, ptr %114, align 16 %115 = call i64 @std.io.printfn(ptr %retparam85, ptr @.str.16, i64 8, ptr %varargslots86, i64 2) %116 = load i64, ptr %.anon79, align 8 %add87 = add i64 %116, 1 @@ -431,14 +431,14 @@ loop.body92: ; preds = %loop.cond90 %120 = getelementptr inbounds [7 x i32], ptr %b, i64 0, i64 %119 %121 = load i32, ptr %120, align 4 store i32 %121, ptr %x94, align 4 - %122 = insertvalue %any undef, ptr %i93, 0 - %123 = insertvalue %any %122, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %124 = getelementptr inbounds [2 x %any], ptr %varargslots96, i64 0, i64 0 - store %any %123, ptr %124, align 16 - %125 = insertvalue %any undef, ptr %x94, 0 - %126 = insertvalue %any %125, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %127 = getelementptr inbounds [2 x %any], ptr %varargslots96, i64 0, i64 1 - store %any %126, ptr %127, align 16 + %122 = insertvalue %"any*" undef, ptr %i93, 0 + %123 = insertvalue %"any*" %122, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %124 = getelementptr inbounds [2 x %"any*"], ptr %varargslots96, i64 0, i64 0 + store %"any*" %123, ptr %124, align 16 + %125 = insertvalue %"any*" undef, ptr %x94, 0 + %126 = insertvalue %"any*" %125, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %127 = getelementptr inbounds [2 x %"any*"], ptr %varargslots96, i64 0, i64 1 + store %"any*" %126, ptr %127, align 16 %128 = call i64 @std.io.printfn(ptr %retparam95, ptr @.str.18, i64 8, ptr %varargslots96, i64 2) %129 = load i64, ptr %.anon89, align 8 %add97 = add i64 %129, 1 @@ -462,14 +462,14 @@ loop.body102: ; preds = %loop.cond100 %133 = getelementptr inbounds [8 x i32], ptr %c, i64 0, i64 %132 %134 = load i32, ptr %133, align 4 store i32 %134, ptr %x104, align 4 - %135 = insertvalue %any undef, ptr %i103, 0 - %136 = insertvalue %any %135, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %137 = getelementptr inbounds [2 x %any], ptr %varargslots106, i64 0, i64 0 - store %any %136, ptr %137, align 16 - %138 = insertvalue %any undef, ptr %x104, 0 - %139 = insertvalue %any %138, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %140 = getelementptr inbounds [2 x %any], ptr %varargslots106, i64 0, i64 1 - store %any %139, ptr %140, align 16 + %135 = insertvalue %"any*" undef, ptr %i103, 0 + %136 = insertvalue %"any*" %135, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %137 = getelementptr inbounds [2 x %"any*"], ptr %varargslots106, i64 0, i64 0 + store %"any*" %136, ptr %137, align 16 + %138 = insertvalue %"any*" undef, ptr %x104, 0 + %139 = insertvalue %"any*" %138, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %140 = getelementptr inbounds [2 x %"any*"], ptr %varargslots106, i64 0, i64 1 + store %"any*" %139, ptr %140, align 16 %141 = call i64 @std.io.printfn(ptr %retparam105, ptr @.str.20, i64 9, ptr %varargslots106, i64 2) %142 = load i64, ptr %.anon99, align 8 %add107 = add i64 %142, 1 @@ -493,14 +493,14 @@ loop.body113: ; preds = %loop.cond111 %146 = getelementptr inbounds [6 x i32], ptr %a109, i64 0, i64 %145 %147 = load i32, ptr %146, align 4 store i32 %147, ptr %x115, align 4 - %148 = insertvalue %any undef, ptr %i114, 0 - %149 = insertvalue %any %148, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 - %150 = getelementptr inbounds [2 x %any], ptr %varargslots117, i64 0, i64 0 - store %any %149, ptr %150, align 16 - %151 = insertvalue %any undef, ptr %x115, 0 - %152 = insertvalue %any %151, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %153 = getelementptr inbounds [2 x %any], ptr %varargslots117, i64 0, i64 1 - store %any %152, ptr %153, align 16 + %148 = insertvalue %"any*" undef, ptr %i114, 0 + %149 = insertvalue %"any*" %148, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1 + %150 = getelementptr inbounds [2 x %"any*"], ptr %varargslots117, i64 0, i64 0 + store %"any*" %149, ptr %150, align 16 + %151 = insertvalue %"any*" undef, ptr %x115, 0 + %152 = insertvalue %"any*" %151, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %153 = getelementptr inbounds [2 x %"any*"], ptr %varargslots117, i64 0, i64 1 + store %"any*" %152, ptr %153, align 16 %154 = call i64 @std.io.printfn(ptr %retparam116, ptr @.str.22, i64 6, ptr %varargslots117, i64 2) %155 = load i64, ptr %.anon110, align 8 %add118 = add i64 %155, 1 diff --git a/test/test_suite/pointers/subarray_variant_to_ptr.c3t b/test/test_suite/pointers/subarray_variant_to_ptr.c3t index 842396467..61b3372f6 100644 --- a/test/test_suite/pointers/subarray_variant_to_ptr.c3t +++ b/test/test_suite/pointers/subarray_variant_to_ptr.c3t @@ -3,7 +3,7 @@ module foo; extern fn void printf(char*, ...); -fn void test1(any z) +fn void test1(any* z) { int* w = z.ptr; printf("%d\n", *w); @@ -26,19 +26,19 @@ fn void main() /* #expect: foo.ll -%any = type { ptr, i64 } +%"any*" = type { ptr, i64 } %"int[]" = type { ptr, i64 } @"$ct.int" = linkonce global %.introspect { i8 2, i64 0, ptr null, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 define void @foo.test1(i64 %0, ptr %1) #0 { entry: - %z = alloca %any, align 8 + %z = alloca %"any*", align 8 %w = alloca ptr, align 8 store i64 %0, ptr %z, align 8 %ptroffset = getelementptr inbounds ptr, ptr %z, i64 1 store ptr %1, ptr %ptroffset, align 8 - %2 = getelementptr inbounds %any, ptr %z, i32 0, i32 0 + %2 = getelementptr inbounds %"any*", ptr %z, i32 0, i32 0 %3 = load ptr, ptr %2, align 8 store ptr %3, ptr %w, align 8 %4 = load ptr, ptr %w, align 8 @@ -69,13 +69,13 @@ entry: %x = alloca i32, align 4 %y = alloca i32, align 4 %w = alloca [2 x i32], align 4 - %taddr = alloca %any, align 8 + %taddr = alloca %"any*", align 8 store i32 123, ptr %x, align 4 store i32 293483, ptr %y, align 4 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %w, ptr align 4 @.__const, i32 8, i1 false) - %0 = insertvalue %any undef, ptr %x, 0 - %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %any %1, ptr %taddr, align 8 + %0 = insertvalue %"any*" undef, ptr %x, 0 + %1 = insertvalue %"any*" %0, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + store %"any*" %1, ptr %taddr, align 8 %2 = getelementptr inbounds { i64, ptr }, ptr %taddr, i32 0, i32 0 %lo = load i64, ptr %2, align 8 %3 = getelementptr inbounds { i64, ptr }, ptr %taddr, i32 0, i32 1 diff --git a/test/test_suite/slices/slice_to_slice_assign.c3t b/test/test_suite/slices/slice_to_slice_assign.c3t index 5d5928b16..5cee40221 100644 --- a/test/test_suite/slices/slice_to_slice_assign.c3t +++ b/test/test_suite/slices/slice_to_slice_assign.c3t @@ -26,10 +26,10 @@ entry: %y = alloca [6 x i32], align 16 %taddr = alloca %"int[]", align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 + %varargslots = alloca [2 x %"any*"], align 16 %taddr1 = alloca %"int[]", align 8 %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [2 x %any], align 16 + %varargslots3 = alloca [2 x %"any*"], align 16 %a = alloca %"int[][]", align 8 %literal = alloca [1 x %"int[]"], align 16 %literal4 = alloca [1 x i32], align 4 @@ -37,12 +37,12 @@ entry: %literal5 = alloca [1 x %"int[]"], align 16 %literal6 = alloca [1 x i32], align 4 %retparam7 = alloca i64, align 8 - %varargslots8 = alloca [1 x %any], align 16 + %varargslots8 = alloca [1 x %"any*"], align 16 %taddr10 = alloca %"int[][]", align 8 %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %any], align 16 + %varargslots12 = alloca [1 x %"any*"], align 16 %retparam14 = alloca i64, align 8 - %varargslots15 = alloca [1 x %any], align 16 + %varargslots15 = alloca [1 x %"any*"], align 16 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %z, ptr align 16 @.__const, i32 28, i1 false) call void @llvm.memset.p0.i64(ptr align 16 %y, i8 0, i64 24, i1 false) %0 = getelementptr inbounds [7 x i32], ptr %z, i64 0, i64 3 @@ -58,14 +58,14 @@ entry: %9 = load i64, ptr %8, align 8 %10 = mul i64 %9, 4 call void @llvm.memmove.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 %10, i1 false) - %11 = insertvalue %any undef, ptr %y, 0 - %12 = insertvalue %any %11, i64 ptrtoint (ptr @"$ct.a6$int" to i64), 1 - %13 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %12, ptr %13, align 16 - %14 = insertvalue %any undef, ptr %z, 0 - %15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.a7$int" to i64), 1 - %16 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %15, ptr %16, align 16 + %11 = insertvalue %"any*" undef, ptr %y, 0 + %12 = insertvalue %"any*" %11, i64 ptrtoint (ptr @"$ct.a6$int" to i64), 1 + %13 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %12, ptr %13, align 16 + %14 = insertvalue %"any*" undef, ptr %z, 0 + %15 = insertvalue %"any*" %14, i64 ptrtoint (ptr @"$ct.a7$int" to i64), 1 + %16 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %15, ptr %16, align 16 %17 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 5, ptr %varargslots, i64 2) %18 = getelementptr inbounds [7 x i32], ptr %z, i64 0, i64 5 %19 = insertvalue %"int[]" undef, ptr %18, 0 @@ -80,14 +80,14 @@ entry: %27 = load i64, ptr %26, align 8 %28 = mul i64 %27, 4 call void @llvm.memmove.p0.p0.i64(ptr align 4 %24, ptr align 4 %25, i64 %28, i1 false) - %29 = insertvalue %any undef, ptr %y, 0 - %30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.a6$int" to i64), 1 - %31 = getelementptr inbounds [2 x %any], ptr %varargslots3, i64 0, i64 0 - store %any %30, ptr %31, align 16 - %32 = insertvalue %any undef, ptr %z, 0 - %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.a7$int" to i64), 1 - %34 = getelementptr inbounds [2 x %any], ptr %varargslots3, i64 0, i64 1 - store %any %33, ptr %34, align 16 + %29 = insertvalue %"any*" undef, ptr %y, 0 + %30 = insertvalue %"any*" %29, i64 ptrtoint (ptr @"$ct.a6$int" to i64), 1 + %31 = getelementptr inbounds [2 x %"any*"], ptr %varargslots3, i64 0, i64 0 + store %"any*" %30, ptr %31, align 16 + %32 = insertvalue %"any*" undef, ptr %z, 0 + %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.a7$int" to i64), 1 + %34 = getelementptr inbounds [2 x %"any*"], ptr %varargslots3, i64 0, i64 1 + store %"any*" %33, ptr %34, align 16 %35 = call i64 @std.io.printfn(ptr %retparam2, ptr @.str.1, i64 5, ptr %varargslots3, i64 2) %36 = getelementptr inbounds [1 x %"int[]"], ptr %literal, i64 0, i64 0 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %literal4, ptr align 4 @.__const.2, i32 4, i1 false) @@ -105,10 +105,10 @@ entry: %44 = insertvalue %"int[][]" undef, ptr %literal5, 0 %45 = insertvalue %"int[][]" %44, i64 1, 1 store %"int[][]" %45, ptr %b, align 8 - %46 = insertvalue %any undef, ptr %a, 0 - %47 = insertvalue %any %46, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 - %48 = getelementptr inbounds [1 x %any], ptr %varargslots8, i64 0, i64 0 - store %any %47, ptr %48, align 16 + %46 = insertvalue %"any*" undef, ptr %a, 0 + %47 = insertvalue %"any*" %46, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 + %48 = getelementptr inbounds [1 x %"any*"], ptr %varargslots8, i64 0, i64 0 + store %"any*" %47, ptr %48, align 16 %49 = call i64 @std.io.printfn(ptr %retparam7, ptr @.str.4, i64 2, ptr %varargslots8, i64 1) %50 = load %"int[][]", ptr %b, align 8 %51 = extractvalue %"int[][]" %50, 0 @@ -127,10 +127,10 @@ entry: %61 = load i64, ptr %60, align 8 %62 = mul i64 %61, 16 call void @llvm.memmove.p0.p0.i64(ptr align 8 %58, ptr align 8 %59, i64 %62, i1 false) - %63 = insertvalue %any undef, ptr %a, 0 - %64 = insertvalue %any %63, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 - %65 = getelementptr inbounds [1 x %any], ptr %varargslots12, i64 0, i64 0 - store %any %64, ptr %65, align 16 + %63 = insertvalue %"any*" undef, ptr %a, 0 + %64 = insertvalue %"any*" %63, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 + %65 = getelementptr inbounds [1 x %"any*"], ptr %varargslots12, i64 0, i64 0 + store %"any*" %64, ptr %65, align 16 %66 = call i64 @std.io.printfn(ptr %retparam11, ptr @.str.5, i64 2, ptr %varargslots12, i64 1) %67 = getelementptr inbounds [6 x i32], ptr %y, i64 0, i64 2 %68 = insertvalue %"int[]" undef, ptr %67, 0 @@ -139,10 +139,10 @@ entry: %71 = extractvalue %"int[][]" %70, 0 %ptroffset13 = getelementptr inbounds %"int[]", ptr %71, i64 0 store %"int[]" %69, ptr %ptroffset13, align 8 - %72 = insertvalue %any undef, ptr %a, 0 - %73 = insertvalue %any %72, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 - %74 = getelementptr inbounds [1 x %any], ptr %varargslots15, i64 0, i64 0 - store %any %73, ptr %74, align 16 + %72 = insertvalue %"any*" undef, ptr %a, 0 + %73 = insertvalue %"any*" %72, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 + %74 = getelementptr inbounds [1 x %"any*"], ptr %varargslots15, i64 0, i64 0 + store %"any*" %73, ptr %74, align 16 %75 = call i64 @std.io.printfn(ptr %retparam14, ptr @.str.6, i64 2, ptr %varargslots15, i64 1) ret void } diff --git a/test/test_suite/slices/slice_to_slice_vector_assign.c3t b/test/test_suite/slices/slice_to_slice_vector_assign.c3t index e624d54bd..cded731da 100644 --- a/test/test_suite/slices/slice_to_slice_vector_assign.c3t +++ b/test/test_suite/slices/slice_to_slice_vector_assign.c3t @@ -27,10 +27,10 @@ entry: %y = alloca <6 x i32>, align 32 %taddr = alloca %"int[]", align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 + %varargslots = alloca [2 x %"any*"], align 16 %taddr1 = alloca %"int[]", align 8 %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [2 x %any], align 16 + %varargslots3 = alloca [2 x %"any*"], align 16 %a = alloca %"int[][]", align 8 %literal = alloca [1 x %"int[]"], align 16 %literal4 = alloca [1 x i32], align 4 @@ -38,12 +38,12 @@ entry: %literal5 = alloca [1 x %"int[]"], align 16 %literal6 = alloca [1 x i32], align 4 %retparam7 = alloca i64, align 8 - %varargslots8 = alloca [1 x %any], align 16 + %varargslots8 = alloca [1 x %"any*"], align 16 %taddr10 = alloca %"int[][]", align 8 %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %any], align 16 + %varargslots12 = alloca [1 x %"any*"], align 16 %retparam14 = alloca i64, align 8 - %varargslots15 = alloca [1 x %any], align 16 + %varargslots15 = alloca [1 x %"any*"], align 16 store <7 x i32> , ptr %z, align 32 store <6 x i32> zeroinitializer, ptr %y, align 32 %0 = getelementptr inbounds <7 x i32>, ptr %z, i64 0, i64 3 @@ -59,14 +59,14 @@ entry: %9 = load i64, ptr %8, align 8 %10 = mul i64 %9, 4 call void @llvm.memmove.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 %10, i1 false) - %11 = insertvalue %any undef, ptr %y, 0 - %12 = insertvalue %any %11, i64 ptrtoint (ptr @"$ct.v6$int" to i64), 1 - %13 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %12, ptr %13, align 16 - %14 = insertvalue %any undef, ptr %z, 0 - %15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.v7$int" to i64), 1 - %16 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %15, ptr %16, align 16 + %11 = insertvalue %"any*" undef, ptr %y, 0 + %12 = insertvalue %"any*" %11, i64 ptrtoint (ptr @"$ct.v6$int" to i64), 1 + %13 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %12, ptr %13, align 16 + %14 = insertvalue %"any*" undef, ptr %z, 0 + %15 = insertvalue %"any*" %14, i64 ptrtoint (ptr @"$ct.v7$int" to i64), 1 + %16 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %15, ptr %16, align 16 %17 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 5, ptr %varargslots, i64 2) %18 = getelementptr inbounds <7 x i32>, ptr %z, i64 0, i64 5 %19 = insertvalue %"int[]" undef, ptr %18, 0 @@ -81,14 +81,14 @@ entry: %27 = load i64, ptr %26, align 8 %28 = mul i64 %27, 4 call void @llvm.memmove.p0.p0.i64(ptr align 4 %24, ptr align 4 %25, i64 %28, i1 false) - %29 = insertvalue %any undef, ptr %y, 0 - %30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.v6$int" to i64), 1 - %31 = getelementptr inbounds [2 x %any], ptr %varargslots3, i64 0, i64 0 - store %any %30, ptr %31, align 16 - %32 = insertvalue %any undef, ptr %z, 0 - %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.v7$int" to i64), 1 - %34 = getelementptr inbounds [2 x %any], ptr %varargslots3, i64 0, i64 1 - store %any %33, ptr %34, align 16 + %29 = insertvalue %"any*" undef, ptr %y, 0 + %30 = insertvalue %"any*" %29, i64 ptrtoint (ptr @"$ct.v6$int" to i64), 1 + %31 = getelementptr inbounds [2 x %"any*"], ptr %varargslots3, i64 0, i64 0 + store %"any*" %30, ptr %31, align 16 + %32 = insertvalue %"any*" undef, ptr %z, 0 + %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.v7$int" to i64), 1 + %34 = getelementptr inbounds [2 x %"any*"], ptr %varargslots3, i64 0, i64 1 + store %"any*" %33, ptr %34, align 16 %35 = call i64 @std.io.printfn(ptr %retparam2, ptr @.str.1, i64 5, ptr %varargslots3, i64 2) %36 = getelementptr inbounds [1 x %"int[]"], ptr %literal, i64 0, i64 0 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %literal4, ptr align 4 @.__const, i32 4, i1 false) @@ -106,10 +106,10 @@ entry: %44 = insertvalue %"int[][]" undef, ptr %literal5, 0 %45 = insertvalue %"int[][]" %44, i64 1, 1 store %"int[][]" %45, ptr %b, align 8 - %46 = insertvalue %any undef, ptr %a, 0 - %47 = insertvalue %any %46, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 - %48 = getelementptr inbounds [1 x %any], ptr %varargslots8, i64 0, i64 0 - store %any %47, ptr %48, align 16 + %46 = insertvalue %"any*" undef, ptr %a, 0 + %47 = insertvalue %"any*" %46, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 + %48 = getelementptr inbounds [1 x %"any*"], ptr %varargslots8, i64 0, i64 0 + store %"any*" %47, ptr %48, align 16 %49 = call i64 @std.io.printfn(ptr %retparam7, ptr @.str.3, i64 2, ptr %varargslots8, i64 1) %50 = load %"int[][]", ptr %b, align 8 %51 = extractvalue %"int[][]" %50, 0 @@ -128,10 +128,10 @@ entry: %61 = load i64, ptr %60, align 8 %62 = mul i64 %61, 16 call void @llvm.memmove.p0.p0.i64(ptr align 8 %58, ptr align 8 %59, i64 %62, i1 false) - %63 = insertvalue %any undef, ptr %a, 0 - %64 = insertvalue %any %63, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 - %65 = getelementptr inbounds [1 x %any], ptr %varargslots12, i64 0, i64 0 - store %any %64, ptr %65, align 16 + %63 = insertvalue %"any*" undef, ptr %a, 0 + %64 = insertvalue %"any*" %63, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 + %65 = getelementptr inbounds [1 x %"any*"], ptr %varargslots12, i64 0, i64 0 + store %"any*" %64, ptr %65, align 16 %66 = call i64 @std.io.printfn(ptr %retparam11, ptr @.str.4, i64 2, ptr %varargslots12, i64 1) %67 = getelementptr inbounds <6 x i32>, ptr %y, i64 0, i64 2 %68 = insertvalue %"int[]" undef, ptr %67, 0 @@ -140,10 +140,10 @@ entry: %71 = extractvalue %"int[][]" %70, 0 %ptroffset13 = getelementptr inbounds %"int[]", ptr %71, i64 0 store %"int[]" %69, ptr %ptroffset13, align 8 - %72 = insertvalue %any undef, ptr %a, 0 - %73 = insertvalue %any %72, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 - %74 = getelementptr inbounds [1 x %any], ptr %varargslots15, i64 0, i64 0 - store %any %73, ptr %74, align 16 + %72 = insertvalue %"any*" undef, ptr %a, 0 + %73 = insertvalue %"any*" %72, i64 ptrtoint (ptr @"$ct.sa$sa$int" to i64), 1 + %74 = getelementptr inbounds [1 x %"any*"], ptr %varargslots15, i64 0, i64 0 + store %"any*" %73, ptr %74, align 16 %75 = call i64 @std.io.printfn(ptr %retparam14, ptr @.str.5, i64 2, ptr %varargslots15, i64 1) ret void } diff --git a/test/test_suite/statements/foreach_more_implementations.c3t b/test/test_suite/statements/foreach_more_implementations.c3t index 2f73a8f1d..edf4c4b9e 100644 --- a/test/test_suite/statements/foreach_more_implementations.c3t +++ b/test/test_suite/statements/foreach_more_implementations.c3t @@ -50,14 +50,14 @@ entry: %ref = alloca ptr, align 8 %element = alloca i64, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %.anon3 = alloca i64, align 8 %vector4 = alloca %Vector, align 8 %.anon5 = alloca i64, align 8 %i = alloca i32, align 4 %element9 = alloca i64, align 8 %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %any], align 16 + %varargslots12 = alloca [1 x %"any*"], align 16 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %x, ptr align 4 @.__const, i32 8, i1 false) %0 = getelementptr inbounds %Vector, ptr %v, i32 0, i32 0 store i64 2, ptr %0, align 8 @@ -85,10 +85,10 @@ loop.body: ; preds = %loop.cond %ptroffset = getelementptr inbounds i32, ptr %8, i64 %9 store ptr %ptroffset, ptr %ref, align 8 %10 = load ptr, ptr %ref, align 8 - %11 = insertvalue %any undef, ptr %10, 0 - %12 = insertvalue %any %11, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %13 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %12, ptr %13, align 16 + %11 = insertvalue %"any*" undef, ptr %10, 0 + %12 = insertvalue %"any*" %11, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %13 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %12, ptr %13, align 16 %14 = call i64 @std.io.printf(ptr %retparam, ptr @.str, i64 3, ptr %varargslots, i64 1) %15 = load ptr, ptr %ref, align 8 %16 = load i32, ptr %15, align 4 @@ -122,10 +122,10 @@ loop.body8: ; preds = %loop.cond6 %ptroffset10 = getelementptr inbounds i32, ptr %24, i64 %25 %26 = load i32, ptr %ptroffset10, align 4 store i32 %26, ptr %i, align 4 - %27 = insertvalue %any undef, ptr %i, 0 - %28 = insertvalue %any %27, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %29 = getelementptr inbounds [1 x %any], ptr %varargslots12, i64 0, i64 0 - store %any %28, ptr %29, align 16 + %27 = insertvalue %"any*" undef, ptr %i, 0 + %28 = insertvalue %"any*" %27, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %29 = getelementptr inbounds [1 x %"any*"], ptr %varargslots12, i64 0, i64 0 + store %"any*" %28, ptr %29, align 16 %30 = call i64 @std.io.printf(ptr %retparam11, ptr @.str.1, i64 3, ptr %varargslots12, i64 1) %31 = load i64, ptr %.anon5, align 8 %add13 = add i64 %31, 1 diff --git a/test/test_suite/stdlib/map.c3t b/test/test_suite/stdlib/map.c3t index ac3cfef48..2da09fbee 100644 --- a/test/test_suite/stdlib/map.c3t +++ b/test/test_suite/stdlib/map.c3t @@ -9,7 +9,7 @@ struct Foo { int x; void* bar; } def IntFooMap = HashMap(); def IntDoubleMap = HashMap(); -fn String Foo.to_string(Foo* foo, Allocator* allocator = mem::heap()) @dynamic +fn String Foo.to_string(Foo* foo, Allocator* allocator = mem::heap()) : Printable { DString s = dstring::new_with_capacity(128, allocator); s.printf("{%s, %p}", foo.x, foo.bar); @@ -58,20 +58,20 @@ define { ptr, i64 } @test.Foo.to_string(ptr %0, ptr %1) #0 { entry: %s = alloca ptr, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %any], align 16 + %varargslots = alloca [2 x %"any*"], align 16 %result = alloca %"char[]", align 8 %2 = call ptr @std.core.dstring.new_with_capacity(i64 128, ptr %1) store ptr %2, ptr %s, align 8 %3 = getelementptr inbounds %Foo, ptr %0, i32 0, i32 0 - %4 = insertvalue %any undef, ptr %3, 0 - %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %6 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 0 - store %any %5, ptr %6, align 16 + %4 = insertvalue %"any*" undef, ptr %3, 0 + %5 = insertvalue %"any*" %4, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %6 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %5, ptr %6, align 16 %7 = getelementptr inbounds %Foo, ptr %0, i32 0, i32 1 - %8 = insertvalue %any undef, ptr %7, 0 - %9 = insertvalue %any %8, i64 ptrtoint (ptr @"$ct.p$void" to i64), 1 - %10 = getelementptr inbounds [2 x %any], ptr %varargslots, i64 0, i64 1 - store %any %9, ptr %10, align 16 + %8 = insertvalue %"any*" undef, ptr %7, 0 + %9 = insertvalue %"any*" %8, i64 ptrtoint (ptr @"$ct.p$void" to i64), 1 + %10 = getelementptr inbounds [2 x %"any*"], ptr %varargslots, i64 0, i64 1 + store %"any*" %9, ptr %10, align 16 %11 = call i64 @std.core.dstring.DString.printf(ptr %retparam, ptr %s, ptr @.str.14, i64 8, ptr %varargslots, i64 2) %12 = load ptr, ptr %s, align 8 %13 = call { ptr, i64 } @std.core.dstring.DString.str_view(ptr %12) @@ -85,44 +85,44 @@ define void @test.main() #0 { entry: %map = alloca %HashMap, align 8 %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %any], align 16 + %varargslots = alloca [1 x %"any*"], align 16 %literal = alloca %Foo, align 8 %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [1 x %any], align 16 + %varargslots2 = alloca [1 x %"any*"], align 16 %literal3 = alloca %Foo, align 8 %retparam6 = alloca i64, align 8 - %varargslots7 = alloca [1 x %any], align 16 + %varargslots7 = alloca [1 x %"any*"], align 16 %retparam8 = alloca i64, align 8 - %varargslots9 = alloca [1 x %any], align 16 + %varargslots9 = alloca [1 x %"any*"], align 16 %retparam10 = alloca %Foo, align 8 %retparam13 = alloca i64, align 8 - %varargslots14 = alloca [1 x %any], align 16 + %varargslots14 = alloca [1 x %"any*"], align 16 %taddr = alloca i8, align 1 %retparam17 = alloca i64, align 8 - %varargslots18 = alloca [1 x %any], align 16 + %varargslots18 = alloca [1 x %"any*"], align 16 %taddr19 = alloca i8, align 1 %literal22 = alloca %Foo, align 8 %retparam25 = alloca i64, align 8 - %varargslots26 = alloca [1 x %any], align 16 + %varargslots26 = alloca [1 x %"any*"], align 16 %result = alloca %"Foo[]", align 8 %map2 = alloca %HashMap.0, align 8 %retparam29 = alloca i64, align 8 - %varargslots30 = alloca [1 x %any], align 16 + %varargslots30 = alloca [1 x %"any*"], align 16 %taddr31 = alloca i8, align 1 %retparam34 = alloca i64, align 8 - %varargslots35 = alloca [1 x %any], align 16 + %varargslots35 = alloca [1 x %"any*"], align 16 %taddr36 = alloca i8, align 1 %retparam39 = alloca i64, align 8 - %varargslots40 = alloca [1 x %any], align 16 + %varargslots40 = alloca [1 x %"any*"], align 16 %result41 = alloca %"int[]", align 8 %retparam44 = alloca i64, align 8 - %varargslots45 = alloca [1 x %any], align 16 + %varargslots45 = alloca [1 x %"any*"], align 16 %result46 = alloca %"double[]", align 8 %current = alloca ptr, align 8 %mark = alloca i64, align 8 %map3 = alloca %HashMap.0, align 8 %retparam49 = alloca i64, align 8 - %varargslots50 = alloca [1 x %any], align 16 + %varargslots50 = alloca [1 x %"any*"], align 16 %result51 = alloca %"int[]", align 8 %mark54 = alloca i64, align 8 %retparam55 = alloca ptr, align 8 @@ -130,10 +130,10 @@ entry: %0 = load ptr, ptr @std.core.mem.thread_allocator, align 8 call void @"std.collections.map$int$test.Foo$.HashMap.init"(ptr %map, i32 16, float 7.500000e-01, ptr %0) %1 = getelementptr inbounds %HashMap, ptr %map, i32 0, i32 2 - %2 = insertvalue %any undef, ptr %1, 0 - %3 = insertvalue %any %2, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %4 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %3, ptr %4, align 16 + %2 = insertvalue %"any*" undef, ptr %1, 0 + %3 = insertvalue %"any*" %2, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %4 = getelementptr inbounds [1 x %"any*"], ptr %varargslots, i64 0, i64 0 + store %"any*" %3, ptr %4, align 16 %5 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 12, ptr %varargslots, i64 1) call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal, ptr align 8 @.__const, i32 16, i1 false) %6 = getelementptr inbounds { i64, ptr }, ptr %literal, i32 0, i32 0 @@ -142,10 +142,10 @@ entry: %hi = load ptr, ptr %7, align 8 %8 = call i8 @"std.collections.map$int$test.Foo$.HashMap.set"(ptr %map, i32 1, i64 %lo, ptr %hi) %9 = getelementptr inbounds %HashMap, ptr %map, i32 0, i32 2 - %10 = insertvalue %any undef, ptr %9, 0 - %11 = insertvalue %any %10, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %12 = getelementptr inbounds [1 x %any], ptr %varargslots2, i64 0, i64 0 - store %any %11, ptr %12, align 16 + %10 = insertvalue %"any*" undef, ptr %9, 0 + %11 = insertvalue %"any*" %10, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %12 = getelementptr inbounds [1 x %"any*"], ptr %varargslots2, i64 0, i64 0 + store %"any*" %11, ptr %12, align 16 %13 = call i64 @std.io.printfn(ptr %retparam1, ptr @.str.1, i64 12, ptr %varargslots2, i64 1) call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal3, ptr align 8 @.__const.2, i32 16, i1 false) %14 = getelementptr inbounds { i64, ptr }, ptr %literal3, i32 0, i32 0 @@ -154,10 +154,10 @@ entry: %hi5 = load ptr, ptr %15, align 8 %16 = call i8 @"std.collections.map$int$test.Foo$.HashMap.set"(ptr %map, i32 1, i64 %lo4, ptr %hi5) %17 = getelementptr inbounds %HashMap, ptr %map, i32 0, i32 2 - %18 = insertvalue %any undef, ptr %17, 0 - %19 = insertvalue %any %18, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 - %20 = getelementptr inbounds [1 x %any], ptr %varargslots7, i64 0, i64 0 - store %any %19, ptr %20, align 16 + %18 = insertvalue %"any*" undef, ptr %17, 0 + %19 = insertvalue %"any*" %18, i64 ptrtoint (ptr @"$ct.uint" to i64), 1 + %20 = getelementptr inbounds [1 x %"any*"], ptr %varargslots7, i64 0, i64 0 + store %"any*" %19, ptr %20, align 16 %21 = call i64 @std.io.printfn(ptr %retparam6, ptr @.str.3, i64 12, ptr %varargslots7, i64 1) %22 = call i64 @"std.collections.map$int$test.Foo$.HashMap.get"(ptr %retparam10, ptr %map, i32 1) %not_err = icmp eq i64 %22, 0 @@ -166,10 +166,10 @@ entry: after_check: ; preds = %entry %24 = getelementptr inbounds %Foo, ptr %retparam10, i32 0, i32 0 - %25 = insertvalue %any undef, ptr %24, 0 - %26 = insertvalue %any %25, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %27 = getelementptr inbounds [1 x %any], ptr %varargslots9, i64 0, i64 0 - store %any %26, ptr %27, align 16 + %25 = insertvalue %"any*" undef, ptr %24, 0 + %26 = insertvalue %"any*" %25, i64 ptrtoint (ptr @"$ct.int" to i64), 1 + %27 = getelementptr inbounds [1 x %"any*"], ptr %varargslots9, i64 0, i64 0 + store %"any*" %26, ptr %27, align 16 %28 = call i64 @std.io.printfn(ptr %retparam8, ptr @.str.4, i64 7, ptr %varargslots9, i64 1) %not_err11 = icmp eq i64 %28, 0 %29 = call i1 @llvm.expect.i1(i1 %not_err11, i1 true) @@ -178,17 +178,17 @@ after_check: ; preds = %entry after_check12: ; preds = %entry, %after_check, %after_check %30 = call i8 @"std.collections.map$int$test.Foo$.HashMap.has_key"(ptr %map, i32 1) store i8 %30, ptr %taddr, align 1 - %31 = insertvalue %any undef, ptr %taddr, 0 - %32 = insertvalue %any %31, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %33 = getelementptr inbounds [1 x %any], ptr %varargslots14, i64 0, i64 0 - store %any %32, ptr %33, align 16 + %31 = insertvalue %"any*" undef, ptr %taddr, 0 + %32 = insertvalue %"any*" %31, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %33 = getelementptr inbounds [1 x %"any*"], ptr %varargslots14, i64 0, i64 0 + store %"any*" %32, ptr %33, align 16 %34 = call i64 @std.io.printfn(ptr %retparam13, ptr @.str.5, i64 9, ptr %varargslots14, i64 1) %35 = call i8 @"std.collections.map$int$test.Foo$.HashMap.has_key"(ptr %map, i32 2) store i8 %35, ptr %taddr19, align 1 - %36 = insertvalue %any undef, ptr %taddr19, 0 - %37 = insertvalue %any %36, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %38 = getelementptr inbounds [1 x %any], ptr %varargslots18, i64 0, i64 0 - store %any %37, ptr %38, align 16 + %36 = insertvalue %"any*" undef, ptr %taddr19, 0 + %37 = insertvalue %"any*" %36, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %38 = getelementptr inbounds [1 x %"any*"], ptr %varargslots18, i64 0, i64 0 + store %"any*" %37, ptr %38, align 16 %39 = call i64 @std.io.printfn(ptr %retparam17, ptr @.str.6, i64 9, ptr %varargslots18, i64 1) call void @llvm.memcpy.p0.p0.i32(ptr align 8 %literal22, ptr align 8 @.__const.7, i32 16, i1 false) %40 = getelementptr inbounds { i64, ptr }, ptr %literal22, i32 0, i32 0 @@ -199,10 +199,10 @@ after_check12: ; preds = %entry, %after_check %43 = load ptr, ptr @std.core.mem.thread_allocator, align 8 %44 = call { ptr, i64 } @"std.collections.map$int$test.Foo$.HashMap.value_list"(ptr %map, ptr %43) store { ptr, i64 } %44, ptr %result, align 8 - %45 = insertvalue %any undef, ptr %result, 0 - %46 = insertvalue %any %45, i64 ptrtoint (ptr @"$ct.sa$test.Foo" to i64), 1 - %47 = getelementptr inbounds [1 x %any], ptr %varargslots26, i64 0, i64 0 - store %any %46, ptr %47, align 16 + %45 = insertvalue %"any*" undef, ptr %result, 0 + %46 = insertvalue %"any*" %45, i64 ptrtoint (ptr @"$ct.sa$test.Foo" to i64), 1 + %47 = getelementptr inbounds [1 x %"any*"], ptr %varargslots26, i64 0, i64 0 + store %"any*" %46, ptr %47, align 16 %48 = call i64 @std.io.printfn(ptr %retparam25, ptr @.str.8, i64 10, ptr %varargslots26, i64 1) call void @llvm.memset.p0.i64(ptr align 8 %map2, i8 0, i64 40, i1 false) %49 = load ptr, ptr @std.core.mem.thread_allocator, align 8 @@ -210,34 +210,34 @@ after_check12: ; preds = %entry, %after_check %50 = call i8 @"std.collections.map$int$double$.HashMap.set"(ptr %map2, i32 4, double 1.300000e+00) %51 = call i8 @"std.collections.map$int$double$.HashMap.has_value"(ptr %map2, double 1.300000e+00) store i8 %51, ptr %taddr31, align 1 - %52 = insertvalue %any undef, ptr %taddr31, 0 - %53 = insertvalue %any %52, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %54 = getelementptr inbounds [1 x %any], ptr %varargslots30, i64 0, i64 0 - store %any %53, ptr %54, align 16 + %52 = insertvalue %"any*" undef, ptr %taddr31, 0 + %53 = insertvalue %"any*" %52, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %54 = getelementptr inbounds [1 x %"any*"], ptr %varargslots30, i64 0, i64 0 + store %"any*" %53, ptr %54, align 16 %55 = call i64 @std.io.printfn(ptr %retparam29, ptr @.str.9, i64 12, ptr %varargslots30, i64 1) %56 = call i8 @"std.collections.map$int$double$.HashMap.has_value"(ptr %map2, double 1.200000e+00) store i8 %56, ptr %taddr36, align 1 - %57 = insertvalue %any undef, ptr %taddr36, 0 - %58 = insertvalue %any %57, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 - %59 = getelementptr inbounds [1 x %any], ptr %varargslots35, i64 0, i64 0 - store %any %58, ptr %59, align 16 + %57 = insertvalue %"any*" undef, ptr %taddr36, 0 + %58 = insertvalue %"any*" %57, i64 ptrtoint (ptr @"$ct.bool" to i64), 1 + %59 = getelementptr inbounds [1 x %"any*"], ptr %varargslots35, i64 0, i64 0 + store %"any*" %58, ptr %59, align 16 %60 = call i64 @std.io.printfn(ptr %retparam34, ptr @.str.10, i64 12, ptr %varargslots35, i64 1) %61 = call i8 @"std.collections.map$int$double$.HashMap.set"(ptr %map2, i32 100, double 3.400000e+00) %62 = load ptr, ptr @std.core.mem.thread_allocator, align 8 %63 = call { ptr, i64 } @"std.collections.map$int$double$.HashMap.key_list"(ptr %map2, ptr %62) store { ptr, i64 } %63, ptr %result41, align 8 - %64 = insertvalue %any undef, ptr %result41, 0 - %65 = insertvalue %any %64, i64 ptrtoint (ptr @"$ct.sa$int" to i64), 1 - %66 = getelementptr inbounds [1 x %any], ptr %varargslots40, i64 0, i64 0 - store %any %65, ptr %66, align 16 + %64 = insertvalue %"any*" undef, ptr %result41, 0 + %65 = insertvalue %"any*" %64, i64 ptrtoint (ptr @"$ct.sa$int" to i64), 1 + %66 = getelementptr inbounds [1 x %"any*"], ptr %varargslots40, i64 0, i64 0 + store %"any*" %65, ptr %66, align 16 %67 = call i64 @std.io.printfn(ptr %retparam39, ptr @.str.11, i64 2, ptr %varargslots40, i64 1) %68 = load ptr, ptr @std.core.mem.thread_allocator, align 8 %69 = call { ptr, i64 } @"std.collections.map$int$double$.HashMap.value_list"(ptr %map2, ptr %68) store { ptr, i64 } %69, ptr %result46, align 8 - %70 = insertvalue %any undef, ptr %result46, 0 - %71 = insertvalue %any %70, i64 ptrtoint (ptr @"$ct.sa$double" to i64), 1 - %72 = getelementptr inbounds [1 x %any], ptr %varargslots45, i64 0, i64 0 - store %any %71, ptr %72, align 16 + %70 = insertvalue %"any*" undef, ptr %result46, 0 + %71 = insertvalue %"any*" %70, i64 ptrtoint (ptr @"$ct.sa$double" to i64), 1 + %72 = getelementptr inbounds [1 x %"any*"], ptr %varargslots45, i64 0, i64 0 + store %"any*" %71, ptr %72, align 16 %73 = call i64 @std.io.printfn(ptr %retparam44, ptr @.str.12, i64 2, ptr %varargslots45, i64 1) %74 = load ptr, ptr @std.core.mem.thread_temp_allocator, align 8 %not = icmp eq ptr %74, null @@ -262,10 +262,10 @@ if.exit: ; preds = %if.then, %after_che %82 = load ptr, ptr @std.core.mem.thread_allocator, align 8 %83 = call { ptr, i64 } @"std.collections.map$int$double$.HashMap.key_list"(ptr %map3, ptr %82) store { ptr, i64 } %83, ptr %result51, align 8 - %84 = insertvalue %any undef, ptr %result51, 0 - %85 = insertvalue %any %84, i64 ptrtoint (ptr @"$ct.sa$int" to i64), 1 - %86 = getelementptr inbounds [1 x %any], ptr %varargslots50, i64 0, i64 0 - store %any %85, ptr %86, align 16 + %84 = insertvalue %"any*" undef, ptr %result51, 0 + %85 = insertvalue %"any*" %84, i64 ptrtoint (ptr @"$ct.sa$int" to i64), 1 + %86 = getelementptr inbounds [1 x %"any*"], ptr %varargslots50, i64 0, i64 0 + store %"any*" %85, ptr %86, align 16 %87 = call i64 @std.io.printfn(ptr %retparam49, ptr @.str.13, i64 2, ptr %varargslots50, i64 1) %88 = load ptr, ptr %current, align 8 %89 = getelementptr inbounds %TempAllocator, ptr %88, i32 0, i32 0 diff --git a/test/unit/regression/any.c3 b/test/unit/regression/any.c3 index 120f05d0a..08e021ebe 100644 --- a/test/unit/regression/any.c3 +++ b/test/unit/regression/any.c3 @@ -3,10 +3,10 @@ module any_tests @test; fn void any_compare() { int x; - any a = &x; - any b = &x; + any* a = &x; + any* b = &x; void* v = &x; - any c = v; + any* c = v; assert(a == b); assert(a == a); assert(a.ptr == c.ptr); @@ -15,7 +15,7 @@ fn void any_compare() assert(!aisc); } -def AnyAlias = any; +def AnyAlias = any*; fn void test_aliasing() { diff --git a/test/unit/regression/liveness_any.c3 b/test/unit/regression/liveness_any.c3 index 4ba5e1a72..d7243bdb8 100644 --- a/test/unit/regression/liveness_any.c3 +++ b/test/unit/regression/liveness_any.c3 @@ -1,7 +1,11 @@ module liveness; -fn void any.tesT(void*) @interface; -fn void Test.tesT(&self) @dynamic +protocol TestProto +{ + fn void tesT(&self); +} + +fn void Test.tesT(&self) : TestProto {} struct Test @@ -11,6 +15,6 @@ struct Test fn void reflect_test() @test { - any b = malloc(Test); + TestProto* b = malloc(Test); b.tesT(); } \ No newline at end of file diff --git a/test/unit/regression/subtype.c3 b/test/unit/regression/subtype.c3 index a73c1ac17..1a95935c3 100644 --- a/test/unit/regression/subtype.c3 +++ b/test/unit/regression/subtype.c3 @@ -17,7 +17,7 @@ fn void switch_subtyping() { Foo f = {}; f.z = 123; - any x = &f; + any* x = &f; switch (x) { case int: diff --git a/test/unit/stdlib/core/builtintests.c3 b/test/unit/stdlib/core/builtintests.c3 index 7e7e24a90..618b284d8 100644 --- a/test/unit/stdlib/core/builtintests.c3 +++ b/test/unit/stdlib/core/builtintests.c3 @@ -3,7 +3,7 @@ module std::core::builtins @test; fn void! test_anycast() { int a; - any b = &a; + any* b = &a; assert(anycast(b, int)! == &a); assert(@catch(anycast(b, double)) == CastResult.TYPE_MISMATCH); }