Optimized and improved aggregate initialization. Compound literal updated to Foo({ 1, 2 })-style. ".name = x" style initialization for named arguments and designated initializers. Added runtime messages on panics. subarrays convert implictly to pointers. len/len() functions. Fix taking slice of pointer. Vararg fixes

Consistent length typedef.

First stab at initializers.

Change compound literal to Foo({ 1, 2 }) style.

Fixed up some tests.

Optimize the zero struct codegen.

Optimize union empty initializer.

Fix issues with unions. Added alignment to globals. Added some union tests.

Use puts to emit error messages during runtime. Fixup of int[] -> int* style conversions.

Fix implicit conversion of int[3]* -> int*

Fix int[] size. Use () to invoke the length of a subarray. Fix taking a slice of a pointer. Limit the number of members in a struct.

Fixes to vararg using debug and cleanups to slices.
This commit is contained in:
Christoffer Lerno
2020-12-09 00:41:23 +01:00
parent 6a5a0f2b94
commit 4da36dfed9
44 changed files with 1854 additions and 650 deletions

View File

@@ -50,7 +50,7 @@ func void tester()
p.uu.e = 8;
Point *p2 = &p;
p2.bb.b = 3;
p = { a = 1, bb.b = 3, e = 2 };
p = { .a = 1, .bb.b = 3, .e = 2 };
Point* pp = &p;
pp.a = 20;
@@ -82,6 +82,6 @@ struct Struct
func void myfunc()
{
Struct s;
s.b = 10; // #error: There is no element or method 'Struct.b'
s.b = 10; // #error: There is no field or method 'Struct.b'
}

View File

@@ -20,5 +20,5 @@ func void test1()
entry:
%p = alloca %test.Point, align 4
%0 = bitcast %test.Point* %p to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%test.Point* @0 to i8*), i32 8, i1 false)
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 8 bitcast (%test.Point* @0 to i8*), i32 8, i1 false)

View File

@@ -0,0 +1,39 @@
struct StructA
{
int a;
}
struct StructB
{
struct b
{
int a;
}
}
func void test()
{
StructA a = {};
StructA a2;
StructB b = {};
StructB b2;
StructB b3 = { .b = { } };
}
// #expect: struct_codegen_empty.ll
%a = alloca %struct_codegen_empty.StructA, align 4
%a2 = alloca %struct_codegen_empty.StructA, align 4
%b = alloca %struct_codegen_empty.StructB, align 4
%b2 = alloca %struct_codegen_empty.StructB, align 4
%b3 = alloca %struct_codegen_empty.StructB, align 4
%0 = bitcast %struct_codegen_empty.StructA* %a to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 4, i1 false)
%1 = bitcast %struct_codegen_empty.StructA* %a2 to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %1, i8 0, i64 4, i1 false)
%2 = bitcast %struct_codegen_empty.StructB* %b to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %2, i8 0, i64 4, i1 false)
%3 = bitcast %struct_codegen_empty.StructB* %b2 to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %3, i8 0, i64 4, i1 false)
%4 = bitcast %struct_codegen_empty.StructB* %b3 to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %4, i8 0, i64 4, i1 false)