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

@@ -156,18 +156,18 @@ static inline void llvm_process_parameter_value(GenContext *c, Decl *decl, unsig
LLVMTypeRef lo = llvm_abi_type(c, info->direct_pair.lo);
LLVMTypeRef hi = llvm_abi_type(c, info->direct_pair.hi);
LLVMTypeRef struct_type = llvm_get_twostruct(c, lo, hi);
unsigned decl_alignment = decl_abi_alignment(decl);
AlignSize decl_alignment = decl_abi_alignment(decl);
// Cast to { lo, hi }
LLVMValueRef cast = LLVMBuildBitCast(c->builder, decl->backend_ref, LLVMPointerType(struct_type, 0), "pair");
// Point to the lo value.
LLVMValueRef lo_ptr = LLVMBuildStructGEP2(c->builder, struct_type, cast, 0, "lo");
// Store it in the struct.
unsigned lo_alignment = MIN(llvm_abi_alignment(lo), decl_alignment);
AlignSize lo_alignment = MIN(llvm_abi_alignment(lo), decl_alignment);
llvm_store_aligned(c, lo_ptr, llvm_get_next_param(c, index), lo_alignment);
// Point to the hi value.
LLVMValueRef hi_ptr = LLVMBuildStructGEP2(c->builder, struct_type, cast, 1, "hi");
// Store it in the struct.
unsigned hi_alignment = MIN(llvm_abi_alignment(hi), decl_alignment);
AlignSize hi_alignment = MIN(llvm_abi_alignment(hi), decl_alignment);
llvm_store_aligned(c, hi_ptr, llvm_get_next_param(c, index), decl_alignment);
return;
}
@@ -181,7 +181,7 @@ static inline void llvm_process_parameter_value(GenContext *c, Decl *decl, unsig
}
// Cast to the coerce type.
LLVMValueRef cast = LLVMBuildBitCast(c->builder, decl->backend_ref, LLVMPointerType(coerce_type, 0), "coerce");
unsigned decl_alignment = decl_abi_alignment(decl);
AlignSize decl_alignment = decl_abi_alignment(decl);
// If we're not flattening, we simply do a store.
if (!abi_info_should_flatten(info))
@@ -302,7 +302,7 @@ void llvm_emit_return_abi(GenContext *c, BEValue *return_value, BEValue *failabl
LLVMTypeRef lo_type = llvm_abi_type(c, info->coerce_expand.hi);
lo_val = llvm_emit_load_aligned(c, lo_type, lo, alignment, "");
// We're done if there's a single element.
// We're done if there's a single field.
if (!info->coerce_expand.hi)
{
llvm_emit_return_value(c, lo_val);