mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Single code path for kind/inner/len/sizeof on type and typeid. Fix of #493. Bump to 0.2.24. Remove ´func´ deprecated keyword. Unify builtin access. Enum and fault name reflection.
55 lines
2.3 KiB
C
55 lines
2.3 KiB
C
// #target: macos-x64
|
|
module test;
|
|
import libc;
|
|
|
|
enum Foo : uint (int val, char* testme)
|
|
{
|
|
A(123, "Number A"),
|
|
B(333, "Number B"),
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
int x = Foo.A.val;
|
|
Foo f = Foo.B;
|
|
Foo g = Foo.A;
|
|
libc::printf("%d (%s) %d (%s)\n", f.val, f.testme, g.val, g.testme);
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
@.enum.0 = internal constant [2 x i8] c"A\00", align 1
|
|
@.enum.1 = internal constant [2 x i8] c"B\00", align 1
|
|
@"ct$uint" = linkonce constant %.introspect { i8 3, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8
|
|
@"ct$test_Foo" = linkonce constant { i8, i64, i64, i64, [2 x %"char[]"] } { i8 8, i64 4, i64 ptrtoint (%.introspect* @"ct$uint" to i64), i64 2, [2 x %"char[]"] [%"char[]" { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.enum.0, i64 0, i64 0), i64 1 }, %"char[]" { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.enum.1, i64 0, i64 0), i64 1 }] }, align 8
|
|
@"test_Foo$val" = linkonce constant [2 x i32] [i32 123, i32 333], align 4
|
|
@.str = private unnamed_addr constant [9 x i8] c"Number A\00", align 1
|
|
@.str.1 = private unnamed_addr constant [9 x i8] c"Number B\00", align 1
|
|
@"test_Foo$testme" = linkonce constant [2 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0)], align 8
|
|
@.str.2 = private unnamed_addr constant [17 x i8] c"%d (%s) %d (%s)\0A\00", align 1
|
|
|
|
; Function Attrs: nounwind
|
|
define void @test_main() #0 {
|
|
entry:
|
|
%x = alloca i32, align 4
|
|
%f = alloca i32, align 4
|
|
%g = alloca i32, align 4
|
|
store i32 123, i32* %x, align 4
|
|
store i32 1, i32* %f, align 4
|
|
store i32 0, i32* %g, align 4
|
|
%0 = load i32, i32* %f, align 4
|
|
%1 = getelementptr inbounds [2 x i32], [2 x i32]* @"test_Foo$val", i32 0, i32 %0
|
|
%2 = load i32, i32* %1, align 4
|
|
%3 = load i32, i32* %f, align 4
|
|
%4 = getelementptr inbounds [2 x i8*], [2 x i8*]* @"test_Foo$testme", i32 0, i32 %3
|
|
%5 = load i8*, i8** %4, align 8
|
|
%6 = load i32, i32* %g, align 4
|
|
%7 = getelementptr inbounds [2 x i32], [2 x i32]* @"test_Foo$val", i32 0, i32 %6
|
|
%8 = load i32, i32* %7, align 4
|
|
%9 = load i32, i32* %g, align 4
|
|
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* @"test_Foo$testme", i32 0, i32 %9
|
|
%11 = load i8*, i8** %10, align 8
|
|
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i32 0, i32 0), i32 %2, i8* %5, i32 %8, i8* %11)
|
|
ret void
|
|
}
|