Files
c3c/test/test_suite/generic/enum_set_test.c3t
Christoffer Lerno 7dcd1618d8 Fixes to header gen.
2024-06-28 11:28:05 +02:00

89 lines
3.5 KiB
Plaintext

// #target: macos-x64
module test;
import std::io;
import std::collections::enumset;
def AbcEnumSet = EnumSet(<Abc>);
enum Abc
{
HELLO,
WORLD
}
fn void main()
{
AbcEnumSet set;
io::printf("Has WORLD: %s\n", set.has(Abc.WORLD));
set.add(Abc.HELLO);
io::printf("Has WORLD: %s\n", set.has(Abc.WORLD));
set.add(Abc.WORLD);
io::printf("Has WORLD: %s\n", set.has(Abc.WORLD));
AbcEnumSet set2;
set2.add_all(set);
io::printf("Has WORLD: %s\n", set2.has(Abc.WORLD));
set.remove_all(set2);
io::printf("Has WORLD: %s\n", set.has(Abc.WORLD));
}
/* #expect: test.ll
define void @test.main() #0 {
entry:
%set = alloca i32, align 4
%varargslots = alloca [1 x %any], align 16
%taddr = alloca i8, align 1
%retparam = alloca i64, align 8
%varargslots1 = alloca [1 x %any], align 16
%taddr2 = alloca i8, align 1
%retparam3 = alloca i64, align 8
%varargslots4 = alloca [1 x %any], align 16
%taddr5 = alloca i8, align 1
%retparam6 = alloca i64, align 8
%set2 = alloca i32, align 4
%varargslots7 = alloca [1 x %any], align 16
%taddr8 = alloca i8, align 1
%retparam9 = alloca i64, align 8
%varargslots10 = alloca [1 x %any], align 16
%taddr11 = alloca i8, align 1
%retparam12 = alloca i64, align 8
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
store %any %2, ptr %varargslots, align 16
%3 = 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)
%4 = call i8 @"std_collections_enumset$test.Abc$.EnumSet.has"(ptr %set, i32 1)
store i8 %4, ptr %taddr2, align 1
%5 = insertvalue %any undef, ptr %taddr2, 0
%6 = insertvalue %any %5, i64 ptrtoint (ptr @"$ct.bool" to i64), 1
store %any %6, ptr %varargslots1, align 16
%7 = call i64 @std.io.printf(ptr %retparam3, ptr @.str.1, i64 14, ptr %varargslots1, i64 1)
call void @"std_collections_enumset$test.Abc$.EnumSet.add"(ptr %set, i32 1)
%8 = call i8 @"std_collections_enumset$test.Abc$.EnumSet.has"(ptr %set, i32 1)
store i8 %8, ptr %taddr5, align 1
%9 = insertvalue %any undef, ptr %taddr5, 0
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.bool" to i64), 1
store %any %10, ptr %varargslots4, align 16
%11 = call i64 @std.io.printf(ptr %retparam6, ptr @.str.2, i64 14, ptr %varargslots4, i64 1)
store i32 0, ptr %set2, align 4
%12 = load i32, ptr %set, align 4
call void @"std_collections_enumset$test.Abc$.EnumSet.add_all"(ptr %set2, i32 %12)
%13 = call i8 @"std_collections_enumset$test.Abc$.EnumSet.has"(ptr %set2, i32 1)
store i8 %13, ptr %taddr8, align 1
%14 = insertvalue %any undef, ptr %taddr8, 0
%15 = insertvalue %any %14, i64 ptrtoint (ptr @"$ct.bool" to i64), 1
store %any %15, ptr %varargslots7, align 16
%16 = call i64 @std.io.printf(ptr %retparam9, ptr @.str.3, i64 14, ptr %varargslots7, i64 1)
%17 = load i32, ptr %set2, align 4
call void @"std_collections_enumset$test.Abc$.EnumSet.remove_all"(ptr %set, i32 %17)
%18 = call i8 @"std_collections_enumset$test.Abc$.EnumSet.has"(ptr %set, i32 1)
store i8 %18, ptr %taddr11, align 1
%19 = insertvalue %any undef, ptr %taddr11, 0
%20 = insertvalue %any %19, i64 ptrtoint (ptr @"$ct.bool" to i64), 1
store %any %20, ptr %varargslots10, align 16
%21 = call i64 @std.io.printf(ptr %retparam12, ptr @.str.4, i64 14, ptr %varargslots10, i64 1)
ret void
}