mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
679 lines
21 KiB
C
679 lines
21 KiB
C
// #target: macos-x64
|
|
|
|
module test;
|
|
import test2;
|
|
import std::array::list;
|
|
import std::array::linkedlist;
|
|
import hello_world;
|
|
|
|
|
|
extern fn int printf(char *, ...);
|
|
|
|
fn void helloWorld()
|
|
{
|
|
printf("helloWorld!\n");
|
|
}
|
|
fn int test_static()
|
|
{
|
|
static int x = 1;
|
|
x++;
|
|
printf("Test static %d\n", x);
|
|
return x;
|
|
}
|
|
|
|
struct Bobo { short b; float c; short d; short e; float f; short g; }
|
|
|
|
|
|
struct Blob { int z; int f; }
|
|
|
|
union Foor
|
|
{
|
|
long a;
|
|
char[12] b;
|
|
}
|
|
|
|
|
|
fn int helo(double d, Bobo b)
|
|
{
|
|
int[3] de = { 1, 2, 3 };
|
|
Bobo c = b;
|
|
helo(1.0, c);
|
|
return 1;
|
|
}
|
|
|
|
|
|
fn int test1(int a, int b)
|
|
{
|
|
a = a >> b;
|
|
if (b > 128) return -1;
|
|
return a;
|
|
}
|
|
|
|
struct Foo2
|
|
{
|
|
int x;
|
|
}
|
|
|
|
fn void Foo2.printme(Foo2 *foo)
|
|
{
|
|
printf("Foo is: %d\n", foo.x);
|
|
}
|
|
|
|
fn int Foo2.mutate(Foo2 *foo)
|
|
{
|
|
printf("Mutating");
|
|
return ++foo.x;
|
|
}
|
|
|
|
define oopsInt = test2::argh<int>;
|
|
define oopsDouble = test2::argh<int>;
|
|
define Argh = fn int(double, Bobo);
|
|
define Argh2 = fn int(double, Bobo);
|
|
|
|
|
|
|
|
fn int sum_us(int... x)
|
|
{
|
|
int sum = 0;
|
|
if (x.len == 0) return 0;
|
|
sum += x[0] + sum_us(...x[1..^1]);
|
|
return sum;
|
|
}
|
|
|
|
define Frob = long;
|
|
|
|
fn int sumd(int[] x)
|
|
{
|
|
int sum = 0;
|
|
for (int i = 0; i < x.len; i++) sum += x[i];
|
|
return sum;
|
|
}
|
|
|
|
struct Foo
|
|
{
|
|
int a;
|
|
int b;
|
|
}
|
|
|
|
define getValueInt = test2::getValue<int>;
|
|
define getValueDouble = test2::getValue<double>;
|
|
define IntBlob = test2::Blob<int>;
|
|
define DoubleBlob = Blob<double>;
|
|
define getMultInt = test2::getMult<int>;
|
|
define getMultDouble = test2::getMult<double>;
|
|
|
|
define IntArray = List<int>;
|
|
define IntList = LinkedList<int>;
|
|
|
|
enum MyEnum : int
|
|
{
|
|
HELO,
|
|
WORLD,
|
|
BYE
|
|
}
|
|
|
|
|
|
fn void main()
|
|
{
|
|
test_static();
|
|
test_static();
|
|
test_static();
|
|
hello_world::hello();
|
|
IntList list;
|
|
list.push(10);
|
|
list.push(15);
|
|
list.push(30);
|
|
for (int i = 0; i < (int)(list.len()); i++)
|
|
{
|
|
printf("Element[%d]: %d\n", i, list.get(i));
|
|
}
|
|
list.free();
|
|
|
|
printf("Elements: %d\n", (int)(MyEnum.elements));
|
|
|
|
int elements = MyEnum.elements;
|
|
printf("Hello\n");
|
|
IntArray array;
|
|
array.append(100);
|
|
array.append(200);
|
|
array.append(400);
|
|
array.push(600);
|
|
array.insert_at(2, 300);
|
|
for (int i = 0; i < (int)(array.len()); i++)
|
|
{
|
|
printf("Element[%d]: %d\n", i, array.get(i));
|
|
}
|
|
array.free();
|
|
IntBlob a = { 42 };
|
|
DoubleBlob b = { 33.3 };
|
|
printf("a was %d\n", getValueInt(a));
|
|
printf("b was %f\n", getValueDouble(b));
|
|
printf("Mult int was %d\n", getMultInt(25));
|
|
printf("Mult double was %f\n", getMultDouble(3.3));
|
|
|
|
|
|
helloWorld();
|
|
Foo ddx;
|
|
int fro = 3;
|
|
int[4] x = { 1, 2, 3, 3 };
|
|
fro += printf("1Vararg4splatA: %d\n", sum_us(...x));
|
|
printf("%d\n", fro);
|
|
int[] z = &x;
|
|
int[3] de = { 1, 2, 3 };
|
|
printf("Vararg4splatB: %d\n", sum_us(...&x));
|
|
printf("Vararg4splatC: %d\n", sum_us(...z));
|
|
printf("Vararg4: %d\n", sum_us(1, 2, 4, 5));
|
|
printf("Vararg1: %d\n", sum_us(1));
|
|
printf("Vararg0: %d\n", sum_us());
|
|
Argh a1;
|
|
Argh2 b2;
|
|
}
|
|
|
|
module hello_world;
|
|
import foo;
|
|
|
|
extern fn int printf(char *, ...);
|
|
define doubleMult = foo::check<double>;
|
|
|
|
fn void hello()
|
|
{
|
|
printf("Hello baby\n");
|
|
printf("Mult %f\n", doubleMult(11.1));
|
|
}
|
|
|
|
module foo <Type>;
|
|
|
|
fn Type check(Type i)
|
|
{
|
|
return i * i;
|
|
}
|
|
|
|
module test2 <Type>;
|
|
|
|
struct Blob
|
|
{
|
|
Type a;
|
|
}
|
|
|
|
fn Type getMult(Type a)
|
|
{
|
|
return a * a;
|
|
}
|
|
Type argh = 234;
|
|
|
|
fault MyErr
|
|
{
|
|
X,
|
|
Y
|
|
}
|
|
|
|
enum Hello : int
|
|
{
|
|
FOO,
|
|
BAR,
|
|
}
|
|
|
|
macro Hello wut()
|
|
{
|
|
return Hello.FOO;
|
|
}
|
|
|
|
define Bye = Hello;
|
|
define wat = wut;
|
|
define byebye = hello;
|
|
|
|
fn int hello()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
fn Type getValue(Blob blob)
|
|
{
|
|
return blob.a;
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
%Blob = type { i32 }
|
|
%Blob.0 = type { double }
|
|
%Foo2 = type { i32 }
|
|
%Bobo = type { i16, float, i16, i16, float, i16 }
|
|
%"int[]" = type { ptr, i64 }
|
|
%LinkedList = type { i64, ptr, ptr }
|
|
%List = type { i64, i64, ptr }
|
|
%Foo = type { i32, i32 }
|
|
|
|
@"ct$test_Bobo" = linkonce constant %.introspect { i8 10, i64 20, i64 0, i64 6, [0 x i64] zeroinitializer }, align 8
|
|
@"ct$test_Blob" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
|
|
@"ct$test_Foor" = linkonce constant %.introspect { i8 11, i64 16, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
|
|
@"ct$test_Foo2" = linkonce constant %.introspect { i8 10, i64 4, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8
|
|
@"ct$test_Foo" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
|
|
@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8
|
|
@"ct$test_MyEnum" = linkonce constant { i8, i64, i64, i64, [3 x %"char[]"] } { i8 8, i64 4, i64 ptrtoint (ptr @"ct$int" to i64), i64 3, [3 x %"char[]"] [%"char[]" { ptr @.enum.0, i64 4 }, %"char[]" { ptr @.enum.1, i64 5 }, %"char[]" { ptr @.enum.2, i64 3 }] }, align 8
|
|
@"test_static$x" = internal unnamed_addr global i32 1, align 4
|
|
|
|
define void @test_Foo2_printme(ptr %0) #0 {
|
|
entry:
|
|
%1 = getelementptr inbounds %Foo2, ptr %0, i32 0, i32 0
|
|
%2 = load i32, ptr %1, align 8
|
|
%3 = call i32 (ptr, ...) @printf(ptr @.str.21, i32 %2)
|
|
ret void
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i32 @test_Foo2_mutate(ptr %0) #0 {
|
|
entry:
|
|
%1 = call i32 (ptr, ...) @printf(ptr @.str.22)
|
|
%2 = getelementptr inbounds %Foo2, ptr %0, i32 0, i32 0
|
|
%3 = load i32, ptr %2, align 8
|
|
%add = add i32 %3, 1
|
|
store i32 %add, ptr %2, align 8
|
|
ret i32 %add
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
declare i32 @printf(ptr, ...) #0
|
|
|
|
; Function Attrs: nounwind
|
|
define void @test_helloWorld() #0 {
|
|
entry:
|
|
%0 = call i32 (ptr, ...) @printf(ptr @.str)
|
|
ret void
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i32 @test_test_static() #0 {
|
|
entry:
|
|
%0 = load i32, ptr @"test_static$x", align 4
|
|
%add = add i32 %0, 1
|
|
store i32 %add, ptr @"test_static$x", align 4
|
|
%1 = load i32, ptr @"test_static$x", align 4
|
|
%2 = call i32 (ptr, ...) @printf(ptr @.str.1, i32 %1)
|
|
%3 = load i32, ptr @"test_static$x", align 4
|
|
ret i32 %3
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i32 @test_helo(double %0, ptr byval(%Bobo) align 8 %1) #0 {
|
|
entry:
|
|
%b = alloca %Bobo, align 4
|
|
%de = alloca [3 x i32], align 4
|
|
%c = alloca %Bobo, align 4
|
|
%indirectarg = alloca %Bobo, align 8
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %b, ptr align 8 %1, i32 20, i1 false)
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %de, ptr align 4 @.__const, i32 12, i1 false)
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %c, ptr align 4 %b, i32 20, i1 false)
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %indirectarg, ptr align 4 %c, i32 20, i1 false)
|
|
%2 = call i32 @test_helo(double 1.000000e+00, ptr byval(%Bobo) align 8 %indirectarg)
|
|
ret i32 1
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i32 @test_test1(i32 %0, i32 %1) #0 {
|
|
entry:
|
|
%a = alloca i32, align 4
|
|
store i32 %0, ptr %a, align 4
|
|
%2 = load i32, ptr %a, align 4
|
|
%ashr = ashr i32 %2, %1
|
|
%3 = freeze i32 %ashr
|
|
store i32 %3, ptr %a, align 4
|
|
%gt = icmp sgt i32 %1, 128
|
|
br i1 %gt, label %if.then, label %if.exit
|
|
|
|
if.then: ; preds = %entry
|
|
ret i32 -1
|
|
|
|
if.exit: ; preds = %entry
|
|
%4 = load i32, ptr %a, align 4
|
|
ret i32 %4
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i32 @test_sum_us(ptr %0, i64 %1) #0 {
|
|
entry:
|
|
%x = alloca %"int[]", align 8
|
|
%sum = alloca i32, align 4
|
|
%vararg = alloca %"int[]", align 8
|
|
%taddr = alloca %"int[]", align 8
|
|
%2 = getelementptr inbounds { ptr, i64 }, ptr %x, i32 0, i32 0
|
|
store ptr %0, ptr %2, align 8
|
|
%3 = getelementptr inbounds { ptr, i64 }, ptr %x, i32 0, i32 1
|
|
store i64 %1, ptr %3, align 8
|
|
store i32 0, ptr %sum, align 4
|
|
%4 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 1
|
|
%5 = load i64, ptr %4, align 8
|
|
%eq = icmp eq i64 0, %5
|
|
br i1 %eq, label %if.then, label %if.exit
|
|
|
|
if.then: ; preds = %entry
|
|
ret i32 0
|
|
|
|
if.exit: ; preds = %entry
|
|
%6 = load i32, ptr %sum, align 4
|
|
%7 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 0
|
|
%8 = load ptr, ptr %7, align 8
|
|
%ptroffset = getelementptr inbounds i32, ptr %8, i64 0
|
|
%9 = load i32, ptr %ptroffset, align 4
|
|
%10 = load %"int[]", ptr %x, align 8
|
|
%11 = extractvalue %"int[]" %10, 0
|
|
%12 = extractvalue %"int[]" %10, 1
|
|
%sub = sub i64 %12, 1
|
|
%13 = add i64 %sub, 1
|
|
%size = sub i64 %13, 1
|
|
%ptroffset1 = getelementptr inbounds i32, ptr %11, i64 1
|
|
%14 = insertvalue %"int[]" undef, ptr %ptroffset1, 0
|
|
%15 = insertvalue %"int[]" %14, i64 %size, 1
|
|
%16 = getelementptr inbounds %"int[]", ptr %vararg, i32 0, i32 1
|
|
%17 = getelementptr inbounds %"int[]", ptr %vararg, i32 0, i32 0
|
|
store %"int[]" %15, ptr %taddr, align 8
|
|
%18 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 0
|
|
%lo = load ptr, ptr %18, align 8
|
|
%19 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 1
|
|
%hi = load i64, ptr %19, align 8
|
|
%20 = call i32 @test_sum_us(ptr %lo, i64 %hi)
|
|
%add = add i32 %9, %20
|
|
%add2 = add i32 %6, %add
|
|
store i32 %add2, ptr %sum, align 4
|
|
%21 = load i32, ptr %sum, align 4
|
|
ret i32 %21
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i32 @test_sumd(ptr %0, i64 %1) #0 {
|
|
entry:
|
|
%x = alloca %"int[]", align 8
|
|
%sum = alloca i32, align 4
|
|
%i = alloca i32, align 4
|
|
%2 = getelementptr inbounds { ptr, i64 }, ptr %x, i32 0, i32 0
|
|
store ptr %0, ptr %2, align 8
|
|
%3 = getelementptr inbounds { ptr, i64 }, ptr %x, i32 0, i32 1
|
|
store i64 %1, ptr %3, align 8
|
|
store i32 0, ptr %sum, align 4
|
|
store i32 0, ptr %i, align 4
|
|
br label %loop.cond
|
|
|
|
loop.cond: ; preds = %loop.body, %entry
|
|
%4 = load i32, ptr %i, align 4
|
|
%sisiext = sext i32 %4 to i64
|
|
%5 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 1
|
|
%6 = load i64, ptr %5, align 8
|
|
%lt = icmp slt i64 %sisiext, %6
|
|
%check = icmp slt i64 %6, 0
|
|
%siui-lt = or i1 %check, %lt
|
|
br i1 %siui-lt, label %loop.body, label %loop.exit
|
|
|
|
loop.body: ; preds = %loop.cond
|
|
%7 = load i32, ptr %sum, align 4
|
|
%8 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 0
|
|
%9 = load ptr, ptr %8, align 8
|
|
%10 = load i32, ptr %i, align 4
|
|
%sisiext1 = sext i32 %10 to i64
|
|
%ptroffset = getelementptr inbounds i32, ptr %9, i64 %sisiext1
|
|
%11 = load i32, ptr %ptroffset, align 4
|
|
%add = add i32 %7, %11
|
|
store i32 %add, ptr %sum, align 4
|
|
%12 = load i32, ptr %i, align 4
|
|
%add2 = add i32 %12, 1
|
|
store i32 %add2, ptr %i, align 4
|
|
br label %loop.cond
|
|
|
|
loop.exit: ; preds = %loop.cond
|
|
%13 = load i32, ptr %sum, align 4
|
|
ret i32 %13
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define void @test_main() #0 {
|
|
entry:
|
|
%list = alloca %LinkedList, align 8
|
|
%i = alloca i32, align 4
|
|
%elements = alloca i32, align 4
|
|
%array = alloca %List, align 8
|
|
%i1 = alloca i32, align 4
|
|
%a = alloca %Blob, align 4
|
|
%b = alloca %Blob.0, align 8
|
|
%tempcoerce = alloca double, align 8
|
|
%ddx = alloca %Foo, align 4
|
|
%fro = alloca i32, align 4
|
|
%x = alloca [4 x i32], align 16
|
|
%vararg = alloca %"int[]", align 8
|
|
%z = alloca %"int[]", align 8
|
|
%de = alloca [3 x i32], align 4
|
|
%vararg10 = alloca %"int[]", align 8
|
|
%vararg13 = alloca %"int[]", align 8
|
|
%vararg16 = alloca %"int[]", align 8
|
|
%varargslots = alloca [4 x i32], align 16
|
|
%vararg19 = alloca %"int[]", align 8
|
|
%varargslots20 = alloca [1 x i32], align 4
|
|
%vararg23 = alloca %"int[]", align 8
|
|
%a1 = alloca ptr, align 8
|
|
%b2 = alloca ptr, align 8
|
|
%0 = call i32 @test_test_static()
|
|
%1 = call i32 @test_test_static()
|
|
%2 = call i32 @test_test_static()
|
|
call void @hello_world_hello()
|
|
call void @llvm.memset.p0.i64(ptr align 8 %list, i8 0, i64 24, i1 false)
|
|
call void @"std_array_linkedlist$$int_LinkedList_push"(ptr %list, i32 10)
|
|
call void @"std_array_linkedlist$$int_LinkedList_push"(ptr %list, i32 15)
|
|
call void @"std_array_linkedlist$$int_LinkedList_push"(ptr %list, i32 30)
|
|
store i32 0, ptr %i, align 4
|
|
br label %loop.cond
|
|
|
|
loop.cond: ; preds = %loop.body, %entry
|
|
%3 = load i32, ptr %i, align 4
|
|
%4 = call i64 @"std_array_linkedlist$$int_LinkedList_len"(ptr %list) #3
|
|
%uisitrunc = trunc i64 %4 to i32
|
|
%lt = icmp slt i32 %3, %uisitrunc
|
|
br i1 %lt, label %loop.body, label %loop.exit
|
|
|
|
loop.body: ; preds = %loop.cond
|
|
%5 = load i32, ptr %i, align 4
|
|
%6 = load i32, ptr %i, align 4
|
|
%siuiext = sext i32 %6 to i64
|
|
%7 = call i32 @"std_array_linkedlist$$int_LinkedList_get"(ptr %list, i64 %siuiext)
|
|
%8 = call i32 (ptr, ...) @printf(ptr @.str.2, i32 %5, i32 %7)
|
|
%9 = load i32, ptr %i, align 4
|
|
%add = add i32 %9, 1
|
|
store i32 %add, ptr %i, align 4
|
|
br label %loop.cond
|
|
|
|
loop.exit: ; preds = %loop.cond
|
|
call void @"std_array_linkedlist$$int_LinkedList_free"(ptr %list)
|
|
%10 = call i32 (ptr, ...) @printf(ptr @.str.3, i32 3)
|
|
store i32 3, ptr %elements, align 4
|
|
%11 = call i32 (ptr, ...) @printf(ptr @.str.4)
|
|
call void @llvm.memset.p0.i64(ptr align 8 %array, i8 0, i64 24, i1 false)
|
|
call void @"std_array_list$$int_List_append"(ptr %array, i32 100)
|
|
call void @"std_array_list$$int_List_append"(ptr %array, i32 200)
|
|
call void @"std_array_list$$int_List_append"(ptr %array, i32 400)
|
|
call void @"std_array_list$$int_List_push"(ptr %array, i32 600) #3
|
|
call void @"std_array_list$$int_List_insert_at"(ptr %array, i64 2, i32 300)
|
|
store i32 0, ptr %i1, align 4
|
|
br label %loop.cond2
|
|
|
|
loop.cond2: ; preds = %loop.body5, %loop.exit
|
|
%12 = load i32, ptr %i1, align 4
|
|
%13 = call i64 @"std_array_list$$int_List_len"(ptr %array)
|
|
%uisitrunc3 = trunc i64 %13 to i32
|
|
%lt4 = icmp slt i32 %12, %uisitrunc3
|
|
br i1 %lt4, label %loop.body5, label %loop.exit8
|
|
|
|
loop.body5: ; preds = %loop.cond2
|
|
%14 = load i32, ptr %i1, align 4
|
|
%15 = load i32, ptr %i1, align 4
|
|
%siuiext6 = sext i32 %15 to i64
|
|
%16 = call i32 @"std_array_list$$int_List_get"(ptr %array, i64 %siuiext6)
|
|
%17 = call i32 (ptr, ...) @printf(ptr @.str.5, i32 %14, i32 %16)
|
|
%18 = load i32, ptr %i1, align 4
|
|
%add7 = add i32 %18, 1
|
|
store i32 %add7, ptr %i1, align 4
|
|
br label %loop.cond2
|
|
|
|
loop.exit8: ; preds = %loop.cond2
|
|
call void @"std_array_list$$int_List_free"(ptr %array)
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a, ptr align 4 @.__const.6, i32 4, i1 false)
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %b, ptr align 8 @.__const.7, i32 8, i1 false)
|
|
%19 = getelementptr inbounds %Blob, ptr %a, i32 0, i32 0
|
|
%20 = load i32, ptr %19, align 4
|
|
%21 = call i32 @"test2$$int_getValue"(i32 %20)
|
|
%22 = call i32 (ptr, ...) @printf(ptr @.str.8, i32 %21)
|
|
%23 = getelementptr inbounds %Blob.0, ptr %b, i32 0, i32 0
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %tempcoerce, ptr align 8 %23, i32 8, i1 false)
|
|
%24 = load double, ptr %tempcoerce, align 8
|
|
%25 = call double @"test2$$double_getValue"(double %24)
|
|
%26 = call i32 (ptr, ...) @printf(ptr @.str.9, double %25)
|
|
%27 = call i32 @"test2$$int_getMult"(i32 25)
|
|
%28 = call i32 (ptr, ...) @printf(ptr @.str.10, i32 %27)
|
|
%29 = call double @"test2$$double_getMult"(double 3.300000e+00)
|
|
%30 = call i32 (ptr, ...) @printf(ptr @.str.11, double %29)
|
|
call void @test_helloWorld()
|
|
%31 = getelementptr inbounds %Foo, ptr %ddx, i32 0, i32 0
|
|
store i32 0, ptr %31, align 4
|
|
%32 = getelementptr inbounds %Foo, ptr %ddx, i32 0, i32 1
|
|
store i32 0, ptr %32, align 4
|
|
store i32 3, ptr %fro, align 4
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 16 %x, ptr align 16 @.__const.12, i32 16, i1 false)
|
|
%33 = load i32, ptr %fro, align 4
|
|
%34 = getelementptr inbounds %"int[]", ptr %vararg, i32 0, i32 1
|
|
%35 = getelementptr inbounds %"int[]", ptr %vararg, i32 0, i32 0
|
|
store i64 4, ptr %34, align 8
|
|
store ptr %x, ptr %35, align 8
|
|
%36 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 0
|
|
%lo = load ptr, ptr %36, align 8
|
|
%37 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 1
|
|
%hi = load i64, ptr %37, align 8
|
|
%38 = call i32 @test_sum_us(ptr %lo, i64 %hi)
|
|
%39 = call i32 (ptr, ...) @printf(ptr @.str.13, i32 %38)
|
|
%add9 = add i32 %33, %39
|
|
store i32 %add9, ptr %fro, align 4
|
|
%40 = load i32, ptr %fro, align 4
|
|
%41 = call i32 (ptr, ...) @printf(ptr @.str.14, i32 %40)
|
|
%42 = insertvalue %"int[]" undef, ptr %x, 0
|
|
%43 = insertvalue %"int[]" %42, i64 4, 1
|
|
store %"int[]" %43, ptr %z, align 8
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %de, ptr align 4 @.__const.15, i32 12, i1 false)
|
|
%44 = getelementptr inbounds %"int[]", ptr %vararg10, i32 0, i32 1
|
|
%45 = getelementptr inbounds %"int[]", ptr %vararg10, i32 0, i32 0
|
|
store i64 4, ptr %44, align 8
|
|
store ptr %x, ptr %45, align 8
|
|
%46 = getelementptr inbounds { ptr, i64 }, ptr %vararg10, i32 0, i32 0
|
|
%lo11 = load ptr, ptr %46, align 8
|
|
%47 = getelementptr inbounds { ptr, i64 }, ptr %vararg10, i32 0, i32 1
|
|
%hi12 = load i64, ptr %47, align 8
|
|
%48 = call i32 @test_sum_us(ptr %lo11, i64 %hi12)
|
|
%49 = call i32 (ptr, ...) @printf(ptr @.str.16, i32 %48)
|
|
%50 = getelementptr inbounds %"int[]", ptr %vararg13, i32 0, i32 1
|
|
%51 = getelementptr inbounds %"int[]", ptr %vararg13, i32 0, i32 0
|
|
%52 = getelementptr inbounds { ptr, i64 }, ptr %z, i32 0, i32 0
|
|
%lo14 = load ptr, ptr %52, align 8
|
|
%53 = getelementptr inbounds { ptr, i64 }, ptr %z, i32 0, i32 1
|
|
%hi15 = load i64, ptr %53, align 8
|
|
%54 = call i32 @test_sum_us(ptr %lo14, i64 %hi15)
|
|
%55 = call i32 (ptr, ...) @printf(ptr @.str.17, i32 %54)
|
|
%56 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 0
|
|
store i32 1, ptr %56, align 4
|
|
%57 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 1
|
|
store i32 2, ptr %57, align 4
|
|
%58 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 2
|
|
store i32 4, ptr %58, align 4
|
|
%59 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 3
|
|
store i32 5, ptr %59, align 4
|
|
%60 = getelementptr inbounds %"int[]", ptr %vararg16, i32 0, i32 1
|
|
store i64 4, ptr %60, align 8
|
|
%61 = getelementptr inbounds %"int[]", ptr %vararg16, i32 0, i32 0
|
|
store ptr %varargslots, ptr %61, align 8
|
|
%62 = getelementptr inbounds { ptr, i64 }, ptr %vararg16, i32 0, i32 0
|
|
%lo17 = load ptr, ptr %62, align 8
|
|
%63 = getelementptr inbounds { ptr, i64 }, ptr %vararg16, i32 0, i32 1
|
|
%hi18 = load i64, ptr %63, align 8
|
|
%64 = call i32 @test_sum_us(ptr %lo17, i64 %hi18)
|
|
%65 = call i32 (ptr, ...) @printf(ptr @.str.18, i32 %64)
|
|
%66 = getelementptr inbounds [1 x i32], ptr %varargslots20, i64 0, i64 0
|
|
store i32 1, ptr %66, align 4
|
|
%67 = getelementptr inbounds %"int[]", ptr %vararg19, i32 0, i32 1
|
|
store i64 1, ptr %67, align 8
|
|
%68 = getelementptr inbounds %"int[]", ptr %vararg19, i32 0, i32 0
|
|
store ptr %varargslots20, ptr %68, align 8
|
|
%69 = getelementptr inbounds { ptr, i64 }, ptr %vararg19, i32 0, i32 0
|
|
%lo21 = load ptr, ptr %69, align 8
|
|
%70 = getelementptr inbounds { ptr, i64 }, ptr %vararg19, i32 0, i32 1
|
|
%hi22 = load i64, ptr %70, align 8
|
|
%71 = call i32 @test_sum_us(ptr %lo21, i64 %hi22)
|
|
%72 = call i32 (ptr, ...) @printf(ptr @.str.19, i32 %71)
|
|
%73 = getelementptr inbounds %"int[]", ptr %vararg23, i32 0, i32 1
|
|
store i64 0, ptr %73, align 8
|
|
%74 = getelementptr inbounds { ptr, i64 }, ptr %vararg23, i32 0, i32 0
|
|
%lo24 = load ptr, ptr %74, align 8
|
|
%75 = getelementptr inbounds { ptr, i64 }, ptr %vararg23, i32 0, i32 1
|
|
%hi25 = load i64, ptr %75, align 8
|
|
%76 = call i32 @test_sum_us(ptr %lo24, i64 %hi25)
|
|
%77 = call i32 (ptr, ...) @printf(ptr @.str.20, i32 %76)
|
|
store ptr null, ptr %a1, align 8
|
|
store ptr null, ptr %b2, align 8
|
|
ret void
|
|
}
|
|
// #expect: hello_world.ll
|
|
|
|
define void @hello_world_hello()
|
|
entry:
|
|
%0 = call i32 (ptr, ...) @printf(ptr @.str)
|
|
%1 = call double @"foo$$double_check"(double 1.110000e+01)
|
|
%2 = call i32 (ptr, ...) @printf(ptr @.str.1, double %1)
|
|
ret void
|
|
|
|
// #expect: foo.double.ll
|
|
|
|
define double @"foo$$double_check"(double %0)
|
|
entry:
|
|
%fmul = fmul double %0, %0
|
|
ret double %fmul
|
|
|
|
|
|
// #expect: test2.int.ll
|
|
|
|
%Blob = type { i32 }
|
|
@"test2$$int_argh" = local_unnamed_addr global i32 234, align 4
|
|
|
|
define i32 @"test2$$int_getMult"(i32 %0) #0 {
|
|
entry:
|
|
%mul = mul i32 %0, %0
|
|
ret i32 %mul
|
|
}
|
|
|
|
define i32 @"test2$$int_hello"() #0 {
|
|
entry:
|
|
ret i32 1
|
|
}
|
|
|
|
define i32 @"test2$$int_getValue"(i32 %0) #0 {
|
|
entry:
|
|
%blob = alloca %Blob, align 4
|
|
%1 = getelementptr inbounds %Blob, ptr %blob, i32 0, i32 0
|
|
store i32 %0, ptr %1, align 4
|
|
%2 = getelementptr inbounds %Blob, ptr %blob, i32 0, i32 0
|
|
%3 = load i32, ptr %2, align 4
|
|
ret i32 %3
|
|
}
|
|
|
|
// #expect: test2.double.ll
|
|
|
|
%Blob = type { double }
|
|
@"test2$$double_argh" = local_unnamed_addr global double 2.340000e+02, align 8
|
|
|
|
define double @"test2$$double_getMult"(double %0)
|
|
entry:
|
|
%fmul = fmul double %0, %0
|
|
ret double %fmul
|
|
|
|
define i32 @"test2$$double_hello"()
|
|
entry:
|
|
ret i32 1
|
|
|
|
define double @"test2$$double_getValue"(double %0)
|
|
entry:
|
|
%blob = alloca %Blob, align 8
|
|
%1 = getelementptr inbounds %Blob, ptr %blob, i32 0, i32 0
|
|
store double %0, ptr %1, align 8
|
|
%2 = getelementptr inbounds %Blob, ptr %blob, i32 0, i32 0
|
|
%3 = load double, ptr %2, align 8
|
|
ret double %3
|