diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43af3146e..991a2c247 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -168,7 +168,7 @@ jobs: - name: run compiler tests run: | cd test - python3 src/tester.py ../build/c3c.exe test_suite14/ + python3 src/tester.py ../build/c3c.exe test_suite/ build-linux: runs-on: ubuntu-latest @@ -177,7 +177,7 @@ jobs: fail-fast: false matrix: build_type: [Release, Debug] - llvm_version: [13, 15, 16, 17] + llvm_version: [15, 16, 17] steps: - uses: actions/checkout@v3 @@ -196,9 +196,7 @@ jobs: sudo apt-get update sudo apt-get install -y clang-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}} llvm-${{matrix.llvm_version}}-dev lld-${{matrix.llvm_version}} liblld-${{matrix.llvm_version}}-dev sudo apt-get install -y libmlir-${{matrix.llvm_version}} libmlir-${{matrix.llvm_version}}-dev mlir-${{matrix.llvm_version}}-tools - if [[ "${{matrix.llvm_version}}" > 13 ]]; then - sudo apt-get install -y libpolly-${{matrix.llvm_version}}-dev - fi + sudo apt-get install -y libpolly-${{matrix.llvm_version}}-dev - name: CMake run: | cmake -B build \ @@ -238,11 +236,7 @@ jobs: - name: run compiler tests run: | cd test - if [[ "${{matrix.llvm_version}}" < 15 ]]; then - python3 src/tester.py ../build/c3c test_suite14/ - else - python3 src/tester.py ../build/c3c test_suite/ - fi + python3 src/tester.py ../build/c3c test_suite/ - name: bundle_output if: matrix.llvm_version == env.LLVM_RELEASE_VERSION @@ -268,7 +262,7 @@ jobs: fail-fast: false matrix: build_type: [Release, Debug] - llvm_version: [13, 14, 15] + llvm_version: [15] steps: - uses: actions/checkout@v3 - name: Download LLVM @@ -318,11 +312,7 @@ jobs: - name: run compiler tests run: | cd test - if [[ "${{matrix.llvm_version}}" < 15 ]]; then - python3 src/tester.py ../build/c3c test_suite14/ - else - python3 src/tester.py ../build/c3c test_suite/ - fi + python3 src/tester.py ../build/c3c test_suite/ - name: bundle_output if: matrix.llvm_version == env.LLVM_RELEASE_VERSION diff --git a/CMakeLists.txt b/CMakeLists.txt index d9b43a7d5..a263d53e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ if (NOT WIN32) find_package(CURL) endif() if (NOT C3_LLVM_VERSION STREQUAL "auto") - if (${C3_LLVM_VERSION} VERSION_LESS 13 OR ${C3_LLVM_VERSION} VERSION_GREATER 17) + if (${C3_LLVM_VERSION} VERSION_LESS 15 OR ${C3_LLVM_VERSION} VERSION_GREATER 17) message(FATAL_ERROR "LLVM ${C3_LLVM_VERSION} is not supported!") endif() endif() @@ -68,7 +68,7 @@ endif() if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") if (C3_LLVM_VERSION STREQUAL "auto") - set(C3_LLVM_VERSION "14") + set(C3_LLVM_VERSION "15") endif() FetchContent_Declare( LLVM_Windows @@ -131,12 +131,9 @@ set(LLVM_LINK_COMPONENTS Target TransformUtils WindowsManifest + WindowsDriver ) -if (${LLVM_PACKAGE_VERSION} VERSION_GREATER 14.1) - set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} WindowsDriver) -endif() - llvm_map_components_to_libnames(llvm_libs ${LLVM_LINK_COMPONENTS}) file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/lib) file(COPY ${CMAKE_SOURCE_DIR}/lib DESTINATION ${CMAKE_BINARY_DIR}) @@ -147,21 +144,10 @@ message(STATUS "using find_library") find_library(LLD_COFF NAMES lldCOFF.lib lldCOFF.a liblldCOFF.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) find_library(LLD_COMMON NAMES lldCommon.lib lldCommon.a liblldCommon.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) find_library(LLD_ELF NAMES lldELF.lib lldELF.a liblldELF.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) -if (${LLVM_PACKAGE_VERSION} VERSION_LESS 14) - find_library(LLD_MACHO NAMES lldMachO2.lib lldMachO2.a liblldMachO2.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) -else () - find_library(LLD_MACHO NAMES lldMachO.lib lldMachO.a liblldMachO.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) -endif () +find_library(LLD_MACHO NAMES lldMachO.lib lldMachO.a liblldMachO.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) find_library(LLD_MINGW NAMES lldMinGW.lib lldMinGW.a liblldMinGW.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) find_library(LLD_WASM NAMES lldWasm.lib lldWasm.a liblldWasm.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) -if (${LLVM_PACKAGE_VERSION} VERSION_LESS 14) - find_library(LLD_CORE NAMES lldCore.lib lldCore.a liblldCore.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) - find_library(LLD_DRIVER NAMES lldDriver.lib lldDriver.a liblldDriver.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) - find_library(LLD_READER_WRITER NAMES lldReaderWriter.lib lldReaderWriter.a liblldReaderWriter.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) - find_library(LLD_YAML NAMES lldYAML.lib lldYAML.a liblldYAML.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) -endif () - if (${LLVM_PACKAGE_VERSION} VERSION_GREATER_EQUAL 16) find_library(LLD_LOONG NAMES libLLVMLoongArchCodeGen.lib libLLVMLoongArchAsmParser.lib libLLVMLoongArchCodeGen.a libLLVMLoongArchAsmParser.a PATHS ${LLVM_LIBRARY_DIRS} NO_DEFAULT_PATH) set(lld_libs diff --git a/lib/std/libc/libc.c3 b/lib/std/libc/libc.c3 index dcc0e31f3..6168b8eb8 100644 --- a/lib/std/libc/libc.c3 +++ b/lib/std/libc/libc.c3 @@ -46,7 +46,7 @@ extern fn CULong stroul(char* str, char** endptr, int base); extern fn void abort(); extern fn void atexit(TerminateFunction f); extern fn void exit(int status); -extern fn char* getenv(char* name); +extern fn ZString getenv(char* name); extern fn int system(char* str); extern fn void bsearch(void* key, void *base, usz items, usz size, CompareFunction compare); extern fn void qsort(void* base, usz items, usz size, CompareFunction compare); @@ -348,9 +348,9 @@ const CLOCKS_PER_SEC = 1000000; define Time = long; define Clock = ulong; -extern fn char* asctime(Tm *timeptr); +extern fn ZString asctime(Tm *timeptr); extern fn Clock clock(); -extern fn char* ctime(Time *timer); +extern fn ZString ctime(Time *timer); extern fn double difftime(Time time1, Time time2); extern fn Tm* gmtime(Time *timer); extern fn Tm* localtime(Time *timer); diff --git a/src/compiler/copying.c b/src/compiler/copying.c index 52ba6c392..53d27e69a 100644 --- a/src/compiler/copying.c +++ b/src/compiler/copying.c @@ -294,7 +294,6 @@ Expr *copy_expr(CopyStruct *c, Expr *source_expr) switch (source_expr->expr_kind) { case EXPR_VARIANTSWITCH: - case EXPR_ARGV_TO_SUBARRAY: UNREACHABLE case EXPR_MACRO_BODY_EXPANSION: MACRO_COPY_EXPR_LIST(expr->body_expansion_expr.values); diff --git a/src/compiler/enums.h b/src/compiler/enums.h index b6e2ea5be..c8ba80ac2 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -207,7 +207,6 @@ typedef enum { EXPR_POISONED, EXPR_ACCESS, - EXPR_ARGV_TO_SUBARRAY, EXPR_ASM, EXPR_BINARY, EXPR_BITACCESS, diff --git a/src/compiler/expr.c b/src/compiler/expr.c index 50ab31151..1e50a8fe4 100644 --- a/src/compiler/expr.c +++ b/src/compiler/expr.c @@ -82,7 +82,6 @@ bool expr_may_addr(Expr *expr) return true; case EXPR_TEST_HOOK: return false; - case EXPR_ARGV_TO_SUBARRAY: case EXPR_ASM: case EXPR_BINARY: case EXPR_BITASSIGN: @@ -327,7 +326,6 @@ bool expr_is_constant_eval(Expr *expr, ConstantEvalKind eval_kind) case EXPR_FLATPATH: case EXPR_COMPOUND_LITERAL: case EXPR_POISONED: - case EXPR_ARGV_TO_SUBARRAY: case EXPR_CT_ARG: case EXPR_ASM: case EXPR_SUBSCRIPT_ASSIGN: @@ -670,7 +668,6 @@ bool expr_is_pure(Expr *expr) return true; case EXPR_VASPLAT: return true; - case EXPR_ARGV_TO_SUBARRAY: case EXPR_BITASSIGN: return false; case EXPR_VARIANTSWITCH: diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index dad593ecd..2f0a99c0f 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -93,9 +93,6 @@ LLVMValueRef llvm_emit_is_no_opt(GenContext *c, LLVMValueRef error_value) LLVMValueRef llvm_emit_memclear_size_align(GenContext *c, LLVMValueRef ptr, uint64_t size, AlignSize align) { -#if LLVM_VERSION_MAJOR < 15 - ptr = LLVMBuildBitCast(c->builder, ptr, llvm_get_type(c, type_get_ptr(type_char)), ""); -#endif return LLVMBuildMemSet(c->builder, ptr, llvm_get_zero(c, type_char), llvm_const_int(c, type_usize, size), align); } @@ -469,10 +466,7 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) break; } - if (init_value && LLVMTypeOf(init_value) != llvm_get_type(c, var_type)) - { - decl->backend_ref = global_ref = llvm_emit_bitcast_ptr(c, global_ref, var_type); - } + decl->backend_ref = global_ref; LLVMReplaceAllUsesWith(old, global_ref); LLVMDeleteGlobal(old); @@ -1173,7 +1167,7 @@ INLINE GenContext *llvm_gen_tests(Module** modules, unsigned module_count, LLVMC if (test_count) { LLVMValueRef array_of_names = LLVMConstArray(c->chars_type, names, test_count); - LLVMValueRef array_of_decls = LLVMConstArray(LLVMPointerType(opt_test, 0), decls, test_count); + LLVMValueRef array_of_decls = LLVMConstArray(c->ptr_type, decls, test_count); LLVMTypeRef arr_type = LLVMTypeOf(array_of_names); name_ref = llvm_add_global_raw(c, ".test_names", arr_type, 0); decl_ref = llvm_add_global_raw(c, ".test_decls", LLVMTypeOf(array_of_decls), 0); @@ -1183,13 +1177,11 @@ INLINE GenContext *llvm_gen_tests(Module** modules, unsigned module_count, LLVMC LLVMSetGlobalConstant(decl_ref, 1); LLVMSetInitializer(name_ref, array_of_names); LLVMSetInitializer(decl_ref, array_of_decls); - name_ref = LLVMBuildBitCast(c->builder, name_ref, llvm_get_ptr_type(c, type_chars), ""); - decl_ref = LLVMBuildBitCast(c->builder, decl_ref, llvm_get_ptr_type(c, type_voidptr), ""); } else { - name_ref = LLVMConstNull(llvm_get_ptr_type(c, type_chars)); - decl_ref = LLVMConstNull(llvm_get_ptr_type(c, type_voidptr)); + name_ref = LLVMConstNull(c->ptr_type); + decl_ref = LLVMConstNull(c->ptr_type); } LLVMValueRef count = llvm_const_int(c, type_usize, test_count); Type *chars_array = type_get_subarray(type_chars); diff --git a/src/compiler/llvm_codegen_builtins.c b/src/compiler/llvm_codegen_builtins.c index ab9b544ee..18e1ac9be 100644 --- a/src/compiler/llvm_codegen_builtins.c +++ b/src/compiler/llvm_codegen_builtins.c @@ -132,7 +132,7 @@ INLINE void llvm_emit_stacktrace(GenContext *c, BEValue *result_value, Expr *exp llvm_value_set(result_value, llvm_get_zero(c, type_voidptr), type_voidptr); return; } - llvm_value_set(result_value, llvm_emit_bitcast(c, c->debug.stack_slot, type_voidptr), type_voidptr); + llvm_value_set(result_value, c->debug.stack_slot, type_voidptr); } INLINE void llvm_emit_volatile_store(GenContext *c, BEValue *result_value, Expr *expr) @@ -282,8 +282,6 @@ INLINE void llvm_emit_memcpy_builtin(GenContext *c, unsigned intrinsic, BEValue Expr **args = expr->call_expr.arguments; LLVMValueRef arg_slots[4]; llvm_emit_intrinsic_args(c, args, arg_slots, 4); - arg_slots[0] = llvm_emit_bitcast(c, arg_slots[0], type_voidptr); - arg_slots[1] = llvm_emit_bitcast(c, arg_slots[1], type_voidptr); LLVMTypeRef call_type[3]; call_type[0] = call_type[1] = llvm_get_type(c, type_voidptr); call_type[2] = llvm_get_type(c, type_usize); @@ -302,8 +300,6 @@ INLINE void llvm_emit_memmove_builtin(GenContext *c, BEValue *be_value, Expr *ex Expr **args = expr->call_expr.arguments; LLVMValueRef arg_slots[4]; llvm_emit_intrinsic_args(c, args, arg_slots, 4); - arg_slots[0] = llvm_emit_bitcast(c, arg_slots[0], type_voidptr); - arg_slots[1] = llvm_emit_bitcast(c, arg_slots[1], type_voidptr); LLVMTypeRef call_type[3]; call_type[0] = call_type[1] = llvm_get_type(c, type_voidptr); call_type[2] = llvm_get_type(c, type_usize); @@ -322,7 +318,6 @@ INLINE void llvm_emit_memset_builtin(GenContext *c, unsigned intrinsic, BEValue Expr **args = expr->call_expr.arguments; LLVMValueRef arg_slots[4]; llvm_emit_intrinsic_args(c, args, arg_slots, 4); - arg_slots[0] = llvm_emit_bitcast(c, arg_slots[0], type_voidptr); LLVMTypeRef call_type[2] = { llvm_get_type(c, type_voidptr), llvm_get_type(c, type_usize) }; LLVMValueRef result = llvm_emit_call_intrinsic(c, intrinsic, call_type, 2, arg_slots, 4); assert(args[4]->const_expr.const_kind == CONST_INTEGER); diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 387057a7b..31889dff7 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -14,7 +14,7 @@ static inline LLVMValueRef llvm_emit_expr_to_rvalue(GenContext *c, Expr *expr); static inline LLVMValueRef llvm_emit_exprid_to_rvalue(GenContext *c, ExprId expr_id); static inline LLVMValueRef llvm_update_vector(GenContext *c, LLVMValueRef vector, LLVMValueRef value, MemberIndex index); static inline void gencontext_emit_expression_list_expr(GenContext *context, BEValue *be_value, Expr *expr); -static inline void llvm_emit_argv_to_subarray(GenContext *c, BEValue *value, Expr *expr); + static inline void llvm_emit_bitassign_array(GenContext *c, BEValue *result, BEValue parent, Decl *parent_decl, Decl *member); static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Expr *expr); static inline void llvm_emit_const_initialize_reference(GenContext *c, BEValue *ref, Expr *expr); @@ -48,7 +48,7 @@ static void llvm_emit_initialize_designated(GenContext *c, BEValue *ref, AlignSi static void llvm_emit_macro_body_expansion(GenContext *c, BEValue *value, Expr *body_expr); static void llvm_emit_post_unary_expr(GenContext *context, BEValue *be_value, Expr *expr); static void llvm_emit_unary_expr(GenContext *c, BEValue *value, Expr *expr); -static void llvm_enter_struct_for_coerce(GenContext *c, LLVMValueRef *struct_ptr, LLVMTypeRef *type, ByteSize dest_size); +static LLVMTypeRef llvm_find_inner_struct_type_for_coerce(GenContext *c, LLVMTypeRef struct_type, ByteSize dest_size); static void llvm_expand_type_to_args(GenContext *context, Type *param_type, LLVMValueRef expand_ptr, LLVMValueRef *args, unsigned *arg_count_ref, AlignSize alignment); INLINE LLVMValueRef llvm_emit_bitstruct_value_update(GenContext *c, LLVMValueRef current_val, TypeSize bits, LLVMTypeRef bitstruct_type, Decl *member, LLVMValueRef val); @@ -197,14 +197,14 @@ static LLVMValueRef llvm_emit_coerce_alignment(GenContext *c, BEValue *be_value, // If we are loading something with greater alignment than what we have, we cannot directly memcpy. if (!llvm_value_is_addr(be_value) || be_value->alignment < target_alignment) { - LLVMValueRef cast = llvm_emit_alloca(c, llvm_get_type(c, be_value->type), target_alignment, "coerce"); - LLVMValueRef target = LLVMBuildBitCast(c->builder, cast, LLVMPointerType(coerce_type, 0), ""); + // COERCE UPDATE bitcast removed, check for ways to optimize + LLVMValueRef target = llvm_emit_alloca(c, llvm_get_type(c, be_value->type), target_alignment, "coerce"); llvm_store_to_ptr_aligned(c, target, be_value, target_alignment); *resulting_alignment = target_alignment; return target; } *resulting_alignment = be_value->alignment; - return LLVMBuildBitCast(c->builder, be_value->value, LLVMPointerType(coerce_type, 0), ""); + return be_value->value; } LLVMValueRef llvm_emit_aggregate_two(GenContext *c, Type *type, LLVMValueRef value1, LLVMValueRef value2) @@ -286,30 +286,25 @@ static inline LLVMValueRef llvm_emit_add_int(GenContext *c, Type *type, LLVMValu return LLVMBuildAdd(c->builder, left, right, "add"); } -static void llvm_enter_struct_for_coerce(GenContext *c, LLVMValueRef *struct_ptr, LLVMTypeRef *type, ByteSize dest_size) +static LLVMTypeRef llvm_find_inner_struct_type_for_coerce(GenContext *c, LLVMTypeRef type, ByteSize dest_size) { while (1) { - if (LLVMGetTypeKind(*type) != LLVMStructTypeKind) return; - if (!LLVMCountStructElementTypes(*type)) return; - LLVMTypeRef first_element = LLVMStructGetTypeAtIndex(*type, 0); + if (LLVMGetTypeKind(type) != LLVMStructTypeKind) break; + if (!LLVMCountStructElementTypes(type)) break; + LLVMTypeRef first_element = LLVMStructGetTypeAtIndex(type, 0); ByteSize first_element_size = llvm_store_size(c, first_element); // If the size is smaller than the total size and smaller than the destination size // then we're done. - if (first_element_size < dest_size && first_element_size < llvm_store_size(c, *type)) - { - return; - } + if (first_element_size < dest_size && first_element_size < llvm_store_size(c, type)) break; AlignSize dummy; - LLVMValueRef ref = llvm_emit_struct_gep_raw(c, *struct_ptr, *type, 0, llvm_abi_alignment(c, *type), &dummy); - - *struct_ptr = ref; - *type = first_element; + type = first_element; } + return type; } /** - * General functionality to convert int <-> int ptr <-> int + * General functionality to convert ptr <-> int */ LLVMValueRef llvm_coerce_int_ptr(GenContext *c, LLVMValueRef value, LLVMTypeRef from, LLVMTypeRef to) { @@ -320,12 +315,7 @@ LLVMValueRef llvm_coerce_int_ptr(GenContext *c, LLVMValueRef value, LLVMTypeRef bool to_is_pointer = LLVMGetTypeKind(to) == LLVMPointerTypeKind; if (LLVMGetTypeKind(from) == LLVMPointerTypeKind) { - // 2a. Destination is a pointer, perform a bitcast. - if (to_is_pointer) - { - return LLVMBuildBitCast(c->builder, value, to, "coerce.val"); - } - // 2b. Otherwise perform ptr -> int + assert(!to_is_pointer && "ptr<->ptr should never happen in LLVM 15+"); from = llvm_get_type(c, type_iptr); value = LLVMBuildPtrToInt(c->builder, value, from, ""); } @@ -392,7 +382,7 @@ LLVMValueRef llvm_emit_coerce(GenContext *c, LLVMTypeRef coerced, BEValue *value // 3. If this is a struct, we index into it. if (LLVMGetTypeKind(llvm_source_type) == LLVMStructTypeKind) { - llvm_enter_struct_for_coerce(c, &addr, &llvm_source_type, target_size); + llvm_source_type = llvm_find_inner_struct_type_for_coerce(c, llvm_source_type, target_size); } // --> from now on we only use LLVM types. @@ -410,8 +400,8 @@ LLVMValueRef llvm_emit_coerce(GenContext *c, LLVMTypeRef coerced, BEValue *value if (source_size >= target_size && source_type_kind != LLVMScalableVectorTypeKind && coerced_type_kind != LLVMScalableVectorTypeKind) { - LLVMValueRef val = LLVMBuildBitCast(c->builder, addr, LLVMPointerType(coerced, 0), ""); - return llvm_load(c, coerced, val, value->alignment, ""); + // COERCE UPDATE bitcast removed, check for ways to optimize + return llvm_load(c, coerced, addr, value->alignment, ""); } if (coerced_type_kind == LLVMScalableVectorTypeKind) @@ -442,7 +432,7 @@ void llvm_emit_coerce_store(GenContext *c, LLVMValueRef addr, AlignSize alignmen // 3. Enter into a struct in case the result is a struct. if (LLVMGetTypeKind(target_type) == LLVMStructTypeKind) { - llvm_enter_struct_for_coerce(c, &addr, &target_type, src_size); + target_type = llvm_find_inner_struct_type_for_coerce(c, target_type, src_size); } // 4. If we are going from int/ptr <-> ptr/int @@ -460,8 +450,8 @@ void llvm_emit_coerce_store(GenContext *c, LLVMValueRef addr, AlignSize alignmen ByteSize target_size = llvm_alloc_size(c, target_type); if (src_size <= target_size && coerced_type_kind != LLVMScalableVectorTypeKind && source_type_kind != LLVMScalableVectorTypeKind) { - LLVMValueRef val = LLVMBuildBitCast(c->builder, addr, LLVMPointerType(coerced, 0), ""); - llvm_store_to_ptr_raw_aligned(c, val, value, alignment); + // COERCE UPDATE bitcast removed, check for ways to optimize + llvm_store_to_ptr_raw_aligned(c, addr, value, alignment); return; } @@ -648,7 +638,6 @@ static inline void llvm_emit_pointer_offset(GenContext *c, BEValue *value, Expr { Expr *pointer = exprptr(expr->pointer_offset_expr.ptr); Expr *offset_expr = exprptr(expr->pointer_offset_expr.offset); - LLVMTypeRef pointee_type = llvm_get_pointee_type(c, pointer->type); // Emit the pointer llvm_emit_expr(c, value, pointer); @@ -661,14 +650,11 @@ static inline void llvm_emit_pointer_offset(GenContext *c, BEValue *value, Expr if (expr->pointer_offset_expr.raw_offset) { - LLVMValueRef raw_pointer = llvm_emit_bitcast_ptr(c, value->value, type_char); - LLVMValueRef pointer_offset = llvm_emit_pointer_gep_raw(c, c->byte_type, raw_pointer, offset.value); - value->value = LLVMBuildBitCast(c->builder, pointer_offset, pointee_type, ""); - } - else - { - value->value = llvm_emit_pointer_gep_raw(c, pointee_type, value->value, offset.value); + // COERCE UPDATE bitcast removed, check for ways to optimize + value->value = llvm_emit_pointer_gep_raw(c, c->byte_type, value->value, offset.value); + return; } + value->value = llvm_emit_pointer_gep_raw(c, llvm_get_pointee_type(c, pointer->type), value->value, offset.value); } @@ -1130,7 +1116,7 @@ static void llvm_emit_arr_to_subarray_cast(GenContext *c, BEValue *value, Type * if (size) { llvm_value_rvalue(c, value); - pointer = llvm_emit_bitcast_ptr(c, value->value, array_type); + pointer = value->value; } else { @@ -1207,10 +1193,9 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu case CAST_PTRANY: { llvm_value_rvalue(c, value); - LLVMValueRef pointer = llvm_emit_bitcast(c, value->value, type_voidptr); BEValue typeid; llvm_emit_typeid(c, &typeid, from_type->pointer); - llvm_value_aggregate_two(c, value, to_type, pointer, typeid.value); + llvm_value_aggregate_two(c, value, to_type, value->value, typeid.value); return; } case CAST_BSARRY: @@ -1242,14 +1227,6 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu break; case CAST_ANYPTR: llvm_emit_any_pointer(c, value, value); - if (llvm_value_is_addr(value)) - { - value->value = LLVMBuildBitCast(c->builder, value->value, llvm_get_ptr_type(c, to_type), ""); - } - else - { - value->value = LLVMBuildBitCast(c->builder, value->value, llvm_get_type(c, to_type), ""); - } break; case CAST_XIERR: to_type = type_lowering(to_type); @@ -1277,17 +1254,6 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu break; case CAST_SAPTR: llvm_emit_subarray_pointer(c, value, value); - if (value->type != to_type) - { - if (llvm_value_is_addr(value)) - { - value->value = LLVMBuildPointerCast(c->builder, value->value, llvm_get_ptr_type(c, to_type), "saptr"); - } - else - { - value->value = LLVMBuildPointerCast(c->builder, value->value, llvm_get_ptr_type(c, to_type), "saptr"); - } - } break; case CAST_EREU: // This is a no op. @@ -1388,7 +1354,6 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu break; case CAST_STST: llvm_value_addr(c, value); - value->value = LLVMBuildBitCast(c->builder, value->value, llvm_get_ptr_type(c, to_type), ""); value->type = to_type; return; case CAST_INTENUM: @@ -1523,11 +1488,6 @@ void llvm_emit_initialize_reference_temporary_const(GenContext *c, BEValue *ref, // Ensure we have a reference. llvm_value_addr(c, ref); - if (expected_type != type) - { - global_copy = LLVMBuildBitCast(c->builder, global_copy, LLVMPointerType(expected_type, 0), ""); - } - // Perform the memcpy. llvm_emit_memcpy(c, ref->value, ref->alignment, global_copy, alignment, type_size(expr->type)); } @@ -1720,8 +1680,6 @@ static inline void llvm_emit_initialize_reference_list(GenContext *c, BEValue *r { assert(vec_size(elements) == 1); real_type = type_lowering(real_type->decl->strukt.members[0]->type); - value = LLVMBuildBitCast(c->builder, ref->value, llvm_get_ptr_type(c, real_type), ""); - ref->value = value; ref->type = real_type; } @@ -1829,7 +1787,7 @@ static void llvm_emit_initialize_designated(GenContext *c, BEValue *ref, AlignSi if (ref->type->type_kind == TYPE_UNION) { llvm_value_set_address(&value, - llvm_emit_bitcast_ptr(c, ref->value, type), + ref->value, type, type_min_alignment(offset, decl_alignment)); } @@ -2741,7 +2699,6 @@ static void gencontext_emit_slice(GenContext *c, BEValue *be_value, Expr *expr) // Move pointer AlignSize alignment; start_pointer = llvm_emit_array_gep_raw_index(c, parent.value, llvm_get_type(c, parent.type), start.value, type_abi_alignment(parent.type), &alignment); - start_pointer = llvm_emit_bitcast_ptr(c, start_pointer, parent.type->array.base); break; } case TYPE_SUBARRAY: @@ -4288,7 +4245,6 @@ static void llvm_emit_const_expr(GenContext *c, BEValue *be_value, Expr *expr) LLVMSetGlobalConstant(global_name, 1); LLVMSetInitializer(global_name, llvm_get_bytes(c, expr->const_expr.bytes.ptr, expr->const_expr.bytes.len)); - global_name = llvm_emit_bitcast_ptr(c, global_name, type_char); llvm_value_set_address_abi_aligned(be_value, global_name, type); return; } @@ -4357,12 +4313,10 @@ static void llvm_emit_const_expr(GenContext *c, BEValue *be_value, Expr *expr) LLVMSetInitializer(global_name, string); if (is_array) { - global_name = llvm_emit_bitcast_ptr(c, global_name, type); llvm_value_set_address(be_value, global_name, type, 1); } else { - global_name = llvm_emit_bitcast(c, global_name, type); llvm_value_set(be_value, global_name, type); } return; @@ -4786,7 +4740,7 @@ static void llvm_emit_splatted_variadic_arg(GenContext *c, Expr *expr, Type *var case TYPE_POINTER: // Load the pointer llvm_value_rvalue(c, &value); - llvm_value_aggregate_two(c, subarray, vararg_type, llvm_emit_bitcast_ptr(c, value.value, type->pointer->array.base), llvm_const_int(c, type_usize, type->pointer->array.len)); + llvm_value_aggregate_two(c, subarray, vararg_type, value.value, llvm_const_int(c, type_usize, type->pointer->array.len)); return; case TYPE_SUBARRAY: *subarray = value; @@ -4877,7 +4831,7 @@ static inline void llvm_emit_vararg_parameter(GenContext *c, BEValue *value, Typ &store_alignment); llvm_store_to_ptr_aligned(c, slot, &temp_value, store_alignment); } - llvm_value_aggregate_two(c, value, vararg_type, llvm_emit_bitcast_ptr(c, array_ref, pointee_type), llvm_const_int(c, type_usize, elements)); + llvm_value_aggregate_two(c, value, vararg_type, array_ref, llvm_const_int(c, type_usize, elements)); } @@ -4963,12 +4917,13 @@ void llvm_emit_raw_call(GenContext *c, BEValue *result_value, FunctionPrototype // { lo, hi } set into { pad, lo, pad, hi } -> original type. // 15a. Create memory to hold the return type. - LLVMValueRef ret = llvm_emit_alloca_aligned(c, call_return_type, ""); - llvm_value_set_address_abi_aligned(result_value, ret, call_return_type); + // COERCE UPDATE bitcast removed, check for ways to optimize + LLVMValueRef coerce = llvm_emit_alloca_aligned(c, call_return_type, ""); + llvm_value_set_address_abi_aligned(result_value, coerce, call_return_type); - // 15b. "Convert" this return type pointer in memory to our coerce type which is { pad, lo, pad, hi } + // COERCE UPDATE bitcast removed, check for ways to optimize + // 15b. Construct our coerce type which is { pad, lo, pad, hi } LLVMTypeRef coerce_type = llvm_get_coerce_type(c, ret_info); - LLVMValueRef coerce = LLVMBuildBitCast(c->builder, ret, coerce_type, ""); // 15d. Find the address to the low value AlignSize alignment; @@ -5721,7 +5676,7 @@ static inline void llvm_emit_typeid_info(GenContext *c, BEValue *value, Expr *ex llvm_value_rvalue(c, value); LLVMValueRef kind; - LLVMValueRef ref = LLVMBuildIntToPtr(c->builder, value->value, LLVMPointerType(c->introspect_type, 0), "introspect*"); + LLVMValueRef ref = LLVMBuildIntToPtr(c->builder, value->value, c->ptr_type, "introspect*"); AlignSize align = llvm_abi_alignment(c, c->introspect_type); AlignSize alignment; if (active_target.feature.safe_mode || expr->typeid_info_expr.kind == TYPEID_INFO_KIND) @@ -5798,9 +5753,8 @@ static inline void llvm_emit_typeid_info(GenContext *c, BEValue *value, Expr *ex LLVMValueRef len = llvm_emit_struct_gep_raw(c, ref, c->introspect_type, INTROSPECT_INDEX_LEN, align, &alignment); len = llvm_load(c, c->size_type, len, alignment, "namelen"); LLVMValueRef val = llvm_emit_struct_gep_raw(c, ref, c->introspect_type, INTROSPECT_INDEX_ADDITIONAL, align, &alignment); - LLVMValueRef ptr_to_first = llvm_emit_bitcast_ptr(c, val, type_chars); Type *subarray = type_get_subarray(type_chars); - llvm_value_set(value, llvm_emit_aggregate_two(c, subarray, ptr_to_first, len), subarray); + llvm_value_set(value, llvm_emit_aggregate_two(c, subarray, val, len), subarray); } break; case TYPEID_INFO_LEN: @@ -5914,88 +5868,6 @@ static inline void llvm_emit_variant(GenContext *c, BEValue *value, Expr *expr) llvm_value_set(value, var, type_any); } -static inline void llvm_emit_argv_to_subarray(GenContext *c, BEValue *value, Expr *expr) -{ - EMIT_LOC(c, expr); - BEValue argc_value; - BEValue argv_value; - llvm_value_set_decl(c, &argc_value, expr->argv_expr.argc); - llvm_value_set_decl(c, &argv_value, expr->argv_expr.argv); - llvm_value_rvalue(c, &argc_value); - llvm_value_rvalue(c, &argv_value); - LLVMValueRef argv_ptr = argv_value.value; - LLVMValueRef count = argc_value.value; - Type *arg_array_type = type_chars; - AlignSize alignment = type_alloca_alignment(type_get_array(arg_array_type, 1)); - LLVMTypeRef arg_array_elem_type = llvm_get_type(c, arg_array_type); - LLVMValueRef arg_array = LLVMBuildArrayAlloca(c->builder, arg_array_elem_type, count, "argarray"); - LLVMSetAlignment(arg_array, alignment); - - // Store the addresses. - LLVMTypeRef loop_type = llvm_get_type(c, type_usize); - LLVMTypeRef char_ptr_type = llvm_get_ptr_type(c, type_char); - LLVMValueRef size = llvm_zext_trunc(c, count, loop_type); - llvm_value_aggregate_two(c, value, expr->type, arg_array, size); - - // Check if zero: - BEValue cond; - llvm_value_set(&cond, LLVMBuildICmp(c->builder, LLVMIntEQ, count, llvm_get_zero(c, argc_value.type), ""), type_bool); - LLVMBasicBlockRef exit_block = llvm_basic_block_new(c, "exit_loop"); - LLVMBasicBlockRef pre_loop_block = llvm_basic_block_new(c, "pre_loop"); - - // Jump to exit if zero - llvm_emit_cond_br(c, &cond, exit_block, pre_loop_block); - - // Now we create the pre loop block - llvm_emit_block(c, pre_loop_block); - EMIT_LOC(c, expr); - - LLVMBasicBlockRef body_block = llvm_basic_block_new(c, "body_loop"); - LLVMValueRef zero = llvm_get_zero_raw(loop_type); - - // Jump to the first entry - llvm_emit_br(c, body_block); - llvm_emit_block(c, body_block); - LLVMValueRef index_var = LLVMBuildPhi(c->builder, loop_type, ""); - - // Find the current substring - LLVMValueRef index = LLVMBuildInBoundsGEP2(c->builder, arg_array_elem_type, arg_array, &index_var, 1, "indexfe"); - LLVMValueRef pointer_to_arg = LLVMBuildInBoundsGEP2(c->builder, char_ptr_type, argv_ptr, &index_var, 1, ""); - - // Get the char* to the argument - LLVMValueRef pointer_value = llvm_load(c, llvm_get_ptr_type(c, type_char), pointer_to_arg, - type_abi_alignment(type_get_ptr(type_char)), ""); - AlignSize index_align; - - // Get strlen to calculate length - LLVMValueRef strlen = LLVMGetNamedFunction(c->module, "strlen"); - LLVMTypeRef strlen_type = LLVMFunctionType(loop_type, &char_ptr_type, 1, false); - if (!strlen) - { - strlen = LLVMAddFunction(c->module, "strlen", strlen_type); - } - EMIT_LOC(c, expr); - LLVMValueRef len = LLVMBuildCall2(c->builder, strlen_type, strlen, &pointer_value, 1, ""); - - // We first set the pointer - AlignSize align = type_abi_alignment(arg_array_type); - LLVMValueRef ptr_loc = llvm_emit_struct_gep_raw(c, index, arg_array_elem_type, 0, align, &index_align); - llvm_store_to_ptr_raw_aligned(c, ptr_loc, pointer_value, index_align); - // Then the length - LLVMValueRef len_loc = llvm_emit_struct_gep_raw(c, index, arg_array_elem_type, 1, align, &index_align); - llvm_store_to_ptr_raw_aligned(c, len_loc, len, index_align); - - // Add index - LLVMValueRef index_plus = LLVMBuildNUWAdd(c->builder, index_var, llvm_const_int(c, type_usize, 1), ""); - llvm_value_set(&cond, LLVMBuildICmp(c->builder, LLVMIntULT, index_plus, size, ""), type_bool); - llvm_emit_cond_br(c, &cond, body_block, exit_block); - LLVMValueRef values[2] = { index_plus, zero }; - LLVMBasicBlockRef blocks[2] = { body_block, pre_loop_block }; - LLVMAddIncoming(index_var, values, blocks, 2); - llvm_emit_block(c, exit_block); - EMIT_LOC(c, expr); -} - static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Expr *expr) { Expr *inner = exprptr(expr->builtin_access_expr.inner); @@ -6034,11 +5906,11 @@ static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Ex llvm_emit_br(c, exit_block); llvm_emit_block(c, ok_block); LLVMValueRef fault_data = LLVMBuildIntToPtr(c->builder, be_value->value, - LLVMPointerType(c->fault_type, 0), ""); + c->ptr_type, ""); LLVMValueRef ptr = LLVMBuildStructGEP2(c->builder, c->fault_type, fault_data, 1, ""); llvm_emit_br(c, exit_block); llvm_emit_block(c, exit_block); - LLVMValueRef phi = LLVMBuildPhi(c->builder, llvm_get_ptr_type(c, type_chars), "faultname"); + LLVMValueRef phi = LLVMBuildPhi(c->builder, c->ptr_type, "faultname"); LLVMValueRef values[] = { zero.value, ptr }; LLVMBasicBlockRef blocks[] = { zero_block, ok_block }; LLVMAddIncoming(phi, values, blocks, 2); @@ -6053,11 +5925,10 @@ static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Ex LLVMTypeRef subarray = llvm_get_type(c, type_chars); LLVMValueRef to_introspect = LLVMBuildIntToPtr(c->builder, inner_type->backend_typeid, - LLVMPointerType(c->introspect_type, 0), ""); + c->ptr_type, ""); LLVMValueRef ptr = LLVMBuildStructGEP2(c->builder, c->introspect_type, to_introspect, INTROSPECT_INDEX_ADDITIONAL, ""); - LLVMValueRef ptr_to_first = llvm_emit_bitcast_ptr(c, ptr, type_chars); LLVMValueRef val = llvm_zext_trunc(c, be_value->value, llvm_get_type(c, type_usize)); - llvm_value_set_address(be_value, llvm_emit_pointer_gep_raw(c, subarray, ptr_to_first, val), + llvm_value_set_address(be_value, llvm_emit_pointer_gep_raw(c, subarray, ptr, val), type_chars, llvm_abi_alignment(c, subarray)); return; } @@ -6166,9 +6037,6 @@ void llvm_emit_expr(GenContext *c, BEValue *value, Expr *expr) case EXPR_VARIANT: llvm_emit_variant(c, value, expr); return; - case EXPR_ARGV_TO_SUBARRAY: - llvm_emit_argv_to_subarray(c, value, expr); - return; case EXPR_TRY_UNWRAP_CHAIN: llvm_emit_try_unwrap_chain(c, value, expr); return; diff --git a/src/compiler/llvm_codegen_function.c b/src/compiler/llvm_codegen_function.c index 2ccda5ec0..45041d79c 100644 --- a/src/compiler/llvm_codegen_function.c +++ b/src/compiler/llvm_codegen_function.c @@ -98,8 +98,8 @@ static void llvm_expand_from_args(GenContext *c, Type *type, LLVMValueRef ref, u case TYPE_UNION: { Type *largest_type = type_find_largest_union_element(type); - LLVMValueRef cast_addr = llvm_emit_bitcast_ptr(c, ref, largest_type); - llvm_expand_from_args(c, largest_type, cast_addr, index, alignment); + // COERCE UPDATE bitcast removed, check for ways to optimize + llvm_expand_from_args(c, largest_type, ref, index, alignment); return; } default: @@ -128,7 +128,8 @@ static inline void llvm_process_parameter_value(GenContext *c, Decl *decl, ABIAr { // Create the expand type: LLVMTypeRef coerce_type = llvm_get_coerce_type(c, info); - LLVMValueRef temp = LLVMBuildBitCast(c->builder, decl->backend_ref, LLVMPointerType(coerce_type, 0), "coerce"); + // COERCE UPDATE bitcast removed, check for ways to optimize + LLVMValueRef temp = decl->backend_ref; llvm_emit_and_set_decl_alloca(c, decl); AlignSize alignment = decl->alignment; @@ -144,35 +145,33 @@ static inline void llvm_process_parameter_value(GenContext *c, Decl *decl, ABIAr } case ABI_ARG_DIRECT_PAIR: { + // Create the two abi types. 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); + AlignSize decl_alignment = decl->alignment; - LLVMValueRef coerce; - if (llvm_store_size(c, struct_type) > type_size(decl->type)) - { - AlignSize struct_alignment = llvm_abi_alignment(c, struct_type); - if (decl_alignment < struct_alignment) decl->alignment = decl_alignment = struct_alignment; - coerce = llvm_emit_alloca(c, struct_type, decl_alignment, ""); - decl->backend_ref = LLVMBuildBitCast(c->builder, coerce, llvm_get_ptr_type(c, decl->type), decl->name ? decl->name : ".anon"); - } - else - { - llvm_emit_and_set_decl_alloca(c, decl); - // Here we do the following transform: - // lo, hi -> { lo, hi } -> struct - // Cast to { lo, hi } - coerce = LLVMBuildBitCast(c->builder, decl->backend_ref, LLVMPointerType(struct_type, 0), "pair"); - } - // Point to the lo value. - AlignSize element_align; - LLVMValueRef lo_ptr = llvm_emit_struct_gep_raw(c, coerce, struct_type, 0, decl_alignment, &element_align); - // Store it in the struct. - llvm_store_to_ptr_raw_aligned(c, lo_ptr, llvm_get_next_param(c, index), element_align); - // Point to the hi value. - LLVMValueRef hi_ptr = llvm_emit_struct_gep_raw(c, coerce, struct_type, 1, decl_alignment, &element_align); - // Store it in the struct. - llvm_store_to_ptr_raw_aligned(c, hi_ptr, llvm_get_next_param(c, index), element_align); + AlignSize hi_alignment = llvm_abi_alignment(c, hi); + AlignSize lo_alignment = llvm_abi_alignment(c, lo); + ByteSize hi_aligned_size = aligned_offset(llvm_store_size(c, hi), hi_alignment); + AlignSize pref_align = MAX(hi_alignment, lo_alignment); + + // Realign to best alignment. + if (pref_align > decl_alignment) decl_alignment = decl->alignment = pref_align; + AlignSize hi_offset = aligned_offset(llvm_store_size(c, lo), hi_alignment); + assert(hi_offset + llvm_store_size(c, hi) <= type_size(decl->type)); + + // Emit decl + llvm_emit_and_set_decl_alloca(c, decl); + LLVMValueRef addr = decl->backend_ref; + + // Store it in the lo position. + llvm_store_to_ptr_raw_aligned(c, addr, llvm_get_next_param(c, index), decl_alignment); + + // Calculate the address + addr = llvm_emit_pointer_inbounds_gep_raw(c, hi, addr, llvm_const_int(c, type_usz, hi_offset / hi_aligned_size)); + + // Store it in the hi location + llvm_store_to_ptr_raw_aligned(c, addr, llvm_get_next_param(c, index), type_min_alignment(decl_alignment, hi_offset)); return; } case ABI_ARG_DIRECT: @@ -193,7 +192,8 @@ static inline void llvm_process_parameter_value(GenContext *c, Decl *decl, ABIAr llvm_emit_and_set_decl_alloca(c, decl); // Cast to the coerce type. - LLVMValueRef cast = LLVMBuildBitCast(c->builder, decl->backend_ref, LLVMPointerType(coerce_type, 0), "coerce"); + // COERCE UPDATE bitcast removed, check for ways to optimize + LLVMValueRef cast = decl->backend_ref; AlignSize decl_alignment = decl->alignment; // Store each expanded parameter. @@ -334,7 +334,8 @@ void llvm_emit_return_abi(GenContext *c, BEValue *return_value, BEValue *optiona LLVMTypeRef coerce_type = llvm_get_coerce_type(c, info); // Create the new pointer assert(return_value); - LLVMValueRef coerce = LLVMBuildBitCast(c->builder, return_value->value, coerce_type, ""); + // COERCE UPDATE bitcast removed, check for ways to optimize + LLVMValueRef coerce = return_value->value; // We might have only one value, in that case, build a GEP to that one. LLVMValueRef lo_val; AlignSize alignment; @@ -476,13 +477,12 @@ void llvm_emit_body(GenContext *c, LLVMValueRef function, const char *module_nam if (c->debug.enable_stacktrace) { LLVMTypeRef slot_type = c->debug.stack_type; - LLVMTypeRef ptr_to_slot_type = LLVMPointerType(slot_type, 0); if (!c->debug.last_ptr) { const char *name = ".$last_stack"; - LLVMValueRef last_stack = c->debug.last_ptr = llvm_add_global_raw(c, name, ptr_to_slot_type, 0); + LLVMValueRef last_stack = c->debug.last_ptr = llvm_add_global_raw(c, name, c->ptr_type, 0); LLVMSetThreadLocal(last_stack, true); - LLVMSetInitializer(last_stack, llvm_get_zero_raw(ptr_to_slot_type)); + LLVMSetInitializer(last_stack, llvm_get_zero_raw(c->ptr_type)); llvm_set_weak(c, last_stack); } AlignSize alignment = llvm_abi_alignment(c, slot_type); @@ -491,7 +491,7 @@ void llvm_emit_body(GenContext *c, LLVMValueRef function, const char *module_nam LLVMValueRef prev_ptr = llvm_emit_struct_gep_raw(c, c->debug.stack_slot, slot_type, 0, alignment, &align_to_use); llvm_store_to_ptr_raw_aligned(c, prev_ptr, - LLVMBuildLoad2(c->builder, ptr_to_slot_type, c->debug.last_ptr, ""), + LLVMBuildLoad2(c->builder, c->ptr_type, c->debug.last_ptr, ""), align_to_use); LLVMValueRef func_name = llvm_emit_struct_gep_raw(c, c->debug.stack_slot, slot_type, 1, alignment, &align_to_use); llvm_store_to_ptr_raw_aligned(c, func_name, c->debug.func_name, align_to_use); diff --git a/src/compiler/llvm_codegen_internal.h b/src/compiler/llvm_codegen_internal.h index 577df4ef5..7ab6626a8 100644 --- a/src/compiler/llvm_codegen_internal.h +++ b/src/compiler/llvm_codegen_internal.h @@ -87,6 +87,7 @@ typedef struct GenContext_ LLVMTypeRef fault_type; LLVMTypeRef size_type; LLVMTypeRef char_ptr_type; + LLVMTypeRef ptr_type; LLVMTypeRef chars_type; Decl *panic_var; struct @@ -276,7 +277,7 @@ TypeSize llvm_abi_size(GenContext *c, LLVMTypeRef type); BitSize llvm_bitsize(GenContext *c, LLVMTypeRef type); AlignSize llvm_abi_alignment(GenContext *c, LLVMTypeRef type); LLVMTypeRef llvm_func_type(GenContext *context, FunctionPrototype *prototype); -LLVMTypeRef llvm_update_prototype_abi(GenContext *context, FunctionPrototype *prototype, LLVMTypeRef **params); +LLVMTypeRef llvm_update_prototype_abi(GenContext *c, FunctionPrototype *prototype, LLVMTypeRef **params); LLVMTypeRef llvm_get_twostruct(GenContext *context, LLVMTypeRef lo, LLVMTypeRef hi); LLVMTypeRef llvm_const_padding_type(GenContext *c, TypeSize size); LLVMMetadataRef llvm_get_debug_type(GenContext *c, Type *type); @@ -285,7 +286,6 @@ LLVMTypeRef llvm_get_pointee_type(GenContext *c, Type *any_type); void llvm_emit_function_decl(GenContext *c, Decl *decl); void llvm_emit_xxlizer(GenContext *c, Decl *decl); bool llvm_types_are_similar(LLVMTypeRef original, LLVMTypeRef coerce); -INLINE LLVMTypeRef llvm_get_ptr_type(GenContext *c, Type *type); // -- Attributes --- void llvm_attribute_add_range(GenContext *c, LLVMValueRef value_to_add_attribute_to, unsigned attribute, int index_start, int index_end); @@ -318,9 +318,6 @@ void llvm_emit_and_set_decl_alloca(GenContext *c, Decl *decl); INLINE void llvm_set_alignment(LLVMValueRef alloca, AlignSize alignment); INLINE AlignSize llvm_type_or_alloca_align(LLVMValueRef dest, Type *type); -// -- Bitcast -- -static inline LLVMValueRef llvm_emit_bitcast(GenContext *c, LLVMValueRef value, Type *type); -INLINE LLVMValueRef llvm_emit_bitcast_ptr(GenContext *c, LLVMValueRef value, Type *type); INLINE LLVMValueRef llvm_zext_trunc(GenContext *c, LLVMValueRef data, LLVMTypeRef type); // -- Constants -- diff --git a/src/compiler/llvm_codegen_internal_impl.h b/src/compiler/llvm_codegen_internal_impl.h index a38cf3c6f..472c79a85 100644 --- a/src/compiler/llvm_codegen_internal_impl.h +++ b/src/compiler/llvm_codegen_internal_impl.h @@ -64,27 +64,13 @@ INLINE LLVMValueRef llvm_store_to_ptr_raw(GenContext *c, LLVMValueRef pointer, L return llvm_store_to_ptr_raw_aligned(c, pointer, value, llvm_type_or_alloca_align(pointer, type)); } -static inline LLVMValueRef llvm_emit_bitcast(GenContext *c, LLVMValueRef value, Type *type) -{ - assert(type->type_kind == TYPE_POINTER); - LLVMTypeRef result_type = llvm_get_type(c, type); - if (result_type == LLVMTypeOf(value)) return value; - return LLVMBuildBitCast(c->builder, value, result_type, ""); -} - INLINE void llvm_value_bitcast(GenContext *c, BEValue *value, Type *type) { assert(llvm_value_is_addr(value)); type = type_lowering(type); - value->value = llvm_emit_bitcast(c, value->value, type_get_ptr(type)); value->type = type; } -INLINE LLVMValueRef llvm_emit_bitcast_ptr(GenContext *c, LLVMValueRef value, Type *type) -{ - return llvm_emit_bitcast(c, value, type_get_ptr(type)); -} - INLINE LLVMValueRef llvm_emit_shl(GenContext *c, LLVMValueRef value, LLVMValueRef shift) { return LLVMBuildShl(c->builder, value, shift, "shl"); @@ -197,11 +183,6 @@ INLINE bool llvm_is_local_eval(GenContext *c) } -INLINE LLVMTypeRef llvm_get_ptr_type(GenContext *c, Type *type) -{ - return llvm_get_type(c, type_get_ptr(type)); -} - INLINE LLVMValueRef llvm_emit_and_raw(GenContext *c, LLVMValueRef lhs, LLVMValueRef rhs) { if (llvm_is_const_null(lhs)) return lhs; diff --git a/src/compiler/llvm_codegen_module.c b/src/compiler/llvm_codegen_module.c index ed57b5a35..df4d233ab 100644 --- a/src/compiler/llvm_codegen_module.c +++ b/src/compiler/llvm_codegen_module.c @@ -115,11 +115,11 @@ void gencontext_begin_module(GenContext *c) } c->bool_type = LLVMInt1TypeInContext(c->context); c->byte_type = LLVMInt8TypeInContext(c->context); + c->ptr_type = LLVMPointerType(c->byte_type, 0); c->chars_type = llvm_get_type(c, type_chars); c->introspect_type = create_introspection_type(c); c->fault_type = create_fault_type(c); c->size_type = llvm_get_type(c, type_usize); - c->char_ptr_type = LLVMPointerType(c->byte_type, 0); if (c->panic_var) c->panic_var->backend_ref = NULL; if (active_target.debug_info != DEBUG_INFO_NONE) @@ -134,7 +134,7 @@ void gencontext_begin_module(GenContext *c) if (active_target.debug_info == DEBUG_INFO_FULL && active_target.feature.safe_mode) { c->debug.stack_type = LLVMStructCreateNamed(c->context, ".$callstack"); - LLVMTypeRef types[4] = { LLVMPointerType(c->debug.stack_type, 0), + LLVMTypeRef types[4] = { c->ptr_type, c->chars_type, c->chars_type, llvm_get_type(c, type_uint) }; diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index 6d1a26f8d..a949d200d 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -1270,7 +1270,7 @@ LLVMValueRef llvm_emit_zstring_named(GenContext *c, const char *str, const char LLVMSetInitializer(global_string, llvm_get_zstring(c, str, len)); AlignSize alignment; LLVMValueRef string = llvm_emit_array_gep_raw(c, global_string, char_array_type, 0, 1, &alignment); - return llvm_emit_bitcast_ptr(c, string, type_char); + return string; } diff --git a/src/compiler/llvm_codegen_storeload.c b/src/compiler/llvm_codegen_storeload.c index a4b917185..0e1a99312 100644 --- a/src/compiler/llvm_codegen_storeload.c +++ b/src/compiler/llvm_codegen_storeload.c @@ -47,12 +47,10 @@ LLVMValueRef llvm_store_to_ptr_aligned(GenContext *c, LLVMValueRef destination, // Here we do an optimized(?) memcopy. ByteSize size = type_size(value->type); LLVMValueRef copy_size = llvm_const_int(c, size <= UINT32_MAX ? type_uint : type_usize, size); - destination = LLVMBuildBitCast(c->builder, destination, llvm_get_ptr_type(c, type_char), ""); - LLVMValueRef source = LLVMBuildBitCast(c->builder, value->value, llvm_get_ptr_type(c, type_char), ""); LLVMValueRef copy = LLVMBuildMemCpy(c->builder, destination, alignment, - source, + value->value, value->alignment ? value->alignment : type_abi_alignment(value->type), copy_size); return copy; diff --git a/src/compiler/llvm_codegen_type.c b/src/compiler/llvm_codegen_type.c index 32b01af1b..47b1f168d 100644 --- a/src/compiler/llvm_codegen_type.c +++ b/src/compiler/llvm_codegen_type.c @@ -5,10 +5,10 @@ #include "llvm_codegen_internal.h" static inline LLVMTypeRef llvm_type_from_decl(GenContext *c, Decl *decl); -static inline LLVMTypeRef llvm_type_from_ptr(GenContext *context, Type *type); + static inline LLVMTypeRef llvm_type_from_array(GenContext *context, Type *type); static void param_expand(GenContext *context, LLVMTypeRef** params_ref, Type *type); -static inline void add_func_type_param(GenContext *context, Type *param_type, ABIArgInfo *arg_info, LLVMTypeRef **params); +static inline void add_func_type_param(GenContext *c, Type *param_type, ABIArgInfo *arg_info, LLVMTypeRef **params); static inline LLVMTypeRef llvm_type_from_decl(GenContext *c, Decl *decl) { @@ -87,19 +87,6 @@ static inline LLVMTypeRef llvm_type_from_decl(GenContext *c, Decl *decl) UNREACHABLE } -static inline LLVMTypeRef llvm_type_from_ptr(GenContext *context, Type *type) -{ - if (type->canonical != type) - { - return type->backend_type = llvm_get_type(context, type->canonical); - } - if (type == type_voidptr) - { - return type->backend_type = llvm_get_ptr_type(context, type_char); - } - return type->backend_type = LLVMPointerType(llvm_get_type(context, type->pointer), /** TODO **/0); -} - static inline LLVMTypeRef llvm_type_from_array(GenContext *context, Type *type) { @@ -165,7 +152,7 @@ static void param_expand(GenContext *context, LLVMTypeRef** params_ref, Type *ty } -static inline void add_func_type_param(GenContext *context, Type *param_type, ABIArgInfo *arg_info, LLVMTypeRef **params) +static inline void add_func_type_param(GenContext *c, Type *param_type, ABIArgInfo *arg_info, LLVMTypeRef **params) { arg_info->param_index_start = (MemberIndex)vec_size(*params); switch (arg_info->kind) @@ -173,31 +160,31 @@ static inline void add_func_type_param(GenContext *context, Type *param_type, AB case ABI_ARG_IGNORE: break; case ABI_ARG_INDIRECT: - vec_add(*params, llvm_get_ptr_type(context, param_type)); + vec_add(*params, c->ptr_type); break; case ABI_ARG_EXPAND_COERCE: - vec_add(*params, llvm_abi_type(context, arg_info->coerce_expand.lo)); + vec_add(*params, llvm_abi_type(c, arg_info->coerce_expand.lo)); if (abi_type_is_valid(arg_info->coerce_expand.hi)) { - vec_add(*params, llvm_abi_type(context, arg_info->coerce_expand.hi)); + vec_add(*params, llvm_abi_type(c, arg_info->coerce_expand.hi)); } break; case ABI_ARG_EXPAND: // Expanding a structs - param_expand(context, params, param_type->canonical); + param_expand(c, params, param_type->canonical); // If we have padding, add it here. if (arg_info->expand.padding_type) { - vec_add(*params, llvm_get_type(context, arg_info->expand.padding_type)); + vec_add(*params, llvm_get_type(c, arg_info->expand.padding_type)); } break; case ABI_ARG_DIRECT: - vec_add(*params, llvm_get_type(context, param_type)); + vec_add(*params, llvm_get_type(c, param_type)); break; case ABI_ARG_DIRECT_SPLIT_STRUCT: { // Normal direct. - LLVMTypeRef coerce_type = llvm_get_type(context, arg_info->direct_struct_expand.type); + LLVMTypeRef coerce_type = llvm_get_type(c, arg_info->direct_struct_expand.type); for (unsigned idx = 0; idx < arg_info->direct_struct_expand.elements; idx++) { vec_add(*params, coerce_type); @@ -207,27 +194,27 @@ static inline void add_func_type_param(GenContext *context, Type *param_type, AB case ABI_ARG_DIRECT_COERCE_INT: { // Normal direct. - LLVMTypeRef coerce_type = LLVMIntTypeInContext(context->context, type_size(param_type) * 8); + LLVMTypeRef coerce_type = LLVMIntTypeInContext(c->context, type_size(param_type) * 8); vec_add(*params, coerce_type); break; } case ABI_ARG_DIRECT_COERCE: { // Normal direct. - LLVMTypeRef coerce_type = llvm_get_type(context, arg_info->direct_coerce_type); + LLVMTypeRef coerce_type = llvm_get_type(c, arg_info->direct_coerce_type); vec_add(*params, coerce_type); break; } case ABI_ARG_DIRECT_PAIR: // Pairs are passed by param. - vec_add(*params, llvm_abi_type(context, arg_info->direct_pair.lo)); - vec_add(*params, llvm_abi_type(context, arg_info->direct_pair.hi)); + vec_add(*params, llvm_abi_type(c, arg_info->direct_pair.lo)); + vec_add(*params, llvm_abi_type(c, arg_info->direct_pair.hi)); break; } arg_info->param_index_end = (MemberIndex)vec_size(*params); } -LLVMTypeRef llvm_update_prototype_abi(GenContext *context, FunctionPrototype *prototype, LLVMTypeRef **params) +LLVMTypeRef llvm_update_prototype_abi(GenContext *c, FunctionPrototype *prototype, LLVMTypeRef **params) { LLVMTypeRef retval = NULL; Type *call_return_type = prototype->abi_ret_type; @@ -241,59 +228,59 @@ LLVMTypeRef llvm_update_prototype_abi(GenContext *context, FunctionPrototype *pr case ABI_ARG_EXPAND: UNREACHABLE; case ABI_ARG_INDIRECT: - vec_add(*params, llvm_get_ptr_type(context, call_return_type)); - retval = llvm_get_type(context, type_void); + vec_add(*params, c->ptr_type); + retval = llvm_get_type(c, type_void); break; case ABI_ARG_EXPAND_COERCE: { - LLVMTypeRef lo = llvm_abi_type(context, ret_arg_info->direct_pair.lo); + LLVMTypeRef lo = llvm_abi_type(c, ret_arg_info->direct_pair.lo); if (!abi_type_is_valid(ret_arg_info->direct_pair.hi)) { retval = lo; break; } - LLVMTypeRef hi = llvm_abi_type(context, ret_arg_info->direct_pair.hi); - retval = llvm_get_twostruct(context, lo, hi); + LLVMTypeRef hi = llvm_abi_type(c, ret_arg_info->direct_pair.hi); + retval = llvm_get_twostruct(c, lo, hi); break; } case ABI_ARG_IGNORE: - retval = llvm_get_type(context, type_void); + retval = llvm_get_type(c, type_void); break; case ABI_ARG_DIRECT_PAIR: { - LLVMTypeRef lo = llvm_abi_type(context, ret_arg_info->direct_pair.lo); - LLVMTypeRef hi = llvm_abi_type(context, ret_arg_info->direct_pair.hi); - retval = llvm_get_twostruct(context, lo, hi); + LLVMTypeRef lo = llvm_abi_type(c, ret_arg_info->direct_pair.lo); + LLVMTypeRef hi = llvm_abi_type(c, ret_arg_info->direct_pair.hi); + retval = llvm_get_twostruct(c, lo, hi); break; } case ABI_ARG_DIRECT: - retval = llvm_get_type(context, call_return_type); + retval = llvm_get_type(c, call_return_type); break; case ABI_ARG_DIRECT_SPLIT_STRUCT: UNREACHABLE case ABI_ARG_DIRECT_COERCE_INT: - retval = LLVMIntTypeInContext(context->context, type_size(call_return_type) * 8); + retval = LLVMIntTypeInContext(c->context, type_size(call_return_type) * 8); break; case ABI_ARG_DIRECT_COERCE: - retval = llvm_get_type(context, ret_arg_info->direct_coerce_type); + retval = llvm_get_type(c, ret_arg_info->direct_coerce_type); break; } // If it's optional and it's not void (meaning ret_abi_info will be NULL) if (prototype->ret_by_ref) { - add_func_type_param(context, type_get_ptr(type_lowering(prototype->ret_by_ref_type)), prototype->ret_by_ref_abi_info, params); + add_func_type_param(c, type_get_ptr(type_lowering(prototype->ret_by_ref_type)), prototype->ret_by_ref_abi_info, params); } // Add in all of the required arguments. VECEACH(prototype->param_types, i) { - add_func_type_param(context, prototype->param_types[i], prototype->abi_args[i], params); + add_func_type_param(c, prototype->param_types[i], prototype->abi_args[i], params); } VECEACH(prototype->varargs, i) { - add_func_type_param(context, prototype->varargs[i], prototype->abi_varargs[i], params); + add_func_type_param(c, prototype->varargs[i], prototype->abi_varargs[i], params); } return retval; } @@ -377,7 +364,8 @@ LLVMTypeRef llvm_get_type(GenContext *c, Type *any_type) case TYPE_BOOL: return any_type->backend_type = LLVMIntTypeInContext(c->context, 8U); case TYPE_POINTER: - return any_type->backend_type = llvm_type_from_ptr(c, any_type); + assert(c->ptr_type); + return any_type->backend_type = c->ptr_type; case TYPE_ARRAY: case TYPE_FLEXIBLE_ARRAY: return any_type->backend_type = llvm_type_from_array(c, any_type); @@ -612,14 +600,7 @@ static LLVMValueRef llvm_get_introspection_for_enum(GenContext *c, Type *type) llvm_set_linkonce(c, global_ref); LLVMSetInitializer(global_ref, associated_value_arr); LLVMSetGlobalConstant(global_ref, true); - if (mixed) - { - associated_value->backend_ref = llvm_emit_bitcast_ptr(c, global_ref, type_get_array(associated_value->type, elements)); - } - else - { - associated_value->backend_ref = global_ref; - } + associated_value->backend_ref = global_ref; } return val; } @@ -668,11 +649,10 @@ static LLVMValueRef llvm_get_introspection_for_fault(GenContext *c, Type *type) llvm_set_linkonce(c, global_name); val->backend_ref = LLVMBuildPointerCast(c->builder, global_name, llvm_get_type(c, type_typeid), ""); } - LLVMTypeRef element_type = llvm_get_type(c, type_typeid); LLVMValueRef* values = elements ? MALLOC(sizeof(LLVMValueRef) * elements) : NULL; for (unsigned i = 0; i < elements; i++) { - values[i] = LLVMBuildBitCast(c->builder, fault_vals[i]->backend_ref, element_type, ""); + values[i] = fault_vals[i]->backend_ref; } return llvm_generate_introspection_global(c, ref, type, INTROSPECT_TYPE_FAULT, NULL, elements, NULL, false); } diff --git a/src/compiler/llvm_codegen_value.c b/src/compiler/llvm_codegen_value.c index 0f2dc3fe7..42ad07454 100644 --- a/src/compiler/llvm_codegen_value.c +++ b/src/compiler/llvm_codegen_value.c @@ -54,7 +54,7 @@ void llvm_value_addr(GenContext *c, BEValue *value) LLVMValueRef ref = llvm_add_global_raw(c, ".taddr", LLVMTypeOf(val), 0); llvm_set_private_linkage(ref); LLVMSetInitializer(ref, val); - llvm_value_set_address_abi_aligned(value, llvm_emit_bitcast_ptr(c, ref, value->type), value->type); + llvm_value_set_address_abi_aligned(value, ref, value->type); } else { diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 45e56071f..80fefea99 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -757,7 +757,6 @@ Expr *recursive_may_narrow_float(Expr *expr, Type *type) case EXPR_TRY_UNWRAP_CHAIN: case EXPR_SUBSCRIPT_ADDR: case EXPR_VARIANTSWITCH: - case EXPR_ARGV_TO_SUBARRAY: case EXPR_COMPILER_CONST: case EXPR_STRINGIFY: case EXPR_CT_EVAL: @@ -925,7 +924,6 @@ Expr *recursive_may_narrow_int(Expr *expr, Type *type) case EXPR_TRY_UNWRAP: case EXPR_TRY_UNWRAP_CHAIN: case EXPR_SUBSCRIPT_ADDR: - case EXPR_ARGV_TO_SUBARRAY: case EXPR_VARIANTSWITCH: case EXPR_COMPILER_CONST: case EXPR_STRINGIFY: diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 30b2756bf..b7c9ee22e 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -443,7 +443,6 @@ static bool sema_binary_is_expr_lvalue(Expr *top_expr, Expr *expr) if (!vec_size(expr->expression_list)) return false; return sema_binary_is_expr_lvalue(top_expr, VECLAST(expr->expression_list)); case EXPR_POISONED: - case EXPR_ARGV_TO_SUBARRAY: case EXPR_ASM: case EXPR_BINARY: case EXPR_BITASSIGN: @@ -7020,9 +7019,6 @@ static inline bool sema_analyse_expr_dispatch(SemaContext *context, Expr *expr) case EXPR_STRINGIFY: if (!sema_expr_analyse_ct_stringify(context, expr)) return false; return true; - case EXPR_ARGV_TO_SUBARRAY: - expr->type = type_get_subarray(global_context_string_type()); - return true; case EXPR_DECL: if (!sema_analyse_var_decl(context, expr->decl_expr, true)) return false; expr->type = expr->decl_expr->type; diff --git a/src/utils/lib.h b/src/utils/lib.h index 434fefba1..a9fb320a4 100644 --- a/src/utils/lib.h +++ b/src/utils/lib.h @@ -320,13 +320,13 @@ void* CONCAT(foreach_vec_, __LINE__) = (vec__); unsigned CONCAT(foreach_len_, __ #if IS_GCC || IS_CLANG #define MAX(_a, _b) ({ \ - typeof(_a) __a__ = (_a); \ - typeof(_b) __b__ = (_b); \ + __auto_type __a__ = (_a); \ + __auto_type __b__ = (_b); \ __a__ > __b__ ? __a__ : __b__; }) #define MIN(_a, _b) ({ \ - typeof(_a) __a__ = (_a); \ - typeof(_b) __b__ = (_b); \ + __auto_type __a__ = (_a); \ + __auto_type __b__ = (_b); \ __a__ < __b__ ? __a__ : __b__; }) #else diff --git a/test/test_suite/abi/literal_load.c3t b/test/test_suite/abi/literal_load.c3t index 797ce3bdb..1d03666ed 100644 --- a/test/test_suite/abi/literal_load.c3t +++ b/test/test_suite/abi/literal_load.c3t @@ -22,11 +22,9 @@ entry: %literal = alloca %Test, align 4 %literal1 = alloca %Test, align 4 store i32 0, ptr %literal, align 4 - %0 = getelementptr inbounds %Test, ptr %literal, i32 0, i32 0 - %1 = load i32, ptr %0, align 4 - call void @blorg(i32 %1) + %0 = load i32, ptr %literal, align 4 + call void @blorg(i32 %0) store i32 0, ptr %literal1, align 4 - %2 = getelementptr inbounds %Test, ptr %literal1, i32 0, i32 0 - %3 = load i32, ptr %2, align 4 - ret i32 %3 -} + %1 = load i32, ptr %literal1, align 4 + ret i32 %1 +} \ No newline at end of file diff --git a/test/test_suite/abi/literal_load_aarch64.c3t b/test/test_suite/abi/literal_load_aarch64.c3t index dde880cfa..d9c3ef29e 100644 --- a/test/test_suite/abi/literal_load_aarch64.c3t +++ b/test/test_suite/abi/literal_load_aarch64.c3t @@ -25,12 +25,10 @@ entry: %literal = alloca %Test, align 4 %literal1 = alloca %Test, align 4 store i32 0, ptr %literal, align 4 - %0 = getelementptr inbounds %Test, ptr %literal, i32 0, i32 0 - %1 = load i32, ptr %0, align 4 - %2 = zext i32 %1 to i64 - call void @blorg(i64 %2) + %0 = load i32, ptr %literal, align 4 + %1 = zext i32 %0 to i64 + call void @blorg(i64 %1) store i32 0, ptr %literal1, align 4 - %3 = getelementptr inbounds %Test, ptr %literal1, i32 0, i32 0 - %4 = load i32, ptr %3, align 4 - ret i32 %4 + %2 = load i32, ptr %literal1, align 4 + ret i32 %2 } \ No newline at end of file diff --git a/test/test_suite/abi/literal_load_mingw.c3t b/test/test_suite/abi/literal_load_mingw.c3t index 430a9da08..3bf6b59a5 100644 --- a/test/test_suite/abi/literal_load_mingw.c3t +++ b/test/test_suite/abi/literal_load_mingw.c3t @@ -23,11 +23,9 @@ entry: %literal = alloca %Test, align 4 %literal1 = alloca %Test, align 4 store i32 0, ptr %literal, align 4 - %0 = getelementptr inbounds %Test, ptr %literal, i32 0, i32 0 - %1 = load i32, ptr %0, align 4 - call void @blorg(i32 %1) + %0 = load i32, ptr %literal, align 4 + call void @blorg(i32 %0) store i32 0, ptr %literal1, align 4 - %2 = getelementptr inbounds %Test, ptr %literal1, i32 0, i32 0 - %3 = load i32, ptr %2, align 4 - ret i32 %3 + %1 = load i32, ptr %literal1, align 4 + ret i32 %1 } diff --git a/test/test_suite/abi/sysv_direct_coerce.c3t b/test/test_suite/abi/sysv_direct_coerce.c3t index 05dbffc86..add49d1fc 100644 --- a/test/test_suite/abi/sysv_direct_coerce.c3t +++ b/test/test_suite/abi/sysv_direct_coerce.c3t @@ -18,26 +18,25 @@ fn void test(Rectangle r) define void @foo_test(<2 x float> %0, <2 x float> %1) #0 { entry: - %r = alloca %Rectangle, align 4 + %r = alloca %Rectangle, align 8 %literal = alloca %Rectangle, align 4 %coerce = alloca %Rectangle, align 8 - %2 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %r, i32 0, i32 0 - store <2 x float> %0, ptr %2, align 4 - %3 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %r, i32 0, i32 1 - store <2 x float> %1, ptr %3, align 4 - %4 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 0 - store float 1.000000e+00, ptr %4, align 4 - %5 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 1 - store float 2.000000e+00, ptr %5, align 4 - %6 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 2 - store float 3.000000e+00, ptr %6, align 4 - %7 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 3 - store float 4.000000e+00, ptr %7, align 4 + store <2 x float> %0, ptr %r, align 8 + %ptroffset = getelementptr inbounds <2 x float>, ptr %r, i64 1 + store <2 x float> %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 0 + store float 1.000000e+00, ptr %2, align 4 + %3 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 1 + store float 2.000000e+00, ptr %3, align 4 + %4 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 2 + store float 3.000000e+00, ptr %4, align 4 + %5 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 3 + store float 4.000000e+00, ptr %5, align 4 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %coerce, ptr align 4 %literal, i32 16, i1 false) - %8 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %coerce, i32 0, i32 0 - %lo = load <2 x float>, ptr %8, align 8 - %9 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %coerce, i32 0, i32 1 - %hi = load <2 x float>, ptr %9, align 8 + %6 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %coerce, i32 0, i32 0 + %lo = load <2 x float>, ptr %6, align 8 + %7 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %coerce, i32 0, i32 1 + %hi = load <2 x float>, ptr %7, align 8 call void @foo_test(<2 x float> %lo, <2 x float> %hi) ret void } \ No newline at end of file diff --git a/test/test_suite/abi/union_x64.c3t b/test/test_suite/abi/union_x64.c3t index daf3b8dd5..030759305 100644 --- a/test/test_suite/abi/union_x64.c3t +++ b/test/test_suite/abi/union_x64.c3t @@ -23,15 +23,15 @@ declare void @hello2(i64, i64) #0 define void @unionx64_hello(i64 %0, i64 %1) #0 { entry: %f = alloca %Foo, align 8 + store i64 %0, ptr %f, align 8 + %ptroffset = getelementptr inbounds i64, ptr %f, i64 1 + store i64 %1, ptr %ptroffset, align 8 %2 = getelementptr inbounds { i64, i64 }, ptr %f, i32 0, i32 0 - store i64 %0, ptr %2, align 8 + %lo = load i64, ptr %2, align 8 %3 = getelementptr inbounds { i64, i64 }, ptr %f, i32 0, i32 1 - store i64 %1, ptr %3, align 8 - %4 = getelementptr inbounds { i64, i64 }, ptr %f, i32 0, i32 0 - %lo = load i64, ptr %4, align 8 - %5 = getelementptr inbounds { i64, i64 }, ptr %f, i32 0, i32 1 - %hi = load i64, ptr %5, align 8 + %hi = load i64, ptr %3, align 8 call void @hello2(i64 %lo, i64 %hi) ret void } +attributes #0 = { nounwind } diff --git a/test/test_suite/clang/2002-01_02.c3t b/test/test_suite/clang/2002-01_02.c3t index 5b22b65c8..4929eefff 100644 --- a/test/test_suite/clang/2002-01_02.c3t +++ b/test/test_suite/clang/2002-01_02.c3t @@ -184,10 +184,8 @@ entry: %le1 = icmp sle i32 %3, %4 %or = or i1 %le, %le1 br i1 %or, label %if.then, label %if.exit - if.then: ; preds = %entry ret ptr null - if.exit: ; preds = %entry ret ptr %0 } @@ -198,9 +196,8 @@ define void @test_teste2() #0 { entry: %xqic = alloca %Foostruct, align 2 store i16 0, ptr %xqic, align 2 - %0 = getelementptr inbounds %Foostruct, ptr %xqic, i32 0, i32 0 - %1 = load i16, ptr %0, align 2 - %2 = call i32 @foo3(i16 %1) + %0 = load i16, ptr %xqic, align 2 + %1 = call i32 @foo3(i16 %0) ret void } @@ -213,22 +210,18 @@ entry: store ptr null, ptr %basel, align 8 store ptr null, ptr %rcand, align 8 br label %loop.body - loop.body: ; preds = %if.exit, %entry %2 = load i32, ptr %lvalid, align 4 %not = icmp eq i32 %2, 0 br i1 %not, label %if.then, label %if.exit - if.then: ; preds = %loop.body %3 = load ptr, ptr %basel, align 8 %4 = getelementptr inbounds %Edge_rec, ptr %3, i32 0, i32 1 %5 = load ptr, ptr %4, align 8 %ptrxi = ptrtoint ptr %5 to i32 ret i32 %ptrxi - if.exit: ; preds = %loop.body br label %loop.body - loop.exit: ; No predecessors! ret i32 1 } @@ -261,60 +254,56 @@ entry: define i32 @test_test2(i32 %0, i64 %1, i32 %2, i32 %3) #0 { entry: - %4 = alloca { i64, i32 }, align 8 - %5 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0 - store i64 %1, ptr %5, align 8 - %6 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1 - store i32 %2, ptr %6, align 8 + %a = alloca %Test, align 8 + store i64 %1, ptr %a, align 8 + %ptroffset = getelementptr inbounds i32, ptr %a, i64 2 + store i32 %2, ptr %ptroffset, align 8 %add = add i32 %0, %3 - %7 = getelementptr inbounds %Test, ptr %4, i32 0, i32 1 - %8 = load i16, ptr %7, align 2 - %sisiext = sext i16 %8 to i32 + %4 = getelementptr inbounds %Test, ptr %a, i32 0, i32 1 + %5 = load i16, ptr %4, align 2 + %sisiext = sext i16 %5 to i32 %add1 = add i32 %add, %sisiext - %9 = getelementptr inbounds %Test, ptr %4, i32 0, i32 2 - %10 = load i32, ptr %9, align 4 - %add2 = add i32 %add1, %10 + %6 = getelementptr inbounds %Test, ptr %a, i32 0, i32 2 + %7 = load i32, ptr %6, align 4 + %add2 = add i32 %add1, %7 ret i32 %add2 } define i32 @test_test3(i64 %0, i32 %1, i64 %2, i32 %3) #0 { entry: - %4 = alloca { i64, i32 }, align 8 - %5 = alloca { i64, i32 }, align 8 - %6 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0 - store i64 %0, ptr %6, align 8 - %7 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1 - store i32 %1, ptr %7, align 8 - %8 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0 - store i64 %2, ptr %8, align 8 - %9 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1 - store i32 %3, ptr %9, align 8 - %10 = getelementptr inbounds %Test, ptr %4, i32 0, i32 1 - %11 = load i16, ptr %10, align 2 - %sisiext = sext i16 %11 to i32 - %12 = getelementptr inbounds %Test, ptr %4, i32 0, i32 2 - %13 = load i32, ptr %12, align 4 - %add = add i32 %sisiext, %13 - %14 = getelementptr inbounds %Test, ptr %5, i32 0, i32 2 - %15 = load i32, ptr %14, align 4 - %add1 = add i32 %add, %15 - %16 = getelementptr inbounds %Test, ptr %5, i32 0, i32 3 - %17 = load i32, ptr %16, align 8 - %add2 = add i32 %add1, %17 - ret i32 %add2 + %a = alloca %Test, align 8 + %b = alloca %Test, align 8 + store i64 %0, ptr %a, align 8 + %ptroffset = getelementptr inbounds i32, ptr %a, i64 2 + store i32 %1, ptr %ptroffset, align 8 + store i64 %2, ptr %b, align 8 + %ptroffset1 = getelementptr inbounds i32, ptr %b, i64 2 + store i32 %3, ptr %ptroffset1, align 8 + %4 = getelementptr inbounds %Test, ptr %a, i32 0, i32 1 + %5 = load i16, ptr %4, align 2 + %sisiext = sext i16 %5 to i32 + %6 = getelementptr inbounds %Test, ptr %a, i32 0, i32 2 + %7 = load i32, ptr %6, align 4 + %add = add i32 %sisiext, %7 + %8 = getelementptr inbounds %Test, ptr %b, i32 0, i32 2 + %9 = load i32, ptr %8, align 4 + %add2 = add i32 %add, %9 + %10 = getelementptr inbounds %Test, ptr %b, i32 0, i32 3 + %11 = load i32, ptr %10, align 8 + %add3 = add i32 %add2, %11 + ret i32 %add3 } define { i64, i32 } @test_test4(i64 %0, i32 %1) #0 { entry: - %2 = alloca { i64, i32 }, align 8 + %a = alloca %Test, align 8 %tempcoerce = alloca { i64, i32 }, align 8 - %3 = getelementptr inbounds { i64, i32 }, ptr %2, i32 0, i32 0 - store i64 %0, ptr %3, align 8 - %4 = getelementptr inbounds { i64, i32 }, ptr %2, i32 0, i32 1 - store i32 %1, ptr %4, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %tempcoerce, ptr align 8 %2, i32 12, i1 false) - %5 = load { i64, i32 }, ptr %tempcoerce, align 8 - ret { i64, i32 } %5 + store i64 %0, ptr %a, align 8 + %ptroffset = getelementptr inbounds i32, ptr %a, i64 2 + store i32 %1, ptr %ptroffset, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %tempcoerce, ptr align 8 %a, i32 12, i1 false) + %2 = load { i64, i32 }, ptr %tempcoerce, align 8 + ret { i64, i32 } %2 } define i32 @test_test6() #0 { diff --git a/test/test_suite/clang/2002-07.c3t b/test/test_suite/clang/2002-07.c3t new file mode 100644 index 000000000..34e9a9020 --- /dev/null +++ b/test/test_suite/clang/2002-07.c3t @@ -0,0 +1,996 @@ +// #target: macos-x64 +module foo; + +extern fn void* malloc(uint); + +struct List +{ + int data; + List* next; +} + +fn List* passThroughList(List* l) { + return l; +} + +// Recursive data structure tests... + +List* data; + +fn void foo() +{ + static int foo = 0; // Test static local variable + foo += 1; // Increment static variable + + data = (List*)malloc(12); // This is not a proper list allocation +} + +List listNode3 = { 4, null }; +List listNode2 = { 3, &listNode3 }; +List listNode0 = { 1, &listNode1 }; +List listNode1 = { 2, &listNode2 }; + + +List[10] listArray; + +// Iterative insert fn +fn void insertIntoListTail(List **l, int data) { + while (*l) l = &(*l).next; + *l = (List*)malloc(List.sizeof); + (*l).data = data; + (*l).next = null; +} + +// Recursive list search fn +fn List *findData(List *l, int data) { + if (!l) return null; + if (l.data == data) return l; + return findData(l.next, data); +} + +extern fn void foundIt(); + +// Driver fn... +fn void doListStuff() { + List* myList = null; + insertIntoListTail(&myList, 100); + insertIntoListTail(&myList, 12); + insertIntoListTail(&myList, 42); + insertIntoListTail(&myList, 1123); + insertIntoListTail(&myList, 1213); + + if (findData(myList, 75)) foundIt(); + if (findData(myList, 42)) foundIt(); + if (findData(myList, 700)) foundIt(); +} + + +fn int floatcomptest(double *x, double *y, float *x1, float *y1) { + return (int)(*x < *y || *x1 < *y1); +} + +// Exposed a bug +fn void* memset_impl(void* dstpp, int c, uint len) +{ + iptr dstp = (iptr)dstpp; + + while (dstp % 4 != 0) + { + ((char*)dstp)[0] = (char)c; + dstp += 1; + len -= 1; + } + return dstpp; +} + +// TEST problem with signed/unsigned versions of the same constants being shared +// incorrectly! +private char* temp; +private int remaining; +private fn char* localmalloc(int size) { + char* blah; + + if (size>remaining) + { + temp = (char*) malloc(32768); + remaining = 32768; + return temp; + } + return null; +} + + +struct PBVTest { double x; double y; int z; } + +fn PBVTest testRetStruct(float x, double y, int z) { + PBVTest t = { x, y, z }; + return t; +} +extern fn PBVTest testRetStruct2(); // external func no inlining + + +fn double callRetStruct(float x, double y, int z) { + PBVTest t = testRetStruct2(); + return t.x+x+y+z; +} + +extern fn int fp(int, char*); +char *ext; +fn void __bb_exit_func() +{ + fp(12, ext ? ext : ""); +} + +extern fn int puts(char* s); + +struct FunStructTest { + int test1; + char *pointer; + int[12] array; +} + +struct SubStruct { + short x, y; +} + +struct Quad { + int w; + SubStruct ss; + SubStruct *ssp; + char c; + int y; +} + +Quad globalQuad = { 4, {1, 2}, null, 3, 156 }; + +define FuncPtr = fn int(int); + +fn uint ptrFunc(FuncPtr func, int x) { + return func(x); +} + +fn char ptrFunc2(FuncPtr[30] funcTab, int num) { + return (char)funcTab[num]('b'); +} + +extern fn char smallArgs2(char w, char x, long zrrk, char y, char z); +extern fn int someFuncA(); +fn char smallArgs(char w, char x, char y, char z) { + someFuncA(); + return smallArgs2(w-1, x+1, y, z, w); +} + +private fn int f0(Quad q, int i) { /* Pass Q by value */ + Quad r = void; + if (i) r.ss = q.ss; + q.ssp = &r.ss; + q.w = q.y = q.c = 1; + return q.ss.y + i + r.y - q.c; +} + +fn int f1(Quad *q, int i) { /* Pass Q by address */ + Quad r = void; + if (i) r = *q; + q.w = q.y = q.c = 1; + return q.ss.y+i+r.y-q.c; +} + + +fn int badFunc(float val) { + int result = void; + if (val > 12.345) result = 4; + return result; /* Test use of undefined value */ +} + +extern fn int ef1(int *, char *, int *); + +fn int func(int param, long param2) { + int result = param; + + {{{{ + char c = void; int x = void; + ef1(&result, &c, &x); + }}} + + { // c & X are duplicate names! + char c; int x; + ef1(&result, &c, &x); + } + + } + return result; +} + + +fn short funFunc(long x, char z) { + return (short)(x+z); +} + +fn uint castTest(int x) { return x; } + +fn double testAdd(double x, float y) { + return x+y+0.5; +} + +fn int funcZ(int i, int j) { + while (i != 20) i += 2; + + j += funcZ(2, i); + return (i * 3 + j*2)*j; +} + +fn int sumArray(int* array, int num) { + int i = void; + int result = 0; + for (i = 0; i < num; ++i) + result += array[i]; + + return result; +} + +fn int arrayParam(int* values) { + return ef1((int*)(iptr)values[50], (char*)1, &values[50]); +} + +fn int arrayToSum() { + int[100] a = void; + int i; + for (i = 0; i < 100; ++i) + a[i] = i*4; + + return a[a[0]]; //SumArray(A, 100); +} + + +fn int externFunc(long, uint*, short, char); + +fn int main(int argc, char **argv) { + uint i = void; + puts("Hello world!\n"); + + externFunc(-1, null, (short)argc, 2); + //func(argc, argc); + + for (i = 0; i < 10; i++) puts(argv[3]); + return 0; +} + +fn double mathFunc(double x, double y, double z, + double aa, double bb, double cc, double dd, + double ee, double ff, double gg, double hh, + double aaa, double abb, double acc, double add, + double aee, double aff) { + return x + y + z + aa + bb + cc + dd + ee + ff + gg + hh + + aaa + abb + acc + add + aee + aff; +} + + + +fn void strcpy(char *s1, char *s2) { + while (*s1++ = *s2++); +} + +fn void strcat(char *s1, char *s2) { + while (*s1++); + s1--; + while (*s1++ = *s2++); +} + +fn int strcmp(char *s1, char *s2) { + while (*s1++ == *s2++); + if (*s1 == 0) { + if (*s2 == 0) { + return 0; + } else { + return -1; + } + } else { + if (*s2 == 0) { + return 1; + } else { + return (*(--s1) - *(--s2)); + } + } +} + +/* #expect: foo.ll + + +@foo_data = local_unnamed_addr global ptr null, align 8 +@foo_listNode3 = global %List { i32 4, ptr null }, align 8 +@foo_listNode2 = global %List { i32 3, ptr @foo_listNode3 }, align 8 +@foo_listNode0 = local_unnamed_addr global %List { i32 1, ptr @foo_listNode1 }, align 8 +@foo_listNode1 = global %List { i32 2, ptr @foo_listNode2 }, align 8 +@foo_listArray = local_unnamed_addr global [10 x %List] zeroinitializer, align 16 +@foo_temp = protected unnamed_addr global ptr null, align 8 +@foo_remaining = protected unnamed_addr global i32 0, align 4 +@foo_ext = local_unnamed_addr global ptr null, align 8 +@foo_globalQuad = local_unnamed_addr global %Quad { i32 4, %SubStruct { i16 1, i16 2 }, ptr null, i8 3, i32 156 }, align 8 +@"foo$foo" = internal unnamed_addr global i32 0, align 4 + +define ptr @foo_passThroughList(ptr %0) #0 { +entry: + ret ptr %0 +} + +define void @foo_foo() #0 { +entry: + %0 = load i32, ptr @"foo$foo", align 4 + %add = add i32 %0, 1 + store i32 %add, ptr @"foo$foo", align 4 + %1 = call ptr @malloc(i32 12) + store ptr %1, ptr @foo_data, align 8 + ret void +} + +define void @foo_insertIntoListTail(ptr %0, i32 %1) #0 { +entry: + %l = alloca ptr, align 8 + store ptr %0, ptr %l, align 8 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %2 = load ptr, ptr %l, align 8 + %3 = load ptr, ptr %2, align 8 + %ptrbool = icmp ne ptr %3, null + br i1 %ptrbool, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + %4 = load ptr, ptr %l, align 8 + %5 = load ptr, ptr %4, align 8 + %6 = getelementptr inbounds %List, ptr %5, i32 0, i32 1 + store ptr %6, ptr %l, align 8 + br label %loop.cond + +loop.exit: ; preds = %loop.cond + %7 = load ptr, ptr %l, align 8 + %8 = call ptr @malloc(i32 16) + store ptr %8, ptr %7, align 8 + %9 = load ptr, ptr %l, align 8 + %10 = load ptr, ptr %9, align 8 + %11 = getelementptr inbounds %List, ptr %10, i32 0, i32 0 + store i32 %1, ptr %11, align 8 + %12 = load ptr, ptr %l, align 8 + %13 = load ptr, ptr %12, align 8 + %14 = getelementptr inbounds %List, ptr %13, i32 0, i32 1 + store ptr null, ptr %14, align 8 + ret void +} + +define ptr @foo_findData(ptr %0, i32 %1) #0 { +entry: + %not = icmp eq ptr %0, null + br i1 %not, label %if.then, label %if.exit + +if.then: ; preds = %entry + ret ptr null + +if.exit: ; preds = %entry + %2 = getelementptr inbounds %List, ptr %0, i32 0, i32 0 + %3 = load i32, ptr %2, align 8 + %eq = icmp eq i32 %3, %1 + br i1 %eq, label %if.then1, label %if.exit2 + +if.then1: ; preds = %if.exit + ret ptr %0 + +if.exit2: ; preds = %if.exit + %4 = getelementptr inbounds %List, ptr %0, i32 0, i32 1 + %5 = load ptr, ptr %4, align 8 + %6 = call ptr @foo_findData(ptr %5, i32 %1) + ret ptr %6 +} + + + +define void @foo_doListStuff() #0 { +entry: + %myList = alloca ptr, align 8 + store ptr null, ptr %myList, align 8 + call void @foo_insertIntoListTail(ptr %myList, i32 100) + call void @foo_insertIntoListTail(ptr %myList, i32 12) + call void @foo_insertIntoListTail(ptr %myList, i32 42) + call void @foo_insertIntoListTail(ptr %myList, i32 1123) + call void @foo_insertIntoListTail(ptr %myList, i32 1213) + %0 = load ptr, ptr %myList, align 8 + %1 = call ptr @foo_findData(ptr %0, i32 75) + %ptrbool = icmp ne ptr %1, null + br i1 %ptrbool, label %if.then, label %if.exit + +if.then: ; preds = %entry + call void @foundIt() + br label %if.exit + +if.exit: ; preds = %if.then, %entry + %2 = load ptr, ptr %myList, align 8 + %3 = call ptr @foo_findData(ptr %2, i32 42) + %ptrbool1 = icmp ne ptr %3, null + br i1 %ptrbool1, label %if.then2, label %if.exit3 + +if.then2: ; preds = %if.exit + call void @foundIt() + br label %if.exit3 + +if.exit3: ; preds = %if.then2, %if.exit + %4 = load ptr, ptr %myList, align 8 + %5 = call ptr @foo_findData(ptr %4, i32 700) + %ptrbool4 = icmp ne ptr %5, null + br i1 %ptrbool4, label %if.then5, label %if.exit6 + +if.then5: ; preds = %if.exit3 + call void @foundIt() + br label %if.exit6 + +if.exit6: ; preds = %if.then5, %if.exit3 + ret void +} + +define i32 @foo_floatcomptest(ptr %0, ptr %1, ptr %2, ptr %3) #0 { +entry: + %4 = load double, ptr %0, align 8 + %5 = load double, ptr %1, align 8 + %lt = fcmp olt double %4, %5 + br i1 %lt, label %or.phi, label %or.rhs + +or.rhs: ; preds = %entry + %6 = load float, ptr %2, align 4 + %7 = load float, ptr %3, align 4 + %lt1 = fcmp olt float %6, %7 + br label %or.phi + +or.phi: ; preds = %or.rhs, %entry + %val = phi i1 [ true, %entry ], [ %lt1, %or.rhs ] + %boolsi = zext i1 %val to i32 + ret i32 %boolsi +} + + +define ptr @foo_memset_impl(ptr %0, i32 %1, i32 %2) #0 { +entry: + %len = alloca i32, align 4 + %dstp = alloca i64, align 8 + store i32 %2, ptr %len, align 4 + %ptrxi = ptrtoint ptr %0 to i64 + store i64 %ptrxi, ptr %dstp, align 8 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %3 = load i64, ptr %dstp, align 8 + %smod = srem i64 %3, 4 + %neq = icmp ne i64 %smod, 0 + br i1 %neq, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + %4 = load i64, ptr %dstp, align 8 + %xiptr = inttoptr i64 %4 to ptr + %ptroffset = getelementptr inbounds i8, ptr %xiptr, i64 0 + %siuitrunc = trunc i32 %1 to i8 + store i8 %siuitrunc, ptr %ptroffset, align 1 + %5 = load i64, ptr %dstp, align 8 + %add = add i64 %5, 1 + store i64 %add, ptr %dstp, align 8 + %6 = load i32, ptr %len, align 4 + %sub = sub i32 %6, 1 + store i32 %sub, ptr %len, align 4 + br label %loop.cond + +loop.exit: ; preds = %loop.cond + ret ptr %0 +} + +define internal ptr @foo_localmalloc(i32 %0) #0 { +entry: + %blah = alloca ptr, align 8 + store ptr null, ptr %blah, align 8 + %1 = load i32, ptr @foo_remaining, align 4 + %gt = icmp sgt i32 %0, %1 + br i1 %gt, label %if.then, label %if.exit + +if.then: ; preds = %entry + %2 = call ptr @malloc(i32 32768) + store ptr %2, ptr @foo_temp, align 8 + store i32 32768, ptr @foo_remaining, align 4 + %3 = load ptr, ptr @foo_temp, align 8 + ret ptr %3 + +if.exit: ; preds = %entry + ret ptr null +} + +define void @foo_testRetStruct(ptr noalias sret(%PBVTest) align 8 %0, float %1, double %2, i32 %3) #0 { +entry: + %t = alloca %PBVTest, align 8 + %4 = getelementptr inbounds %PBVTest, ptr %t, i32 0, i32 0 + %fpfpext = fpext float %1 to double + store double %fpfpext, ptr %4, align 8 + %5 = getelementptr inbounds %PBVTest, ptr %t, i32 0, i32 1 + store double %2, ptr %5, align 8 + %6 = getelementptr inbounds %PBVTest, ptr %t, i32 0, i32 2 + store i32 %3, ptr %6, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %t, i32 24, i1 false) + ret void +} + +define double @foo_callRetStruct(float %0, double %1, i32 %2) #0 { +entry: + %t = alloca %PBVTest, align 8 + call void @testRetStruct2(ptr sret(%PBVTest) align 8 %t) + %3 = getelementptr inbounds %PBVTest, ptr %t, i32 0, i32 0 + %4 = load double, ptr %3, align 8 + %fpfpext = fpext float %0 to double + %fadd = fadd double %4, %fpfpext + %fadd1 = fadd double %fadd, %1 + %sifp = sitofp i32 %2 to double + %fadd2 = fadd double %fadd1, %sifp + ret double %fadd2 +} + + +define void @foo___bb_exit_func() #0 { +entry: + %0 = load ptr, ptr @foo_ext, align 8 + %ptrbool = icmp ne ptr %0, null + br i1 %ptrbool, label %cond.lhs, label %cond.rhs + +cond.lhs: ; preds = %entry + %1 = load ptr, ptr @foo_ext, align 8 + br label %cond.phi + +cond.rhs: ; preds = %entry + br label %cond.phi + +cond.phi: ; preds = %cond.rhs, %cond.lhs + %val = phi ptr [ %1, %cond.lhs ], [ @.str, %cond.rhs ] + %2 = call i32 @fp(i32 12, ptr %val) + ret void +} + +define i32 @foo_ptrFunc(ptr %0, i32 %1) #0 { +entry: + %2 = call i32 %0(i32 %1) + ret i32 %2 +} + +define zeroext i8 @foo_ptrFunc2(ptr byval([30 x ptr]) align 8 %0, i32 %1) #0 { +entry: + %sisiext = sext i32 %1 to i64 + %2 = getelementptr inbounds [30 x ptr], ptr %0, i64 0, i64 %sisiext + %3 = load ptr, ptr %2, align 8 + %4 = call i32 %3(i32 98) + %siuitrunc = trunc i32 %4 to i8 + ret i8 %siuitrunc +} + +define zeroext i8 @foo_smallArgs(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3) #0 { +entry: + %4 = call i32 @someFuncA() + %uisiext = zext i8 %0 to i32 + %sub = sub i32 %uisiext, 1 + %siuitrunc = trunc i32 %sub to i8 + %uisiext1 = zext i8 %1 to i32 + %add = add i32 %uisiext1, 1 + %siuitrunc2 = trunc i32 %add to i8 + %uisiext3 = zext i8 %2 to i64 + %5 = call i8 @smallArgs2(i8 %siuitrunc, i8 %siuitrunc2, i64 %uisiext3, i8 %3, i8 %0) + ret i8 %5 +} + +define internal i32 @foo_f0(ptr byval(%Quad) align 8 %0, i32 %1) #0 { +entry: + %r = alloca %Quad, align 8 + %intbool = icmp ne i32 %1, 0 + br i1 %intbool, label %if.then, label %if.exit + +if.then: ; preds = %entry + %2 = getelementptr inbounds %Quad, ptr %r, i32 0, i32 1 + %3 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 1 + call void @llvm.memcpy.p0.p0.i32(ptr align 4 %2, ptr align 4 %3, i32 4, i1 false) + br label %if.exit + +if.exit: ; preds = %if.then, %entry + %4 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 2 + %5 = getelementptr inbounds %Quad, ptr %r, i32 0, i32 1 + store ptr %5, ptr %4, align 8 + %6 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 0 + %7 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 4 + %8 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 3 + store i8 1, ptr %8, align 8 + store i32 1, ptr %7, align 4 + store i32 1, ptr %6, align 8 + %9 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 1 + %10 = getelementptr inbounds %SubStruct, ptr %9, i32 0, i32 1 + %11 = load i16, ptr %10, align 2 + %sisiext = sext i16 %11 to i32 + %add = add i32 %sisiext, %1 + %12 = getelementptr inbounds %Quad, ptr %r, i32 0, i32 4 + %13 = load i32, ptr %12, align 4 + %add1 = add i32 %add, %13 + %14 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 3 + %15 = load i8, ptr %14, align 8 + %uisiext = zext i8 %15 to i32 + %sub = sub i32 %add1, %uisiext + ret i32 %sub +} + +define i32 @foo_f1(ptr %0, i32 %1) #0 { +entry: + %r = alloca %Quad, align 8 + %intbool = icmp ne i32 %1, 0 + br i1 %intbool, label %if.then, label %if.exit + +if.then: ; preds = %entry + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %r, ptr align 8 %0, i32 24, i1 false) + br label %if.exit + +if.exit: ; preds = %if.then, %entry + %2 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 0 + %3 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 4 + %4 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 3 + store i8 1, ptr %4, align 8 + store i32 1, ptr %3, align 4 + store i32 1, ptr %2, align 8 + %5 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 1 + %6 = getelementptr inbounds %SubStruct, ptr %5, i32 0, i32 1 + %7 = load i16, ptr %6, align 2 + %sisiext = sext i16 %7 to i32 + %add = add i32 %sisiext, %1 + %8 = getelementptr inbounds %Quad, ptr %r, i32 0, i32 4 + %9 = load i32, ptr %8, align 4 + %add1 = add i32 %add, %9 + %10 = getelementptr inbounds %Quad, ptr %0, i32 0, i32 3 + %11 = load i8, ptr %10, align 8 + %uisiext = zext i8 %11 to i32 + %sub = sub i32 %add1, %uisiext + ret i32 %sub +} + +define i32 @foo_badFunc(float %0) #0 { +entry: + %result = alloca i32, align 4 + %fpfpext = fpext float %0 to double + %gt = fcmp ogt double %fpfpext, 1.234500e+01 + br i1 %gt, label %if.then, label %if.exit + +if.then: ; preds = %entry + store i32 4, ptr %result, align 4 + br label %if.exit + +if.exit: ; preds = %if.then, %entry + %1 = load i32, ptr %result, align 4 + ret i32 %1 +} + +define i32 @foo_func(i32 %0, i64 %1) #0 { +entry: + %result = alloca i32, align 4 + %c = alloca i8, align 1 + %x = alloca i32, align 4 + %c1 = alloca i8, align 1 + %x2 = alloca i32, align 4 + store i32 %0, ptr %result, align 4 + %2 = call i32 @ef1(ptr %result, ptr %c, ptr %x) + store i8 0, ptr %c1, align 1 + store i32 0, ptr %x2, align 4 + %3 = call i32 @ef1(ptr %result, ptr %c1, ptr %x2) + %4 = load i32, ptr %result, align 4 + ret i32 %4 +} + +define signext i16 @foo_funFunc(i64 %0, i8 zeroext %1) #0 { +entry: + %uisiext = zext i8 %1 to i64 + %add = add i64 %0, %uisiext + %sisitrunc = trunc i64 %add to i16 + ret i16 %sisitrunc +} + +define i32 @foo_castTest(i32 %0) #0 { +entry: + ret i32 %0 +} + +define double @foo_testAdd(double %0, float %1) #0 { +entry: + %fpfpext = fpext float %1 to double + %fadd = fadd double %0, %fpfpext + %fadd1 = fadd double %fadd, 5.000000e-01 + ret double %fadd1 +} + +define i32 @foo_funcZ(i32 %0, i32 %1) #0 { +entry: + %i = alloca i32, align 4 + %j = alloca i32, align 4 + store i32 %0, ptr %i, align 4 + store i32 %1, ptr %j, align 4 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %2 = load i32, ptr %i, align 4 + %neq = icmp ne i32 %2, 20 + br i1 %neq, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + %3 = load i32, ptr %i, align 4 + %add = add i32 %3, 2 + store i32 %add, ptr %i, align 4 + br label %loop.cond + +loop.exit: ; preds = %loop.cond + %4 = load i32, ptr %j, align 4 + %5 = load i32, ptr %i, align 4 + %6 = call i32 @foo_funcZ(i32 2, i32 %5) + %add1 = add i32 %4, %6 + store i32 %add1, ptr %j, align 4 + %7 = load i32, ptr %i, align 4 + %mul = mul i32 %7, 3 + %8 = load i32, ptr %j, align 4 + %mul2 = mul i32 %8, 2 + %add3 = add i32 %mul, %mul2 + %9 = load i32, ptr %j, align 4 + %mul4 = mul i32 %add3, %9 + ret i32 %mul4 +} + +define i32 @foo_sumArray(ptr %0, i32 %1) #0 { +entry: + %i = alloca i32, align 4 + %result = alloca i32, align 4 + store i32 0, ptr %result, align 4 + store i32 0, ptr %i, align 4 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %2 = load i32, ptr %i, align 4 + %lt = icmp slt i32 %2, %1 + br i1 %lt, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + %3 = load i32, ptr %result, align 4 + %4 = load i32, ptr %i, align 4 + %sisiext = sext i32 %4 to i64 + %ptroffset = getelementptr inbounds i32, ptr %0, i64 %sisiext + %5 = load i32, ptr %ptroffset, align 4 + %add = add i32 %3, %5 + store i32 %add, ptr %result, align 4 + %6 = load i32, ptr %i, align 4 + %add1 = add i32 %6, 1 + store i32 %add1, ptr %i, align 4 + br label %loop.cond + +loop.exit: ; preds = %loop.cond + %7 = load i32, ptr %result, align 4 + ret i32 %7 +} + +define i32 @foo_arrayParam(ptr %0) #0 { +entry: + %ptroffset = getelementptr inbounds i32, ptr %0, i64 50 + %1 = load i32, ptr %ptroffset, align 4 + %sisiext = sext i32 %1 to i64 + %xiptr = inttoptr i64 %sisiext to ptr + %ptroffset1 = getelementptr inbounds i32, ptr %0, i64 50 + %2 = call i32 @ef1(ptr %xiptr, ptr inttoptr (i64 1 to ptr), ptr %ptroffset1) + ret i32 %2 +} + +define i32 @foo_arrayToSum() #0 { +entry: + %a = alloca [100 x i32], align 16 + %i = alloca i32, align 4 + store i32 0, ptr %i, align 4 + store i32 0, ptr %i, align 4 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %0 = load i32, ptr %i, align 4 + %lt = icmp slt i32 %0, 100 + br i1 %lt, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + %1 = load i32, ptr %i, align 4 + %sisiext = sext i32 %1 to i64 + %2 = getelementptr inbounds [100 x i32], ptr %a, i64 0, i64 %sisiext + %3 = load i32, ptr %i, align 4 + %mul = mul i32 %3, 4 + store i32 %mul, ptr %2, align 4 + %4 = load i32, ptr %i, align 4 + %add = add i32 %4, 1 + store i32 %add, ptr %i, align 4 + br label %loop.cond + +loop.exit: ; preds = %loop.cond + %5 = getelementptr inbounds [100 x i32], ptr %a, i64 0, i64 0 + %6 = load i32, ptr %5, align 4 + %sisiext1 = sext i32 %6 to i64 + %7 = getelementptr inbounds [100 x i32], ptr %a, i64 0, i64 %sisiext1 + %8 = load i32, ptr %7, align 4 + ret i32 %8 +} + +define i32 @main(i32 %0, ptr %1) #0 { +entry: + %i = alloca i32, align 4 + %2 = call i32 @puts(ptr @.str.10) + %sisitrunc = trunc i32 %0 to i16 + %3 = call i32 @foo_externFunc(i64 -1, ptr null, i16 %sisitrunc, i8 2) + store i32 0, ptr %i, align 4 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %4 = load i32, ptr %i, align 4 + %gt = icmp ugt i32 10, %4 + br i1 %gt, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + %ptroffset = getelementptr inbounds ptr, ptr %1, i64 3 + %5 = load ptr, ptr %ptroffset, align 8 + %6 = call i32 @puts(ptr %5) + %7 = load i32, ptr %i, align 4 + %add = add i32 %7, 1 + store i32 %add, ptr %i, align 4 + br label %loop.cond + +loop.exit: ; preds = %loop.cond + ret i32 0 +} + +define double @foo_mathFunc(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10, double %11, double %12, double %13, double %14, double %15, double %16) #0 { +entry: + %fadd = fadd double %0, %1 + %fadd1 = fadd double %fadd, %2 + %fadd2 = fadd double %fadd1, %3 + %fadd3 = fadd double %fadd2, %4 + %fadd4 = fadd double %fadd3, %5 + %fadd5 = fadd double %fadd4, %6 + %fadd6 = fadd double %fadd5, %7 + %fadd7 = fadd double %fadd6, %8 + %fadd8 = fadd double %fadd7, %9 + %fadd9 = fadd double %fadd8, %10 + %fadd10 = fadd double %fadd9, %11 + %fadd11 = fadd double %fadd10, %12 + %fadd12 = fadd double %fadd11, %13 + %fadd13 = fadd double %fadd12, %14 + %fadd14 = fadd double %fadd13, %15 + %fadd15 = fadd double %fadd14, %16 + ret double %fadd15 +} + +define void @foo_strcpy(ptr %0, ptr %1) #0 { +entry: + %s1 = alloca ptr, align 8 + %s2 = alloca ptr, align 8 + store ptr %0, ptr %s1, align 8 + store ptr %1, ptr %s2, align 8 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %2 = load ptr, ptr %s1, align 8 + %ptroffset = getelementptr i8, ptr %2, i8 1 + store ptr %ptroffset, ptr %s1, align 8 + %3 = load ptr, ptr %s2, align 8 + %ptroffset1 = getelementptr i8, ptr %3, i8 1 + store ptr %ptroffset1, ptr %s2, align 8 + %4 = load i8, ptr %3, align 1 + store i8 %4, ptr %2, align 1 + %intbool = icmp ne i8 %4, 0 + br i1 %intbool, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + br label %loop.cond + +loop.exit: ; preds = %loop.cond + ret void +} + +define void @foo_strcat(ptr %0, ptr %1) #0 { +entry: + %s1 = alloca ptr, align 8 + %s2 = alloca ptr, align 8 + store ptr %0, ptr %s1, align 8 + store ptr %1, ptr %s2, align 8 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %2 = load ptr, ptr %s1, align 8 + %ptroffset = getelementptr i8, ptr %2, i8 1 + store ptr %ptroffset, ptr %s1, align 8 + %3 = load i8, ptr %2, align 1 + %intbool = icmp ne i8 %3, 0 + br i1 %intbool, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + br label %loop.cond + +loop.exit: ; preds = %loop.cond + %4 = load ptr, ptr %s1, align 8 + %ptroffset1 = getelementptr i8, ptr %4, i8 -1 + store ptr %ptroffset1, ptr %s1, align 8 + br label %loop.cond2 + +loop.cond2: ; preds = %loop.body6, %loop.exit + %5 = load ptr, ptr %s1, align 8 + %ptroffset3 = getelementptr i8, ptr %5, i8 1 + store ptr %ptroffset3, ptr %s1, align 8 + %6 = load ptr, ptr %s2, align 8 + %ptroffset4 = getelementptr i8, ptr %6, i8 1 + store ptr %ptroffset4, ptr %s2, align 8 + %7 = load i8, ptr %6, align 1 + store i8 %7, ptr %5, align 1 + %intbool5 = icmp ne i8 %7, 0 + br i1 %intbool5, label %loop.body6, label %loop.exit7 + +loop.body6: ; preds = %loop.cond2 + br label %loop.cond2 + +loop.exit7: ; preds = %loop.cond2 + ret void +} + +define i32 @foo_strcmp(ptr %0, ptr %1) #0 { +entry: + %s1 = alloca ptr, align 8 + %s2 = alloca ptr, align 8 + store ptr %0, ptr %s1, align 8 + store ptr %1, ptr %s2, align 8 + br label %loop.cond + +loop.cond: ; preds = %loop.body, %entry + %2 = load ptr, ptr %s1, align 8 + %ptroffset = getelementptr i8, ptr %2, i8 1 + store ptr %ptroffset, ptr %s1, align 8 + %3 = load i8, ptr %2, align 1 + %4 = load ptr, ptr %s2, align 8 + %ptroffset1 = getelementptr i8, ptr %4, i8 1 + store ptr %ptroffset1, ptr %s2, align 8 + %5 = load i8, ptr %4, align 1 + %eq = icmp eq i8 %3, %5 + br i1 %eq, label %loop.body, label %loop.exit + +loop.body: ; preds = %loop.cond + br label %loop.cond + +loop.exit: ; preds = %loop.cond + %6 = load ptr, ptr %s1, align 8 + %7 = load i8, ptr %6, align 1 + %zext = zext i8 %7 to i32 + %eq2 = icmp eq i32 0, %zext + br i1 %eq2, label %if.then, label %if.else6 + +if.then: ; preds = %loop.exit + %8 = load ptr, ptr %s2, align 8 + %9 = load i8, ptr %8, align 1 + %zext3 = zext i8 %9 to i32 + %eq4 = icmp eq i32 0, %zext3 + br i1 %eq4, label %if.then5, label %if.else + +if.then5: ; preds = %if.then + ret i32 0 + +if.else: ; preds = %if.then + ret i32 -1 + +if.else6: ; preds = %loop.exit + %10 = load ptr, ptr %s2, align 8 + %11 = load i8, ptr %10, align 1 + %zext7 = zext i8 %11 to i32 + %eq8 = icmp eq i32 0, %zext7 + br i1 %eq8, label %if.then9, label %if.else10 + +if.then9: ; preds = %if.else6 + ret i32 1 + +if.else10: ; preds = %if.else6 + %12 = load ptr, ptr %s1, align 8 + %ptroffset11 = getelementptr i8, ptr %12, i8 -1 + store ptr %ptroffset11, ptr %s1, align 8 + %13 = load i8, ptr %ptroffset11, align 1 + %uisiext = zext i8 %13 to i32 + %14 = load ptr, ptr %s2, align 8 + %ptroffset12 = getelementptr i8, ptr %14, i8 -1 + store ptr %ptroffset12, ptr %s2, align 8 + %15 = load i8, ptr %ptroffset12, align 1 + %uisiext13 = zext i8 %15 to i32 + %sub = sub i32 %uisiext, %uisiext13 + ret i32 %sub +} diff --git a/test/test_suite/compile_time/ct_memberof.c3t b/test/test_suite/compile_time/ct_memberof.c3t index b8b2b4ca7..546e7351a 100644 --- a/test/test_suite/compile_time/ct_memberof.c3t +++ b/test/test_suite/compile_time/ct_memberof.c3t @@ -103,16 +103,14 @@ fn void main() define void @test_hello(i32 %0, double %1, i64 %2, i64 %3, ptr %4, i64 %5) #0 { entry: - %d = alloca [4 x i32], align 4 + %d = alloca [4 x i32], align 8 %args = alloca %"variant[]", align 8 - %6 = getelementptr inbounds { i64, i64 }, ptr %d, i32 0, i32 0 - store i64 %2, ptr %6, align 4 - %7 = getelementptr inbounds { i64, i64 }, ptr %d, i32 0, i32 1 - store i64 %3, ptr %7, align 4 - %8 = getelementptr inbounds { ptr, i64 }, ptr %args, i32 0, i32 0 - store ptr %4, ptr %8, align 8 - %9 = getelementptr inbounds { ptr, i64 }, ptr %args, i32 0, i32 1 - store i64 %5, ptr %9, align 8 + store i64 %2, ptr %d, align 8 + %ptroffset = getelementptr inbounds i64, ptr %d, i64 1 + store i64 %3, ptr %ptroffset, align 8 + store ptr %4, ptr %args, align 8 + %ptroffset1 = getelementptr inbounds i64, ptr %args, i64 1 + store i64 %5, ptr %ptroffset1, align 8 ret void } diff --git a/test/test_suite/compile_time/untyped_conversions.c3t b/test/test_suite/compile_time/untyped_conversions.c3t index ba7d841b5..b90c8daae 100644 --- a/test/test_suite/compile_time/untyped_conversions.c3t +++ b/test/test_suite/compile_time/untyped_conversions.c3t @@ -54,25 +54,24 @@ entry: %retparam = alloca i64, align 8 %varargslots = alloca [3 x %variant], align 16 store i64 %0, ptr %a, align 4 - %4 = getelementptr inbounds { ptr, i64 }, ptr %b, i32 0, i32 0 - store ptr %1, ptr %4, align 8 - %5 = getelementptr inbounds { ptr, i64 }, ptr %b, i32 0, i32 1 - store i64 %2, ptr %5, align 8 + store ptr %1, ptr %b, align 8 + %ptroffset = getelementptr inbounds i64, ptr %b, i64 1 + store i64 %2, ptr %ptroffset, align 8 store double %3, ptr %c, align 8 - %6 = insertvalue %variant undef, ptr %a, 0 - %7 = insertvalue %variant %6, i64 ptrtoint (ptr @"ct$a2$int" to i64), 1 - %8 = getelementptr inbounds [3 x %variant], ptr %varargslots, i64 0, i64 0 - store %variant %7, ptr %8, align 16 - %9 = insertvalue %variant undef, ptr %b, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (ptr @"ct$sa$int" to i64), 1 - %11 = getelementptr inbounds [3 x %variant], ptr %varargslots, i64 0, i64 1 - store %variant %10, ptr %11, align 16 - %12 = insertvalue %variant undef, ptr %c, 0 - %13 = insertvalue %variant %12, i64 ptrtoint (ptr @"ct$v2$int" to i64), 1 - %14 = getelementptr inbounds [3 x %variant], ptr %varargslots, i64 0, i64 2 - store %variant %13, ptr %14, align 16 - %15 = call i64 @std_io_printfn(ptr %retparam, ptr @.str, i64 8, ptr %varargslots, i64 3) - %not_err = icmp eq i64 %15, 0 + %4 = insertvalue %variant undef, ptr %a, 0 + %5 = insertvalue %variant %4, i64 ptrtoint (ptr @"ct$a2$int" to i64), 1 + %6 = getelementptr inbounds [3 x %variant], ptr %varargslots, i64 0, i64 0 + store %variant %5, ptr %6, align 16 + %7 = insertvalue %variant undef, ptr %b, 0 + %8 = insertvalue %variant %7, i64 ptrtoint (ptr @"ct$sa$int" to i64), 1 + %9 = getelementptr inbounds [3 x %variant], ptr %varargslots, i64 0, i64 1 + store %variant %8, ptr %9, align 16 + %10 = insertvalue %variant undef, ptr %c, 0 + %11 = insertvalue %variant %10, i64 ptrtoint (ptr @"ct$v2$int" to i64), 1 + %12 = getelementptr inbounds [3 x %variant], ptr %varargslots, i64 0, i64 2 + store %variant %11, ptr %12, align 16 + %13 = call i64 @std_io_printfn(ptr %retparam, ptr @.str, i64 8, ptr %varargslots, i64 3) + %not_err = icmp eq i64 %13, 0 br i1 %not_err, label %after_check, label %voiderr after_check: ; preds = %entry diff --git a/test/test_suite/enumerations/enum_associated_values_other.c3t b/test/test_suite/enumerations/enum_associated_values_other.c3t index 7c6d45c7b..4f0b08d9e 100644 --- a/test/test_suite/enumerations/enum_associated_values_other.c3t +++ b/test/test_suite/enumerations/enum_associated_values_other.c3t @@ -59,22 +59,21 @@ entry: %z = alloca %"char[]", align 8 %retparam = alloca i64, align 8 %varargslots = alloca [1 x %variant], align 16 - %2 = getelementptr inbounds { ptr, i64 }, ptr %args, i32 0, i32 0 - store ptr %0, ptr %2, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %args, i32 0, i32 1 - store i64 %1, ptr %3, align 8 + store ptr %0, ptr %args, align 8 + %ptroffset = getelementptr inbounds i64, ptr %args, i64 1 + store i64 %1, ptr %ptroffset, align 8 store i64 ptrtoint (ptr @"ct$abc_Abc" to i64), ptr %y, align 8 store ptr @abc_dabc, ptr %x, align 8 store i32 1, ptr %a, align 4 - %4 = load i32, ptr %a, align 4 - %5 = getelementptr inbounds [2 x %"char[]"], ptr @"abc_Foo$val", i32 0, i32 %4 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %z, ptr align 8 %5, i32 16, i1 false) - %6 = insertvalue %variant undef, ptr %z, 0 - %7 = insertvalue %variant %6, i64 ptrtoint (ptr @"ct$sa$char" to i64), 1 - %8 = getelementptr inbounds [1 x %variant], ptr %varargslots, i64 0, i64 0 - store %variant %7, ptr %8, align 16 - %9 = call i64 @std_io_printfn(ptr %retparam, ptr @.str.2, i64 2, ptr %varargslots, i64 1) - %not_err = icmp eq i64 %9, 0 + %2 = load i32, ptr %a, align 4 + %3 = getelementptr inbounds [2 x %"char[]"], ptr @"abc_Foo$val", i32 0, i32 %2 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %z, ptr align 8 %3, i32 16, i1 false) + %4 = insertvalue %variant undef, ptr %z, 0 + %5 = insertvalue %variant %4, i64 ptrtoint (ptr @"ct$sa$char" to i64), 1 + %6 = getelementptr inbounds [1 x %variant], ptr %varargslots, i64 0, i64 0 + store %variant %5, ptr %6, align 16 + %7 = call i64 @std_io_printfn(ptr %retparam, ptr @.str.2, i64 2, ptr %varargslots, i64 1) + %not_err = icmp eq i64 %7, 0 br i1 %not_err, label %after_check, label %voiderr after_check: ; preds = %entry diff --git a/test/test_suite/errors/error_regression_2.c3t b/test/test_suite/errors/error_regression_2.c3t index 5021b89c5..368217384 100644 --- a/test/test_suite/errors/error_regression_2.c3t +++ b/test/test_suite/errors/error_regression_2.c3t @@ -191,69 +191,67 @@ entry: %len = alloca i64, align 8 %needle_len = alloca i64, align 8 %i = alloca i64, align 8 - %4 = getelementptr inbounds { ptr, i64 }, ptr %haystack, i32 0, i32 0 - store ptr %0, ptr %4, align 8 - %5 = getelementptr inbounds { ptr, i64 }, ptr %haystack, i32 0, i32 1 - store i64 %1, ptr %5, align 8 - %6 = getelementptr inbounds { ptr, i64 }, ptr %needle, i32 0, i32 0 - store ptr %2, ptr %6, align 8 - %7 = getelementptr inbounds { ptr, i64 }, ptr %needle, i32 0, i32 1 - store i64 %3, ptr %7, align 8 - %8 = getelementptr inbounds %"char[]", ptr %haystack, i32 0, i32 1 - %9 = load i64, ptr %8, align 8 - store i64 %9, ptr %len, align 8 - %10 = getelementptr inbounds %"char[]", ptr %needle, i32 0, i32 1 - %11 = load i64, ptr %10, align 8 - store i64 %11, ptr %needle_len, align 8 - %12 = load i64, ptr %len, align 8 - %13 = load i64, ptr %needle_len, align 8 - %lt = icmp ult i64 %12, %13 + store ptr %0, ptr %haystack, align 8 + %ptroffset = getelementptr inbounds i64, ptr %haystack, i64 1 + store i64 %1, ptr %ptroffset, align 8 + store ptr %2, ptr %needle, align 8 + %ptroffset1 = getelementptr inbounds i64, ptr %needle, i64 1 + store i64 %3, ptr %ptroffset1, align 8 + %4 = getelementptr inbounds %"char[]", ptr %haystack, i32 0, i32 1 + %5 = load i64, ptr %4, align 8 + store i64 %5, ptr %len, align 8 + %6 = getelementptr inbounds %"char[]", ptr %needle, i32 0, i32 1 + %7 = load i64, ptr %6, align 8 + store i64 %7, ptr %needle_len, align 8 + %8 = load i64, ptr %len, align 8 + %9 = load i64, ptr %needle_len, align 8 + %lt = icmp ult i64 %8, %9 br i1 %lt, label %if.then, label %if.exit if.then: ; preds = %entry ret i8 0 if.exit: ; preds = %entry - %14 = load i64, ptr %needle_len, align 8 - %not = icmp eq i64 %14, 0 - br i1 %not, label %if.then1, label %if.exit2 + %10 = load i64, ptr %needle_len, align 8 + %not = icmp eq i64 %10, 0 + br i1 %not, label %if.then2, label %if.exit3 -if.then1: ; preds = %if.exit +if.then2: ; preds = %if.exit ret i8 1 -if.exit2: ; preds = %if.exit - %15 = load i64, ptr %len, align 8 - %16 = load i64, ptr %needle_len, align 8 - %sub = sub i64 %16, 1 - %sub3 = sub i64 %15, %sub - store i64 %sub3, ptr %len, align 8 +if.exit3: ; preds = %if.exit + %11 = load i64, ptr %len, align 8 + %12 = load i64, ptr %needle_len, align 8 + %sub = sub i64 %12, 1 + %sub4 = sub i64 %11, %sub + store i64 %sub4, ptr %len, align 8 store i64 0, ptr %i, align 8 br label %loop.cond -loop.cond: ; preds = %if.exit6, %if.exit2 - %17 = load i64, ptr %i, align 8 - %18 = load i64, ptr %len, align 8 - %lt4 = icmp ult i64 %17, %18 - br i1 %lt4, label %loop.body, label %loop.exit +loop.cond: ; preds = %if.exit8, %if.exit3 + %13 = load i64, ptr %i, align 8 + %14 = load i64, ptr %len, align 8 + %lt5 = icmp ult i64 %13, %14 + br i1 %lt5, label %loop.body, label %loop.exit loop.body: ; preds = %loop.cond - %19 = getelementptr inbounds %"char[]", ptr %haystack, i32 0, i32 0 - %20 = load ptr, ptr %19, align 8 - %21 = load i64, ptr %i, align 8 - %ptroffset = getelementptr inbounds i8, ptr %20, i64 %21 - %22 = getelementptr inbounds %"char[]", ptr %needle, i32 0, i32 0 - %23 = load ptr, ptr %22, align 8 - %24 = load i64, ptr %needle_len, align 8 - %25 = call i32 @memcmp(ptr %ptroffset, ptr %23, i64 %24) - %eq = icmp eq i32 %25, 0 - br i1 %eq, label %if.then5, label %if.exit6 + %15 = getelementptr inbounds %"char[]", ptr %haystack, i32 0, i32 0 + %16 = load ptr, ptr %15, align 8 + %17 = load i64, ptr %i, align 8 + %ptroffset6 = getelementptr inbounds i8, ptr %16, i64 %17 + %18 = getelementptr inbounds %"char[]", ptr %needle, i32 0, i32 0 + %19 = load ptr, ptr %18, align 8 + %20 = load i64, ptr %needle_len, align 8 + %21 = call i32 @memcmp(ptr %ptroffset6, ptr %19, i64 %20) + %eq = icmp eq i32 %21, 0 + br i1 %eq, label %if.then7, label %if.exit8 -if.then5: ; preds = %loop.body +if.then7: ; preds = %loop.body ret i8 1 -if.exit6: ; preds = %loop.body - %26 = load i64, ptr %i, align 8 - %add = add i64 %26, 1 +if.exit8: ; preds = %loop.body + %22 = load i64, ptr %i, align 8 + %add = add i64 %22, 1 store i64 %add, ptr %i, align 8 br label %loop.cond @@ -291,56 +289,55 @@ entry: %literal47 = alloca %Head, align 8 %error_var48 = alloca i64, align 8 %value49 = alloca %"char[]", align 8 - %temp50 = alloca ptr, align 8 - %temp56 = alloca ptr, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %url, i32 0, i32 0 - store ptr %1, ptr %3, align 8 - %4 = getelementptr inbounds { ptr, i64 }, ptr %url, i32 0, i32 1 - store i64 %2, ptr %4, align 8 - %5 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %lo = load ptr, ptr %5, align 8 - %6 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %hi = load i64, ptr %6, align 8 - %7 = call i8 @test_contains(ptr %lo, i64 %hi, ptr @.str, i64 4) - %8 = trunc i8 %7 to i1 - br i1 %8, label %if.then, label %if.exit + %temp51 = alloca ptr, align 8 + %temp57 = alloca ptr, align 8 + store ptr %1, ptr %url, align 8 + %ptroffset = getelementptr inbounds i64, ptr %url, i64 1 + store i64 %2, ptr %ptroffset, align 8 + %3 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %lo = load ptr, ptr %3, align 8 + %4 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %hi = load i64, ptr %4, align 8 + %5 = call i8 @test_contains(ptr %lo, i64 %hi, ptr @.str, i64 4) + %6 = trunc i8 %5 to i1 + br i1 %6, label %if.then, label %if.exit if.then: ; preds = %entry ret i64 ptrtoint (ptr @"test_ReadError$BAD_READ" to i64) if.exit: ; preds = %entry - %9 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %lo1 = load ptr, ptr %9, align 8 - %10 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %hi2 = load i64, ptr %10, align 8 - %11 = call i8 @test_contains(ptr %lo1, i64 %hi2, ptr @.str.3, i64 12) - %12 = trunc i8 %11 to i1 - br i1 %12, label %if.then3, label %if.exit4 + %7 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %lo1 = load ptr, ptr %7, align 8 + %8 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %hi2 = load i64, ptr %8, align 8 + %9 = call i8 @test_contains(ptr %lo1, i64 %hi2, ptr @.str.3, i64 12) + %10 = trunc i8 %9 to i1 + br i1 %10, label %if.then3, label %if.exit4 if.then3: ; preds = %if.exit - %13 = getelementptr inbounds %Doc, ptr %literal, i32 0, i32 0 - store ptr null, ptr %13, align 8 + %11 = getelementptr inbounds %Doc, ptr %literal, i32 0, i32 0 + store ptr null, ptr %11, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal, i32 8, i1 false) ret i64 0 if.exit4: ; preds = %if.exit - %14 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %lo5 = load ptr, ptr %14, align 8 - %15 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %hi6 = load i64, ptr %15, align 8 - %16 = call i8 @test_contains(ptr %lo5, i64 %hi6, ptr @.str.4, i64 13) - %17 = trunc i8 %16 to i1 - br i1 %17, label %if.then7, label %if.exit13 + %12 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %lo5 = load ptr, ptr %12, align 8 + %13 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %hi6 = load i64, ptr %13, align 8 + %14 = call i8 @test_contains(ptr %lo5, i64 %hi6, ptr @.str.4, i64 13) + %15 = trunc i8 %14 to i1 + br i1 %15, label %if.then7, label %if.exit13 if.then7: ; preds = %if.exit4 - %18 = getelementptr inbounds %Doc, ptr %literal9, i32 0, i32 0 - %19 = getelementptr inbounds %Head, ptr %literal10, i32 0, i32 0 - store ptr null, ptr %19, align 8 + %16 = getelementptr inbounds %Doc, ptr %literal9, i32 0, i32 0 + %17 = getelementptr inbounds %Head, ptr %literal10, i32 0, i32 0 + store ptr null, ptr %17, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %value, ptr align 8 %literal10, i32 8, i1 false) - %20 = call ptr @std_core_mem_malloc(i64 8) #2 - store ptr %20, ptr %temp, align 8 - %21 = load ptr, ptr %temp, align 8 - %not = icmp eq ptr %21, null + %18 = call ptr @std_core_mem_malloc(i64 8) #2 + store ptr %18, ptr %temp, align 8 + %19 = load ptr, ptr %temp, align 8 + %not = icmp eq ptr %19, null br i1 %not, label %if.then11, label %if.exit12 if.then11: ; preds = %if.then7 @@ -348,38 +345,38 @@ if.then11: ; preds = %if.then7 br label %guard_block if.exit12: ; preds = %if.then7 - %22 = load ptr, ptr %temp, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %22, ptr align 8 %value, i32 8, i1 false) + %20 = load ptr, ptr %temp, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %20, ptr align 8 %value, i32 8, i1 false) br label %noerr_block guard_block: ; preds = %if.then11 - %23 = load i64, ptr %error_var, align 8 - ret i64 %23 + %21 = load i64, ptr %error_var, align 8 + ret i64 %21 noerr_block: ; preds = %if.exit12 - %24 = load ptr, ptr %temp, align 8 - store ptr %24, ptr %18, align 8 + %22 = load ptr, ptr %temp, align 8 + store ptr %22, ptr %16, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal9, i32 8, i1 false) ret i64 0 if.exit13: ; preds = %if.exit4 - %25 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %lo14 = load ptr, ptr %25, align 8 - %26 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %hi15 = load i64, ptr %26, align 8 - %27 = call i8 @test_contains(ptr %lo14, i64 %hi15, ptr @.str.5, i64 11) - %28 = trunc i8 %27 to i1 - br i1 %28, label %if.then16, label %if.exit36 + %23 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %lo14 = load ptr, ptr %23, align 8 + %24 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %hi15 = load i64, ptr %24, align 8 + %25 = call i8 @test_contains(ptr %lo14, i64 %hi15, ptr @.str.5, i64 11) + %26 = trunc i8 %25 to i1 + br i1 %26, label %if.then16, label %if.exit36 if.then16: ; preds = %if.exit13 - %29 = getelementptr inbounds %Doc, ptr %literal18, i32 0, i32 0 + %27 = getelementptr inbounds %Doc, ptr %literal18, i32 0, i32 0 store ptr null, ptr %literal21, align 8 - %30 = getelementptr inbounds %Head, ptr %literal21, i32 0, i32 0 + %28 = getelementptr inbounds %Head, ptr %literal21, i32 0, i32 0 store %"char[]" zeroinitializer, ptr %value23, align 8 - %31 = call ptr @std_core_mem_malloc(i64 16) #2 - store ptr %31, ptr %temp24, align 8 - %32 = load ptr, ptr %temp24, align 8 - %not25 = icmp eq ptr %32, null + %29 = call ptr @std_core_mem_malloc(i64 16) #2 + store ptr %29, ptr %temp24, align 8 + %30 = load ptr, ptr %temp24, align 8 + %not25 = icmp eq ptr %30, null br i1 %not25, label %if.then26, label %if.exit27 if.then26: ; preds = %if.then16 @@ -387,22 +384,22 @@ if.then26: ; preds = %if.then16 br label %guard_block28 if.exit27: ; preds = %if.then16 - %33 = load ptr, ptr %temp24, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %33, ptr align 8 %value23, i32 16, i1 false) + %31 = load ptr, ptr %temp24, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %31, ptr align 8 %value23, i32 16, i1 false) br label %noerr_block29 guard_block28: ; preds = %if.then26 - %34 = load i64, ptr %error_var22, align 8 - ret i64 %34 + %32 = load i64, ptr %error_var22, align 8 + ret i64 %32 noerr_block29: ; preds = %if.exit27 - %35 = load ptr, ptr %temp24, align 8 - store ptr %35, ptr %30, align 8 + %33 = load ptr, ptr %temp24, align 8 + store ptr %33, ptr %28, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %value20, ptr align 8 %literal21, i32 8, i1 false) - %36 = call ptr @std_core_mem_malloc(i64 8) #2 - store ptr %36, ptr %temp30, align 8 - %37 = load ptr, ptr %temp30, align 8 - %not31 = icmp eq ptr %37, null + %34 = call ptr @std_core_mem_malloc(i64 8) #2 + store ptr %34, ptr %temp30, align 8 + %35 = load ptr, ptr %temp30, align 8 + %not31 = icmp eq ptr %35, null br i1 %not31, label %if.then32, label %if.exit33 if.then32: ; preds = %noerr_block29 @@ -410,109 +407,109 @@ if.then32: ; preds = %noerr_block29 br label %guard_block34 if.exit33: ; preds = %noerr_block29 - %38 = load ptr, ptr %temp30, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %38, ptr align 8 %value20, i32 8, i1 false) + %36 = load ptr, ptr %temp30, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %36, ptr align 8 %value20, i32 8, i1 false) br label %noerr_block35 guard_block34: ; preds = %if.then32 - %39 = load i64, ptr %error_var19, align 8 - ret i64 %39 + %37 = load i64, ptr %error_var19, align 8 + ret i64 %37 noerr_block35: ; preds = %if.exit33 - %40 = load ptr, ptr %temp30, align 8 - store ptr %40, ptr %29, align 8 + %38 = load ptr, ptr %temp30, align 8 + store ptr %38, ptr %27, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal18, i32 8, i1 false) ret i64 0 if.exit36: ; preds = %if.exit13 - %41 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %42 = load i64, ptr %41, align 8 - %uisitrunc = trunc i64 %42 to i32 - %43 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %44 = load ptr, ptr %43, align 8 - %45 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr null, i64 0, ptr @.str.7, i32 %uisitrunc, ptr %44) - store i32 %45, ptr %len, align 4 - %46 = load i32, ptr %len, align 4 - %siuiext = sext i32 %46 to i64 + %39 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %40 = load i64, ptr %39, align 8 + %uisitrunc = trunc i64 %40 to i32 + %41 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %42 = load ptr, ptr %41, align 8 + %43 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr null, i64 0, ptr @.str.7, i32 %uisitrunc, ptr %42) + store i32 %43, ptr %len, align 4 + %44 = load i32, ptr %len, align 4 + %siuiext = sext i32 %44 to i64 %add = add i64 %siuiext, 1 - %47 = call ptr @std_core_mem_malloc(i64 %add) #2 - store ptr %47, ptr %str, align 8 - %48 = load ptr, ptr %str, align 8 - %not37 = icmp eq ptr %48, null + %45 = call ptr @std_core_mem_malloc(i64 %add) #2 + store ptr %45, ptr %str, align 8 + %46 = load ptr, ptr %str, align 8 + %not37 = icmp eq ptr %46, null br i1 %not37, label %if.then38, label %if.exit39 if.then38: ; preds = %if.exit36 ret i64 ptrtoint (ptr @"test_ReadError$OUT_OF_MEMORY" to i64) if.exit39: ; preds = %if.exit36 - %49 = load ptr, ptr %str, align 8 - %50 = load i32, ptr %len, align 4 - %siuiext40 = sext i32 %50 to i64 + %47 = load ptr, ptr %str, align 8 + %48 = load i32, ptr %len, align 4 + %siuiext40 = sext i32 %48 to i64 %add41 = add i64 %siuiext40, 1 - %51 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %52 = load i64, ptr %51, align 8 - %uisitrunc42 = trunc i64 %52 to i32 - %53 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %54 = load ptr, ptr %53, align 8 - %55 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr %49, i64 %add41, ptr @.str.8, i32 %uisitrunc42, ptr %54) - %56 = getelementptr inbounds %Doc, ptr %literal44, i32 0, i32 0 + %49 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %50 = load i64, ptr %49, align 8 + %uisitrunc42 = trunc i64 %50 to i32 + %51 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %52 = load ptr, ptr %51, align 8 + %53 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr %47, i64 %add41, ptr @.str.8, i32 %uisitrunc42, ptr %52) + %54 = getelementptr inbounds %Doc, ptr %literal44, i32 0, i32 0 store ptr null, ptr %literal47, align 8 - %57 = getelementptr inbounds %Head, ptr %literal47, i32 0, i32 0 - %58 = load ptr, ptr %str, align 8 - %59 = load i32, ptr %len, align 4 - %sub = sub i32 %59, 1 + %55 = getelementptr inbounds %Head, ptr %literal47, i32 0, i32 0 + %56 = load ptr, ptr %str, align 8 + %57 = load i32, ptr %len, align 4 + %sub = sub i32 %57, 1 %sisiext = sext i32 %sub to i64 - %60 = add i64 %sisiext, 1 - %size = sub i64 %60, 0 - %ptroffset = getelementptr inbounds i8, ptr %58, i64 0 - %61 = insertvalue %"char[]" undef, ptr %ptroffset, 0 - %62 = insertvalue %"char[]" %61, i64 %size, 1 - store %"char[]" %62, ptr %value49, align 8 - %63 = call ptr @std_core_mem_malloc(i64 16) #2 - store ptr %63, ptr %temp50, align 8 - %64 = load ptr, ptr %temp50, align 8 - %not51 = icmp eq ptr %64, null - br i1 %not51, label %if.then52, label %if.exit53 + %58 = add i64 %sisiext, 1 + %size = sub i64 %58, 0 + %ptroffset50 = getelementptr inbounds i8, ptr %56, i64 0 + %59 = insertvalue %"char[]" undef, ptr %ptroffset50, 0 + %60 = insertvalue %"char[]" %59, i64 %size, 1 + store %"char[]" %60, ptr %value49, align 8 + %61 = call ptr @std_core_mem_malloc(i64 16) #2 + store ptr %61, ptr %temp51, align 8 + %62 = load ptr, ptr %temp51, align 8 + %not52 = icmp eq ptr %62, null + br i1 %not52, label %if.then53, label %if.exit54 -if.then52: ; preds = %if.exit39 +if.then53: ; preds = %if.exit39 store i64 ptrtoint (ptr @"test_ReadError$OUT_OF_MEMORY" to i64), ptr %error_var48, align 8 - br label %guard_block54 + br label %guard_block55 -if.exit53: ; preds = %if.exit39 - %65 = load ptr, ptr %temp50, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %65, ptr align 8 %value49, i32 16, i1 false) - br label %noerr_block55 +if.exit54: ; preds = %if.exit39 + %63 = load ptr, ptr %temp51, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %63, ptr align 8 %value49, i32 16, i1 false) + br label %noerr_block56 -guard_block54: ; preds = %if.then52 - %66 = load i64, ptr %error_var48, align 8 - ret i64 %66 +guard_block55: ; preds = %if.then53 + %64 = load i64, ptr %error_var48, align 8 + ret i64 %64 -noerr_block55: ; preds = %if.exit53 - %67 = load ptr, ptr %temp50, align 8 - store ptr %67, ptr %57, align 8 +noerr_block56: ; preds = %if.exit54 + %65 = load ptr, ptr %temp51, align 8 + store ptr %65, ptr %55, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %value46, ptr align 8 %literal47, i32 8, i1 false) - %68 = call ptr @std_core_mem_malloc(i64 8) #2 - store ptr %68, ptr %temp56, align 8 - %69 = load ptr, ptr %temp56, align 8 - %not57 = icmp eq ptr %69, null - br i1 %not57, label %if.then58, label %if.exit59 + %66 = call ptr @std_core_mem_malloc(i64 8) #2 + store ptr %66, ptr %temp57, align 8 + %67 = load ptr, ptr %temp57, align 8 + %not58 = icmp eq ptr %67, null + br i1 %not58, label %if.then59, label %if.exit60 -if.then58: ; preds = %noerr_block55 +if.then59: ; preds = %noerr_block56 store i64 ptrtoint (ptr @"test_ReadError$OUT_OF_MEMORY" to i64), ptr %error_var45, align 8 - br label %guard_block60 + br label %guard_block61 -if.exit59: ; preds = %noerr_block55 - %70 = load ptr, ptr %temp56, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %70, ptr align 8 %value46, i32 8, i1 false) - br label %noerr_block61 +if.exit60: ; preds = %noerr_block56 + %68 = load ptr, ptr %temp57, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %68, ptr align 8 %value46, i32 8, i1 false) + br label %noerr_block62 -guard_block60: ; preds = %if.then58 - %71 = load i64, ptr %error_var45, align 8 - ret i64 %71 +guard_block61: ; preds = %if.then59 + %69 = load i64, ptr %error_var45, align 8 + ret i64 %69 -noerr_block61: ; preds = %if.exit59 - %72 = load ptr, ptr %temp56, align 8 - store ptr %72, ptr %56, align 8 +noerr_block62: ; preds = %if.exit60 + %70 = load ptr, ptr %temp57, align 8 + store ptr %70, ptr %54, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal44, i32 8, i1 false) ret i64 0 } @@ -522,35 +519,34 @@ define { ptr, i8 } @test_buildSummary(ptr %0) #0 { entry: %doc = alloca %Doc, align 8 %literal = alloca %Summary, align 8 - %1 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 - store ptr %0, ptr %1, align 8 - %2 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 0 - store ptr null, ptr %2, align 8 - %3 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 1 - store i8 0, ptr %3, align 8 - %4 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 0 - %5 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 - %6 = load ptr, ptr %5, align 8 - %ptrbool = icmp ne ptr %6, null + store ptr %0, ptr %doc, align 8 + %1 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 0 + store ptr null, ptr %1, align 8 + %2 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 1 + store i8 0, ptr %2, align 8 + %3 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 0 + %4 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 + %5 = load ptr, ptr %4, align 8 + %ptrbool = icmp ne ptr %5, null br i1 %ptrbool, label %cond.lhs, label %cond.rhs cond.lhs: ; preds = %entry - %7 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 - %8 = load ptr, ptr %7, align 8 - %9 = getelementptr inbounds %Head, ptr %8, i32 0, i32 0 - %10 = load ptr, ptr %9, align 8 + %6 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 + %7 = load ptr, ptr %6, align 8 + %8 = getelementptr inbounds %Head, ptr %7, i32 0, i32 0 + %9 = load ptr, ptr %8, align 8 br label %cond.phi cond.rhs: ; preds = %entry br label %cond.phi cond.phi: ; preds = %cond.rhs, %cond.lhs - %val = phi ptr [ %10, %cond.lhs ], [ null, %cond.rhs ] - store ptr %val, ptr %4, align 8 - %11 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 1 - store i8 1, ptr %11, align 8 - %12 = load { ptr, i8 }, ptr %literal, align 8 - ret { ptr, i8 } %12 + %val = phi ptr [ %9, %cond.lhs ], [ null, %cond.rhs ] + store ptr %val, ptr %3, align 8 + %10 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 1 + store i8 1, ptr %10, align 8 + %11 = load { ptr, i8 }, ptr %literal, align 8 + ret { ptr, i8 } %11 } ; Function Attrs: nounwind @@ -561,39 +557,37 @@ entry: %result = alloca %Summary, align 8 %literal = alloca %Summary, align 8 %taddr = alloca %Summary, align 8 - %2 = getelementptr inbounds { ptr, i64 }, ptr %url, i32 0, i32 0 - store ptr %0, ptr %2, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %url, i32 0, i32 1 - store i64 %1, ptr %3, align 8 - %4 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %lo = load ptr, ptr %4, align 8 - %5 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %hi = load i64, ptr %5, align 8 - %6 = call i64 @test_readDoc(ptr %retparam, ptr %lo, i64 %hi) - %not_err = icmp eq i64 %6, 0 + store ptr %0, ptr %url, align 8 + %ptroffset = getelementptr inbounds i64, ptr %url, i64 1 + store i64 %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %lo = load ptr, ptr %2, align 8 + %3 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %hi = load i64, ptr %3, align 8 + %4 = call i64 @test_readDoc(ptr %retparam, ptr %lo, i64 %hi) + %not_err = icmp eq i64 %4, 0 br i1 %not_err, label %after_check, label %else_block after_check: ; preds = %entry - %7 = getelementptr inbounds %Doc, ptr %retparam, i32 0, i32 0 - %8 = load ptr, ptr %7, align 8 - %9 = call { ptr, i8 } @test_buildSummary(ptr %8) - store { ptr, i8 } %9, ptr %result, align 8 - %10 = load %Summary, ptr %result, align 8 + %5 = load ptr, ptr %retparam, align 8 + %6 = call { ptr, i8 } @test_buildSummary(ptr %5) + store { ptr, i8 } %6, ptr %result, align 8 + %7 = load %Summary, ptr %result, align 8 br label %phi_block else_block: ; preds = %entry - %11 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 0 - store ptr null, ptr %11, align 8 - %12 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 1 - store i8 0, ptr %12, align 8 - %13 = load %Summary, ptr %literal, align 8 + %8 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 0 + store ptr null, ptr %8, align 8 + %9 = getelementptr inbounds %Summary, ptr %literal, i32 0, i32 1 + store i8 0, ptr %9, align 8 + %10 = load %Summary, ptr %literal, align 8 br label %phi_block phi_block: ; preds = %else_block, %after_check - %val = phi %Summary [ %10, %after_check ], [ %13, %else_block ] + %val = phi %Summary [ %7, %after_check ], [ %10, %else_block ] store %Summary %val, ptr %taddr, align 8 - %14 = load { ptr, i8 }, ptr %taddr, align 8 - ret { ptr, i8 } %14 + %11 = load { ptr, i8 }, ptr %taddr, align 8 + ret { ptr, i8 } %11 } ; Function Attrs: nounwind @@ -602,36 +596,35 @@ entry: %doc = alloca %Doc, align 8 %head = alloca ptr, align 8 %reterr = alloca i64, align 8 + store ptr %1, ptr %doc, align 8 %2 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 - store ptr %1, ptr %2, align 8 - %3 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 - %4 = load ptr, ptr %3, align 8 - %not = icmp eq ptr %4, null + %3 = load ptr, ptr %2, align 8 + %not = icmp eq ptr %3, null br i1 %not, label %if.then, label %if.exit if.then: ; preds = %entry ret i64 ptrtoint (ptr @"test_TitleResult$TITLE_MISSING" to i64) if.exit: ; preds = %entry - %5 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 - %6 = load ptr, ptr %5, align 8 - %7 = getelementptr inbounds %Head, ptr %6, i32 0, i32 0 - %8 = load ptr, ptr %7, align 8 - store ptr %8, ptr %head, align 8 - %9 = load ptr, ptr %head, align 8 - %not1 = icmp eq ptr %9, null + %4 = getelementptr inbounds %Doc, ptr %doc, i32 0, i32 0 + %5 = load ptr, ptr %4, align 8 + %6 = getelementptr inbounds %Head, ptr %5, i32 0, i32 0 + %7 = load ptr, ptr %6, align 8 + store ptr %7, ptr %head, align 8 + %8 = load ptr, ptr %head, align 8 + %not1 = icmp eq ptr %8, null br i1 %not1, label %if.then2, label %if.exit3 if.then2: ; preds = %if.exit ret i64 ptrtoint (ptr @"test_TitleResult$TITLE_MISSING" to i64) if.exit3: ; preds = %if.exit - %10 = load ptr, ptr %head, align 8 - %11 = getelementptr inbounds %"char[]", ptr %10, i32 0, i32 1 - %12 = load i64, ptr %11, align 8 - %lt = icmp ult i64 0, %12 - %13 = zext i1 %lt to i8 - store i8 %13, ptr %0, align 1 + %9 = load ptr, ptr %head, align 8 + %10 = getelementptr inbounds %"char[]", ptr %9, i32 0, i32 1 + %11 = load i64, ptr %10, align 8 + %lt = icmp ult i64 0, %11 + %12 = zext i1 %lt to i8 + store i8 %12, ptr %0, align 1 ret i64 0 } @@ -642,41 +635,39 @@ entry: %reterr = alloca i64, align 8 %retparam = alloca i8, align 1 %retparam1 = alloca %Doc, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %url, i32 0, i32 0 - store ptr %1, ptr %3, align 8 - %4 = getelementptr inbounds { ptr, i64 }, ptr %url, i32 0, i32 1 - store i64 %2, ptr %4, align 8 - %5 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %lo = load ptr, ptr %5, align 8 - %6 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %hi = load i64, ptr %6, align 8 - %7 = call i64 @test_readDoc(ptr %retparam1, ptr %lo, i64 %hi) - %not_err = icmp eq i64 %7, 0 + store ptr %1, ptr %url, align 8 + %ptroffset = getelementptr inbounds i64, ptr %url, i64 1 + store i64 %2, ptr %ptroffset, align 8 + %3 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %lo = load ptr, ptr %3, align 8 + %4 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %hi = load i64, ptr %4, align 8 + %5 = call i64 @test_readDoc(ptr %retparam1, ptr %lo, i64 %hi) + %not_err = icmp eq i64 %5, 0 br i1 %not_err, label %after_check, label %assign_optional assign_optional: ; preds = %entry - store i64 %7, ptr %reterr, align 8 + store i64 %5, ptr %reterr, align 8 br label %err_retblock after_check: ; preds = %entry - %8 = getelementptr inbounds %Doc, ptr %retparam1, i32 0, i32 0 - %9 = load ptr, ptr %8, align 8 - %10 = call i64 @test_isTitleNonEmpty(ptr %retparam, ptr %9) - %not_err2 = icmp eq i64 %10, 0 + %6 = load ptr, ptr %retparam1, align 8 + %7 = call i64 @test_isTitleNonEmpty(ptr %retparam, ptr %6) + %not_err2 = icmp eq i64 %7, 0 br i1 %not_err2, label %after_check4, label %assign_optional3 assign_optional3: ; preds = %after_check - store i64 %10, ptr %reterr, align 8 + store i64 %7, ptr %reterr, align 8 br label %err_retblock after_check4: ; preds = %after_check - %11 = load i8, ptr %retparam, align 1 - store i8 %11, ptr %0, align 1 + %8 = load i8, ptr %retparam, align 1 + store i8 %8, ptr %0, align 1 ret i64 0 err_retblock: ; preds = %assign_optional3, %assign_optional - %12 = load i64, ptr %reterr, align 8 - ret i64 %12 + %9 = load i64, ptr %reterr, align 8 + ret i64 %9 } ; Function Attrs: nounwind diff --git a/test/test_suite/functions/test_regression.c3t b/test/test_suite/functions/test_regression.c3t index ac9fa1c8f..828bd976e 100644 --- a/test/test_suite/functions/test_regression.c3t +++ b/test/test_suite/functions/test_regression.c3t @@ -234,323 +234,319 @@ fn Type getValue(Blob blob) /* #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, ptr } - %Foo = type { i32, i32 } +%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, 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 +@"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 4 - %3 = call i32 (ptr, ...) @printf(ptr @.str.21, i32 %2) - ret void - } +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 4 + %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 4 - %add = add i32 %3, 1 - store i32 %add, ptr %2, align 4 - ret i32 %add - } +; 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 4 + %add = add i32 %3, 1 + store i32 %add, ptr %2, align 4 + ret i32 %add +} - ; Function Attrs: nounwind - declare i32 @printf(ptr, ...) #0 +; 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 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_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: - %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 %de, ptr align 4 @.__const, i32 12, i1 false) - call void @llvm.memcpy.p0.p0.i32(ptr align 4 %c, ptr align 4 %1, 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_helo(double %0, ptr byval(%Bobo) align 8 %1) #0 { +entry: + %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 %de, ptr align 4 @.__const, i32 12, i1 false) + call void @llvm.memcpy.p0.p0.i32(ptr align 4 %c, ptr align 4 %1, 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 +; 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.then: ; preds = %entry + ret i32 -1 - if.exit: ; preds = %entry - %4 = load i32, ptr %a, align 4 - ret i32 %4 - } +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 - %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 +; Function Attrs: nounwind +define i32 @test_sum_us(ptr %0, i64 %1) #0 { +entry: + %x = alloca %"int[]", align 8 + %sum = alloca i32, align 4 + store ptr %0, ptr %x, align 8 + %ptroffset = getelementptr inbounds i64, ptr %x, i64 1 + store i64 %1, ptr %ptroffset, align 8 + store i32 0, ptr %sum, align 4 + %2 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 1 + %3 = load i64, ptr %2, align 8 + %eq = icmp eq i64 0, %3 + br i1 %eq, label %if.then, label %if.exit - if.then: ; preds = %entry - ret i32 0 +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 = call i32 @test_sum_us(ptr %ptroffset1, i64 %size) - %add = add i32 %9, %14 - %add2 = add i32 %6, %add - store i32 %add2, ptr %sum, align 4 - %15 = load i32, ptr %sum, align 4 - ret i32 %15 - } +if.exit: ; preds = %entry + %4 = load i32, ptr %sum, align 4 + %5 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 0 + %6 = load ptr, ptr %5, align 8 + %ptroffset1 = getelementptr inbounds i32, ptr %6, i64 0 + %7 = load i32, ptr %ptroffset1, align 4 + %8 = load %"int[]", ptr %x, align 8 + %9 = extractvalue %"int[]" %8, 0 + %10 = extractvalue %"int[]" %8, 1 + %sub = sub i64 %10, 1 + %11 = add i64 %sub, 1 + %size = sub i64 %11, 1 + %ptroffset2 = getelementptr inbounds i32, ptr %9, i64 1 + %12 = call i32 @test_sum_us(ptr %ptroffset2, i64 %size) + %add = add i32 %7, %12 + %add3 = add i32 %4, %add + store i32 %add3, ptr %sum, align 4 + %13 = load i32, ptr %sum, align 4 + ret i32 %13 +} - ; 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 +; 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 + store ptr %0, ptr %x, align 8 + %ptroffset = getelementptr inbounds i64, ptr %x, i64 1 + store i64 %1, ptr %ptroffset, 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.cond: ; preds = %loop.body, %entry + %2 = load i32, ptr %i, align 4 + %sisiext = sext i32 %2 to i64 + %3 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 1 + %4 = load i64, ptr %3, align 8 + %lt = icmp slt i64 %sisiext, %4 + %check = icmp slt i64 %4, 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.body: ; preds = %loop.cond + %5 = load i32, ptr %sum, align 4 + %6 = getelementptr inbounds %"int[]", ptr %x, i32 0, i32 0 + %7 = load ptr, ptr %6, align 8 + %8 = load i32, ptr %i, align 4 + %sisiext1 = sext i32 %8 to i64 + %ptroffset2 = getelementptr inbounds i32, ptr %7, i64 %sisiext1 + %9 = load i32, ptr %ptroffset2, align 4 + %add = add i32 %5, %9 + store i32 %add, ptr %sum, align 4 + %10 = load i32, ptr %i, align 4 + %add3 = add i32 %10, 1 + store i32 %add3, ptr %i, align 4 + br label %loop.cond - loop.exit: ; preds = %loop.cond - %13 = load i32, ptr %sum, align 4 - ret i32 %13 - } +loop.exit: ; preds = %loop.cond + %11 = load i32, ptr %sum, align 4 + ret i32 %11 +} - ; 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 - %ddx = alloca %Foo, align 4 - %fro = alloca i32, align 4 - %x = alloca [4 x i32], align 16 - %z = alloca %"int[]", align 8 - %de = alloca [3 x i32], align 4 - %varargslots = alloca [4 x i32], align 16 - %varargslots10 = alloca [1 x i32], align 4 - %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 +; 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 + %ddx = alloca %Foo, align 4 + %fro = alloca i32, align 4 + %x = alloca [4 x i32], align 16 + %z = alloca %"int[]", align 8 + %de = alloca [3 x i32], align 4 + %varargslots = alloca [4 x i32], align 16 + %varargslots10 = alloca [1 x i32], align 4 + %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.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.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 32, 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.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 32, 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.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.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 - %24 = load double, ptr %23, 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 = call i32 @test_sum_us(ptr %x, i64 4) - %35 = call i32 (ptr, ...) @printf(ptr @.str.13, i32 %34) - %add9 = add i32 %33, %35 - store i32 %add9, ptr %fro, align 4 - %36 = load i32, ptr %fro, align 4 - %37 = call i32 (ptr, ...) @printf(ptr @.str.14, i32 %36) - %38 = insertvalue %"int[]" undef, ptr %x, 0 - %39 = insertvalue %"int[]" %38, i64 4, 1 - store %"int[]" %39, ptr %z, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 4 %de, ptr align 4 @.__const.15, i32 12, i1 false) - %40 = call i32 @test_sum_us(ptr %x, i64 4) - %41 = call i32 (ptr, ...) @printf(ptr @.str.16, i32 %40) - %42 = getelementptr inbounds %"int[]", ptr %z, i32 0, i32 0 - %lo = load ptr, ptr %42, align 8 - %43 = getelementptr inbounds %"int[]", ptr %z, i32 0, i32 1 - %hi = load i64, ptr %43, align 8 - %44 = call i32 @test_sum_us(ptr %lo, i64 %hi) - %45 = call i32 (ptr, ...) @printf(ptr @.str.17, i32 %44) - %46 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 0 - store i32 1, ptr %46, align 4 - %47 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 1 - store i32 2, ptr %47, align 4 - %48 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 2 - store i32 4, ptr %48, align 4 - %49 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 3 - store i32 5, ptr %49, align 4 - %50 = call i32 @test_sum_us(ptr %varargslots, i64 4) - %51 = call i32 (ptr, ...) @printf(ptr @.str.18, i32 %50) - %52 = getelementptr inbounds [1 x i32], ptr %varargslots10, i64 0, i64 0 - store i32 1, ptr %52, align 4 - %53 = call i32 @test_sum_us(ptr %varargslots10, i64 1) - %54 = call i32 (ptr, ...) @printf(ptr @.str.19, i32 %53) - %55 = call i32 @test_sum_us(ptr null, i64 0) - %56 = call i32 (ptr, ...) @printf(ptr @.str.20, i32 %55) - store ptr null, ptr %a1, align 8 - store ptr null, ptr %b2, align 8 - ret void - } +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 = load i32, ptr %a, align 4 + %20 = call i32 @"test2$$int_getValue"(i32 %19) + %21 = call i32 (ptr, ...) @printf(ptr @.str.8, i32 %20) + %22 = load double, ptr %b, align 8 + %23 = call double @"test2$$double_getValue"(double %22) + %24 = call i32 (ptr, ...) @printf(ptr @.str.9, double %23) + %25 = call i32 @"test2$$int_getMult"(i32 25) + %26 = call i32 (ptr, ...) @printf(ptr @.str.10, i32 %25) + %27 = call double @"test2$$double_getMult"(double 3.300000e+00) + %28 = call i32 (ptr, ...) @printf(ptr @.str.11, double %27) + call void @test_helloWorld() + %29 = getelementptr inbounds %Foo, ptr %ddx, i32 0, i32 0 + store i32 0, ptr %29, align 4 + %30 = getelementptr inbounds %Foo, ptr %ddx, i32 0, i32 1 + store i32 0, ptr %30, 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) + %31 = load i32, ptr %fro, align 4 + %32 = call i32 @test_sum_us(ptr %x, i64 4) + %33 = call i32 (ptr, ...) @printf(ptr @.str.13, i32 %32) + %add9 = add i32 %31, %33 + store i32 %add9, ptr %fro, align 4 + %34 = load i32, ptr %fro, align 4 + %35 = call i32 (ptr, ...) @printf(ptr @.str.14, i32 %34) + %36 = insertvalue %"int[]" undef, ptr %x, 0 + %37 = insertvalue %"int[]" %36, i64 4, 1 + store %"int[]" %37, ptr %z, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 4 %de, ptr align 4 @.__const.15, i32 12, i1 false) + %38 = call i32 @test_sum_us(ptr %x, i64 4) + %39 = call i32 (ptr, ...) @printf(ptr @.str.16, i32 %38) + %40 = getelementptr inbounds %"int[]", ptr %z, i32 0, i32 0 + %lo = load ptr, ptr %40, align 8 + %41 = getelementptr inbounds %"int[]", ptr %z, i32 0, i32 1 + %hi = load i64, ptr %41, align 8 + %42 = call i32 @test_sum_us(ptr %lo, i64 %hi) + %43 = call i32 (ptr, ...) @printf(ptr @.str.17, i32 %42) + %44 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 0 + store i32 1, ptr %44, align 4 + %45 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 1 + store i32 2, ptr %45, align 4 + %46 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 2 + store i32 4, ptr %46, align 4 + %47 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 3 + store i32 5, ptr %47, align 4 + %48 = call i32 @test_sum_us(ptr %varargslots, i64 4) + %49 = call i32 (ptr, ...) @printf(ptr @.str.18, i32 %48) + %50 = getelementptr inbounds [1 x i32], ptr %varargslots10, i64 0, i64 0 + store i32 1, ptr %50, align 4 + %51 = call i32 @test_sum_us(ptr %varargslots10, i64 1) + %52 = call i32 (ptr, ...) @printf(ptr @.str.19, i32 %51) + %53 = call i32 @test_sum_us(ptr null, i64 0) + %54 = call i32 (ptr, ...) @printf(ptr @.str.20, i32 %53) + 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() @@ -587,11 +583,10 @@ entry: define i32 @"test2$$int_getValue"(i32 %0) #0 { entry: %blob = alloca %Blob, align 4 + store i32 %0, ptr %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 + %2 = load i32, ptr %1, align 4 + ret i32 %2 } // #expect: test2.double.ll @@ -609,10 +604,9 @@ entry: ret i32 1 define double @"test2$$double_getValue"(double %0) - entry: +entry: %blob = alloca %Blob, align 8 + store double %0, ptr %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 \ No newline at end of file + %2 = load double, ptr %1, align 8 + ret double %2 diff --git a/test/test_suite/functions/test_regression_mingw.c3t b/test/test_suite/functions/test_regression_mingw.c3t index b4ed290a6..7669c1c7a 100644 --- a/test/test_suite/functions/test_regression_mingw.c3t +++ b/test/test_suite/functions/test_regression_mingw.c3t @@ -534,70 +534,68 @@ 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 - %24 = load i64, ptr %23, align 8 - %25 = call double @"test2$$double_getValue"(i64 %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) + %19 = load i32, ptr %a, align 4 + %20 = call i32 @"test2$$int_getValue"(i32 %19) + %21 = call i32 (ptr, ...) @printf(ptr @.str.8, i32 %20) + %22 = load i64, ptr %b, align 8 + %23 = call double @"test2$$double_getValue"(i64 %22) + %24 = call i32 (ptr, ...) @printf(ptr @.str.9, double %23) + %25 = call i32 @"test2$$int_getMult"(i32 25) + %26 = call i32 (ptr, ...) @printf(ptr @.str.10, i32 %25) + %27 = call double @"test2$$double_getMult"(double 3.300000e+00) + %28 = call i32 (ptr, ...) @printf(ptr @.str.11, double %27) 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 + %29 = getelementptr inbounds %Foo, ptr %ddx, i32 0, i32 0 + store i32 0, ptr %29, align 4 + %30 = getelementptr inbounds %Foo, ptr %ddx, i32 0, i32 1 + store i32 0, ptr %30, 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 = insertvalue %"int[]" undef, ptr %x, 0 - %35 = insertvalue %"int[]" %34, i64 4, 1 - store %"int[]" %35, ptr %indirectarg, align 8 - %36 = call i32 @test_sum_us(ptr align 8 %indirectarg) - %37 = call i32 (ptr, ...) @printf(ptr @.str.13, i32 %36) - %add9 = add i32 %33, %37 + %31 = load i32, ptr %fro, align 4 + %32 = insertvalue %"int[]" undef, ptr %x, 0 + %33 = insertvalue %"int[]" %32, i64 4, 1 + store %"int[]" %33, ptr %indirectarg, align 8 + %34 = call i32 @test_sum_us(ptr align 8 %indirectarg) + %35 = call i32 (ptr, ...) @printf(ptr @.str.13, i32 %34) + %add9 = add i32 %31, %35 store i32 %add9, ptr %fro, align 4 - %38 = load i32, ptr %fro, align 4 - %39 = call i32 (ptr, ...) @printf(ptr @.str.14, i32 %38) + %36 = load i32, ptr %fro, align 4 + %37 = call i32 (ptr, ...) @printf(ptr @.str.14, i32 %36) + %38 = insertvalue %"int[]" undef, ptr %x, 0 + %39 = insertvalue %"int[]" %38, i64 4, 1 + store %"int[]" %39, ptr %z, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 4 %de, ptr align 4 @.__const.15, i32 12, i1 false) %40 = insertvalue %"int[]" undef, ptr %x, 0 %41 = insertvalue %"int[]" %40, i64 4, 1 - store %"int[]" %41, ptr %z, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 4 %de, ptr align 4 @.__const.15, i32 12, i1 false) - %42 = insertvalue %"int[]" undef, ptr %x, 0 - %43 = insertvalue %"int[]" %42, i64 4, 1 - store %"int[]" %43, ptr %indirectarg10, align 8 - %44 = call i32 @test_sum_us(ptr align 8 %indirectarg10) - %45 = call i32 (ptr, ...) @printf(ptr @.str.16, i32 %44) + store %"int[]" %41, ptr %indirectarg10, align 8 + %42 = call i32 @test_sum_us(ptr align 8 %indirectarg10) + %43 = call i32 (ptr, ...) @printf(ptr @.str.16, i32 %42) call void @llvm.memcpy.p0.p0.i32(ptr align 8 %indirectarg11, ptr align 8 %z, i32 16, i1 false) - %46 = call i32 @test_sum_us(ptr align 8 %indirectarg11) - %47 = call i32 (ptr, ...) @printf(ptr @.str.17, i32 %46) - %48 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 0 - store i32 1, ptr %48, align 4 - %49 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 1 - store i32 2, ptr %49, align 4 - %50 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 2 - store i32 4, ptr %50, align 4 - %51 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 3 - store i32 5, ptr %51, align 4 - %52 = insertvalue %"int[]" undef, ptr %varargslots, 0 - %53 = insertvalue %"int[]" %52, i64 4, 1 - store %"int[]" %53, ptr %indirectarg12, align 8 - %54 = call i32 @test_sum_us(ptr align 8 %indirectarg12) - %55 = call i32 (ptr, ...) @printf(ptr @.str.18, i32 %54) - %56 = getelementptr inbounds [1 x i32], ptr %varargslots13, i64 0, i64 0 - store i32 1, ptr %56, align 4 - %57 = insertvalue %"int[]" undef, ptr %varargslots13, 0 - %58 = insertvalue %"int[]" %57, i64 1, 1 - store %"int[]" %58, ptr %indirectarg14, align 8 - %59 = call i32 @test_sum_us(ptr align 8 %indirectarg14) - %60 = call i32 (ptr, ...) @printf(ptr @.str.19, i32 %59) + %44 = call i32 @test_sum_us(ptr align 8 %indirectarg11) + %45 = call i32 (ptr, ...) @printf(ptr @.str.17, i32 %44) + %46 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 0 + store i32 1, ptr %46, align 4 + %47 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 1 + store i32 2, ptr %47, align 4 + %48 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 2 + store i32 4, ptr %48, align 4 + %49 = getelementptr inbounds [4 x i32], ptr %varargslots, i64 0, i64 3 + store i32 5, ptr %49, align 4 + %50 = insertvalue %"int[]" undef, ptr %varargslots, 0 + %51 = insertvalue %"int[]" %50, i64 4, 1 + store %"int[]" %51, ptr %indirectarg12, align 8 + %52 = call i32 @test_sum_us(ptr align 8 %indirectarg12) + %53 = call i32 (ptr, ...) @printf(ptr @.str.18, i32 %52) + %54 = getelementptr inbounds [1 x i32], ptr %varargslots13, i64 0, i64 0 + store i32 1, ptr %54, align 4 + %55 = insertvalue %"int[]" undef, ptr %varargslots13, 0 + %56 = insertvalue %"int[]" %55, i64 1, 1 + store %"int[]" %56, ptr %indirectarg14, align 8 + %57 = call i32 @test_sum_us(ptr align 8 %indirectarg14) + %58 = call i32 (ptr, ...) @printf(ptr @.str.19, i32 %57) store %"int[]" zeroinitializer, ptr %indirectarg15, align 8 - %61 = call i32 @test_sum_us(ptr align 8 %indirectarg15) - %62 = call i32 (ptr, ...) @printf(ptr @.str.20, i32 %61) + %59 = call i32 @test_sum_us(ptr align 8 %indirectarg15) + %60 = call i32 (ptr, ...) @printf(ptr @.str.20, i32 %59) store ptr null, ptr %a1, align 8 store ptr null, ptr %b2, align 8 ret void @@ -666,11 +664,10 @@ entry: define i32 @"test2$$int_getValue"(i32 %0) entry: %blob = alloca %Blob, align 4 + store i32 %0, ptr %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 + %2 = load i32, ptr %1, align 4 + ret i32 %2 // #expect: test2.double.ll @@ -691,9 +688,8 @@ entry: define double @"test2$$double_getValue"(i64 %0) entry: %blob = alloca %Blob, align 8 + store i64 %0, ptr %blob, align 8 %1 = getelementptr inbounds %Blob, ptr %blob, i32 0, i32 0 - store i64 %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 + %2 = load double, ptr %1, align 8 + ret double %2 diff --git a/test/test_suite/functions/typeless_varargs.c3t b/test/test_suite/functions/typeless_varargs.c3t index fd419f58f..08b18edd2 100644 --- a/test/test_suite/functions/typeless_varargs.c3t +++ b/test/test_suite/functions/typeless_varargs.c3t @@ -27,14 +27,13 @@ fn int main() define void @test_retest(ptr %0, i64 %1) #0 { entry: %foo = alloca %"variant[]", align 8 - %2 = getelementptr inbounds { ptr, i64 }, ptr %foo, i32 0, i32 0 - store ptr %0, ptr %2, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %foo, i32 0, i32 1 - store i64 %1, ptr %3, align 8 - %4 = getelementptr inbounds %"variant[]", ptr %foo, i32 0, i32 0 - %lo = load ptr, ptr %4, align 8 - %5 = getelementptr inbounds %"variant[]", ptr %foo, i32 0, i32 1 - %hi = load i64, ptr %5, align 8 + store ptr %0, ptr %foo, align 8 + %ptroffset = getelementptr inbounds i64, ptr %foo, i64 1 + store i64 %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %"variant[]", ptr %foo, i32 0, i32 0 + %lo = load ptr, ptr %2, align 8 + %3 = getelementptr inbounds %"variant[]", ptr %foo, i32 0, i32 1 + %hi = load i64, ptr %3, align 8 call void @test_test(ptr %lo, i64 %hi) ret void } @@ -42,17 +41,16 @@ entry: define void @test_test(ptr %0, i64 %1) #0 { entry: %foo = alloca %"variant[]", align 8 - %2 = getelementptr inbounds { ptr, i64 }, ptr %foo, i32 0, i32 0 - store ptr %0, ptr %2, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %foo, i32 0, i32 1 - store i64 %1, ptr %3, align 8 - %4 = getelementptr inbounds %"variant[]", ptr %foo, i32 0, i32 0 + store ptr %0, ptr %foo, align 8 + %ptroffset = getelementptr inbounds i64, ptr %foo, i64 1 + store i64 %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %"variant[]", ptr %foo, i32 0, i32 0 + %3 = load ptr, ptr %2, align 8 + %ptroffset1 = getelementptr inbounds %variant, ptr %3, i64 0 + %4 = getelementptr inbounds %variant, ptr %ptroffset1, i32 0, i32 0 %5 = load ptr, ptr %4, align 8 - %ptroffset = getelementptr inbounds %variant, ptr %5, i64 0 - %6 = getelementptr inbounds %variant, ptr %ptroffset, i32 0, i32 0 - %7 = load ptr, ptr %6, align 8 - %8 = load i32, ptr %7, align 4 - call void (ptr, ...) @printf(ptr @.str, i32 %8) + %6 = load i32, ptr %5, align 4 + call void (ptr, ...) @printf(ptr @.str, i32 %6) ret void } diff --git a/test/test_suite/functions/varargs_followed_by_named.c3t b/test/test_suite/functions/varargs_followed_by_named.c3t index 10eb6f76e..58b8ddb47 100644 --- a/test/test_suite/functions/varargs_followed_by_named.c3t +++ b/test/test_suite/functions/varargs_followed_by_named.c3t @@ -25,18 +25,17 @@ fn void main() define void @foo_test(i32 %0, ptr %1, i64 %2, i32 %3) #0 { entry: %y = alloca %"int[]", align 8 - %4 = getelementptr inbounds { ptr, i64 }, ptr %y, i32 0, i32 0 - store ptr %1, ptr %4, align 8 - %5 = getelementptr inbounds { ptr, i64 }, ptr %y, i32 0, i32 1 - store i64 %2, ptr %5, align 8 - %6 = getelementptr inbounds %"int[]", ptr %y, i32 0, i32 1 - %7 = load i64, ptr %6, align 8 - %uisitrunc = trunc i64 %7 to i32 - %8 = getelementptr inbounds %"int[]", ptr %y, i32 0, i32 0 - %9 = load ptr, ptr %8, align 8 - %ptroffset = getelementptr inbounds i32, ptr %9, i64 0 - %10 = load i32, ptr %ptroffset, align 4 - call void (ptr, ...) @printf(ptr @.str, i32 %0, i32 %uisitrunc, i32 %3, i32 %10) + store ptr %1, ptr %y, align 8 + %ptroffset = getelementptr inbounds i64, ptr %y, i64 1 + store i64 %2, ptr %ptroffset, align 8 + %4 = getelementptr inbounds %"int[]", ptr %y, i32 0, i32 1 + %5 = load i64, ptr %4, align 8 + %uisitrunc = trunc i64 %5 to i32 + %6 = getelementptr inbounds %"int[]", ptr %y, i32 0, i32 0 + %7 = load ptr, ptr %6, align 8 + %ptroffset1 = getelementptr inbounds i32, ptr %7, i64 0 + %8 = load i32, ptr %ptroffset1, align 4 + call void (ptr, ...) @printf(ptr @.str, i32 %0, i32 %uisitrunc, i32 %3, i32 %8) ret void } @@ -44,13 +43,12 @@ entry: define void @foo_test2(i32 %0, ptr %1, i64 %2, i32 %3) #0 { entry: %y = alloca %"variant[]", align 8 - %4 = getelementptr inbounds { ptr, i64 }, ptr %y, i32 0, i32 0 - store ptr %1, ptr %4, align 8 - %5 = getelementptr inbounds { ptr, i64 }, ptr %y, i32 0, i32 1 - store i64 %2, ptr %5, align 8 - %6 = getelementptr inbounds %"variant[]", ptr %y, i32 0, i32 1 - %7 = load i64, ptr %6, align 8 - %uisitrunc = trunc i64 %7 to i32 + store ptr %1, ptr %y, align 8 + %ptroffset = getelementptr inbounds i64, ptr %y, i64 1 + store i64 %2, ptr %ptroffset, align 8 + %4 = getelementptr inbounds %"variant[]", ptr %y, i32 0, i32 1 + %5 = load i64, ptr %4, align 8 + %uisitrunc = trunc i64 %5 to i32 call void (ptr, ...) @printf(ptr @.str.1, i32 %0, i32 %uisitrunc, i32 %3) ret void } diff --git a/test/test_suite/initializer_lists/fasta.c3t b/test/test_suite/initializer_lists/fasta.c3t index fdfb403a7..03c380a71 100644 --- a/test/test_suite/initializer_lists/fasta.c3t +++ b/test/test_suite/initializer_lists/fasta.c3t @@ -161,35 +161,34 @@ entry: %seq = alloca %"char[]", align 8 %len = alloca i64, align 8 %i = alloca i32, align 4 - %3 = getelementptr inbounds { ptr, i64 }, ptr %seq, i32 0, i32 0 - store ptr %0, ptr %3, align 8 - %4 = getelementptr inbounds { ptr, i64 }, ptr %seq, i32 0, i32 1 - store i64 %1, ptr %4, align 8 - %5 = getelementptr inbounds %"char[]", ptr %seq, i32 0, i32 1 - %6 = load i64, ptr %5, align 8 - store i64 %6, ptr %len, align 8 + store ptr %0, ptr %seq, align 8 + %ptroffset = getelementptr inbounds i64, ptr %seq, i64 1 + store i64 %1, ptr %ptroffset, align 8 + %3 = getelementptr inbounds %"char[]", ptr %seq, i32 0, i32 1 + %4 = load i64, ptr %3, align 8 + store i64 %4, ptr %len, align 8 store i32 0, ptr %i, align 4 br label %loop.cond loop.cond: ; preds = %if.exit, %entry - %7 = load i32, ptr %i, align 4 - %lt = icmp slt i32 %7, %2 + %5 = load i32, ptr %i, align 4 + %lt = icmp slt i32 %5, %2 br i1 %lt, label %loop.body, label %loop.exit loop.body: ; preds = %loop.cond - %8 = getelementptr inbounds %"char[]", ptr %seq, i32 0, i32 0 - %9 = load ptr, ptr %8, align 8 - %10 = load i32, ptr %i, align 4 - %sisiext = sext i32 %10 to i64 - %11 = load i64, ptr %len, align 8 - %smod = srem i64 %sisiext, %11 - %ptroffset = getelementptr inbounds i8, ptr %9, i64 %smod - %12 = load i8, ptr %ptroffset, align 1 - %uisiext = zext i8 %12 to i32 + %6 = getelementptr inbounds %"char[]", ptr %seq, i32 0, i32 0 + %7 = load ptr, ptr %6, align 8 + %8 = load i32, ptr %i, align 4 + %sisiext = sext i32 %8 to i64 + %9 = load i64, ptr %len, align 8 + %smod = srem i64 %sisiext, %9 + %ptroffset1 = getelementptr inbounds i8, ptr %7, i64 %smod + %10 = load i8, ptr %ptroffset1, align 1 + %uisiext = zext i8 %10 to i32 call void @putchar(i32 %uisiext) - %13 = load i32, ptr %i, align 4 - %smod1 = srem i32 %13, 60 - %eq = icmp eq i32 %smod1, 59 + %11 = load i32, ptr %i, align 4 + %smod2 = srem i32 %11, 60 + %eq = icmp eq i32 %smod2, 59 br i1 %eq, label %if.then, label %if.exit if.then: ; preds = %loop.body @@ -197,22 +196,22 @@ if.then: ; preds = %loop.body br label %if.exit if.exit: ; preds = %if.then, %loop.body - %14 = load i32, ptr %i, align 4 - %add = add i32 %14, 1 + %12 = load i32, ptr %i, align 4 + %add = add i32 %12, 1 store i32 %add, ptr %i, align 4 br label %loop.cond loop.exit: ; preds = %loop.cond - %15 = load i32, ptr %i, align 4 - %smod2 = srem i32 %15, 60 - %neq = icmp ne i32 %smod2, 0 - br i1 %neq, label %if.then3, label %if.exit4 + %13 = load i32, ptr %i, align 4 + %smod3 = srem i32 %13, 60 + %neq = icmp ne i32 %smod3, 0 + br i1 %neq, label %if.then4, label %if.exit5 -if.then3: ; preds = %loop.exit +if.then4: ; preds = %loop.exit call void @putchar(i32 10) - br label %if.exit4 + br label %if.exit5 -if.exit4: ; preds = %if.then3, %loop.exit +if.exit5: ; preds = %if.then4, %loop.exit ret void } @@ -225,104 +224,102 @@ entry: %i = alloca i32, align 4 %v = alloca double, align 8 %j = alloca i32, align 4 - %5 = getelementptr inbounds { ptr, i64 }, ptr %symb, i32 0, i32 0 - store ptr %0, ptr %5, align 8 - %6 = getelementptr inbounds { ptr, i64 }, ptr %symb, i32 0, i32 1 - store i64 %1, ptr %6, align 8 - %7 = getelementptr inbounds { ptr, i64 }, ptr %probability, i32 0, i32 0 - store ptr %2, ptr %7, align 8 - %8 = getelementptr inbounds { ptr, i64 }, ptr %probability, i32 0, i32 1 - store i64 %3, ptr %8, align 8 - %9 = getelementptr inbounds %"char[]", ptr %symb, i32 0, i32 1 - %10 = load i64, ptr %9, align 8 - %11 = getelementptr inbounds %"double[]", ptr %probability, i32 0, i32 1 - %12 = load i64, ptr %11, align 8 - %eq = icmp eq i64 %10, %12 + store ptr %0, ptr %symb, align 8 + %ptroffset = getelementptr inbounds i64, ptr %symb, i64 1 + store i64 %1, ptr %ptroffset, align 8 + store ptr %2, ptr %probability, align 8 + %ptroffset1 = getelementptr inbounds i64, ptr %probability, i64 1 + store i64 %3, ptr %ptroffset1, align 8 + %5 = getelementptr inbounds %"char[]", ptr %symb, i32 0, i32 1 + %6 = load i64, ptr %5, align 8 + %7 = getelementptr inbounds %"double[]", ptr %probability, i32 0, i32 1 + %8 = load i64, ptr %7, align 8 + %eq = icmp eq i64 %6, %8 call void @llvm.assume(i1 %eq) - %13 = getelementptr inbounds %"double[]", ptr %probability, i32 0, i32 1 - %14 = load i64, ptr %13, align 8 - %uisitrunc = trunc i64 %14 to i32 + %9 = getelementptr inbounds %"double[]", ptr %probability, i32 0, i32 1 + %10 = load i64, ptr %9, align 8 + %uisitrunc = trunc i64 %10 to i32 store i32 %uisitrunc, ptr %len, align 4 store i32 0, ptr %i, align 4 br label %loop.cond -loop.cond: ; preds = %if.exit9, %entry - %15 = load i32, ptr %i, align 4 - %lt = icmp slt i32 %15, %4 - br i1 %lt, label %loop.body, label %loop.exit11 +loop.cond: ; preds = %if.exit11, %entry + %11 = load i32, ptr %i, align 4 + %lt = icmp slt i32 %11, %4 + br i1 %lt, label %loop.body, label %loop.exit13 loop.body: ; preds = %loop.cond - %16 = call float @fasta_fasta_rand(float 1.000000e+00) - %fpfpext = fpext float %16 to double + %12 = call float @fasta_fasta_rand(float 1.000000e+00) + %fpfpext = fpext float %12 to double store double %fpfpext, ptr %v, align 8 store i32 0, ptr %j, align 4 - br label %loop.cond1 + br label %loop.cond2 -loop.cond1: ; preds = %if.exit, %loop.body - %17 = load i32, ptr %j, align 4 - %18 = load i32, ptr %len, align 4 - %sub = sub i32 %18, 1 - %lt2 = icmp slt i32 %17, %sub - br i1 %lt2, label %loop.body3, label %loop.exit +loop.cond2: ; preds = %if.exit, %loop.body + %13 = load i32, ptr %j, align 4 + %14 = load i32, ptr %len, align 4 + %sub = sub i32 %14, 1 + %lt3 = icmp slt i32 %13, %sub + br i1 %lt3, label %loop.body4, label %loop.exit -loop.body3: ; preds = %loop.cond1 - %19 = load double, ptr %v, align 8 - %20 = getelementptr inbounds %"double[]", ptr %probability, i32 0, i32 0 - %21 = load ptr, ptr %20, align 8 - %22 = load i32, ptr %j, align 4 - %sisiext = sext i32 %22 to i64 - %ptroffset = getelementptr inbounds double, ptr %21, i64 %sisiext - %23 = load double, ptr %ptroffset, align 8 - %fsub = fsub double %19, %23 +loop.body4: ; preds = %loop.cond2 + %15 = load double, ptr %v, align 8 + %16 = getelementptr inbounds %"double[]", ptr %probability, i32 0, i32 0 + %17 = load ptr, ptr %16, align 8 + %18 = load i32, ptr %j, align 4 + %sisiext = sext i32 %18 to i64 + %ptroffset5 = getelementptr inbounds double, ptr %17, i64 %sisiext + %19 = load double, ptr %ptroffset5, align 8 + %fsub = fsub double %15, %19 store double %fsub, ptr %v, align 8 - %24 = load double, ptr %v, align 8 - %lt4 = fcmp olt double %24, 0.000000e+00 - br i1 %lt4, label %if.then, label %if.exit + %20 = load double, ptr %v, align 8 + %lt6 = fcmp olt double %20, 0.000000e+00 + br i1 %lt6, label %if.then, label %if.exit -if.then: ; preds = %loop.body3 +if.then: ; preds = %loop.body4 br label %loop.exit -if.exit: ; preds = %loop.body3 - %25 = load i32, ptr %j, align 4 - %add = add i32 %25, 1 +if.exit: ; preds = %loop.body4 + %21 = load i32, ptr %j, align 4 + %add = add i32 %21, 1 store i32 %add, ptr %j, align 4 - br label %loop.cond1 + br label %loop.cond2 -loop.exit: ; preds = %if.then, %loop.cond1 - %26 = getelementptr inbounds %"char[]", ptr %symb, i32 0, i32 0 - %27 = load ptr, ptr %26, align 8 - %28 = load i32, ptr %j, align 4 - %sisiext5 = sext i32 %28 to i64 - %ptroffset6 = getelementptr inbounds i8, ptr %27, i64 %sisiext5 - %29 = load i8, ptr %ptroffset6, align 1 - %uisiext = zext i8 %29 to i32 +loop.exit: ; preds = %if.then, %loop.cond2 + %22 = getelementptr inbounds %"char[]", ptr %symb, i32 0, i32 0 + %23 = load ptr, ptr %22, align 8 + %24 = load i32, ptr %j, align 4 + %sisiext7 = sext i32 %24 to i64 + %ptroffset8 = getelementptr inbounds i8, ptr %23, i64 %sisiext7 + %25 = load i8, ptr %ptroffset8, align 1 + %uisiext = zext i8 %25 to i32 call void @putchar(i32 %uisiext) - %30 = load i32, ptr %i, align 4 - %smod = srem i32 %30, 60 - %eq7 = icmp eq i32 %smod, 59 - br i1 %eq7, label %if.then8, label %if.exit9 + %26 = load i32, ptr %i, align 4 + %smod = srem i32 %26, 60 + %eq9 = icmp eq i32 %smod, 59 + br i1 %eq9, label %if.then10, label %if.exit11 -if.then8: ; preds = %loop.exit +if.then10: ; preds = %loop.exit call void @putchar(i32 10) - br label %if.exit9 + br label %if.exit11 -if.exit9: ; preds = %if.then8, %loop.exit - %31 = load i32, ptr %i, align 4 - %add10 = add i32 %31, 1 - store i32 %add10, ptr %i, align 4 +if.exit11: ; preds = %if.then10, %loop.exit + %27 = load i32, ptr %i, align 4 + %add12 = add i32 %27, 1 + store i32 %add12, ptr %i, align 4 br label %loop.cond -loop.exit11: ; preds = %loop.cond - %32 = load i32, ptr %i, align 4 - %smod12 = srem i32 %32, 60 - %neq = icmp ne i32 %smod12, 0 - br i1 %neq, label %if.then13, label %if.exit14 +loop.exit13: ; preds = %loop.cond + %28 = load i32, ptr %i, align 4 + %smod14 = srem i32 %28, 60 + %neq = icmp ne i32 %smod14, 0 + br i1 %neq, label %if.then15, label %if.exit16 -if.then13: ; preds = %loop.exit11 +if.then15: ; preds = %loop.exit13 call void @putchar(i32 10) - br label %if.exit14 + br label %if.exit16 -if.exit14: ; preds = %if.then13, %loop.exit11 +if.exit16: ; preds = %if.then15, %loop.exit13 ret void } diff --git a/test/test_suite/pointers/subarray_variant_to_ptr.c3t b/test/test_suite/pointers/subarray_variant_to_ptr.c3t index f54c2e7f9..19dc067f0 100644 --- a/test/test_suite/pointers/subarray_variant_to_ptr.c3t +++ b/test/test_suite/pointers/subarray_variant_to_ptr.c3t @@ -35,16 +35,15 @@ define void @foo_test1(i64 %0, ptr %1) #0 { entry: %z = alloca %variant, align 8 %w = alloca ptr, align 8 - %2 = getelementptr inbounds { i64, ptr }, ptr %z, i32 0, i32 0 - store i64 %0, ptr %2, align 8 - %3 = getelementptr inbounds { i64, ptr }, ptr %z, i32 0, i32 1 - store ptr %1, ptr %3, align 8 - %4 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 - %5 = load ptr, ptr %4, align 8 - store ptr %5, ptr %w, align 8 - %6 = load ptr, ptr %w, align 8 - %7 = load i32, ptr %6, align 4 - call void (ptr, ...) @printf(ptr @.str, i32 %7) + store i64 %0, ptr %z, align 8 + %ptroffset = getelementptr inbounds ptr, ptr %z, i64 1 + store ptr %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 + %3 = load ptr, ptr %2, align 8 + store ptr %3, ptr %w, align 8 + %4 = load ptr, ptr %w, align 8 + %5 = load i32, ptr %4, align 4 + call void (ptr, ...) @printf(ptr @.str, i32 %5) ret void } @@ -52,16 +51,15 @@ define void @foo_test2(ptr %0, i64 %1) #0 { entry: %z = alloca %"int[]", align 8 %w = alloca ptr, align 8 - %2 = getelementptr inbounds { ptr, i64 }, ptr %z, i32 0, i32 0 - store ptr %0, ptr %2, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %z, i32 0, i32 1 - store i64 %1, ptr %3, align 8 - %4 = getelementptr inbounds %"int[]", ptr %z, i32 0, i32 0 - %5 = load ptr, ptr %4, align 8 - store ptr %5, ptr %w, align 8 - %6 = load ptr, ptr %w, align 8 - %7 = load i32, ptr %6, align 4 - call void (ptr, ...) @printf(ptr @.str.1, i32 %7) + store ptr %0, ptr %z, align 8 + %ptroffset = getelementptr inbounds i64, ptr %z, i64 1 + store i64 %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %"int[]", ptr %z, i32 0, i32 0 + %3 = load ptr, ptr %2, align 8 + store ptr %3, ptr %w, align 8 + %4 = load ptr, ptr %w, align 8 + %5 = load i32, ptr %4, align 4 + call void (ptr, ...) @printf(ptr @.str.1, i32 %5) ret void } diff --git a/test/test_suite/stdlib/map.c3t b/test/test_suite/stdlib/map.c3t index 20a9072b4..994df1fdd 100644 --- a/test/test_suite/stdlib/map.c3t +++ b/test/test_suite/stdlib/map.c3t @@ -65,7 +65,7 @@ entry: if.then: ; preds = %entry %1 = load ptr, ptr @std_core_mem_thread_allocator, align 8 - call void @"std_map$$typeid.p$std_io$ToStringFunction_HashMap_init"(ptr @std_io_tostring_functions, i32 + call void @"std_map$$typeid.p$std_io$ToStringFunction_HashMap_init"(ptr @std_io_tostring_functions, i32 64, float 7.500000e-01, ptr %1) br label %if.exit if.exit: ; preds = %if.then, %entry @@ -131,7 +131,7 @@ entry: %retparam36 = alloca i64, align 8 %varargslots37 = alloca [1 x %variant], align 16 %result = alloca %"Foo[]", align 8 - %map2 = alloca %HashMap.3, align 8 + %map2 = alloca %HashMap.2, align 8 %retparam41 = alloca i64, align 8 %varargslots42 = alloca [1 x %variant], align 16 %taddr43 = alloca i8, align 1 @@ -148,7 +148,7 @@ entry: %error_var = alloca i64, align 8 %retparam65 = alloca ptr, align 8 %mark = alloca i64, align 8 - %map3 = alloca %HashMap.3, align 8 + %map3 = alloca %HashMap.2, align 8 %retparam68 = alloca i64, align 8 %varargslots69 = alloca [1 x %variant], align 16 %result70 = alloca %"int[]", align 8 diff --git a/test/test_suite/struct/struct_as_value.c3t b/test/test_suite/struct/struct_as_value.c3t index e8d2156b0..4fb50eb49 100644 --- a/test/test_suite/struct/struct_as_value.c3t +++ b/test/test_suite/struct/struct_as_value.c3t @@ -41,7 +41,6 @@ cond.rhs: ; preds = %entry cond.phi: ; preds = %cond.rhs, %cond.lhs %val = phi %Event [ %1, %cond.lhs ], [ %2, %cond.rhs ] store %Event %val, ptr %taddr, align 4 - %3 = getelementptr inbounds %Event, ptr %taddr, i32 0, i32 0 - %4 = load i32, ptr %3, align 4 - ret i32 %4 + %3 = load i32, ptr %taddr, align 4 + ret i32 %3 } \ No newline at end of file diff --git a/test/test_suite/struct/struct_as_value_aarch64.c3t b/test/test_suite/struct/struct_as_value_aarch64.c3t index 54740fa84..a0b81ba79 100644 --- a/test/test_suite/struct/struct_as_value_aarch64.c3t +++ b/test/test_suite/struct/struct_as_value_aarch64.c3t @@ -36,7 +36,6 @@ cond.rhs: ; preds = %entry cond.phi: ; preds = %cond.rhs, %cond.lhs %val = phi %Event [ %1, %cond.lhs ], [ %2, %cond.rhs ] store %Event %val, ptr %taddr, align 4 - %3 = getelementptr inbounds %Event, ptr %taddr, i32 0, i32 0 - %4 = load i32, ptr %3, align 4 - ret i32 %4 + %3 = load i32, ptr %taddr, align 4 + ret i32 %3 } diff --git a/test/test_suite/variant/variant_assign.c3t b/test/test_suite/variant/variant_assign.c3t index 7c6966935..fea29d473 100644 --- a/test/test_suite/variant/variant_assign.c3t +++ b/test/test_suite/variant/variant_assign.c3t @@ -68,40 +68,39 @@ entry: %switch = alloca i64, align 8 %z1 = alloca ptr, align 8 %z4 = alloca ptr, align 8 - %2 = getelementptr inbounds { i64, ptr }, ptr %z, i32 0, i32 0 - store i64 %0, ptr %2, align 8 - %3 = getelementptr inbounds { i64, ptr }, ptr %z, i32 0, i32 1 - store ptr %1, ptr %3, align 8 - %4 = getelementptr inbounds %variant, ptr %z, i32 0, i32 1 - %5 = load i64, ptr %4, align 8 - store i64 %5, ptr %switch, align 8 + store i64 %0, ptr %z, align 8 + %ptroffset = getelementptr inbounds ptr, ptr %z, i64 1 + store ptr %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %variant, ptr %z, i32 0, i32 1 + %3 = load i64, ptr %2, align 8 + store i64 %3, ptr %switch, align 8 br label %switch.entry switch.entry: ; preds = %entry - %6 = load i64, ptr %switch, align 8 - %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %6 + %4 = load i64, ptr %switch, align 8 + %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %4 br i1 %eq, label %switch.case, label %next_if switch.case: ; preds = %switch.entry - %7 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 - %8 = load ptr, ptr %7, align 8 - store ptr %8, ptr %z1, align 8 - %9 = load ptr, ptr %z1, align 8 - %10 = load i32, ptr %9, align 4 - call void (ptr, ...) @printf(ptr @.str, i32 %10) + %5 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 + %6 = load ptr, ptr %5, align 8 + store ptr %6, ptr %z1, align 8 + %7 = load ptr, ptr %z1, align 8 + %8 = load i32, ptr %7, align 4 + call void (ptr, ...) @printf(ptr @.str, i32 %8) br label %switch.exit next_if: ; preds = %switch.entry - %eq2 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %6 + %eq2 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %4 br i1 %eq2, label %switch.case3, label %next_if5 switch.case3: ; preds = %next_if - %11 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 - %12 = load ptr, ptr %11, align 8 - store ptr %12, ptr %z4, align 8 - %13 = load ptr, ptr %z4, align 8 - %14 = load double, ptr %13, align 8 - call void (ptr, ...) @printf(ptr @.str.1, double %14) + %9 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 + %10 = load ptr, ptr %9, align 8 + store ptr %10, ptr %z4, align 8 + %11 = load ptr, ptr %z4, align 8 + %12 = load double, ptr %11, align 8 + call void (ptr, ...) @printf(ptr @.str.1, double %12) br label %switch.exit next_if5: ; preds = %next_if @@ -123,45 +122,44 @@ entry: %z = alloca ptr, align 8 %taddr = alloca i32, align 4 %z3 = alloca ptr, align 8 - %2 = getelementptr inbounds { i64, ptr }, ptr %y, i32 0, i32 0 - store i64 %0, ptr %2, align 8 - %3 = getelementptr inbounds { i64, ptr }, ptr %y, i32 0, i32 1 - store ptr %1, ptr %3, align 8 + store i64 %0, ptr %y, align 8 + %ptroffset = getelementptr inbounds ptr, ptr %y, i64 1 + store ptr %1, ptr %ptroffset, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %.anon, ptr align 8 %y, i32 16, i1 false) - %4 = getelementptr inbounds %variant, ptr %y, i32 0, i32 1 - %5 = load i64, ptr %4, align 8 - store i64 %5, ptr %switch, align 8 + %2 = getelementptr inbounds %variant, ptr %y, i32 0, i32 1 + %3 = load i64, ptr %2, align 8 + store i64 %3, ptr %switch, align 8 br label %switch.entry switch.entry: ; preds = %entry - %6 = load i64, ptr %switch, align 8 - %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %6 + %4 = load i64, ptr %switch, align 8 + %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %4 br i1 %eq, label %switch.case, label %next_if switch.case: ; preds = %switch.entry - %7 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 - %8 = load ptr, ptr %7, align 8 - store ptr %8, ptr %z, align 8 + %5 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 + %6 = load ptr, ptr %5, align 8 + store ptr %6, ptr %z, align 8 store i32 12, ptr %taddr, align 4 - %9 = insertvalue %variant undef, ptr %taddr, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (ptr @"ct$int" to i64), 1 - store %variant %10, ptr %y, align 8 - %11 = load ptr, ptr %z, align 8 - %12 = load i32, ptr %11, align 4 - call void (ptr, ...) @printf(ptr @.str.3, i32 %12) + %7 = insertvalue %variant undef, ptr %taddr, 0 + %8 = insertvalue %variant %7, i64 ptrtoint (ptr @"ct$int" to i64), 1 + store %variant %8, ptr %y, align 8 + %9 = load ptr, ptr %z, align 8 + %10 = load i32, ptr %9, align 4 + call void (ptr, ...) @printf(ptr @.str.3, i32 %10) br label %switch.exit next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %6 + %eq1 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %4 br i1 %eq1, label %switch.case2, label %next_if4 switch.case2: ; preds = %next_if - %13 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 - %14 = load ptr, ptr %13, align 8 - store ptr %14, ptr %z3, align 8 - %15 = load ptr, ptr %z3, align 8 - %16 = load double, ptr %15, align 8 - call void (ptr, ...) @printf(ptr @.str.4, double %16) + %11 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 + %12 = load ptr, ptr %11, align 8 + store ptr %12, ptr %z3, align 8 + %13 = load ptr, ptr %z3, align 8 + %14 = load double, ptr %13, align 8 + call void (ptr, ...) @printf(ptr @.str.4, double %14) br label %switch.exit next_if4: ; preds = %next_if @@ -182,41 +180,40 @@ entry: %switch = alloca i64, align 8 %z = alloca i32, align 4 %z3 = alloca double, align 8 - %2 = getelementptr inbounds { i64, ptr }, ptr %y, i32 0, i32 0 - store i64 %0, ptr %2, align 8 - %3 = getelementptr inbounds { i64, ptr }, ptr %y, i32 0, i32 1 - store ptr %1, ptr %3, align 8 + store i64 %0, ptr %y, align 8 + %ptroffset = getelementptr inbounds ptr, ptr %y, i64 1 + store ptr %1, ptr %ptroffset, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %.anon, ptr align 8 %y, i32 16, i1 false) - %4 = getelementptr inbounds %variant, ptr %y, i32 0, i32 1 - %5 = load i64, ptr %4, align 8 - store i64 %5, ptr %switch, align 8 + %2 = getelementptr inbounds %variant, ptr %y, i32 0, i32 1 + %3 = load i64, ptr %2, align 8 + store i64 %3, ptr %switch, align 8 br label %switch.entry switch.entry: ; preds = %entry - %6 = load i64, ptr %switch, align 8 - %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %6 + %4 = load i64, ptr %switch, align 8 + %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %4 br i1 %eq, label %switch.case, label %next_if switch.case: ; preds = %switch.entry - %7 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 - %8 = load ptr, ptr %7, align 8 - %9 = load i32, ptr %8, align 4 - store i32 %9, ptr %z, align 4 - %10 = load i32, ptr %z, align 4 - call void (ptr, ...) @printf(ptr @.str.6, i32 %10) + %5 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 + %6 = load ptr, ptr %5, align 8 + %7 = load i32, ptr %6, align 4 + store i32 %7, ptr %z, align 4 + %8 = load i32, ptr %z, align 4 + call void (ptr, ...) @printf(ptr @.str.6, i32 %8) br label %switch.exit next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %6 + %eq1 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %4 br i1 %eq1, label %switch.case2, label %next_if4 switch.case2: ; preds = %next_if - %11 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 - %12 = load ptr, ptr %11, align 8 - %13 = load double, ptr %12, align 8 - store double %13, ptr %z3, align 8 - %14 = load double, ptr %z3, align 8 - call void (ptr, ...) @printf(ptr @.str.7, double %14) + %9 = getelementptr inbounds %variant, ptr %.anon, i32 0, i32 0 + %10 = load ptr, ptr %9, align 8 + %11 = load double, ptr %10, align 8 + store double %11, ptr %z3, align 8 + %12 = load double, ptr %z3, align 8 + call void (ptr, ...) @printf(ptr @.str.7, double %12) br label %switch.exit next_if4: ; preds = %next_if diff --git a/test/test_suite/variant/variant_switch.c3t b/test/test_suite/variant/variant_switch.c3t index cf3528609..11b4a8f72 100644 --- a/test/test_suite/variant/variant_switch.c3t +++ b/test/test_suite/variant/variant_switch.c3t @@ -40,42 +40,41 @@ entry: %switch = alloca i64, align 8 %z1 = alloca ptr, align 8 %z4 = alloca ptr, align 8 - %2 = getelementptr inbounds { i64, ptr }, ptr %z, i32 0, i32 0 - store i64 %0, ptr %2, align 8 - %3 = getelementptr inbounds { i64, ptr }, ptr %z, i32 0, i32 1 - store ptr %1, ptr %3, align 8 - %4 = getelementptr inbounds %variant, ptr %z, i32 0, i32 1 - %5 = load i64, ptr %4, align 8 - store i64 %5, ptr %switch, align 8 + store i64 %0, ptr %z, align 8 + %ptroffset = getelementptr inbounds ptr, ptr %z, i64 1 + store ptr %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %variant, ptr %z, i32 0, i32 1 + %3 = load i64, ptr %2, align 8 + store i64 %3, ptr %switch, align 8 br label %switch.entry switch.entry: ; preds = %entry - %6 = load i64, ptr %switch, align 8 - %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %6 + %4 = load i64, ptr %switch, align 8 + %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %4 br i1 %eq, label %switch.case, label %next_if switch.case: ; preds = %switch.entry - %7 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 - %8 = load ptr, ptr %7, align 8 - store ptr %8, ptr %z1, align 8 + %5 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 + %6 = load ptr, ptr %5, align 8 + store ptr %6, ptr %z1, align 8 + %7 = load ptr, ptr %z1, align 8 + %8 = load i32, ptr %7, align 4 + call void (ptr, ...) @printf(ptr @.str, i32 %8) %9 = load ptr, ptr %z1, align 8 - %10 = load i32, ptr %9, align 4 - call void (ptr, ...) @printf(ptr @.str, i32 %10) - %11 = load ptr, ptr %z1, align 8 - store i32 3, ptr %11, align 4 + store i32 3, ptr %9, align 4 br label %switch.exit next_if: ; preds = %switch.entry - %eq2 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %6 + %eq2 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %4 br i1 %eq2, label %switch.case3, label %next_if5 switch.case3: ; preds = %next_if - %12 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 - %13 = load ptr, ptr %12, align 8 - store ptr %13, ptr %z4, align 8 - %14 = load ptr, ptr %z4, align 8 - %15 = load double, ptr %14, align 8 - call void (ptr, ...) @printf(ptr @.str.1, double %15) + %10 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 + %11 = load ptr, ptr %10, align 8 + store ptr %11, ptr %z4, align 8 + %12 = load ptr, ptr %z4, align 8 + %13 = load double, ptr %12, align 8 + call void (ptr, ...) @printf(ptr @.str.1, double %13) br label %switch.exit next_if5: ; preds = %next_if @@ -86,16 +85,16 @@ switch.default: ; preds = %next_if5 br label %switch.exit switch.exit: ; preds = %switch.default, %switch.case3, %switch.case - %16 = getelementptr inbounds %variant, ptr %z, i32 0, i32 1 - %17 = load i64, ptr %16, align 8 - %eq6 = icmp eq i64 %17, ptrtoint (ptr @"ct$int" to i64) + %14 = getelementptr inbounds %variant, ptr %z, i32 0, i32 1 + %15 = load i64, ptr %14, align 8 + %eq6 = icmp eq i64 %15, ptrtoint (ptr @"ct$int" to i64) br i1 %eq6, label %if.then, label %if.exit if.then: ; preds = %switch.exit - %18 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 - %19 = load ptr, ptr %18, align 8 - %20 = load i32, ptr %19, align 4 - call void (ptr, ...) @printf(ptr @.str.3, i32 %20) + %16 = getelementptr inbounds %variant, ptr %z, i32 0, i32 0 + %17 = load ptr, ptr %16, align 8 + %18 = load i32, ptr %17, align 4 + call void (ptr, ...) @printf(ptr @.str.3, i32 %18) br label %if.exit if.exit: ; preds = %if.then, %switch.exit diff --git a/test/test_suite/variant/variant_test.c3t b/test/test_suite/variant/variant_test.c3t index dfdee6d08..69b78d6ea 100644 --- a/test/test_suite/variant/variant_test.c3t +++ b/test/test_suite/variant/variant_test.c3t @@ -76,18 +76,17 @@ define void @foo_test(i64 %0, ptr %1) #0 { entry: %x = alloca %variant, align 8 %switch = alloca i64, align 8 - %2 = getelementptr inbounds { i64, ptr }, ptr %x, i32 0, i32 0 - store i64 %0, ptr %2, align 8 - %3 = getelementptr inbounds { i64, ptr }, ptr %x, i32 0, i32 1 - store ptr %1, ptr %3, align 8 - %4 = getelementptr inbounds %variant, ptr %x, i32 0, i32 1 - %5 = load i64, ptr %4, align 8 - store i64 %5, ptr %switch, align 8 + store i64 %0, ptr %x, align 8 + %ptroffset = getelementptr inbounds ptr, ptr %x, i64 1 + store ptr %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %variant, ptr %x, i32 0, i32 1 + %3 = load i64, ptr %2, align 8 + store i64 %3, ptr %switch, align 8 br label %switch.entry switch.entry: ; preds = %entry - %6 = load i64, ptr %switch, align 8 - %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %6 + %4 = load i64, ptr %switch, align 8 + %eq = icmp eq i64 ptrtoint (ptr @"ct$int" to i64), %4 br i1 %eq, label %switch.case, label %next_if switch.case: ; preds = %switch.entry @@ -95,7 +94,7 @@ switch.case: ; preds = %switch.entry br label %switch.exit next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %6 + %eq1 = icmp eq i64 ptrtoint (ptr @"ct$double" to i64), %4 br i1 %eq1, label %switch.case2, label %next_if3 switch.case2: ; preds = %next_if @@ -103,7 +102,7 @@ switch.case2: ; preds = %next_if br label %switch.exit next_if3: ; preds = %next_if - %eq4 = icmp eq i64 ptrtoint (ptr @"ct$variant" to i64), %6 + %eq4 = icmp eq i64 ptrtoint (ptr @"ct$variant" to i64), %4 br i1 %eq4, label %switch.case5, label %next_if6 switch.case5: ; preds = %next_if3 @@ -111,7 +110,7 @@ switch.case5: ; preds = %next_if3 br label %switch.exit next_if6: ; preds = %next_if3 - %eq7 = icmp eq i64 ptrtoint (ptr @"ct$p$int" to i64), %6 + %eq7 = icmp eq i64 ptrtoint (ptr @"ct$p$int" to i64), %4 br i1 %eq7, label %switch.case8, label %next_if9 switch.case8: ; preds = %next_if6 @@ -136,35 +135,34 @@ entry: %.anon = alloca i64, align 8 %.anon1 = alloca i64, align 8 %element = alloca %variant, align 8 - %2 = getelementptr inbounds { ptr, i64 }, ptr %y, i32 0, i32 0 - store ptr %0, ptr %2, align 8 - %3 = getelementptr inbounds { ptr, i64 }, ptr %y, i32 0, i32 1 - store i64 %1, ptr %3, align 8 - %4 = getelementptr inbounds %"variant[]", ptr %y, i32 0, i32 1 - %5 = load i64, ptr %4, align 8 - store i64 %5, ptr %.anon, align 8 + store ptr %0, ptr %y, align 8 + %ptroffset = getelementptr inbounds i64, ptr %y, i64 1 + store i64 %1, ptr %ptroffset, align 8 + %2 = getelementptr inbounds %"variant[]", ptr %y, i32 0, i32 1 + %3 = load i64, ptr %2, align 8 + store i64 %3, ptr %.anon, align 8 store i64 0, ptr %.anon1, align 8 br label %loop.cond loop.cond: ; preds = %loop.body, %entry - %6 = load i64, ptr %.anon1, align 8 - %7 = load i64, ptr %.anon, align 8 - %lt = icmp ult i64 %6, %7 + %4 = load i64, ptr %.anon1, align 8 + %5 = load i64, ptr %.anon, align 8 + %lt = icmp ult i64 %4, %5 br i1 %lt, label %loop.body, label %loop.exit loop.body: ; preds = %loop.cond - %8 = getelementptr inbounds %"variant[]", ptr %y, i32 0, i32 0 - %9 = load ptr, ptr %8, align 8 - %10 = load i64, ptr %.anon1, align 8 - %ptroffset = getelementptr inbounds %variant, ptr %9, i64 %10 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %element, ptr align 8 %ptroffset, i32 16, i1 false) - %11 = getelementptr inbounds { i64, ptr }, ptr %element, i32 0, i32 0 - %lo = load i64, ptr %11, align 8 - %12 = getelementptr inbounds { i64, ptr }, ptr %element, i32 0, i32 1 - %hi = load ptr, ptr %12, align 8 + %6 = getelementptr inbounds %"variant[]", ptr %y, i32 0, i32 0 + %7 = load ptr, ptr %6, align 8 + %8 = load i64, ptr %.anon1, align 8 + %ptroffset2 = getelementptr inbounds %variant, ptr %7, i64 %8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %element, ptr align 8 %ptroffset2, i32 16, i1 false) + %9 = getelementptr inbounds { i64, ptr }, ptr %element, i32 0, i32 0 + %lo = load i64, ptr %9, align 8 + %10 = getelementptr inbounds { i64, ptr }, ptr %element, i32 0, i32 1 + %hi = load ptr, ptr %10, align 8 call void @foo_test(i64 %lo, ptr %hi) - %13 = load i64, ptr %.anon1, align 8 - %add = add i64 %13, 1 + %11 = load i64, ptr %.anon1, align 8 + %add = add i64 %11, 1 store i64 %add, ptr %.anon1, align 8 br label %loop.cond diff --git a/test/test_suite14/abi/aarch64_args.c3t b/test/test_suite14/abi/aarch64_args.c3t deleted file mode 100644 index c716c6597..000000000 --- a/test/test_suite14/abi/aarch64_args.c3t +++ /dev/null @@ -1,34 +0,0 @@ -// #target: macos-aarch64 -module test; - -struct Large { - void*[8] pointers; -} - -extern fn void pass_large(Large); - -fn void example() { - Large l = {}; - pass_large(l); - pass_large(l); -} - -/* #expect: test.ll - -define void @test_example() #0 { -entry: - %l = alloca %Large, align 8 - %indirectarg = alloca %Large, align 8 - %indirectarg1 = alloca %Large, align 8 - %0 = bitcast %Large* %l to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %0, i8 0, i64 64, i1 false) - %1 = bitcast %Large* %indirectarg to i8* - %2 = bitcast %Large* %l to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %1, i8* align 8 %2, i32 64, i1 false) - call void @pass_large(%Large* align 8 %indirectarg) - %3 = bitcast %Large* %indirectarg1 to i8* - %4 = bitcast %Large* %l to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 64, i1 false) - call void @pass_large(%Large* align 8 %indirectarg1) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/abi/aarch64_hfa_args.c3t b/test/test_suite14/abi/aarch64_hfa_args.c3t deleted file mode 100644 index bead21eb7..000000000 --- a/test/test_suite14/abi/aarch64_hfa_args.c3t +++ /dev/null @@ -1,32 +0,0 @@ -// #target: macos-aarch64 -module test; -define Int8x16 = ichar[<16>]; -define Float32x3 = float[<3>]; - -struct HFAv3 -{ - Float32x3[4] arr; -} - -struct MixedHFAv3 -{ - Float32x3[3] arr; - Int8x16 b; -} - -fn HFAv3 test(HFAv3 a0, HFAv3 a1, HFAv3 a2) { - return a2; -} - -fn MixedHFAv3 test_mixed(MixedHFAv3 a0, MixedHFAv3 a1, MixedHFAv3 a2) { - return a2; -} - -/* #expect: test.ll - - -%HFAv3 = type { [4 x <3 x float>] } -%MixedHFAv3 = type { [3 x <3 x float>], <16 x i8> } - -define %HFAv3 @test_test([4 x <4 x float>] %0, [4 x <4 x float>] %1, [4 x <4 x float>] %2) -define %MixedHFAv3 @test_test_mixed([4 x <4 x float>] %0, [4 x <4 x float>] %1, [4 x <4 x float>] %2) #0 { diff --git a/test/test_suite14/abi/darwin64_avx.c3t b/test/test_suite14/abi/darwin64_avx.c3t deleted file mode 100644 index b5e3d5fc0..000000000 --- a/test/test_suite14/abi/darwin64_avx.c3t +++ /dev/null @@ -1,141 +0,0 @@ -// #target: macos-x64 -// #opt: --x86vec=avx -module test; - -define Mm256 = float[<8>]; -struct St256 { - Mm256 m; -} - -St256 x38; -Mm256 x37; - -extern fn void f38(St256 x); -extern fn void f37(Mm256 x); -fn void f39() { f38(x38); f37(x37); } - -// The two next tests make sure that the struct below is passed -// in the same way regardless of avx being used - -// CHECK: declare void @func40(%struct.t128* byval(%struct.t128) align 16) - -define Mm128 = float[<4>]; -struct Two128 { - Mm128 m; - Mm128 n; -} - -extern fn void func40(Two128 s); -fn void func41(Two128 s) { - func40(s); -} - -struct Atwo128 { - Mm128[2] array; -} - -struct Sa { - Atwo128 x; -} - -extern fn void func42(Sa s); -fn void func43(Sa s) { - func42(s); -} - - -define Vec46 = float[<2>]; -extern fn void f46(Vec46,Vec46,Vec46,Vec46,Vec46,Vec46,Vec46,Vec46,Vec46,Vec46); -fn void test46() { Vec46 x = {1,2}; f46(x,x,x,x,x,x,x,x,x,x); } - -struct Vec47 { uint a; } -extern fn void f47(int,int,int,int,int,int,Vec47); -fn void test47(int a, Vec47 b) { f47(a, a, a, a, a, a, b); } - -fn void test49_helper(double, ...); -fn void test49(double d, double e) { test49_helper(d, e); } - -struct Complex { double i; double c; } -extern fn void test52_helper(int, ...); -Mm256 x52; -fn void test52() { - test52_helper(0, x52, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Complex { 0, 1.0 }); -} - -extern fn void test54_helper(Mm256, ...); -Mm256 x54; -fn void test54() { - test54_helper(x54, x54, 1.0, 1.0, 1.0, 1.0, 1.0, Complex { 0, 1.0 }); - test54_helper(x54, x54, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Complex { 0, 1.0 }); -} - -define Mm512 = float[<16>]; -struct St512 { - Mm512 m; -} - -St512 x55; -Mm512 x56; - -extern fn void f55(St512 x); - -extern fn void f56(Mm512 x); -fn void f57() { f55(x55); f56(x56); } - -struct Two256 { - Mm256 m; - Mm256 n; -} - -extern fn void f58(Two256 s); -fn void f59(Two256 s) { - f58(s); -} - -struct Atwo256 { - Mm256[2] array; -} - -struct SAtwo256 { - Atwo256 x; -} - -extern fn void f60(SAtwo256 s); -fn void f61(SAtwo256 s) { - f60(s); -} - - -/* #expect: test.ll - -declare void @f38(<8 x float>) -declare void @f37(<8 x float>) - -declare void @func40(%Two128* byval(%Two128) align 16) -define void @test_func41(%Two128* byval(%Two128) align 16 %0) - -declare void @func42(%Sa* byval(%Sa) align 16) -define void @test_func43(%Sa* byval(%Sa) align 16 %0) - -declare void @f46(double, double, double, double, double, double, double, double, <2 x float>* byval(<2 x float>) align 8, <2 x float>* byval(<2 x float>) align 8) -declare void @f47(i32, i32, i32, i32, i32, i32, i32) - -declare void @test_test49_helper(double, ...) -define void @test_test49(double %0, double %1) -entry: - call void (double, ...) @test_test49_helper(double %0, double %1) - ret void - - call void (i32, ...) @test52_helper(i32 0, <8 x float> %0, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double %lo, double %hi) - - call void (<8 x float>, ...) @test54_helper(<8 x float> %0, <8 x float> %1, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double %lo, double %hi) - call void (<8 x float>, ...) @test54_helper(<8 x float> %6, <8 x float> %7, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, %Complex* byval(%Complex) align 8 %literal1) - -declare void @f55(%St512* byval(%St512) align 64) #0 -declare void @f56(<16 x float>* byval(<16 x float>) align 64) #0 - -declare void @f58(%Two256* byval(%Two256) align 32) #0 -define void @test_f59(%Two256* byval(%Two256) align 32 %0) #0 { - -declare void @f60(%SAtwo256* byval(%SAtwo256) align 32) #0 -define void @test_f61(%SAtwo256* byval(%SAtwo256) align 32 %0) #0 { \ No newline at end of file diff --git a/test/test_suite14/abi/darwin64_avx512.c3t b/test/test_suite14/abi/darwin64_avx512.c3t deleted file mode 100644 index 26e579226..000000000 --- a/test/test_suite14/abi/darwin64_avx512.c3t +++ /dev/null @@ -1,75 +0,0 @@ -// #target: macos-x64 -// #opt: --x86vec=avx512 -module test; - -define Mm256 = float[<8>]; -define Mm512 = float[<16>]; -struct St512 { - Mm512 m; -} - -St512 x55; -Mm512 x56; - -extern fn void f55(St512 x); - -extern fn void f56(Mm512 x); -fn void f57() { f55(x55); f56(x56); } - -struct Two256 { - Mm256 m; - Mm256 n; -} - -extern fn void f58(Two256 s); -fn void f59(Two256 s) { - f58(s); -} - -struct Atwo256 { - Mm256[2] array; -} - -struct SAtwo256 { - Atwo256 x; -} - -extern fn void f60(SAtwo256 s); -fn void f61(SAtwo256 s) { - f60(s); -} - -struct Complex { double i; double c; } - -// AVX512: @f62_helper(i32 0, <16 x float> {{%[a-zA-Z0-9]+}}, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double {{%[a-zA-Z0-9]+}}, double {{%[a-zA-Z0-9]+}}) -fn void f62_helper(int, ...); -Mm512 x62; -fn void f62() { - f62_helper(0, x62, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Complex { 1.0, 1.0 }); -} - -fn void f64_helper(Mm512, ...); -Mm512 x64; -fn void f64() { - f64_helper(x64, x64, 1.0, 1.0, 1.0, 1.0, 1.0, Complex { 1.0, 1.0 }); - f64_helper(x64, x64, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Complex { 1.0, 1.0 }); -} - - -/* #expect: test.ll - -declare void @f55(<16 x float>) #0 -declare void @f56(<16 x float>) #0 - -declare void @f58(%Two256* byval(%Two256) align 32) #0 -define void @test_f59(%Two256* byval(%Two256) align 32 %0) #0 { - -declare void @f60(%SAtwo256* byval(%SAtwo256) align 32) #0 -define void @test_f61(%SAtwo256* byval(%SAtwo256) align 32 %0) #0 { - - -define void @test_f62() #0 { - call void (i32, ...) @test_f62_helper(i32 0, <16 x float> %0, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double %lo, double %hi) -define void @test_f64() #0 { - call void (<16 x float>, ...) @test_f64_helper(<16 x float> %0, <16 x float> %1, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double %lo, double %hi) - call void (<16 x float>, ...) @test_f64_helper(<16 x float> %6, <16 x float> %7, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, %Complex* byval(%Complex) align 8 %literal1) diff --git a/test/test_suite14/abi/darwin64_sret.c3t b/test/test_suite14/abi/darwin64_sret.c3t deleted file mode 100644 index 64b7125fc..000000000 --- a/test/test_suite14/abi/darwin64_sret.c3t +++ /dev/null @@ -1,21 +0,0 @@ -// #target: macos-x64 -module foo; - -struct SimdDouble4x4 -{ - double[<4>][4] columns; -} - -fn SimdDouble4x4 ident(SimdDouble4x4 x) { - return x; -} - -/* #expect: foo.ll - -define void @foo_ident(%SimdDouble4x4* noalias sret(%SimdDouble4x4) align 32 %0, %SimdDouble4x4* byval(%SimdDouble4x4) align 32 %1) #0 { -entry: - %2 = bitcast %SimdDouble4x4* %0 to i8* - %3 = bitcast %SimdDouble4x4* %1 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 32 %2, i8* align 32 %3, i32 128, i1 false) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/abi/darwin64_sse.c3t b/test/test_suite14/abi/darwin64_sse.c3t deleted file mode 100644 index a425eb231..000000000 --- a/test/test_suite14/abi/darwin64_sse.c3t +++ /dev/null @@ -1,56 +0,0 @@ -// #target: macos-x64 -// #opt: --x86vec=sse -module test; - -define Mm256 = float[<8>]; -struct St256 { - Mm256 m; -} - -St256 x38; -Mm256 x37; - -extern fn void f38(St256 x); -extern fn void f37(Mm256 x); -fn void f39() { f38(x38); f37(x37); } - -// The two next tests make sure that the struct below is passed -// in the same way regardless of avx being used - -// CHECK: declare void @func40(%struct.t128* byval(%struct.t128) align 16) - -define Mm128 = float[<4>]; -struct Two128 { - Mm128 m; - Mm128 n; -} - -extern fn void func40(Two128 s); -fn void func41(Two128 s) { - func40(s); -} - -struct Atwo128 { - Mm128[2] array; -} - -struct Sa { - Atwo128 x; -} - -extern fn void func42(Sa s); -fn void func43(Sa s) { - func42(s); -} - - -/* #expect: test.ll - -declare void @f38(%St256* byval(%St256) align 32) -declare void @f37(<8 x float>* byval(<8 x float>) align 32) - -declare void @func40(%Two128* byval(%Two128) align 16) -define void @test_func41(%Two128* byval(%Two128) align 16 %0) - -declare void @func42(%Sa* byval(%Sa) align 16) -define void @test_func43(%Sa* byval(%Sa) align 16 %0) diff --git a/test/test_suite14/abi/darwin_arg.c3t b/test/test_suite14/abi/darwin_arg.c3t deleted file mode 100644 index ce0e37812..000000000 --- a/test/test_suite14/abi/darwin_arg.c3t +++ /dev/null @@ -1,26 +0,0 @@ -// #target: macos-x64 -module test; -struct Str -{ - union - { - float128 a; - long c; - } -} - -extern fn void d(Str s); -Str ss; -fn void f9122143() -{ - d(ss); -} - -/* #expect: test.ll - -declare void @d(i64, double) #0 - - %lo = load i64, i64* getelementptr inbounds ({ i64, double }, { i64, double }* bitcast (%Str* @test_ss to { i64, double }*), i32 0, i32 0), align 16 - %hi = load double, double* getelementptr inbounds ({ i64, double }, { i64, double }* bitcast (%Str* @test_ss to { i64, double }*), i32 0, i32 1), align 8 - call void @d(i64 %lo, double %hi) - ret void diff --git a/test/test_suite14/abi/darwinx64_1.c3t b/test/test_suite14/abi/darwinx64_1.c3t deleted file mode 100644 index 90ceda530..000000000 --- a/test/test_suite14/abi/darwinx64_1.c3t +++ /dev/null @@ -1,48 +0,0 @@ -// #target: macos-x64 -module test; - -fn char f0() { - return 0; -} - -fn short f1() { - return 0; -} - -fn int f2() { - return 0; -} - -fn float f3() { - return 0; -} - -fn double f4() { - return 0; -} - -fn void f6(char a0, short a1, int a2, long a3, void *a4) {} - -enum Enum7 : int { A, B, C } -fn void f7(Enum7 a0) {} - -struct Struct8 -{ - int a; - int b; -} - -fn Struct8 f8_1() { while (1) {} return Struct8 {}; } -fn void f8_2(Struct8 a0) {} - -/* #expect: test.ll - -define zeroext i8 @test_f0() -define signext i16 @test_f1() -define i32 @test_f2() -define float @test_f3() -define double @test_f4() -define void @test_f6(i8 zeroext %0, i16 signext %1, i32 %2, i64 %3, i8* %4) -define void @test_f7(i32 %0) -define i64 @test_f8_1() -define void @test_f8_2(i64 %0) #0 { diff --git a/test/test_suite14/abi/darwinx64_2.c3t b/test/test_suite14/abi/darwinx64_2.c3t deleted file mode 100644 index 713557505..000000000 --- a/test/test_suite14/abi/darwinx64_2.c3t +++ /dev/null @@ -1,186 +0,0 @@ -// #target: macos-x64 -module test; -import std; - -struct St12 -{ - int a @align(16); -} -fn St12 f12_0() { while (1) {}; unreachable(); } -fn void f12_1(St12 a0) {} - -struct St13_0 { long[3] f0; } -struct St13_1 { long[2] f0; } -fn St13_0 f13(int a, int b, int c, int d, - St13_1 e, int f) { while (1) {}; unreachable(); } - -fn void f14(int a, int b, int c, int d, int e, int f, ichar x) {} - -fn void f15(int a, int b, int c, int d, int e, int f, void *x) {} - -fn void f16(float a, float b, float c, float d, float e, float f, float g, float h, - float x) {} - -struct Fl18_s0 { int f0; } -fn void fl18(int a, Fl18_s0 f18_arg1) { while (1) {} } - -struct St20 @align(32) { - int x; - int y; -} -fn void f20(St20 x) {} - -struct StringRef -{ - int x; - char* ptr; -} -fn char *f21(StringRef s) { return s.x+s.ptr; } - -struct St22s @align(16) -{ ulong[2] x; } -fn void f22(St22s x, St22s y) { } - - - -struct St23S { - short f0; - uint f1; - int f2; -} - - -fn void f23(int a, St23S b) { -} - -struct St24s { int a; int b; } - -fn St23S f24(St23S *x, St24s *p2) -{ - return *x; - -} - -fn float[<4>] f25(float[<4>] x) { - return x+x; -} - -struct Foo26 { - int *x; - float *y; -} - -fn Foo26 f26(Foo26 *p) { - return *p; -} - - -struct V4f32wrapper { - float[<4>] v; -} - -fn V4f32wrapper f27(V4f32wrapper x) { - return x; -} - -// PR22563 - We should unwrap simple structs and arrays to pass -// and return them in the appropriate vector registers if possible. - -define V8f32 = float[<8>]; -struct V8f32wrapper { - V8f32 v; -} - -fn V8f32wrapper f27a(V8f32wrapper x) { - return x; -} - -struct V8f32wrapper_wrapper { - V8f32[1] v; -} - -fn V8f32wrapper_wrapper f27b(V8f32wrapper_wrapper x) { - return x; -} - -struct F28c { - double x; - int y; -} -fn void f28(F28c c) { -} - -struct Inner -{ - double x; - int y; -} -struct F29a -{ - Inner[1] c; -} - -fn void f29a(F29a a) { -} - -struct St0 { - char[8] f0; char f2; char f3; char f4; } -fn void f30(St0 p_4) { -} - -struct F31foo { float a, b, c; } -fn float f31(F31foo x) { - return x.c; -} - -define V1i64 = ulong[<1>]; - -fn V1i64 f34(V1i64 arg) { return arg; } - - -define V1i64_2 = uint[<2>]; -fn V1i64_2 f35(V1i64_2 arg) { return arg+arg; } - -define V2i32 = float[<2>]; -fn V2i32 f36(V2i32 arg) { return arg; } - - -/* #expect: test.ll - -define i32 @test_f12_0() -define void @test_f12_1(i32 %0) -define void @test_f13(%St13_0* noalias sret(%St13_0) align 8 %0, i32 %1, i32 %2, i32 %3, i32 %4, %St13_1* byval(%St13_1) align 8 %5, i32 %6) #0 { -define void @test_f14(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i8 signext %6) #0 { -define void @test_f15(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i8* %6) - -define void @test_f16(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7, float %8) - -define void @test_fl18(i32 %0, i32 %1) -define void @test_f20(%St20* byval(%St20) align 32 %0) -define i8* @test_f21(i64 %0, i8* %1) - -define void @test_f22(i64 %0, i64 %1, i64 %2, i64 %3) -entry: - %x = alloca %St22s, align 16 - %y = alloca %St22s, align 16 - -define void @test_f23(i32 %0, i64 %1, i32 %2) -define { i64, i32 } @test_f24(%St23S* %0, %St24s* %1) - -define <4 x float> @test_f25(<4 x float> %0) #0 { -entry: - %fadd = fadd <4 x float> %0, %0 - ret <4 x float> %fadd -} - -define { i32*, float* } @test_f26(%Foo26* %0) -define <4 x float> @test_f27(<4 x float> %0) -define <8 x float> @test_f27a(<8 x float> %0) -define <8 x float> @test_f27b(<8 x float> %0) -define void @test_f28(double %0, i32 %1) -define void @test_f29a(double %0, i32 %1) -define void @test_f30(i64 %0, i24 %1) -define float @test_f31(<2 x float> %0, float %1) -define double @test_f34(double %0) -define double @test_f35(double %0) -define double @test_f36(double %0) diff --git a/test/test_suite14/abi/literal_load.c3t b/test/test_suite14/abi/literal_load.c3t deleted file mode 100644 index 02dd36d0e..000000000 --- a/test/test_suite14/abi/literal_load.c3t +++ /dev/null @@ -1,31 +0,0 @@ -// #target: macos-x64 - -struct Test -{ - int x; -} - -Test foo = {}; - -extern fn void blorg(Test t); - -fn Test creator() -{ - blorg(Test{}); - return Test{}; -} - -// #expect: literal_load.ll - - %literal = alloca %Test, align 4 - %literal1 = alloca %Test, align 4 - %0 = bitcast %Test* %literal to i32* - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds %Test, %Test* %literal, i32 0, i32 0 - %2 = load i32, i32* %1, align 4 - call void @blorg(i32 %2) - %3 = bitcast %Test* %literal1 to i32* - store i32 0, i32* %3, align 4 - %4 = getelementptr inbounds %Test, %Test* %literal1, i32 0, i32 0 - %5 = load i32, i32* %4, align 4 - ret i32 %5 \ No newline at end of file diff --git a/test/test_suite14/abi/literal_load_aarch64.c3t b/test/test_suite14/abi/literal_load_aarch64.c3t deleted file mode 100644 index ea6de7b9d..000000000 --- a/test/test_suite14/abi/literal_load_aarch64.c3t +++ /dev/null @@ -1,38 +0,0 @@ -// #target: linux-aarch64 -module literal_load; - -struct Test -{ - int x; -} - -Test foo = {}; - -extern fn void blorg(Test t); - -fn Test creator() -{ - blorg(Test{}); - return Test{}; -} - -// #expect: literal_load.ll - -declare void @blorg(i64) #0 - -define i32 @literal_load_creator() #0 { -entry: - %literal = alloca %Test, align 4 - %literal1 = alloca %Test, align 4 - %0 = bitcast %Test* %literal to i32* - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds %Test, %Test* %literal, i32 0, i32 0 - %2 = load i32, i32* %1, align 4 - %3 = zext i32 %2 to i64 - call void @blorg(i64 %3) - %4 = bitcast %Test* %literal1 to i32* - store i32 0, i32* %4, align 4 - %5 = getelementptr inbounds %Test, %Test* %literal1, i32 0, i32 0 - %6 = load i32, i32* %5, align 4 - ret i32 %6 -} \ No newline at end of file diff --git a/test/test_suite14/abi/literal_load_mingw.c3t b/test/test_suite14/abi/literal_load_mingw.c3t deleted file mode 100644 index 18e5f6156..000000000 --- a/test/test_suite14/abi/literal_load_mingw.c3t +++ /dev/null @@ -1,32 +0,0 @@ -// #target: mingw-x64 -module literal_load; - -struct Test -{ - int x; -} - -Test foo = {}; - -extern fn void blorg(Test t); - -fn Test creator() -{ - blorg(Test{}); - return Test{}; -} - -// #expect: literal_load.ll - - %literal = alloca %Test, align 4 - %literal1 = alloca %Test, align 4 - %0 = bitcast %Test* %literal to i32* - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds %Test, %Test* %literal, i32 0, i32 0 - %2 = load i32, i32* %1, align 4 - call void @blorg(i32 %2) - %3 = bitcast %Test* %literal1 to i32* - store i32 0, i32* %3, align 4 - %4 = getelementptr inbounds %Test, %Test* %literal1, i32 0, i32 0 - %5 = load i32, i32* %4, align 4 - ret i32 %5 \ No newline at end of file diff --git a/test/test_suite14/abi/macho_section_attributes.c3 b/test/test_suite14/abi/macho_section_attributes.c3 deleted file mode 100644 index a889be39e..000000000 --- a/test/test_suite14/abi/macho_section_attributes.c3 +++ /dev/null @@ -1,8 +0,0 @@ -// #target: macos-x64 - -int foo @section("foo, 12345678901234567 "); // #error: Mach-o requires the section to be at the most 16 characters -int bar @section("foo, "); // #error: Mach-o requires 'segment,section' as the format, did you type it correctly? -int baz @section("foo"); // #error: Mach-o requires 'segment,section' as the format, did you type it correctly? -int abc @section("foo,b,c,d,e,f"); // #error: Too many parts to the Mach-o section description. -int def @section("foo,b,c,d"); - diff --git a/test/test_suite14/abi/pass_large_aarch.c3t b/test/test_suite14/abi/pass_large_aarch.c3t deleted file mode 100644 index 3e156d241..000000000 --- a/test/test_suite14/abi/pass_large_aarch.c3t +++ /dev/null @@ -1,37 +0,0 @@ -// #target: linux-aarch64 - -module pass_large; - - -struct Large -{ - void*[8] pointers; -} - -extern fn void pass_large(Large large); - -fn void example() -{ - Large l = {}; - pass_large(l); - pass_large(l); -} - -/* #expect: pass_large.ll - -define void @pass_large_example() -entry: - %l = alloca %Large, align 8 - %indirectarg = alloca %Large, align 8 - %indirectarg1 = alloca %Large, align 8 - %0 = bitcast %Large* %l to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %0, i8 0, i64 64, i1 false) - %1 = bitcast %Large* %indirectarg to i8* - %2 = bitcast %Large* %l to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %1, i8* align 8 %2, i32 64, i1 false) - call void @pass_large(%Large* align 8 %indirectarg) - %3 = bitcast %Large* %indirectarg1 to i8* - %4 = bitcast %Large* %l to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 64, i1 false) - call void @pass_large(%Large* align 8 %indirectarg1) - ret void diff --git a/test/test_suite14/abi/regcall_expand.c3t b/test/test_suite14/abi/regcall_expand.c3t deleted file mode 100644 index b712caf02..000000000 --- a/test/test_suite14/abi/regcall_expand.c3t +++ /dev/null @@ -1,55 +0,0 @@ -// #target: mingw-x64 -module test; - -extern fn void printf(char*, ...); - -struct Foo -{ - float[2] x; -} -fn void test(Foo x) @regcall -{ -} - -fn int main() -{ - test(Foo { }); - return 0; -} - -/* #expect: test.ll - -%Foo = type { [2 x float] } - -$"ct$test_Foo" = comdat any - -@"ct$test_Foo" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 1, [0 x i64] zeroinitializer }, comdat, align 8 - -define x86_regcallcc void @test_test(float %0, float %1) #0 { -entry: - %x = alloca %Foo, align 4 - %2 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %3 = getelementptr inbounds [2 x float], [2 x float]* %2, i64 0, i64 0 - store float %0, float* %3, align 4 - %4 = getelementptr inbounds [2 x float], [2 x float]* %2, i64 0, i64 1 - store float %1, float* %4, align 4 - ret void -} - -; Function Attrs: nounwind -define i32 @main() #0 { -entry: - %literal = alloca %Foo, align 4 - %0 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 0 - %1 = getelementptr inbounds [2 x float], [2 x float]* %0, i64 0, i64 0 - store float 0.000000e+00, float* %1, align 4 - %2 = getelementptr inbounds [2 x float], [2 x float]* %0, i64 0, i64 1 - store float 0.000000e+00, float* %2, align 4 - %3 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 0 - %4 = getelementptr inbounds [2 x float], [2 x float]* %3, i64 0, i64 0 - %loadexpanded = load float, float* %4, align 4 - %5 = getelementptr inbounds [2 x float], [2 x float]* %3, i64 0, i64 1 - %loadexpanded1 = load float, float* %5, align 4 - call x86_regcallcc void @test_test(float %loadexpanded, float %loadexpanded1) - ret i32 0 -} \ No newline at end of file diff --git a/test/test_suite14/abi/riscv64-lp64-abi.c3t b/test/test_suite14/abi/riscv64-lp64-abi.c3t deleted file mode 100644 index 3bb7951bd..000000000 --- a/test/test_suite14/abi/riscv64-lp64-abi.c3t +++ /dev/null @@ -1,48 +0,0 @@ -// #target: linux-riscv64 -module test; - -struct Large { - long a, b, c, d; -} - -define V32i8 = char[<32>]; - -fn int f_scalar_stack_1(int a, int128 b, float c, float128 d, V32i8 e, - char f, char g, char h) { - return g + h; -} - -fn Large f_scalar_stack_2(double a, int128 b, float128 c, V32i8 d, - char e, ichar f, char g) { - return Large {(long)(a), e, f, g}; -} - -/* #expect: test.ll - -define signext i32 @test_f_scalar_stack_1(i32 signext %0, i128 %1, float %2, fp128 %3, <32 x i8>* align 32 %4, i8 zeroext %5, i8 %6, i8 %7) #0 { -entry: - %uisiext = zext i8 %6 to i32 - %uisiext1 = zext i8 %7 to i32 - %add = add i32 %uisiext, %uisiext1 - ret i32 %add -} -define void @test_f_scalar_stack_2(%Large* noalias sret(%Large) align 8 %0, double %1, i128 %2, fp128 %3, <32 x i8>* align 32 %4, i8 zeroext %5, i8 %6, i8 %7) #0 { -entry: - %literal = alloca %Large, align 8 - %8 = getelementptr inbounds %Large, %Large* %literal, i32 0, i32 0 - %fpsi = fptosi double %1 to i64 - store i64 %fpsi, i64* %8, align 8 - %9 = getelementptr inbounds %Large, %Large* %literal, i32 0, i32 1 - %uisiext = zext i8 %5 to i64 - store i64 %uisiext, i64* %9, align 8 - %10 = getelementptr inbounds %Large, %Large* %literal, i32 0, i32 2 - %sisiext = sext i8 %6 to i64 - store i64 %sisiext, i64* %10, align 8 - %11 = getelementptr inbounds %Large, %Large* %literal, i32 0, i32 3 - %uisiext1 = zext i8 %7 to i64 - store i64 %uisiext1, i64* %11, align 8 - %12 = bitcast %Large* %0 to i8* - %13 = bitcast %Large* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %12, i8* align 8 %13, i32 32, i1 false) - ret void -} diff --git a/test/test_suite14/abi/small_struct_x64.c3t b/test/test_suite14/abi/small_struct_x64.c3t deleted file mode 100644 index 3c953d485..000000000 --- a/test/test_suite14/abi/small_struct_x64.c3t +++ /dev/null @@ -1,80 +0,0 @@ -// #target: macos-x64 -module test; -struct Foo -{ - char a; - char b; - char c; -} - -fn int testing() -{ - Foo y = getFoo(Foo { 4, 5, 6 }); - return y.a + y.c; -} - -fn Foo getFoo(Foo f) -{ - return Foo { 1, 2, 3 }; -} - -/* #expect: test.ll - -define i32 @test_testing() #0 { -entry: - %y = alloca %Foo, align 1 - %literal = alloca %Foo, align 1 - %tempcoerce = alloca i24, align 4 - %result = alloca %Foo, align 1 - %tempcoerce1 = alloca i24, align 4 - %0 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 0 - store i8 4, i8* %0, align 1 - %1 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 1 - store i8 5, i8* %1, align 1 - %2 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 2 - store i8 6, i8* %2, align 1 - %3 = bitcast i24* %tempcoerce to i8* - %4 = bitcast %Foo* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 1 %4, i32 3, i1 false) - %5 = load i24, i24* %tempcoerce, align 4 - %6 = call i24 @test_getFoo(i24 %5) - store i24 %6, i24* %tempcoerce1, align 4 - %7 = bitcast %Foo* %result to i8* - %8 = bitcast i24* %tempcoerce1 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %7, i8* align 4 %8, i32 3, i1 false) - %9 = bitcast %Foo* %y to i8* - %10 = bitcast %Foo* %result to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %9, i8* align 1 %10, i32 3, i1 false) - %11 = getelementptr inbounds %Foo, %Foo* %y, i32 0, i32 0 - %12 = load i8, i8* %11, align 1 - %uisiext = zext i8 %12 to i32 - %13 = getelementptr inbounds %Foo, %Foo* %y, i32 0, i32 2 - %14 = load i8, i8* %13, align 1 - %uisiext2 = zext i8 %14 to i32 - %add = add i32 %uisiext, %uisiext2 - ret i32 %add -} - -; Function Attrs: nounwind -define i24 @test_getFoo(i24 %0) #0 { -entry: - %f = alloca %Foo, align 1 - %tempcoerce = alloca i24, align 4 - %literal = alloca %Foo, align 1 - %tempcoerce1 = alloca i24, align 4 - store i24 %0, i24* %tempcoerce, align 4 - %1 = bitcast %Foo* %f to i8* - %2 = bitcast i24* %tempcoerce to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %1, i8* align 4 %2, i32 3, i1 false) - %3 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 0 - store i8 1, i8* %3, align 1 - %4 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 1 - store i8 2, i8* %4, align 1 - %5 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 2 - store i8 3, i8* %5, align 1 - %6 = bitcast i24* %tempcoerce1 to i8* - %7 = bitcast %Foo* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 1 %7, i32 3, i1 false) - %8 = load i24, i24* %tempcoerce1, align 4 - ret i24 %8 -} diff --git a/test/test_suite14/abi/sysv_abi_avx.c3t b/test/test_suite14/abi/sysv_abi_avx.c3t deleted file mode 100644 index 8f36042b0..000000000 --- a/test/test_suite14/abi/sysv_abi_avx.c3t +++ /dev/null @@ -1,42 +0,0 @@ -// #target: linux-x64 -// #opt: --x86vec=avx512 -module foo; - -struct StringRef -{ - char* str; - usz size; -} - -char gc; -extern fn void take_stringref(StringRef s); -fn void callit() -{ - StringRef s = { "asdf" , 4}; - take_stringref(s); -} - -extern fn float[<8>] get_m256(); -extern fn void take_m256(float[<8>] x); -extern fn float[<16>] get_m512(); -extern fn void take_m512(float[<16>] x); - -fn void use_vectors() -{ - float[<8>] v1 = get_m256(); - take_m256(v1); - float[<16>] v2 = get_m512(); - take_m512(v2); -} - -/* #expect: foo.ll - -declare void @take_stringref(i8*, i64) #0 -call void @take_stringref(i8* %lo, i64 %hi) - -define void @foo_use_vectors() #0 { -entry: - %0 = call <8 x float> @get_m256() - call void @take_m256(<8 x float> %1) - %2 = call <16 x float> @get_m512() - call void @take_m512(<16 x float> %3) diff --git a/test/test_suite14/abi/sysv_abi_noavx.c3t b/test/test_suite14/abi/sysv_abi_noavx.c3t deleted file mode 100644 index 75c83e061..000000000 --- a/test/test_suite14/abi/sysv_abi_noavx.c3t +++ /dev/null @@ -1,42 +0,0 @@ -// #target: linux-x64 -// #opt: --x86vec=none -module foo; - -struct StringRef -{ - char* str; - usz size; -} - -char gc; -extern fn void take_stringref(StringRef s); -fn void callit() -{ - StringRef s = { "asdf" , 4}; - take_stringref(s); -} - -extern fn float[<8>] get_m256(); -extern fn void take_m256(float[<8>] x); -extern fn float[<16>] get_m512(); -extern fn void take_m512(float[<16>] x); - -fn void use_vectors() -{ - float[<8>] v1 = get_m256(); - take_m256(v1); - float[<16>] v2 = get_m512(); - take_m512(v2); -} - -/* #expect: foo.ll - -declare void @take_stringref(i8*, i64) #0 - call void @take_stringref(i8* %lo, i64 %hi) - -define void @foo_use_vectors() #0 { -entry: - %0 = call <8 x float> @get_m256() - call void @take_m256(<8 x float>* byval(<8 x float>) align 32 %v1) - %1 = call <16 x float> @get_m512() - call void @take_m512(<16 x float>* byval(<16 x float>) align 64 %v2) diff --git a/test/test_suite14/abi/sysv_direct_coerce.c3t b/test/test_suite14/abi/sysv_direct_coerce.c3t deleted file mode 100644 index a81bf313a..000000000 --- a/test/test_suite14/abi/sysv_direct_coerce.c3t +++ /dev/null @@ -1,47 +0,0 @@ -// #target: macos-x64 -module foo; - -struct Rectangle -{ - float x; // Rectangle top-left corner position x - float y; // Rectangle top-left corner position y - float width; // Rectangle width - float height; // Rectangle height -} - -fn void test(Rectangle r) -{ - test(Rectangle { 1, 2, 3, 4 }); -} - -/* #expect: foo.ll - -define void @foo_test(<2 x float> %0, <2 x float> %1) #0 { -entry: - %r = alloca %Rectangle, align 4 - %literal = alloca %Rectangle, align 4 - %coerce = alloca %Rectangle, align 8 - %pair = bitcast %Rectangle* %r to { <2 x float>, <2 x float> }* - %2 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %pair, i32 0, i32 0 - store <2 x float> %0, <2 x float>* %2, align 4 - %3 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %pair, i32 0, i32 1 - store <2 x float> %1, <2 x float>* %3, align 4 - %4 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 0 - store float 1.000000e+00, float* %4, align 4 - %5 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 1 - store float 2.000000e+00, float* %5, align 4 - %6 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 2 - store float 3.000000e+00, float* %6, align 4 - %7 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 3 - store float 4.000000e+00, float* %7, align 4 - %8 = bitcast %Rectangle* %coerce to { <2 x float>, <2 x float> }* - %9 = bitcast { <2 x float>, <2 x float> }* %8 to i8* - %10 = bitcast %Rectangle* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %9, i8* align 4 %10, i32 16, i1 false) - %11 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %8, i32 0, i32 0 - %lo = load <2 x float>, <2 x float>* %11, align 8 - %12 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %8, i32 0, i32 1 - %hi = load <2 x float>, <2 x float>* %12, align 8 - call void @foo_test(<2 x float> %lo, <2 x float> %hi) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/abi/test_sret.c3t b/test/test_suite14/abi/test_sret.c3t deleted file mode 100644 index ec8b22292..000000000 --- a/test/test_suite14/abi/test_sret.c3t +++ /dev/null @@ -1,31 +0,0 @@ -// #target: macos-x64 - -struct Abc { - long a; - long b; - long c; - long d; - long e; -} - -extern fn Abc foo1(); -extern fn Abc foo2(); - -fn void bar() { - Abc dummy1 = foo1(); - Abc dummy2 = foo2(); -} - -// Cleanup for this result, since it's creating an unnecessary sret. - -// #expect: test_sret.ll - -declare void @foo1(%Abc* noalias sret(%Abc) align 8) - -declare void @foo2(%Abc* noalias sret(%Abc) align 8) - - %dummy1 = alloca %Abc, align 8 - %dummy2 = alloca %Abc, align 8 - call void @foo1(%Abc* sret(%Abc) align 8 %dummy1) - call void @foo2(%Abc* sret(%Abc) align 8 %dummy2) - ret void diff --git a/test/test_suite14/abi/union_x64.c3t b/test/test_suite14/abi/union_x64.c3t deleted file mode 100644 index 9490947df..000000000 --- a/test/test_suite14/abi/union_x64.c3t +++ /dev/null @@ -1,38 +0,0 @@ -// #target: macos-x64 - -module unionx64; - -union Foo -{ - long a; - char[12] b; -} -extern fn void hello2(Foo f); - -fn void hello(Foo f) -{ - hello2(f); -} - -/* #expect: unionx64.ll - -%Foo = type { i64, [8 x i8] } - -declare void @hello2(i64, i64) #0 - -define void @unionx64_hello(i64 %0, i64 %1) #0 { -entry: - %f = alloca %Foo, align 8 - %pair = bitcast %Foo* %f to { i64, i64 }* - %2 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %pair, i32 0, i32 0 - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - %4 = bitcast %Foo* %f to { i64, i64 }* - %5 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %4, i32 0, i32 0 - %lo = load i64, i64* %5, align 8 - %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %4, i32 0, i32 1 - %hi = load i64, i64* %6, align 8 - call void @hello2(i64 %lo, i64 %hi) - ret void -} diff --git a/test/test_suite14/abi/vec2_aarch64.c3t b/test/test_suite14/abi/vec2_aarch64.c3t deleted file mode 100644 index 8f29e8784..000000000 --- a/test/test_suite14/abi/vec2_aarch64.c3t +++ /dev/null @@ -1,100 +0,0 @@ -// #target: linux-aarch64 -module abi; - -struct Vector2 { - float x; - float y; -} -extern fn Vector2 vector2_zero() { return Vector2 {}; } -extern fn Vector2 vector2_one() { return Vector2 {}; } -extern fn Vector2 vector2_add(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern fn Vector2 vector2_add_value(Vector2 v, float add) { return Vector2 {}; } -extern fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern fn Vector2 vector2_subtract_value(Vector2 v, float sub) { return Vector2 {}; } - -// #expect: abi.ll -%Vector2 = type { float, float } - -define %Vector2 @vector2_zero() #0 { -entry: - %literal = alloca %Vector2, align 4 - %0 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %0, align 4 - %1 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %1, align 4 - %2 = load %Vector2, %Vector2* %literal, align 4 - ret %Vector2 %2 -} - -define %Vector2 @vector2_one() #0 { -entry: - %literal = alloca %Vector2, align 4 - %0 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %0, align 4 - %1 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %1, align 4 - %2 = load %Vector2, %Vector2* %literal, align 4 - ret %Vector2 %2 -} - -define %Vector2 @vector2_add([2 x float] %0, [2 x float] %1) #0 { -entry: - %v1 = alloca %Vector2, align 4 - %v2 = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v1 to [2 x float]* - store [2 x float] %0, [2 x float]* %2, align 4 - %3 = bitcast %Vector2* %v2 to [2 x float]* - store [2 x float] %1, [2 x float]* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %4, align 4 - %5 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %5, align 4 - %6 = load %Vector2, %Vector2* %literal, align 4 - ret %Vector2 %6 -} - -define %Vector2 @vector2_add_value([2 x float] %0, float %1) #0 { -entry: - %v = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v to [2 x float]* - store [2 x float] %0, [2 x float]* %2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = load %Vector2, %Vector2* %literal, align 4 - ret %Vector2 %5 -} - -define %Vector2 @vector2_subtract([2 x float] %0, [2 x float] %1) #0 { -entry: - %v1 = alloca %Vector2, align 4 - %v2 = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v1 to [2 x float]* - store [2 x float] %0, [2 x float]* %2, align 4 - %3 = bitcast %Vector2* %v2 to [2 x float]* - store [2 x float] %1, [2 x float]* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %4, align 4 - %5 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %5, align 4 - %6 = load %Vector2, %Vector2* %literal, align 4 - ret %Vector2 %6 -} - -define %Vector2 @vector2_subtract_value([2 x float] %0, float %1) #0 { -entry: - %v = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v to [2 x float]* - store [2 x float] %0, [2 x float]* %2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = load %Vector2, %Vector2* %literal, align 4 - ret %Vector2 %5 -} diff --git a/test/test_suite14/abi/vec2_wasm.c3t b/test/test_suite14/abi/vec2_wasm.c3t deleted file mode 100644 index a976b652c..000000000 --- a/test/test_suite14/abi/vec2_wasm.c3t +++ /dev/null @@ -1,99 +0,0 @@ -// #target: wasm32 -module abi; - -struct Vector2 { - float x; - float y; -} -extern fn Vector2 vector2_zero() { return Vector2 {}; } -extern fn Vector2 vector2_one() { return Vector2 {}; } -extern fn Vector2 vector2_add(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern fn Vector2 vector2_add_value(Vector2 v, float add) { return Vector2 {}; } -extern fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern fn Vector2 vector2_subtract_value(Vector2 v, float sub) { return Vector2 {}; } - -// #expect: abi.ll -target triple = "wasm32-unknown-unknown" - -%Vector2 = type { float, float } - -define void @vector2_zero(%Vector2* noalias sret(%Vector2) align 4 %0) #0 { -entry: - %literal = alloca %Vector2, align 4 - %1 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %1, align 4 - %2 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %2, align 4 - %3 = bitcast %Vector2* %0 to i8* - %4 = bitcast %Vector2* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) - ret void -} - -define void @vector2_one(%Vector2* noalias sret(%Vector2) align 4 %0) #0 { -entry: - %literal = alloca %Vector2, align 4 - %1 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %1, align 4 - %2 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %2, align 4 - %3 = bitcast %Vector2* %0 to i8* - %4 = bitcast %Vector2* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false) - ret void -} - -define void @vector2_add(%Vector2* noalias sret(%Vector2) align 4 %0, %Vector2* byval(%Vector2) align 4 %1, %Vector2* byval(%Vector2) align 4 %2) #0 { -entry: - %literal = alloca %Vector2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = bitcast %Vector2* %0 to i8* - %6 = bitcast %Vector2* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) - ret void -} - -; Function Attrs: nounwind -define void @vector2_add_value(%Vector2* noalias sret(%Vector2) align 4 %0, %Vector2* byval(%Vector2) align 4 %1, float %2) #0 { -entry: - %literal = alloca %Vector2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = bitcast %Vector2* %0 to i8* - %6 = bitcast %Vector2* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) - ret void -} - -; Function Attrs: nounwind -define void @vector2_subtract(%Vector2* noalias sret(%Vector2) align 4 %0, %Vector2* byval(%Vector2) align 4 %1, %Vector2* byval(%Vector2) align 4 %2) #0 { -entry: - %literal = alloca %Vector2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = bitcast %Vector2* %0 to i8* - %6 = bitcast %Vector2* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) - ret void -} - -; Function Attrs: nounwind -define void @vector2_subtract_value(%Vector2* noalias sret(%Vector2) align 4 %0, %Vector2* byval(%Vector2) align 4 %1, float %2) #0 { -entry: - %literal = alloca %Vector2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = bitcast %Vector2* %0 to i8* - %6 = bitcast %Vector2* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false) - ret void -} diff --git a/test/test_suite14/abi/vec2_x64.c3t b/test/test_suite14/abi/vec2_x64.c3t deleted file mode 100644 index d3a81963b..000000000 --- a/test/test_suite14/abi/vec2_x64.c3t +++ /dev/null @@ -1,110 +0,0 @@ -// #target: macos-x64 -module abi; - -struct Vector2 { - float x; - float y; -} -extern fn Vector2 vector2_zero() { return Vector2 {}; } -extern fn Vector2 vector2_one() { return Vector2 {}; } -extern fn Vector2 vector2_add(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern fn Vector2 vector2_add_value(Vector2 v, float add) { return Vector2 {}; } -extern fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) { return Vector2 {}; } -extern fn Vector2 vector2_subtract_value(Vector2 v, float sub) { return Vector2 {}; } - -/* #expect: abi.ll - -%Vector2 = type { float, float } - -define <2 x float> @vector2_zero() #0 { -entry: - %literal = alloca %Vector2, align 4 - %0 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %0, align 4 - %1 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %1, align 4 - %2 = bitcast %Vector2* %literal to <2 x float>* - %3 = load <2 x float>, <2 x float>* %2, align 4 - ret <2 x float> %3 -} - -define <2 x float> @vector2_one() #0 { -entry: - %literal = alloca %Vector2, align 4 - %0 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %0, align 4 - %1 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %1, align 4 - %2 = bitcast %Vector2* %literal to <2 x float>* - %3 = load <2 x float>, <2 x float>* %2, align 4 - ret <2 x float> %3 -} - -define <2 x float> @vector2_add(<2 x float> %0, <2 x float> %1) #0 { -entry: - %v1 = alloca %Vector2, align 4 - %v2 = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v1 to <2 x float>* - store <2 x float> %0, <2 x float>* %2, align 4 - %3 = bitcast %Vector2* %v2 to <2 x float>* - store <2 x float> %1, <2 x float>* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %4, align 4 - %5 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %5, align 4 - %6 = bitcast %Vector2* %literal to <2 x float>* - %7 = load <2 x float>, <2 x float>* %6, align 4 - ret <2 x float> %7 -} - -; Function Attrs: nounwind -define <2 x float> @vector2_add_value(<2 x float> %0, float %1) #0 { -entry: - %v = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v to <2 x float>* - store <2 x float> %0, <2 x float>* %2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = bitcast %Vector2* %literal to <2 x float>* - %6 = load <2 x float>, <2 x float>* %5, align 4 - ret <2 x float> %6 -} - -; Function Attrs: nounwind -define <2 x float> @vector2_subtract(<2 x float> %0, <2 x float> %1) #0 { -entry: - %v1 = alloca %Vector2, align 4 - %v2 = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v1 to <2 x float>* - store <2 x float> %0, <2 x float>* %2, align 4 - %3 = bitcast %Vector2* %v2 to <2 x float>* - store <2 x float> %1, <2 x float>* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %4, align 4 - %5 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %5, align 4 - %6 = bitcast %Vector2* %literal to <2 x float>* - %7 = load <2 x float>, <2 x float>* %6, align 4 - ret <2 x float> %7 -} - -; Function Attrs: nounwind -define <2 x float> @vector2_subtract_value(<2 x float> %0, float %1) #0 { -entry: - %v = alloca %Vector2, align 4 - %literal = alloca %Vector2, align 4 - %2 = bitcast %Vector2* %v to <2 x float>* - store <2 x float> %0, <2 x float>* %2, align 4 - %3 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %Vector2, %Vector2* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %4, align 4 - %5 = bitcast %Vector2* %literal to <2 x float>* - %6 = load <2 x float>, <2 x float>* %5, align 4 - ret <2 x float> %6 -} diff --git a/test/test_suite14/abi/x64alignarray.c3t b/test/test_suite14/abi/x64alignarray.c3t deleted file mode 100644 index 55b2cefb4..000000000 --- a/test/test_suite14/abi/x64alignarray.c3t +++ /dev/null @@ -1,28 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn void test1_f(void *); - -fn void test1_g() -{ - float[4] x; - test1_f(&x); -} - -/* #expect: test.ll - -define void @test_test1_g() #0 { -entry: - %x = alloca [4 x float], align 16 - %0 = getelementptr inbounds [4 x float], [4 x float]* %x, i64 0, i64 0 - store float 0.000000e+00, float* %0, align 4 - %1 = getelementptr inbounds [4 x float], [4 x float]* %x, i64 0, i64 1 - store float 0.000000e+00, float* %1, align 4 - %2 = getelementptr inbounds [4 x float], [4 x float]* %x, i64 0, i64 2 - store float 0.000000e+00, float* %2, align 4 - %3 = getelementptr inbounds [4 x float], [4 x float]* %x, i64 0, i64 3 - store float 0.000000e+00, float* %3, align 4 - %ptrptr = bitcast [4 x float]* %x to i8* - call void @test1_f(i8* %ptrptr) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/arrays/array_casts.c3t b/test/test_suite14/arrays/array_casts.c3t deleted file mode 100644 index 7c2419f00..000000000 --- a/test/test_suite14/arrays/array_casts.c3t +++ /dev/null @@ -1,34 +0,0 @@ -// #target: macos-x64 - -module array_casts; - -fn void test() -{ - int[3] x; - int *y = &x; - int[] z = &x; -} - -// #expect: array_casts.ll - -%"int[]" = type { i32*, i64 } - -define void @array_casts_test() #0 { -entry: - %x = alloca [3 x i32], align 4 - %y = alloca i32*, align 8 - %z = alloca %"int[]", align 8 - %0 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 0 - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - store i32 0, i32* %1, align 4 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 2 - store i32 0, i32* %2, align 4 - %ptrptr = bitcast [3 x i32]* %x to i32* - store i32* %ptrptr, i32** %y, align 8 - %3 = bitcast [3 x i32]* %x to i32* - %4 = insertvalue %"int[]" undef, i32* %3, 0 - %5 = insertvalue %"int[]" %4, i64 3, 1 - store %"int[]" %5, %"int[]"* %z, align 8 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/arrays/array_indexing.c3 b/test/test_suite14/arrays/array_indexing.c3 deleted file mode 100644 index 72cb162f6..000000000 --- a/test/test_suite14/arrays/array_indexing.c3 +++ /dev/null @@ -1,11 +0,0 @@ -enum Foo : int -{ - TEST -} - -int[100] a = { [Foo.TEST] = 123 }; - -fn void test() -{ - a[Foo.TEST] = 33; -} \ No newline at end of file diff --git a/test/test_suite14/arrays/array_invalid_casts.c3 b/test/test_suite14/arrays/array_invalid_casts.c3 deleted file mode 100644 index 869499795..000000000 --- a/test/test_suite14/arrays/array_invalid_casts.c3 +++ /dev/null @@ -1,12 +0,0 @@ - -fn void test() -{ - int[3] x; - double *y = &x; // #error: 'int[3]*' to 'double* -} - -fn void test2() -{ - int[3] x; - double[] z = &x; // #error: 'int[3]*' to 'double[]' -} \ No newline at end of file diff --git a/test/test_suite14/arrays/array_literal.c3t b/test/test_suite14/arrays/array_literal.c3t deleted file mode 100644 index 10a74df30..000000000 --- a/test/test_suite14/arrays/array_literal.c3t +++ /dev/null @@ -1,28 +0,0 @@ -// #target: macos-x64 -module array_literal; - -fn double test(uint x) -{ - double[30] student_t = { 0.0 , 12.706 , 4.303 , 3.182 , 2.776 , 2.571 , - 2.447 , 2.365 , 2.306 , 2.262 , 2.228 , - 2.201 , 2.179 , 2.160 , 2.145 , 2.131 , - 2.120 , 2.110 , 2.101 , 2.093 , 2.086 , - 2.080 , 2.074 , 2.069 , 2.064 , 2.060 , - 2.056 , 2.052 , 2.048 , 2.045 }; - return student_t[x]; -} - -/* #expect: array_literal.ll - -@.__const = private unnamed_addr constant [30 x double] [double 0.000000e+00, double 1.270600e+01, double 4.303000e+00, double 3.182000e+00, double 2.776000e+00, double 2.571000e+00, double 2.447000e+00, double 2.365000e+00, double 2.306000e+00, double 2.262000e+00, double 2.228000e+00, double 2.201000e+00, double 2.179000e+00, double 2.160000e+00, double 2.145000e+00, double 2.131000e+00, double 2.120000e+00, double 2.110000e+00, double 2.101000e+00, double 2.093000e+00, double 2.086000e+00, double 2.080000e+00, double 2.074000e+00, double 2.069000e+00, double 2.064000e+00, double 2.060000e+00, double 2.056000e+00, double 2.052000e+00, double 2.048000e+00, double 2.045000e+00], align 16 - -define double @array_literal_test(i32 %0) #0 { -entry: - %student_t = alloca [30 x double], align 16 - %1 = bitcast [30 x double]* %student_t to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %1, i8* align 16 bitcast ([30 x double]* @.__const to i8*), i32 240, i1 false) - %zext = zext i32 %0 to i64 - %2 = getelementptr inbounds [30 x double], [30 x double]* %student_t, i64 0, i64 %zext - %3 = load double, double* %2, align 8 - ret double %3 -} diff --git a/test/test_suite14/arrays/array_struct.c3t b/test/test_suite14/arrays/array_struct.c3t deleted file mode 100644 index 95a64f13f..000000000 --- a/test/test_suite14/arrays/array_struct.c3t +++ /dev/null @@ -1,13 +0,0 @@ -// #target: macos-x64 -module test; - -struct Foo -{ - int x, y; -} - -private Foo[10] array; - -// #expect: test.ll - -@test_array = protected unnamed_addr global [10 x %Foo] zeroinitializer, align 16 \ No newline at end of file diff --git a/test/test_suite14/arrays/complex_array_const.c3t b/test/test_suite14/arrays/complex_array_const.c3t deleted file mode 100644 index 85b28771f..000000000 --- a/test/test_suite14/arrays/complex_array_const.c3t +++ /dev/null @@ -1,21 +0,0 @@ -// #target: macos-x64 -module test; - -struct Connection -{ - long to; - char* type; - long length; -} - -private Connection[3] link -= { {1, "link1", 10}, - {2, "link2", 20}, - {3, "link3", 30} }; - -// #expect: test.ll - -@.str = private unnamed_addr constant [6 x i8] c"link1\00", align 1 -@.str.1 = private unnamed_addr constant [6 x i8] c"link2\00", align 1 -@.str.2 = private unnamed_addr constant [6 x i8] c"link3\00", align 1 -@test_link = protected unnamed_addr global [3 x %Connection] [%Connection { i64 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 10 }, %Connection { i64 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i64 20 }, %Connection { i64 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i64 30 }], align 16 diff --git a/test/test_suite14/arrays/global_array_non_const.c3 b/test/test_suite14/arrays/global_array_non_const.c3 deleted file mode 100644 index da0d1cb95..000000000 --- a/test/test_suite14/arrays/global_array_non_const.c3 +++ /dev/null @@ -1,17 +0,0 @@ - -const int CONSTANT = 1; -int[CONSTANT] a2; -int[3] a3 = { [CONSTANT] = 1 }; -const bool B = true; -int[B] c2; // #error: Expected an integer - -int non_constant = 10; -int[non_constant] b; // #error: Expected a constant value as - -fn int foo() -{ - return 10; -} - -int[foo()] c; // #error: Expected a constant value as - diff --git a/test/test_suite14/arrays/global_init.c3t b/test/test_suite14/arrays/global_init.c3t deleted file mode 100644 index 23b6868f6..000000000 --- a/test/test_suite14/arrays/global_init.c3t +++ /dev/null @@ -1,71 +0,0 @@ -// #target: macos-x64 -module test; - -int* foo = &&3; - -int a; -int c; -int d; -int[3] abc; -int *b = (&((&a + 1)[2]) + 1 - 2) + 5; -int *bf = &abc[2] + 2; -int *bf2 = &abc[2]; -int *bf3 = &abc[2] + 2; - -fn void main() { - int *bf34 = (&abc[2] + 2) + 3; - static variant[3] x = { &&42, &&'c', &&"for" }; - variant[3] y = { &&42, &&'c', &&"for" }; -} - -/* #expect: test.ll - -@.taddr = private global i32 3, align 4 -@test_foo = local_unnamed_addr global i32* @.taddr, align 8 -@test_a = global i32 0, align 4 -@test_c = local_unnamed_addr global i32 0, align 4 -@test_d = local_unnamed_addr global i32 0, align 4 -@test_abc = local_unnamed_addr global [3 x i32] zeroinitializer, align 4 -@test_b = local_unnamed_addr global i32* getelementptr (i32, i32* @test_a, i64 7), align 8 -@test_bf = local_unnamed_addr global i32* getelementptr ([3 x i32], [3 x i32]* @test_abc, i64 1, i64 1), align 8 -@test_bf2 = local_unnamed_addr global i32* getelementptr inbounds ([3 x i32], [3 x i32]* @test_abc, i64 0, i64 2), align 8 -@test_bf3 = local_unnamed_addr global i32* getelementptr ([3 x i32], [3 x i32]* @test_abc, i64 1, i64 1), align 8 -@.taddr.9 = private global i32 42, align 4 -@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@.taddr.10 = private global i8 99, align 1 -@"ct$char" = linkonce constant %.introspect { i8 3, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@.str = private unnamed_addr constant [4 x i8] c"for\00", align 1 -@.taddr.11 = private global [3 x i8]* bitcast ([4 x i8]* @.str to [3 x i8]*), align 8 -@"ct$a3$char" = linkonce constant %.introspect { i8 15, i64 3, i64 ptrtoint (%.introspect* @"ct$char" to i64), i64 3, [0 x i64] zeroinitializer }, align 8 -@"ct$p$a3$char" = linkonce constant %.introspect { i8 19, i64 8, i64 ptrtoint (%.introspect* @"ct$a3$char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 -@"main$x" = internal unnamed_addr global [3 x %variant] [%variant { i8* bitcast (i32* @.taddr.9 to i8*), i64 ptrtoint (%.introspect* @"ct$int" to i64) }, %variant { i8* @.taddr.10, i64 ptrtoint (%.introspect* @"ct$char" to i64) }, %variant { i8* bitcast ([3 x i8]** @.taddr.11 to i8*), i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64) }], align 16 -@.str.12 = private unnamed_addr constant [4 x i8] c"for\00", align 1 - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %bf34 = alloca i32*, align 8 - %y = alloca [3 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca i8, align 1 - %taddr2 = alloca [3 x i8]*, align 8 - store i32* getelementptr - %0 = getelementptr inbounds [3 x %variant], [3 x %variant]* %y, i64 0, i64 0 - store i32 42, i32* %taddr, align 4 - %1 = bitcast i32* %taddr to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %3, %variant* %0, align 16 - %4 = getelementptr inbounds [3 x %variant], [3 x %variant]* %y, i64 0, i64 1 - store i8 99, i8* %taddr1, align 1 - %5 = insertvalue %variant undef, i8* %taddr1, 0 - %6 = insertvalue %variant %5, i64 ptrtoint (%.introspect* @"ct$char" to i64), 1 - store %variant %6, %variant* %4, align 16 - %7 = getelementptr inbounds [3 x %variant], [3 x %variant]* %y, i64 0, i64 2 - store [3 x i8]* bitcast ([4 x i8]* @.str.12 to [3 x i8]*), [3 x i8]** %taddr2, align 8 - %8 = bitcast [3 x i8]** %taddr2 to i8* - %9 = insertvalue %variant undef, i8* %8, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - store %variant %10, %variant* %7, align 16 - ret void -} diff --git a/test/test_suite14/arrays/global_init_array_out_of_range.c3 b/test/test_suite14/arrays/global_init_array_out_of_range.c3 deleted file mode 100644 index 7471b4927..000000000 --- a/test/test_suite14/arrays/global_init_array_out_of_range.c3 +++ /dev/null @@ -1,2 +0,0 @@ -int[3] abc; -int *bf3 = (&abc[4]) + 2; // #error: An index of '4' is out of range, a value between 0 and 2 was expected \ No newline at end of file diff --git a/test/test_suite14/arrays/index_from_back.c3t b/test/test_suite14/arrays/index_from_back.c3t deleted file mode 100644 index 7fabb3d9a..000000000 --- a/test/test_suite14/arrays/index_from_back.c3t +++ /dev/null @@ -1,53 +0,0 @@ -// #target: macos-x64 - -module test; - -fn void test(int[10] x, int[<10>] y) -{ - int a = x[4]; - int b = x[^2]; - int c = y[4]; - int d = y[^2]; - int j = 3; - int e = y[^j]; - int f = x[^j]; -} - -/* #expect: test.ll - -define void @test_test([10 x i32]* byval([10 x i32]) align 8 %0, <10 x i32>* byval(<10 x i32>) align 64 %1) #0 { -entry: - %a = alloca i32, align 4 - %b = alloca i32, align 4 - %c = alloca i32, align 4 - %d = alloca i32, align 4 - %j = alloca i32, align 4 - %e = alloca i32, align 4 - %f = alloca i32, align 4 - %2 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 0, i64 4 - %3 = load i32, i32* %2, align 4 - store i32 %3, i32* %a, align 4 - %4 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 0, i64 8 - %5 = load i32, i32* %4, align 4 - store i32 %5, i32* %b, align 4 - %6 = load <10 x i32>, <10 x i32>* %1, align 64 - %7 = extractelement <10 x i32> %6, i64 4 - store i32 %7, i32* %c, align 4 - %8 = load <10 x i32>, <10 x i32>* %1, align 64 - %9 = extractelement <10 x i32> %8, i64 8 - store i32 %9, i32* %d, align 4 - store i32 3, i32* %j, align 4 - %10 = load <10 x i32>, <10 x i32>* %1, align 64 - %11 = load i32, i32* %j, align 4 - %sisiext = sext i32 %11 to i64 - %12 = sub nuw i64 10, %sisiext - %13 = extractelement <10 x i32> %10, i64 %12 - store i32 %13, i32* %e, align 4 - %14 = load i32, i32* %j, align 4 - %sisiext1 = sext i32 %14 to i64 - %15 = sub nuw i64 10, %sisiext1 - %16 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 0, i64 %15 - %17 = load i32, i32* %16, align 4 - store i32 %17, i32* %f, align 4 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/arrays/index_into_global.c3t b/test/test_suite14/arrays/index_into_global.c3t deleted file mode 100644 index c8c0e2be6..000000000 --- a/test/test_suite14/arrays/index_into_global.c3t +++ /dev/null @@ -1,33 +0,0 @@ -// #target: macos-x64 - -module foo; - -struct Bar { - int a; -} - -Bar[6] bar; - -fn int main() -{ - test_bar(0); - return 0; -} - -fn void test_bar(int idx) -{ - bar[idx].a = 0; - bar[0].a = idx; -} - -/* #expect: foo.ll - -define void @foo_test_bar(i32 %0) #0 { -entry: - %sisiext = sext i32 %0 to i64 - %1 = getelementptr inbounds [6 x %Bar], [6 x %Bar]* @foo_bar, i64 0, i64 %sisiext - %2 = getelementptr inbounds %Bar, %Bar* %1, i32 0, i32 0 - store i32 0, i32* %2, align 4 - store i32 %0, i32* getelementptr inbounds ([6 x %Bar], [6 x %Bar]* @foo_bar, i64 0, i64 0, i32 0), align 4 - ret void -} diff --git a/test/test_suite14/arrays/inferred_array_err.c3 b/test/test_suite14/arrays/inferred_array_err.c3 deleted file mode 100644 index 0e7dabd0b..000000000 --- a/test/test_suite14/arrays/inferred_array_err.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn int[*] hello() // #error: Inferred array types can only be used in declarations with initializers -{ - return int[3] { 1, 2, 3}; -} - -int[*] c; // #error: Inferred array types can only be used in declarations with initializers - diff --git a/test/test_suite14/arrays/inferred_array_err2.c3 b/test/test_suite14/arrays/inferred_array_err2.c3 deleted file mode 100644 index b3c4ebf9e..000000000 --- a/test/test_suite14/arrays/inferred_array_err2.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test() -{ - int[3] z; - (int[*])(z); // #error: Inferred array types can only be used in declarations with initializers -} \ No newline at end of file diff --git a/test/test_suite14/arrays/negative_array.c3 b/test/test_suite14/arrays/negative_array.c3 deleted file mode 100644 index 15e33a942..000000000 --- a/test/test_suite14/arrays/negative_array.c3 +++ /dev/null @@ -1,5 +0,0 @@ - -int[-1] a; // #error: An array may not have a negative -int[10-20] b; // #error: An array may not have a negative -int[<-1>] c; // #error: A vector may not have a negative width -int[<10-20>] d; // #error: A vector may not have a negative width diff --git a/test/test_suite14/arrays/slice.c3 b/test/test_suite14/arrays/slice.c3 deleted file mode 100644 index 6d12e07c3..000000000 --- a/test/test_suite14/arrays/slice.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn void test() -{ - int[3] x = { 1, 2, 3 }; - int[] z = &x; - z[1]; -// z.size(); -} \ No newline at end of file diff --git a/test/test_suite14/asm/asm_ops_x64_1.c3t b/test/test_suite14/asm/asm_ops_x64_1.c3t deleted file mode 100644 index c399bc821..000000000 --- a/test/test_suite14/asm/asm_ops_x64_1.c3t +++ /dev/null @@ -1,36 +0,0 @@ -// #target: macos-x64 -module test; - -fn void main(char[][] args) -{ - int x; - if (args.len < 10) return; - asm - { - in $eax, 3; - in $ax, $dx; - incb $al; - incw $bx; - incl $eax; - incq $rax; - incl [&x]; - insb; - insw; - insl; - int 0x08; - int3; - // int1; Broken in LLVM - invd; - invlpg [&x]; - invpcid $rax, [&x]; - invlpga $ecx, $rax; - iret; - iretl; - iretw; - iretq; - } -} - -/* #expect: test.ll - -"in $$3, %eax\0Ain %dx, %ax\0Aincb %al\0Aincw %bx\0Aincl %eax\0Aincq %rax\0Aincl $0\0Ainsb \0Ainsw \0Ainsl \0Aint $$8\0Aint3 \0Ainvd \0Ainvlpg $0\0Ainvpcid $1, %rax\0Ainvlpga %rax, %ecx\0Airet \0Airetl \0Airetw \0Airetq \0A", "=*&m,*m,~{cc},~{rax},~{rbx},~{flags},~{dirflag},~{fspr}" diff --git a/test/test_suite14/asm/asm_ops_x64_2.c3t b/test/test_suite14/asm/asm_ops_x64_2.c3t deleted file mode 100644 index a9c3db917..000000000 --- a/test/test_suite14/asm/asm_ops_x64_2.c3t +++ /dev/null @@ -1,30 +0,0 @@ -// #target: macos-x64 -module test; - -fn void main(char[][] args) -{ - int foo; - asm - { - adcxl $eax, $ecx; - adcxq $rax, $rcx; - addpd $xmm1, $xmm2; - addps $xmm1, $xmm2; - addsd $xmm1, $xmm2; - addss $xmm1, $xmm2; - vaddpd $xmm1, $xmm2, $xmm3; - vaddpd $ymm1, $ymm2, $ymm3; - vaddpd $xmm1, $xmm2, [&foo]; - vaddps $xmm1, $xmm2, $xmm3; - vaddps $ymm1, $ymm2, $ymm3; - vaddps $xmm1, $xmm2, [&foo]; - vaddsd $xmm1, $xmm2, $xmm3; - vaddsd $xmm1, $xmm2, [&foo]; - vaddss $xmm1, $xmm2, $xmm3; - vaddss $xmm1, $xmm2, [&foo]; - } -} - -/* #expect: test.ll - -"adcxl %ecx, %eax\0Aadcxq %rcx, %rax\0Aaddpd %xmm2, %xmm1\0Aaddps %xmm2, %xmm1\0Aaddsd %xmm2, %xmm1\0Aaddss %xmm2, %xmm1\0Avaddpd %xmm3, %xmm2, %xmm1\0Avaddpd %ymm3, %ymm2, %ymm1\0Avaddpd $0, %xmm2, %xmm1\0Avaddps %xmm3, %xmm2, %xmm1\0Avaddps %ymm3, %ymm2, %ymm1\0Avaddps $0, %xmm2, %xmm1\0Avaddsd %xmm3, %xmm2, %xmm1\0Avaddsd $0, %xmm2, %xmm1\0Avaddss %xmm3, %xmm2, %xmm1\0Avaddss $0, %xmm2, %xmm1\0A", "*m,~{cc},~{rcx},~{xmm1},~{flags},~{dirflag},~{fspr}" diff --git a/test/test_suite14/asm/asm_regression.c3t b/test/test_suite14/asm/asm_regression.c3t deleted file mode 100644 index 2296afcb8..000000000 --- a/test/test_suite14/asm/asm_regression.c3t +++ /dev/null @@ -1,50 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; -fn void main() -{ - int x = 222; - int y = 223; - long z = 0; - z = x + y; - z *= x; - int g = 0; - int* gp = &g; - int[4] a = { 3, 4, 5, 6 }; - int* xa = &a; - usz asf = 1; - int aa = 3; - asm - { - - movl x, 4; - movl [gp], x; - movl x, 1; - movl [xa + asf * 4 + 4], x; - movl $eax, (23 + x); - movl x, $eax; - movq [&z], 33; - addl aa, 22; - } - io::printfn("aa: %d", aa); - io::printfn("Z: %d", z); - io::printfn("x: %d", x); - io::printfn("G was: %d", g); - foreach(int abc : a) io::printfn("%d", abc); - -} - -/* #expect: test.ll - - %5 = load i32*, i32** %gp, align 8 - %6 = load i32*, i32** %xa, align 8 - %7 = load i64, i64* %asf, align 8 - %8 = load i32, i32* %x, align 4 - %add3 = add i32 23, %8 - %9 = load i32, i32* %aa, align 4 - %10 = call { i32, i32 } asm alignstack "movl $$4, $0\0Amovl $0, ($3)\0Amovl $$1, $0\0Amovl $0, 4($4,$5,4)\0Amovl $6, %eax\0Amovl %eax, $0\0Amovq $$33, $1\0Aaddl $$22, $2\0A", "=&r,=*&m,=r,r,r,r,r,2,~{cc},~{rax},~{flags},~{dirflag},~{fspr}" - %11 = extractvalue { i32, i32 } %10, 0 - store i32 %11, i32* %x, align 4 - %12 = extractvalue { i32, i32 } %10, 1 - store i32 %12, i32* %aa, align 4 diff --git a/test/test_suite14/assert/assert_variants.c3t b/test/test_suite14/assert/assert_variants.c3t deleted file mode 100644 index 10e42aae6..000000000 --- a/test/test_suite14/assert/assert_variants.c3t +++ /dev/null @@ -1,62 +0,0 @@ -// #target: windows-x64 - -fn int foo() -{ - return 1; -} - -fn void test() -{ - int x = foo(); - int y = foo(); - int z = foo(); - assert(x > 0); - assert(y > 0 && z > 0); - assert(x > 0 && y > 0 && z > 0); - assert(foo() > 0); - assert(x > 0 && foo() > 0); - assert(!(x < 1 || y < 1), "Foo"); -} - - -// #expect: assert_variants.ll - - %x = alloca i32, align 4 - %y = alloca i32, align 4 - %z = alloca i32, align 4 - %0 = call i32 @assert_variants_foo() - store i32 %0, i32* %x, align 4 - %1 = call i32 @assert_variants_foo() - store i32 %1, i32* %y, align 4 - %2 = call i32 @assert_variants_foo() - store i32 %2, i32* %z, align 4 - %3 = load i32, i32* %x, align 4 - %gt = icmp sgt i32 %3, 0 - call void @llvm.assume(i1 %gt) - %4 = load i32, i32* %y, align 4 - %gt1 = icmp sgt i32 %4, 0 - call void @llvm.assume(i1 %gt1) - %5 = load i32, i32* %z, align 4 - %gt2 = icmp sgt i32 %5, 0 - call void @llvm.assume(i1 %gt2) - %6 = load i32, i32* %x, align 4 - %gt3 = icmp sgt i32 %6, 0 - call void @llvm.assume(i1 %gt3) - %7 = load i32, i32* %y, align 4 - %gt4 = icmp sgt i32 %7, 0 - call void @llvm.assume(i1 %gt4) - %8 = load i32, i32* %z, align 4 - %gt5 = icmp sgt i32 %8, 0 - call void @llvm.assume(i1 %gt5) - %9 = load i32, i32* %x, align 4 - %gt6 = icmp sgt i32 %9, 0 - call void @llvm.assume(i1 %gt6) - %10 = load i32, i32* %x, align 4 - %lt = icmp slt i32 %10, 1 - %not = xor i1 %lt, true - call void @llvm.assume(i1 %not) - %11 = load i32, i32* %y, align 4 - %lt7 = icmp slt i32 %11, 1 - %not8 = xor i1 %lt7, true - call void @llvm.assume(i1 %not8) - ret void \ No newline at end of file diff --git a/test/test_suite14/assert/global_static_assert_not_constant.c3 b/test/test_suite14/assert/global_static_assert_not_constant.c3 deleted file mode 100644 index 9d1c3496d..000000000 --- a/test/test_suite14/assert/global_static_assert_not_constant.c3 +++ /dev/null @@ -1,3 +0,0 @@ -int x = 3; - -$assert(x == 3); // #error: Compile time evaluation requires a compile time constant value. \ No newline at end of file diff --git a/test/test_suite14/assert/local_static_assert_not_constant.c3 b/test/test_suite14/assert/local_static_assert_not_constant.c3 deleted file mode 100644 index cc02a64ca..000000000 --- a/test/test_suite14/assert/local_static_assert_not_constant.c3 +++ /dev/null @@ -1,20 +0,0 @@ -int x = 3; - -fn void test() -{ - $assert(x == 3); // #error: Compile time evaluation requires a compile time constant value. -} - -fn void test2() -{ - int i = 0; - $assert(1); - $assert(i == 0); // #error: Compile time evaluation requires a compile time constant value. -} - -fn int foo(); -fn void test3() -{ - int i = 0; - $assert(foo() == 0); // #error: Compile time evaluation requires a compile time constant value. -} diff --git a/test/test_suite14/assert/static_assert.c3 b/test/test_suite14/assert/static_assert.c3 deleted file mode 100644 index a49691433..000000000 --- a/test/test_suite14/assert/static_assert.c3 +++ /dev/null @@ -1,8 +0,0 @@ - -const int FOO = 2; - -fn void test() -{ - $assert(FOO == 2, "Bad"); - $assert(FOO == 0, "Good"); // #error: Compile time assert - Good -} \ No newline at end of file diff --git a/test/test_suite14/assert/unreachable.c3t b/test/test_suite14/assert/unreachable.c3t deleted file mode 100644 index 774891b82..000000000 --- a/test/test_suite14/assert/unreachable.c3t +++ /dev/null @@ -1,40 +0,0 @@ -// #target: macos-x64 -fn int foo() -{ - return 1; -} - -fn void test() -{ - int x = foo(); - if (x > 0) return; - unreachable(); - x++; -} - - -/* #expect: unreachable.ll - -define void @unreachable_test() #0 { -entry: - %x = alloca i32, align 4 - %0 = call i32 @unreachable_foo() - store i32 %0, i32* %x, align 4 - %1 = load i32, i32* %x, align 4 - %gt = icmp sgt i32 %1, 0 - br i1 %gt, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret void - -if.exit: ; preds = %entry - %2 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %2(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i32 0, i32 0), i64 30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i64 14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i64 4, i32 10) - unreachable - -after.unreachable: ; No predecessors! - %3 = load i32, i32* %x, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %x, align 4 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/assignment/int_assign.c3t b/test/test_suite14/assignment/int_assign.c3t deleted file mode 100644 index 0160df514..000000000 --- a/test/test_suite14/assignment/int_assign.c3t +++ /dev/null @@ -1,69 +0,0 @@ -module test; - -fn int foo() -{ - int x = 0; - int y; - x += y; - x -= y; - x %= y; - x /= y; - x *= y; - x <<= y; - x >>= y; - x ^= y; - x |= y; - x &= y; - return x; -} - - -// #expect: test.ll - - %x = alloca i32, align 4 - %y = alloca i32, align 4 - store i32 0, i32* %x, align 4 - store i32 0, i32* %y, align 4 - %0 = load i32, i32* %x, align 4 - %1 = load i32, i32* %y, align 4 - %add = add i32 %0, %1 - store i32 %add, i32* %x, align 4 - %2 = load i32, i32* %x, align 4 - %3 = load i32, i32* %y, align 4 - %sub = sub i32 %2, %3 - store i32 %sub, i32* %x, align 4 - %4 = load i32, i32* %x, align 4 - %5 = load i32, i32* %y, align 4 - %smod = srem i32 %4, %5 - store i32 %smod, i32* %x, align 4 - %6 = load i32, i32* %x, align 4 - %7 = load i32, i32* %y, align 4 - %sdiv = sdiv i32 %6, %7 - store i32 %sdiv, i32* %x, align 4 - %8 = load i32, i32* %x, align 4 - %9 = load i32, i32* %y, align 4 - %mul = mul i32 %8, %9 - store i32 %mul, i32* %x, align 4 - %10 = load i32, i32* %x, align 4 - %11 = load i32, i32* %y, align 4 - %shl = shl i32 %10, %11 - %12 = freeze i32 %shl - store i32 %12, i32* %x, align 4 - %13 = load i32, i32* %x, align 4 - %14 = load i32, i32* %y, align 4 - %ashr = ashr i32 %13, %14 - %15 = freeze i32 %ashr - store i32 %15, i32* %x, align 4 - %16 = load i32, i32* %x, align 4 - %17 = load i32, i32* %y, align 4 - %xor = xor i32 %16, %17 - store i32 %xor, i32* %x, align 4 - %18 = load i32, i32* %x, align 4 - %19 = load i32, i32* %y, align 4 - %or = or i32 %18, %19 - store i32 %or, i32* %x, align 4 - %20 = load i32, i32* %x, align 4 - %21 = load i32, i32* %y, align 4 - %and = and i32 %20, %21 - store i32 %and, i32* %x, align 4 - %22 = load i32, i32* %x, align 4 diff --git a/test/test_suite14/assignment/var_variable.c3t b/test/test_suite14/assignment/var_variable.c3t deleted file mode 100644 index 1eed2f9b0..000000000 --- a/test/test_suite14/assignment/var_variable.c3t +++ /dev/null @@ -1,40 +0,0 @@ -module test; -import std::io; - - -macro @foo(;@body) -{ - var i = 1.0; - @body(); -} - -fn void main() -{ - @foo() { int j = 1; }; - @foo() { var j = 1.0; }; // #error: is only allowed inside -} - -fn void test() -{ - var g = 1; // #error: is only allowed inside -} - -macro void test2m() -{ - var h = { 1, 2 }; // #error: cannot be inferred -} - -fn void test2() -{ - test2m(); -} -struct Foo { int a; } -macro void test3m() -{ - var $foo = Foo.membersof; - var h = $foo[0]; // #error: compile time type -} -fn void test3() -{ - test3m(); -} \ No newline at end of file diff --git a/test/test_suite14/attributes/attribute_visibility.c3t b/test/test_suite14/attributes/attribute_visibility.c3t deleted file mode 100644 index adfa7b9b9..000000000 --- a/test/test_suite14/attributes/attribute_visibility.c3t +++ /dev/null @@ -1,12 +0,0 @@ -// #target: macos-x64 -module test; -private const int FOO = 4; -define @Align(x) = @align(x * FOO); - -module test2; -import test; -int black @Align(16) = 123; - -// #expect: test2.ll - -@test2_black = local_unnamed_addr global i32 123, align 64 \ No newline at end of file diff --git a/test/test_suite14/attributes/recursive_attributes.c3 b/test/test_suite14/attributes/recursive_attributes.c3 deleted file mode 100644 index 82ef26716..000000000 --- a/test/test_suite14/attributes/recursive_attributes.c3 +++ /dev/null @@ -1,25 +0,0 @@ -module test; - -define @Align(y) = @Align16(y / 2); -// This one is directly recursive -define @Align16(x) = @align(4), @Align(8 * x); // #error: Recursive declaration of attribute -// This one uses a recursive attribute -define @AlignIndirect(x) = @Align16(x); // #error: Recursive declaration of attribute -define @Test = @noinline; -struct Foo -{ - int z; - int xy @Align16(8); -} - -Foo f; - -fn void testme() @Test -{ - int x; -} - -struct Bar -{ - int abc @AlignIndirect(8); -} \ No newline at end of file diff --git a/test/test_suite14/attributes/user_defined_attributes.c3t b/test/test_suite14/attributes/user_defined_attributes.c3t deleted file mode 100644 index b55335e62..000000000 --- a/test/test_suite14/attributes/user_defined_attributes.c3t +++ /dev/null @@ -1,45 +0,0 @@ -// #target: macos-x64 - -module test; - -define @Align(y) = @align(y); -define @Align16(x) = @Align(8 * x), @align(1024); -define @Test = @noinline; -define @TestZero; -struct Foo -{ - int z; - int xy @Align16(8); -} - -Foo f; - -fn void testme() @Test -{ - int x; -} - -fn void main() @TestZero -{ - testme(); -} - -/* #expect: test.ll - -%Foo = type { i32, [1020 x i8], i32, [1020 x i8] } - -@"ct$test_Foo" = linkonce constant %.introspect { i8 10, i64 2048, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@test_f = local_unnamed_addr global %Foo zeroinitializer, align 1024 - -define void @test_testme() #0 { -entry: - %x = alloca i32, align 4 - store i32 0, i32* %x, align 4 - ret void -} - -define void @test_main() #1 { -entry: - call void @test_testme() - ret void -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/address_of_bitstruct.c3 b/test/test_suite14/bitstruct/address_of_bitstruct.c3 deleted file mode 100644 index 7fe1d41ba..000000000 --- a/test/test_suite14/bitstruct/address_of_bitstruct.c3 +++ /dev/null @@ -1,15 +0,0 @@ -bitstruct BitField : char -{ - int a : 0..2; - int b : 4..5; - int c : 6..7; -} - -fn void test() -{ - BitField x; - BitField* z = &x; - x.a; - z.a; - &x.a; // #error: You cannot take the address of a bitstruct member -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/array_with_boolean.c3t b/test/test_suite14/bitstruct/array_with_boolean.c3t deleted file mode 100644 index 8437695c6..000000000 --- a/test/test_suite14/bitstruct/array_with_boolean.c3t +++ /dev/null @@ -1,71 +0,0 @@ -// #target: macos-x64 - -module foo; - -bitstruct BitField : char[3] -{ - int a : 0..2; - int b : 3..8; - int c : 9..18; - bool d : 19; - bool e : 20; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - BitField xx = { 2, 3, 15, true, false }; - BitField xy = { 2, 3, 15, false, true }; - printf("%x, %x, %x, %d, %d\n", xx.a, xx.b, xx.c, xx.d, xx.e); -} - - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %xx = alloca [3 x i8], align 1 - %xy = alloca [3 x i8], align 1 - store [3 x i8] c"\1A\1E\08", [3 x i8]* %xx, align 1 - store [3 x i8] c"\1A\1E\10", [3 x i8]* %xy, align 1 - %0 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %1 = load i8, i8* %0, align 1 - %zext = zext i8 %1 to i32 - %shl = shl i32 %zext, 29 - %ashr = ashr i32 %shl, 29 - %2 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %3 = load i8, i8* %2, align 1 - %zext1 = zext i8 %3 to i32 - %lshrl = lshr i32 %zext1, 3 - %4 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %5 = load i8, i8* %4, align 1 - %zext2 = zext i8 %5 to i32 - %shl3 = shl i32 %zext2, 5 - %6 = or i32 %shl3, %lshrl - %shl4 = shl i32 %6, 26 - %ashr5 = ashr i32 %shl4, 26 - %7 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %8 = load i8, i8* %7, align 1 - %zext6 = zext i8 %8 to i32 - %lshrl7 = lshr i32 %zext6, 1 - %9 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %10 = load i8, i8* %9, align 1 - %zext8 = zext i8 %10 to i32 - %shl9 = shl i32 %zext8, 7 - %11 = or i32 %shl9, %lshrl7 - %shl10 = shl i32 %11, 22 - %ashr11 = ashr i32 %shl10, 22 - %12 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %13 = load i8, i8* %12, align 1 - %lshrl12 = lshr i8 %13, 3 - %14 = trunc i8 %lshrl12 to i1 - %boolsi = zext i1 %14 to i32 - %15 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %16 = load i8, i8* %15, align 1 - %lshrl13 = lshr i8 %16, 4 - %17 = trunc i8 %lshrl13 to i1 - %boolsi14 = zext i1 %17 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i32 0, i32 0), i32 %ashr, i32 %ashr5, i32 %ashr11, i32 %boolsi, i32 %boolsi14) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/bitfield_access.c3t b/test/test_suite14/bitstruct/bitfield_access.c3t deleted file mode 100644 index 65c190e9e..000000000 --- a/test/test_suite14/bitstruct/bitfield_access.c3t +++ /dev/null @@ -1,180 +0,0 @@ -// #target: macos-x64 - -module foo; - -bitstruct BitField : char -{ - int a : 0..2; - int b : 4..5; - int c : 6..7; -} - -bitstruct BitFieldI : ushort -{ - int a : 0..4; - int b : 5..10; - int c : 11..15; -} - - -struct Packet -{ - bitstruct : int - { - int a : 0..2; - int b : 3..5; - int c : 6..10; - } - int packet_id; -} - -bitstruct BitField3 : char[3] -{ - int a : 0..2; - int b : 3..8; - int c : 9..18; - int d : 19..23; -} - -bitstruct BitField3u : char[3] -{ - uint a : 0..2; - uint b : 3..8; - uint c : 9..18; - uint d : 19..23; -} - -bitstruct BitField4 : char[3] -{ - int a : 0..2; - int b : 3..7; - int c : 8..15; - int d : 16..19; -} - -bitstruct BitFieldCross : char[5] -{ - uint a : 5..22; -} - -BitField c = { 2, -1, 1 }; - -extern fn void printf(char*, ...); - -fn void main() -{ - BitField b = { 3, -1, 1 }; - BitFieldI c1 = { 5, 0, 0 }; - BitFieldI c2 = { 0, 3, 0 }; - BitFieldI c3 = { 0, 0, 9 }; - BitFieldI c4 = { -5, 7, 9 }; - BitFieldI c5 = { -5, 0, 0 }; - BitFieldI c6 = { 5, 0, 0 }; - BitFieldI c7 = { 0, 0, 5 }; - - BitField3 e1 = { 3, 1, 3, 4 }; - BitField3 e2 = { 1, 1, 3, 4 }; - BitField3 e3 = { 2, 1, 3, 4 }; - BitField d = { }; - - printf("%d\n", e1.a); - printf("%d\n", e2.a); - printf("%d\n", e3.a); - - BitField3u z1 = { 3, 1, 3, 4 }; - BitField3u z2 = { 4, 1, 3, 4 }; - BitField3u z3 = { 7, 1, 3, 4 }; - printf("%u\n", z1.a); - printf("%u\n", z2.a); - printf("%u\n", z3.a); - BitFieldCross xx = { 0x1238 }; - printf("%x\n", xx.a); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %b = alloca i8, align 1 - %c1 = alloca i16, align 2 - %c2 = alloca i16, align 2 - %c3 = alloca i16, align 2 - %c4 = alloca i16, align 2 - %c5 = alloca i16, align 2 - %c6 = alloca i16, align 2 - %c7 = alloca i16, align 2 - %e1 = alloca [3 x i8], align 1 - %e2 = alloca [3 x i8], align 1 - %e3 = alloca [3 x i8], align 1 - %d = alloca i8, align 1 - %z1 = alloca [3 x i8], align 1 - %z2 = alloca [3 x i8], align 1 - %z3 = alloca [3 x i8], align 1 - %xx = alloca [5 x i8], align 1 - store i8 115, i8* %b, align 1 - store i16 5, i16* %c1, align 2 - store i16 96, i16* %c2, align 2 - store i16 18432, i16* %c3, align 2 - store i16 18683, i16* %c4, align 2 - store i16 27, i16* %c5, align 2 - store i16 5, i16* %c6, align 2 - store i16 10240, i16* %c7, align 2 - store [3 x i8] c"\0B\06 ", [3 x i8]* %e1, align 1 - store [3 x i8] c"\09\06 ", [3 x i8]* %e2, align 1 - store [3 x i8] c"\0A\06 ", [3 x i8]* %e3, align 1 - store i8 0, i8* %d, align 1 - %0 = getelementptr inbounds [3 x i8], [3 x i8]* %e1, i64 0, i64 0 - %1 = load i8, i8* %0, align 1 - %zext = zext i8 %1 to i32 - %shl = shl i32 %zext, 29 - %ashr = ashr i32 %shl, 29 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %ashr) - %2 = getelementptr inbounds [3 x i8], [3 x i8]* %e2, i64 0, i64 0 - %3 = load i8, i8* %2, align 1 - %zext1 = zext i8 %3 to i32 - %shl2 = shl i32 %zext1, 29 - %ashr3 = ashr i32 %shl2, 29 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %ashr3) - %4 = getelementptr inbounds [3 x i8], [3 x i8]* %e3, i64 0, i64 0 - %5 = load i8, i8* %4, align 1 - %zext4 = zext i8 %5 to i32 - %shl5 = shl i32 %zext4, 29 - %ashr6 = ashr i32 %shl5, 29 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 %ashr6) - store [3 x i8] c"\0B\06 ", [3 x i8]* %z1, align 1 - store [3 x i8] c"\0C\06 ", [3 x i8]* %z2, align 1 - store [3 x i8] c"\0F\06 ", [3 x i8]* %z3, align 1 - %6 = getelementptr inbounds [3 x i8], [3 x i8]* %z1, i64 0, i64 0 - %7 = load i8, i8* %6, align 1 - %zext7 = zext i8 %7 to i32 - %8 = and i32 7, %zext7 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 %8) - %9 = getelementptr inbounds [3 x i8], [3 x i8]* %z2, i64 0, i64 0 - %10 = load i8, i8* %9, align 1 - %zext8 = zext i8 %10 to i32 - %11 = and i32 7, %zext8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i32 %11) - %12 = getelementptr inbounds [3 x i8], [3 x i8]* %z3, i64 0, i64 0 - %13 = load i8, i8* %12, align 1 - %zext9 = zext i8 %13 to i32 - %14 = and i32 7, %zext9 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 %14) - store [5 x i8] c"\00G\02\00\00", [5 x i8]* %xx, align 1 - %15 = getelementptr inbounds [5 x i8], [5 x i8]* %xx, i64 0, i64 0 - %16 = load i8, i8* %15, align 1 - %zext10 = zext i8 %16 to i32 - %lshrl = lshr i32 %zext10, 5 - %17 = getelementptr inbounds [5 x i8], [5 x i8]* %xx, i64 0, i64 1 - %18 = load i8, i8* %17, align 1 - %zext11 = zext i8 %18 to i32 - %shl12 = shl i32 %zext11, 3 - %19 = or i32 %shl12, %lshrl - %20 = getelementptr inbounds [5 x i8], [5 x i8]* %xx, i64 0, i64 2 - %21 = load i8, i8* %20, align 1 - %zext13 = zext i8 %21 to i32 - %shl14 = shl i32 %zext13, 11 - %22 = or i32 %shl14, %19 - %23 = and i32 262143, %22 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i32 %23) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/bitstruct_access_signed.c3t b/test/test_suite14/bitstruct/bitstruct_access_signed.c3t deleted file mode 100644 index d769244ab..000000000 --- a/test/test_suite14/bitstruct/bitstruct_access_signed.c3t +++ /dev/null @@ -1,91 +0,0 @@ -// #target: macos-x64 - -module foo; - -bitstruct BitFieldCross : char[3] -{ - uint d : 0..4; - int a : 5..22; - uint c : 23..23; -} - -bitstruct BitFieldCrossU : char[3] -{ - uint d : 0..4; - uint a : 5..22; - uint c : 23..23; -} -extern fn void printf(char*, ...); - -fn void main() -{ - BitFieldCross xx = { 0, -17, 0 }; - printf("%d\n", xx.a); - xx = { 0x1f, -17, 1 }; - printf("%d\n", xx.a); - BitFieldCrossU xxu = { 0x1f, 0x15678, 1 }; - printf("%x\n", xxu.a); - -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %xx = alloca [3 x i8], align 1 - %xxu = alloca [3 x i8], align 1 - store [3 x i8] c"\E0\FD\7F", [3 x i8]* %xx, align 1 - %0 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %1 = load i8, i8* %0, align 1 - %zext = zext i8 %1 to i32 - %lshrl = lshr i32 %zext, 5 - %2 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %3 = load i8, i8* %2, align 1 - %zext1 = zext i8 %3 to i32 - %shl = shl i32 %zext1, 3 - %4 = or i32 %shl, %lshrl - %5 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %6 = load i8, i8* %5, align 1 - %zext2 = zext i8 %6 to i32 - %shl3 = shl i32 %zext2, 11 - %7 = or i32 %shl3, %4 - %shl4 = shl i32 %7, 14 - %ashr = ashr i32 %shl4, 14 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %ashr) - store [3 x i8] c"\FF\FD\FF", [3 x i8]* %xx, align 1 - %8 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %9 = load i8, i8* %8, align 1 - %zext5 = zext i8 %9 to i32 - %lshrl6 = lshr i32 %zext5, 5 - %10 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %11 = load i8, i8* %10, align 1 - %zext7 = zext i8 %11 to i32 - %shl8 = shl i32 %zext7, 3 - %12 = or i32 %shl8, %lshrl6 - %13 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %14 = load i8, i8* %13, align 1 - %zext9 = zext i8 %14 to i32 - %shl10 = shl i32 %zext9, 11 - %15 = or i32 %shl10, %12 - %shl11 = shl i32 %15, 14 - %ashr12 = ashr i32 %shl11, 14 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %ashr12) - store [3 x i8] c"\1F\CF\AA", [3 x i8]* %xxu, align 1 - %16 = getelementptr inbounds [3 x i8], [3 x i8]* %xxu, i64 0, i64 0 - %17 = load i8, i8* %16, align 1 - %zext13 = zext i8 %17 to i32 - %lshrl14 = lshr i32 %zext13, 5 - %18 = getelementptr inbounds [3 x i8], [3 x i8]* %xxu, i64 0, i64 1 - %19 = load i8, i8* %18, align 1 - %zext15 = zext i8 %19 to i32 - %shl16 = shl i32 %zext15, 3 - %20 = or i32 %shl16, %lshrl14 - %21 = getelementptr inbounds [3 x i8], [3 x i8]* %xxu, i64 0, i64 2 - %22 = load i8, i8* %21, align 1 - %zext17 = zext i8 %22 to i32 - %shl18 = shl i32 %zext17, 11 - %23 = or i32 %shl18, %20 - %24 = and i32 262143, %23 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 %24) - ret void -} diff --git a/test/test_suite14/bitstruct/bitstruct_arrays.c3t b/test/test_suite14/bitstruct/bitstruct_arrays.c3t deleted file mode 100644 index e661e9837..000000000 --- a/test/test_suite14/bitstruct/bitstruct_arrays.c3t +++ /dev/null @@ -1,1148 +0,0 @@ -// #target: macos-x64 - -module foo; - -bitstruct BitField : long -{ - int a : 0..2; - int b : 3..8; - int c : 9..18; - bool d : 19; - bool e : 20; -} - -bitstruct BitField2 : char[3] -{ - int a : 0..2; - int b : 3..8; - int c : 9..18; - bool d : 19; - bool e : 20; -} - -bitstruct BitField3 : char[3] -{ - int a : 1..3; - int b : 4..9; - int c : 10..19; - bool d : 20; - bool e : 21; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - test1(); - test2(); - test3(); -} -fn void test1() -{ - BitField xx = { 2, 3, 15, true, false }; - xx.a = 3; - printf("%d, %d\n", xx.a, xx.b); - xx.a -= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b *= 2; - printf("%d, %d\n", xx.a, xx.b); - xx.b ^= 4; - printf("%d, %d\n", xx.a, xx.b); - xx.b |= 4; - printf("%d, %d\n", xx.a, xx.b); - xx.b <<= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b >>= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b /= 2; - printf("%d, %d\n", xx.a, xx.b); - xx.b %= 2; - printf("%d, %d\n", xx.a, xx.b); - xx.e = true; - printf("%d\n", xx.e); - xx.e = false; - printf("%d\n", xx.e); -} - -fn void test2() -{ - BitField2 xx = { 2, 3, 15, false, false }; - xx.a = 3; - printf("%d, %d\n", xx.a, xx.b); - xx.a -= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b *= 2; - printf("%d, %d\n", xx.a, xx.b); - xx.b ^= 4; - printf("%d, %d\n", xx.a, xx.b); - xx.b |= 4; - printf("%d, %d\n", xx.a, xx.b); - xx.b <<= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b >>= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b /= 2; - printf("%d, %d\n", xx.a, xx.b); - xx.b %= 2; - printf("%d, %d\n", xx.a, xx.b); - printf("..%d\n", xx.e); - xx.e = true; - printf("%d\n", xx.e); - xx.e = false; - printf("%d\n", xx.e); -} - -fn void test3() -{ - BitField3 xx = { 2, 3, 15, false, false }; - xx.a = 3; - printf("%d, %d\n", xx.a, xx.b); - xx.a -= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b *= 2; - printf("%d, %d\n", xx.a, xx.b); - xx.b ^= 4; - printf("%d, %d\n", xx.a, xx.b); - xx.b |= 4; - printf("%d, %d\n", xx.a, xx.b); - xx.b <<= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b >>= 1; - printf("%d, %d\n", xx.a, xx.b); - xx.b /= 2; - printf("%d, %d\n", xx.a, xx.b); - xx.b %= 2; - printf("%d, %d\n", xx.a, xx.b); - printf("..%d\n", xx.e); - xx.e = true; - printf("%d\n", xx.e); - xx.e = false; - printf("%d\n", xx.e); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - call void @foo_test1() - call void @foo_test2() - call void @foo_test3() - ret void -} - -; Function Attrs: nounwind -define void @foo_test1() #0 { -entry: - %xx = alloca i64, align 8 - store i64 531994, i64* %xx, align 8 - %0 = load i64, i64* %xx, align 8 - %1 = and i64 %0, -8 - %2 = or i64 %1, 3 - store i64 %2, i64* %xx, align 8 - %3 = load i64, i64* %xx, align 8 - %shl = shl i64 %3, 61 - %ashr = ashr i64 %shl, 61 - %4 = trunc i64 %ashr to i32 - %5 = load i64, i64* %xx, align 8 - %shl1 = shl i64 %5, 55 - %ashr2 = ashr i64 %shl1, 58 - %6 = trunc i64 %ashr2 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 %4, i32 %6) - %7 = load i64, i64* %xx, align 8 - %shl3 = shl i64 %7, 61 - %ashr4 = ashr i64 %shl3, 61 - %8 = trunc i64 %ashr4 to i32 - %sub = sub i32 %8, 1 - %9 = load i64, i64* %xx, align 8 - %zext = zext i32 %sub to i64 - %10 = and i64 %zext, 7 - %11 = and i64 %9, -8 - %12 = or i64 %11, %10 - store i64 %12, i64* %xx, align 8 - %13 = load i64, i64* %xx, align 8 - %shl5 = shl i64 %13, 61 - %ashr6 = ashr i64 %shl5, 61 - %14 = trunc i64 %ashr6 to i32 - %15 = load i64, i64* %xx, align 8 - %shl7 = shl i64 %15, 55 - %ashr8 = ashr i64 %shl7, 58 - %16 = trunc i64 %ashr8 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 %14, i32 %16) - %17 = load i64, i64* %xx, align 8 - %shl9 = shl i64 %17, 55 - %ashr10 = ashr i64 %shl9, 58 - %18 = trunc i64 %ashr10 to i32 - %mul = mul i32 %18, 2 - %19 = load i64, i64* %xx, align 8 - %zext11 = zext i32 %mul to i64 - %shl12 = shl i64 %zext11, 3 - %20 = and i64 %shl12, 504 - %21 = and i64 %19, -505 - %22 = or i64 %21, %20 - store i64 %22, i64* %xx, align 8 - %23 = load i64, i64* %xx, align 8 - %shl13 = shl i64 %23, 61 - %ashr14 = ashr i64 %shl13, 61 - %24 = trunc i64 %ashr14 to i32 - %25 = load i64, i64* %xx, align 8 - %shl15 = shl i64 %25, 55 - %ashr16 = ashr i64 %shl15, 58 - %26 = trunc i64 %ashr16 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i32 %24, i32 %26) - %27 = load i64, i64* %xx, align 8 - %shl17 = shl i64 %27, 55 - %ashr18 = ashr i64 %shl17, 58 - %28 = trunc i64 %ashr18 to i32 - %xor = xor i32 %28, 4 - %29 = load i64, i64* %xx, align 8 - %zext19 = zext i32 %xor to i64 - %shl20 = shl i64 %zext19, 3 - %30 = and i64 %shl20, 504 - %31 = and i64 %29, -505 - %32 = or i64 %31, %30 - store i64 %32, i64* %xx, align 8 - %33 = load i64, i64* %xx, align 8 - %shl21 = shl i64 %33, 61 - %ashr22 = ashr i64 %shl21, 61 - %34 = trunc i64 %ashr22 to i32 - %35 = load i64, i64* %xx, align 8 - %shl23 = shl i64 %35, 55 - %ashr24 = ashr i64 %shl23, 58 - %36 = trunc i64 %ashr24 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i32 %34, i32 %36) - %37 = load i64, i64* %xx, align 8 - %shl25 = shl i64 %37, 55 - %ashr26 = ashr i64 %shl25, 58 - %38 = trunc i64 %ashr26 to i32 - %or = or i32 %38, 4 - %39 = load i64, i64* %xx, align 8 - %zext27 = zext i32 %or to i64 - %shl28 = shl i64 %zext27, 3 - %40 = and i64 %shl28, 504 - %41 = and i64 %39, -505 - %42 = or i64 %41, %40 - store i64 %42, i64* %xx, align 8 - %43 = load i64, i64* %xx, align 8 - %shl29 = shl i64 %43, 61 - %ashr30 = ashr i64 %shl29, 61 - %44 = trunc i64 %ashr30 to i32 - %45 = load i64, i64* %xx, align 8 - %shl31 = shl i64 %45, 55 - %ashr32 = ashr i64 %shl31, 58 - %46 = trunc i64 %ashr32 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 %44, i32 %46) - %47 = load i64, i64* %xx, align 8 - %shl33 = shl i64 %47, 55 - %ashr34 = ashr i64 %shl33, 58 - %48 = trunc i64 %ashr34 to i32 - %shl35 = shl i32 %48, 1 - %49 = freeze i32 %shl35 - %50 = load i64, i64* %xx, align 8 - %zext36 = zext i32 %49 to i64 - %shl37 = shl i64 %zext36, 3 - %51 = and i64 %shl37, 504 - %52 = and i64 %50, -505 - %53 = or i64 %52, %51 - store i64 %53, i64* %xx, align 8 - %54 = load i64, i64* %xx, align 8 - %shl38 = shl i64 %54, 61 - %ashr39 = ashr i64 %shl38, 61 - %55 = trunc i64 %ashr39 to i32 - %56 = load i64, i64* %xx, align 8 - %shl40 = shl i64 %56, 55 - %ashr41 = ashr i64 %shl40, 58 - %57 = trunc i64 %ashr41 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i32 %55, i32 %57) - %58 = load i64, i64* %xx, align 8 - %shl42 = shl i64 %58, 55 - %ashr43 = ashr i64 %shl42, 58 - %59 = trunc i64 %ashr43 to i32 - %ashr44 = ashr i32 %59, 1 - %60 = freeze i32 %ashr44 - %61 = load i64, i64* %xx, align 8 - %zext45 = zext i32 %60 to i64 - %shl46 = shl i64 %zext45, 3 - %62 = and i64 %shl46, 504 - %63 = and i64 %61, -505 - %64 = or i64 %63, %62 - store i64 %64, i64* %xx, align 8 - %65 = load i64, i64* %xx, align 8 - %shl47 = shl i64 %65, 61 - %ashr48 = ashr i64 %shl47, 61 - %66 = trunc i64 %ashr48 to i32 - %67 = load i64, i64* %xx, align 8 - %shl49 = shl i64 %67, 55 - %ashr50 = ashr i64 %shl49, 58 - %68 = trunc i64 %ashr50 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i32 %66, i32 %68) - %69 = load i64, i64* %xx, align 8 - %shl51 = shl i64 %69, 55 - %ashr52 = ashr i64 %shl51, 58 - %70 = trunc i64 %ashr52 to i32 - %sdiv = sdiv i32 %70, 2 - %71 = load i64, i64* %xx, align 8 - %zext53 = zext i32 %sdiv to i64 - %shl54 = shl i64 %zext53, 3 - %72 = and i64 %shl54, 504 - %73 = and i64 %71, -505 - %74 = or i64 %73, %72 - store i64 %74, i64* %xx, align 8 - %75 = load i64, i64* %xx, align 8 - %shl55 = shl i64 %75, 61 - %ashr56 = ashr i64 %shl55, 61 - %76 = trunc i64 %ashr56 to i32 - %77 = load i64, i64* %xx, align 8 - %shl57 = shl i64 %77, 55 - %ashr58 = ashr i64 %shl57, 58 - %78 = trunc i64 %ashr58 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i32 %76, i32 %78) - %79 = load i64, i64* %xx, align 8 - %shl59 = shl i64 %79, 55 - %ashr60 = ashr i64 %shl59, 58 - %80 = trunc i64 %ashr60 to i32 - %smod = srem i32 %80, 2 - %81 = load i64, i64* %xx, align 8 - %zext61 = zext i32 %smod to i64 - %shl62 = shl i64 %zext61, 3 - %82 = and i64 %shl62, 504 - %83 = and i64 %81, -505 - %84 = or i64 %83, %82 - store i64 %84, i64* %xx, align 8 - %85 = load i64, i64* %xx, align 8 - %shl63 = shl i64 %85, 61 - %ashr64 = ashr i64 %shl63, 61 - %86 = trunc i64 %ashr64 to i32 - %87 = load i64, i64* %xx, align 8 - %shl65 = shl i64 %87, 55 - %ashr66 = ashr i64 %shl65, 58 - %88 = trunc i64 %ashr66 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i32 %86, i32 %88) - %89 = load i64, i64* %xx, align 8 - %90 = and i64 %89, -1048577 - %91 = or i64 %90, 1048576 - store i64 %91, i64* %xx, align 8 - %92 = load i64, i64* %xx, align 8 - %lshrl = lshr i64 %92, 20 - %93 = and i64 1, %lshrl - %ztrunc = trunc i64 %93 to i8 - %94 = trunc i8 %ztrunc to i1 - %boolsi = zext i1 %94 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i32 %boolsi) - %95 = load i64, i64* %xx, align 8 - %96 = and i64 %95, -1048577 - store i64 %96, i64* %xx, align 8 - %97 = load i64, i64* %xx, align 8 - %lshrl67 = lshr i64 %97, 20 - %98 = and i64 1, %lshrl67 - %ztrunc68 = trunc i64 %98 to i8 - %99 = trunc i8 %ztrunc68 to i1 - %boolsi69 = zext i1 %99 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i32 %boolsi69) - ret void -} - -; Function Attrs: nounwind -define void @foo_test2() #0 { -entry: - %xx = alloca [3 x i8], align 1 - store [3 x i8] c"\1A\1E\00", [3 x i8]* %xx, align 1 - %0 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %1 = load i8, i8* %0, align 1 - %2 = and i8 %1, -8 - %3 = or i8 %2, 3 - store i8 %2, i8* %0, align 1 - %4 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %5 = load i8, i8* %4, align 1 - %zext = zext i8 %5 to i32 - %shl = shl i32 %zext, 29 - %ashr = ashr i32 %shl, 29 - %6 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %7 = load i8, i8* %6, align 1 - %zext1 = zext i8 %7 to i32 - %lshrl = lshr i32 %zext1, 3 - %8 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %9 = load i8, i8* %8, align 1 - %zext2 = zext i8 %9 to i32 - %shl3 = shl i32 %zext2, 5 - %10 = or i32 %shl3, %lshrl - %shl4 = shl i32 %10, 26 - %ashr5 = ashr i32 %shl4, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i32 0, i32 0), i32 %ashr, i32 %ashr5) - %11 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %12 = load i8, i8* %11, align 1 - %zext6 = zext i8 %12 to i32 - %shl7 = shl i32 %zext6, 29 - %ashr8 = ashr i32 %shl7, 29 - %sub = sub i32 %ashr8, 1 - %13 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %ztrunc = trunc i32 %sub to i8 - %14 = and i8 %ztrunc, 7 - %15 = load i8, i8* %13, align 1 - %16 = and i8 %15, -8 - %17 = or i8 %16, %14 - store i8 %16, i8* %13, align 1 - %18 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %19 = load i8, i8* %18, align 1 - %zext9 = zext i8 %19 to i32 - %shl10 = shl i32 %zext9, 29 - %ashr11 = ashr i32 %shl10, 29 - %20 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %21 = load i8, i8* %20, align 1 - %zext12 = zext i8 %21 to i32 - %lshrl13 = lshr i32 %zext12, 3 - %22 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %23 = load i8, i8* %22, align 1 - %zext14 = zext i8 %23 to i32 - %shl15 = shl i32 %zext14, 5 - %24 = or i32 %shl15, %lshrl13 - %shl16 = shl i32 %24, 26 - %ashr17 = ashr i32 %shl16, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i32 %ashr11, i32 %ashr17) - %25 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %26 = load i8, i8* %25, align 1 - %zext18 = zext i8 %26 to i32 - %lshrl19 = lshr i32 %zext18, 3 - %27 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %28 = load i8, i8* %27, align 1 - %zext20 = zext i8 %28 to i32 - %shl21 = shl i32 %zext20, 5 - %29 = or i32 %shl21, %lshrl19 - %shl22 = shl i32 %29, 26 - %ashr23 = ashr i32 %shl22, 26 - %mul = mul i32 %ashr23, 2 - %30 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl24 = shl i32 %mul, 3 - %ztrunc25 = trunc i32 %shl24 to i8 - %31 = load i8, i8* %30, align 1 - %32 = and i8 %31, 7 - %33 = or i8 %32, %ztrunc25 - store i8 %33, i8* %30, align 1 - %lshrl26 = lshr i32 %mul, 5 - %34 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc27 = trunc i32 %lshrl26 to i8 - %35 = and i8 %ztrunc27, 1 - %36 = load i8, i8* %34, align 1 - %37 = and i8 %36, -2 - %38 = or i8 %37, %35 - store i8 %37, i8* %34, align 1 - %39 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %40 = load i8, i8* %39, align 1 - %zext28 = zext i8 %40 to i32 - %shl29 = shl i32 %zext28, 29 - %ashr30 = ashr i32 %shl29, 29 - %41 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %42 = load i8, i8* %41, align 1 - %zext31 = zext i8 %42 to i32 - %lshrl32 = lshr i32 %zext31, 3 - %43 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %44 = load i8, i8* %43, align 1 - %zext33 = zext i8 %44 to i32 - %shl34 = shl i32 %zext33, 5 - %45 = or i32 %shl34, %lshrl32 - %shl35 = shl i32 %45, 26 - %ashr36 = ashr i32 %shl35, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i32 0, i32 0), i32 %ashr30, i32 %ashr36) - %46 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %47 = load i8, i8* %46, align 1 - %zext37 = zext i8 %47 to i32 - %lshrl38 = lshr i32 %zext37, 3 - %48 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %49 = load i8, i8* %48, align 1 - %zext39 = zext i8 %49 to i32 - %shl40 = shl i32 %zext39, 5 - %50 = or i32 %shl40, %lshrl38 - %shl41 = shl i32 %50, 26 - %ashr42 = ashr i32 %shl41, 26 - %xor = xor i32 %ashr42, 4 - %51 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl43 = shl i32 %xor, 3 - %ztrunc44 = trunc i32 %shl43 to i8 - %52 = load i8, i8* %51, align 1 - %53 = and i8 %52, 7 - %54 = or i8 %53, %ztrunc44 - store i8 %54, i8* %51, align 1 - %lshrl45 = lshr i32 %xor, 5 - %55 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc46 = trunc i32 %lshrl45 to i8 - %56 = and i8 %ztrunc46, 1 - %57 = load i8, i8* %55, align 1 - %58 = and i8 %57, -2 - %59 = or i8 %58, %56 - store i8 %58, i8* %55, align 1 - %60 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %61 = load i8, i8* %60, align 1 - %zext47 = zext i8 %61 to i32 - %shl48 = shl i32 %zext47, 29 - %ashr49 = ashr i32 %shl48, 29 - %62 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %63 = load i8, i8* %62, align 1 - %zext50 = zext i8 %63 to i32 - %lshrl51 = lshr i32 %zext50, 3 - %64 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %65 = load i8, i8* %64, align 1 - %zext52 = zext i8 %65 to i32 - %shl53 = shl i32 %zext52, 5 - %66 = or i32 %shl53, %lshrl51 - %shl54 = shl i32 %66, 26 - %ashr55 = ashr i32 %shl54, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i32 0, i32 0), i32 %ashr49, i32 %ashr55) - %67 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %68 = load i8, i8* %67, align 1 - %zext56 = zext i8 %68 to i32 - %lshrl57 = lshr i32 %zext56, 3 - %69 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %70 = load i8, i8* %69, align 1 - %zext58 = zext i8 %70 to i32 - %shl59 = shl i32 %zext58, 5 - %71 = or i32 %shl59, %lshrl57 - %shl60 = shl i32 %71, 26 - %ashr61 = ashr i32 %shl60, 26 - %or = or i32 %ashr61, 4 - %72 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl62 = shl i32 %or, 3 - %ztrunc63 = trunc i32 %shl62 to i8 - %73 = load i8, i8* %72, align 1 - %74 = and i8 %73, 7 - %75 = or i8 %74, %ztrunc63 - store i8 %75, i8* %72, align 1 - %lshrl64 = lshr i32 %or, 5 - %76 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc65 = trunc i32 %lshrl64 to i8 - %77 = and i8 %ztrunc65, 1 - %78 = load i8, i8* %76, align 1 - %79 = and i8 %78, -2 - %80 = or i8 %79, %77 - store i8 %79, i8* %76, align 1 - %81 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %82 = load i8, i8* %81, align 1 - %zext66 = zext i8 %82 to i32 - %shl67 = shl i32 %zext66, 29 - %ashr68 = ashr i32 %shl67, 29 - %83 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %84 = load i8, i8* %83, align 1 - %zext69 = zext i8 %84 to i32 - %lshrl70 = lshr i32 %zext69, 3 - %85 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %86 = load i8, i8* %85, align 1 - %zext71 = zext i8 %86 to i32 - %shl72 = shl i32 %zext71, 5 - %87 = or i32 %shl72, %lshrl70 - %shl73 = shl i32 %87, 26 - %ashr74 = ashr i32 %shl73, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i32 0, i32 0), i32 %ashr68, i32 %ashr74) - %88 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %89 = load i8, i8* %88, align 1 - %zext75 = zext i8 %89 to i32 - %lshrl76 = lshr i32 %zext75, 3 - %90 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %91 = load i8, i8* %90, align 1 - %zext77 = zext i8 %91 to i32 - %shl78 = shl i32 %zext77, 5 - %92 = or i32 %shl78, %lshrl76 - %shl79 = shl i32 %92, 26 - %ashr80 = ashr i32 %shl79, 26 - %shl81 = shl i32 %ashr80, 1 - %93 = freeze i32 %shl81 - %94 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl82 = shl i32 %93, 3 - %ztrunc83 = trunc i32 %shl82 to i8 - %95 = load i8, i8* %94, align 1 - %96 = and i8 %95, 7 - %97 = or i8 %96, %ztrunc83 - store i8 %97, i8* %94, align 1 - %lshrl84 = lshr i32 %93, 5 - %98 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc85 = trunc i32 %lshrl84 to i8 - %99 = and i8 %ztrunc85, 1 - %100 = load i8, i8* %98, align 1 - %101 = and i8 %100, -2 - %102 = or i8 %101, %99 - store i8 %101, i8* %98, align 1 - %103 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %104 = load i8, i8* %103, align 1 - %zext86 = zext i8 %104 to i32 - %shl87 = shl i32 %zext86, 29 - %ashr88 = ashr i32 %shl87, 29 - %105 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %106 = load i8, i8* %105, align 1 - %zext89 = zext i8 %106 to i32 - %lshrl90 = lshr i32 %zext89, 3 - %107 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %108 = load i8, i8* %107, align 1 - %zext91 = zext i8 %108 to i32 - %shl92 = shl i32 %zext91, 5 - %109 = or i32 %shl92, %lshrl90 - %shl93 = shl i32 %109, 26 - %ashr94 = ashr i32 %shl93, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i32 0, i32 0), i32 %ashr88, i32 %ashr94) - %110 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %111 = load i8, i8* %110, align 1 - %zext95 = zext i8 %111 to i32 - %lshrl96 = lshr i32 %zext95, 3 - %112 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %113 = load i8, i8* %112, align 1 - %zext97 = zext i8 %113 to i32 - %shl98 = shl i32 %zext97, 5 - %114 = or i32 %shl98, %lshrl96 - %shl99 = shl i32 %114, 26 - %ashr100 = ashr i32 %shl99, 26 - %ashr101 = ashr i32 %ashr100, 1 - %115 = freeze i32 %ashr101 - %116 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl102 = shl i32 %115, 3 - %ztrunc103 = trunc i32 %shl102 to i8 - %117 = load i8, i8* %116, align 1 - %118 = and i8 %117, 7 - %119 = or i8 %118, %ztrunc103 - store i8 %119, i8* %116, align 1 - %lshrl104 = lshr i32 %115, 5 - %120 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc105 = trunc i32 %lshrl104 to i8 - %121 = and i8 %ztrunc105, 1 - %122 = load i8, i8* %120, align 1 - %123 = and i8 %122, -2 - %124 = or i8 %123, %121 - store i8 %123, i8* %120, align 1 - %125 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %126 = load i8, i8* %125, align 1 - %zext106 = zext i8 %126 to i32 - %shl107 = shl i32 %zext106, 29 - %ashr108 = ashr i32 %shl107, 29 - %127 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %128 = load i8, i8* %127, align 1 - %zext109 = zext i8 %128 to i32 - %lshrl110 = lshr i32 %zext109, 3 - %129 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %130 = load i8, i8* %129, align 1 - %zext111 = zext i8 %130 to i32 - %shl112 = shl i32 %zext111, 5 - %131 = or i32 %shl112, %lshrl110 - %shl113 = shl i32 %131, 26 - %ashr114 = ashr i32 %shl113, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i32 0, i32 0), i32 %ashr108, i32 %ashr114) - %132 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %133 = load i8, i8* %132, align 1 - %zext115 = zext i8 %133 to i32 - %lshrl116 = lshr i32 %zext115, 3 - %134 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %135 = load i8, i8* %134, align 1 - %zext117 = zext i8 %135 to i32 - %shl118 = shl i32 %zext117, 5 - %136 = or i32 %shl118, %lshrl116 - %shl119 = shl i32 %136, 26 - %ashr120 = ashr i32 %shl119, 26 - %sdiv = sdiv i32 %ashr120, 2 - %137 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl121 = shl i32 %sdiv, 3 - %ztrunc122 = trunc i32 %shl121 to i8 - %138 = load i8, i8* %137, align 1 - %139 = and i8 %138, 7 - %140 = or i8 %139, %ztrunc122 - store i8 %140, i8* %137, align 1 - %lshrl123 = lshr i32 %sdiv, 5 - %141 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc124 = trunc i32 %lshrl123 to i8 - %142 = and i8 %ztrunc124, 1 - %143 = load i8, i8* %141, align 1 - %144 = and i8 %143, -2 - %145 = or i8 %144, %142 - store i8 %144, i8* %141, align 1 - %146 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %147 = load i8, i8* %146, align 1 - %zext125 = zext i8 %147 to i32 - %shl126 = shl i32 %zext125, 29 - %ashr127 = ashr i32 %shl126, 29 - %148 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %149 = load i8, i8* %148, align 1 - %zext128 = zext i8 %149 to i32 - %lshrl129 = lshr i32 %zext128, 3 - %150 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %151 = load i8, i8* %150, align 1 - %zext130 = zext i8 %151 to i32 - %shl131 = shl i32 %zext130, 5 - %152 = or i32 %shl131, %lshrl129 - %shl132 = shl i32 %152, 26 - %ashr133 = ashr i32 %shl132, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i32 0, i32 0), i32 %ashr127, i32 %ashr133) - %153 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %154 = load i8, i8* %153, align 1 - %zext134 = zext i8 %154 to i32 - %lshrl135 = lshr i32 %zext134, 3 - %155 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %156 = load i8, i8* %155, align 1 - %zext136 = zext i8 %156 to i32 - %shl137 = shl i32 %zext136, 5 - %157 = or i32 %shl137, %lshrl135 - %shl138 = shl i32 %157, 26 - %ashr139 = ashr i32 %shl138, 26 - %smod = srem i32 %ashr139, 2 - %158 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl140 = shl i32 %smod, 3 - %ztrunc141 = trunc i32 %shl140 to i8 - %159 = load i8, i8* %158, align 1 - %160 = and i8 %159, 7 - %161 = or i8 %160, %ztrunc141 - store i8 %161, i8* %158, align 1 - %lshrl142 = lshr i32 %smod, 5 - %162 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc143 = trunc i32 %lshrl142 to i8 - %163 = and i8 %ztrunc143, 1 - %164 = load i8, i8* %162, align 1 - %165 = and i8 %164, -2 - %166 = or i8 %165, %163 - store i8 %165, i8* %162, align 1 - %167 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %168 = load i8, i8* %167, align 1 - %zext144 = zext i8 %168 to i32 - %shl145 = shl i32 %zext144, 29 - %ashr146 = ashr i32 %shl145, 29 - %169 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %170 = load i8, i8* %169, align 1 - %zext147 = zext i8 %170 to i32 - %lshrl148 = lshr i32 %zext147, 3 - %171 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %172 = load i8, i8* %171, align 1 - %zext149 = zext i8 %172 to i32 - %shl150 = shl i32 %zext149, 5 - %173 = or i32 %shl150, %lshrl148 - %shl151 = shl i32 %173, 26 - %ashr152 = ashr i32 %shl151, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i32 0, i32 0), i32 %ashr146, i32 %ashr152) - %174 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %175 = load i8, i8* %174, align 1 - %lshrl153 = lshr i8 %175, 4 - %176 = trunc i8 %lshrl153 to i1 - %boolsi = zext i1 %176 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i32 0, i32 0), i32 %boolsi) - %177 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %178 = load i8, i8* %177, align 1 - %179 = and i8 %178, -17 - %180 = or i8 %179, 16 - store i8 %180, i8* %177, align 1 - %181 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %182 = load i8, i8* %181, align 1 - %lshrl154 = lshr i8 %182, 4 - %183 = trunc i8 %lshrl154 to i1 - %boolsi155 = zext i1 %183 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i32 0, i32 0), i32 %boolsi155) - %184 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %185 = load i8, i8* %184, align 1 - %186 = and i8 %185, -17 - store i8 %186, i8* %184, align 1 - %187 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %188 = load i8, i8* %187, align 1 - %lshrl156 = lshr i8 %188, 4 - %189 = trunc i8 %lshrl156 to i1 - %boolsi157 = zext i1 %189 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i32 0, i32 0), i32 %boolsi157) - ret void -} - -; Function Attrs: nounwind -define void @foo_test3() #0 { -entry: - %xx = alloca [3 x i8], align 1 - store [3 x i8] c"4<\00", [3 x i8]* %xx, align 1 - %0 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %1 = load i8, i8* %0, align 1 - %2 = and i8 %1, -15 - %3 = or i8 %2, 6 - store i8 %3, i8* %0, align 1 - %4 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %5 = load i8, i8* %4, align 1 - %zext = zext i8 %5 to i32 - %lshrl = lshr i32 %zext, 1 - %shl = shl i32 %lshrl, 29 - %ashr = ashr i32 %shl, 29 - %6 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %7 = load i8, i8* %6, align 1 - %zext1 = zext i8 %7 to i32 - %lshrl2 = lshr i32 %zext1, 4 - %8 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %9 = load i8, i8* %8, align 1 - %zext3 = zext i8 %9 to i32 - %shl4 = shl i32 %zext3, 4 - %10 = or i32 %shl4, %lshrl2 - %shl5 = shl i32 %10, 26 - %ashr6 = ashr i32 %shl5, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i32 0, i32 0), i32 %ashr, i32 %ashr6) - %11 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %12 = load i8, i8* %11, align 1 - %zext7 = zext i8 %12 to i32 - %lshrl8 = lshr i32 %zext7, 1 - %shl9 = shl i32 %lshrl8, 29 - %ashr10 = ashr i32 %shl9, 29 - %sub = sub i32 %ashr10, 1 - %13 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl11 = shl i32 %sub, 1 - %ztrunc = trunc i32 %shl11 to i8 - %14 = and i8 %ztrunc, 15 - %15 = load i8, i8* %13, align 1 - %16 = and i8 %15, -15 - %17 = or i8 %16, %14 - store i8 %17, i8* %13, align 1 - %lshrl12 = lshr i32 %sub, 7 - %18 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %19 = load i8, i8* %18, align 1 - %zext13 = zext i8 %19 to i32 - %lshrl14 = lshr i32 %zext13, 1 - %shl15 = shl i32 %lshrl14, 29 - %ashr16 = ashr i32 %shl15, 29 - %20 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %21 = load i8, i8* %20, align 1 - %zext17 = zext i8 %21 to i32 - %lshrl18 = lshr i32 %zext17, 4 - %22 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %23 = load i8, i8* %22, align 1 - %zext19 = zext i8 %23 to i32 - %shl20 = shl i32 %zext19, 4 - %24 = or i32 %shl20, %lshrl18 - %shl21 = shl i32 %24, 26 - %ashr22 = ashr i32 %shl21, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i32 0, i32 0), i32 %ashr16, i32 %ashr22) - %25 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %26 = load i8, i8* %25, align 1 - %zext23 = zext i8 %26 to i32 - %lshrl24 = lshr i32 %zext23, 4 - %27 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %28 = load i8, i8* %27, align 1 - %zext25 = zext i8 %28 to i32 - %shl26 = shl i32 %zext25, 4 - %29 = or i32 %shl26, %lshrl24 - %shl27 = shl i32 %29, 26 - %ashr28 = ashr i32 %shl27, 26 - %mul = mul i32 %ashr28, 2 - %30 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl29 = shl i32 %mul, 4 - %ztrunc30 = trunc i32 %shl29 to i8 - %31 = load i8, i8* %30, align 1 - %32 = and i8 %31, 15 - %33 = or i8 %32, %ztrunc30 - store i8 %33, i8* %30, align 1 - %lshrl31 = lshr i32 %mul, 4 - %34 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc32 = trunc i32 %lshrl31 to i8 - %35 = and i8 %ztrunc32, 3 - %36 = load i8, i8* %34, align 1 - %37 = and i8 %36, -4 - %38 = or i8 %37, %35 - store i8 %37, i8* %34, align 1 - %39 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %40 = load i8, i8* %39, align 1 - %zext33 = zext i8 %40 to i32 - %lshrl34 = lshr i32 %zext33, 1 - %shl35 = shl i32 %lshrl34, 29 - %ashr36 = ashr i32 %shl35, 29 - %41 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %42 = load i8, i8* %41, align 1 - %zext37 = zext i8 %42 to i32 - %lshrl38 = lshr i32 %zext37, 4 - %43 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %44 = load i8, i8* %43, align 1 - %zext39 = zext i8 %44 to i32 - %shl40 = shl i32 %zext39, 4 - %45 = or i32 %shl40, %lshrl38 - %shl41 = shl i32 %45, 26 - %ashr42 = ashr i32 %shl41, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.25, i32 0, i32 0), i32 %ashr36, i32 %ashr42) - %46 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %47 = load i8, i8* %46, align 1 - %zext43 = zext i8 %47 to i32 - %lshrl44 = lshr i32 %zext43, 4 - %48 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %49 = load i8, i8* %48, align 1 - %zext45 = zext i8 %49 to i32 - %shl46 = shl i32 %zext45, 4 - %50 = or i32 %shl46, %lshrl44 - %shl47 = shl i32 %50, 26 - %ashr48 = ashr i32 %shl47, 26 - %xor = xor i32 %ashr48, 4 - %51 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl49 = shl i32 %xor, 4 - %ztrunc50 = trunc i32 %shl49 to i8 - %52 = load i8, i8* %51, align 1 - %53 = and i8 %52, 15 - %54 = or i8 %53, %ztrunc50 - store i8 %54, i8* %51, align 1 - %lshrl51 = lshr i32 %xor, 4 - %55 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc52 = trunc i32 %lshrl51 to i8 - %56 = and i8 %ztrunc52, 3 - %57 = load i8, i8* %55, align 1 - %58 = and i8 %57, -4 - %59 = or i8 %58, %56 - store i8 %58, i8* %55, align 1 - %60 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %61 = load i8, i8* %60, align 1 - %zext53 = zext i8 %61 to i32 - %lshrl54 = lshr i32 %zext53, 1 - %shl55 = shl i32 %lshrl54, 29 - %ashr56 = ashr i32 %shl55, 29 - %62 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %63 = load i8, i8* %62, align 1 - %zext57 = zext i8 %63 to i32 - %lshrl58 = lshr i32 %zext57, 4 - %64 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %65 = load i8, i8* %64, align 1 - %zext59 = zext i8 %65 to i32 - %shl60 = shl i32 %zext59, 4 - %66 = or i32 %shl60, %lshrl58 - %shl61 = shl i32 %66, 26 - %ashr62 = ashr i32 %shl61, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.26, i32 0, i32 0), i32 %ashr56, i32 %ashr62) - %67 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %68 = load i8, i8* %67, align 1 - %zext63 = zext i8 %68 to i32 - %lshrl64 = lshr i32 %zext63, 4 - %69 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %70 = load i8, i8* %69, align 1 - %zext65 = zext i8 %70 to i32 - %shl66 = shl i32 %zext65, 4 - %71 = or i32 %shl66, %lshrl64 - %shl67 = shl i32 %71, 26 - %ashr68 = ashr i32 %shl67, 26 - %or = or i32 %ashr68, 4 - %72 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl69 = shl i32 %or, 4 - %ztrunc70 = trunc i32 %shl69 to i8 - %73 = load i8, i8* %72, align 1 - %74 = and i8 %73, 15 - %75 = or i8 %74, %ztrunc70 - store i8 %75, i8* %72, align 1 - %lshrl71 = lshr i32 %or, 4 - %76 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc72 = trunc i32 %lshrl71 to i8 - %77 = and i8 %ztrunc72, 3 - %78 = load i8, i8* %76, align 1 - %79 = and i8 %78, -4 - %80 = or i8 %79, %77 - store i8 %79, i8* %76, align 1 - %81 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %82 = load i8, i8* %81, align 1 - %zext73 = zext i8 %82 to i32 - %lshrl74 = lshr i32 %zext73, 1 - %shl75 = shl i32 %lshrl74, 29 - %ashr76 = ashr i32 %shl75, 29 - %83 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %84 = load i8, i8* %83, align 1 - %zext77 = zext i8 %84 to i32 - %lshrl78 = lshr i32 %zext77, 4 - %85 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %86 = load i8, i8* %85, align 1 - %zext79 = zext i8 %86 to i32 - %shl80 = shl i32 %zext79, 4 - %87 = or i32 %shl80, %lshrl78 - %shl81 = shl i32 %87, 26 - %ashr82 = ashr i32 %shl81, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i32 0, i32 0), i32 %ashr76, i32 %ashr82) - %88 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %89 = load i8, i8* %88, align 1 - %zext83 = zext i8 %89 to i32 - %lshrl84 = lshr i32 %zext83, 4 - %90 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %91 = load i8, i8* %90, align 1 - %zext85 = zext i8 %91 to i32 - %shl86 = shl i32 %zext85, 4 - %92 = or i32 %shl86, %lshrl84 - %shl87 = shl i32 %92, 26 - %ashr88 = ashr i32 %shl87, 26 - %shl89 = shl i32 %ashr88, 1 - %93 = freeze i32 %shl89 - %94 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl90 = shl i32 %93, 4 - %ztrunc91 = trunc i32 %shl90 to i8 - %95 = load i8, i8* %94, align 1 - %96 = and i8 %95, 15 - %97 = or i8 %96, %ztrunc91 - store i8 %97, i8* %94, align 1 - %lshrl92 = lshr i32 %93, 4 - %98 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc93 = trunc i32 %lshrl92 to i8 - %99 = and i8 %ztrunc93, 3 - %100 = load i8, i8* %98, align 1 - %101 = and i8 %100, -4 - %102 = or i8 %101, %99 - store i8 %101, i8* %98, align 1 - %103 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %104 = load i8, i8* %103, align 1 - %zext94 = zext i8 %104 to i32 - %lshrl95 = lshr i32 %zext94, 1 - %shl96 = shl i32 %lshrl95, 29 - %ashr97 = ashr i32 %shl96, 29 - %105 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %106 = load i8, i8* %105, align 1 - %zext98 = zext i8 %106 to i32 - %lshrl99 = lshr i32 %zext98, 4 - %107 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %108 = load i8, i8* %107, align 1 - %zext100 = zext i8 %108 to i32 - %shl101 = shl i32 %zext100, 4 - %109 = or i32 %shl101, %lshrl99 - %shl102 = shl i32 %109, 26 - %ashr103 = ashr i32 %shl102, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i32 0, i32 0), i32 %ashr97, i32 %ashr103) - %110 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %111 = load i8, i8* %110, align 1 - %zext104 = zext i8 %111 to i32 - %lshrl105 = lshr i32 %zext104, 4 - %112 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %113 = load i8, i8* %112, align 1 - %zext106 = zext i8 %113 to i32 - %shl107 = shl i32 %zext106, 4 - %114 = or i32 %shl107, %lshrl105 - %shl108 = shl i32 %114, 26 - %ashr109 = ashr i32 %shl108, 26 - %ashr110 = ashr i32 %ashr109, 1 - %115 = freeze i32 %ashr110 - %116 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl111 = shl i32 %115, 4 - %ztrunc112 = trunc i32 %shl111 to i8 - %117 = load i8, i8* %116, align 1 - %118 = and i8 %117, 15 - %119 = or i8 %118, %ztrunc112 - store i8 %119, i8* %116, align 1 - %lshrl113 = lshr i32 %115, 4 - %120 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc114 = trunc i32 %lshrl113 to i8 - %121 = and i8 %ztrunc114, 3 - %122 = load i8, i8* %120, align 1 - %123 = and i8 %122, -4 - %124 = or i8 %123, %121 - store i8 %123, i8* %120, align 1 - %125 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %126 = load i8, i8* %125, align 1 - %zext115 = zext i8 %126 to i32 - %lshrl116 = lshr i32 %zext115, 1 - %shl117 = shl i32 %lshrl116, 29 - %ashr118 = ashr i32 %shl117, 29 - %127 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %128 = load i8, i8* %127, align 1 - %zext119 = zext i8 %128 to i32 - %lshrl120 = lshr i32 %zext119, 4 - %129 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %130 = load i8, i8* %129, align 1 - %zext121 = zext i8 %130 to i32 - %shl122 = shl i32 %zext121, 4 - %131 = or i32 %shl122, %lshrl120 - %shl123 = shl i32 %131, 26 - %ashr124 = ashr i32 %shl123, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.29, i32 0, i32 0), i32 %ashr118, i32 %ashr124) - %132 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %133 = load i8, i8* %132, align 1 - %zext125 = zext i8 %133 to i32 - %lshrl126 = lshr i32 %zext125, 4 - %134 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %135 = load i8, i8* %134, align 1 - %zext127 = zext i8 %135 to i32 - %shl128 = shl i32 %zext127, 4 - %136 = or i32 %shl128, %lshrl126 - %shl129 = shl i32 %136, 26 - %ashr130 = ashr i32 %shl129, 26 - %sdiv = sdiv i32 %ashr130, 2 - %137 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl131 = shl i32 %sdiv, 4 - %ztrunc132 = trunc i32 %shl131 to i8 - %138 = load i8, i8* %137, align 1 - %139 = and i8 %138, 15 - %140 = or i8 %139, %ztrunc132 - store i8 %140, i8* %137, align 1 - %lshrl133 = lshr i32 %sdiv, 4 - %141 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc134 = trunc i32 %lshrl133 to i8 - %142 = and i8 %ztrunc134, 3 - %143 = load i8, i8* %141, align 1 - %144 = and i8 %143, -4 - %145 = or i8 %144, %142 - store i8 %144, i8* %141, align 1 - %146 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %147 = load i8, i8* %146, align 1 - %zext135 = zext i8 %147 to i32 - %lshrl136 = lshr i32 %zext135, 1 - %shl137 = shl i32 %lshrl136, 29 - %ashr138 = ashr i32 %shl137, 29 - %148 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %149 = load i8, i8* %148, align 1 - %zext139 = zext i8 %149 to i32 - %lshrl140 = lshr i32 %zext139, 4 - %150 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %151 = load i8, i8* %150, align 1 - %zext141 = zext i8 %151 to i32 - %shl142 = shl i32 %zext141, 4 - %152 = or i32 %shl142, %lshrl140 - %shl143 = shl i32 %152, 26 - %ashr144 = ashr i32 %shl143, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.30, i32 0, i32 0), i32 %ashr138, i32 %ashr144) - %153 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %154 = load i8, i8* %153, align 1 - %zext145 = zext i8 %154 to i32 - %lshrl146 = lshr i32 %zext145, 4 - %155 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %156 = load i8, i8* %155, align 1 - %zext147 = zext i8 %156 to i32 - %shl148 = shl i32 %zext147, 4 - %157 = or i32 %shl148, %lshrl146 - %shl149 = shl i32 %157, 26 - %ashr150 = ashr i32 %shl149, 26 - %smod = srem i32 %ashr150, 2 - %158 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %shl151 = shl i32 %smod, 4 - %ztrunc152 = trunc i32 %shl151 to i8 - %159 = load i8, i8* %158, align 1 - %160 = and i8 %159, 15 - %161 = or i8 %160, %ztrunc152 - store i8 %161, i8* %158, align 1 - %lshrl153 = lshr i32 %smod, 4 - %162 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %ztrunc154 = trunc i32 %lshrl153 to i8 - %163 = and i8 %ztrunc154, 3 - %164 = load i8, i8* %162, align 1 - %165 = and i8 %164, -4 - %166 = or i8 %165, %163 - store i8 %165, i8* %162, align 1 - %167 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %168 = load i8, i8* %167, align 1 - %zext155 = zext i8 %168 to i32 - %lshrl156 = lshr i32 %zext155, 1 - %shl157 = shl i32 %lshrl156, 29 - %ashr158 = ashr i32 %shl157, 29 - %169 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 0 - %170 = load i8, i8* %169, align 1 - %zext159 = zext i8 %170 to i32 - %lshrl160 = lshr i32 %zext159, 4 - %171 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 1 - %172 = load i8, i8* %171, align 1 - %zext161 = zext i8 %172 to i32 - %shl162 = shl i32 %zext161, 4 - %173 = or i32 %shl162, %lshrl160 - %shl163 = shl i32 %173, 26 - %ashr164 = ashr i32 %shl163, 26 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.31, i32 0, i32 0), i32 %ashr158, i32 %ashr164) - %174 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %175 = load i8, i8* %174, align 1 - %lshrl165 = lshr i8 %175, 5 - %176 = trunc i8 %lshrl165 to i1 - %boolsi = zext i1 %176 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.32, i32 0, i32 0), i32 %boolsi) - %177 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %178 = load i8, i8* %177, align 1 - %179 = and i8 %178, -33 - %180 = or i8 %179, 32 - store i8 %180, i8* %177, align 1 - %181 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %182 = load i8, i8* %181, align 1 - %lshrl166 = lshr i8 %182, 5 - %183 = trunc i8 %lshrl166 to i1 - %boolsi167 = zext i1 %183 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.33, i32 0, i32 0), i32 %boolsi167) - %184 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %185 = load i8, i8* %184, align 1 - %186 = and i8 %185, -33 - store i8 %186, i8* %184, align 1 - %187 = getelementptr inbounds [3 x i8], [3 x i8]* %xx, i64 0, i64 2 - %188 = load i8, i8* %187, align 1 - %lshrl168 = lshr i8 %188, 5 - %189 = trunc i8 %lshrl168 to i1 - %boolsi169 = zext i1 %189 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.34, i32 0, i32 0), i32 %boolsi169) - ret void -} diff --git a/test/test_suite14/bitstruct/bitstruct_arrays_be.c3t b/test/test_suite14/bitstruct/bitstruct_arrays_be.c3t deleted file mode 100644 index 9e5b7a254..000000000 --- a/test/test_suite14/bitstruct/bitstruct_arrays_be.c3t +++ /dev/null @@ -1,146 +0,0 @@ -// #target: macos-x64 -module foo; - -module foo; - -bitstruct BitField3 : char[4] @bigendian -{ - uint c : 4..19; -} - -bitstruct BitField4 : char[4] -{ - uint c : 4..19; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - test3(); -} -fn void test3() -{ - //BitField3 xx = { 0xdeadbeef }; - BitField3 xx = { 0xbeaf }; - printf("%x = beaf\n", xx.c); - BitField4 xy = { 0xbeaf }; - void *abc = &xy; - char[4]* z = abc; - printf("%x = beaf\n", xy.c); - xy.c = 0xbeef; - printf("%x = beef\n", xy.c); - xx.c = 0xbeef; - printf("%x = beef\n", xx.c); -} - - -/* #expect: foo.ll - -define void @foo_test3() #0 { -entry: - %xx = alloca [4 x i8], align 1 - %xy = alloca [4 x i8], align 1 - %abc = alloca i8*, align 8 - %z = alloca [4 x i8]*, align 8 - store [4 x i8] c"\E0\FB\0A\00", [4 x i8]* %xx, align 1 - %0 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 0 - %1 = load i8, i8* %0, align 1 - %zext = zext i8 %1 to i32 - %lshrl = lshr i32 %zext, 4 - %2 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 1 - %3 = load i8, i8* %2, align 1 - %zext1 = zext i8 %3 to i32 - %shl = shl i32 %zext1, 4 - %4 = or i32 %shl, %lshrl - %5 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 2 - %6 = load i8, i8* %5, align 1 - %zext2 = zext i8 %6 to i32 - %shl3 = shl i32 %zext2, 12 - %7 = or i32 %shl3, %4 - %shl4 = shl i32 %7, 16 - %8 = call i32 @llvm.bswap.i32(i32 %shl4) - %9 = and i32 65535, %8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 %9) - store [4 x i8] c"\F0\EA\0B\00", [4 x i8]* %xy, align 1 - %ptrptr = bitcast [4 x i8]* %xy to i8* - store i8* %ptrptr, i8** %abc, align 8 - %10 = load i8*, i8** %abc, align 8 - %ptrptr5 = bitcast i8* %10 to [4 x i8]* - store [4 x i8]* %ptrptr5, [4 x i8]** %z, align 8 - %11 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 0 - %12 = load i8, i8* %11, align 1 - %zext6 = zext i8 %12 to i32 - %lshrl7 = lshr i32 %zext6, 4 - %13 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 1 - %14 = load i8, i8* %13, align 1 - %zext8 = zext i8 %14 to i32 - %shl9 = shl i32 %zext8, 4 - %15 = or i32 %shl9, %lshrl7 - %16 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 2 - %17 = load i8, i8* %16, align 1 - %zext10 = zext i8 %17 to i32 - %shl11 = shl i32 %zext10, 12 - %18 = or i32 %shl11, %15 - %19 = and i32 65535, %18 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i32 %19) - %20 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 0 - %21 = load i8, i8* %20, align 1 - %22 = and i8 %21, 15 - %23 = or i8 %22, -16 - store i8 %23, i8* %20, align 1 - %24 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 1 - store i8 -18, i8* %24, align 1 - %25 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 2 - %26 = load i8, i8* %25, align 1 - %27 = and i8 %26, -16 - %28 = or i8 %27, 11 - store i8 %27, i8* %25, align 1 - %29 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 0 - %30 = load i8, i8* %29, align 1 - %zext12 = zext i8 %30 to i32 - %lshrl13 = lshr i32 %zext12, 4 - %31 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 1 - %32 = load i8, i8* %31, align 1 - %zext14 = zext i8 %32 to i32 - %shl15 = shl i32 %zext14, 4 - %33 = or i32 %shl15, %lshrl13 - %34 = getelementptr inbounds [4 x i8], [4 x i8]* %xy, i64 0, i64 2 - %35 = load i8, i8* %34, align 1 - %zext16 = zext i8 %35 to i32 - %shl17 = shl i32 %zext16, 12 - %36 = or i32 %shl17, %33 - %37 = and i32 65535, %36 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i32 %37) - %38 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 0 - %39 = load i8, i8* %38, align 1 - %40 = and i8 %39, 15 - %41 = or i8 %40, -32 - store i8 %41, i8* %38, align 1 - %42 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 1 - store i8 -5, i8* %42, align 1 - %43 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 2 - %44 = load i8, i8* %43, align 1 - %45 = and i8 %44, -16 - %46 = or i8 %45, 14 - store i8 %45, i8* %43, align 1 - %47 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 0 - %48 = load i8, i8* %47, align 1 - %zext18 = zext i8 %48 to i32 - %lshrl19 = lshr i32 %zext18, 4 - %49 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 1 - %50 = load i8, i8* %49, align 1 - %zext20 = zext i8 %50 to i32 - %shl21 = shl i32 %zext20, 4 - %51 = or i32 %shl21, %lshrl19 - %52 = getelementptr inbounds [4 x i8], [4 x i8]* %xx, i64 0, i64 2 - %53 = load i8, i8* %52, align 1 - %zext22 = zext i8 %53 to i32 - %shl23 = shl i32 %zext22, 12 - %54 = or i32 %shl23, %51 - %shl24 = shl i32 %54, 16 - %55 = call i32 @llvm.bswap.i32(i32 %shl24) - %56 = and i32 65535, %55 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i32 %56) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/bitstruct_be.c3t b/test/test_suite14/bitstruct/bitstruct_be.c3t deleted file mode 100644 index 37683735e..000000000 --- a/test/test_suite14/bitstruct/bitstruct_be.c3t +++ /dev/null @@ -1,315 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -bitstruct Test : int @bigendian -{ - ushort a : 0..15; - ushort b : 16..31; -} - -bitstruct Test2 : char[4] @bigendian -{ - ushort a : 0..15; - ushort b : 16..31; -} - -fn void main() -{ - IntBE x; - x.val = 123; - - io::printf("BE 123 => %d (%d)\n", (int)x, x.val); - Test abc = { .a = 0x1234, .b = 0x5678 }; - Test2 abc2 = { .a = 0x1234, .b = 0x5678 }; - char[4]* z = (char[4]*)&abc; - char[4]* z2 = (char[4]*)&abc2; - foreach (d : z2) io::printf(" %x", d); - io::println(""); - foreach (d : z) io::printf(" %x", d); - io::println(""); - io::printfn("abc.a = %x", abc.a); - abc.a = 0x1234; - abc.b = 0x5678; - io::printfn("->abc.a = %x", abc.a); - foreach (d : z) io::printf(" %x", d); - io::println(""); - - IntLE y; - y.val = 123; - io::printf("LE 123 => %d (%d)\n", (int)y, y.val); - -} - -/* #expect: test.ll - - %0 = load i32, i32* %x, align 4 - %1 = call i32 @llvm.bswap.i32(i32 %0) - store i32 2063597568, i32* %x, align 4 - %2 = bitcast i32* %x to i8* - %3 = insertvalue %variant undef, i8* %2, 0 - %4 = insertvalue %variant %3, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %5 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 0 - store %variant %4, %variant* %5, align 16 - %6 = load i32, i32* %x, align 4 - %7 = call i32 @llvm.bswap.i32(i32 %6) - store i32 %7, i32* %taddr, align 4 - %8 = bitcast i32* %taddr to i8* - %9 = insertvalue %variant undef, i8* %8, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %11 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 1 - store %variant %10, %variant* %11, align 16 - %12 = bitcast [2 x %variant]* %varargslots to %variant* - %13 = insertvalue %"variant[]" undef, %variant* %12, 0 - %14 = insertvalue %"variant[]" %13, i64 2, 1 - store %"variant[]" %14, %"variant[]"* %taddr1, align 8 - %15 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %16 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 0 - %lo = load i8*, i8** %16, align 8 - %17 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 1 - %hi = load i64, i64* %17, align 8 - %18 = call i64 @std_io_printf(i64* %retparam, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i32 0, i32 0), i64 18, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %18, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - store i32 873625686, i32* %abc, align 4 - store [4 x i8] c"\124Vx", [4 x i8]* %abc2, align 1 - %ptrptr = bitcast i32* %abc to [4 x i8]* - store [4 x i8]* %ptrptr, [4 x i8]** %z, align 8 - store [4 x i8]* %abc2, [4 x i8]** %z2, align 8 - %19 = load [4 x i8]*, [4 x i8]** %z2, align 8 - store [4 x i8]* %19, [4 x i8]** %.anon, align 8 - store i64 0, i64* %.anon2, align 8 - br label %loop.cond - -loop.cond: ; preds = %voiderr10, %voiderr - %20 = load i64, i64* %.anon2, align 8 - %gt = icmp ugt i64 4, %20 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %21 = load [4 x i8]*, [4 x i8]** %.anon, align 8 - %22 = load i64, i64* %.anon2, align 8 - %23 = getelementptr inbounds [4 x i8], [4 x i8]* %21, i64 0, i64 %22 - %24 = load i8, i8* %23, align 1 - store i8 %24, i8* %d, align 1 - %25 = insertvalue %variant undef, i8* %d, 0 - %26 = insertvalue %variant %25, i64 ptrtoint (%.introspect* @"ct$char" to i64), 1 - %27 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots4, i64 0, i64 0 - store %variant %26, %variant* %27, align 16 - %28 = bitcast [1 x %variant]* %varargslots4 to %variant* - %29 = insertvalue %"variant[]" undef, %variant* %28, 0 - %30 = insertvalue %"variant[]" %29, i64 1, 1 - store %"variant[]" %30, %"variant[]"* %taddr5, align 8 - %31 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %32 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %31, i32 0, i32 0 - %lo6 = load i8*, i8** %32, align 8 - %33 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %31, i32 0, i32 1 - %hi7 = load i64, i64* %33, align 8 - %34 = call i64 @std_io_printf(i64* %retparam3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i64 3, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %34, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %loop.body - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %loop.body - %35 = load i64, i64* %.anon2, align 8 - %add = add i64 %35, 1 - store i64 %add, i64* %.anon2, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %36 = call i32 @std_io_println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0)) #2 - %37 = load [4 x i8]*, [4 x i8]** %z, align 8 - store [4 x i8]* %37, [4 x i8]** %.anon11, align 8 - store i64 0, i64* %.anon12, align 8 - br label %loop.cond13 - -loop.cond13: ; preds = %voiderr24, %loop.exit - %38 = load i64, i64* %.anon12, align 8 - %gt14 = icmp ugt i64 4, %38 - br i1 %gt14, label %loop.body15, label %loop.exit26 - -loop.body15: ; preds = %loop.cond13 - %39 = load [4 x i8]*, [4 x i8]** %.anon11, align 8 - %40 = load i64, i64* %.anon12, align 8 - %41 = getelementptr inbounds [4 x i8], [4 x i8]* %39, i64 0, i64 %40 - %42 = load i8, i8* %41, align 1 - store i8 %42, i8* %d16, align 1 - %43 = insertvalue %variant undef, i8* %d16, 0 - %44 = insertvalue %variant %43, i64 ptrtoint (%.introspect* @"ct$char" to i64), 1 - %45 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots18, i64 0, i64 0 - store %variant %44, %variant* %45, align 16 - %46 = bitcast [1 x %variant]* %varargslots18 to %variant* - %47 = insertvalue %"variant[]" undef, %variant* %46, 0 - %48 = insertvalue %"variant[]" %47, i64 1, 1 - store %"variant[]" %48, %"variant[]"* %taddr19, align 8 - %49 = bitcast %"variant[]"* %taddr19 to { i8*, i64 }* - %50 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %49, i32 0, i32 0 - %lo20 = load i8*, i8** %50, align 8 - %51 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %49, i32 0, i32 1 - %hi21 = load i64, i64* %51, align 8 - %52 = call i64 @std_io_printf(i64* %retparam17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i64 3, i8* %lo20, i64 %hi21) - %not_err22 = icmp eq i64 %52, 0 - br i1 %not_err22, label %after_check23, label %voiderr24 - -after_check23: ; preds = %loop.body15 - br label %voiderr24 - -voiderr24: ; preds = %after_check23, %loop.body15 - %53 = load i64, i64* %.anon12, align 8 - %add25 = add i64 %53, 1 - store i64 %add25, i64* %.anon12, align 8 - br label %loop.cond13 - -loop.exit26: ; preds = %loop.cond13 - %54 = call i32 @std_io_println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0)) #2 - %55 = load i32, i32* %abc, align 4 - %56 = call i32 @llvm.bswap.i32(i32 %55) - %57 = and i32 65535, %56 - %ztrunc = trunc i32 %57 to i16 - store i16 %ztrunc, i16* %taddr29, align 2 - %58 = bitcast i16* %taddr29 to i8* - %59 = insertvalue %variant undef, i8* %58, 0 - %60 = insertvalue %variant %59, i64 ptrtoint (%.introspect* @"ct$ushort" to i64), 1 - %61 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots28, i64 0, i64 0 - store %variant %60, %variant* %61, align 16 - %62 = bitcast [1 x %variant]* %varargslots28 to %variant* - %63 = insertvalue %"variant[]" undef, %variant* %62, 0 - %64 = insertvalue %"variant[]" %63, i64 1, 1 - store %"variant[]" %64, %"variant[]"* %taddr30, align 8 - %65 = bitcast %"variant[]"* %taddr30 to { i8*, i64 }* - %66 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %65, i32 0, i32 0 - %lo31 = load i8*, i8** %66, align 8 - %67 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %65, i32 0, i32 1 - %hi32 = load i64, i64* %67, align 8 - %68 = call i64 @std_io_printfn(i64* %retparam27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i32 0, i32 0), i64 10, i8* %lo31, i64 %hi32) - %not_err33 = icmp eq i64 %68, 0 - br i1 %not_err33, label %after_check34, label %voiderr35 - -after_check34: ; preds = %loop.exit26 - br label %voiderr35 - -voiderr35: ; preds = %after_check34, %loop.exit26 - %69 = load i32, i32* %abc, align 4 - %70 = call i32 @llvm.bswap.i32(i32 %69) - %71 = and i32 %70, -65536 - %72 = or i32 %71, 4660 - %73 = call i32 @llvm.bswap.i32(i32 %72) - store i32 %73, i32* %abc, align 4 - %74 = load i32, i32* %abc, align 4 - %75 = call i32 @llvm.bswap.i32(i32 %74) - %76 = and i32 %75, 65535 - %77 = or i32 %76, 1450704896 - %78 = call i32 @llvm.bswap.i32(i32 %77) - store i32 %78, i32* %abc, align 4 - %79 = load i32, i32* %abc, align 4 - %80 = call i32 @llvm.bswap.i32(i32 %79) - %81 = and i32 65535, %80 - %ztrunc38 = trunc i32 %81 to i16 - store i16 %ztrunc38, i16* %taddr39, align 2 - %82 = bitcast i16* %taddr39 to i8* - %83 = insertvalue %variant undef, i8* %82, 0 - %84 = insertvalue %variant %83, i64 ptrtoint (%.introspect* @"ct$ushort" to i64), 1 - %85 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots37, i64 0, i64 0 - store %variant %84, %variant* %85, align 16 - %86 = bitcast [1 x %variant]* %varargslots37 to %variant* - %87 = insertvalue %"variant[]" undef, %variant* %86, 0 - %88 = insertvalue %"variant[]" %87, i64 1, 1 - store %"variant[]" %88, %"variant[]"* %taddr40, align 8 - %89 = bitcast %"variant[]"* %taddr40 to { i8*, i64 }* - %90 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %89, i32 0, i32 0 - %lo41 = load i8*, i8** %90, align 8 - %91 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %89, i32 0, i32 1 - %hi42 = load i64, i64* %91, align 8 - %92 = call i64 @std_io_printfn(i64* %retparam36, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i32 0, i32 0), i64 12, i8* %lo41, i64 %hi42) - %not_err43 = icmp eq i64 %92, 0 - br i1 %not_err43, label %after_check44, label %voiderr45 - -after_check44: ; preds = %voiderr35 - br label %voiderr45 - -voiderr45: ; preds = %after_check44, %voiderr35 - %93 = load [4 x i8]*, [4 x i8]** %z, align 8 - store [4 x i8]* %93, [4 x i8]** %.anon46, align 8 - store i64 0, i64* %.anon47, align 8 - br label %loop.cond48 - -loop.cond48: ; preds = %voiderr59, %voiderr45 - %94 = load i64, i64* %.anon47, align 8 - %gt49 = icmp ugt i64 4, %94 - br i1 %gt49, label %loop.body50, label %loop.exit61 - -loop.body50: ; preds = %loop.cond48 - %95 = load [4 x i8]*, [4 x i8]** %.anon46, align 8 - %96 = load i64, i64* %.anon47, align 8 - %97 = getelementptr inbounds [4 x i8], [4 x i8]* %95, i64 0, i64 %96 - %98 = load i8, i8* %97, align 1 - store i8 %98, i8* %d51, align 1 - %99 = insertvalue %variant undef, i8* %d51, 0 - %100 = insertvalue %variant %99, i64 ptrtoint (%.introspect* @"ct$char" to i64), 1 - %101 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots53, i64 0, i64 0 - store %variant %100, %variant* %101, align 16 - %102 = bitcast [1 x %variant]* %varargslots53 to %variant* - %103 = insertvalue %"variant[]" undef, %variant* %102, 0 - %104 = insertvalue %"variant[]" %103, i64 1, 1 - store %"variant[]" %104, %"variant[]"* %taddr54, align 8 - %105 = bitcast %"variant[]"* %taddr54 to { i8*, i64 }* - %106 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %105, i32 0, i32 0 - %lo55 = load i8*, i8** %106, align 8 - %107 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %105, i32 0, i32 1 - %hi56 = load i64, i64* %107, align 8 - %108 = call i64 @std_io_printf(i64* %retparam52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i64 3, i8* %lo55, i64 %hi56) - %not_err57 = icmp eq i64 %108, 0 - br i1 %not_err57, label %after_check58, label %voiderr59 - -after_check58: ; preds = %loop.body50 - br label %voiderr59 - -voiderr59: ; preds = %after_check58, %loop.body50 - %109 = load i64, i64* %.anon47, align 8 - %add60 = add i64 %109, 1 - store i64 %add60, i64* %.anon47, align 8 - br label %loop.cond48 - -loop.exit61: ; preds = %loop.cond48 - %110 = call i32 @std_io_println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i32 0, i32 0)) #2 - store i32 0, i32* %y, align 4 - %111 = load i32, i32* %y, align 4 - store i32 123, i32* %y, align 4 - %112 = bitcast i32* %y to i8* - %113 = insertvalue %variant undef, i8* %112, 0 - %114 = insertvalue %variant %113, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %115 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots63, i64 0, i64 0 - store %variant %114, %variant* %115, align 16 - %116 = load i32, i32* %y, align 4 - store i32 %116, i32* %taddr64, align 4 - %117 = bitcast i32* %taddr64 to i8* - %118 = insertvalue %variant undef, i8* %117, 0 - %119 = insertvalue %variant %118, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %120 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots63, i64 0, i64 1 - store %variant %119, %variant* %120, align 16 - %121 = bitcast [2 x %variant]* %varargslots63 to %variant* - %122 = insertvalue %"variant[]" undef, %variant* %121, 0 - %123 = insertvalue %"variant[]" %122, i64 2, 1 - store %"variant[]" %123, %"variant[]"* %taddr65, align 8 - %124 = bitcast %"variant[]"* %taddr65 to { i8*, i64 }* - %125 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %124, i32 0, i32 0 - %lo66 = load i8*, i8** %125, align 8 - %126 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %124, i32 0, i32 1 - %hi67 = load i64, i64* %126, align 8 - %127 = call i64 @std_io_printf(i64* %retparam62, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i32 0, i32 0), i64 18, i8* %lo66, i64 %hi67) - %not_err68 = icmp eq i64 %127, 0 - br i1 %not_err68, label %after_check69, label %voiderr70 - -after_check69: ; preds = %loop.exit61 - br label %voiderr70 - -voiderr70: ; preds = %after_check69, %loop.exit61 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/bitstruct_general.c3 b/test/test_suite14/bitstruct/bitstruct_general.c3 deleted file mode 100644 index 62580160b..000000000 --- a/test/test_suite14/bitstruct/bitstruct_general.c3 +++ /dev/null @@ -1,46 +0,0 @@ -// #target: macos-x64 - -module foo; - - -bitstruct BitField -{// #error: followed by bitstruct type - int a : 0..2; - int b : 4..6; - int c : 7..8; -} - - -bitstruct BitField2 : char -{ - int a : 0..2; - int b : 4..6; - int c : 7..8; -} - -struct Packet -{ - bitstruct : int - { - int a : 0..2; - int b : 3..5; - int c : 5..6; - } - int packet_id; -} - -bitstruct BitField3 : char[3] -{ - int a : 0..2; - int b : 3..8; - int c : 9..18; - int d : 19..23; -} - -bitstruct BitField4 : char[3] @align(8) -{ - int a : 0..2; - int b : 3..7; - int c : 8..15; - int d : 16..19; -} diff --git a/test/test_suite14/bitstruct/bitstruct_init.c3 b/test/test_suite14/bitstruct/bitstruct_init.c3 deleted file mode 100644 index ebb316d4c..000000000 --- a/test/test_suite14/bitstruct/bitstruct_init.c3 +++ /dev/null @@ -1,62 +0,0 @@ -module foo; - -bitstruct Foo : uint -{ - int x : 1..3; - uint y : 11..13; - int z : 15..15; -} - -struct Bar -{ - int x; - bitstruct baz : int - { - int x : 1..3; - } -} - -struct Bar2 -{ - int x; - bitstruct : int - { - int z : 1..3; - } - -} -fn void testNested() -{ - Bar b1 = { 3, { 3 } }; - Bar b2 = { .x = 3, .baz.x = 3 }; - Bar2 b3 = { 1, 3 }; - Bar2 b4 = { .x = 123, .z = 3 }; - Bar2 b5 = { .x = 123, .z = 4 }; // #error: would be truncated - Bar2 b6 = { 1, 4 }; // #error: would be truncated - Bar b7 = { 3, { 4 } }; // #error: would be truncated - Bar b8 = { .x = 3, .baz.x = 4 }; // #error: would be truncated - -} - -fn void test() -{ - Foo abc = {}; - abc.x = -4; - abc.z = 0; - abc.z = -1; - abc.x = 3; - abc.y = 7; - abc.x = -5; // #error: would be truncated - abc.x = 4; // #error: would be truncated - abc.y = 8; // #error: would be truncated -} - -fn void test2() -{ - Foo abc = { -4, 8, 0 }; // #error: would be truncated -} - -fn void test3() -{ - Foo abc = { .x = -4, .z = 0, .y = 8 }; // #error: would be truncated -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/bitstruct_initializer.c3t b/test/test_suite14/bitstruct/bitstruct_initializer.c3t deleted file mode 100644 index 2bc364917..000000000 --- a/test/test_suite14/bitstruct/bitstruct_initializer.c3t +++ /dev/null @@ -1,569 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -bitstruct Foo : ulong -{ - uint x : 0..31; - uint y : 32..62; - bool w : 63; -} - -bitstruct Bar : char[8] -{ - uint x : 0..31; - uint y : 32..62; - bool w : 63; -} -struct Abc -{ - int x; - Foo b; -} - -fn void hello(int z) -{ - Foo x; - x = { .x = z, .w = z < 100 }; - Abc y = { .b.x = 32, .b.y = 10 }; - Abc d = { .b = { 23, 11, true } }; - Bar b; - b = { .x = z, .w = z < 100 }; - io::printfn("%s %s %s", x.x, x.y, x.w); - io::printfn("%s %s %s", y.b.x, y.b.y, y.b.w); - io::printfn("%s %s %s", b.x, b.y, b.w); - x = { z + 1, 1, z > 100 }; - y.b = { 33, 11, true }; - b = { z + 1, 1, z > 100 }; - io::printfn("%s %s %s", x.x, x.y, x.w); - io::printfn("%s %s %s", y.b.x, y.b.y, y.b.w); - io::printfn("%s %s %s", b.x, b.y, b.w); - -} - -fn void main() -{ - hello(12); -} - -/* #expect: test.ll - -define void @test_hello(i32 %0) #0 { -entry: - %x = alloca i64, align 8 - %y = alloca %Abc, align 8 - %d = alloca %Abc, align 8 - %b = alloca [8 x i8], align 1 - %retparam = alloca i64, align 8 - %varargslots = alloca [3 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr13 = alloca i32, align 4 - %taddr16 = alloca i8, align 1 - %taddr17 = alloca %"variant[]", align 8 - %retparam18 = alloca i64, align 8 - %varargslots19 = alloca [3 x %variant], align 16 - %taddr21 = alloca i32, align 4 - %taddr24 = alloca i32, align 4 - %taddr27 = alloca i8, align 1 - %taddr28 = alloca %"variant[]", align 8 - %retparam34 = alloca i64, align 8 - %varargslots35 = alloca [3 x %variant], align 16 - %taddr43 = alloca i32, align 4 - %taddr51 = alloca i32, align 4 - %taddr53 = alloca i8, align 1 - %taddr54 = alloca %"variant[]", align 8 - %retparam74 = alloca i64, align 8 - %varargslots75 = alloca [3 x %variant], align 16 - %taddr77 = alloca i32, align 4 - %taddr80 = alloca i32, align 4 - %taddr83 = alloca i8, align 1 - %taddr84 = alloca %"variant[]", align 8 - %retparam90 = alloca i64, align 8 - %varargslots91 = alloca [3 x %variant], align 16 - %taddr93 = alloca i32, align 4 - %taddr96 = alloca i32, align 4 - %taddr99 = alloca i8, align 1 - %taddr100 = alloca %"variant[]", align 8 - %retparam106 = alloca i64, align 8 - %varargslots107 = alloca [3 x %variant], align 16 - %taddr115 = alloca i32, align 4 - %taddr123 = alloca i32, align 4 - %taddr125 = alloca i8, align 1 - %taddr126 = alloca %"variant[]", align 8 - store i64 0, i64* %x, align 8 - %zext = zext i32 %0 to i64 - %1 = and i64 %zext, 4294967295 - %lt = icmp slt i32 %0, 100 - %2 = zext i1 %lt to i8 - %zext1 = zext i8 %2 to i64 - %shl = shl i64 %zext1, 63 - %3 = and i64 %shl, -9223372036854775808 - %4 = and i64 %1, 9223372036854775807 - %5 = or i64 %4, %3 - store i64 %5, i64* %x, align 8 - %6 = bitcast %Abc* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %6, i8* align 8 bitcast (%Abc* @.__const to i8*), i32 16, i1 false) - %7 = bitcast %Abc* %d to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %7, i8* align 8 bitcast (%Abc* @.__const.1 to i8*), i32 16, i1 false) - %8 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 0 - store i8 0, i8* %8, align 1 - %9 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 1 - store i8 0, i8* %9, align 1 - %10 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 2 - store i8 0, i8* %10, align 1 - %11 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 3 - store i8 0, i8* %11, align 1 - %12 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 4 - store i8 0, i8* %12, align 1 - %13 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 5 - store i8 0, i8* %13, align 1 - %14 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 6 - store i8 0, i8* %14, align 1 - %15 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - store i8 0, i8* %15, align 1 - %16 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 0 - store i8 0, i8* %16, align 1 - %17 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 1 - store i8 0, i8* %17, align 1 - %18 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 2 - store i8 0, i8* %18, align 1 - %19 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 3 - store i8 0, i8* %19, align 1 - %20 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 4 - store i8 0, i8* %20, align 1 - %21 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 5 - store i8 0, i8* %21, align 1 - %22 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 6 - store i8 0, i8* %22, align 1 - %23 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - store i8 0, i8* %23, align 1 - %24 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 0 - %ztrunc = trunc i32 %0 to i8 - store i8 %ztrunc, i8* %24, align 1 - %lshrl = lshr i32 %0, 8 - %25 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 1 - %ztrunc2 = trunc i32 %lshrl to i8 - store i8 %ztrunc2, i8* %25, align 1 - %lshrl3 = lshr i32 %lshrl, 8 - %26 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 2 - %ztrunc4 = trunc i32 %lshrl3 to i8 - store i8 %ztrunc4, i8* %26, align 1 - %lshrl5 = lshr i32 %lshrl3, 8 - %27 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 3 - %ztrunc6 = trunc i32 %lshrl5 to i8 - store i8 %ztrunc6, i8* %27, align 1 - %lshrl7 = lshr i32 %lshrl5, 8 - %lt8 = icmp slt i32 %0, 100 - %28 = zext i1 %lt8 to i8 - %shl9 = shl i8 %28, 7 - %29 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - %30 = load i8, i8* %29, align 1 - %31 = and i8 %30, 127 - %32 = or i8 %31, %shl9 - store i8 %32, i8* %29, align 1 - %33 = load i64, i64* %x, align 8 - %34 = and i64 4294967295, %33 - %ztrunc10 = trunc i64 %34 to i32 - store i32 %ztrunc10, i32* %taddr, align 4 - %35 = bitcast i32* %taddr to i8* - %36 = insertvalue %variant undef, i8* %35, 0 - %37 = insertvalue %variant %36, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %38 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots, i64 0, i64 0 - store %variant %37, %variant* %38, align 16 - %39 = load i64, i64* %x, align 8 - %lshrl11 = lshr i64 %39, 32 - %40 = and i64 2147483647, %lshrl11 - %ztrunc12 = trunc i64 %40 to i32 - store i32 %ztrunc12, i32* %taddr13, align 4 - %41 = bitcast i32* %taddr13 to i8* - %42 = insertvalue %variant undef, i8* %41, 0 - %43 = insertvalue %variant %42, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %44 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots, i64 0, i64 1 - store %variant %43, %variant* %44, align 16 - %45 = load i64, i64* %x, align 8 - %lshrl14 = lshr i64 %45, 63 - %46 = and i64 1, %lshrl14 - %ztrunc15 = trunc i64 %46 to i8 - store i8 %ztrunc15, i8* %taddr16, align 1 - %47 = insertvalue %variant undef, i8* %taddr16, 0 - %48 = insertvalue %variant %47, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %49 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots, i64 0, i64 2 - store %variant %48, %variant* %49, align 16 - %50 = bitcast [3 x %variant]* %varargslots to %variant* - %51 = insertvalue %"variant[]" undef, %variant* %50, 0 - %52 = insertvalue %"variant[]" %51, i64 3, 1 - store %"variant[]" %52, %"variant[]"* %taddr17, align 8 - %53 = bitcast %"variant[]"* %taddr17 to { i8*, i64 }* - %54 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %53, i32 0, i32 0 - %lo = load i8*, i8** %54, align 8 - %55 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %53, i32 0, i32 1 - %hi = load i64, i64* %55, align 8 - %56 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i64 8, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %56, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %57 = getelementptr inbounds %Abc, %Abc* %y, i32 0, i32 1 - %58 = load i64, i64* %57, align 8 - %59 = and i64 4294967295, %58 - %ztrunc20 = trunc i64 %59 to i32 - store i32 %ztrunc20, i32* %taddr21, align 4 - %60 = bitcast i32* %taddr21 to i8* - %61 = insertvalue %variant undef, i8* %60, 0 - %62 = insertvalue %variant %61, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %63 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots19, i64 0, i64 0 - store %variant %62, %variant* %63, align 16 - %64 = getelementptr inbounds %Abc, %Abc* %y, i32 0, i32 1 - %65 = load i64, i64* %64, align 8 - %lshrl22 = lshr i64 %65, 32 - %66 = and i64 2147483647, %lshrl22 - %ztrunc23 = trunc i64 %66 to i32 - store i32 %ztrunc23, i32* %taddr24, align 4 - %67 = bitcast i32* %taddr24 to i8* - %68 = insertvalue %variant undef, i8* %67, 0 - %69 = insertvalue %variant %68, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %70 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots19, i64 0, i64 1 - store %variant %69, %variant* %70, align 16 - %71 = getelementptr inbounds %Abc, %Abc* %y, i32 0, i32 1 - %72 = load i64, i64* %71, align 8 - %lshrl25 = lshr i64 %72, 63 - %73 = and i64 1, %lshrl25 - %ztrunc26 = trunc i64 %73 to i8 - store i8 %ztrunc26, i8* %taddr27, align 1 - %74 = insertvalue %variant undef, i8* %taddr27, 0 - %75 = insertvalue %variant %74, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %76 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots19, i64 0, i64 2 - store %variant %75, %variant* %76, align 16 - %77 = bitcast [3 x %variant]* %varargslots19 to %variant* - %78 = insertvalue %"variant[]" undef, %variant* %77, 0 - %79 = insertvalue %"variant[]" %78, i64 3, 1 - store %"variant[]" %79, %"variant[]"* %taddr28, align 8 - %80 = bitcast %"variant[]"* %taddr28 to { i8*, i64 }* - %81 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %80, i32 0, i32 0 - %lo29 = load i8*, i8** %81, align 8 - %82 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %80, i32 0, i32 1 - %hi30 = load i64, i64* %82, align 8 - %83 = call i64 @std_io_printfn(i64* %retparam18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i64 8, i8* %lo29, i64 %hi30) - %not_err31 = icmp eq i64 %83, 0 - br i1 %not_err31, label %after_check32, label %voiderr33 - -after_check32: ; preds = %voiderr - br label %voiderr33 - -voiderr33: ; preds = %after_check32, %voiderr - %84 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 0 - %85 = load i8, i8* %84, align 1 - %zext36 = zext i8 %85 to i32 - %86 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 1 - %87 = load i8, i8* %86, align 1 - %zext37 = zext i8 %87 to i32 - %shl38 = shl i32 %zext37, 8 - %88 = or i32 %shl38, %zext36 - %89 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 2 - %90 = load i8, i8* %89, align 1 - %zext39 = zext i8 %90 to i32 - %shl40 = shl i32 %zext39, 16 - %91 = or i32 %shl40, %88 - %92 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 3 - %93 = load i8, i8* %92, align 1 - %zext41 = zext i8 %93 to i32 - %shl42 = shl i32 %zext41, 24 - %94 = or i32 %shl42, %91 - store i32 %94, i32* %taddr43, align 4 - %95 = bitcast i32* %taddr43 to i8* - %96 = insertvalue %variant undef, i8* %95, 0 - %97 = insertvalue %variant %96, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %98 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots35, i64 0, i64 0 - store %variant %97, %variant* %98, align 16 - %99 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 4 - %100 = load i8, i8* %99, align 1 - %zext44 = zext i8 %100 to i32 - %101 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 5 - %102 = load i8, i8* %101, align 1 - %zext45 = zext i8 %102 to i32 - %shl46 = shl i32 %zext45, 8 - %103 = or i32 %shl46, %zext44 - %104 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 6 - %105 = load i8, i8* %104, align 1 - %zext47 = zext i8 %105 to i32 - %shl48 = shl i32 %zext47, 16 - %106 = or i32 %shl48, %103 - %107 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - %108 = load i8, i8* %107, align 1 - %zext49 = zext i8 %108 to i32 - %shl50 = shl i32 %zext49, 24 - %109 = or i32 %shl50, %106 - %110 = and i32 2147483647, %109 - store i32 %110, i32* %taddr51, align 4 - %111 = bitcast i32* %taddr51 to i8* - %112 = insertvalue %variant undef, i8* %111, 0 - %113 = insertvalue %variant %112, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %114 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots35, i64 0, i64 1 - store %variant %113, %variant* %114, align 16 - %115 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - %116 = load i8, i8* %115, align 1 - %lshrl52 = lshr i8 %116, 7 - %117 = trunc i8 %lshrl52 to i1 - %118 = zext i1 %117 to i8 - store i8 %118, i8* %taddr53, align 1 - %119 = insertvalue %variant undef, i8* %taddr53, 0 - %120 = insertvalue %variant %119, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %121 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots35, i64 0, i64 2 - store %variant %120, %variant* %121, align 16 - %122 = bitcast [3 x %variant]* %varargslots35 to %variant* - %123 = insertvalue %"variant[]" undef, %variant* %122, 0 - %124 = insertvalue %"variant[]" %123, i64 3, 1 - store %"variant[]" %124, %"variant[]"* %taddr54, align 8 - %125 = bitcast %"variant[]"* %taddr54 to { i8*, i64 }* - %126 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %125, i32 0, i32 0 - %lo55 = load i8*, i8** %126, align 8 - %127 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %125, i32 0, i32 1 - %hi56 = load i64, i64* %127, align 8 - %128 = call i64 @std_io_printfn(i64* %retparam34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i64 8, i8* %lo55, i64 %hi56) - %not_err57 = icmp eq i64 %128, 0 - br i1 %not_err57, label %after_check58, label %voiderr59 - -after_check58: ; preds = %voiderr33 - br label %voiderr59 - -voiderr59: ; preds = %after_check58, %voiderr33 - %add = add i32 %0, 1 - %zext60 = zext i32 %add to i64 - %129 = and i64 %zext60, 4294967295 - %130 = and i64 %129, -9223372032559808513 - %131 = or i64 %130, 4294967296 - %gt = icmp sgt i32 %0, 100 - %132 = zext i1 %gt to i8 - %zext61 = zext i8 %132 to i64 - %shl62 = shl i64 %zext61, 63 - %133 = and i64 %shl62, -9223372036854775808 - %134 = and i64 %131, 9223372036854775807 - %135 = or i64 %134, %133 - store i64 %135, i64* %x, align 8 - %136 = getelementptr inbounds %Abc, %Abc* %y, i32 0, i32 1 - store i64 -9223371989610135519, i64* %136, align 8 - %137 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 0 - store i8 0, i8* %137, align 1 - %138 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 1 - store i8 0, i8* %138, align 1 - %139 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 2 - store i8 0, i8* %139, align 1 - %140 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 3 - store i8 0, i8* %140, align 1 - %141 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 4 - store i8 0, i8* %141, align 1 - %142 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 5 - store i8 0, i8* %142, align 1 - %143 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 6 - store i8 0, i8* %143, align 1 - %144 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - store i8 0, i8* %144, align 1 - %add63 = add i32 %0, 1 - %145 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 0 - %ztrunc64 = trunc i32 %add63 to i8 - store i8 %ztrunc64, i8* %145, align 1 - %lshrl65 = lshr i32 %add63, 8 - %146 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 1 - %ztrunc66 = trunc i32 %lshrl65 to i8 - store i8 %ztrunc66, i8* %146, align 1 - %lshrl67 = lshr i32 %lshrl65, 8 - %147 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 2 - %ztrunc68 = trunc i32 %lshrl67 to i8 - store i8 %ztrunc68, i8* %147, align 1 - %lshrl69 = lshr i32 %lshrl67, 8 - %148 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 3 - %ztrunc70 = trunc i32 %lshrl69 to i8 - store i8 %ztrunc70, i8* %148, align 1 - %lshrl71 = lshr i32 %lshrl69, 8 - %149 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 4 - store i8 1, i8* %149, align 1 - %150 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 5 - store i8 0, i8* %150, align 1 - %151 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 6 - store i8 0, i8* %151, align 1 - %152 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - %153 = load i8, i8* %152, align 1 - %154 = and i8 %153, -128 - store i8 %154, i8* %152, align 1 - %gt72 = icmp sgt i32 %0, 100 - %155 = zext i1 %gt72 to i8 - %shl73 = shl i8 %155, 7 - %156 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - %157 = load i8, i8* %156, align 1 - %158 = and i8 %157, 127 - %159 = or i8 %158, %shl73 - store i8 %159, i8* %156, align 1 - %160 = load i64, i64* %x, align 8 - %161 = and i64 4294967295, %160 - %ztrunc76 = trunc i64 %161 to i32 - store i32 %ztrunc76, i32* %taddr77, align 4 - %162 = bitcast i32* %taddr77 to i8* - %163 = insertvalue %variant undef, i8* %162, 0 - %164 = insertvalue %variant %163, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %165 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots75, i64 0, i64 0 - store %variant %164, %variant* %165, align 16 - %166 = load i64, i64* %x, align 8 - %lshrl78 = lshr i64 %166, 32 - %167 = and i64 2147483647, %lshrl78 - %ztrunc79 = trunc i64 %167 to i32 - store i32 %ztrunc79, i32* %taddr80, align 4 - %168 = bitcast i32* %taddr80 to i8* - %169 = insertvalue %variant undef, i8* %168, 0 - %170 = insertvalue %variant %169, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %171 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots75, i64 0, i64 1 - store %variant %170, %variant* %171, align 16 - %172 = load i64, i64* %x, align 8 - %lshrl81 = lshr i64 %172, 63 - %173 = and i64 1, %lshrl81 - %ztrunc82 = trunc i64 %173 to i8 - store i8 %ztrunc82, i8* %taddr83, align 1 - %174 = insertvalue %variant undef, i8* %taddr83, 0 - %175 = insertvalue %variant %174, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %176 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots75, i64 0, i64 2 - store %variant %175, %variant* %176, align 16 - %177 = bitcast [3 x %variant]* %varargslots75 to %variant* - %178 = insertvalue %"variant[]" undef, %variant* %177, 0 - %179 = insertvalue %"variant[]" %178, i64 3, 1 - store %"variant[]" %179, %"variant[]"* %taddr84, align 8 - %180 = bitcast %"variant[]"* %taddr84 to { i8*, i64 }* - %181 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %180, i32 0, i32 0 - %lo85 = load i8*, i8** %181, align 8 - %182 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %180, i32 0, i32 1 - %hi86 = load i64, i64* %182, align 8 - %183 = call i64 @std_io_printfn(i64* %retparam74, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i64 8, i8* %lo85, i64 %hi86) - %not_err87 = icmp eq i64 %183, 0 - br i1 %not_err87, label %after_check88, label %voiderr89 - -after_check88: ; preds = %voiderr59 - br label %voiderr89 - -voiderr89: ; preds = %after_check88, %voiderr59 - %184 = getelementptr inbounds %Abc, %Abc* %y, i32 0, i32 1 - %185 = load i64, i64* %184, align 8 - %186 = and i64 4294967295, %185 - %ztrunc92 = trunc i64 %186 to i32 - store i32 %ztrunc92, i32* %taddr93, align 4 - %187 = bitcast i32* %taddr93 to i8* - %188 = insertvalue %variant undef, i8* %187, 0 - %189 = insertvalue %variant %188, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %190 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots91, i64 0, i64 0 - store %variant %189, %variant* %190, align 16 - %191 = getelementptr inbounds %Abc, %Abc* %y, i32 0, i32 1 - %192 = load i64, i64* %191, align 8 - %lshrl94 = lshr i64 %192, 32 - %193 = and i64 2147483647, %lshrl94 - %ztrunc95 = trunc i64 %193 to i32 - store i32 %ztrunc95, i32* %taddr96, align 4 - %194 = bitcast i32* %taddr96 to i8* - %195 = insertvalue %variant undef, i8* %194, 0 - %196 = insertvalue %variant %195, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %197 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots91, i64 0, i64 1 - store %variant %196, %variant* %197, align 16 - %198 = getelementptr inbounds %Abc, %Abc* %y, i32 0, i32 1 - %199 = load i64, i64* %198, align 8 - %lshrl97 = lshr i64 %199, 63 - %200 = and i64 1, %lshrl97 - %ztrunc98 = trunc i64 %200 to i8 - store i8 %ztrunc98, i8* %taddr99, align 1 - %201 = insertvalue %variant undef, i8* %taddr99, 0 - %202 = insertvalue %variant %201, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %203 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots91, i64 0, i64 2 - store %variant %202, %variant* %203, align 16 - %204 = bitcast [3 x %variant]* %varargslots91 to %variant* - %205 = insertvalue %"variant[]" undef, %variant* %204, 0 - %206 = insertvalue %"variant[]" %205, i64 3, 1 - store %"variant[]" %206, %"variant[]"* %taddr100, align 8 - %207 = bitcast %"variant[]"* %taddr100 to { i8*, i64 }* - %208 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %207, i32 0, i32 0 - %lo101 = load i8*, i8** %208, align 8 - %209 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %207, i32 0, i32 1 - %hi102 = load i64, i64* %209, align 8 - %210 = call i64 @std_io_printfn(i64* %retparam90, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i64 8, i8* %lo101, i64 %hi102) - %not_err103 = icmp eq i64 %210, 0 - br i1 %not_err103, label %after_check104, label %voiderr105 - -after_check104: ; preds = %voiderr89 - br label %voiderr105 - -voiderr105: ; preds = %after_check104, %voiderr89 - %211 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 0 - %212 = load i8, i8* %211, align 1 - %zext108 = zext i8 %212 to i32 - %213 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 1 - %214 = load i8, i8* %213, align 1 - %zext109 = zext i8 %214 to i32 - %shl110 = shl i32 %zext109, 8 - %215 = or i32 %shl110, %zext108 - %216 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 2 - %217 = load i8, i8* %216, align 1 - %zext111 = zext i8 %217 to i32 - %shl112 = shl i32 %zext111, 16 - %218 = or i32 %shl112, %215 - %219 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 3 - %220 = load i8, i8* %219, align 1 - %zext113 = zext i8 %220 to i32 - %shl114 = shl i32 %zext113, 24 - %221 = or i32 %shl114, %218 - store i32 %221, i32* %taddr115, align 4 - %222 = bitcast i32* %taddr115 to i8* - %223 = insertvalue %variant undef, i8* %222, 0 - %224 = insertvalue %variant %223, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %225 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots107, i64 0, i64 0 - store %variant %224, %variant* %225, align 16 - %226 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 4 - %227 = load i8, i8* %226, align 1 - %zext116 = zext i8 %227 to i32 - %228 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 5 - %229 = load i8, i8* %228, align 1 - %zext117 = zext i8 %229 to i32 - %shl118 = shl i32 %zext117, 8 - %230 = or i32 %shl118, %zext116 - %231 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 6 - %232 = load i8, i8* %231, align 1 - %zext119 = zext i8 %232 to i32 - %shl120 = shl i32 %zext119, 16 - %233 = or i32 %shl120, %230 - %234 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - %235 = load i8, i8* %234, align 1 - %zext121 = zext i8 %235 to i32 - %shl122 = shl i32 %zext121, 24 - %236 = or i32 %shl122, %233 - %237 = and i32 2147483647, %236 - store i32 %237, i32* %taddr123, align 4 - %238 = bitcast i32* %taddr123 to i8* - %239 = insertvalue %variant undef, i8* %238, 0 - %240 = insertvalue %variant %239, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %241 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots107, i64 0, i64 1 - store %variant %240, %variant* %241, align 16 - %242 = getelementptr inbounds [8 x i8], [8 x i8]* %b, i64 0, i64 7 - %243 = load i8, i8* %242, align 1 - %lshrl124 = lshr i8 %243, 7 - %244 = trunc i8 %lshrl124 to i1 - %245 = zext i1 %244 to i8 - store i8 %245, i8* %taddr125, align 1 - %246 = insertvalue %variant undef, i8* %taddr125, 0 - %247 = insertvalue %variant %246, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %248 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots107, i64 0, i64 2 - store %variant %247, %variant* %248, align 16 - %249 = bitcast [3 x %variant]* %varargslots107 to %variant* - %250 = insertvalue %"variant[]" undef, %variant* %249, 0 - %251 = insertvalue %"variant[]" %250, i64 3, 1 - store %"variant[]" %251, %"variant[]"* %taddr126, align 8 - %252 = bitcast %"variant[]"* %taddr126 to { i8*, i64 }* - %253 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %252, i32 0, i32 0 - %lo127 = load i8*, i8** %253, align 8 - %254 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %252, i32 0, i32 1 - %hi128 = load i64, i64* %254, align 8 - %255 = call i64 @std_io_printfn(i64* %retparam106, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0), i64 8, i8* %lo127, i64 %hi128) - %not_err129 = icmp eq i64 %255, 0 - br i1 %not_err129, label %after_check130, label %voiderr131 - -after_check130: ; preds = %voiderr105 - br label %voiderr131 - -voiderr131: ; preds = %after_check130, %voiderr105 - ret void -} diff --git a/test/test_suite14/bitstruct/bitstruct_intcontainer.c3t b/test/test_suite14/bitstruct/bitstruct_intcontainer.c3t deleted file mode 100644 index 12580a87f..000000000 --- a/test/test_suite14/bitstruct/bitstruct_intcontainer.c3t +++ /dev/null @@ -1,105 +0,0 @@ -// #target: macos-x64 - -module foo; - -bitstruct BitFieldCross : uint -{ - uint d : 0..4; - int a : 5..22; - uint c : 23..31; -} - -bitstruct BitFieldCrossU : int -{ - uint d : 0..4; - uint a : 5..22; - uint c : 23..31; -} - -bitstruct BitFieldCrossUL : long -{ - uint d : 0..4; - uint a : 5..22; - uint c : 23..40; - uint e : 41..61; -} - -bitstruct BitFieldCrossULBE : long @bigendian -{ - uint d : 0..4; - uint a : 5..22; - uint c : 23..40; - uint e : 41..61; -} -extern fn void printf(char*, ...); - -fn void main() -{ - BitFieldCross xx = { 0, -15, 0 }; - printf("%d\n", xx.a); - xx = { 0x1f, -15, 0x7f }; - printf("%d\n", xx.a); - BitFieldCrossU xxu = { 0x1f, 0x25678, 0x1ff }; - printf("%x\n", xxu.a); - BitFieldCrossUL xxy = { 0x1f, 0x25678, 0xeffe, 0xa9597 }; - printf("%x, %x, %x\n", xxy.a, xxy.c, xxy.e); - BitFieldCrossULBE xxybe = { 0x1f, 0x25678, 0xeffe, 0xa9597 }; - printf("%x, %x, %x\n", xxybe.a, xxybe.c, xxybe.e); -} - - -/* #expect: foo.ll - -entry: - %xx = alloca i32, align 4 - %xxu = alloca i32, align 4 - %xxy = alloca i64, align 8 - %xxybe = alloca i64, align 8 - store i32 8388128, i32* %xx, align 4 - %0 = load i32, i32* %xx, align 4 - %shl = shl i32 %0, 9 - %ashr = ashr i32 %shl, 14 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %ashr) - store i32 1073741375, i32* %xx, align 4 - %1 = load i32, i32* %xx, align 4 - %shl1 = shl i32 %1, 9 - %ashr2 = ashr i32 %shl1, 14 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %ashr2) - store i32 -3485921, i32* %xxu, align 4 - %2 = load i32, i32* %xxu, align 4 - %lshrl = lshr i32 %2, 5 - %3 = and i32 262143, %lshrl - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 %3) - store i64 1525363991714123551, i64* %xxy, align 8 - %4 = load i64, i64* %xxy, align 8 - %lshrl3 = lshr i64 %4, 5 - %5 = and i64 262143, %lshrl3 - %ztrunc = trunc i64 %5 to i32 - %6 = load i64, i64* %xxy, align 8 - %lshrl4 = lshr i64 %6, 23 - %7 = and i64 262143, %lshrl4 - %ztrunc5 = trunc i64 %7 to i32 - %8 = load i64, i64* %xxy, align 8 - %lshrl6 = lshr i64 %8, 41 - %9 = and i64 2097151, %lshrl6 - %ztrunc7 = trunc i64 %9 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0), i32 %ztrunc, i32 %ztrunc5, i32 %ztrunc7) - store i64 2292133196431502101, i64* %xxybe, align 8 - %10 = load i64, i64* %xxybe, align 8 - %11 = call i64 @llvm.bswap.i64(i64 %10) - %lshrl8 = lshr i64 %11, 5 - %12 = and i64 262143, %lshrl8 - %ztrunc9 = trunc i64 %12 to i32 - %13 = load i64, i64* %xxybe, align 8 - %14 = call i64 @llvm.bswap.i64(i64 %13) - %lshrl10 = lshr i64 %14, 23 - %15 = and i64 262143, %lshrl10 - %ztrunc11 = trunc i64 %15 to i32 - %16 = load i64, i64* %xxybe, align 8 - %17 = call i64 @llvm.bswap.i64(i64 %16) - %lshrl12 = lshr i64 %17, 41 - %18 = and i64 2097151, %lshrl12 - %ztrunc13 = trunc i64 %18 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0), i32 %ztrunc9, i32 %ztrunc11, i32 %ztrunc13) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/bitstruct_overlap.c3 b/test/test_suite14/bitstruct/bitstruct_overlap.c3 deleted file mode 100644 index bbee3b194..000000000 --- a/test/test_suite14/bitstruct/bitstruct_overlap.c3 +++ /dev/null @@ -1,47 +0,0 @@ -bitstruct Foo1 : char -{ - int a : 2..5; - int b : 5..6; // #error: Overlapping members -} - -bitstruct Foo2 : char -{ - int a : 2..5; - int b : 4..6; // #error: Overlapping members -} - -bitstruct Foo3 : char -{ - int a : 2..5; - int b : 2..6; // #error: Overlapping members -} - -bitstruct Foo4 : char -{ - int a : 2..5; - int b : 1..6; // #error: Overlapping members -} - -bitstruct Foo5 : char -{ - int a : 2..5; - int b : 1..3; // #error: Overlapping members -} - -bitstruct Foo6 : char -{ - int a : 2..5; - int b : 1..1; -} - -bitstruct Foo7 : char @overlap -{ - int a : 2..5; - int b : 1..3; -} - -bitstruct Foo8 : char -{ - int a : 2..5; - bool b : 3; // #error: Overlapping members -} diff --git a/test/test_suite14/bitstruct/bitstruct_single_error.c3 b/test/test_suite14/bitstruct/bitstruct_single_error.c3 deleted file mode 100644 index 663cf196c..000000000 --- a/test/test_suite14/bitstruct/bitstruct_single_error.c3 +++ /dev/null @@ -1,19 +0,0 @@ -bitstruct Foo1 : char -{ - char x : 1..1; -} - -bitstruct Foo2 : char -{ - char x : 1; // #error: Only booleans may use non-range indices -} - -bitstruct Foo3 : char -{ - bool x : 0..2; // #error: The bit width of 'bool' -} - -bitstruct Foo4 : int -{ - char x : 0..15; // #error: The bit width of 'char' -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/bitstruct_to_int.c3t b/test/test_suite14/bitstruct/bitstruct_to_int.c3t deleted file mode 100644 index 4954606b3..000000000 --- a/test/test_suite14/bitstruct/bitstruct_to_int.c3t +++ /dev/null @@ -1,109 +0,0 @@ -// #target: macos-x64 - -module foo; - -extern fn void printf(char*, ...); - -bitstruct Foo : uint -{ - int x : 1..3; - uint y : 11..13; - int z : 15..15; -} - -bitstruct Foo2 : char[4] -{ - int x : 1..3; - uint y : 11..13; - int z : 15..15; -} - -fn void test() -{ - Foo b = {}; - int x = (int)b; - char[4] y = (char[4])b; - Foo *c = &b; - c.x; - int* x2 = (int*)c; - char[4]* y2 = (char[4]*)c; -} - -fn void test2() -{ - Foo2 b = { 3, 2, -1 }; - int x = (int)b; - char[4] y = (char[4])b; - Foo2 *c = &b; - printf("%d\n", c.x); - int* x2 = (int*)c; - char[4]* y2 = (char[4]*)c; -} - -fn void main() -{ - test(); - test2(); -} - -/* #expect: foo.ll - -define void @foo_test() #0 { -entry: - %b = alloca i32, align 4 - %x = alloca i32, align 4 - %y = alloca [4 x i8], align 1 - %c = alloca i32*, align 8 - %x2 = alloca i32*, align 8 - %y2 = alloca [4 x i8]*, align 8 - store i32 0, i32* %b, align 4 - %0 = load i32, i32* %b, align 4 - store i32 %0, i32* %x, align 4 - %1 = bitcast i32* %b to [4 x i8]* - %2 = load [4 x i8], [4 x i8]* %1, align 4 - store [4 x i8] %2, [4 x i8]* %y, align 1 - store i32* %b, i32** %c, align 8 - %3 = load i32*, i32** %c, align 8 - %4 = load i32, i32* %3, align 4 - %shl = shl i32 %4, 28 - %ashr = ashr i32 %shl, 29 - %5 = load i32*, i32** %c, align 8 - store i32* %5, i32** %x2, align 8 - %6 = load i32*, i32** %c, align 8 - %ptrptr = bitcast i32* %6 to [4 x i8]* - store [4 x i8]* %ptrptr, [4 x i8]** %y2, align 8 - ret void -} - -; Function Attrs: nounwind -define void @foo_test2() #0 { -entry: - %b = alloca [4 x i8], align 1 - %x = alloca i32, align 4 - %y = alloca [4 x i8], align 1 - %c = alloca [4 x i8]*, align 8 - %x2 = alloca i32*, align 8 - %y2 = alloca [4 x i8]*, align 8 - store [4 x i8] c"\06\90\00\00", [4 x i8]* %b, align 1 - %0 = bitcast [4 x i8]* %b to i32* - %1 = load i32, i32* %0, align 1 - store i32 %1, i32* %x, align 4 - %2 = bitcast [4 x i8]* %y to i8* - %3 = bitcast [4 x i8]* %b to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %2, i8* align 1 %3, i32 4, i1 false) - store [4 x i8]* %b, [4 x i8]** %c, align 8 - %4 = load [4 x i8]*, [4 x i8]** %c, align 8 - %5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0 - %6 = load i8, i8* %5, align 1 - %zext = zext i8 %6 to i32 - %lshrl = lshr i32 %zext, 1 - %shl = shl i32 %lshrl, 29 - %ashr = ashr i32 %shl, 29 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %ashr) - %7 = load [4 x i8]*, [4 x i8]** %c, align 8 - %ptrptr = bitcast [4 x i8]* %7 to i32* - store i32* %ptrptr, i32** %x2, align 8 - %8 = load [4 x i8]*, [4 x i8]** %c, align 8 - store [4 x i8]* %8, [4 x i8]** %y2, align 8 - ret void -} diff --git a/test/test_suite14/bitstruct/embedded_bitstruct.c3t b/test/test_suite14/bitstruct/embedded_bitstruct.c3t deleted file mode 100644 index 9614c47d8..000000000 --- a/test/test_suite14/bitstruct/embedded_bitstruct.c3t +++ /dev/null @@ -1,81 +0,0 @@ -// #target: macos-x64 - -module foo; - -struct Bar -{ - int x; - struct - { - struct - { - int y; - } - } - bitstruct : uint - { - int ww : 2..10; - } -} - -struct Foo -{ - struct - { - struct - { - int x; - } - struct - { - int y; - } - int z; - } - int w; -} -extern fn void printf(char*, ...); - -fn void main() -{ - Bar b = { 1, 2, -5 }; - printf("%d %d\n", b.y, b.ww); - Foo f = { 5, 6, 7, 8 }; - printf("%d %d %d %d\n", f.x, f.y, f.z, f.w); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %b = alloca %Bar, align 4 - %f = alloca %Foo, align 4 - %0 = bitcast %Bar* %b to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%Bar* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1 - %2 = getelementptr inbounds %.anon, %.anon* %1, i32 0, i32 0 - %3 = getelementptr inbounds %.anon.0, %.anon.0* %2, i32 0, i32 0 - %4 = load i32, i32* %3, align 4 - %5 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 2 - %6 = load i32, i32* %5, align 4 - %shl = shl i32 %6, 21 - %ashr = ashr i32 %shl, 23 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i32 %4, i32 %ashr) - %7 = bitcast %Foo* %f to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 bitcast (%Foo* @.__const.10 to i8*), i32 16, i1 false) - %8 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 0 - %9 = getelementptr inbounds %.anon.1, %.anon.1* %8, i32 0, i32 0 - %10 = getelementptr inbounds %.anon.2, %.anon.2* %9, i32 0, i32 0 - %11 = load i32, i32* %10, align 4 - %12 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 0 - %13 = getelementptr inbounds %.anon.1, %.anon.1* %12, i32 0, i32 1 - %14 = getelementptr inbounds %.anon.3, %.anon.3* %13, i32 0, i32 0 - %15 = load i32, i32* %14, align 4 - %16 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 0 - %17 = getelementptr inbounds %.anon.1, %.anon.1* %16, i32 0, i32 2 - %18 = load i32, i32* %17, align 4 - %19 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 1 - %20 = load i32, i32* %19, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i32 %11, i32 %15, i32 %18, i32 %20) - ret void -} diff --git a/test/test_suite14/bitstruct/invalid_bitstruct_member_types.c3 b/test/test_suite14/bitstruct/invalid_bitstruct_member_types.c3 deleted file mode 100644 index 21a1aaa19..000000000 --- a/test/test_suite14/bitstruct/invalid_bitstruct_member_types.c3 +++ /dev/null @@ -1,26 +0,0 @@ - -bitstruct Test : int -{ - bool x : 0..0; - float a : 1..3; // #error: 'float' is not supported in a bitstruct, only enums, integer and boolean values may be used. -} - -define Baz = distinct float; -define Foo = distinct bool; -enum Boo -{ - BAR -} -bitstruct Test2 : int -{ - Foo x : 0..0; - Boo y : 4..6; - Baz a : 1..3; // #error: 'Baz' is not supported in a bitstruct, only enums, integer and boolean values may be used. -} - - -bitstruct Test3 : int -{ - Foo x : 0..0; - Brob a : 1..3; // #error: 'Brob' could not be found, did you spell it right? -} diff --git a/test/test_suite14/bitstruct/invalid_bitstruct_name_other_ident.c3 b/test/test_suite14/bitstruct/invalid_bitstruct_name_other_ident.c3 deleted file mode 100644 index dda1db4e6..000000000 --- a/test/test_suite14/bitstruct/invalid_bitstruct_name_other_ident.c3 +++ /dev/null @@ -1,20 +0,0 @@ -bitstruct test : int // #error: Names of bitstructs must start with an uppercase letter. -{ - int a : 1..3; - int b : 5..10; - uint c : 20..20; -} - -bitstruct $if : int // #error: 'bitstruct' should be followed by the name of the bitstruct. -{ - int a : 1..3; - int b : 5..10; - uint c : 20..20; -} - -bitstruct if : int // #error: Names of bitstructs must start with an uppercase letter. -{ - int a : 1..3; - int b : 5..10; - uint c : 20..20; -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/invalid_bitstruct_type.c3 b/test/test_suite14/bitstruct/invalid_bitstruct_type.c3 deleted file mode 100644 index d4d616ec0..000000000 --- a/test/test_suite14/bitstruct/invalid_bitstruct_type.c3 +++ /dev/null @@ -1,7 +0,0 @@ - -bitstruct Test : float // #error: The type of the bitstruct cannot be 'float' but must be an integer or an array of integers. -{ - int a : 1..3; - int b : 5..10; - uint c : 20..20; -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/invalid_empty_struct_union.c3 b/test/test_suite14/bitstruct/invalid_empty_struct_union.c3 deleted file mode 100644 index d51661a07..000000000 --- a/test/test_suite14/bitstruct/invalid_empty_struct_union.c3 +++ /dev/null @@ -1,7 +0,0 @@ -struct Foo // #error: Zero sized structs are not permitted. -{ -} - -union Bar // #error: Zero sized unions are not permitted. -{ -} \ No newline at end of file diff --git a/test/test_suite14/bitstruct/missing_bitstruct_type.c3 b/test/test_suite14/bitstruct/missing_bitstruct_type.c3 deleted file mode 100644 index 1b82e0c70..000000000 --- a/test/test_suite14/bitstruct/missing_bitstruct_type.c3 +++ /dev/null @@ -1,3 +0,0 @@ -bitstruct BitField -{ // #error: followed by bitstruct -} \ No newline at end of file diff --git a/test/test_suite14/builtins/builtin_vector_abs.c3t b/test/test_suite14/builtins/builtin_vector_abs.c3t deleted file mode 100644 index 2bfaff266..000000000 --- a/test/test_suite14/builtins/builtin_vector_abs.c3t +++ /dev/null @@ -1,18 +0,0 @@ -// #target: macos-x64 -module test; -fn void main() -{ - { - float[<2>] vf1 = { 1, -1 }; - float[<2>] absf = $$abs(vf1); - } - { - int[<2>] v1 = { 1, -1 }; - int[<2>] absi = $$abs(v1); - } -} - -/* #expect: test.ll - - %1 = call <2 x float> @llvm.fabs.v2f32(<2 x float> %0) - %3 = call <2 x i32> @llvm.abs.v2i32(<2 x i32> %2, i1 false) diff --git a/test/test_suite14/builtins/builtin_vector_min_max.c3t b/test/test_suite14/builtins/builtin_vector_min_max.c3t deleted file mode 100644 index ff05001aa..000000000 --- a/test/test_suite14/builtins/builtin_vector_min_max.c3t +++ /dev/null @@ -1,24 +0,0 @@ -// #target: macos-x64 -module test; -fn void main() -{ - { - float[<2>] vf1 = { 1, -1 }; - float[<2>] vf2 = { 1, 1 }; - float[<2>] max = $$max(vf1, vf2); - float[<2>] min = $$min(vf1, vf2); - } - { - int[<2>] v1 = { 1, -1 }; - int[<2>] v2 = { 1, 1 }; - int[<2>] max = $$max(v1, v2); - int[<2>] min = $$min(v1, v2); - } -} - -/* #expect: test.ll - - %2 = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %0, <2 x float> %1) - %5 = call <2 x float> @llvm.minnum.v2f32(<2 x float> %3, <2 x float> %4) - %8 = call <2 x i32> @llvm.smax.v2i32(<2 x i32> %6, <2 x i32> %7) - %11 = call <2 x i32> @llvm.smin.v2i32(<2 x i32> %9, <2 x i32> %10) diff --git a/test/test_suite14/builtins/builtin_with_optional.c3 b/test/test_suite14/builtins/builtin_with_optional.c3 deleted file mode 100644 index 037fa3b5a..000000000 --- a/test/test_suite14/builtins/builtin_with_optional.c3 +++ /dev/null @@ -1,8 +0,0 @@ -fn void main() -{ - float x; - x = $$fma(x, x, x); - float! y; - y = $$fma(x, x, y); - x = $$fma(x, x, y); // #error: 'float!' -} \ No newline at end of file diff --git a/test/test_suite14/builtins/exacts.c3t b/test/test_suite14/builtins/exacts.c3t deleted file mode 100644 index 9012d5d91..000000000 --- a/test/test_suite14/builtins/exacts.c3t +++ /dev/null @@ -1,24 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -fn void main() -{ - ichar x = 23; - ichar y = 121; - int z1 = $$mul(x, y); - ichar z2 = $$div(y, x); - ichar z3 = $$mod(y, x); - int z4 = $$add(x, y); - int z5 = $$sub(x, y); - int z6 = $$neg(x); - io::printfn("%s %s %s %s %s %s", z1, z2, z3, z4, z5, z6); -} - -/* #expect: test.ll - - %emul = mul i8 %0, %1 - %esdiv = sdiv i8 %2, %3 - %eumod = srem i8 %4, %5 - %eadd = add i8 %6, %7 - %esub = sub i8 %8, %9 - %eneg = sub i8 0, %10 \ No newline at end of file diff --git a/test/test_suite14/builtins/mem.c3t b/test/test_suite14/builtins/mem.c3t deleted file mode 100644 index 416fd4196..000000000 --- a/test/test_suite14/builtins/mem.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 -module test; - -fn void main() -{ - ushort src = 1; - ushort dst = 2; - - $$memcpy(&dst, &src, ushort.sizeof, false, $alignof(dst), $alignof(src)); - $$memmove(&dst, &src, ushort.sizeof, false, $alignof(dst), $alignof(src)); - $$memset(&dst, 0u8, ushort.sizeof, false, $alignof(dst)); - - $$memcpy_inline(&dst, &src, ushort.sizeof, false, $alignof(dst), $alignof(src)); - $$memset_inline(&dst, 0u8, ushort.sizeof, false, $alignof(dst)); -} - -/* #expect: test.ll - - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 2 %0, i8* align 2 %1, i64 2, i1 false) - call void @llvm.memmove.p0i8.p0i8.i64(i8* align 2 %2, i8* align 2 %3, i64 2, i1 false) - call void @llvm.memset.p0i8.i64(i8* align 2 %4, i8 0, i64 2, i1 false) - call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 2 %5, i8* align 2 %6, i64 2, i1 false) diff --git a/test/test_suite14/builtins/overflows.c3t b/test/test_suite14/builtins/overflows.c3t deleted file mode 100644 index 1c728775c..000000000 --- a/test/test_suite14/builtins/overflows.c3t +++ /dev/null @@ -1,66 +0,0 @@ -module test; -import std::io; -fn void main() -{ - ichar x = 23; - ichar y = 121; - ichar z1; - ichar z2; - ichar z3; - ichar z4; - ichar z5; - bool success1 = $$overflow_mul(x, y, &z1); - bool success2 = $$overflow_add(x, y, &z2); - bool success3 = $$overflow_add(x, x, &z3); - bool success4 = $$overflow_sub($$neg(y), y, &z4); - bool success5 = $$overflow_sub(x, y, &z5); - io::printfn("%s %s", success1, z1); - io::printfn("%s %s", success2, z2); - io::printfn("%s %s", success3, z3); - io::printfn("%s %s", success4, z4); - io::printfn("%s %s", success5, z5); -} - -/* #expect: test.ll - - %0 = load i8, i8* %x, align 1 - %1 = load i8, i8* %y, align 1 - %2 = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %0, i8 %1) - %3 = extractvalue { i8, i1 } %2, 1 - %4 = extractvalue { i8, i1 } %2, 0 - store i8 %4, i8* %z1, align 1 - %5 = zext i1 %3 to i8 - store i8 %5, i8* %success1, align 1 - %6 = load i8, i8* %x, align 1 - %7 = load i8, i8* %y, align 1 - %8 = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %6, i8 %7) - %9 = extractvalue { i8, i1 } %8, 1 - %10 = extractvalue { i8, i1 } %8, 0 - store i8 %10, i8* %z2, align 1 - %11 = zext i1 %9 to i8 - store i8 %11, i8* %success2, align 1 - %12 = load i8, i8* %x, align 1 - %13 = load i8, i8* %x, align 1 - %14 = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %12, i8 %13) - %15 = extractvalue { i8, i1 } %14, 1 - %16 = extractvalue { i8, i1 } %14, 0 - store i8 %16, i8* %z3, align 1 - %17 = zext i1 %15 to i8 - store i8 %17, i8* %success3, align 1 - %18 = load i8, i8* %y, align 1 - %eneg = sub i8 0, %18 - %19 = load i8, i8* %y, align 1 - %20 = call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %eneg, i8 %19) - %21 = extractvalue { i8, i1 } %20, 1 - %22 = extractvalue { i8, i1 } %20, 0 - store i8 %22, i8* %z4, align 1 - %23 = zext i1 %21 to i8 - store i8 %23, i8* %success4, align 1 - %24 = load i8, i8* %x, align 1 - %25 = load i8, i8* %y, align 1 - %26 = call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %24, i8 %25) - %27 = extractvalue { i8, i1 } %26, 1 - %28 = extractvalue { i8, i1 } %26, 0 - store i8 %28, i8* %z5, align 1 - %29 = zext i1 %27 to i8 - store i8 %29, i8* %success5, align 1 diff --git a/test/test_suite14/builtins/prefetch.c3t b/test/test_suite14/builtins/prefetch.c3t deleted file mode 100644 index 79084d5e0..000000000 --- a/test/test_suite14/builtins/prefetch.c3t +++ /dev/null @@ -1,25 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn void main() -{ - int a; - $$prefetch(&a, 1, 3); - $$prefetch(&a, 0, 1); - prefetch(&a); -} - -/* #expect: test.ll - - %a = alloca i32, align 4 - %ptr = alloca i8*, align 8 - store i32 0, i32* %a, align 4 - %ptrptr = bitcast i32* %a to i8* - call void @llvm.prefetch.p0i8(i8* %ptrptr, i32 1, i32 3, i32 1) - %ptrptr1 = bitcast i32* %a to i8* - call void @llvm.prefetch.p0i8(i8* %ptrptr1, i32 0, i32 1, i32 1) - %ptrptr2 = bitcast i32* %a to i8* - store i8* %ptrptr2, i8** %ptr, align 8 - %0 = load i8*, i8** %ptr, align 8 - call void @llvm.prefetch.p0i8(i8* %0, i32 0, i32 3, i32 1) diff --git a/test/test_suite14/builtins/reduce_arithmetics.c3t b/test/test_suite14/builtins/reduce_arithmetics.c3t deleted file mode 100644 index 49601fb29..000000000 --- a/test/test_suite14/builtins/reduce_arithmetics.c3t +++ /dev/null @@ -1,43 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn void main() -{ - int a; - io::printfn("%s", $$pow_int(double[<2>] { 23.3, 2.1 }, 3)); - io::printfn("%s", $$reduce_add(int[<2>] { 3, 10 })); - io::printfn("%s", $$reduce_fadd(double[<2>] { 3, 10 }, -0.0)); - io::printfn("%s", $$reduce_fadd(double[<2>] { 3, 10 }, 3.2)); - io::printfn("%s", $$reduce_mul(int[<2>] { 3, 10 })); - io::printfn("%s", $$reduce_fmul(double[<2>] { 3, 10 }, 3.4)); - io::printfn("%s", $$reduce_and(int[<2>] { 3, 11 })); - io::printfn("%s", $$reduce_or(int[<2>] { 3, 10 })); - io::printfn("%s", $$reduce_xor(int[<2>] { 3, 10 })); - io::printfn("%s", $$reduce_max(double[<2>] { 23.2, 23.3 })); - io::printfn("%s", $$reduce_max(int[<2>] { -23, 32 })); - io::printfn("%s", $$reduce_max(char[<2>] { 4, 253 })); - io::printfn("%s", $$reduce_min(double[<2>] { 23.2, 23.3 })); - io::printfn("%s", $$reduce_min(int[<2>] { -23, 32 })); - io::printfn("%s", $$reduce_min(char[<2>] { 4, 253 })); - -} - -/* #expect: test.ll - - - call <2 x double> @llvm.powi.v2f64.i32(<2 x double> , i32 3) - call i32 @llvm.vector.reduce.add.v2i32(<2 x i32> ) - call double @llvm.vector.reduce.fadd.v2f64(double -0.000000e+00, <2 x double> ) - call double @llvm.vector.reduce.fadd.v2f64(double 3.200000e+00, <2 x double> ) - call i32 @llvm.vector.reduce.mul.v2i32(<2 x i32> ) - call double @llvm.vector.reduce.fmul.v2f64(double 3.400000e+00, <2 x double> ) - call i32 @llvm.vector.reduce.and.v2i32(<2 x i32> ) - call i32 @llvm.vector.reduce.or.v2i32(<2 x i32> ) - call i32 @llvm.vector.reduce.xor.v2i32(<2 x i32> ) - call double @llvm.vector.reduce.fmax.v2f64(<2 x double> ) - call i32 @llvm.vector.reduce.smax.v2i32(<2 x i32> ) - call i8 @llvm.vector.reduce.umax.v2i8(<2 x i8> ) - call double @llvm.vector.reduce.fmin.v2f64(<2 x double> ) - call i32 @llvm.vector.reduce.smin.v2i32(<2 x i32> ) - call i8 @llvm.vector.reduce.umin.v2i8(<2 x i8> ) diff --git a/test/test_suite14/builtins/reverse_builtin.c3t b/test/test_suite14/builtins/reverse_builtin.c3t deleted file mode 100644 index effef43d0..000000000 --- a/test/test_suite14/builtins/reverse_builtin.c3t +++ /dev/null @@ -1,14 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; - -fn void main() -{ - int[<4>] a = { 1, -3, 5, -7 }; - io::printfn("%s", $$reverse(a)); -} - -/* #expect: test.ll - - %reverse = shufflevector <4 x i32> %0, <4 x i32> poison, <4 x i32> \ No newline at end of file diff --git a/test/test_suite14/builtins/rounding_builtins.c3t b/test/test_suite14/builtins/rounding_builtins.c3t deleted file mode 100644 index 593c7ec52..000000000 --- a/test/test_suite14/builtins/rounding_builtins.c3t +++ /dev/null @@ -1,48 +0,0 @@ -// #target: macos-x64 -module test; - -fn void main() -{ - double d = 1.2345; - - double d1 = $$ceil(d); - double d2 = $$floor(d); -// double d3 = $$llrint(d); -// double d4 = $$llround(d); -// double d5 = $$lrint(d); -// double d6 = $$lround(d); - double d7 = $$nearbyint(d); - double d8 = $$rint(d); - double d9 = $$round(d); - double d10 = $$roundeven(d); - - double[<2>] vd = { 1.2345, 0.6789 }; - - double[<2>] vd1 = $$ceil(vd); - double[<2>] vd2 = $$floor(vd); -// double[<2>] vd3 = $$llrint(vd); -// double[<2>] vd4 = $$llround(vd); -// double[<2>] vd5 = $$lrint(vd); -// double[<2>] vd6 = $$lround(vd); - double[<2>] vd7 = $$nearbyint(vd); - double[<2>] vd8 = $$rint(vd); - double[<2>] vd9 = $$round(vd); - double[<2>] vd10 = $$roundeven(vd); - - return; -} - -// #expect: test.ll - - %1 = call double @llvm.ceil.f64(double %0) - %3 = call double @llvm.floor.f64(double %2) - %5 = call double @llvm.nearbyint.f64(double %4) - %7 = call double @llvm.rint.f64(double %6) - %9 = call double @llvm.round.f64(double %8) - %11 = call double @llvm.roundeven.f64(double %10) - %13 = call <2 x double> @llvm.ceil.v2f64(<2 x double> %12) - %15 = call <2 x double> @llvm.floor.v2f64(<2 x double> %14) - %17 = call <2 x double> @llvm.nearbyint.v2f64(<2 x double> %16) - %19 = call <2 x double> @llvm.rint.v2f64(<2 x double> %18) - %21 = call <2 x double> @llvm.round.v2f64(<2 x double> %20) - %23 = call <2 x double> @llvm.roundeven.v2f64(<2 x double> %22) diff --git a/test/test_suite14/builtins/sat_builtins.c3t b/test/test_suite14/builtins/sat_builtins.c3t deleted file mode 100644 index 4a10937ee..000000000 --- a/test/test_suite14/builtins/sat_builtins.c3t +++ /dev/null @@ -1,38 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; - -fn void main() -{ - char a = 123; - char b = 222; - io::printfn("%s %s", $$sat_add(a, b), $$sat_add((ichar)a, (ichar)30)); - io::printfn("%s %s", $$sat_sub(a, b), $$sat_sub((ichar)-120, (ichar)10)); - b = 3; - io::printfn("%s %s", $$sat_shl(a, b), $$sat_shl((ichar)a, (ichar)1)); - b = 222; - char[<2>] x = { 123, 222 }; - char[<2>] y = { 143, 50 }; - ichar[<2>] z = { 120, -120 }; - ichar[<2>] w = { -44, 30 }; - io::printfn("%s %s", $$sat_add(x, y), $$sat_add(z, z)); - io::printfn("%s %s", $$sat_sub(x, y), $$sat_sub(w, z)); - io::printfn("%s %s", $$sat_shl(x, char[<2>] { 1, 1 }), $$sat_shl(z, ichar[<2>] { 1, 1 })); -} - -/* #expect: test.ll - - - call i8 @llvm.uadd.sat.i8 - call i8 @llvm.sadd.sat.i8 - call i8 @llvm.usub.sat.i8 - call i8 @llvm.ssub.sat.i8 - call i8 @llvm.ushl.sat.i8 - call i8 @llvm.sshl.sat.i8 - call <2 x i8> @llvm.uadd.sat.v2i8 - call <2 x i8> @llvm.sadd.sat.v2i8 - call <2 x i8> @llvm.usub.sat.v2i8 - call <2 x i8> @llvm.ssub.sat.v2i8 - call <2 x i8> @llvm.ushl.sat.v2i8 - call <2 x i8> @llvm.sshl.sat.v2i8 diff --git a/test/test_suite14/builtins/shufflevector.c3t b/test/test_suite14/builtins/shufflevector.c3t deleted file mode 100644 index 725a336eb..000000000 --- a/test/test_suite14/builtins/shufflevector.c3t +++ /dev/null @@ -1,101 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; - -struct Matrix2x2 -{ - union - { - struct - { - float m00, m01; - float m10, m11; - } - struct - { - float[<2>] m0; - float[<2>] m1; - } - float[<4>] m; - } -} - -fn float[<2>] apply1(Matrix2x2* mat, float[<2>] vec) -{ - return float[<2>] { - mat.m00 * vec[0] + mat.m01 * vec[1], - mat.m10 * vec[0] + mat.m11 * vec[1], - }; -} - -fn float[<2>] apply2(Matrix2x2* mat, float[<2>] vec) -{ - return float[<2>] { - mat.m0[0] * vec[0] + mat.m0[1] * vec[1], - mat.m1[0] * vec[0] + mat.m1[1] * vec[1], - }; -} - -fn float[<2>] apply3(Matrix2x2* mat, float[<2>] vec) -{ - float[<2>] a = $$swizzle2(mat.m0, mat.m1, 0, 3); - float[<2>] b = $$swizzle2(mat.m0, mat.m1, 1, 2); - float[<2>] flip = $$swizzle(vec, 1, 0); - return a * vec + b * flip; -} - - -fn void main() -{ - Matrix2x2 a = { 1, -3, 5, -7 }; - io::printfn("1: %s", apply1(&a, float[<2>] { 11, 13 })); - io::printfn("2: %s", apply2(&a, float[<2>] { 11, 13 })); - io::printfn("3: %s", apply3(&a, float[<2>] { 11, 13 })); -} - -/* #expect: test.ll - -define double @test_apply3(%Matrix2x2* %0, double %1) #0 { -entry: - %vec = alloca <2 x float>, align 8 - %a = alloca <2 x float>, align 8 - %b = alloca <2 x float>, align 8 - %flip = alloca <2 x float>, align 8 - %taddr = alloca <2 x float>, align 8 - %2 = bitcast <2 x float>* %vec to double* - store double %1, double* %2, align 8 - %3 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %0, i32 0, i32 0 - %4 = bitcast %.anon* %3 to %.anon.1* - %5 = getelementptr inbounds %.anon.1, %.anon.1* %4, i32 0, i32 0 - %6 = load <2 x float>, <2 x float>* %5, align 16 - %7 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %0, i32 0, i32 0 - %8 = bitcast %.anon* %7 to %.anon.1* - %9 = getelementptr inbounds %.anon.1, %.anon.1* %8, i32 0, i32 1 - %10 = load <2 x float>, <2 x float>* %9, align 8 - %shuffle = shufflevector <2 x float> %6, <2 x float> %10, <2 x i32> - store <2 x float> %shuffle, <2 x float>* %a, align 8 - %11 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %0, i32 0, i32 0 - %12 = bitcast %.anon* %11 to %.anon.1* - %13 = getelementptr inbounds %.anon.1, %.anon.1* %12, i32 0, i32 0 - %14 = load <2 x float>, <2 x float>* %13, align 16 - %15 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %0, i32 0, i32 0 - %16 = bitcast %.anon* %15 to %.anon.1* - %17 = getelementptr inbounds %.anon.1, %.anon.1* %16, i32 0, i32 1 - %18 = load <2 x float>, <2 x float>* %17, align 8 - %shuffle1 = shufflevector <2 x float> %14, <2 x float> %18, <2 x i32> - store <2 x float> %shuffle1, <2 x float>* %b, align 8 - %19 = load <2 x float>, <2 x float>* %vec, align 8 - %shuffle2 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> - store <2 x float> %shuffle2, <2 x float>* %flip, align 8 - %20 = load <2 x float>, <2 x float>* %a, align 8 - %21 = load <2 x float>, <2 x float>* %vec, align 8 - %fmul = fmul <2 x float> %20, %21 - %22 = load <2 x float>, <2 x float>* %b, align 8 - %23 = load <2 x float>, <2 x float>* %flip, align 8 - %fmul3 = fmul <2 x float> %22, %23 - %fadd = fadd <2 x float> %fmul, %fmul3 - store <2 x float> %fadd, <2 x float>* %taddr, align 8 - %24 = bitcast <2 x float>* %taddr to double* - %25 = load double, double* %24, align 8 - ret double %25 \ No newline at end of file diff --git a/test/test_suite14/builtins/simple_builtins.c3t b/test/test_suite14/builtins/simple_builtins.c3t deleted file mode 100644 index 913250933..000000000 --- a/test/test_suite14/builtins/simple_builtins.c3t +++ /dev/null @@ -1,62 +0,0 @@ -// #target: macos-x64 -module foo; - -fn int foo(double b) -{ - double d = $$ceil(b); - double e = $$max(1.0, d); - double f = $$fma(d, 2.0, 3.0); - double m = $$fmuladd(d, 2.0, 3.0); - int xeb = 13; - - int[3] abcd; - int sy = $$volatile_load(&xeb); - $$volatile_store(&xeb, sy + 1); - $$volatile_store(&abcd[2], sy + 2); - sy = $$volatile_load(&abcd[2]); - return 1; -} - -/* #expect: foo.ll - -define i32 @foo_foo(double %0) #0 { -entry: - %d = alloca double, align 8 - %e = alloca double, align 8 - %f = alloca double, align 8 - %m = alloca double, align 8 - %xeb = alloca i32, align 4 - %abcd = alloca [3 x i32], align 4 - %sy = alloca i32, align 4 - %1 = call double @llvm.ceil.f64(double %0) - store double %1, double* %d, align 8 - %2 = load double, double* %d, align 8 - %3 = call double @llvm.maxnum.f64(double 1.000000e+00, double %2) - store double %3, double* %e, align 8 - %4 = load double, double* %d, align 8 - %5 = call double @llvm.fma.f64(double %4, double 2.000000e+00, double 3.000000e+00) - store double %5, double* %f, align 8 - %6 = load double, double* %d, align 8 - %7 = call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double 3.000000e+00) - store double %7, double* %m, align 8 - store i32 13, i32* %xeb, align 4 - %8 = getelementptr inbounds [3 x i32], [3 x i32]* %abcd, i64 0, i64 0 - store i32 0, i32* %8, align 4 - %9 = getelementptr inbounds [3 x i32], [3 x i32]* %abcd, i64 0, i64 1 - store i32 0, i32* %9, align 4 - %10 = getelementptr inbounds [3 x i32], [3 x i32]* %abcd, i64 0, i64 2 - store i32 0, i32* %10, align 4 - %11 = load volatile i32, i32* %xeb, align 4 - store i32 %11, i32* %sy, align 4 - %12 = load i32, i32* %sy, align 4 - %add = add i32 %12, 1 - store volatile i32 %add, i32* %xeb, align 4 - %13 = getelementptr inbounds [3 x i32], [3 x i32]* %abcd, i64 0, i64 2 - %14 = load i32, i32* %sy, align 4 - %add1 = add i32 %14, 2 - store volatile i32 %add1, i32* %13, align 4 - %15 = getelementptr inbounds [3 x i32], [3 x i32]* %abcd, i64 0, i64 2 - %16 = load volatile i32, i32* %15, align 4 - store i32 %16, i32* %sy, align 4 - ret i32 1 -} diff --git a/test/test_suite14/cast/cast_from_ptr.c3t b/test/test_suite14/cast/cast_from_ptr.c3t deleted file mode 100644 index 5fd784a32..000000000 --- a/test/test_suite14/cast/cast_from_ptr.c3t +++ /dev/null @@ -1,18 +0,0 @@ -module test; - -fn void tester() -{ - int *x; - short y = (short)((uptr)(x)); - uptr z = (uptr)((short)((uptr)(x))); -} - -/* #expect: test.ll - - %0 = load i32*, i32** %x, align 8 - %ptrxi = ptrtoint i32* %0 to i16 - store i16 %ptrxi, i16* %y, align 2 - %1 = load i32*, i32** %x, align 8 - %ptrxi1 = ptrtoint i32* %1 to i16 - %siuiext = sext i16 %ptrxi1 to i64 - store i64 %siuiext, i64* %z, align 8 diff --git a/test/test_suite14/cast/cast_ok.c3 b/test/test_suite14/cast/cast_ok.c3 deleted file mode 100644 index 8ce12894c..000000000 --- a/test/test_suite14/cast/cast_ok.c3 +++ /dev/null @@ -1,11 +0,0 @@ -struct Foo { int a; } - -fn void test4() -{ - int x = (int)(32); -} - -fn void test5() -{ - Foo x = (Foo)(Foo{32}); -} \ No newline at end of file diff --git a/test/test_suite14/cast/cast_parse_fails.c3 b/test/test_suite14/cast/cast_parse_fails.c3 deleted file mode 100644 index e52fbad02..000000000 --- a/test/test_suite14/cast/cast_parse_fails.c3 +++ /dev/null @@ -1,13 +0,0 @@ -struct Foo { int a; } - -fn void test2() -{ - int x = int{ 32 }; // #error: 'int' cannot use compound literal initialization, did you intend to use a cast -} - -fn void test3() -{ - int x = int(32); // #error: A type cannot be followed by (), if you intended a cast, use (type)(expression) -} - - diff --git a/test/test_suite14/cast/cast_parse_fails2.c3 b/test/test_suite14/cast/cast_parse_fails2.c3 deleted file mode 100644 index 020eeb416..000000000 --- a/test/test_suite14/cast/cast_parse_fails2.c3 +++ /dev/null @@ -1,8 +0,0 @@ - -struct Foo { int a; } - -fn void test1() -{ - (Foo)({ 32 }); - Foo({ 32 }); // #error: A type cannot be followed by (), if you intended a cast, use (type)(expression) -} \ No newline at end of file diff --git a/test/test_suite14/cast/cast_struct.c3 b/test/test_suite14/cast/cast_struct.c3 deleted file mode 100644 index 35c81a6db..000000000 --- a/test/test_suite14/cast/cast_struct.c3 +++ /dev/null @@ -1,37 +0,0 @@ -struct Foo -{ - int a; - float b; -} - -struct Bar -{ - int b; - float c; -} - -struct Baz -{ - int b; - int c; -} - -struct BazTwo -{ - int[1] d; - int e; -} - -fn void test() -{ - Foo x; - Bar y = (Bar)(x); // #error: The cast 'Foo' to 'Bar' is not allowed - - Baz z; - int[2] w = (int[2])(z); // #error: The cast 'Baz' to 'int[2]' is not allowed - z = (Baz)(w); - BazTwo v = (BazTwo)(z); // #error: The cast 'Baz' to 'BazTwo' is not allowed - v = (BazTwo)(w); - z = (Baz)(v); - w = (int[2])(v); -} diff --git a/test/test_suite14/cast/cast_struct_fails.c3 b/test/test_suite14/cast/cast_struct_fails.c3 deleted file mode 100644 index 244ae1cfc..000000000 --- a/test/test_suite14/cast/cast_struct_fails.c3 +++ /dev/null @@ -1,35 +0,0 @@ -struct Foo -{ - int a; - float b; -} - -struct Bar -{ - int b; - float c; -} - -struct Baz -{ - int b; - int c; -} - -struct BazTwo -{ - int[2] d; - int e; -} - -fn void test1() -{ - Foo x; - Bar z = (Baz)(x); // #error: cast 'Foo' to 'Baz' -} -fn void test2() -{ - Baz x; - BazTwo z = (BazTwo)(x); // #error: cast 'Baz' to 'BazTwo' -} - diff --git a/test/test_suite14/cast/cast_to_failable.c3 b/test/test_suite14/cast/cast_to_failable.c3 deleted file mode 100644 index 663cb3114..000000000 --- a/test/test_suite14/cast/cast_to_failable.c3 +++ /dev/null @@ -1,12 +0,0 @@ -fault MyErr -{ - FOO -} - -fn void test() -{ - int! x; - int! d = ($typeof(MyErr.FOO!))(x); // #error: Casting to an optional type is not allowed -} - - diff --git a/test/test_suite14/cast/implicit_infer_len_cast.c3t b/test/test_suite14/cast/implicit_infer_len_cast.c3t deleted file mode 100644 index 88c57eb8f..000000000 --- a/test/test_suite14/cast/implicit_infer_len_cast.c3t +++ /dev/null @@ -1,66 +0,0 @@ -// #target: macos-x64 -module test; - -macro int test(int[*][*]* y) -{ - $typeof(*y) z = *y; - return z[1][1]; -} -fn void main() -{ - int[2][*] x = { { 2, 3}, { 5, 6 }}; - int[<2>][*] y = { { 1, 3 }}; - int[<*>][*] z = y; - int[<2>][1] w = z; - int[<2>][] aa = { { 1, 3 }}; - int[][*] bb = { { 1, 3 } }; - test(&x); -} -/* #expect: test.ll - - %x = alloca [2 x [2 x i32]], align 16 - %y = alloca [1 x <2 x i32>], align 8 - %z = alloca [1 x <2 x i32>], align 8 - %w = alloca [1 x <2 x i32>], align 8 - %aa = alloca %"int[<2>][]", align 8 - %literal = alloca [1 x <2 x i32>], align 8 - %bb = alloca [1 x %"int[]"], align 16 - %literal1 = alloca [2 x i32], align 4 - %y2 = alloca [2 x [2 x i32]]*, align 8 - %z3 = alloca [2 x [2 x i32]], align 16 - %0 = bitcast [2 x [2 x i32]]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %0, i8* align 16 bitcast ([2 x [2 x i32]]* @.__const to i8*), i32 16, i1 false) - %1 = bitcast [1 x <2 x i32>]* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %1, i8* align 8 bitcast ([1 x <2 x i32>]* @.__const.1 to i8*), i32 8, i1 false) - %2 = bitcast [1 x <2 x i32>]* %z to i8* - %3 = bitcast [1 x <2 x i32>]* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %2, i8* align 8 %3, i32 8, i1 false) - %4 = bitcast [1 x <2 x i32>]* %w to i8* - %5 = bitcast [1 x <2 x i32>]* %z to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 8, i1 false) - %6 = getelementptr inbounds [1 x <2 x i32>], [1 x <2 x i32>]* %literal, i64 0, i64 0 - %7 = getelementptr inbounds <2 x i32>, <2 x i32>* %6, i64 0, i64 0 - store i32 1, i32* %7, align 4 - %8 = getelementptr inbounds <2 x i32>, <2 x i32>* %6, i64 0, i64 1 - store i32 3, i32* %8, align 4 - %9 = bitcast [1 x <2 x i32>]* %literal to <2 x i32>* - %10 = insertvalue %"int[<2>][]" undef, <2 x i32>* %9, 0 - %11 = insertvalue %"int[<2>][]" %10, i64 1, 1 - store %"int[<2>][]" %11, %"int[<2>][]"* %aa, align 8 - %12 = getelementptr inbounds [1 x %"int[]"], [1 x %"int[]"]* %bb, i64 0, i64 0 - %13 = getelementptr inbounds [2 x i32], [2 x i32]* %literal1, i64 0, i64 0 - store i32 1, i32* %13, align 4 - %14 = getelementptr inbounds [2 x i32], [2 x i32]* %literal1, i64 0, i64 1 - store i32 3, i32* %14, align 4 - %15 = bitcast [2 x i32]* %literal1 to i32* - %16 = insertvalue %"int[]" undef, i32* %15, 0 - %17 = insertvalue %"int[]" %16, i64 2, 1 - store %"int[]" %17, %"int[]"* %12, align 16 - store [2 x [2 x i32]]* %x, [2 x [2 x i32]]** %y2, align 8 - %18 = load [2 x [2 x i32]]*, [2 x [2 x i32]]** %y2, align 8 - %19 = bitcast [2 x [2 x i32]]* %z3 to i8* - %20 = bitcast [2 x [2 x i32]]* %18 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %19, i8* align 4 %20, i32 16, i1 false) - %21 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %z3, i64 0, i64 1 - %22 = getelementptr inbounds [2 x i32], [2 x i32]* %21, i64 0, i64 1 - ret void diff --git a/test/test_suite14/cast/top_down_cast_fails.c3 b/test/test_suite14/cast/top_down_cast_fails.c3 deleted file mode 100644 index 2cd1e3938..000000000 --- a/test/test_suite14/cast/top_down_cast_fails.c3 +++ /dev/null @@ -1,29 +0,0 @@ -fn void test() -{ - int x; - int y; - long z = x * y; - z = x * y + z; // #error: 'long' - z = x * y + x; // #error: 'long' - z = x / y; - z = x + y; - z = x - y; - z = x % y; - z = x / y + z; // #error: 'long' - z = x + y + z; // #error: 'long' - z = x - y + z; // #error: 'long' - z = x % y + z; // #error: 'long' - z = x / y + x; // #error: 'long' - z = x + y + x; // #error: 'long' - z = x - y + x; // #error: 'long' - z = x % y + x; // #error: 'long' - - z = x << y + x; // #error: 'long' - z = x >> y + x; // #error: 'long' - z = x << y + z; // #error: 'long' - z = x >> y + z; // #error: 'long' - z = ~x + x; // #error: 'long' - z = ~x + z; // #error: 'long' - z = -x + z; // #error: 'long' - z = x + z; -} \ No newline at end of file diff --git a/test/test_suite14/cast/top_down_casts.c3t b/test/test_suite14/cast/top_down_casts.c3t deleted file mode 100644 index ac882bf5a..000000000 --- a/test/test_suite14/cast/top_down_casts.c3t +++ /dev/null @@ -1,101 +0,0 @@ -fn void test() -{ - int x; - int y; - long z = x * y; - z = x / y; - z = x + y; - z = x - y; - z = x % y; - z = x << y; - z = x >> y; - z = ~x; - z = -x; - int! w; - z = w ?? 1; -} - -/* #expect: top_down_casts.ll - -define void @top_down_casts_test() #0 { -entry: - %x = alloca i32, align 4 - %y = alloca i32, align 4 - %z = alloca i64, align 8 - %w = alloca i32, align 4 - %w.f = alloca i64, align 8 - store i32 0, i32* %x, align 4 - store i32 0, i32* %y, align 4 - %0 = load i32, i32* %x, align 4 - %sisiext = sext i32 %0 to i64 - %1 = load i32, i32* %y, align 4 - %sisiext1 = sext i32 %1 to i64 - %mul = mul i64 %sisiext, %sisiext1 - store i64 %mul, i64* %z, align 8 - %2 = load i32, i32* %x, align 4 - %sisiext2 = sext i32 %2 to i64 - %3 = load i32, i32* %y, align 4 - %sisiext3 = sext i32 %3 to i64 - %sdiv = sdiv i64 %sisiext2, %sisiext3 - store i64 %sdiv, i64* %z, align 8 - %4 = load i32, i32* %x, align 4 - %sisiext4 = sext i32 %4 to i64 - %5 = load i32, i32* %y, align 4 - %sisiext5 = sext i32 %5 to i64 - %add = add i64 %sisiext4, %sisiext5 - store i64 %add, i64* %z, align 8 - %6 = load i32, i32* %x, align 4 - %sisiext6 = sext i32 %6 to i64 - %7 = load i32, i32* %y, align 4 - %sisiext7 = sext i32 %7 to i64 - %sub = sub i64 %sisiext6, %sisiext7 - store i64 %sub, i64* %z, align 8 - %8 = load i32, i32* %x, align 4 - %sisiext8 = sext i32 %8 to i64 - %9 = load i32, i32* %y, align 4 - %sisiext9 = sext i32 %9 to i64 - %smod = srem i64 %sisiext8, %sisiext9 - store i64 %smod, i64* %z, align 8 - %10 = load i32, i32* %x, align 4 - %sisiext10 = sext i32 %10 to i64 - %11 = load i32, i32* %y, align 4 - %zext = zext i32 %11 to i64 - %shl = shl i64 %sisiext10, %zext - %12 = freeze i64 %shl - store i64 %12, i64* %z, align 8 - %13 = load i32, i32* %x, align 4 - %sisiext11 = sext i32 %13 to i64 - %14 = load i32, i32* %y, align 4 - %zext12 = zext i32 %14 to i64 - %ashr = ashr i64 %sisiext11, %zext12 - %15 = freeze i64 %ashr - store i64 %15, i64* %z, align 8 - %16 = load i32, i32* %x, align 4 - %sisiext13 = sext i32 %16 to i64 - %bnot = xor i64 %sisiext13, -1 - store i64 %bnot, i64* %z, align 8 - %17 = load i32, i32* %x, align 4 - %sisiext14 = sext i32 %17 to i64 - %18 = load i32, i32* %x, align 4 - %sisiext15 = sext i32 %18 to i64 - %neg = sub i64 0, %sisiext15 - store i64 %neg, i64* %z, align 8 - store i64 0, i64* %w.f, align 8 - store i32 0, i32* %w, align 4 - %optval = load i64, i64* %w.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %else_block - -after_check: ; preds = %entry - %19 = load i32, i32* %w, align 4 - %sisiext16 = sext i32 %19 to i64 - br label %phi_block - -else_block: ; preds = %entry - br label %phi_block - -phi_block: ; preds = %else_block, %after_check - %val = phi i64 [ %sisiext16, %after_check ], [ 1, %else_block ] - store i64 %val, i64* %z, align 8 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/clang/2002-01_02.c3t b/test/test_suite14/clang/2002-01_02.c3t deleted file mode 100644 index f04926b66..000000000 --- a/test/test_suite14/clang/2002-01_02.c3t +++ /dev/null @@ -1,376 +0,0 @@ -// #target: macos-x64 -module test; - -struct Foo { int x, y; } -Foo[10] array; - -fn void foo() {} - -fn void *dlclose(void*); - -fn void ap_os_dso_unload(void *handle) -{ - dlclose(handle); - return; -} - -extern fn void foo2(int, double, float); - -fn void bar(int x) { - foo2(x, x ? 1.0 : 12.5, 1.0f); -} - -extern fn int tolower(int); - -fn char *rangematch(char *pattern, int teste, int c) { - - if ((c <= teste) | (tolower(c) <= tolower((char)(teste)))) return (char*)(0); - - return pattern; -} - -struct Foostruct { - short x; -} - -extern fn int foo3(Foostruct ic); - -fn void teste2() { - Foostruct xqic; - foo3(xqic); -} - -struct Vertex -{ - float a, b, c; -} -struct Edge_rec -{ - Vertex *v; - Edge_rec *next; - int wasseen; - int more_data; -} - -define QuadEdge = Edge_rec*; - -struct EdgePair { - QuadEdge left, right; -} - -struct EdgeStack { - int ptr; - QuadEdge *elts; - int stack_size; -} - -fn int do_merge(QuadEdge ldo, QuadEdge rdo) { - int lvalid; - QuadEdge basel; - QuadEdge rcand; - while (1) { - if (!lvalid) { - return (int)((iptr)(basel.next)); - } - } - return 1; -} - -fn int test(int x) { - return x; -} - -fn void abc(int *x); -fn int def(int y, int z) { - abc(&z); - return y; -} - -struct Test { short x, x2; int y, z; } - -fn int testing(Test *a) { - return a.x2+a.y; -} - -fn int test2(int x, Test a, int y) { - return x+y+a.x2+a.y; -} -fn int test3(Test a, Test b) { - return a.x2+a.y+b.y+b.z; -} - -fn Test test4(Test a) { - return a; -} - -fn int test6() { - int[200] b; - return b[4]; -} - -struct STest2 { int x; short[4] y; double z; } - -fn STest2 test7(STest2 x) { - return x; -} - -extern fn int printf(char * format, ...); - -fn int main2() { - long v = 123455678902i64; - printf("%lld\n", v); - return 1; -} - -double afoo = 17; -double abar = 12.0; -float axx = 12.0f; - -char*[*] procnames = { - "EXIT" -}; - -void *[*] data = { &afoo, &abar, &axx }; - -/* #expect: test.ll - -%Foo = type { i32, i32 } -%Foostruct = type { i16 } -%Edge_rec = type { %Vertex*, %Edge_rec*, i32, i32 } -%Vertex = type { float, float, float } -%Test = type { i16, i16, i32, i32 } -%STest2 = type { i32, [4 x i16], double } - -@test_array = local_unnamed_addr global [10 x %Foo] zeroinitializer, align 16 -@test_afoo = global double 1.700000e+01, align 8 -@test_abar = global double 1.200000e+01, align 8 -@test_axx = global float 1.200000e+01, align 4 -@.str = private unnamed_addr constant [5 x i8] c"EXIT\00", align 1 -@test_procnames = local_unnamed_addr global [1 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0)], align 8 -@test_data = local_unnamed_addr global [3 x i8*] [i8* bitcast (double* @test_afoo to i8*), i8* bitcast (double* @test_abar to i8*), i8* bitcast (float* @test_axx to i8*)], align 16 -@.str.6 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1 - -; Function Attrs: nounwind -define void @test_foo() #0 { -entry: - ret void -} - -; Function Attrs: nounwind -declare i8* @test_dlclose(i8*) #0 - -; Function Attrs: nounwind -define void @test_ap_os_dso_unload(i8* %0) #0 { -entry: - %1 = call i8* @test_dlclose(i8* %0) - ret void -} - -; Function Attrs: nounwind -declare void @foo2(i32, double, float) #0 - -; Function Attrs: nounwind -define void @test_bar(i32 %0) #0 { -entry: - %intbool = icmp ne i32 %0, 0 - %ternary = select i1 %intbool, double 1.000000e+00, double 1.250000e+01 - call void @foo2(i32 %0, double %ternary, float 1.000000e+00) - ret void -} - -; Function Attrs: nounwind -declare i32 @tolower(i32) #0 - -; Function Attrs: nounwind -define i8* @test_rangematch(i8* %0, i32 %1, i32 %2) #0 { -entry: - %le = icmp sle i32 %2, %1 - %3 = call i32 @tolower(i32 %2) - %siuitrunc = trunc i32 %1 to i8 - %uisiext = zext i8 %siuitrunc to i32 - %4 = call i32 @tolower(i32 %uisiext) - %le1 = icmp sle i32 %3, %4 - %or = or i1 %le, %le1 - br i1 %or, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i8* null - -if.exit: ; preds = %entry - ret i8* %0 -} - -; Function Attrs: nounwind -declare i32 @foo3(i16) #0 - -; Function Attrs: nounwind -define void @test_teste2() #0 { -entry: - %xqic = alloca %Foostruct, align 2 - %0 = bitcast %Foostruct* %xqic to i16* - store i16 0, i16* %0, align 2 - %1 = getelementptr inbounds %Foostruct, %Foostruct* %xqic, i32 0, i32 0 - %2 = load i16, i16* %1, align 2 - %3 = call i32 @foo3(i16 %2) - ret void -} - -; Function Attrs: nounwind -define i32 @test_do_merge(%Edge_rec* %0, %Edge_rec* %1) #0 { -entry: - %lvalid = alloca i32, align 4 - %basel = alloca %Edge_rec*, align 8 - %rcand = alloca %Edge_rec*, align 8 - store i32 0, i32* %lvalid, align 4 - store %Edge_rec* null, %Edge_rec** %basel, align 8 - store %Edge_rec* null, %Edge_rec** %rcand, align 8 - br label %loop.body - -loop.body: ; preds = %if.exit, %entry - %2 = load i32, i32* %lvalid, align 4 - %not = icmp eq i32 %2, 0 - br i1 %not, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - %3 = load %Edge_rec*, %Edge_rec** %basel, align 8 - %4 = getelementptr inbounds %Edge_rec, %Edge_rec* %3, i32 0, i32 1 - %5 = load %Edge_rec*, %Edge_rec** %4, align 8 - %ptrxi = ptrtoint %Edge_rec* %5 to i32 - ret i32 %ptrxi - -if.exit: ; preds = %loop.body - br label %loop.body - -loop.exit: ; No predecessors! - ret i32 1 -} - -; Function Attrs: nounwind -define i32 @test_test(i32 %0) #0 { -entry: - ret i32 %0 -} - -; Function Attrs: nounwind -declare void @test_abc(i32*) #0 - -; Function Attrs: nounwind -define i32 @test_def(i32 %0, i32 %1) #0 { -entry: - %z = alloca i32, align 4 - store i32 %1, i32* %z, align 4 - call void @test_abc(i32* %z) - ret i32 %0 -} - -; Function Attrs: nounwind -define i32 @test_testing(%Test* %0) #0 { -entry: - %1 = getelementptr inbounds %Test, %Test* %0, i32 0, i32 1 - %2 = load i16, i16* %1, align 2 - %sisiext = sext i16 %2 to i32 - %3 = getelementptr inbounds %Test, %Test* %0, i32 0, i32 2 - %4 = load i32, i32* %3, align 4 - %add = add i32 %sisiext, %4 - ret i32 %add -} - -; Function Attrs: nounwind -define i32 @test_test2(i32 %0, i64 %1, i32 %2, i32 %3) #0 { -entry: - %4 = alloca { i64, i32 }, align 8 - %a = bitcast { i64, i32 }* %4 to %Test* - %5 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %4, i32 0, i32 0 - store i64 %1, i64* %5, align 8 - %6 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %4, i32 0, i32 1 - store i32 %2, i32* %6, align 8 - %add = add i32 %0, %3 - %7 = getelementptr inbounds %Test, %Test* %a, i32 0, i32 1 - %8 = load i16, i16* %7, align 2 - %sisiext = sext i16 %8 to i32 - %add1 = add i32 %add, %sisiext - %9 = getelementptr inbounds %Test, %Test* %a, i32 0, i32 2 - %10 = load i32, i32* %9, align 4 - %add2 = add i32 %add1, %10 - ret i32 %add2 -} - -; Function Attrs: nounwind -define i32 @test_test3(i64 %0, i32 %1, i64 %2, i32 %3) #0 { -entry: - %4 = alloca { i64, i32 }, align 8 - %5 = alloca { i64, i32 }, align 8 - %a = bitcast { i64, i32 }* %4 to %Test* - %6 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %4, i32 0, i32 0 - store i64 %0, i64* %6, align 8 - %7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %4, i32 0, i32 1 - store i32 %1, i32* %7, align 8 - %b = bitcast { i64, i32 }* %5 to %Test* - %8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0 - store i64 %2, i64* %8, align 8 - %9 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1 - store i32 %3, i32* %9, align 8 - %10 = getelementptr inbounds %Test, %Test* %a, i32 0, i32 1 - %11 = load i16, i16* %10, align 2 - %sisiext = sext i16 %11 to i32 - %12 = getelementptr inbounds %Test, %Test* %a, i32 0, i32 2 - %13 = load i32, i32* %12, align 4 - %add = add i32 %sisiext, %13 - %14 = getelementptr inbounds %Test, %Test* %b, i32 0, i32 2 - %15 = load i32, i32* %14, align 4 - %add1 = add i32 %add, %15 - %16 = getelementptr inbounds %Test, %Test* %b, i32 0, i32 3 - %17 = load i32, i32* %16, align 8 - %add2 = add i32 %add1, %17 - ret i32 %add2 -} - -; Function Attrs: nounwind -define { i64, i32 } @test_test4(i64 %0, i32 %1) #0 { -entry: - %2 = alloca { i64, i32 }, align 8 - %tempcoerce = alloca { i64, i32 }, align 8 - %a = bitcast { i64, i32 }* %2 to %Test* - %3 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %2, i32 0, i32 0 - store i64 %0, i64* %3, align 8 - %4 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %2, i32 0, i32 1 - store i32 %1, i32* %4, align 8 - %5 = bitcast { i64, i32 }* %tempcoerce to i8* - %6 = bitcast %Test* %a to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 8 %6, i32 12, i1 false) - %7 = load { i64, i32 }, { i64, i32 }* %tempcoerce, align 8 - ret { i64, i32 } %7 -} - -; Function Attrs: nounwind -define i32 @test_test6() #0 { -entry: - %b = alloca [200 x i32], align 16 - %0 = bitcast [200 x i32]* %b to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %0, i8 0, i64 800, i1 false) - %1 = getelementptr inbounds [200 x i32], [200 x i32]* %b, i64 0, i64 4 - %2 = load i32, i32* %1, align 4 - ret i32 %2 -} - -; Function Attrs: nounwind -define void @test_test7(%STest2* noalias sret(%STest2) align 8 %0, %STest2* byval(%STest2) align 8 %1) #0 { -entry: - %2 = bitcast %STest2* %0 to i8* - %3 = bitcast %STest2* %1 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %2, i8* align 8 %3, i32 24, i1 false) - ret void -} - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define i32 @test_main2() #0 { -entry: - %v = alloca i64, align 8 - store i64 123455678902, i64* %v, align 8 - %0 = load i64, i64* %v, align 8 - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i64 %0) - ret i32 1 -} diff --git a/test/test_suite14/clang/2002-03.c3t b/test/test_suite14/clang/2002-03.c3t deleted file mode 100644 index 9cc3fba78..000000000 --- a/test/test_suite14/clang/2002-03.c3t +++ /dev/null @@ -1,96 +0,0 @@ -// #target: macos-x64 -module test; -fn int strcmp(char *s1, char *s2); - -fn int test(char *x) { - /* LLVM-GCC used to emit: - %.LC0 = internal global [3 x sbyte] c"\1F\FFFFFF8B\00" - */ - return strcmp(x, "\x1f\x8B"); -} - -int[10] a = { [0] = 0, [1] = 2 }; - -char[10] str = "x"; - -void*[5] arr = { [0] = null, [1] = null }; - -float[12] f = { [0] = 1.23f, [1] = 34.7f }; - -struct Test { int x; double y; } - -Test[10] array = { [0] = { 2, 12.0 }, [1] = { 3, 24.0 } }; - -int[4][4] b = { [0] = { 1, 2, 3, 4}, [1] = { [0] = 5, [1] = 6, [2] = 7 }, [2] = { [0] = 8, [1] = 9 } }; - -struct Connection { - long to; - char[10] type; - long length; -} - -Connection[3] link -= { {1, "link1", 10}, - {2, "link2", 20}, - {3, "link3", 30} }; - - -fn int trys(char *s, int x) -{ - int asa; - double val; - int lLS; - if (x) { - asa = lLS + asa; - } else { - } - return asa+(int)(val); -} - -fn char* foo() { - return "*** Word \"%s\" on line %d is not"; -} - -/* #expect: test.ll - -@test_a = local_unnamed_addr global { i32, i32, [8 x i32] } { i32 0, i32 2, [8 x i32] zeroinitializer }, align 16 -@test_str = local_unnamed_addr global [10 x i8] c"x\00\00\00\00\00\00\00\00\00", align 1 -@test_arr = local_unnamed_addr global { i8*, i8*, [3 x i8*] } zeroinitializer, align 16 -@test_f = local_unnamed_addr global { float, float, [10 x float] } { float 0x3FF3AE1480000000, float 0x40415999A0000000, [10 x float] zeroinitializer }, align 16 -@test_array = local_unnamed_addr global { %Test, %Test, [8 x %Test] } { %Test { i32 2, double 1.200000e+01 }, %Test { i32 3, double 2.400000e+01 }, [8 x %Test] zeroinitializer }, align 16 -@test_b = local_unnamed_addr global { [4 x i32], { i32, i32, i32, i32 }, { i32, i32, [2 x i32] }, [4 x i32] } { [4 x i32] [i32 1, i32 2, i32 3, i32 4], { i32, i32, i32, i32 } { i32 5, i32 6, i32 7, i32 0 }, { i32, i32, [2 x i32] } { i32 8, i32 9, [2 x i32] zeroinitializer }, [4 x i32] zeroinitializer }, align 16 -@test_link = local_unnamed_addr global [3 x %Connection] [%Connection { i64 1, [10 x i8] c"link1\00\00\00\00\00", i64 10 }, %Connection { i64 2, [10 x i8] c"link2\00\00\00\00\00", i64 20 }, %Connection { i64 3, [10 x i8] c"link3\00\00\00\00\00", i64 30 }], align 16 - -declare i32 @test_strcmp(i8*, i8*) #0 - -define i32 @test_test(i8* %0) #0 { -entry: - %1 = call i32 @test_strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0)) - ret i32 %1 -} - -define i32 @test_trys(i8* %0, i32 %1) #0 { -entry: - %asa = alloca i32, align 4 - %val = alloca double, align 8 - %lLS = alloca i32, align 4 - store i32 0, i32* %asa, align 4 - store double 0.000000e+00, double* %val, align 8 - store i32 0, i32* %lLS, align 4 - %intbool = icmp ne i32 %1, 0 - br i1 %intbool, label %if.then, label %if.exit - -if.then: ; preds = %entry - %2 = load i32, i32* %lLS, align 4 - %3 = load i32, i32* %asa, align 4 - %add = add i32 %2, %3 - store i32 %add, i32* %asa, align 4 - br label %if.exit - -if.exit: ; preds = %if.then, %entry - %4 = load i32, i32* %asa, align 4 - %5 = load double, double* %val, align 8 - %fpsi = fptosi double %5 to i32 - %add1 = add i32 %4, %fpsi - ret i32 %add1 -} diff --git a/test/test_suite14/clang/2002-04.c3t b/test/test_suite14/clang/2002-04.c3t deleted file mode 100644 index 4909eab1b..000000000 --- a/test/test_suite14/clang/2002-04.c3t +++ /dev/null @@ -1,179 +0,0 @@ -// #target: macos-x64 -module test; -extern fn int printf(char *, ...); -extern fn int foo(); - -fn int main2() { - while (foo()) { - switch (foo()) { - case 0: - case 1: - case 2: - case 3: - printf("3"); - nextcase; - case 4: printf("4"); nextcase; - case 5: - case 6: - default: - } - } - return 0; -} - -fn double test(uint x) -{ - double[30] student_t={0.0 , 12.706 , 4.303 , 3.182 , 2.776 , 2.571 , - 2.447 , 2.365 , 2.306 , 2.262 , 2.228 , - 2.201 , 2.179 , 2.160 , 2.145 , 2.131 , - 2.120 , 2.110 , 2.101 , 2.093 , 2.086 , - 2.080 , 2.074 , 2.069 , 2.064 , 2.060 , - 2.056 , 2.052 , 2.048 , 2.045 }; - return student_t[x]; -} - -struct St { - int i; - short s1, s2; -} - -extern fn St func_returning_struct(); - -fn void loop() { - func_returning_struct(); -} - -struct FooSt { - char p; - short q; - char r; - int x; - short y, z; - int q2; -} - -extern fn int testF(FooSt x, float); -extern fn int testE(char,short,char,int,int,float); -fn void test3(FooSt *x) { - x.q = 1; -} - -fn void test2(FooSt y) { - testE(y.p, y.q, y.r, y.x, y.y, 0.1f); - testF(y, 0.1f); - test2(y); - test3(&y); -} - -/* #expect: test.ll - - -define i32 @test_main2() #0 { -entry: - %switch = alloca i32, align 4 - br label %loop.cond - -loop.cond: ; preds = %switch.exit, %entry - %0 = call i32 @foo() - %intbool = icmp ne i32 %0, 0 - br i1 %intbool, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %1 = call i32 @foo() - store i32 %1, i32* %switch, align 4 - br label %switch.entry - -switch.entry: ; preds = %loop.body - %2 = load i32, i32* %switch, align 4 - switch i32 %2, label %switch.exit [ - i32 0, label %switch.case - i32 1, label %switch.case - i32 2, label %switch.case - i32 3, label %switch.case - i32 4, label %switch.case1 - i32 5, label %switch.exit - i32 6, label %switch.exit - ] - -switch.case: ; preds = %switch.entry, %switch.entry, %switch.entry, %switch.entry - %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)) - br label %switch.case1 - -switch.case1: ; preds = %switch.entry, %switch.case - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.entry, %switch.entry, %switch.case1, %switch.entry - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret i32 0 -} - -; Function Attrs: nounwind -define double @test_test(i32 %0) #0 { -entry: - %student_t = alloca [30 x double], align 16 - %1 = bitcast [30 x double]* %student_t to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %1, i8* align 16 bitcast ([30 x double]* @.__const to i8*), i32 240, i1 false) - %zext = zext i32 %0 to i64 - %2 = getelementptr inbounds [30 x double], [30 x double]* %student_t, i64 0, i64 %zext - %3 = load double, double* %2, align 8 - ret double %3 -} - -; Function Attrs: nounwind -declare i64 @func_returning_struct() #0 - -; Function Attrs: nounwind -define void @test_loop() #0 { -entry: - %result = alloca %St, align 4 - %0 = call i64 @func_returning_struct() - %1 = bitcast %St* %result to i64* - store i64 %0, i64* %1, align 4 - ret void -} - -; Function Attrs: nounwind -declare i32 @testF(%FooSt* byval(%FooSt) align 8, float) #0 - -; Function Attrs: nounwind -declare i32 @testE(i8 zeroext, i16 signext, i8 zeroext, i32, i32, float) #0 - -; Function Attrs: nounwind -define void @test_test3(%FooSt* %0) #0 { -entry: - %1 = getelementptr inbounds %FooSt, %FooSt* %0, i32 0, i32 1 - store i16 1, i16* %1, align 2 - ret void -} - -; Function Attrs: nounwind -define void @test_test2(%FooSt* byval(%FooSt) align 8 %0) #0 { -entry: - %indirectarg = alloca %FooSt, align 8 - %indirectarg1 = alloca %FooSt, align 8 - %1 = getelementptr inbounds %FooSt, %FooSt* %0, i32 0, i32 0 - %2 = load i8, i8* %1, align 4 - %3 = getelementptr inbounds %FooSt, %FooSt* %0, i32 0, i32 1 - %4 = load i16, i16* %3, align 2 - %5 = getelementptr inbounds %FooSt, %FooSt* %0, i32 0, i32 2 - %6 = load i8, i8* %5, align 4 - %7 = getelementptr inbounds %FooSt, %FooSt* %0, i32 0, i32 3 - %8 = load i32, i32* %7, align 4 - %9 = getelementptr inbounds %FooSt, %FooSt* %0, i32 0, i32 4 - %10 = load i16, i16* %9, align 4 - %sisiext = sext i16 %10 to i32 - %11 = call i32 @testE(i8 %2, i16 %4, i8 %6, i32 %8, i32 %sisiext, float 0x3FB99999A0000000) - %12 = bitcast %FooSt* %indirectarg to i8* - %13 = bitcast %FooSt* %0 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %12, i8* align 4 %13, i32 20, i1 false) - %14 = call i32 @testF(%FooSt* byval(%FooSt) align 8 %indirectarg, float 0x3FB99999A0000000) - %15 = bitcast %FooSt* %indirectarg1 to i8* - %16 = bitcast %FooSt* %0 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %15, i8* align 4 %16, i32 20, i1 false) - call void @test_test2(%FooSt* byval(%FooSt) align 8 %indirectarg1) - call void @test_test3(%FooSt* %0) - ret void -} diff --git a/test/test_suite14/comments/simple_comments.c3 b/test/test_suite14/comments/simple_comments.c3 deleted file mode 100644 index ded9afc18..000000000 --- a/test/test_suite14/comments/simple_comments.c3 +++ /dev/null @@ -1,15 +0,0 @@ -module comments; -/* Span *//* style */ - -/* Nested /* Errors // Inside */ */ -// Single line -/* - Multiline span style - */ - -fn void test() -{ - return; -} - -/* /* nested /* comments! */ !! */ goes here */ diff --git a/test/test_suite14/compile_time/compile_time_access_subscript.c3t b/test/test_suite14/compile_time/compile_time_access_subscript.c3t deleted file mode 100644 index 53593ac93..000000000 --- a/test/test_suite14/compile_time/compile_time_access_subscript.c3t +++ /dev/null @@ -1,122 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -struct Abc -{ - float m00, m01, m10, m11; -} - -Abc a = flip(Abc { 1, 2, 3, 4 }); - -macro flip($init) -{ - return Abc { $init.m01, $init.m10, $init.m11, $init.m00 }; -} - -macro check_type($Type) -{ - var $b = $Type[4][4] {}; - $Type z = $b[2][2]; - return z; -} - -enum Blurb { FOO } - -define Bdd = distinct Abc; -fn void main() -{ - var $i = int[4] { 1, 2, 3, 4 }; - var $b = Abc[2] { Abc {}, Abc { 11, 22, 33, 44 }}; - var $c = variant[4] {}; - check_type(int); - check_type(Abc); - check_type(anyerr); - check_type(Blurb); - check_type(int*); - check_type(bool); - check_type(typeid); - check_type(int[<3>]); - check_type(Bdd); - check_type(int[2]); - check_type(int[]); - io::printfn("%d", $b[0].m11); -} - -/* #expect: test.ll - - %z = alloca i32, align 4 - %z1 = alloca %Abc, align 4 - %z2 = alloca i64, align 8 - %z3 = alloca i32, align 4 - %z4 = alloca i32*, align 8 - %z5 = alloca i8, align 1 - %z6 = alloca i64, align 8 - %z7 = alloca <3 x i32>, align 16 - %z8 = alloca %Abc, align 4 - %z9 = alloca [2 x i32], align 4 - %z10 = alloca %"int[]", align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %literal = alloca %Abc, align 4 - %taddr = alloca %"variant[]", align 8 - store i32 0, i32* %z, align 4 - %0 = getelementptr inbounds %Abc, %Abc* %z1, i32 0, i32 0 - store float 0.000000e+00, float* %0, align 4 - %1 = getelementptr inbounds %Abc, %Abc* %z1, i32 0, i32 1 - store float 0.000000e+00, float* %1, align 4 - %2 = getelementptr inbounds %Abc, %Abc* %z1, i32 0, i32 2 - store float 0.000000e+00, float* %2, align 4 - %3 = getelementptr inbounds %Abc, %Abc* %z1, i32 0, i32 3 - store float 0.000000e+00, float* %3, align 4 - store i64 0, i64* %z2, align 8 - store i32 0, i32* %z3, align 4 - store i32* null, i32** %z4, align 8 - store i8 0, i8* %z5, align 1 - store i64 0, i64* %z6, align 8 - store <3 x i32> zeroinitializer, <3 x i32>* %z7, align 16 - %4 = getelementptr inbounds %Abc, %Abc* %z8, i32 0, i32 0 - store float 0.000000e+00, float* %4, align 4 - %5 = getelementptr inbounds %Abc, %Abc* %z8, i32 0, i32 1 - store float 0.000000e+00, float* %5, align 4 - %6 = getelementptr inbounds %Abc, %Abc* %z8, i32 0, i32 2 - store float 0.000000e+00, float* %6, align 4 - %7 = getelementptr inbounds %Abc, %Abc* %z8, i32 0, i32 3 - store float 0.000000e+00, float* %7, align 4 - %8 = getelementptr inbounds [2 x i32], [2 x i32]* %z9, i64 0, i64 0 - store i32 0, i32* %8, align 4 - %9 = getelementptr inbounds [2 x i32], [2 x i32]* %z9, i64 0, i64 1 - store i32 0, i32* %9, align 4 - %10 = bitcast %"int[]"* %z10 to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %10, i8 0, i64 16, i1 false) - %11 = getelementptr inbounds %Abc, %Abc* %literal, i32 0, i32 0 - store float 0.000000e+00, float* %11, align 4 - %12 = getelementptr inbounds %Abc, %Abc* %literal, i32 0, i32 1 - store float 0.000000e+00, float* %12, align 4 - %13 = getelementptr inbounds %Abc, %Abc* %literal, i32 0, i32 2 - store float 0.000000e+00, float* %13, align 4 - %14 = getelementptr inbounds %Abc, %Abc* %literal, i32 0, i32 3 - store float 0.000000e+00, float* %14, align 4 - %15 = bitcast %Abc* %literal to i8* - %16 = insertvalue %variant undef, i8* %15, 0 - %17 = insertvalue %variant %16, i64 ptrtoint (%.introspect* @"ct$test_Abc" to i64), 1 - %18 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %17, %variant* %18, align 16 - %19 = bitcast [1 x %variant]* %varargslots to %variant* - %20 = insertvalue %"variant[]" undef, %variant* %19, 0 - %21 = insertvalue %"variant[]" %20, i64 1, 1 - store %"variant[]" %21, %"variant[]"* %taddr, align 8 - %22 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %22, i32 0, i32 0 - %lo = load i8*, i8** %23, align 8 - %24 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %22, i32 0, i32 1 - %hi = load i64, i64* %24, align 8 - %25 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i64 2, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %25, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - ret void -} diff --git a/test/test_suite14/compile_time/compile_time_array.c3t b/test/test_suite14/compile_time/compile_time_array.c3t deleted file mode 100644 index f67c3ddb2..000000000 --- a/test/test_suite14/compile_time/compile_time_array.c3t +++ /dev/null @@ -1,29 +0,0 @@ -// #target: macos-x64 -module test; - -fn void test() -{ - var $foo = { 1, "a" }; - var $bar = $foo[0]; - var $i = 1; - var $baz = $foo[$i]; - int x = $bar; - char[] z = $baz; -} - -/* #expect: test.ll - - -%"char[]" = type { i8*, i64 } - -@.str = private unnamed_addr constant [2 x i8] c"a\00", align 1 - -define void @test_test() #0 { -entry: - %x = alloca i32, align 4 - %z = alloca %"char[]", align 8 - store i32 1, i32* %x, align 4 - store %"char[]" { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i64 1 }, %"char[]"* %z, align 8 - ret void -} - diff --git a/test/test_suite14/compile_time/compile_time_array_ref.c3t b/test/test_suite14/compile_time/compile_time_array_ref.c3t deleted file mode 100644 index aed2889fe..000000000 --- a/test/test_suite14/compile_time/compile_time_array_ref.c3t +++ /dev/null @@ -1,24 +0,0 @@ -// #target: macos-x64 -module foo; - -char[8192] stack; -char* x = &stack[0] + 1000; - -fn void test() -{ - static char[2] y; - static char* z = &y[1]; -} - -/* #expect: foo.ll - -@foo_stack = local_unnamed_addr global [8192 x i8] zeroinitializer, align 16 -@foo_x = local_unnamed_addr global i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @foo_stack, i64 0, i64 1000), align 8 -@"test$y" = internal unnamed_addr global [2 x i8] zeroinitializer, align 1 -@"test$z" = internal unnamed_addr global i8* getelementptr inbounds ([2 x i8], [2 x i8]* @"test$y", i64 0, i64 1), align 8 - -; Function Attrs: nounwind -define void @foo_test() #0 { -entry: - ret void -} diff --git a/test/test_suite14/compile_time/compile_time_bitops.c3t b/test/test_suite14/compile_time/compile_time_bitops.c3t deleted file mode 100644 index 92f924f2b..000000000 --- a/test/test_suite14/compile_time/compile_time_bitops.c3t +++ /dev/null @@ -1,18 +0,0 @@ -// #target: macos-x64 -module foo; - -int x1 = 2 ^ 4; -int x2 = 2 | 4; -int x3 = 2 & 4; -int y1 = 4 << 2; -int y2 = 4 >> 2; -int y3 = ~4; - -/* #expect: foo.ll - -@foo_x1 = local_unnamed_addr global i32 6, align 4 -@foo_x2 = local_unnamed_addr global i32 6, align 4 -@foo_x3 = local_unnamed_addr global i32 0, align 4 -@foo_y1 = local_unnamed_addr global i32 16, align 4 -@foo_y2 = local_unnamed_addr global i32 1, align 4 -@foo_y3 = local_unnamed_addr global i32 -5, align 4 \ No newline at end of file diff --git a/test/test_suite14/compile_time/compile_time_pointers.c3t b/test/test_suite14/compile_time/compile_time_pointers.c3t deleted file mode 100644 index ae7c411b1..000000000 --- a/test/test_suite14/compile_time/compile_time_pointers.c3t +++ /dev/null @@ -1,35 +0,0 @@ -// #target: macos-x64 -module test; - -const uptr ABC = 0x213; -const void* BAC = (void*)144 - 1; -const void* EXX = (void*)155; -const isz KEX = BAC - EXX; -const void* CAB = BAC; -const uptr ZAB = (uptr)CAB; -const int* BOB = (int*)16 - 1; -const int* BAB = (int*)16 + 1; -const isz AO = BAB - BOB; - -$if (ZAB > 100): -int abc = 123; -$endif; - -fn void test() -{ - abc++; - uptr foo = (uptr)BAC; -} - -/* #expect: test.ll - -@test_ABC = local_unnamed_addr constant i64 531, align 8 -@test_BAC = local_unnamed_addr constant i8* inttoptr (i64 143 to i8*), align 8 -@test_EXX = local_unnamed_addr constant i8* inttoptr (i64 155 to i8*), align 8 -@test_KEX = local_unnamed_addr constant i64 -12, align 8 -@test_CAB = local_unnamed_addr constant i8* inttoptr (i64 143 to i8*), align 8 -@test_ZAB = local_unnamed_addr constant i64 143, align 8 -@test_BOB = local_unnamed_addr constant i32* inttoptr (i64 12 to i32*), align 8 -@test_BAB = local_unnamed_addr constant i32* inttoptr (i64 20 to i32*), align 8 -@test_AO = local_unnamed_addr constant i64 2, align 8 -@test_abc = local_unnamed_addr global i32 123, align 4 \ No newline at end of file diff --git a/test/test_suite14/compile_time/compile_time_ptr_ref.c3t b/test/test_suite14/compile_time/compile_time_ptr_ref.c3t deleted file mode 100644 index 83bf64236..000000000 --- a/test/test_suite14/compile_time/compile_time_ptr_ref.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 -module test; - - -int*[] blurp = { &ptr, &ptr, (&ptr + 1), &ptr - 1, (int*)((iptr)(&ptr) - 4) }; -int* c = (int*)((iptr)(&ptr) - 4); -int* c2 = (int*)((iptr)(&ptr) + 4); -int* c3 = (int*)(4 + (iptr)(&ptr)); -iptr ff = (iptr)(&ptr); -int ptr = 0; - -// #expect: test.ll - -%"int*[]" = type { i32**, i64 } - -@.taddr = private global [5 x i32*] [i32* @test_ptr, i32* @test_ptr, i32* getelementptr inbounds (i32, i32* @test_ptr, i64 1), i32* getelementptr (i32, i32* @test_ptr, i64 -1), i32* bitcast (i8* getelementptr (i8, i8* bitcast (i32* @test_ptr to i8*), i64 -4) to i32*)], align 8 -@test_blurp = local_unnamed_addr global %"int*[]" { i32** getelementptr inbounds ([5 x i32*], [5 x i32*]* @.taddr, i32 0, i32 0), i64 5 }, align 8 -@test_c = local_unnamed_addr global i32* bitcast (i8* getelementptr (i8, i8* bitcast (i32* @test_ptr to i8*), i64 -4) to i32*), align 8 -@test_c2 = local_unnamed_addr global i32* bitcast (i8* getelementptr (i8, i8* bitcast (i32* @test_ptr to i8*), i64 4) to i32*), align 8 -@test_c3 = local_unnamed_addr global i32* bitcast (i8* getelementptr (i8, i8* bitcast (i32* @test_ptr to i8*), i64 4) to i32*), align 8 -@test_ff = local_unnamed_addr global i64 ptrtoint (i32* @test_ptr to i64), align 8 -@test_ptr = global i32 0, align 4 \ No newline at end of file diff --git a/test/test_suite14/compile_time/ct_builtin_time_date.c3t b/test/test_suite14/compile_time/ct_builtin_time_date.c3t deleted file mode 100644 index 10fba0f36..000000000 --- a/test/test_suite14/compile_time/ct_builtin_time_date.c3t +++ /dev/null @@ -1,126 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -macro printline() -{ - io::printfn("%d", $$LINE); io::printfn("%d", $$LINE_RAW); -} -fn void test(int x) -{ - io::printfn("%d", x); - if (x > 0) $$FUNCTION(x - 1); - io::println($$TIME); - io::println($$DATE); - printline(); - io::println($$FILE); - io::println($$MODULE); -} - -bool is_def = $defined($$FUNCTION); -fn void main() -{ - bool is_def2 = $defined($$FUNCTION); - test(10); -} - -/* #expect: test.ll - -define void @test_test(i32 %0) #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [1 x %variant], align 16 - %taddr4 = alloca i64, align 8 - %taddr5 = alloca %"variant[]", align 8 - %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %variant], align 16 - %taddr13 = alloca i64, align 8 - %taddr14 = alloca %"variant[]", align 8 - store i32 %0, i32* %taddr, align 4 - %1 = bitcast i32* %taddr to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %4 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %3, %variant* %4, align 16 - %5 = bitcast [1 x %variant]* %varargslots to %variant* - %6 = insertvalue %"variant[]" undef, %variant* %5, 0 - %7 = insertvalue %"variant[]" %6, i64 1, 1 - store %"variant[]" %7, %"variant[]"* %taddr1, align 8 - %8 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0 - %lo = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1 - %hi = load i64, i64* %10, align 8 - %11 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i64 2, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %11, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %gt = icmp sgt i32 %0, 0 - br i1 %gt, label %if.then, label %if.exit - -if.then: ; preds = %voiderr - %sub = sub i32 %0, 1 - call void @test_test(i32 %sub) - br label %if.exit - -if.exit: ; preds = %if.then, %voiderr - %12 = call i32 @std_io_println(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0)) #1 - %13 = call i32 @std_io_println(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0)) #1 - store i64 14, i64* %taddr4, align 8 - %14 = bitcast i64* %taddr4 to i8* - %15 = insertvalue %variant undef, i8* %14, 0 - %16 = insertvalue %variant %15, i64 ptrtoint (%.introspect* @"ct$long" to i64), 1 - %17 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots3, i64 0, i64 0 - store %variant %16, %variant* %17, align 16 - %18 = bitcast [1 x %variant]* %varargslots3 to %variant* - %19 = insertvalue %"variant[]" undef, %variant* %18, 0 - %20 = insertvalue %"variant[]" %19, i64 1, 1 - store %"variant[]" %20, %"variant[]"* %taddr5, align 8 - %21 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 0 - %lo6 = load i8*, i8** %22, align 8 - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 1 - %hi7 = load i64, i64* %23, align 8 - %24 = call i64 @std_io_printfn(i64* %retparam2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i64 2, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %24, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %if.exit - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %if.exit - store i64 6, i64* %taddr13, align 8 - %25 = bitcast i64* %taddr13 to i8* - %26 = insertvalue %variant undef, i8* %25, 0 - %27 = insertvalue %variant %26, i64 ptrtoint (%.introspect* @"ct$long" to i64), 1 - %28 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots12, i64 0, i64 0 - store %variant %27, %variant* %28, align 16 - %29 = bitcast [1 x %variant]* %varargslots12 to %variant* - %30 = insertvalue %"variant[]" undef, %variant* %29, 0 - %31 = insertvalue %"variant[]" %30, i64 1, 1 - store %"variant[]" %31, %"variant[]"* %taddr14, align 8 - %32 = bitcast %"variant[]"* %taddr14 to { i8*, i64 }* - %33 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 0 - %lo15 = load i8*, i8** %33, align 8 - %34 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 1 - %hi16 = load i64, i64* %34, align 8 - %35 = call i64 @std_io_printfn(i64* %retparam11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i64 2, i8* %lo15, i64 %hi16) - %not_err17 = icmp eq i64 %35, 0 - br i1 %not_err17, label %after_check18, label %voiderr19 - -after_check18: ; preds = %voiderr10 - br label %voiderr19 - -voiderr19: ; preds = %after_check18, %voiderr10 - %36 = call i32 @std_io_println(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i32 0, i32 0)) #1 - %37 = call i32 @std_io_println(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0)) #1 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/compile_time/ct_checks.c3t b/test/test_suite14/compile_time/ct_checks.c3t deleted file mode 100644 index 214382b48..000000000 --- a/test/test_suite14/compile_time/ct_checks.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn void main() -{ - int a; - bool b = $checks(a = 12.0); - var $y = 23; - bool c = $checks(int z = 23, $y += 23, &c); - bool d = $checks(&c, $y, int yy = 23); - int z = $y; - io::printfn("%s %s %s", b, $y, c); -} - -/* #expect: test.ll - - store i32 0 - store i8 0 - store i8 1 - store i8 1 - store i32 46 diff --git a/test/test_suite14/compile_time/ct_enum_values.c3t b/test/test_suite14/compile_time/ct_enum_values.c3t deleted file mode 100644 index 49ec977b7..000000000 --- a/test/test_suite14/compile_time/ct_enum_values.c3t +++ /dev/null @@ -1,30 +0,0 @@ -// #target: macos-x64 -module test; -enum Vehicles -{ - CAR, - PLANE -} - -macro elements($Type) -{ - int x; - $foreach ($x : $Type.values): - x = (int)$x; - $endforeach; -} - -fn void main() -{ - elements(Vehicles); -} - -/* #expect: test.ll - -entry: - %x = alloca i32, align 4 - store i32 0, i32* %x, align 4 - store i32 0, i32* %x, align 4 - store i32 1, i32* %x, align 4 - ret void -} diff --git a/test/test_suite14/compile_time/ct_eval.c3t b/test/test_suite14/compile_time/ct_eval.c3t deleted file mode 100644 index 55f6e312b..000000000 --- a/test/test_suite14/compile_time/ct_eval.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 -module test; -extern fn void printf(char*, ...); - -fn void main() -{ - var $x = "abc"; - int abc = 20; - $eval($x) = 444; - printf("Val: %d\n", $eval("abc")); -} -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %abc = alloca i32, align 4 - store i32 20, i32* %abc, align 4 - store i32 444, i32* %abc, align 4 - %0 = load i32, i32* %abc, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %0) - ret void -} diff --git a/test/test_suite14/compile_time/ct_eval_sym.c3 b/test/test_suite14/compile_time/ct_eval_sym.c3 deleted file mode 100644 index d351c8d95..000000000 --- a/test/test_suite14/compile_time/ct_eval_sym.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn int test() -{ - void* x = (void*)&$eval($$FUNC); - return 1; -} \ No newline at end of file diff --git a/test/test_suite14/compile_time/ct_for.c3t b/test/test_suite14/compile_time/ct_for.c3t deleted file mode 100644 index 7d8994ea8..000000000 --- a/test/test_suite14/compile_time/ct_for.c3t +++ /dev/null @@ -1,32 +0,0 @@ -// #target: macos-x64 - -module test; - -extern fn void printf(char*, ...); - -fn void main() -{ - - $for (var $i = 0; $i < 3; $i++): - printf("Foo %d\n", $i); - $endfor; - - $for ($i = 0, var $j = 100; $i < 4;): - printf("Foo %d %d\n", $i++, $j--); - $endfor; - -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 0) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 1) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i32 2) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i32 0, i32 100) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), i32 1, i32 99) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i32 0, i32 0), i32 2, i32 98) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), i32 3, i32 97) - ret void -} diff --git a/test/test_suite14/compile_time/ct_foreach.c3t b/test/test_suite14/compile_time/ct_foreach.c3t deleted file mode 100644 index 02cfb3830..000000000 --- a/test/test_suite14/compile_time/ct_foreach.c3t +++ /dev/null @@ -1,52 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn void printf(char*, ...); - -fn void main() -{ - - var $foo = { 1, 10, 34 }; - $foreach ($i : $foo): - printf("Foo %d\n", $i); - $endforeach; - - $foreach ($i, $j : $foo): - printf("Bar %d %d\n", $i, $j); - $endforeach; - - $foreach ($x : { 123, "abc", 1177, "hello" }): - $typeof($x) z = $x; - $switch ($typeof($x)): - $case int: - printf("Bar %d\n", $x); - $default: - printf("Bar %s\n", $x); - $endswitch; - $endforeach; - -} - -/* #expect: test.ll -define void @test_main() #0 { -entry: - %z = alloca i32, align 4 - %z1 = alloca [3 x i8]*, align 8 - %z2 = alloca i32, align 4 - %z3 = alloca [5 x i8]*, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 1) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 10) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i32 34) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i32 0, i32 1) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), i32 1, i32 10) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i32 0, i32 0), i32 2, i32 34) - store i32 123, i32* %z, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i32 123) - store [3 x i8]* bitcast ([4 x i8]* @.str.7 to [3 x i8]*), [3 x i8]** %z1, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), [3 x i8]* bitcast ([4 x i8]* @.str.9 to [3 x i8]*)) - store i32 1177, i32* %z2, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i32 1177) - store [5 x i8]* bitcast ([6 x i8]* @.str.11 to [5 x i8]*), [5 x i8]** %z3, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), [5 x i8]* bitcast ([6 x i8]* @.str.13 to [5 x i8]*)) - ret void -} diff --git a/test/test_suite14/compile_time/ct_func.c3t b/test/test_suite14/compile_time/ct_func.c3t deleted file mode 100644 index 85895870b..000000000 --- a/test/test_suite14/compile_time/ct_func.c3t +++ /dev/null @@ -1,29 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn int test() -{ - io::println($$FUNC); - return 1; -} - -struct Foo -{ int x; } - -fn void Foo.tester(Foo* f) -{ - io::println($$FUNC); -} - -fn void main() -{ - Foo f; - f.tester(); - test(); -} - -/* #expect: test.ll - -@.str = private unnamed_addr constant [5 x i8] c"test\00", align 1 -@.str.1 = private unnamed_addr constant [11 x i8] c"Foo.tester\00", align 1 diff --git a/test/test_suite14/compile_time/ct_funcptr.c3t b/test/test_suite14/compile_time/ct_funcptr.c3t deleted file mode 100644 index 4747f4862..000000000 --- a/test/test_suite14/compile_time/ct_funcptr.c3t +++ /dev/null @@ -1,61 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn void test(int x) -{ - $typeof(&$$FUNCTION) ptr = &$$FUNCTION; - io::printfn("%d", x); - if (x > 0) ptr(x - 1); -} - -fn void main() -{ - test(10); -} - -/* #expect: test.ll - -define void @test_test(i32 %0) #0 { -entry: - %ptr = alloca void (i32)*, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - store void (i32)* @test_test, void (i32)** %ptr, align 8 - store i32 %0, i32* %taddr, align 4 - %1 = bitcast i32* %taddr to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %4 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %3, %variant* %4, align 16 - %5 = bitcast [1 x %variant]* %varargslots to %variant* - %6 = insertvalue %"variant[]" undef, %variant* %5, 0 - %7 = insertvalue %"variant[]" %6, i64 1, 1 - store %"variant[]" %7, %"variant[]"* %taddr1, align 8 - %8 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0 - %lo = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1 - %hi = load i64, i64* %10, align 8 - %11 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i64 2, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %11, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %gt = icmp sgt i32 %0, 0 - br i1 %gt, label %if.then, label %if.exit - -if.then: ; preds = %voiderr - %12 = load void (i32)*, void (i32)** %ptr, align 8 - %sub = sub i32 %0, 1 - call void %12(i32 %sub) - br label %if.exit - -if.exit: ; preds = %if.then, %voiderr - ret void -} diff --git a/test/test_suite14/compile_time/ct_if.c3t b/test/test_suite14/compile_time/ct_if.c3t deleted file mode 100644 index 296572c9a..000000000 --- a/test/test_suite14/compile_time/ct_if.c3t +++ /dev/null @@ -1,65 +0,0 @@ -$if (0): -$else: - $if (0): - $elif (0): - $elif (0): - $else: - int x = 1; - $endif; -$endif; - -$if (0): -$assert(false); -$elif (0): -$assert(false); -$else: -$assert(true); -$endif; - -$if (1): -$assert(true); -int d = 5; -$elif (0): -$assert(false); -$else: -$assert(false); -$endif; - -$if (0): -$assert(true); -$elif (1): -$assert(true); -int c = 5; -$else: -$assert(false); -$endif; - -$if (0): -$assert(true); -$elif (1): -$assert(true); -int b = 4; -$elif (0): -$assert(false); -$else: -$assert(false); -$endif; - -$if (0): -$assert(true); -$elif (0): -$assert(false); -$elif (1): -$assert(true); -int a = 3; -$else: -$assert(false); -$endif; - -// #expect: ct_if.ll - -@ct_if_d = local_unnamed_addr global i32 5, align 4 -@ct_if_c = local_unnamed_addr global i32 5, align 4 -@ct_if_b = local_unnamed_addr global i32 4, align 4 -@ct_if_a = local_unnamed_addr global i32 3, align 4 -@ct_if_x = local_unnamed_addr global i32 1, align 4 \ No newline at end of file diff --git a/test/test_suite14/compile_time/ct_if_fails.c3 b/test/test_suite14/compile_time/ct_if_fails.c3 deleted file mode 100644 index 2392071f1..000000000 --- a/test/test_suite14/compile_time/ct_if_fails.c3 +++ /dev/null @@ -1,28 +0,0 @@ -int x; -$if (x > 0): -$endif; - -$if (0): - $assert(false); -$endif; - -$if (1): -$else: -$endif; - -$if (1): -$else: -$else: // #error: Expected the start of a global declaration here -$endif; - - -$if (1): -$elif (2): -$else: -$endif; - -$if (1): -$elif (2): -$elif (3): -$else: -$endif; diff --git a/test/test_suite14/compile_time/ct_memberof.c3t b/test/test_suite14/compile_time/ct_memberof.c3t deleted file mode 100644 index 959f9d8d0..000000000 --- a/test/test_suite14/compile_time/ct_memberof.c3t +++ /dev/null @@ -1,913 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn int hell() { return 1; } - -macro print_args($Type) -{ - var $params = $Type.params; - $foreach ($param : $params): - io::println($param.nameof); - $endforeach; -} - -bitstruct Bark : ulong -{ - int x : 1..4; - short y : 6..10; -} - -struct Foo -{ - int x; - union test { - int y; - double z; - } - struct { - int abc; - int bcd; - } - double q; -} -macro print_fields($Type) -{ - io::printfn("Type: %s", $Type.nameof); - var $params = $Type.membersof; - $foreach ($param : $params): - io::printfn("%s: %s", $param.nameof, $param.typeid.nameof); - $endforeach; -} - -fn void hello(int a, double b, int[4] d, args...) {} -fn void test(int x) -{ - print_args($typeof(&test)); - print_args($typeof(&hell)); - print_args($typeof(&hello)); - io::println($typeof(&test).returns.nameof); - io::println($typeof(&hell).returns.nameof); - print_fields(Foo); - print_fields(Bar); - print_fields(Bark); -} - -struct BarInner -{ - char a; - char b; -} - -struct Bar -{ - char a; - short b; - struct - { - union - { - BarInner y; - char z; - struct { - char z1; - char z2; - } - } - } - struct baz - { - int foo; - } -} -fn void main() -{ - var $x = Bar.a; - - io::printfn("len: %d", Bar.membersof.len); - io::printfn("len: %d", Bar.baz.membersof.len); - io::printfn("a: %d %d", Bar.a.offsetof, Bar.a.alignof); - io::printfn("b: %d %d", Bar.b.offsetof, Bar.b.alignof); - io::printfn("y: %d %d", Bar.y.offsetof, Bar.y.alignof); - io::printfn("z: %d %d", Bar.z.offsetof, Bar.z.alignof); - io::printfn("z1: %d %d", Bar.z1.offsetof, Bar.z1.alignof); - io::printfn("z2: %d %d", Bar.z2.offsetof, Bar.z2.alignof); - io::printfn("baz: %d %d", Bar.baz.offsetof, Bar.baz.alignof); - io::printfn("Bar: %d", $x.alignof); - io::printfn("foo: %d %d", Bar.baz.foo.offsetof, Bar.baz.foo.alignof); - - test(10); -} - -/* #expect: test.ll - -define void @test_hello(i32 %0, double %1, i64 %2, i64 %3, i8* %4, i64 %5) #0 { -entry: - %d = alloca [4 x i32], align 4 - %args = alloca %"variant[]", align 8 - %pair = bitcast [4 x i32]* %d to { i64, i64 }* - %6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %pair, i32 0, i32 0 - store i64 %2, i64* %6, align 4 - %7 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %pair, i32 0, i32 1 - store i64 %3, i64* %7, align 4 - %pair1 = bitcast %"variant[]"* %args to { i8*, i64 }* - %8 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 0 - store i8* %4, i8** %8, align 8 - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 1 - store i64 %5, i64* %9, align 8 - ret void -} - -; Function Attrs: nounwind -define void @test_test(i32 %0) #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca [3 x i8]*, align 8 - %taddr1 = alloca %"variant[]", align 8 - %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [2 x %variant], align 16 - %taddr4 = alloca [1 x i8]*, align 8 - %taddr5 = alloca [3 x i8]*, align 8 - %taddr6 = alloca %"variant[]", align 8 - %retparam12 = alloca i64, align 8 - %varargslots13 = alloca [2 x %variant], align 16 - %taddr14 = alloca [4 x i8]*, align 8 - %taddr15 = alloca [4 x i8]*, align 8 - %taddr16 = alloca %"variant[]", align 8 - %retparam22 = alloca i64, align 8 - %varargslots23 = alloca [2 x %variant], align 16 - %taddr24 = alloca [0 x i8]*, align 8 - %taddr25 = alloca [5 x i8]*, align 8 - %taddr26 = alloca %"variant[]", align 8 - %retparam32 = alloca i64, align 8 - %varargslots33 = alloca [2 x %variant], align 16 - %taddr34 = alloca [1 x i8]*, align 8 - %taddr35 = alloca [6 x i8]*, align 8 - %taddr36 = alloca %"variant[]", align 8 - %retparam42 = alloca i64, align 8 - %varargslots43 = alloca [1 x %variant], align 16 - %taddr44 = alloca [3 x i8]*, align 8 - %taddr45 = alloca %"variant[]", align 8 - %retparam51 = alloca i64, align 8 - %varargslots52 = alloca [2 x %variant], align 16 - %taddr53 = alloca [1 x i8]*, align 8 - %taddr54 = alloca [4 x i8]*, align 8 - %taddr55 = alloca %"variant[]", align 8 - %retparam61 = alloca i64, align 8 - %varargslots62 = alloca [2 x %variant], align 16 - %taddr63 = alloca [1 x i8]*, align 8 - %taddr64 = alloca [5 x i8]*, align 8 - %taddr65 = alloca %"variant[]", align 8 - %retparam71 = alloca i64, align 8 - %varargslots72 = alloca [2 x %variant], align 16 - %taddr73 = alloca [0 x i8]*, align 8 - %taddr74 = alloca [5 x i8]*, align 8 - %taddr75 = alloca %"variant[]", align 8 - %retparam81 = alloca i64, align 8 - %varargslots82 = alloca [2 x %variant], align 16 - %taddr83 = alloca [3 x i8]*, align 8 - %taddr84 = alloca [3 x i8]*, align 8 - %taddr85 = alloca %"variant[]", align 8 - %retparam91 = alloca i64, align 8 - %varargslots92 = alloca [1 x %variant], align 16 - %taddr93 = alloca [4 x i8]*, align 8 - %taddr94 = alloca %"variant[]", align 8 - %retparam100 = alloca i64, align 8 - %varargslots101 = alloca [2 x %variant], align 16 - %taddr102 = alloca [1 x i8]*, align 8 - %taddr103 = alloca [3 x i8]*, align 8 - %taddr104 = alloca %"variant[]", align 8 - %retparam110 = alloca i64, align 8 - %varargslots111 = alloca [2 x %variant], align 16 - %taddr112 = alloca [1 x i8]*, align 8 - %taddr113 = alloca [5 x i8]*, align 8 - %taddr114 = alloca %"variant[]", align 8 - %1 = call i32 @std_io_println(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0)) #1 - %2 = call i32 @std_io_println(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0)) #1 - %3 = call i32 @std_io_println(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i32 0, i32 0)) #1 - %4 = call i32 @std_io_println(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i32 0, i32 0)) #1 - %5 = call i32 @std_io_println(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i32 0, i32 0)) #1 - %6 = call i32 @std_io_println(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0)) #1 - %7 = call i32 @std_io_println(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i32 0, i32 0)) #1 - store [3 x i8]* bitcast ([4 x i8]* @.str.17 to [3 x i8]*), [3 x i8]** %taddr, align 8 - %8 = bitcast [3 x i8]** %taddr to i8* - %9 = insertvalue %variant undef, i8* %8, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - %11 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %10, %variant* %11, align 16 - %12 = bitcast [1 x %variant]* %varargslots to %variant* - %13 = insertvalue %"variant[]" undef, %variant* %12, 0 - %14 = insertvalue %"variant[]" %13, i64 1, 1 - store %"variant[]" %14, %"variant[]"* %taddr1, align 8 - %15 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %16 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 0 - %lo = load i8*, i8** %16, align 8 - %17 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 1 - %hi = load i64, i64* %17, align 8 - %18 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i32 0, i32 0), i64 8, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %18, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - store [1 x i8]* bitcast ([2 x i8]* @.str.19 to [1 x i8]*), [1 x i8]** %taddr4, align 8 - %19 = bitcast [1 x i8]** %taddr4 to i8* - %20 = insertvalue %variant undef, i8* %19, 0 - %21 = insertvalue %variant %20, i64 ptrtoint (%.introspect* @"ct$p$a1$char" to i64), 1 - %22 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots3, i64 0, i64 0 - store %variant %21, %variant* %22, align 16 - store [3 x i8]* bitcast ([4 x i8]* @.str.20 to [3 x i8]*), [3 x i8]** %taddr5, align 8 - %23 = bitcast [3 x i8]** %taddr5 to i8* - %24 = insertvalue %variant undef, i8* %23, 0 - %25 = insertvalue %variant %24, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - %26 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots3, i64 0, i64 1 - store %variant %25, %variant* %26, align 16 - %27 = bitcast [2 x %variant]* %varargslots3 to %variant* - %28 = insertvalue %"variant[]" undef, %variant* %27, 0 - %29 = insertvalue %"variant[]" %28, i64 2, 1 - store %"variant[]" %29, %"variant[]"* %taddr6, align 8 - %30 = bitcast %"variant[]"* %taddr6 to { i8*, i64 }* - %31 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %30, i32 0, i32 0 - %lo7 = load i8*, i8** %31, align 8 - %32 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %30, i32 0, i32 1 - %hi8 = load i64, i64* %32, align 8 - %33 = call i64 @std_io_printfn(i64* %retparam2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i32 0, i32 0), i64 6, i8* %lo7, i64 %hi8) - %not_err9 = icmp eq i64 %33, 0 - br i1 %not_err9, label %after_check10, label %voiderr11 - -after_check10: ; preds = %voiderr - br label %voiderr11 - -voiderr11: ; preds = %after_check10, %voiderr - store [4 x i8]* bitcast ([5 x i8]* @.str.22 to [4 x i8]*), [4 x i8]** %taddr14, align 8 - %34 = bitcast [4 x i8]** %taddr14 to i8* - %35 = insertvalue %variant undef, i8* %34, 0 - %36 = insertvalue %variant %35, i64 ptrtoint (%.introspect* @"ct$p$a4$char" to i64), 1 - %37 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots13, i64 0, i64 0 - store %variant %36, %variant* %37, align 16 - store [4 x i8]* bitcast ([5 x i8]* @.str.23 to [4 x i8]*), [4 x i8]** %taddr15, align 8 - %38 = bitcast [4 x i8]** %taddr15 to i8* - %39 = insertvalue %variant undef, i8* %38, 0 - %40 = insertvalue %variant %39, i64 ptrtoint (%.introspect* @"ct$p$a4$char" to i64), 1 - %41 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots13, i64 0, i64 1 - store %variant %40, %variant* %41, align 16 - %42 = bitcast [2 x %variant]* %varargslots13 to %variant* - %43 = insertvalue %"variant[]" undef, %variant* %42, 0 - %44 = insertvalue %"variant[]" %43, i64 2, 1 - store %"variant[]" %44, %"variant[]"* %taddr16, align 8 - %45 = bitcast %"variant[]"* %taddr16 to { i8*, i64 }* - %46 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 0 - %lo17 = load i8*, i8** %46, align 8 - %47 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 1 - %hi18 = load i64, i64* %47, align 8 - %48 = call i64 @std_io_printfn(i64* %retparam12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.21, i32 0, i32 0), i64 6, i8* %lo17, i64 %hi18) - %not_err19 = icmp eq i64 %48, 0 - br i1 %not_err19, label %after_check20, label %voiderr21 - -after_check20: ; preds = %voiderr11 - br label %voiderr21 - -voiderr21: ; preds = %after_check20, %voiderr11 - store [0 x i8]* bitcast ([1 x i8]* @.str.25 to [0 x i8]*), [0 x i8]** %taddr24, align 8 - %49 = bitcast [0 x i8]** %taddr24 to i8* - %50 = insertvalue %variant undef, i8* %49, 0 - %51 = insertvalue %variant %50, i64 ptrtoint (%.introspect* @"ct$p$a0$char" to i64), 1 - %52 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots23, i64 0, i64 0 - store %variant %51, %variant* %52, align 16 - store [5 x i8]* bitcast ([6 x i8]* @.str.26 to [5 x i8]*), [5 x i8]** %taddr25, align 8 - %53 = bitcast [5 x i8]** %taddr25 to i8* - %54 = insertvalue %variant undef, i8* %53, 0 - %55 = insertvalue %variant %54, i64 ptrtoint (%.introspect* @"ct$p$a5$char" to i64), 1 - %56 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots23, i64 0, i64 1 - store %variant %55, %variant* %56, align 16 - %57 = bitcast [2 x %variant]* %varargslots23 to %variant* - %58 = insertvalue %"variant[]" undef, %variant* %57, 0 - %59 = insertvalue %"variant[]" %58, i64 2, 1 - store %"variant[]" %59, %"variant[]"* %taddr26, align 8 - %60 = bitcast %"variant[]"* %taddr26 to { i8*, i64 }* - %61 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %60, i32 0, i32 0 - %lo27 = load i8*, i8** %61, align 8 - %62 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %60, i32 0, i32 1 - %hi28 = load i64, i64* %62, align 8 - %63 = call i64 @std_io_printfn(i64* %retparam22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i32 0, i32 0), i64 6, i8* %lo27, i64 %hi28) - %not_err29 = icmp eq i64 %63, 0 - br i1 %not_err29, label %after_check30, label %voiderr31 - -after_check30: ; preds = %voiderr21 - br label %voiderr31 - -voiderr31: ; preds = %after_check30, %voiderr21 - store [1 x i8]* bitcast ([2 x i8]* @.str.28 to [1 x i8]*), [1 x i8]** %taddr34, align 8 - %64 = bitcast [1 x i8]** %taddr34 to i8* - %65 = insertvalue %variant undef, i8* %64, 0 - %66 = insertvalue %variant %65, i64 ptrtoint (%.introspect* @"ct$p$a1$char" to i64), 1 - %67 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots33, i64 0, i64 0 - store %variant %66, %variant* %67, align 16 - store [6 x i8]* bitcast ([7 x i8]* @.str.29 to [6 x i8]*), [6 x i8]** %taddr35, align 8 - %68 = bitcast [6 x i8]** %taddr35 to i8* - %69 = insertvalue %variant undef, i8* %68, 0 - %70 = insertvalue %variant %69, i64 ptrtoint (%.introspect* @"ct$p$a6$char" to i64), 1 - %71 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots33, i64 0, i64 1 - store %variant %70, %variant* %71, align 16 - %72 = bitcast [2 x %variant]* %varargslots33 to %variant* - %73 = insertvalue %"variant[]" undef, %variant* %72, 0 - %74 = insertvalue %"variant[]" %73, i64 2, 1 - store %"variant[]" %74, %"variant[]"* %taddr36, align 8 - %75 = bitcast %"variant[]"* %taddr36 to { i8*, i64 }* - %76 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %75, i32 0, i32 0 - %lo37 = load i8*, i8** %76, align 8 - %77 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %75, i32 0, i32 1 - %hi38 = load i64, i64* %77, align 8 - %78 = call i64 @std_io_printfn(i64* %retparam32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.27, i32 0, i32 0), i64 6, i8* %lo37, i64 %hi38) - %not_err39 = icmp eq i64 %78, 0 - br i1 %not_err39, label %after_check40, label %voiderr41 - -after_check40: ; preds = %voiderr31 - br label %voiderr41 - -voiderr41: ; preds = %after_check40, %voiderr31 - store [3 x i8]* bitcast ([4 x i8]* @.str.31 to [3 x i8]*), [3 x i8]** %taddr44, align 8 - %79 = bitcast [3 x i8]** %taddr44 to i8* - %80 = insertvalue %variant undef, i8* %79, 0 - %81 = insertvalue %variant %80, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - %82 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots43, i64 0, i64 0 - store %variant %81, %variant* %82, align 16 - %83 = bitcast [1 x %variant]* %varargslots43 to %variant* - %84 = insertvalue %"variant[]" undef, %variant* %83, 0 - %85 = insertvalue %"variant[]" %84, i64 1, 1 - store %"variant[]" %85, %"variant[]"* %taddr45, align 8 - %86 = bitcast %"variant[]"* %taddr45 to { i8*, i64 }* - %87 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %86, i32 0, i32 0 - %lo46 = load i8*, i8** %87, align 8 - %88 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %86, i32 0, i32 1 - %hi47 = load i64, i64* %88, align 8 - %89 = call i64 @std_io_printfn(i64* %retparam42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.30, i32 0, i32 0), i64 8, i8* %lo46, i64 %hi47) - %not_err48 = icmp eq i64 %89, 0 - br i1 %not_err48, label %after_check49, label %voiderr50 - -after_check49: ; preds = %voiderr41 - br label %voiderr50 - -voiderr50: ; preds = %after_check49, %voiderr41 - store [1 x i8]* bitcast ([2 x i8]* @.str.33 to [1 x i8]*), [1 x i8]** %taddr53, align 8 - %90 = bitcast [1 x i8]** %taddr53 to i8* - %91 = insertvalue %variant undef, i8* %90, 0 - %92 = insertvalue %variant %91, i64 ptrtoint (%.introspect* @"ct$p$a1$char" to i64), 1 - %93 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots52, i64 0, i64 0 - store %variant %92, %variant* %93, align 16 - store [4 x i8]* bitcast ([5 x i8]* @.str.34 to [4 x i8]*), [4 x i8]** %taddr54, align 8 - %94 = bitcast [4 x i8]** %taddr54 to i8* - %95 = insertvalue %variant undef, i8* %94, 0 - %96 = insertvalue %variant %95, i64 ptrtoint (%.introspect* @"ct$p$a4$char" to i64), 1 - %97 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots52, i64 0, i64 1 - store %variant %96, %variant* %97, align 16 - %98 = bitcast [2 x %variant]* %varargslots52 to %variant* - %99 = insertvalue %"variant[]" undef, %variant* %98, 0 - %100 = insertvalue %"variant[]" %99, i64 2, 1 - store %"variant[]" %100, %"variant[]"* %taddr55, align 8 - %101 = bitcast %"variant[]"* %taddr55 to { i8*, i64 }* - %102 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %101, i32 0, i32 0 - %lo56 = load i8*, i8** %102, align 8 - %103 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %101, i32 0, i32 1 - %hi57 = load i64, i64* %103, align 8 - %104 = call i64 @std_io_printfn(i64* %retparam51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.32, i32 0, i32 0), i64 6, i8* %lo56, i64 %hi57) - %not_err58 = icmp eq i64 %104, 0 - br i1 %not_err58, label %after_check59, label %voiderr60 - -after_check59: ; preds = %voiderr50 - br label %voiderr60 - -voiderr60: ; preds = %after_check59, %voiderr50 - store [1 x i8]* bitcast ([2 x i8]* @.str.36 to [1 x i8]*), [1 x i8]** %taddr63, align 8 - %105 = bitcast [1 x i8]** %taddr63 to i8* - %106 = insertvalue %variant undef, i8* %105, 0 - %107 = insertvalue %variant %106, i64 ptrtoint (%.introspect* @"ct$p$a1$char" to i64), 1 - %108 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots62, i64 0, i64 0 - store %variant %107, %variant* %108, align 16 - store [5 x i8]* bitcast ([6 x i8]* @.str.37 to [5 x i8]*), [5 x i8]** %taddr64, align 8 - %109 = bitcast [5 x i8]** %taddr64 to i8* - %110 = insertvalue %variant undef, i8* %109, 0 - %111 = insertvalue %variant %110, i64 ptrtoint (%.introspect* @"ct$p$a5$char" to i64), 1 - %112 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots62, i64 0, i64 1 - store %variant %111, %variant* %112, align 16 - %113 = bitcast [2 x %variant]* %varargslots62 to %variant* - %114 = insertvalue %"variant[]" undef, %variant* %113, 0 - %115 = insertvalue %"variant[]" %114, i64 2, 1 - store %"variant[]" %115, %"variant[]"* %taddr65, align 8 - %116 = bitcast %"variant[]"* %taddr65 to { i8*, i64 }* - %117 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %116, i32 0, i32 0 - %lo66 = load i8*, i8** %117, align 8 - %118 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %116, i32 0, i32 1 - %hi67 = load i64, i64* %118, align 8 - %119 = call i64 @std_io_printfn(i64* %retparam61, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.35, i32 0, i32 0), i64 6, i8* %lo66, i64 %hi67) - %not_err68 = icmp eq i64 %119, 0 - br i1 %not_err68, label %after_check69, label %voiderr70 - -after_check69: ; preds = %voiderr60 - br label %voiderr70 - -voiderr70: ; preds = %after_check69, %voiderr60 - store [0 x i8]* bitcast ([1 x i8]* @.str.39 to [0 x i8]*), [0 x i8]** %taddr73, align 8 - %120 = bitcast [0 x i8]** %taddr73 to i8* - %121 = insertvalue %variant undef, i8* %120, 0 - %122 = insertvalue %variant %121, i64 ptrtoint (%.introspect* @"ct$p$a0$char" to i64), 1 - %123 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots72, i64 0, i64 0 - store %variant %122, %variant* %123, align 16 - store [5 x i8]* bitcast ([6 x i8]* @.str.40 to [5 x i8]*), [5 x i8]** %taddr74, align 8 - %124 = bitcast [5 x i8]** %taddr74 to i8* - %125 = insertvalue %variant undef, i8* %124, 0 - %126 = insertvalue %variant %125, i64 ptrtoint (%.introspect* @"ct$p$a5$char" to i64), 1 - %127 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots72, i64 0, i64 1 - store %variant %126, %variant* %127, align 16 - %128 = bitcast [2 x %variant]* %varargslots72 to %variant* - %129 = insertvalue %"variant[]" undef, %variant* %128, 0 - %130 = insertvalue %"variant[]" %129, i64 2, 1 - store %"variant[]" %130, %"variant[]"* %taddr75, align 8 - %131 = bitcast %"variant[]"* %taddr75 to { i8*, i64 }* - %132 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %131, i32 0, i32 0 - %lo76 = load i8*, i8** %132, align 8 - %133 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %131, i32 0, i32 1 - %hi77 = load i64, i64* %133, align 8 - %134 = call i64 @std_io_printfn(i64* %retparam71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.38, i32 0, i32 0), i64 6, i8* %lo76, i64 %hi77) - %not_err78 = icmp eq i64 %134, 0 - br i1 %not_err78, label %after_check79, label %voiderr80 - -after_check79: ; preds = %voiderr70 - br label %voiderr80 - -voiderr80: ; preds = %after_check79, %voiderr70 - store [3 x i8]* bitcast ([4 x i8]* @.str.42 to [3 x i8]*), [3 x i8]** %taddr83, align 8 - %135 = bitcast [3 x i8]** %taddr83 to i8* - %136 = insertvalue %variant undef, i8* %135, 0 - %137 = insertvalue %variant %136, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - %138 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots82, i64 0, i64 0 - store %variant %137, %variant* %138, align 16 - store [3 x i8]* bitcast ([4 x i8]* @.str.43 to [3 x i8]*), [3 x i8]** %taddr84, align 8 - %139 = bitcast [3 x i8]** %taddr84 to i8* - %140 = insertvalue %variant undef, i8* %139, 0 - %141 = insertvalue %variant %140, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - %142 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots82, i64 0, i64 1 - store %variant %141, %variant* %142, align 16 - %143 = bitcast [2 x %variant]* %varargslots82 to %variant* - %144 = insertvalue %"variant[]" undef, %variant* %143, 0 - %145 = insertvalue %"variant[]" %144, i64 2, 1 - store %"variant[]" %145, %"variant[]"* %taddr85, align 8 - %146 = bitcast %"variant[]"* %taddr85 to { i8*, i64 }* - %147 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %146, i32 0, i32 0 - %lo86 = load i8*, i8** %147, align 8 - %148 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %146, i32 0, i32 1 - %hi87 = load i64, i64* %148, align 8 - %149 = call i64 @std_io_printfn(i64* %retparam81, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.41, i32 0, i32 0), i64 6, i8* %lo86, i64 %hi87) - %not_err88 = icmp eq i64 %149, 0 - br i1 %not_err88, label %after_check89, label %voiderr90 - -after_check89: ; preds = %voiderr80 - br label %voiderr90 - -voiderr90: ; preds = %after_check89, %voiderr80 - store [4 x i8]* bitcast ([5 x i8]* @.str.45 to [4 x i8]*), [4 x i8]** %taddr93, align 8 - %150 = bitcast [4 x i8]** %taddr93 to i8* - %151 = insertvalue %variant undef, i8* %150, 0 - %152 = insertvalue %variant %151, i64 ptrtoint (%.introspect* @"ct$p$a4$char" to i64), 1 - %153 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots92, i64 0, i64 0 - store %variant %152, %variant* %153, align 16 - %154 = bitcast [1 x %variant]* %varargslots92 to %variant* - %155 = insertvalue %"variant[]" undef, %variant* %154, 0 - %156 = insertvalue %"variant[]" %155, i64 1, 1 - store %"variant[]" %156, %"variant[]"* %taddr94, align 8 - %157 = bitcast %"variant[]"* %taddr94 to { i8*, i64 }* - %158 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %157, i32 0, i32 0 - %lo95 = load i8*, i8** %158, align 8 - %159 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %157, i32 0, i32 1 - %hi96 = load i64, i64* %159, align 8 - %160 = call i64 @std_io_printfn(i64* %retparam91, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.44, i32 0, i32 0), i64 8, i8* %lo95, i64 %hi96) - %not_err97 = icmp eq i64 %160, 0 - br i1 %not_err97, label %after_check98, label %voiderr99 - -after_check98: ; preds = %voiderr90 - br label %voiderr99 - -voiderr99: ; preds = %after_check98, %voiderr90 - store [1 x i8]* bitcast ([2 x i8]* @.str.47 to [1 x i8]*), [1 x i8]** %taddr102, align 8 - %161 = bitcast [1 x i8]** %taddr102 to i8* - %162 = insertvalue %variant undef, i8* %161, 0 - %163 = insertvalue %variant %162, i64 ptrtoint (%.introspect* @"ct$p$a1$char" to i64), 1 - %164 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots101, i64 0, i64 0 - store %variant %163, %variant* %164, align 16 - store [3 x i8]* bitcast ([4 x i8]* @.str.48 to [3 x i8]*), [3 x i8]** %taddr103, align 8 - %165 = bitcast [3 x i8]** %taddr103 to i8* - %166 = insertvalue %variant undef, i8* %165, 0 - %167 = insertvalue %variant %166, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - %168 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots101, i64 0, i64 1 - store %variant %167, %variant* %168, align 16 - %169 = bitcast [2 x %variant]* %varargslots101 to %variant* - %170 = insertvalue %"variant[]" undef, %variant* %169, 0 - %171 = insertvalue %"variant[]" %170, i64 2, 1 - store %"variant[]" %171, %"variant[]"* %taddr104, align 8 - %172 = bitcast %"variant[]"* %taddr104 to { i8*, i64 }* - %173 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %172, i32 0, i32 0 - %lo105 = load i8*, i8** %173, align 8 - %174 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %172, i32 0, i32 1 - %hi106 = load i64, i64* %174, align 8 - %175 = call i64 @std_io_printfn(i64* %retparam100, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.46, i32 0, i32 0), i64 6, i8* %lo105, i64 %hi106) - %not_err107 = icmp eq i64 %175, 0 - br i1 %not_err107, label %after_check108, label %voiderr109 - -after_check108: ; preds = %voiderr99 - br label %voiderr109 - -voiderr109: ; preds = %after_check108, %voiderr99 - store [1 x i8]* bitcast ([2 x i8]* @.str.50 to [1 x i8]*), [1 x i8]** %taddr112, align 8 - %176 = bitcast [1 x i8]** %taddr112 to i8* - %177 = insertvalue %variant undef, i8* %176, 0 - %178 = insertvalue %variant %177, i64 ptrtoint (%.introspect* @"ct$p$a1$char" to i64), 1 - %179 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots111, i64 0, i64 0 - store %variant %178, %variant* %179, align 16 - store [5 x i8]* bitcast ([6 x i8]* @.str.51 to [5 x i8]*), [5 x i8]** %taddr113, align 8 - %180 = bitcast [5 x i8]** %taddr113 to i8* - %181 = insertvalue %variant undef, i8* %180, 0 - %182 = insertvalue %variant %181, i64 ptrtoint (%.introspect* @"ct$p$a5$char" to i64), 1 - %183 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots111, i64 0, i64 1 - store %variant %182, %variant* %183, align 16 - %184 = bitcast [2 x %variant]* %varargslots111 to %variant* - %185 = insertvalue %"variant[]" undef, %variant* %184, 0 - %186 = insertvalue %"variant[]" %185, i64 2, 1 - store %"variant[]" %186, %"variant[]"* %taddr114, align 8 - %187 = bitcast %"variant[]"* %taddr114 to { i8*, i64 }* - %188 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %187, i32 0, i32 0 - %lo115 = load i8*, i8** %188, align 8 - %189 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %187, i32 0, i32 1 - %hi116 = load i64, i64* %189, align 8 - %190 = call i64 @std_io_printfn(i64* %retparam110, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.49, i32 0, i32 0), i64 6, i8* %lo115, i64 %hi116) - %not_err117 = icmp eq i64 %190, 0 - br i1 %not_err117, label %after_check118, label %voiderr119 - -after_check118: ; preds = %voiderr109 - br label %voiderr119 - -voiderr119: ; preds = %after_check118, %voiderr109 - ret void -} - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i64, align 8 - %taddr1 = alloca %"variant[]", align 8 - %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [1 x %variant], align 16 - %taddr4 = alloca i64, align 8 - %taddr5 = alloca %"variant[]", align 8 - %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [2 x %variant], align 16 - %taddr13 = alloca i64, align 8 - %taddr14 = alloca i64, align 8 - %taddr15 = alloca %"variant[]", align 8 - %retparam21 = alloca i64, align 8 - %varargslots22 = alloca [2 x %variant], align 16 - %taddr23 = alloca i64, align 8 - %taddr24 = alloca i64, align 8 - %taddr25 = alloca %"variant[]", align 8 - %retparam31 = alloca i64, align 8 - %varargslots32 = alloca [2 x %variant], align 16 - %taddr33 = alloca i64, align 8 - %taddr34 = alloca i64, align 8 - %taddr35 = alloca %"variant[]", align 8 - %retparam41 = alloca i64, align 8 - %varargslots42 = alloca [2 x %variant], align 16 - %taddr43 = alloca i64, align 8 - %taddr44 = alloca i64, align 8 - %taddr45 = alloca %"variant[]", align 8 - %retparam51 = alloca i64, align 8 - %varargslots52 = alloca [2 x %variant], align 16 - %taddr53 = alloca i64, align 8 - %taddr54 = alloca i64, align 8 - %taddr55 = alloca %"variant[]", align 8 - %retparam61 = alloca i64, align 8 - %varargslots62 = alloca [2 x %variant], align 16 - %taddr63 = alloca i64, align 8 - %taddr64 = alloca i64, align 8 - %taddr65 = alloca %"variant[]", align 8 - %retparam71 = alloca i64, align 8 - %varargslots72 = alloca [2 x %variant], align 16 - %taddr73 = alloca i64, align 8 - %taddr74 = alloca i64, align 8 - %taddr75 = alloca %"variant[]", align 8 - %retparam81 = alloca i64, align 8 - %varargslots82 = alloca [1 x %variant], align 16 - %taddr83 = alloca i64, align 8 - %taddr84 = alloca %"variant[]", align 8 - %retparam90 = alloca i64, align 8 - %varargslots91 = alloca [2 x %variant], align 16 - %taddr92 = alloca i64, align 8 - %taddr93 = alloca i64, align 8 - %taddr94 = alloca %"variant[]", align 8 - store i64 4, i64* %taddr, align 8 - %0 = bitcast i64* %taddr to i8* - %1 = insertvalue %variant undef, i8* %0, 0 - %2 = insertvalue %variant %1, i64 ptrtoint (%.introspect* @"ct$long" to i64), 1 - %3 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %2, %variant* %3, align 16 - %4 = bitcast [1 x %variant]* %varargslots to %variant* - %5 = insertvalue %"variant[]" undef, %variant* %4, 0 - %6 = insertvalue %"variant[]" %5, i64 1, 1 - store %"variant[]" %6, %"variant[]"* %taddr1, align 8 - %7 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %8 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %7, i32 0, i32 0 - %lo = load i8*, i8** %8, align 8 - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %7, i32 0, i32 1 - %hi = load i64, i64* %9, align 8 - %10 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.52, i32 0, i32 0), i64 7, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %10, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - store i64 1, i64* %taddr4, align 8 - %11 = bitcast i64* %taddr4 to i8* - %12 = insertvalue %variant undef, i8* %11, 0 - %13 = insertvalue %variant %12, i64 ptrtoint (%.introspect* @"ct$long" to i64), 1 - %14 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots3, i64 0, i64 0 - store %variant %13, %variant* %14, align 16 - %15 = bitcast [1 x %variant]* %varargslots3 to %variant* - %16 = insertvalue %"variant[]" undef, %variant* %15, 0 - %17 = insertvalue %"variant[]" %16, i64 1, 1 - store %"variant[]" %17, %"variant[]"* %taddr5, align 8 - %18 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 0 - %lo6 = load i8*, i8** %19, align 8 - %20 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 1 - %hi7 = load i64, i64* %20, align 8 - %21 = call i64 @std_io_printfn(i64* %retparam2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.53, i32 0, i32 0), i64 7, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %21, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %voiderr - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %voiderr - store i64 0, i64* %taddr13, align 8 - %22 = bitcast i64* %taddr13 to i8* - %23 = insertvalue %variant undef, i8* %22, 0 - %24 = insertvalue %variant %23, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %25 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots12, i64 0, i64 0 - store %variant %24, %variant* %25, align 16 - store i64 4, i64* %taddr14, align 8 - %26 = bitcast i64* %taddr14 to i8* - %27 = insertvalue %variant undef, i8* %26, 0 - %28 = insertvalue %variant %27, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %29 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots12, i64 0, i64 1 - store %variant %28, %variant* %29, align 16 - %30 = bitcast [2 x %variant]* %varargslots12 to %variant* - %31 = insertvalue %"variant[]" undef, %variant* %30, 0 - %32 = insertvalue %"variant[]" %31, i64 2, 1 - store %"variant[]" %32, %"variant[]"* %taddr15, align 8 - %33 = bitcast %"variant[]"* %taddr15 to { i8*, i64 }* - %34 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %33, i32 0, i32 0 - %lo16 = load i8*, i8** %34, align 8 - %35 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %33, i32 0, i32 1 - %hi17 = load i64, i64* %35, align 8 - %36 = call i64 @std_io_printfn(i64* %retparam11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.54, i32 0, i32 0), i64 8, i8* %lo16, i64 %hi17) - %not_err18 = icmp eq i64 %36, 0 - br i1 %not_err18, label %after_check19, label %voiderr20 - -after_check19: ; preds = %voiderr10 - br label %voiderr20 - -voiderr20: ; preds = %after_check19, %voiderr10 - store i64 2, i64* %taddr23, align 8 - %37 = bitcast i64* %taddr23 to i8* - %38 = insertvalue %variant undef, i8* %37, 0 - %39 = insertvalue %variant %38, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %40 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots22, i64 0, i64 0 - store %variant %39, %variant* %40, align 16 - store i64 2, i64* %taddr24, align 8 - %41 = bitcast i64* %taddr24 to i8* - %42 = insertvalue %variant undef, i8* %41, 0 - %43 = insertvalue %variant %42, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %44 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots22, i64 0, i64 1 - store %variant %43, %variant* %44, align 16 - %45 = bitcast [2 x %variant]* %varargslots22 to %variant* - %46 = insertvalue %"variant[]" undef, %variant* %45, 0 - %47 = insertvalue %"variant[]" %46, i64 2, 1 - store %"variant[]" %47, %"variant[]"* %taddr25, align 8 - %48 = bitcast %"variant[]"* %taddr25 to { i8*, i64 }* - %49 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %48, i32 0, i32 0 - %lo26 = load i8*, i8** %49, align 8 - %50 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %48, i32 0, i32 1 - %hi27 = load i64, i64* %50, align 8 - %51 = call i64 @std_io_printfn(i64* %retparam21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.55, i32 0, i32 0), i64 8, i8* %lo26, i64 %hi27) - %not_err28 = icmp eq i64 %51, 0 - br i1 %not_err28, label %after_check29, label %voiderr30 - -after_check29: ; preds = %voiderr20 - br label %voiderr30 - -voiderr30: ; preds = %after_check29, %voiderr20 - store i64 4, i64* %taddr33, align 8 - %52 = bitcast i64* %taddr33 to i8* - %53 = insertvalue %variant undef, i8* %52, 0 - %54 = insertvalue %variant %53, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %55 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots32, i64 0, i64 0 - store %variant %54, %variant* %55, align 16 - store i64 4, i64* %taddr34, align 8 - %56 = bitcast i64* %taddr34 to i8* - %57 = insertvalue %variant undef, i8* %56, 0 - %58 = insertvalue %variant %57, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %59 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots32, i64 0, i64 1 - store %variant %58, %variant* %59, align 16 - %60 = bitcast [2 x %variant]* %varargslots32 to %variant* - %61 = insertvalue %"variant[]" undef, %variant* %60, 0 - %62 = insertvalue %"variant[]" %61, i64 2, 1 - store %"variant[]" %62, %"variant[]"* %taddr35, align 8 - %63 = bitcast %"variant[]"* %taddr35 to { i8*, i64 }* - %64 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %63, i32 0, i32 0 - %lo36 = load i8*, i8** %64, align 8 - %65 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %63, i32 0, i32 1 - %hi37 = load i64, i64* %65, align 8 - %66 = call i64 @std_io_printfn(i64* %retparam31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.56, i32 0, i32 0), i64 8, i8* %lo36, i64 %hi37) - %not_err38 = icmp eq i64 %66, 0 - br i1 %not_err38, label %after_check39, label %voiderr40 - -after_check39: ; preds = %voiderr30 - br label %voiderr40 - -voiderr40: ; preds = %after_check39, %voiderr30 - store i64 4, i64* %taddr43, align 8 - %67 = bitcast i64* %taddr43 to i8* - %68 = insertvalue %variant undef, i8* %67, 0 - %69 = insertvalue %variant %68, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %70 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots42, i64 0, i64 0 - store %variant %69, %variant* %70, align 16 - store i64 4, i64* %taddr44, align 8 - %71 = bitcast i64* %taddr44 to i8* - %72 = insertvalue %variant undef, i8* %71, 0 - %73 = insertvalue %variant %72, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %74 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots42, i64 0, i64 1 - store %variant %73, %variant* %74, align 16 - %75 = bitcast [2 x %variant]* %varargslots42 to %variant* - %76 = insertvalue %"variant[]" undef, %variant* %75, 0 - %77 = insertvalue %"variant[]" %76, i64 2, 1 - store %"variant[]" %77, %"variant[]"* %taddr45, align 8 - %78 = bitcast %"variant[]"* %taddr45 to { i8*, i64 }* - %79 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %78, i32 0, i32 0 - %lo46 = load i8*, i8** %79, align 8 - %80 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %78, i32 0, i32 1 - %hi47 = load i64, i64* %80, align 8 - %81 = call i64 @std_io_printfn(i64* %retparam41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.57, i32 0, i32 0), i64 8, i8* %lo46, i64 %hi47) - %not_err48 = icmp eq i64 %81, 0 - br i1 %not_err48, label %after_check49, label %voiderr50 - -after_check49: ; preds = %voiderr40 - br label %voiderr50 - -voiderr50: ; preds = %after_check49, %voiderr40 - store i64 4, i64* %taddr53, align 8 - %82 = bitcast i64* %taddr53 to i8* - %83 = insertvalue %variant undef, i8* %82, 0 - %84 = insertvalue %variant %83, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %85 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots52, i64 0, i64 0 - store %variant %84, %variant* %85, align 16 - store i64 4, i64* %taddr54, align 8 - %86 = bitcast i64* %taddr54 to i8* - %87 = insertvalue %variant undef, i8* %86, 0 - %88 = insertvalue %variant %87, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %89 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots52, i64 0, i64 1 - store %variant %88, %variant* %89, align 16 - %90 = bitcast [2 x %variant]* %varargslots52 to %variant* - %91 = insertvalue %"variant[]" undef, %variant* %90, 0 - %92 = insertvalue %"variant[]" %91, i64 2, 1 - store %"variant[]" %92, %"variant[]"* %taddr55, align 8 - %93 = bitcast %"variant[]"* %taddr55 to { i8*, i64 }* - %94 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %93, i32 0, i32 0 - %lo56 = load i8*, i8** %94, align 8 - %95 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %93, i32 0, i32 1 - %hi57 = load i64, i64* %95, align 8 - %96 = call i64 @std_io_printfn(i64* %retparam51, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.58, i32 0, i32 0), i64 9, i8* %lo56, i64 %hi57) - %not_err58 = icmp eq i64 %96, 0 - br i1 %not_err58, label %after_check59, label %voiderr60 - -after_check59: ; preds = %voiderr50 - br label %voiderr60 - -voiderr60: ; preds = %after_check59, %voiderr50 - store i64 5, i64* %taddr63, align 8 - %97 = bitcast i64* %taddr63 to i8* - %98 = insertvalue %variant undef, i8* %97, 0 - %99 = insertvalue %variant %98, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %100 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots62, i64 0, i64 0 - store %variant %99, %variant* %100, align 16 - store i64 1, i64* %taddr64, align 8 - %101 = bitcast i64* %taddr64 to i8* - %102 = insertvalue %variant undef, i8* %101, 0 - %103 = insertvalue %variant %102, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %104 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots62, i64 0, i64 1 - store %variant %103, %variant* %104, align 16 - %105 = bitcast [2 x %variant]* %varargslots62 to %variant* - %106 = insertvalue %"variant[]" undef, %variant* %105, 0 - %107 = insertvalue %"variant[]" %106, i64 2, 1 - store %"variant[]" %107, %"variant[]"* %taddr65, align 8 - %108 = bitcast %"variant[]"* %taddr65 to { i8*, i64 }* - %109 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %108, i32 0, i32 0 - %lo66 = load i8*, i8** %109, align 8 - %110 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %108, i32 0, i32 1 - %hi67 = load i64, i64* %110, align 8 - %111 = call i64 @std_io_printfn(i64* %retparam61, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.59, i32 0, i32 0), i64 9, i8* %lo66, i64 %hi67) - %not_err68 = icmp eq i64 %111, 0 - br i1 %not_err68, label %after_check69, label %voiderr70 - -after_check69: ; preds = %voiderr60 - br label %voiderr70 - -voiderr70: ; preds = %after_check69, %voiderr60 - store i64 8, i64* %taddr73, align 8 - %112 = bitcast i64* %taddr73 to i8* - %113 = insertvalue %variant undef, i8* %112, 0 - %114 = insertvalue %variant %113, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %115 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots72, i64 0, i64 0 - store %variant %114, %variant* %115, align 16 - store i64 4, i64* %taddr74, align 8 - %116 = bitcast i64* %taddr74 to i8* - %117 = insertvalue %variant undef, i8* %116, 0 - %118 = insertvalue %variant %117, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %119 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots72, i64 0, i64 1 - store %variant %118, %variant* %119, align 16 - %120 = bitcast [2 x %variant]* %varargslots72 to %variant* - %121 = insertvalue %"variant[]" undef, %variant* %120, 0 - %122 = insertvalue %"variant[]" %121, i64 2, 1 - store %"variant[]" %122, %"variant[]"* %taddr75, align 8 - %123 = bitcast %"variant[]"* %taddr75 to { i8*, i64 }* - %124 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %123, i32 0, i32 0 - %lo76 = load i8*, i8** %124, align 8 - %125 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %123, i32 0, i32 1 - %hi77 = load i64, i64* %125, align 8 - %126 = call i64 @std_io_printfn(i64* %retparam71, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.60, i32 0, i32 0), i64 10, i8* %lo76, i64 %hi77) - %not_err78 = icmp eq i64 %126, 0 - br i1 %not_err78, label %after_check79, label %voiderr80 - -after_check79: ; preds = %voiderr70 - br label %voiderr80 - -voiderr80: ; preds = %after_check79, %voiderr70 - store i64 4, i64* %taddr83, align 8 - %127 = bitcast i64* %taddr83 to i8* - %128 = insertvalue %variant undef, i8* %127, 0 - %129 = insertvalue %variant %128, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %130 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots82, i64 0, i64 0 - store %variant %129, %variant* %130, align 16 - %131 = bitcast [1 x %variant]* %varargslots82 to %variant* - %132 = insertvalue %"variant[]" undef, %variant* %131, 0 - %133 = insertvalue %"variant[]" %132, i64 1, 1 - store %"variant[]" %133, %"variant[]"* %taddr84, align 8 - %134 = bitcast %"variant[]"* %taddr84 to { i8*, i64 }* - %135 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %134, i32 0, i32 0 - %lo85 = load i8*, i8** %135, align 8 - %136 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %134, i32 0, i32 1 - %hi86 = load i64, i64* %136, align 8 - %137 = call i64 @std_io_printfn(i64* %retparam81, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.61, i32 0, i32 0), i64 7, i8* %lo85, i64 %hi86) - %not_err87 = icmp eq i64 %137, 0 - br i1 %not_err87, label %after_check88, label %voiderr89 - -after_check88: ; preds = %voiderr80 - br label %voiderr89 - -voiderr89: ; preds = %after_check88, %voiderr80 - store i64 8, i64* %taddr92, align 8 - %138 = bitcast i64* %taddr92 to i8* - %139 = insertvalue %variant undef, i8* %138, 0 - %140 = insertvalue %variant %139, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %141 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots91, i64 0, i64 0 - store %variant %140, %variant* %141, align 16 - store i64 4, i64* %taddr93, align 8 - %142 = bitcast i64* %taddr93 to i8* - %143 = insertvalue %variant undef, i8* %142, 0 - %144 = insertvalue %variant %143, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %145 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots91, i64 0, i64 1 - store %variant %144, %variant* %145, align 16 - %146 = bitcast [2 x %variant]* %varargslots91 to %variant* - %147 = insertvalue %"variant[]" undef, %variant* %146, 0 - %148 = insertvalue %"variant[]" %147, i64 2, 1 - store %"variant[]" %148, %"variant[]"* %taddr94, align 8 - %149 = bitcast %"variant[]"* %taddr94 to { i8*, i64 }* - %150 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %149, i32 0, i32 0 - %lo95 = load i8*, i8** %150, align 8 - %151 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %149, i32 0, i32 1 - %hi96 = load i64, i64* %151, align 8 - %152 = call i64 @std_io_printfn(i64* %retparam90, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.62, i32 0, i32 0), i64 10, i8* %lo95, i64 %hi96) - %not_err97 = icmp eq i64 %152, 0 - br i1 %not_err97, label %after_check98, label %voiderr99 - -after_check98: ; preds = %voiderr89 - br label %voiderr99 - -voiderr99: ; preds = %after_check98, %voiderr89 - call void @test_test(i32 10) - ret void -} diff --git a/test/test_suite14/compile_time/ct_switch.c3t b/test/test_suite14/compile_time/ct_switch.c3t deleted file mode 100644 index 125f74188..000000000 --- a/test/test_suite14/compile_time/ct_switch.c3t +++ /dev/null @@ -1,63 +0,0 @@ -// #target: macos-x64 - -module test; - -macro getisprime($x) -{ - $switch ($x): - $case 1: - $case 2: - $case 3: - $case 5: - $case 7: - $case 11: - $case 13: - return "prime"; - $case 4: - $case 6: - $case 8: - $case 9: - $case 10: - $case 12: - return "not_prime"; - $case 17: - $default: - return "donnowifprime"; - $endswitch; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - printf("%s\n", getisprime(3)); - printf("%s\n", getisprime(12)); - printf("%s\n", getisprime(4)); - printf("%s\n", getisprime(100)); - printf("%s\n", getisprime(17)); -} - -/* #expect: test.ll - -@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.1 = private unnamed_addr constant [6 x i8] c"prime\00", align 1 -@.str.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.3 = private unnamed_addr constant [10 x i8] c"not_prime\00", align 1 -@.str.4 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.5 = private unnamed_addr constant [10 x i8] c"not_prime\00", align 1 -@.str.6 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.7 = private unnamed_addr constant [14 x i8] c"donnowifprime\00", align 1 -@.str.8 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.9 = private unnamed_addr constant [14 x i8] c"donnowifprime\00", align 1 -; Function Attrs: nounwind -declare void @printf(i8*, ...) #0 -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), [5 x i8]* bitcast ([6 x i8]* @.str.1 to [5 x i8]*)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), [9 x i8]* bitcast ([10 x i8]* @.str.3 to [9 x i8]*)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), [9 x i8]* bitcast ([10 x i8]* @.str.5 to [9 x i8]*)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), [13 x i8]* bitcast ([14 x i8]* @.str.7 to [13 x i8]*)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), [13 x i8]* bitcast ([14 x i8]* @.str.9 to [13 x i8]*)) - ret void -} diff --git a/test/test_suite14/compile_time/ct_switch_errors.c3 b/test/test_suite14/compile_time/ct_switch_errors.c3 deleted file mode 100644 index 19bc289d8..000000000 --- a/test/test_suite14/compile_time/ct_switch_errors.c3 +++ /dev/null @@ -1,36 +0,0 @@ - -fn void test() -{ - $switch (3): - $case 2: - return; - $default: - $default: // #error: More than one $default is not allowed - return; - $endswitch; -} - -fn void test1() -{ - $switch (-1): - $case -1: - return; - $case -1: // #error: '-1' appears more than once - return; - $default: - return; - $endswitch; -} - - -fn void test3() -{ - $switch (3): - $case 3: - return; - $case 123.0: // #error: 'int' - return; - $default: - return; - $endswitch; -} \ No newline at end of file diff --git a/test/test_suite14/compile_time/ct_switch_more_checks.c3 b/test/test_suite14/compile_time/ct_switch_more_checks.c3 deleted file mode 100644 index 4f4abb444..000000000 --- a/test/test_suite14/compile_time/ct_switch_more_checks.c3 +++ /dev/null @@ -1,48 +0,0 @@ -module test; -import std::io; - -fn void foo() -{ - int a; - $switch ($typeof(a)): - $case int..float: // #error: $case ranges are only allowed for floats - io::println("Hello"); - $default: - io::println("World"); - $endswitch; -} - -fn void foo2() -{ - int a; - $switch ($typeof(a)): - $case true..false: // #error: $case ranges are only allowed - io::println("Hello"); - $default: - io::println("World"); - $endswitch; -} - -fn void foo3() -{ - int a; - $switch ({ 1, 3 }): // #error: Only types, strings, integers, floats and booleans - $case 1: - io::println("Hello"); - $default: - io::println("World"); - $endswitch; -} - -fn void main() -{ - int a; - $switch ("abc"): - $case "cde": - io::println("!!!"); - $case "abc": - io::println("Hello"); - $default: - io::println("World"); - $endswitch; -} diff --git a/test/test_suite14/compile_time/ct_switch_top_level.c3t b/test/test_suite14/compile_time/ct_switch_top_level.c3t deleted file mode 100644 index 5ffd7cf82..000000000 --- a/test/test_suite14/compile_time/ct_switch_top_level.c3t +++ /dev/null @@ -1,54 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn void printf(char*, ...); - -macro tester() -{ - var $Type = int; - $switch ($Type): - $case int: - printf("Hello\n"); - int z = 0; - $default: - int j = 213; - $endswitch; - -} -$switch (bool.typeid): -$case int: - int oefke = 23; -$default: - int oeoekgokege = 343432; -$endswitch; - -fn int main() -{ - tester(); - tester(); - int i = 1; - return 1; -} - -/* #expect: test.ll - -source_filename = "test" -target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-apple-darwin" - -@test_oeoekgokege = local_unnamed_addr global i32 343432, align 4 -@.str = private unnamed_addr constant [7 x i8] c"Hello\0A\00", align 1 -@.str.1 = private unnamed_addr constant [7 x i8] c"Hello\0A\00", align 1 - -define i32 @main() #0 { -entry: - %z = alloca i32, align 4 - %z1 = alloca i32, align 4 - %i = alloca i32, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0)) - store i32 0, i32* %z, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0)) - store i32 0, i32* %z1, align 4 - store i32 1, i32* %i, align 4 - ret i32 1 -} diff --git a/test/test_suite14/compile_time/ct_switch_type_check.c3t b/test/test_suite14/compile_time/ct_switch_type_check.c3t deleted file mode 100644 index da7da4389..000000000 --- a/test/test_suite14/compile_time/ct_switch_type_check.c3t +++ /dev/null @@ -1,44 +0,0 @@ -// #target: macos-x64 - -module test; - -macro get_type($Type) -{ - $switch ($Type.typeid): - $case int: - return "int"; - $case double: - return "double"; - $default: - return "any other"; - $endswitch; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - printf("%s\n", get_type(int)); - printf("%s\n", get_type(double)); - printf("%s\n", get_type(bool)); - -} - -/* #expect: test.ll - -@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.1 = private unnamed_addr constant [4 x i8] c"int\00", align 1 -@.str.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.3 = private unnamed_addr constant [7 x i8] c"double\00", align 1 -@.str.4 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.5 = private unnamed_addr constant [10 x i8] c"any other\00", align 1 -; Function Attrs: nounwind -declare void @printf(i8*, ...) #0 -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), [3 x i8]* bitcast ([4 x i8]* @.str.1 to [3 x i8]*)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), [6 x i8]* bitcast ([7 x i8]* @.str.3 to [6 x i8]*)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), [9 x i8]* bitcast ([10 x i8]* @.str.5 to [9 x i8]*)) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/compile_time/ct_switch_type_errors.c3 b/test/test_suite14/compile_time/ct_switch_type_errors.c3 deleted file mode 100644 index 2e1dd90e1..000000000 --- a/test/test_suite14/compile_time/ct_switch_type_errors.c3 +++ /dev/null @@ -1,51 +0,0 @@ - -fn void test() -{ - $switch (int.typeid): - $case int: - return; - $default: - $default: // #error: More than one $default is not allowed - return; - $endswitch; -} - -fn void test1() -{ - $switch (int.typeid): - $case int: - return; - $case int: // #error: 'int' appears more than once - return; - $default: - return; - $endswitch; -} - -define Foo = int; -define Bar = double; -fn void test2() -{ - $switch (int.typeid): - $case int: - return; - $case Bar: - return; - $case Foo: // #error: 'int' appears more than once - return; - $default: - return; - $endswitch; -} - -fn void test3() -{ - $switch (int.typeid): - $case int: - return; - $case 123: // #error: A type was expected here not 'int' - return; - $default: - return; - $endswitch; -} \ No newline at end of file diff --git a/test/test_suite14/compile_time/cttype_reassign.c3t b/test/test_suite14/compile_time/cttype_reassign.c3t deleted file mode 100644 index 6081a9191..000000000 --- a/test/test_suite14/compile_time/cttype_reassign.c3t +++ /dev/null @@ -1,15 +0,0 @@ -// #target: macos-x64 -module reassign; - -fn void test() -{ - var $Foo = double; - $Foo = int; - $Foo hello; -} - -// #expect: reassign.ll - - %hello = alloca i32, align 4 - store i32 0, i32* %hello, align 4 - ret void \ No newline at end of file diff --git a/test/test_suite14/compile_time/not_yet_initialized.c3 b/test/test_suite14/compile_time/not_yet_initialized.c3 deleted file mode 100644 index 2fbe0b136..000000000 --- a/test/test_suite14/compile_time/not_yet_initialized.c3 +++ /dev/null @@ -1,17 +0,0 @@ -macro foo($Foo) -{ - $Foo a; - return a; -} - -fn void test1() -{ - var $Bar; - foo($Bar); // #error: You need to assign a type to -} - -fn void test2() -{ - var $Bar; - $Bar z; // #error: You need to assign a type to -} diff --git a/test/test_suite14/compile_time/stringify.c3t b/test/test_suite14/compile_time/stringify.c3t deleted file mode 100644 index 7f1df621b..000000000 --- a/test/test_suite14/compile_time/stringify.c3t +++ /dev/null @@ -1,109 +0,0 @@ -// #target: macos-x64 -module test; -import libc; -import std::io; - -macro @timeit(#call) -{ - long t = (long)libc::clock(); - var $Type = $typeof(#call); - var $is_void = $Type.typeid == void.typeid; -$if ($is_void): - #call; -$else: - $Type result = #call; -$endif; - long diff = (long)libc::clock() - t; - libc::printf("'%s' took %lld us\n", $stringify(#call), diff); -$if (!$is_void): - return result; -$endif; -} - -fn void test() -{ - for (int i = 0; i < 1000; i++) libc::printf("%d\n", i); -} - -fn void main() -{ - @timeit(test()); - int a = 100; - int x = @timeit(1 + 3 + a); - libc::printf("Result was %d\n", x); -} - -/* #expect: test.ll - -@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 -@.str.1 = private unnamed_addr constant [19 x i8] c"'%s' took %lld us\0A\00", align 1 -@.str.2 = private unnamed_addr constant [7 x i8] c"test()\00", align 1 -@.str.3 = private unnamed_addr constant [19 x i8] c"'%s' took %lld us\0A\00", align 1 -@.str.4 = private unnamed_addr constant [10 x i8] c"1 + 3 + a\00", align 1 -@.str.5 = private unnamed_addr constant [15 x i8] c"Result was %d\0A\00", align 1 - -define void @test_test() #0 { -entry: - %i = alloca i32, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %0 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %0, 1000 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %1 = load i32, i32* %i, align 4 - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %1) - %3 = load i32, i32* %i, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret void -} - -define void @test_main() #0 { -entry: - %t = alloca i64, align 8 - %diff = alloca i64, align 8 - %a = alloca i32, align 4 - %x = alloca i32, align 4 - %t1 = alloca i64, align 8 - %result = alloca i32, align 4 - %diff2 = alloca i64, align 8 - %0 = call i64 @clock() - store i64 %0, i64* %t, align 8 - call void @test_test() - %1 = call i64 @clock() - %2 = load i64, i64* %t, align 8 - %sub = sub i64 %1, %2 - store i64 %sub, i64* %diff, align 8 - %3 = load i64, i64* %diff, align 8 - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i32 0, i32 0), [6 x i8]* bitcast ([7 x i8]* @.str.2 to [6 x i8]*), i64 %3) - store i32 100, i32* %a, align 4 - %5 = call i64 @clock() - store i64 %5, i64* %t1, align 8 - %6 = load i32, i32* %a, align 4 - %add = add i32 4, %6 - store i32 %add, i32* %result, align 4 - %7 = call i64 @clock() - %8 = load i64, i64* %t1, align 8 - %sub3 = sub i64 %7, %8 - store i64 %sub3, i64* %diff2, align 8 - %9 = load i64, i64* %diff2, align 8 - %10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i32 0, i32 0), [9 x i8]* bitcast ([10 x i8]* @.str.4 to [9 x i8]*), i64 %9) - %11 = load i32, i32* %result, align 4 - store i32 %11, i32* %x, align 4 - %12 = load i32, i32* %x, align 4 - %13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i32 0, i32 0), i32 %12) - ret void -} - -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @test_main() - ret i32 0 -} diff --git a/test/test_suite14/compile_time/stringify2.c3t b/test/test_suite14/compile_time/stringify2.c3t deleted file mode 100644 index ed8968e55..000000000 --- a/test/test_suite14/compile_time/stringify2.c3t +++ /dev/null @@ -1,20 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn void main() -{ - var $s1 = $stringify(1 + 2); - char[*] s2 = $stringify($s1); - char[] s3 = $s1; - - io::printfn("$s1 == %s", $s1); - io::printfn("s2 == %s", &s2); - io::printfn("s3 == %s", s3); -} - -/* #expect: test.ll - -c"$s1\00", align 1 -c"1 + 2\00", align 1 -c"1 + 2\00", align 1 \ No newline at end of file diff --git a/test/test_suite14/compile_time/ternary_folding.c3t b/test/test_suite14/compile_time/ternary_folding.c3t deleted file mode 100644 index b57db3ad4..000000000 --- a/test/test_suite14/compile_time/ternary_folding.c3t +++ /dev/null @@ -1,25 +0,0 @@ -// #target: macos-x64 - -int foo = 2.2 ? 1 : 2; -double bar = false ? 1.0 : 2; -bool baz = 1 ? false : true; - -fn void test() -{ - int x = 1 ? 0 : test2(); -} - -fn int test2() { return 3; } - -// #expect: ternary_folding.ll - -@ternary_folding_foo = local_unnamed_addr global i32 1, align 4 -@ternary_folding_bar = local_unnamed_addr global double 2.000000e+00, align 8 -@ternary_folding_baz = local_unnamed_addr global i8 0, align 1 - -define void @ternary_folding_test() #0 { -entry: - %x = alloca i32, align 4 - store i32 0, i32* %x, align 4 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/compile_time/typefrom.c3t b/test/test_suite14/compile_time/typefrom.c3t deleted file mode 100644 index 8955f105e..000000000 --- a/test/test_suite14/compile_time/typefrom.c3t +++ /dev/null @@ -1,15 +0,0 @@ -// #target: macos-x64 - -module test; - - -fn int main() -{ - var $foo = double.typeid; - $typefrom($foo) a = 123.0; - return (int)a; -} - -/* #expect: test.ll - - %a = alloca double, align 8 \ No newline at end of file diff --git a/test/test_suite14/compile_time/typefrom_errors.c3t b/test/test_suite14/compile_time/typefrom_errors.c3t deleted file mode 100644 index 37cb68d96..000000000 --- a/test/test_suite14/compile_time/typefrom_errors.c3t +++ /dev/null @@ -1,13 +0,0 @@ - -fn void test() -{ - typeid x; - $typefrom(2 > 1 ? int.typeid : double.typeid) xf; - $typefrom(x) a; // #error: Expected a constant -} - -fn void test2() -{ - var $x = 1; - $typefrom($x) a; // #error: Expected a constant -} \ No newline at end of file diff --git a/test/test_suite14/compile_time/typeof_example.c3t b/test/test_suite14/compile_time/typeof_example.c3t deleted file mode 100644 index 2c628ac56..000000000 --- a/test/test_suite14/compile_time/typeof_example.c3t +++ /dev/null @@ -1,54 +0,0 @@ -extern fn void printf(char *, ...); - -macro bitcast($Target, value) -{ - $typeof(value) temp = value; - $Target* result = ($Target*)(&temp); - return *result; -} - -fn void main() -{ - float f = 100; - int i = bitcast(int, f); - float f2 = bitcast(float, i); - printf("Bitcast %f to %d to %f", f, i, f2); -} - -/* #expect: typeof_example.ll - - %f = alloca float, align 4 - %i = alloca i32, align 4 - %value = alloca float, align 4 - %temp = alloca float, align 4 - %result = alloca i32*, align 8 - %f2 = alloca float, align 4 - %value1 = alloca i32, align 4 - %temp2 = alloca i32, align 4 - %result3 = alloca float*, align 8 - store float 1.000000e+02, float* %f, align 4 - %0 = load float, float* %f, align 4 - store float %0, float* %value, align 4 - %1 = load float, float* %value, align 4 - store float %1, float* %temp, align 4 - %ptrptr = bitcast float* %temp to i32* - store i32* %ptrptr, i32** %result, align 8 - %2 = load i32*, i32** %result, align 8 - %3 = load i32, i32* %2, align 4 - store i32 %3, i32* %i, align 4 - %4 = load i32, i32* %i, align 4 - store i32 %4, i32* %value1, align 4 - %5 = load i32, i32* %value1, align 4 - store i32 %5, i32* %temp2, align 4 - %ptrptr4 = bitcast i32* %temp2 to float* - store float* %ptrptr4, float** %result3, align 8 - %6 = load float*, float** %result3, align 8 - %7 = load float, float* %6, align 4 - store float %7, float* %f2, align 4 - %8 = load float, float* %f, align 4 - %fpfpext = fpext float %8 to double - %9 = load i32, i32* %i, align 4 - %10 = load float, float* %f2, align 4 - %fpfpext5 = fpext float %10 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), double %fpfpext, i32 %9, double %fpfpext5) - ret void \ No newline at end of file diff --git a/test/test_suite14/compile_time/typeof_from_literal.c3 b/test/test_suite14/compile_time/typeof_from_literal.c3 deleted file mode 100644 index e5deaa514..000000000 --- a/test/test_suite14/compile_time/typeof_from_literal.c3 +++ /dev/null @@ -1,14 +0,0 @@ -module foo; - -fn void a() -{ - $typeof(9146744073709551615i64) ef; - int fffx = ef; // #error: 'long' -} - -fn void b() -{ - $typeof(9223372036854775809u64) ef; - int fffx = ef; // #error: 'ulong' -} - diff --git a/test/test_suite14/compile_time/untyped_conversions.c3t b/test/test_suite14/compile_time/untyped_conversions.c3t deleted file mode 100644 index 4113e0029..000000000 --- a/test/test_suite14/compile_time/untyped_conversions.c3t +++ /dev/null @@ -1,137 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -struct Foo -{ - int a; int b; -} -fn void test(int[2] a, int[] b, int[<2>] c) -{ - io::printfn("%s %s %s", a, b, c); -} -fn void main() -{ - var $x = { { 1, 2 } }; - Foo[1] abc = (Foo[1])$x; - Foo def = (Foo)$x[0]; - int[2][1] y = (int[2][1])$x; - double[2][1] y2 = $x; - io::printfn("%s %s {%s, %s}", y, y2, def.a, def.b); - test({ 1, 2 }, { 3, 4}, { 5, 6 }); - var $a = { 2, 7 }; - test($a, $a, $a); -} - -/* #expect: test.ll - -entry: - %abc = alloca [1 x %Foo], align 4 - %def = alloca %Foo, align 4 - %y = alloca [1 x [2 x i32]], align 4 - %y2 = alloca [1 x [2 x double]], align 16 - %retparam = alloca i64, align 8 - %varargslots = alloca [4 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %literal = alloca [2 x i32], align 4 - %literal1 = alloca [2 x i32], align 4 - %taddr2 = alloca %"int[]", align 8 - %taddr5 = alloca <2 x i32>, align 8 - %literal6 = alloca [2 x i32], align 4 - %literal7 = alloca [2 x i32], align 4 - %taddr8 = alloca %"int[]", align 8 - %taddr11 = alloca <2 x i32>, align 8 - %0 = bitcast [1 x %Foo]* %abc to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([1 x %Foo]* @.__const to i8*), i32 8, i1 false) - %1 = bitcast %Foo* %def to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 bitcast (%Foo* @.__const.1 to i8*), i32 8, i1 false) - %2 = bitcast [1 x [2 x i32]]* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 4 bitcast ([1 x [2 x i32]]* @.__const.2 to i8*), i32 8, i1 false) - %3 = bitcast [1 x [2 x double]]* %y2 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %3, i8* align 16 bitcast ([1 x [2 x double]]* @.__const.3 to i8*), i32 16, i1 false) - %4 = bitcast [1 x [2 x i32]]* %y to i8* - %5 = insertvalue %variant undef, i8* %4, 0 - %6 = insertvalue %variant %5, i64 ptrtoint (%.introspect* @"ct$a1$a2$int" to i64), 1 - %7 = getelementptr inbounds [4 x %variant], [4 x %variant]* %varargslots, i64 0, i64 0 - store %variant %6, %variant* %7, align 16 - %8 = bitcast [1 x [2 x double]]* %y2 to i8* - %9 = insertvalue %variant undef, i8* %8, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (%.introspect* @"ct$a1$a2$double" to i64), 1 - %11 = getelementptr inbounds [4 x %variant], [4 x %variant]* %varargslots, i64 0, i64 1 - store %variant %10, %variant* %11, align 16 - %12 = getelementptr inbounds %Foo, %Foo* %def, i32 0, i32 0 - %13 = bitcast i32* %12 to i8* - %14 = insertvalue %variant undef, i8* %13, 0 - %15 = insertvalue %variant %14, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %16 = getelementptr inbounds [4 x %variant], [4 x %variant]* %varargslots, i64 0, i64 2 - store %variant %15, %variant* %16, align 16 - %17 = getelementptr inbounds %Foo, %Foo* %def, i32 0, i32 1 - %18 = bitcast i32* %17 to i8* - %19 = insertvalue %variant undef, i8* %18, 0 - %20 = insertvalue %variant %19, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %21 = getelementptr inbounds [4 x %variant], [4 x %variant]* %varargslots, i64 0, i64 3 - store %variant %20, %variant* %21, align 16 - %22 = bitcast [4 x %variant]* %varargslots to %variant* - %23 = insertvalue %"variant[]" undef, %variant* %22, 0 - %24 = insertvalue %"variant[]" %23, i64 4, 1 - store %"variant[]" %24, %"variant[]"* %taddr, align 8 - %25 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %26 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %25, i32 0, i32 0 - %lo = load i8*, i8** %26, align 8 - %27 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %25, i32 0, i32 1 - %hi = load i64, i64* %27, align 8 - %28 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i64 14, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %28, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %29 = getelementptr inbounds [2 x i32], [2 x i32]* %literal, i64 0, i64 0 - store i32 1, i32* %29, align 4 - %30 = getelementptr inbounds [2 x i32], [2 x i32]* %literal, i64 0, i64 1 - store i32 2, i32* %30, align 4 - %31 = bitcast [2 x i32]* %literal to i64* - %32 = load i64, i64* %31, align 4 - %33 = getelementptr inbounds [2 x i32], [2 x i32]* %literal1, i64 0, i64 0 - store i32 3, i32* %33, align 4 - %34 = getelementptr inbounds [2 x i32], [2 x i32]* %literal1, i64 0, i64 1 - store i32 4, i32* %34, align 4 - %35 = bitcast [2 x i32]* %literal1 to i32* - %36 = insertvalue %"int[]" undef, i32* %35, 0 - %37 = insertvalue %"int[]" %36, i64 2, 1 - store %"int[]" %37, %"int[]"* %taddr2, align 8 - %38 = bitcast %"int[]"* %taddr2 to { i8*, i64 }* - %39 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %38, i32 0, i32 0 - %lo3 = load i8*, i8** %39, align 8 - %40 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %38, i32 0, i32 1 - %hi4 = load i64, i64* %40, align 8 - store <2 x i32> , <2 x i32>* %taddr5, align 8 - %41 = bitcast <2 x i32>* %taddr5 to double* - %42 = load double, double* %41, align 8 - call void @test_test(i64 %32, i8* %lo3, i64 %hi4, double %42) - %43 = getelementptr inbounds [2 x i32], [2 x i32]* %literal6, i64 0, i64 0 - store i32 2, i32* %43, align 4 - %44 = getelementptr inbounds [2 x i32], [2 x i32]* %literal6, i64 0, i64 1 - store i32 7, i32* %44, align 4 - %45 = bitcast [2 x i32]* %literal6 to i64* - %46 = load i64, i64* %45, align 4 - %47 = getelementptr inbounds [2 x i32], [2 x i32]* %literal7, i64 0, i64 0 - store i32 2, i32* %47, align 4 - %48 = getelementptr inbounds [2 x i32], [2 x i32]* %literal7, i64 0, i64 1 - store i32 7, i32* %48, align 4 - %49 = bitcast [2 x i32]* %literal7 to i32* - %50 = insertvalue %"int[]" undef, i32* %49, 0 - %51 = insertvalue %"int[]" %50, i64 2, 1 - store %"int[]" %51, %"int[]"* %taddr8, align 8 - %52 = bitcast %"int[]"* %taddr8 to { i8*, i64 }* - %53 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %52, i32 0, i32 0 - %lo9 = load i8*, i8** %53, align 8 - %54 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %52, i32 0, i32 1 - %hi10 = load i64, i64* %54, align 8 - store <2 x i32> , <2 x i32>* %taddr11, align 8 - %55 = bitcast <2 x i32>* %taddr11 to double* - %56 = load double, double* %55, align 8 - call void @test_test(i64 %46, i8* %lo9, i64 %hi10, double %56) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/compile_time_introspection/alignof.c3t b/test/test_suite14/compile_time_introspection/alignof.c3t deleted file mode 100644 index c3f585a55..000000000 --- a/test/test_suite14/compile_time_introspection/alignof.c3t +++ /dev/null @@ -1,65 +0,0 @@ -// #target: macos-x64 -module foo; - -int[100] zfe; -struct Bob -{ - Bob[] x; - char[100] y; - struct w { - int z; - } -} - -union Ex -{ - char[8] c; - int[2] y; - double z; -} - -union Br -{ - int y; - char x; -} -struct Ar -{ - long z; - Br[10] br; -} - -union Foob -{ - long a; - char[8] c; -} -Ar izzy; - -long x = $alignof(zfe); -short y = Bob.y.alignof; -int z = Bob.w.z.alignof; -int v = $alignof(v); -int x1 = Ex.c.alignof; -int x2 = Ex.y.alignof; -int x3 = char[8].alignof; -int x9 = $alignof(izzy.br[1]); -int x10 = $alignof(izzy.br[1]); -int x11 = $alignof(izzy.br[1]); -int z0 = Foob.c.alignof; - - - -/* #expect: foo.ll - -@foo_x = local_unnamed_addr global i64 16, align 8 -@foo_y = local_unnamed_addr global i16 8, align 2 -@foo_z = local_unnamed_addr global i32 4, align 4 -@foo_v = local_unnamed_addr global i32 4, align 4 -@foo_x1 = local_unnamed_addr global i32 8, align 4 -@foo_x2 = local_unnamed_addr global i32 8, align 4 -@foo_x3 = local_unnamed_addr global i32 1, align 4 -@foo_x9 = local_unnamed_addr global i32 4, align 4 -@foo_x10 = local_unnamed_addr global i32 4, align 4 -@foo_x11 = local_unnamed_addr global i32 4, align 4 -@foo_z0 = local_unnamed_addr global i32 8, align 4 diff --git a/test/test_suite14/compile_time_introspection/defined.c3t b/test/test_suite14/compile_time_introspection/defined.c3t deleted file mode 100644 index ed7146453..000000000 --- a/test/test_suite14/compile_time_introspection/defined.c3t +++ /dev/null @@ -1,97 +0,0 @@ -// #target: macos-x64 - -module mymodule; - -extern fn void printf(char *, ...); - -struct Foo -{ - int a; - int ab; - struct bob - { - int j; - } -} -fn void main() -{ - int x = 0; - var $counter = 0; - $if ($defined(x)): - x++; - $counter++; - $endif; - $if ($defined(Foo.ab)): - int y = 10; - $counter++; - x++; - $endif; - $if ($defined(Foo.ab.x)): - x = 0; - $counter = 0; - $endif; - $if ($defined(Foo.bob)): - x++; - $counter++; - $endif; - $if ($defined($eval("x"))): - x++; - $counter++; - $endif; - $if ($defined($evaltype("Foo").$eval("ab"))): - x++; - $counter++; - $endif; - $if ($defined($evaltype("mymodule::Foo").$eval("bob"))): - x++; - $counter++; - $endif; - $if ($defined(y)): - x++; - $counter++; - y = 1; - $endif; - $if ($defined(z)): - $counter = 0; - x = 0; - $endif; - int z = $counter; - printf("%d\n", x); -} - -// #expect: mymodule.ll - -define void @mymodule_main() #0 { -entry: - %x = alloca i32, align 4 - %y = alloca i32, align 4 - %z = alloca i32, align 4 - store i32 0, i32* %x, align 4 - %0 = load i32, i32* %x, align 4 - %add = add i32 %0, 1 - store i32 %add, i32* %x, align 4 - store i32 10, i32* %y, align 4 - %1 = load i32, i32* %x, align 4 - %add1 = add i32 %1, 1 - store i32 %add1, i32* %x, align 4 - %2 = load i32, i32* %x, align 4 - %add2 = add i32 %2, 1 - store i32 %add2, i32* %x, align 4 - %3 = load i32, i32* %x, align 4 - %add3 = add i32 %3, 1 - store i32 %add3, i32* %x, align 4 - %4 = load i32, i32* %x, align 4 - %add4 = add i32 %4, 1 - store i32 %add4, i32* %x, align 4 - %5 = load i32, i32* %x, align 4 - %add5 = add i32 %5, 1 - store i32 %add5, i32* %x, align 4 - %6 = load i32, i32* %x, align 4 - %add6 = add i32 %6, 1 - store i32 %add6, i32* %x, align 4 - store i32 1, i32* %y, align 4 - store i32 7, i32* %z, align 4 - %7 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %7) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/compile_time_introspection/defined_builtin.c3t b/test/test_suite14/compile_time_introspection/defined_builtin.c3t deleted file mode 100644 index 9acaede32..000000000 --- a/test/test_suite14/compile_time_introspection/defined_builtin.c3t +++ /dev/null @@ -1,18 +0,0 @@ -// #target: macos-x64 -module foo; -fn void test() -{ - bool a = $defined($$sin); - bool b = $defined($$bas); -} - -/* #expect: foo.ll - -define void @foo_test() #0 { -entry: - %a = alloca i8, align 1 - %b = alloca i8, align 1 - store i8 1, i8* %a, align 1 - store i8 0, i8* %b, align 1 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/compile_time_introspection/defined_err.c3 b/test/test_suite14/compile_time_introspection/defined_err.c3 deleted file mode 100644 index ae06b4be9..000000000 --- a/test/test_suite14/compile_time_introspection/defined_err.c3 +++ /dev/null @@ -1,25 +0,0 @@ -fn void test1() -{ - bool x = $defined(1); // #error: Expected an identifier here -} - -struct Foo -{ - int x; -} - -fn void test2() -{ - $assert($defined(int[1])); - bool x = $defined(int[y]); // #error: 'y' could not be found, did you spell it right? -} - -fn void test3() -{ - $assert($defined(Foo[1])); - $assert($defined(Foo*)); - $assert($defined(Foo[])); - $assert($defined(Foo[*])); - bool x = $defined(Foo[y]); // #error: 'y' could not be found, did you spell it right? -} - diff --git a/test/test_suite14/compile_time_introspection/nameof.c3t b/test/test_suite14/compile_time_introspection/nameof.c3t deleted file mode 100644 index eafd32cad..000000000 --- a/test/test_suite14/compile_time_introspection/nameof.c3t +++ /dev/null @@ -1,68 +0,0 @@ -// #target: macos-x64 -module mymodule; - -extern fn void printf(char *, ...); - -struct Foo { int y; } - -int b; - -fn void main() -{ - printf("%s\n", Foo.qnameof); - printf("%s\n", $evaltype("Foo").qnameof); - printf("%s\n", Foo.nameof); - printf("%s\n", $evaltype("mymodule::Foo").nameof); - printf("%s\n", Foo.extnameof); - printf("%s\n", $evaltype("Foo").extnameof); - - printf("%s\n", $qnameof(b)); - printf("%s\n", $qnameof($eval("b"))); - printf("%s\n", $nameof(b)); - printf("%s\n", $nameof($eval("mymodule::b"))); - printf("%s\n", $extnameof(b)); - printf("%s\n", $extnameof($eval("b"))); - - int a; - - printf("%s\n", $qnameof(a)); - printf("%s\n", $qnameof($eval("a"))); - printf("%s\n", $nameof(a)); - printf("%s\n", $nameof($eval("a"))); - -} - -/* #expect: mymodule.ll - -@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.1 = private unnamed_addr constant [14 x i8] c"mymodule::Foo\00", align 1 -@.str.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.3 = private unnamed_addr constant [14 x i8] c"mymodule::Foo\00", align 1 -@.str.4 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.5 = private unnamed_addr constant [4 x i8] c"Foo\00", align 1 -@.str.6 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.7 = private unnamed_addr constant [4 x i8] c"Foo\00", align 1 -@.str.8 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.9 = private unnamed_addr constant [13 x i8] c"mymodule_Foo\00", align 1 -@.str.10 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.11 = private unnamed_addr constant [13 x i8] c"mymodule_Foo\00", align 1 -@.str.12 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.13 = private unnamed_addr constant [12 x i8] c"mymodule::b\00", align 1 -@.str.14 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.15 = private unnamed_addr constant [12 x i8] c"mymodule::b\00", align 1 -@.str.16 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.17 = private unnamed_addr constant [2 x i8] c"b\00", align 1 -@.str.18 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.19 = private unnamed_addr constant [2 x i8] c"b\00", align 1 -@.str.20 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.21 = private unnamed_addr constant [11 x i8] c"mymodule_b\00", align 1 -@.str.22 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.23 = private unnamed_addr constant [11 x i8] c"mymodule_b\00", align 1 -@.str.24 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.25 = private unnamed_addr constant [2 x i8] c"a\00", align 1 -@.str.26 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.27 = private unnamed_addr constant [2 x i8] c"a\00", align 1 -@.str.28 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.29 = private unnamed_addr constant [2 x i8] c"a\00", align 1 -@.str.30 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 -@.str.31 = private unnamed_addr constant [2 x i8] c"a\00", align 1 \ No newline at end of file diff --git a/test/test_suite14/compile_time_introspection/nameof_err.c3 b/test/test_suite14/compile_time_introspection/nameof_err.c3 deleted file mode 100644 index 0de24c9ee..000000000 --- a/test/test_suite14/compile_time_introspection/nameof_err.c3 +++ /dev/null @@ -1,20 +0,0 @@ -fn void main() -{ - int a; - $extnameof(a); // #error: 'a' does not have an external name. -} -fn void main2() -{ - int a; - $extnameof($eval("a")); // #error: 'a' does not have an external name. -} - -fn void main3() -{ - $evaltype("int").extnameof; // #error: 'int' does not have a property 'extnameof' -} - -fn void main4() -{ - $evaltype("foo::int").extnameof; // #error: Only valid types may be resolved with $evaltype. -} diff --git a/test/test_suite14/compile_time_introspection/offsetof.c3t b/test/test_suite14/compile_time_introspection/offsetof.c3t deleted file mode 100644 index 915dbaa64..000000000 --- a/test/test_suite14/compile_time_introspection/offsetof.c3t +++ /dev/null @@ -1,50 +0,0 @@ -// #target: macos-x64 -module foo; - -int[100] zfe; -struct Bob -{ - Bob[] x; - char[100] y; - struct w { - int z; - } -} - -union Ex -{ - char[8] c; - int[2] y; - double z; -} - -struct Br -{ - int y; - char x; -} -struct Ar -{ - long z; - Br[10] br; -} - -union Foob -{ - long a; - char[8] c; -} - - -short y = Bob.y.offsetof; -int z = Bob.w.z.offsetof; -int w = Bob.w.offsetof; -int z0 = Foob.c.offsetof; -int z03 = Foob.a.offsetof; - -// #expect: foo.ll -@foo_y = local_unnamed_addr global i16 16, align 2 -@foo_z = local_unnamed_addr global i32 116, align 4 -@foo_w = local_unnamed_addr global i32 116, align 4 -@foo_z0 = local_unnamed_addr global i32 0, align 4 -@foo_z03 = local_unnamed_addr global i32 0, align 4 diff --git a/test/test_suite14/compile_time_introspection/qnameof.c3t b/test/test_suite14/compile_time_introspection/qnameof.c3t deleted file mode 100644 index 2cdb4fdc2..000000000 --- a/test/test_suite14/compile_time_introspection/qnameof.c3t +++ /dev/null @@ -1,55 +0,0 @@ -module qnametest; - -extern fn int printf(char *, ...); -int x; - -struct Blob { int z; int f; } - -fn void main() -{ - int help; - printf("printf: %s\n", $nameof(printf)); - printf("printfq: %s\n", $qnameof(printf)); - printf("Blobq: %s\n", Blob.qnameof); - printf("Blob: %s\n", Blob.nameof); - printf("xq: %s\n", $qnameof(x)); - printf("x: %s\n", $nameof(x)); - printf("helpq: %s\n", $qnameof(help)); - printf("mainq: %s\n", $qnameof(main)); - printf("Blob**[3]: %s\n", Blob**[3].nameof); -} - -// #expect: qnametest.ll - -@.str = private unnamed_addr constant [12 x i8] c"printf: %s\0A\00", align 1 -@.str.1 = private unnamed_addr constant [7 x i8] c"printf\00", align 1 -@.str.2 = private unnamed_addr constant [13 x i8] c"printfq: %s\0A\00", align 1 -@.str.3 = private unnamed_addr constant [18 x i8] c"qnametest::printf\00", align 1 -@.str.4 = private unnamed_addr constant [11 x i8] c"Blobq: %s\0A\00", align 1 -@.str.5 = private unnamed_addr constant [16 x i8] c"qnametest::Blob\00", align 1 -@.str.6 = private unnamed_addr constant [10 x i8] c"Blob: %s\0A\00", align 1 -@.str.7 = private unnamed_addr constant [5 x i8] c"Blob\00", align 1 -@.str.8 = private unnamed_addr constant [8 x i8] c"xq: %s\0A\00", align 1 -@.str.9 = private unnamed_addr constant [13 x i8] c"qnametest::x\00", align 1 -@.str.10 = private unnamed_addr constant [7 x i8] c"x: %s\0A\00", align 1 -@.str.11 = private unnamed_addr constant [2 x i8] c"x\00", align 1 -@.str.12 = private unnamed_addr constant [11 x i8] c"helpq: %s\0A\00", align 1 -@.str.13 = private unnamed_addr constant [5 x i8] c"help\00", align 1 -@.str.14 = private unnamed_addr constant [11 x i8] c"mainq: %s\0A\00", align 1 -@.str.15 = private unnamed_addr constant [16 x i8] c"qnametest::main\00", align 1 -@.str.16 = private unnamed_addr constant [15 x i8] c"Blob**[3]: %s\0A\00", align 1 -@.str.17 = private unnamed_addr constant [10 x i8] c"Blob**[3]\00", align 1 - -define void @qnametest_main() - %help = alloca i32, align 4 - store i32 0, i32* %help, align 4 - %0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), [6 x i8]* bitcast ([7 x i8]* @.str.1 to [6 x i8]*)) - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0), [17 x i8]* bitcast ([18 x i8]* @.str.3 to [17 x i8]*)) - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), [15 x i8]* bitcast ([16 x i8]* @.str.5 to [15 x i8]*)) - %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), [4 x i8]* bitcast ([5 x i8]* @.str.7 to [4 x i8]*)) - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), [12 x i8]* bitcast ([13 x i8]* @.str.9 to [12 x i8]*)) - %5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i32 0, i32 0), [1 x i8]* bitcast ([2 x i8]* @.str.11 to [1 x i8]*)) - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i32 0, i32 0), [4 x i8]* bitcast ([5 x i8]* @.str.13 to [4 x i8]*)) - %7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i32 0, i32 0), [15 x i8]* bitcast ([16 x i8]* @.str.15 to [15 x i8]*)) - %8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i32 0, i32 0), [9 x i8]* bitcast ([10 x i8]* @.str.17 to [9 x i8]*)) - ret void diff --git a/test/test_suite14/compile_time_introspection/sizeof.c3t b/test/test_suite14/compile_time_introspection/sizeof.c3t deleted file mode 100644 index 2a5bfb30c..000000000 --- a/test/test_suite14/compile_time_introspection/sizeof.c3t +++ /dev/null @@ -1,65 +0,0 @@ -module foo; -import bar; - -long x = Baz.sizeof; -short y = $evaltype("Baz").sizeof; -int z = bar::Baz.sizeof; -int w = bar::Baz.sizeof; -int v = bar::abc::Foo.sizeof; -int x1 = $sizeof(x); -int y1 = $sizeof($eval("y")); -int a = Baz.y.sizeof; -int b = $evaltype("Deep").a.$eval("b").sizeof; -int c = Deep.a.b.c.sizeof; -int d = Deep[][100].sizeof; -int e = $evaltype("Deep")[][100]**[100][]*.sizeof; -int a2 = Baz.y.sizeof; -int a3 = Baz.y.sizeof; -int a4 = Baz.y.sizeof; -int a5 = Baz.y.sizeof; - -module bar; - -struct Deep -{ - int x; - struct a - { - struct b - { - char[5] c; - } - } -} - -struct Baz -{ - int x; - char[60] y; -} - -module bar::abc; - -struct Foo -{ - char x; -} - -// #expect: foo.ll - -@foo_x = local_unnamed_addr global i64 64, align 8 -@foo_y = local_unnamed_addr global i16 64, align 2 -@foo_z = local_unnamed_addr global i32 64, align 4 -@foo_w = local_unnamed_addr global i32 64, align 4 -@foo_v = local_unnamed_addr global i32 1, align 4 -@foo_x1 = local_unnamed_addr global i32 8, align 4 -@foo_y1 = local_unnamed_addr global i32 2, align 4 -@foo_a = local_unnamed_addr global i32 60, align 4 -@foo_b = local_unnamed_addr global i32 5, align 4 -@foo_c = local_unnamed_addr global i32 5, align 4 -@foo_d = local_unnamed_addr global i32 1600, align 4 -@foo_e = local_unnamed_addr global i32 8, align 4 -@foo_a2 = local_unnamed_addr global i32 60, align 4 -@foo_a3 = local_unnamed_addr global i32 60, align 4 -@foo_a4 = local_unnamed_addr global i32 60, align 4 -@foo_a5 = local_unnamed_addr global i32 60, align 4 \ No newline at end of file diff --git a/test/test_suite14/compile_time_introspection/sizeof_errors.c3 b/test/test_suite14/compile_time_introspection/sizeof_errors.c3 deleted file mode 100644 index 1496dc056..000000000 --- a/test/test_suite14/compile_time_introspection/sizeof_errors.c3 +++ /dev/null @@ -1,66 +0,0 @@ -module foo; -import bar; - -fn void a() -{ - int x = Bazy.sizeof; // #error: 'Bazy' could not be found, did you spell it right -} - -fn void b() -{ - int x = $evaltype("Bazz").sizeof; // #error: 'Bazz' could not be found, did you spell it rig -} - - -fn void e() -{ - int x = bar::Baze.sizeof; // #error: 'bar::Baze' could not be found, did you spell it right -} - -fn void f() -{ - int x = $evaltype("bar::Bazy").sizeof; // #error: 'bar::Bazy' could not be found -} - -fn void g() -{ - int x = $evaltype("bar::").sizeof; // #error: Only valid types may be resolved with $evaltype -} - -fn void k() -{ - int v = $evaltype("int").x.sizeof; // #error: 'int' does not have a property 'x'. -} - -fn void l() -{ - int v = $sizeof(int[].len); // #error: 'int[]' does not have a property 'len' -} - -fn void m() -{ - int v = $sizeof(int[4].len); -} - -fn void n() -{ - int v = Baz.x1.sizeof; // #error: No method or inner struct/union 'Baz.x1' found. -} - - - -module bar; - -struct Baz -{ - int x; - char[60] y; -} - -module bar::abc; - -struct Foo -{ - char x; -} - diff --git a/test/test_suite14/constants/byte_literal_fail_base64.c3 b/test/test_suite14/constants/byte_literal_fail_base64.c3 deleted file mode 100644 index ce3837ea6..000000000 --- a/test/test_suite14/constants/byte_literal_fail_base64.c3 +++ /dev/null @@ -1 +0,0 @@ -char[*] foo64 = b64"SGVsbG8g!V29ybGQ="; // #error: '!' is not a valid base64 character \ No newline at end of file diff --git a/test/test_suite14/constants/byte_literal_fail_base64_2.c3 b/test/test_suite14/constants/byte_literal_fail_base64_2.c3 deleted file mode 100644 index 443883c14..000000000 --- a/test/test_suite14/constants/byte_literal_fail_base64_2.c3 +++ /dev/null @@ -1 +0,0 @@ -char[*] foo64 = b64"SGVsbG8gV29y=bGQ="; // #error: 'b' can't be placed after an ending '=' \ No newline at end of file diff --git a/test/test_suite14/constants/byte_literal_fail_base64_4.c3 b/test/test_suite14/constants/byte_literal_fail_base64_4.c3 deleted file mode 100644 index ab8705d22..000000000 --- a/test/test_suite14/constants/byte_literal_fail_base64_4.c3 +++ /dev/null @@ -1 +0,0 @@ -char[*] foo64 = b64"SGVsbG8gV29ybGQ==="; // #error: There cannot be more than \ No newline at end of file diff --git a/test/test_suite14/constants/byte_literal_fail_hex.c3 b/test/test_suite14/constants/byte_literal_fail_hex.c3 deleted file mode 100644 index 115e3d4ba..000000000 --- a/test/test_suite14/constants/byte_literal_fail_hex.c3 +++ /dev/null @@ -1 +0,0 @@ -char[*] foo64 = x"abc def ^"; // #error: '^' isn't a valid hexadecimal digit, all digits should be a-z, A-Z and 0-9. diff --git a/test/test_suite14/constants/byte_literals.c3t b/test/test_suite14/constants/byte_literals.c3t deleted file mode 100644 index 211c5974c..000000000 --- a/test/test_suite14/constants/byte_literals.c3t +++ /dev/null @@ -1,13 +0,0 @@ -char[*] foob = x"a0"; -char[*] fooz = x"00aabbccddeeff"; -char[*] fooy = x'dead beef'; -char[*] foow = x"4549234d e d"; -char[*] foo64 = b64"SGVsbG8gV29ybGQ="; - -// #expect: byte_literals.ll - -@byte_literals_foob = local_unnamed_addr global [1 x i8] c"\A0", align 1 -@byte_literals_fooz = local_unnamed_addr global [7 x i8] c"\00\AA\BB\CC\DD\EE\FF", align 1 -@byte_literals_fooy = local_unnamed_addr global [4 x i8] c"\DE\AD\BE\EF", align 1 -@byte_literals_foow = local_unnamed_addr global [5 x i8] c"EI#M\ED", align 1 -@byte_literals_foo64 = local_unnamed_addr global [11 x i8] c"Hello World", align 1 diff --git a/test/test_suite14/constants/char_literals.c3t b/test/test_suite14/constants/char_literals.c3t deleted file mode 100644 index a4ed8ce35..000000000 --- a/test/test_suite14/constants/char_literals.c3t +++ /dev/null @@ -1,24 +0,0 @@ -// #file: file1.c3 -module test; - -char a = ' '; -char b = '\r'; -char c = '\t'; -char d = '\n'; -char e = '\0'; -char f = '\''; -char g = '"'; -char h = '\\'; -char i = '\e'; - -// #expect: test.ll - -@test_a = local_unnamed_addr global i8 32, align 1 -@test_b = local_unnamed_addr global i8 13, align 1 -@test_c = local_unnamed_addr global i8 9, align 1 -@test_d = local_unnamed_addr global i8 10, align 1 -@test_e = local_unnamed_addr global i8 0, align 1 -@test_f = local_unnamed_addr global i8 39, align 1 -@test_g = local_unnamed_addr global i8 34, align 1 -@test_h = local_unnamed_addr global i8 92, align 1 -@test_i = local_unnamed_addr global i8 27, align 1 diff --git a/test/test_suite14/constants/const_var_copy.c3t b/test/test_suite14/constants/const_var_copy.c3t deleted file mode 100644 index d2c1dcd8e..000000000 --- a/test/test_suite14/constants/const_var_copy.c3t +++ /dev/null @@ -1,29 +0,0 @@ -// #target: macos-x64 -module foo; -const char[100] FOO = { [50] = 1 }; -const int[<4>] BAR = { 1, 2, 3, 4 }; - -fn void test(int z) -{ - char s = FOO[z]; - int zd = BAR[z]; -} - -/* #expect: foo.ll - -@foo_FOO = local_unnamed_addr constant { [50 x i8], i8, [49 x i8] } { [50 x i8] zeroinitializer, i8 1, [49 x i8] zeroinitializer }, align 16 -@foo_BAR = local_unnamed_addr constant <4 x i32> , align 16 - -define void @foo_test(i32 %0) #0 { -entry: - %s = alloca i8, align 1 - %zd = alloca i32, align 4 - %sisiext = sext i32 %0 to i64 - %1 = getelementptr inbounds [100 x i8], [100 x i8]* bitcast ({ [50 x i8], i8, [49 x i8] }* @foo_FOO to [100 x i8]*), i64 0, i64 %sisiext - %2 = load i8, i8* %1, align 1 - store i8 %2, i8* %s, align 1 - %sisiext1 = sext i32 %0 to i64 - %3 = extractelement <4 x i32> , i64 %sisiext1 - store i32 %3, i32* %zd, align 4 - ret void -} diff --git a/test/test_suite14/constants/constants.c3t b/test/test_suite14/constants/constants.c3t deleted file mode 100644 index b91366f98..000000000 --- a/test/test_suite14/constants/constants.c3t +++ /dev/null @@ -1,39 +0,0 @@ -private const char AA = ~(char)(0); -const char BB = 200 ; -private const uint CC = ~(uint)(0); -private const uint DD = FOO; - -private const FOO = ~(uint)(0); - -private uint x = AA; -private uint z = CC; -private char w = (char)(FOO); -private ushort v = (ushort)(FOO); -private uint z2 = DD; - -fn void test() -{ - int xx = (int)FOO; - uint* yy = &&FOO; -} - -// #expect: constants.ll - -@constants_AA = protected unnamed_addr constant i8 -1, align 1 -@constants_BB = local_unnamed_addr constant i8 -56, align 1 -@constants_CC = protected unnamed_addr constant i32 -1, align 4 -@constants_DD = protected unnamed_addr constant i32 -1, align 4 -@constants_x = protected unnamed_addr global i32 255, align 4 -@constants_z = protected unnamed_addr global i32 -1, align 4 -@constants_w = protected unnamed_addr global i8 -1, align 1 -@constants_v = protected unnamed_addr global i16 -1, align 2 -@constants_z2 = protected unnamed_addr global i32 -1, align 4 - -entry: - %xx = alloca i32 - %yy = alloca i32* - %taddr = alloca i32 - store i32 -1, i32* %xx - store i32 -1, i32* %taddr - store i32* %taddr, i32** %yy - ret void \ No newline at end of file diff --git a/test/test_suite14/constants/float_type.c3t b/test/test_suite14/constants/float_type.c3t deleted file mode 100644 index 5ee96b84e..000000000 --- a/test/test_suite14/constants/float_type.c3t +++ /dev/null @@ -1,11 +0,0 @@ -// #target: macos-x64 -module test; -uint f0 = $typeof(1.0f).sizeof; -uint f32 = $typeof(1.0f32).sizeof; -uint f64 = $typeof(1.0f64).sizeof; - -/* #expect: test.ll - -@test_f0 = local_unnamed_addr global i32 4, align 4 -@test_f32 = local_unnamed_addr global i32 4, align 4 -@test_f64 = local_unnamed_addr global i32 8, align 4 \ No newline at end of file diff --git a/test/test_suite14/constants/init_order.c3t b/test/test_suite14/constants/init_order.c3t deleted file mode 100644 index e4390261a..000000000 --- a/test/test_suite14/constants/init_order.c3t +++ /dev/null @@ -1,25 +0,0 @@ -// #target: macos-x64 -module test; - -macro foo() -{ - $if ($defined(A)): - return A + 1; - $else: - return 1; - $endif; -} - -const Z = foo(); - -$if (!$defined(A) && Z == 1): - const A = 222; -$endif; - -const B = foo(); - -/* #expect: test.ll - -@test_Z = local_unnamed_addr constant i32 1, align 4 -@test_B = local_unnamed_addr constant i32 223, align 4 -@test_A = local_unnamed_addr constant i32 222, align 4 \ No newline at end of file diff --git a/test/test_suite14/contracts/ct_eval_of_ensure.c3 b/test/test_suite14/contracts/ct_eval_of_ensure.c3 deleted file mode 100644 index 7c8209999..000000000 --- a/test/test_suite14/contracts/ct_eval_of_ensure.c3 +++ /dev/null @@ -1,16 +0,0 @@ -module test; -/** - * @ensure return > 100 - */ -fn int test(int baz) -{ - return 1; // #error: @ensure "return > 100" violated. -} - -extern fn void printf(char*, ...); -fn void main(String[] args) -{ - test(1022); - printf("Hello\n"); -} - diff --git a/test/test_suite14/contracts/in_out.c3 b/test/test_suite14/contracts/in_out.c3 deleted file mode 100644 index 359d4949a..000000000 --- a/test/test_suite14/contracts/in_out.c3 +++ /dev/null @@ -1,31 +0,0 @@ -struct Foo { int x; } -/** - * @param [out] f - **/ -fn void bar(Foo* f) -{ - f.x = 123; -} - -/** - * @param [in] f - **/ -fn void foo(Foo* f) -{ - bar(f); // #error: It's not allowed to pass an 'in' -} - -/** - * @param [in] f - **/ -fn void foo2(Foo* f) -{ -} - -/** - * @param [out] f - **/ -fn void baz(Foo *f) -{ - foo2(f); // #error: It's not allowed to pass an 'out' -} \ No newline at end of file diff --git a/test/test_suite14/contracts/pure.c3 b/test/test_suite14/contracts/pure.c3 deleted file mode 100644 index 139931e44..000000000 --- a/test/test_suite14/contracts/pure.c3 +++ /dev/null @@ -1,24 +0,0 @@ -module inlineme; - -/** - * @pure - */ -fn void test() -{ - int x = 123; - int* y = &x; -} - -int abc; -fn void test2() -{ - abc = 1233; -} - -/** - * @pure - */ -fn void test3() -{ - abc = 1233; // #error: '@pure' functions may not access globals -} \ No newline at end of file diff --git a/test/test_suite14/contracts/pure_calls.c3 b/test/test_suite14/contracts/pure_calls.c3 deleted file mode 100644 index 6454bbc97..000000000 --- a/test/test_suite14/contracts/pure_calls.c3 +++ /dev/null @@ -1,26 +0,0 @@ -module inlineme; - -/** - * @pure - */ -fn void test() -{ - int x = 123; - int* y = &x; - test3(); - test2() @pure; - test2(); // #error: Only '@pure' functions may be called, you can override this with an attribute -} - -int abc; -fn void test2() -{ - abc = 1233; -} - -/** - * @pure - */ -fn void test3() -{ -} \ No newline at end of file diff --git a/test/test_suite14/contracts/simple_test.c3t b/test/test_suite14/contracts/simple_test.c3t deleted file mode 100644 index 2f752b62f..000000000 --- a/test/test_suite14/contracts/simple_test.c3t +++ /dev/null @@ -1,90 +0,0 @@ -// #target: macos-x64 - -/** - * @param [inout] foo `test` - * @require baz > 100 `whatever` - * @ensure *foo > 231 -*/ -fn void test(int *foo, int baz) -{ - *foo = 444; -} - -/** - * @param [inout] foo `test` - * @require baz > 100 `whatever` - * @ensure return < 200 -*/ -fn int test2(int *foo, int baz) -{ - *foo = 444; - return baz; -} - -/** - * @require x > 0 - * @ensure return > 0 - **/ -fn int test3(int x) -{ - return x + 1; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - int fooofke; - test(&fooofke, 330); - test2(&fooofke, 150); - test3(123); - printf("Foo: %d\n", fooofke); -} - -/* #expect: simple_test.ll - -define void @simple_test_test(i32* %0, i32 %1) #0 { -entry: - %gt = icmp sgt i32 %1, 100 - call void @llvm.assume(i1 %gt) - store i32 444, i32* %0, align 4 - ret void -} - -define i32 @simple_test_test2(i32* %0, i32 %1) #0 { -entry: - %gt = icmp sgt i32 %1, 100 - call void @llvm.assume(i1 %gt) - store i32 444, i32* %0, align 4 - %lt = icmp slt i32 %1, 200 - call void @llvm.assume(i1 %lt) - ret i32 %1 -} - -define i32 @simple_test_test3(i32 %0) #0 { -entry: - %gt = icmp sgt i32 %0, 0 - call void @llvm.assume(i1 %gt) - %add = add i32 %0, 1 - %gt1 = icmp sgt i32 %add, 0 - call void @llvm.assume(i1 %gt1) - ret i32 %add -} - -define void @simple_test_main() #0 { -entry: - %fooofke = alloca i32, align 4 - store i32 0, i32* %fooofke, align 4 - call void @simple_test_test(i32* %fooofke, i32 330) - %0 = call i32 @simple_test_test2(i32* %fooofke, i32 150) - %1 = call i32 @simple_test_test3(i32 123) - %2 = load i32, i32* %fooofke, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %2) - ret void -} - -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @simple_test_main() - ret i32 0 -} diff --git a/test/test_suite14/debug_symbols/constants.c3t b/test/test_suite14/debug_symbols/constants.c3t deleted file mode 100644 index c90334e96..000000000 --- a/test/test_suite14/debug_symbols/constants.c3t +++ /dev/null @@ -1,28 +0,0 @@ -// #target: macos-x64 -// #debuginfo: yes -private const char AA = 1; -const char BB = 200 ; -private const uint CC = ~(uint)(0); -private const FOO = ~(uint)(0); - -/* #expect: constants.ll - -@constants_AA = protected unnamed_addr constant i8 1, align 1 -@constants_BB = local_unnamed_addr constant i8 -56, align 1 -@constants_CC = protected unnamed_addr constant i32 -1, align 4 -@constants_FOO = protected unnamed_addr constant i32 -1, align 4 - -!llvm.dbg.cu = !{!0} - -!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "c3c", isOptimized: false, runtimeVersion: 1, emissionKind: FullDebug -!1 = !DIFile(filename: "constants.c3", -!DIGlobalVariableExpression -distinct !DIGlobalVariable(name: "AA", linkageName: "constants_AA", scope: !1, file: !1, line: 1 -!DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char) -!DIGlobalVariableExpression -distinct !DIGlobalVariable(name: "BB", linkageName: "constants_BB", scope: !1, file: !1, line: 2 -!DIGlobalVariableExpression -distinct !DIGlobalVariable(name: "CC", linkageName: "constants_CC", scope: !1, file: !1, line: 3 -!DIBasicType(name: "uint", size: 32, encoding: DW_ATE_unsigned) -!DIGlobalVariableExpression -distinct !DIGlobalVariable(name: "FOO", linkageName: "constants_FOO", scope: !1, file: !1, line: 4 diff --git a/test/test_suite14/defer/defer_and_expr_block.c3t b/test/test_suite14/defer/defer_and_expr_block.c3t deleted file mode 100644 index 1eca0d219..000000000 --- a/test/test_suite14/defer/defer_and_expr_block.c3t +++ /dev/null @@ -1,40 +0,0 @@ -// #target: macos-x64 -module foo; -extern fn void printf(char*,...); - -fn void main() -{ - defer printf("On exit\n"); - {| - defer printf("Baz\n"); - defer {| - defer printf("Hello!\n"); - defer printf("1\n"); - if (true) return 12; - defer printf("2\n"); - return 34; - |}; - |}; - defer printf("On 2\n"); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %blockret = alloca i32, align 4 - br label %if.then - -if.then: ; preds = %entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0)) - store i32 12, i32* %blockret, align 4 - br label %expr_block.exit - -expr_block.exit: ; preds = %if.then - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i32 0, i32 0)) - ret void -} - diff --git a/test/test_suite14/defer/defer_single_stmt.c3 b/test/test_suite14/defer/defer_single_stmt.c3 deleted file mode 100644 index d6bb0cffc..000000000 --- a/test/test_suite14/defer/defer_single_stmt.c3 +++ /dev/null @@ -1,41 +0,0 @@ -fn void test1() -{ - while (1) defer foo(); // #error: Looping over a raw 'defer' -} - -fn void test1a() -{ - while (1) { defer foo(); } -} - -fn void test2() -{ - if (1) defer foo(); // #error: An 'if' statement may not be followed by a raw 'defer' -} - -fn void test2a() -{ - if (1) { defer foo(); } -} - -fn void test3() -{ - defer defer foo(); // #error: A defer may not have a body consisting of a raw 'defer' -} - -fn void test3a() -{ - defer { defer foo(); } -} - -fn void test4() -{ - for (;;) defer foo(); // #error: Looping over a raw 'defer' -} - -fn void test4a() -{ - for(;;) { defer foo(); } -} - -fn void foo() {} diff --git a/test/test_suite14/defer/defer_static_var.c3t b/test/test_suite14/defer/defer_static_var.c3t deleted file mode 100644 index fb228b656..000000000 --- a/test/test_suite14/defer/defer_static_var.c3t +++ /dev/null @@ -1,204 +0,0 @@ -// #target: macos-x64 -module foo; -extern fn void printf(char*,...); - -fn int foo(int x) -{ - defer - { - static int y = 0; - y++; - printf("Here we go %d\n", y); - } - if (x > 0) return 2; - return x; -} - -macro void foo2(int x) -{ - printf("->%d\n", x); - for (int i = 0; i < 100; i++) - { - defer - { - static int y = 0; - y++; - printf(">%d--%d\n", i, y); - } - if (i == x) break; - printf("--"); - } -} - -fn void main() -{ - foo(1); - foo(2); - foo(-2); - foo2(0); - foo2(1); - foo2(2); -} - -/* #expect: foo.ll - -@"foo$y" = internal unnamed_addr global i32 0, align 4 -@"main$y" = internal unnamed_addr global i32 0, align 4 -@"main$y.7" = internal unnamed_addr global i32 0, align 4 -@"main$y.12" = internal unnamed_addr global i32 0, align 4 - -define i32 @foo_foo(i32 %0) #0 { -entry: - %gt = icmp sgt i32 %0, 0 - br i1 %gt, label %if.then, label %if.exit - -if.then: ; preds = %entry - %1 = load i32, i32* @"foo$y", align 4 - %add = add i32 %1, 1 - store i32 %add, i32* @"foo$y", align 4 - %2 = load i32, i32* @"foo$y", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0), i32 %2) - ret i32 2 - -if.exit: ; preds = %entry - %3 = load i32, i32* @"foo$y", align 4 - %add1 = add i32 %3, 1 - store i32 %add1, i32* @"foo$y", align 4 - %4 = load i32, i32* @"foo$y", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i32 %4) - ret i32 %0 -} - -define void @foo_main() #0 { -entry: - %x = alloca i32, align 4 - %i = alloca i32, align 4 - %x3 = alloca i32, align 4 - %i4 = alloca i32, align 4 - %x15 = alloca i32, align 4 - %i16 = alloca i32, align 4 - %0 = call i32 @foo_foo(i32 1) - %1 = call i32 @foo_foo(i32 2) - %2 = call i32 @foo_foo(i32 -2) - store i32 0, i32* %x, align 4 - %3 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i32 %3) - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %if.exit, %entry - %4 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %4, 100 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %5 = load i32, i32* %i, align 4 - %6 = load i32, i32* %x, align 4 - %eq = icmp eq i32 %5, %6 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - %7 = load i32, i32* @"main$y", align 4 - %add = add i32 %7, 1 - store i32 %add, i32* @"main$y", align 4 - %8 = load i32, i32* %i, align 4 - %9 = load i32, i32* @"main$y", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i32 %8, i32 %9) - br label %loop.exit - -if.exit: ; preds = %loop.body - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0)) - %10 = load i32, i32* @"main$y", align 4 - %add1 = add i32 %10, 1 - store i32 %add1, i32* @"main$y", align 4 - %11 = load i32, i32* %i, align 4 - %12 = load i32, i32* @"main$y", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i32 %11, i32 %12) - %13 = load i32, i32* %i, align 4 - %add2 = add i32 %13, 1 - store i32 %add2, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %if.then, %loop.cond - store i32 1, i32* %x3, align 4 - %14 = load i32, i32* %x3, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i32 %14) - store i32 0, i32* %i4, align 4 - br label %loop.cond5 - -loop.cond5: ; preds = %if.exit11, %loop.exit - %15 = load i32, i32* %i4, align 4 - %lt6 = icmp slt i32 %15, 100 - br i1 %lt6, label %loop.body7, label %loop.exit14 - -loop.body7: ; preds = %loop.cond5 - %16 = load i32, i32* %i4, align 4 - %17 = load i32, i32* %x3, align 4 - %eq8 = icmp eq i32 %16, %17 - br i1 %eq8, label %if.then9, label %if.exit11 - -if.then9: ; preds = %loop.body7 - %18 = load i32, i32* @"main$y.7", align 4 - %add10 = add i32 %18, 1 - store i32 %add10, i32* @"main$y.7", align 4 - %19 = load i32, i32* %i4, align 4 - %20 = load i32, i32* @"main$y.7", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i32 %19, i32 %20) - br label %loop.exit14 - -if.exit11: ; preds = %loop.body7 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0)) - %21 = load i32, i32* @"main$y.7", align 4 - %add12 = add i32 %21, 1 - store i32 %add12, i32* @"main$y.7", align 4 - %22 = load i32, i32* %i4, align 4 - %23 = load i32, i32* @"main$y.7", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i32 %22, i32 %23) - %24 = load i32, i32* %i4, align 4 - %add13 = add i32 %24, 1 - store i32 %add13, i32* %i4, align 4 - br label %loop.cond5 - -loop.exit14: ; preds = %if.then9, %loop.cond5 - store i32 2, i32* %x15, align 4 - %25 = load i32, i32* %x15, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i32 %25) - store i32 0, i32* %i16, align 4 - br label %loop.cond17 - -loop.cond17: ; preds = %if.exit23, %loop.exit14 - %26 = load i32, i32* %i16, align 4 - %lt18 = icmp slt i32 %26, 100 - br i1 %lt18, label %loop.body19, label %loop.exit26 - -loop.body19: ; preds = %loop.cond17 - %27 = load i32, i32* %i16, align 4 - %28 = load i32, i32* %x15, align 4 - %eq20 = icmp eq i32 %27, %28 - br i1 %eq20, label %if.then21, label %if.exit23 - -if.then21: ; preds = %loop.body19 - %29 = load i32, i32* @"main$y.12", align 4 - %add22 = add i32 %29, 1 - store i32 %add22, i32* @"main$y.12", align 4 - %30 = load i32, i32* %i16, align 4 - %31 = load i32, i32* @"main$y.12", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i32 0, i32 0), i32 %30, i32 %31) - br label %loop.exit26 - -if.exit23: ; preds = %loop.body19 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0)) - %32 = load i32, i32* @"main$y.12", align 4 - %add24 = add i32 %32, 1 - store i32 %add24, i32* @"main$y.12", align 4 - %33 = load i32, i32* %i16, align 4 - %34 = load i32, i32* @"main$y.12", align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i32 0, i32 0), i32 %33, i32 %34) - %35 = load i32, i32* %i16, align 4 - %add25 = add i32 %35, 1 - store i32 %add25, i32* %i16, align 4 - br label %loop.cond17 - -loop.exit26: ; preds = %if.then21, %loop.cond17 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/defer/defer_with_rethrow.c3 b/test/test_suite14/defer/defer_with_rethrow.c3 deleted file mode 100644 index 265f2fa0e..000000000 --- a/test/test_suite14/defer/defer_with_rethrow.c3 +++ /dev/null @@ -1,14 +0,0 @@ -fn int! foo() -{ return 1; } - - -fn int! bar() -{ - defer { - {| - foo()?; - |}; - } - defer foo()?; // #error: Returns are not allowed inside of defers. - return 1; -} \ No newline at end of file diff --git a/test/test_suite14/defer/defer_with_return.c3 b/test/test_suite14/defer/defer_with_return.c3 deleted file mode 100644 index eeabe94d6..000000000 --- a/test/test_suite14/defer/defer_with_return.c3 +++ /dev/null @@ -1,10 +0,0 @@ -fn int! bar() -{ - defer { - {| - return 4; - |}; - } - defer return 3; // #error: Return is not allowed inside of a defer - return 1; -} \ No newline at end of file diff --git a/test/test_suite14/define/common.c3 b/test/test_suite14/define/common.c3 deleted file mode 100644 index 53a163483..000000000 --- a/test/test_suite14/define/common.c3 +++ /dev/null @@ -1,17 +0,0 @@ -module foo; - -// define = -define standard_foo = __stdin; -define someFunctionIntBool = someFunction; -define FooInt = Foo; -define A_CONST_INT = A_CONST; - -define standard_foo = ofke; // #error: Expected '=' -define fn foo = fef; // #error: An identifier was expected here. -define feokfe = fn void(int); // #error: Expected a function or variable name here -define AOFKE = ofek; // #error: Expected a constant name here -define okfoe = OFKEOK; // #error: Expected a function or variable name here -define Helo = helo; // #error: A type name was expected here -define Helo = OFKE; // #error: A type name was expected here -define helo = Helo; // #error: A type alias must start with an uppercase letter and contain at least one lower case letter. -define HELO = Helo; // #error: A type alias must start with an uppercase letter and contain at least one lower case letter. diff --git a/test/test_suite14/define/define_name_errors.c3 b/test/test_suite14/define/define_name_errors.c3 deleted file mode 100644 index 76f884abf..000000000 --- a/test/test_suite14/define/define_name_errors.c3 +++ /dev/null @@ -1,9 +0,0 @@ - -define int = int; // #error: 'int' is the name of a built-in type and can't be used as an alias. -define main = int; // #error: 'main' is reserved and cannot be used as an alias. - -define hello = int; // #error: A type alias must start with an uppercase letter and contain at least one lower case letter -define hello = Foo; // #error: A type alias must start with an uppercase letter and contain at least one lower case letter - -define HELLO = int; // #error: A type alias must start with an uppercase letter and contain at least one lower case letter -define HELLO = Foo; // #error: A type alias must start with an uppercase letter and contain at least one lower case letter \ No newline at end of file diff --git a/test/test_suite14/define/forbidden_defines.c3 b/test/test_suite14/define/forbidden_defines.c3 deleted file mode 100644 index 86a7ca17d..000000000 --- a/test/test_suite14/define/forbidden_defines.c3 +++ /dev/null @@ -1,3 +0,0 @@ -define Abc = int[*]; // #error: Inferred array types can only -define Bcd = anyerr; // #error: 'anyerr' may not be aliased. -define Efd = variant; // #error: 'variant' may not be aliased. diff --git a/test/test_suite14/define/test_at.c3 b/test/test_suite14/define/test_at.c3 deleted file mode 100644 index 30c060010..000000000 --- a/test/test_suite14/define/test_at.c3 +++ /dev/null @@ -1,17 +0,0 @@ -module foo; -import std::io; - -macro @hello(Type thing) { - io::printfn("%d", $sizeof(thing)); -} - -module bar; - -import private foo; - -define intHello = foo::@hello; // #error: cannot be aliased -define @intHello = foo::hello; // #error: cannot use - -fn void main(String[] args) { - @intHello(42); -} \ No newline at end of file diff --git a/test/test_suite14/define/test_at_alias.c3 b/test/test_suite14/define/test_at_alias.c3 deleted file mode 100644 index f10964a90..000000000 --- a/test/test_suite14/define/test_at_alias.c3 +++ /dev/null @@ -1,16 +0,0 @@ -module foo; -import std::io; - -macro @hello(Type thing) { - io::printfn("%d", $sizeof(thing)); -} - -module bar; - -import private foo; - -define @intHello = foo::@hello; - -fn void main(String[] args) { - @intHello(42); -} \ No newline at end of file diff --git a/test/test_suite14/distinct/distinct_invalid.c3 b/test/test_suite14/distinct/distinct_invalid.c3 deleted file mode 100644 index af271a330..000000000 --- a/test/test_suite14/distinct/distinct_invalid.c3 +++ /dev/null @@ -1,8 +0,0 @@ -fault Error -{} - -define Foo1 = distinct Error; // #error: You cannot create a distinct - -define Foo3 = distinct void; // #error: create a distinct type from 'void' - -define Foo4 = distinct typeid; // #error: create a distinct type from 'typeid' diff --git a/test/test_suite14/distinct/distinct_slicing.c3 b/test/test_suite14/distinct/distinct_slicing.c3 deleted file mode 100644 index e7a389f44..000000000 --- a/test/test_suite14/distinct/distinct_slicing.c3 +++ /dev/null @@ -1,10 +0,0 @@ -define Foo = distinct double[]; - -fn void main() -{ - Foo x = { 1.0, 4.5, 7.123 }; - Foo y = x; - Foo z = x[0:2]; - Foo w = x[1..2]; - double[] yekf = x[1..1]; // #error: Implicitly casting 'Foo' to 'double[]' is not permitted -} diff --git a/test/test_suite14/distinct/distinct_struct.c3 b/test/test_suite14/distinct/distinct_struct.c3 deleted file mode 100644 index f7e7b39e0..000000000 --- a/test/test_suite14/distinct/distinct_struct.c3 +++ /dev/null @@ -1,28 +0,0 @@ - -struct Struct -{ - int x; - double y; -} - -define Foo = distinct Struct; - -struct Struct2 -{ - Foo f; - int d; - struct bar - { - Foo x; - } -} -Foo f = { 1, 1.0 }; - -fn void test(int x) -{ - Struct s = { 1, 2.0 }; - Foo f2 = (Foo)(s); - Foo f3 = { .x = 1 }; - Struct2 s2 = { .f = { 1, 2.0 } }; - Struct2 s3 = { .bar.x.y = 3.0 }; -} \ No newline at end of file diff --git a/test/test_suite14/distinct/distinct_struct_array.c3 b/test/test_suite14/distinct/distinct_struct_array.c3 deleted file mode 100644 index f6e4eb4e1..000000000 --- a/test/test_suite14/distinct/distinct_struct_array.c3 +++ /dev/null @@ -1,19 +0,0 @@ -module test; - -define Foo = distinct int; - -struct Struct -{ - Foo x; - int y; -} - -define Struct2 = distinct Struct; -define StructArr = distinct Struct2[3]; - -fn void test(int x) -{ - StructArr z = { { .x = 1 }, { .y = x }, { 1, 2 }}; - usz len = z.len; - Foo zz = z[2].x; -} diff --git a/test/test_suite14/distinct/distinct_union.c3 b/test/test_suite14/distinct/distinct_union.c3 deleted file mode 100644 index 49af50a55..000000000 --- a/test/test_suite14/distinct/distinct_union.c3 +++ /dev/null @@ -1,34 +0,0 @@ -module test; - -union Union -{ - int x; - double y; -} - -define Foo = distinct Union; - -union Union2 -{ - Foo f; - int d; - struct bar - { - Foo x; - } -} -Foo f = { .x = 1 }; - -define Union3 = distinct Union2; - -define UnionArr = distinct Union3[3]; - -fn void test(int x) -{ - Union s = { .y = 2.0 }; - Foo f2 = (Foo)(s); - Foo f3 = { .x = 1 }; - Union2 s2 = { .f = { .y = 1 } }; - Union2 s3 = { .bar.x.y = 3.0 }; - UnionArr a = { [0].bar.x.x = 100 }; -} diff --git a/test/test_suite14/distinct/distinct_voidptr_null.c3t b/test/test_suite14/distinct/distinct_voidptr_null.c3t deleted file mode 100644 index c983ef398..000000000 --- a/test/test_suite14/distinct/distinct_voidptr_null.c3t +++ /dev/null @@ -1,23 +0,0 @@ -// #target: macos-x64 -module foo; - -define Foo = distinct void*; - -extern fn void test(Foo f) {} -fn void main() -{ - Foo f = null; - f = null; - test(null); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %f = alloca i8*, align 8 - store i8* null, i8** %f, align 8 - store i8* null, i8** %f, align 8 - call void @test(i8* null) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/distinct/test_errors.c3 b/test/test_suite14/distinct/test_errors.c3 deleted file mode 100644 index e90141453..000000000 --- a/test/test_suite14/distinct/test_errors.c3 +++ /dev/null @@ -1,11 +0,0 @@ -module test; - -define Int2 = distinct int; - -fn void test() -{ - Int2 a = 1; - a = a + 1; - int b; - a = b; // #error: 'Int2' -} \ No newline at end of file diff --git a/test/test_suite14/distinct/test_ops_on_int.c3 b/test/test_suite14/distinct/test_ops_on_int.c3 deleted file mode 100644 index 76f50b233..000000000 --- a/test/test_suite14/distinct/test_ops_on_int.c3 +++ /dev/null @@ -1,29 +0,0 @@ -module test; - -define Foo = distinct int; - -fn int test1() -{ - Foo x = 1; - x += 2; - Foo y = 3; - y = x + y; - int z = 4; - y += (Foo)(z); - y = y << z; - y = y >> z; - y = y + y; - y = y - y; - y = y * y; - y = y / y; - y = y & y; - y = y ^ y; - y = y | y; - bool a1 = y != y; - bool a2 = y < y; - bool a3 = y <= y; - bool a4 = y == y; - y = y == 1 ? 1 : y; - y = y < (y + 1) ? 1 : y; - return (int)(y); -} diff --git a/test/test_suite14/distinct/test_ops_on_struct.c3 b/test/test_suite14/distinct/test_ops_on_struct.c3 deleted file mode 100644 index 8afcb4962..000000000 --- a/test/test_suite14/distinct/test_ops_on_struct.c3 +++ /dev/null @@ -1,24 +0,0 @@ -module test; - -struct Struct -{ - int x; - double y; -} - -define Foo = distinct Struct; - -struct Struct2 -{ - Foo f; - int d; -} -Foo f = { 1, 1.0 }; - -fn void test(int x) -{ - Struct s = { 1, 2.0 }; - Foo f2 = (Foo)(s); - Foo f3 = { .x = 1 }; - Struct2 s2 = { .f = { 1, 2.0 } }; -} \ No newline at end of file diff --git a/test/test_suite14/enumerations/compile_time.c3t b/test/test_suite14/enumerations/compile_time.c3t deleted file mode 100644 index 68c6f8db0..000000000 --- a/test/test_suite14/enumerations/compile_time.c3t +++ /dev/null @@ -1,16 +0,0 @@ -enum MyEnum : short -{ - HELO, - WORLD, - BYE -} - -int myenum_elements = MyEnum.elements; -int myenum_alignof = MyEnum.alignof; -int myenum_sizeof = MyEnum.sizeof; - -// #expect: compile_time.ll - -@compile_time_myenum_elements = local_unnamed_addr global i32 3, align 4 -@compile_time_myenum_alignof = local_unnamed_addr global i32 2, align 4 -@compile_time_myenum_sizeof = local_unnamed_addr global i32 2, align 4 \ No newline at end of file diff --git a/test/test_suite14/enumerations/enum_associated_value.c3t b/test/test_suite14/enumerations/enum_associated_value.c3t deleted file mode 100644 index fcf37b228..000000000 --- a/test/test_suite14/enumerations/enum_associated_value.c3t +++ /dev/null @@ -1,54 +0,0 @@ -// #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 -} diff --git a/test/test_suite14/enumerations/enum_cast.c3t b/test/test_suite14/enumerations/enum_cast.c3t deleted file mode 100644 index 43a9b3a48..000000000 --- a/test/test_suite14/enumerations/enum_cast.c3t +++ /dev/null @@ -1,102 +0,0 @@ -// #target: macos-x64 -module test; - -enum MyEnum : char -{ - FOO, - BAR -} - -fn void test2() -{ - char ww = MyEnum.FOO.ordinal; - MyEnum x = MyEnum.BAR; - char zz = x.ordinal; -} - -fn void test() -{ - char b = MyEnum.FOO; - int z = (int)(MyEnum.BAR); - var $foo = (int)(MyEnum.FOO); - var $baz = MyEnum.BAR; - MyEnum x = MyEnum.BAR; - char b2 = x; - int z2 = (int)(x); - float d = (float)(MyEnum.FOO); - bool hello = (bool)(MyEnum.FOO); - var $d = (float)(MyEnum.FOO); - var $hello = (bool)(MyEnum.FOO); - MyEnum! xf = MyEnum.BAR; - float! e = (float)(x); - e = (float)(xf); - -} - -/* #expect: test.ll - -define void @test_test2() #0 { -entry: - %ww = alloca i8, align 1 - %x = alloca i8, align 1 - %zz = alloca i8, align 1 - store i8 0, i8* %ww, align 1 - store i8 1, i8* %x, align 1 - %0 = load i8, i8* %x, align 1 - store i8 %0, i8* %zz, align 1 - ret void -} - -; Function Attrs: nounwind -define void @test_test() #0 { -entry: - %b = alloca i8, align 1 - %z = alloca i32, align 4 - %x = alloca i8, align 1 - %b2 = alloca i8, align 1 - %z2 = alloca i32, align 4 - %d = alloca float, align 4 - %hello = alloca i8, align 1 - %xf = alloca i8, align 1 - %xf.f = alloca i64, align 8 - %e = alloca float, align 4 - %e.f = alloca i64, align 8 - store i8 0, i8* %b, align 1 - store i32 1, i32* %z, align 4 - store i8 1, i8* %x, align 1 - %0 = load i8, i8* %x, align 1 - store i8 %0, i8* %b2, align 1 - %1 = load i8, i8* %x, align 1 - %uisiext = zext i8 %1 to i32 - store i32 %uisiext, i32* %z2, align 4 - store float 0.000000e+00, float* %d, align 4 - store i8 0, i8* %hello, align 1 - store i8 1, i8* %xf, align 1 - store i64 0, i64* %xf.f, align 8 - %2 = load i8, i8* %x, align 1 - %uifp = uitofp i8 %2 to float - store float %uifp, float* %e, align 4 - store i64 0, i64* %e.f, align 8 - %optval = load i64, i64* %xf.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %e.f, align 8 - br label %after_assign - -after_check: ; preds = %entry - %3 = load i8, i8* %xf, align 1 - %uifp1 = uitofp i8 %3 to float - store float %uifp1, float* %e, align 4 - store i64 0, i64* %e.f, align 8 - br label %after_assign - -after_assign: ; preds = %after_check, %assign_optional - br label %voiderr - -voiderr: ; preds = %after_assign - ret void -} - -attributes #0 = { nounwind } \ No newline at end of file diff --git a/test/test_suite14/enumerations/enum_invalid_param.c3 b/test/test_suite14/enumerations/enum_invalid_param.c3 deleted file mode 100644 index ff86eb5f9..000000000 --- a/test/test_suite14/enumerations/enum_invalid_param.c3 +++ /dev/null @@ -1,9 +0,0 @@ -enum Test : int (int a, int b) -{ - FOO(1, 2) -} - -enum Test2 : int (int a, int nameof) // #error: 'nameof' is not a valid parameter name for enums -{ - FOO(1, 2) -} diff --git a/test/test_suite14/enumerations/enum_same_param.c3 b/test/test_suite14/enumerations/enum_same_param.c3 deleted file mode 100644 index 1196ed7ca..000000000 --- a/test/test_suite14/enumerations/enum_same_param.c3 +++ /dev/null @@ -1,9 +0,0 @@ -enum Test : int (int a, int b) -{ - FOO(1, 2) -} - -enum Test2 : int (int a, int a) // #error: Duplicate parameter name 'a' -{ - FOO(1, 2) -} diff --git a/test/test_suite14/enumerations/enum_values.c3t b/test/test_suite14/enumerations/enum_values.c3t deleted file mode 100644 index 9a06a62c3..000000000 --- a/test/test_suite14/enumerations/enum_values.c3t +++ /dev/null @@ -1,40 +0,0 @@ -// #target: macos-x64 - -module test; - -enum Foo -{ - ABC, - BCD -} - -Foo zfok = Foo.values[0]; -Foo[] zw = &&Foo.values; - -fn void test(int x) -{ - Foo zonk = Foo.values[x]; -} - -/* #expect: test.ll - -%"Foo[]" = type { i32*, i64 } - -@test_zfok = local_unnamed_addr global i32 0, align 4 -@.taddr = private global [2 x i32] [i32 0, i32 1], align 4 -@test_zw = local_unnamed_addr global %"Foo[]" { i32* getelementptr inbounds ([2 x i32], [2 x i32]* @.taddr, i32 0, i32 0), i64 2 }, align 8 - -define void @test_test(i32 %0) #0 { -entry: - %zonk = alloca i32, align 4 - %literal = alloca [2 x i32], align 4 - %1 = getelementptr inbounds [2 x i32], [2 x i32]* %literal, i64 0, i64 0 - store i32 0, i32* %1, align 4 - %2 = getelementptr inbounds [2 x i32], [2 x i32]* %literal, i64 0, i64 1 - store i32 1, i32* %2, align 4 - %sisiext = sext i32 %0 to i64 - %3 = getelementptr inbounds [2 x i32], [2 x i32]* %literal, i64 0, i64 %sisiext - %4 = load i32, i32* %3, align 4 - store i32 %4, i32* %zonk, align 4 - ret void -} diff --git a/test/test_suite14/enumerations/simple_inference.c3t b/test/test_suite14/enumerations/simple_inference.c3t deleted file mode 100644 index 54ae20f1c..000000000 --- a/test/test_suite14/enumerations/simple_inference.c3t +++ /dev/null @@ -1,23 +0,0 @@ -// #target: macos-x64 - -enum HelloEnum -{ - HELLO, - WORLD, - ELLOWORLD, -} -fn void test() -{ - HelloEnum h = WORLD; - h = ELLOWORLD; -} - -/* #expect: simple_inference.ll - -define void @simple_inference_test() #0 { -entry: - %h = alloca i32, align 4 - store i32 1, i32* %h, align 4 - store i32 2, i32* %h, align 4 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/anyerr_void.c3t b/test/test_suite14/errors/anyerr_void.c3t deleted file mode 100644 index a46b30952..000000000 --- a/test/test_suite14/errors/anyerr_void.c3t +++ /dev/null @@ -1,86 +0,0 @@ -fault MyError -{ - FOO, - BAR -} -fn void! errorThing() -{ - return MyError.BAR!; -} - -fn void! errorThing2() -{ - return; -} - -extern fn void printf(char*, ...); -fn void main() -{ - anyerr z = errorThing(); - printf("Z; %llx\n", (iptr)(z)); - printf("BAR: %llx\n", (iptr)(MyError.BAR)); - printf("FOO: %llx\n", (iptr)(MyError.FOO)); - z = errorThing2(); - printf("Z2: %llx\n", (iptr)(z)); -} - -/* #expect: anyerr_void.ll - -define i64 @anyerr_void_errorThing() #0 { -entry: - ret i64 ptrtoint (%.fault* @"anyerr_void_MyError$BAR" to i64) -} - -define i64 @anyerr_void_errorThing2() #0 { -entry: - %reterr = alloca i64, align 8 - ret i64 0 -} - -; Function Attrs: nounwind -declare void @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define void @anyerr_void_main() #0 { -entry: - %z = alloca i64, align 8 - %error_var = alloca i64, align 8 - %error_var1 = alloca i64, align 8 - store i64 0, i64* %error_var, align 8 - %0 = call i64 @anyerr_void_errorThing() - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %0, i64* %error_var, align 8 - br label %noerr_block - -after_check: ; preds = %entry - br label %noerr_block - -noerr_block: ; preds = %after_check, %assign_optional - %1 = load i64, i64* %error_var, align 8 - store i64 %1, i64* %z, align 8 - %2 = load i64, i64* %z, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i64 %2) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i64 ptrtoint (%.fault* @"anyerr_void_MyError$BAR" to i64)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i64 ptrtoint (%.fault* @"anyerr_void_MyError$FOO" to i64)) - store i64 0, i64* %error_var1, align 8 - %3 = call i64 @anyerr_void_errorThing2() - %not_err2 = icmp eq i64 %3, 0 - br i1 %not_err2, label %after_check4, label %assign_optional3 - -assign_optional3: ; preds = %noerr_block - store i64 %3, i64* %error_var1, align 8 - br label %noerr_block5 - -after_check4: ; preds = %noerr_block - br label %noerr_block5 - -noerr_block5: ; preds = %after_check4, %assign_optional3 - %4 = load i64, i64* %error_var1, align 8 - store i64 %4, i64* %z, align 8 - %5 = load i64, i64* %z, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), i64 %5) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/bitshift_failable.c3 b/test/test_suite14/errors/bitshift_failable.c3 deleted file mode 100644 index f649501f3..000000000 --- a/test/test_suite14/errors/bitshift_failable.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test() -{ - int! x = 0; - int! z = x << 100; // #error: shift exceeds bitsize of 'int' -} \ No newline at end of file diff --git a/test/test_suite14/errors/else_checks.c3t b/test/test_suite14/errors/else_checks.c3t deleted file mode 100644 index 3d7538f91..000000000 --- a/test/test_suite14/errors/else_checks.c3t +++ /dev/null @@ -1,112 +0,0 @@ -// #target: macos-x64 - -extern fn int! testError(); - -fn void test() -{ - - double x = (testError() + testError()) ?? 100; - double y = (1 << testError()) ?? 100; - double z = testError() >> 1 ?? 100; - double w = testError() * testError() ?? 100; -} - -/* #expect: else_checks.ll - -; Function Attrs: nounwind -declare i64 @testError(i32*) #0 - -; Function Attrs: nounwind -define void @else_checks_test() #0 { -entry: - %x = alloca double, align 8 - %retparam = alloca i32, align 4 - %retparam1 = alloca i32, align 4 - %y = alloca double, align 8 - %retparam4 = alloca i32, align 4 - %z = alloca double, align 8 - %retparam11 = alloca i32, align 4 - %w = alloca double, align 8 - %retparam18 = alloca i32, align 4 - %retparam21 = alloca i32, align 4 - %0 = call i64 @testError(i32* %retparam) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %else_block - -after_check: ; preds = %entry - %1 = load i32, i32* %retparam, align 4 - %2 = call i64 @testError(i32* %retparam1) - %not_err2 = icmp eq i64 %2, 0 - br i1 %not_err2, label %after_check3, label %else_block - -after_check3: ; preds = %after_check - %3 = load i32, i32* %retparam1, align 4 - %add = add i32 %1, %3 - br label %phi_block - -else_block: ; preds = %after_check, %entry - br label %phi_block - -phi_block: ; preds = %else_block, %after_check3 - %val = phi i32 [ %add, %after_check3 ], [ 100, %else_block ] - %sifp = sitofp i32 %val to double - store double %sifp, double* %x, align 8 - %4 = call i64 @testError(i32* %retparam4) - %not_err5 = icmp eq i64 %4, 0 - br i1 %not_err5, label %after_check6, label %else_block7 - -after_check6: ; preds = %phi_block - %5 = load i32, i32* %retparam4, align 4 - %shl = shl i32 1, %5 - %6 = freeze i32 %shl - br label %phi_block8 - -else_block7: ; preds = %phi_block - br label %phi_block8 - -phi_block8: ; preds = %else_block7, %after_check6 - %val9 = phi i32 [ %6, %after_check6 ], [ 100, %else_block7 ] - %sifp10 = sitofp i32 %val9 to double - store double %sifp10, double* %y, align 8 - %7 = call i64 @testError(i32* %retparam11) - %not_err12 = icmp eq i64 %7, 0 - br i1 %not_err12, label %after_check13, label %else_block14 - -after_check13: ; preds = %phi_block8 - %8 = load i32, i32* %retparam11, align 4 - %ashr = ashr i32 %8, 1 - %9 = freeze i32 %ashr - br label %phi_block15 - -else_block14: ; preds = %phi_block8 - br label %phi_block15 - -phi_block15: ; preds = %else_block14, %after_check13 - %val16 = phi i32 [ %9, %after_check13 ], [ 100, %else_block14 ] - %sifp17 = sitofp i32 %val16 to double - store double %sifp17, double* %z, align 8 - %10 = call i64 @testError(i32* %retparam18) - %not_err19 = icmp eq i64 %10, 0 - br i1 %not_err19, label %after_check20, label %else_block24 - -after_check20: ; preds = %phi_block15 - %11 = load i32, i32* %retparam18, align 4 - %12 = call i64 @testError(i32* %retparam21) - %not_err22 = icmp eq i64 %12, 0 - br i1 %not_err22, label %after_check23, label %else_block24 - -after_check23: ; preds = %after_check20 - %13 = load i32, i32* %retparam21, align 4 - %mul = mul i32 %11, %13 - br label %phi_block25 - -else_block24: ; preds = %after_check20, %phi_block15 - br label %phi_block25 - -phi_block25: ; preds = %else_block24, %after_check23 - %val26 = phi i32 [ %mul, %after_check23 ], [ 100, %else_block24 ] - %sifp27 = sitofp i32 %val26 to double - store double %sifp27, double* %w, align 8 - ret void -} - diff --git a/test/test_suite14/errors/error_decl_ok.c3 b/test/test_suite14/errors/error_decl_ok.c3 deleted file mode 100644 index a17338068..000000000 --- a/test/test_suite14/errors/error_decl_ok.c3 +++ /dev/null @@ -1,19 +0,0 @@ -module errors; - -fault TheError -{ - A -} - -fault TheError2 -{ - A, - B -} - -fault TheError3 -{ - C, D -} - - diff --git a/test/test_suite14/errors/error_else.c3t b/test/test_suite14/errors/error_else.c3t deleted file mode 100644 index cf6ce3134..000000000 --- a/test/test_suite14/errors/error_else.c3t +++ /dev/null @@ -1,22 +0,0 @@ -module foo; - -fault Baz -{ - TEST -} - -module bar; -import foo; - -fn int! abc() -{ - return Baz.TEST!; -} - -module baz; -import foo; - -fn int! abc() -{ - return Baz.TEST!; -} diff --git a/test/test_suite14/errors/error_introspect.c3t b/test/test_suite14/errors/error_introspect.c3t deleted file mode 100644 index 45ece3b94..000000000 --- a/test/test_suite14/errors/error_introspect.c3t +++ /dev/null @@ -1,130 +0,0 @@ -// #target: macos-x64 -module foo; -import std::io; - -fault Foo -{ - BAR, - BAZ -} - -fn void main() -{ - char[][] x = Foo.names; - io::printfn("Foo.names: %s", x); - io::printfn("Foo.values: %s", Foo.values); - io::printfn("Foo.elements: %s", Foo.elements); -} - -/* #expect: foo.ll - -@"foo_Foo$BAR" = linkonce constant %.fault { i64 ptrtoint (%.introspect* @"ct$foo_Foo" to i64), %"char[]" { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.fault, i64 0, i64 0), i64 3 } }, align 8 -@.fault = internal constant [4 x i8] c"BAR\00", align 1 -@"foo_Foo$BAZ" = linkonce constant %.fault { i64 ptrtoint (%.introspect* @"ct$foo_Foo" to i64), %"char[]" { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.fault.1, i64 0, i64 0), i64 3 } }, align 8 -@.fault.1 = internal constant [4 x i8] c"BAZ\00", align 1 -@"ct$foo_Foo" = linkonce constant %.introspect { i8 9, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@.str = private unnamed_addr constant [4 x i8] c"BAR\00", align 1 -@.str.2 = private unnamed_addr constant [4 x i8] c"BAZ\00", align 1 -@.str.3 = private unnamed_addr constant [14 x i8] c"Foo.names: %s\00", align 1 -@"ct$char" = linkonce constant %.introspect { i8 3, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$sa$char" = linkonce constant %.introspect { i8 16, i64 16, i64 ptrtoint (%.introspect* @"ct$char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$sa$sa$char" = linkonce constant %.introspect { i8 16, i64 16, i64 ptrtoint (%.introspect* @"ct$sa$char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 -@.str.4 = private unnamed_addr constant [15 x i8] c"Foo.values: %s\00", align 1 -@"ct$a2$foo_Foo" = linkonce constant %.introspect { i8 15, i64 16, i64 ptrtoint (%.introspect* @"ct$foo_Foo" to i64), i64 2, [0 x i64] zeroinitializer }, align 8 -@.str.5 = private unnamed_addr constant [17 x i8] c"Foo.elements: %s\00", align 1 -@"ct$long" = linkonce constant %.introspect { i8 2, i64 8, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 - - %x = alloca %"char[][]", align 8 - %literal = alloca [2 x %"char[]"], align 16 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [1 x %variant], align 16 - %literal3 = alloca [2 x i64], align 16 - %taddr4 = alloca %"variant[]", align 8 - %retparam10 = alloca i64, align 8 - %varargslots11 = alloca [1 x %variant], align 16 - %taddr12 = alloca i64, align 8 - %taddr13 = alloca %"variant[]", align 8 - %0 = getelementptr inbounds [2 x %"char[]"], [2 x %"char[]"]* %literal, i64 0, i64 0 - store %"char[]" { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3 }, %"char[]"* %0, align 8 - %1 = getelementptr inbounds [2 x %"char[]"], [2 x %"char[]"]* %literal, i64 0, i64 1 - store %"char[]" { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i64 3 }, %"char[]"* %1, align 8 - %2 = bitcast [2 x %"char[]"]* %literal to %"char[]"* - %3 = insertvalue %"char[][]" undef, %"char[]"* %2, 0 - %4 = insertvalue %"char[][]" %3, i64 2, 1 - store %"char[][]" %4, %"char[][]"* %x, align 8 - %5 = bitcast %"char[][]"* %x to i8* - %6 = insertvalue %variant undef, i8* %5, 0 - %7 = insertvalue %variant %6, i64 ptrtoint (%.introspect* @"ct$sa$sa$char" to i64), 1 - %8 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %7, %variant* %8, align 16 - %9 = bitcast [1 x %variant]* %varargslots to %variant* - %10 = insertvalue %"variant[]" undef, %variant* %9, 0 - %11 = insertvalue %"variant[]" %10, i64 1, 1 - store %"variant[]" %11, %"variant[]"* %taddr, align 8 - %12 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %13 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %12, i32 0, i32 0 - %lo = load i8*, i8** %13, align 8 - %14 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %12, i32 0, i32 1 - %hi = load i64, i64* %14, align 8 - %15 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0), i64 13, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %15, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %16 = getelementptr inbounds [2 x i64], [2 x i64]* %literal3, i64 0, i64 0 - store i64 ptrtoint (%.fault* @"foo_Foo$BAR" to i64), i64* %16, align 8 - %17 = getelementptr inbounds [2 x i64], [2 x i64]* %literal3, i64 0, i64 1 - store i64 ptrtoint (%.fault* @"foo_Foo$BAZ" to i64), i64* %17, align 8 - %18 = bitcast [2 x i64]* %literal3 to i8* - %19 = insertvalue %variant undef, i8* %18, 0 - %20 = insertvalue %variant %19, i64 ptrtoint (%.introspect* @"ct$a2$foo_Foo" to i64), 1 - %21 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots2, i64 0, i64 0 - store %variant %20, %variant* %21, align 16 - %22 = bitcast [1 x %variant]* %varargslots2 to %variant* - %23 = insertvalue %"variant[]" undef, %variant* %22, 0 - %24 = insertvalue %"variant[]" %23, i64 1, 1 - store %"variant[]" %24, %"variant[]"* %taddr4, align 8 - %25 = bitcast %"variant[]"* %taddr4 to { i8*, i64 }* - %26 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %25, i32 0, i32 0 - %lo5 = load i8*, i8** %26, align 8 - %27 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %25, i32 0, i32 1 - %hi6 = load i64, i64* %27, align 8 - %28 = call i64 @std_io_printfn(i64* %retparam1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i64 14, i8* %lo5, i64 %hi6) - %not_err7 = icmp eq i64 %28, 0 - br i1 %not_err7, label %after_check8, label %voiderr9 - -after_check8: ; preds = %voiderr - br label %voiderr9 - -voiderr9: ; preds = %after_check8, %voiderr - store i64 2, i64* %taddr12, align 8 - %29 = bitcast i64* %taddr12 to i8* - %30 = insertvalue %variant undef, i8* %29, 0 - %31 = insertvalue %variant %30, i64 ptrtoint (%.introspect* @"ct$long" to i64), 1 - %32 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots11, i64 0, i64 0 - store %variant %31, %variant* %32, align 16 - %33 = bitcast [1 x %variant]* %varargslots11 to %variant* - %34 = insertvalue %"variant[]" undef, %variant* %33, 0 - %35 = insertvalue %"variant[]" %34, i64 1, 1 - store %"variant[]" %35, %"variant[]"* %taddr13, align 8 - %36 = bitcast %"variant[]"* %taddr13 to { i8*, i64 }* - %37 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %36, i32 0, i32 0 - %lo14 = load i8*, i8** %37, align 8 - %38 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %36, i32 0, i32 1 - %hi15 = load i64, i64* %38, align 8 - %39 = call i64 @std_io_printfn(i64* %retparam10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i32 0, i32 0), i64 16, i8* %lo14, i64 %hi15) - %not_err16 = icmp eq i64 %39, 0 - br i1 %not_err16, label %after_check17, label %voiderr18 - -after_check17: ; preds = %voiderr9 - br label %voiderr18 - -voiderr18: ; preds = %after_check17, %voiderr9 - ret void -} diff --git a/test/test_suite14/errors/error_regression_2.c3t b/test/test_suite14/errors/error_regression_2.c3t deleted file mode 100644 index 3fd6c10a5..000000000 --- a/test/test_suite14/errors/error_regression_2.c3t +++ /dev/null @@ -1,917 +0,0 @@ -// #target: macos-x64 -module test; -import std; -import libc; - -struct Doc { Head *head; } -struct Head { char[]* title; } - -struct Summary -{ - char[]* title; - bool ok; -} - -fn void Summary.print(Summary *s, CFile out) -{ - // We don't have a native printf in C3 yet, so use libc, - // which is not all that nice for the strings but... - char[] title = s.title ? *s.title : "missing"; - libc::fprintf(out, "Summary({ .title = %.*s, .ok = %s})", (int)title.len, title.ptr, s.ok ? (char*)"true" : (char*)"false"); -} - -fn bool contains(char[] haystack, char[] needle) -{ - usz len = haystack.len; - usz needle_len = needle.len; - if (len < needle_len) return false; - if (!needle_len) return true; - len -= needle_len - 1; - for (usz i = 0; i < len; i++) - { - if (libc::memcmp(&haystack[i], needle.ptr, needle_len) == 0) - { - return true; - } - } - return false; -} - -macro dupe(value) -{ - $typeof(&value) temp = malloc($sizeof(value)); - if (!temp) return ReadError.OUT_OF_MEMORY!; - *temp = value; - return temp; -} - -fault ReadError -{ - BAD_READ, - OUT_OF_MEMORY -} - -fn Doc! readDoc(char[] url) -{ - if (contains(url, "fail")) return ReadError.BAD_READ!; - if (contains(url, "head-missing")) return { .head = null }; - if (contains(url, "title-missing")) return { dupe(Head { .title = null })? }; - if (contains(url, "title-empty")) return { dupe(Head { .title = dupe((char[])"")? })? }; - // Not particularly elegant due to missing string functions. - int len = libc::snprintf(null, 0, "Title of %.*s", (int)url.len, url.ptr); - char* str = malloc(len + 1); - if (!str) return ReadError.OUT_OF_MEMORY!; - libc::snprintf(str, len + 1, "Title of %.*s", (int)url.len, url.ptr); - return { dupe(Head { .title = dupe(str[..len - 1])? })? }; -} - -fn Summary buildSummary(Doc doc) -{ - return Summary { - .title = doc.head ? doc.head.title : null, - .ok = true, - }; -} - -fn Summary readAndBuildSummary(char[] url) -{ - return buildSummary(readDoc(url)) ?? Summary { .title = null, .ok = false }; - /* - // or - Summary summary = buildSummary(readDoc(url)); - if (catch summary) return Summary { .title = null, .ok = false }; - return summary; - // or - Summary summary = buildSummary(readDoc(url)); - if (try summary) return summary; - return Summary { .title = null, .ok = false }; - */ -} - - -fault TitleResult -{ - TITLE_MISSING -} - -fn bool! isTitleNonEmpty(Doc doc) -{ - if (!doc.head) return TitleResult.TITLE_MISSING!; - char[]* head = doc.head.title; - if (!head) return TitleResult.TITLE_MISSING!; - return (*head).len > 0; -} - - -fn bool! readWhetherTitleNonEmpty(char[] url) -{ - return isTitleNonEmpty(readDoc(url)); -} - -fn char* bool_to_string(bool b) -{ - return b ? "true" : "false"; -} -fn char* nameFromError(anyerr e) -{ - switch (e) - { - case TitleResult.TITLE_MISSING: - return "no title"; - case ReadError.BAD_READ: - return "bad read"; - case ReadError.OUT_OF_MEMORY: - return "out of memory"; - default: - return "unknown error"; - } -} - - -fn void main() -{ - const char[][] URLS = { "good", "title-empty", "title-missing", "head-missing", "fail" }; - foreach (char[] url : URLS) - { - // Yes, it's pretty onerous to print strings for the moment in C3 - libc::printf(`Checking "https://%.*s/":` "\n", (int)url.len, url.ptr); - Summary summary = readAndBuildSummary(url); - libc::printf(" Summary: "); - summary.print(libc::stdout()); - libc::printf("\n"); - char[] title_sure = summary.title ? *summary.title : ""; - libc::printf(" Title: %.*s\n", (int)title_sure.len, title_sure.ptr); - bool! has_title = readWhetherTitleNonEmpty(url); - // This looks a bit less than elegant, but as you see it's mostly due to having to - // use printf here. - libc::printf(" Has title: %s vs %s\n", bool_to_string(has_title) ?? nameFromError(catch(has_title)), (has_title ?? false) ? (char*)"true" : (char*)"false"); - } -} - -/* #expect: test.ll - -define void @test_Summary_print(%Summary* %0, i8* %1) #0 { -entry: - %title = alloca %"char[]", align 8 - %2 = getelementptr inbounds %Summary, %Summary* %0, i32 0, i32 0 - %3 = load %"char[]"*, %"char[]"** %2, align 8 - %ptrbool = icmp ne %"char[]"* %3, null - br i1 %ptrbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - %4 = getelementptr inbounds %Summary, %Summary* %0, i32 0, i32 0 - %5 = load %"char[]"*, %"char[]"** %4, align 8 - %6 = load %"char[]", %"char[]"* %5, align 8 - br label %cond.phi - -cond.rhs: ; preds = %entry - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %cond.lhs - %val = phi %"char[]" [ %6, %cond.lhs ], [ { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i32 0, i32 0), i64 7 }, %cond.rhs ] - store %"char[]" %val, %"char[]"* %title, align 8 - %7 = getelementptr inbounds %"char[]", %"char[]"* %title, i32 0, i32 1 - %8 = load i64, i64* %7, align 8 - %uisitrunc = trunc i64 %8 to i32 - %9 = getelementptr inbounds %"char[]", %"char[]"* %title, i32 0, i32 0 - %10 = load i8*, i8** %9, align 8 - %11 = getelementptr inbounds %Summary, %Summary* %0, i32 0, i32 1 - %12 = load i8, i8* %11, align 8 - %13 = trunc i8 %12 to i1 - %ternary = select i1 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i32 0, i32 0) - %14 = call i32 (i8*, i8*, ...) @fprintf(i8* %1, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.29, i32 0, i32 0), i32 %uisitrunc, i8* %10, i8* %ternary) - ret void -} - -; Function Attrs: nounwind -define zeroext i8 @test_contains(i8* %0, i64 %1, i8* %2, i64 %3) #0 { -entry: - %haystack = alloca %"char[]", align 8 - %needle = alloca %"char[]", align 8 - %len = alloca i64, align 8 - %needle_len = alloca i64, align 8 - %i = alloca i64, align 8 - %pair = bitcast %"char[]"* %haystack to { i8*, i64 }* - %4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %4, align 8 - %5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %5, align 8 - %pair1 = bitcast %"char[]"* %needle to { i8*, i64 }* - %6 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 0 - store i8* %2, i8** %6, align 8 - %7 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 1 - store i64 %3, i64* %7, align 8 - %8 = getelementptr inbounds %"char[]", %"char[]"* %haystack, i32 0, i32 1 - %9 = load i64, i64* %8, align 8 - store i64 %9, i64* %len, align 8 - %10 = getelementptr inbounds %"char[]", %"char[]"* %needle, i32 0, i32 1 - %11 = load i64, i64* %10, align 8 - store i64 %11, i64* %needle_len, align 8 - %12 = load i64, i64* %len, align 8 - %13 = load i64, i64* %needle_len, align 8 - %lt = icmp ult i64 %12, %13 - br i1 %lt, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i8 0 - -if.exit: ; preds = %entry - %14 = load i64, i64* %needle_len, align 8 - %not = icmp eq i64 %14, 0 - br i1 %not, label %if.then2, label %if.exit3 - -if.then2: ; preds = %if.exit - ret i8 1 - -if.exit3: ; preds = %if.exit - %15 = load i64, i64* %len, align 8 - %16 = load i64, i64* %needle_len, align 8 - %sub = sub i64 %16, 1 - %sub4 = sub i64 %15, %sub - store i64 %sub4, i64* %len, align 8 - store i64 0, i64* %i, align 8 - br label %loop.cond - -loop.cond: ; preds = %if.exit7, %if.exit3 - %17 = load i64, i64* %i, align 8 - %18 = load i64, i64* %len, align 8 - %lt5 = icmp ult i64 %17, %18 - br i1 %lt5, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %19 = getelementptr inbounds %"char[]", %"char[]"* %haystack, i32 0, i32 0 - %20 = load i8*, i8** %19, align 8 - %21 = load i64, i64* %i, align 8 - %ptroffset = getelementptr inbounds i8, i8* %20, i64 %21 - %22 = getelementptr inbounds %"char[]", %"char[]"* %needle, i32 0, i32 0 - %23 = load i8*, i8** %22, align 8 - %24 = load i64, i64* %needle_len, align 8 - %25 = call i32 @memcmp(i8* %ptroffset, i8* %23, i64 %24) - %eq = icmp eq i32 %25, 0 - br i1 %eq, label %if.then6, label %if.exit7 - -if.then6: ; preds = %loop.body - ret i8 1 - -if.exit7: ; preds = %loop.body - %26 = load i64, i64* %i, align 8 - %add = add i64 %26, 1 - store i64 %add, i64* %i, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret i8 0 -} - -; Function Attrs: nounwind -define i64 @test_readDoc(%Doc* %0, i8* %1, i64 %2) #0 { -entry: - %url = alloca %"char[]", align 8 - %reterr = alloca i64, align 8 - %literal = alloca %Doc, align 8 - %reterr8 = alloca i64, align 8 - %literal9 = alloca %Doc, align 8 - %error_var = alloca i64, align 8 - %value = alloca %Head, align 8 - %literal10 = alloca %Head, align 8 - %temp = alloca %Head*, align 8 - %reterr17 = alloca i64, align 8 - %literal18 = alloca %Doc, align 8 - %error_var19 = alloca i64, align 8 - %value20 = alloca %Head, align 8 - %literal21 = alloca %Head, align 8 - %error_var22 = alloca i64, align 8 - %value23 = alloca %"char[]", align 8 - %temp24 = alloca %"char[]"*, align 8 - %temp31 = alloca %Head*, align 8 - %len = alloca i32, align 4 - %str = alloca i8*, align 8 - %reterr45 = alloca i64, align 8 - %literal46 = alloca %Doc, align 8 - %error_var47 = alloca i64, align 8 - %value48 = alloca %Head, align 8 - %literal49 = alloca %Head, align 8 - %error_var50 = alloca i64, align 8 - %value51 = alloca %"char[]", align 8 - %temp52 = alloca %"char[]"*, align 8 - %temp59 = alloca %Head*, align 8 - %pair = bitcast %"char[]"* %url to { i8*, i64 }* - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %1, i8** %3, align 8 - %4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %2, i64* %4, align 8 - %5 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo = load i8*, i8** %5, align 8 - %6 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi = load i64, i64* %6, align 8 - %7 = call i8 @test_contains(i8* %lo, i64 %hi, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i64 4) - %8 = trunc i8 %7 to i1 - br i1 %8, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i64 ptrtoint (%.fault* @"test_ReadError$BAD_READ" to i64) - -if.exit: ; preds = %entry - %9 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo1 = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi2 = load i64, i64* %10, align 8 - %11 = call i8 @test_contains(i8* %lo1, i64 %hi2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0), i64 12) - %12 = trunc i8 %11 to i1 - br i1 %12, label %if.then3, label %if.exit4 - -if.then3: ; preds = %if.exit - %13 = getelementptr inbounds %Doc, %Doc* %literal, i32 0, i32 0 - store %Head* null, %Head** %13, align 8 - %14 = bitcast %Doc* %0 to i8* - %15 = bitcast %Doc* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %14, i8* align 8 %15, i32 8, i1 false) - ret i64 0 - -if.exit4: ; preds = %if.exit - %16 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo5 = load i8*, i8** %16, align 8 - %17 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi6 = load i64, i64* %17, align 8 - %18 = call i8 @test_contains(i8* %lo5, i64 %hi6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i64 13) - %19 = trunc i8 %18 to i1 - br i1 %19, label %if.then7, label %if.exit13 - -if.then7: ; preds = %if.exit4 - %20 = getelementptr inbounds %Doc, %Doc* %literal9, i32 0, i32 0 - %21 = getelementptr inbounds %Head, %Head* %literal10, i32 0, i32 0 - store %"char[]"* null, %"char[]"** %21, align 8 - %22 = bitcast %Head* %value to i8* - %23 = bitcast %Head* %literal10 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %22, i8* align 8 %23, i32 8, i1 false) - %24 = call i8* @std_core_mem_malloc(i64 8) #2 - %ptrptr = bitcast i8* %24 to %Head* - store %Head* %ptrptr, %Head** %temp, align 8 - %25 = load %Head*, %Head** %temp, align 8 - %not = icmp eq %Head* %25, null - br i1 %not, label %if.then11, label %if.exit12 - -if.then11: ; preds = %if.then7 - store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var, align 8 - br label %guard_block - -if.exit12: ; preds = %if.then7 - %26 = load %Head*, %Head** %temp, align 8 - %27 = bitcast %Head* %26 to i8* - %28 = bitcast %Head* %value to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %27, i8* align 8 %28, i32 8, i1 false) - br label %noerr_block - -guard_block: ; preds = %if.then11 - %29 = load i64, i64* %error_var, align 8 - ret i64 %29 - -noerr_block: ; preds = %if.exit12 - %30 = load %Head*, %Head** %temp, align 8 - store %Head* %30, %Head** %20, align 8 - %31 = bitcast %Doc* %0 to i8* - %32 = bitcast %Doc* %literal9 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %31, i8* align 8 %32, i32 8, i1 false) - ret i64 0 - -if.exit13: ; preds = %if.exit4 - %33 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo14 = load i8*, i8** %33, align 8 - %34 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi15 = load i64, i64* %34, align 8 - %35 = call i8 @test_contains(i8* %lo14, i64 %hi15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i32 0, i32 0), i64 11) - %36 = trunc i8 %35 to i1 - br i1 %36, label %if.then16, label %if.exit38 - -if.then16: ; preds = %if.exit13 - %37 = getelementptr inbounds %Doc, %Doc* %literal18, i32 0, i32 0 - %38 = bitcast %Head* %literal21 to %"char[]"** - store %"char[]"* null, %"char[]"** %38, align 8 - %39 = getelementptr inbounds %Head, %Head* %literal21, i32 0, i32 0 - store %"char[]" zeroinitializer, %"char[]"* %value23, align 8 - %40 = call i8* @std_core_mem_malloc(i64 16) #2 - %ptrptr25 = bitcast i8* %40 to %"char[]"* - store %"char[]"* %ptrptr25, %"char[]"** %temp24, align 8 - %41 = load %"char[]"*, %"char[]"** %temp24, align 8 - %not26 = icmp eq %"char[]"* %41, null - br i1 %not26, label %if.then27, label %if.exit28 - -if.then27: ; preds = %if.then16 - store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var22, align 8 - br label %guard_block29 - -if.exit28: ; preds = %if.then16 - %42 = load %"char[]"*, %"char[]"** %temp24, align 8 - %43 = bitcast %"char[]"* %42 to i8* - %44 = bitcast %"char[]"* %value23 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %43, i8* align 8 %44, i32 16, i1 false) - br label %noerr_block30 - -guard_block29: ; preds = %if.then27 - %45 = load i64, i64* %error_var22, align 8 - ret i64 %45 - -noerr_block30: ; preds = %if.exit28 - %46 = load %"char[]"*, %"char[]"** %temp24, align 8 - store %"char[]"* %46, %"char[]"** %39, align 8 - %47 = bitcast %Head* %value20 to i8* - %48 = bitcast %Head* %literal21 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %47, i8* align 8 %48, i32 8, i1 false) - %49 = call i8* @std_core_mem_malloc(i64 8) #2 - %ptrptr32 = bitcast i8* %49 to %Head* - store %Head* %ptrptr32, %Head** %temp31, align 8 - %50 = load %Head*, %Head** %temp31, align 8 - %not33 = icmp eq %Head* %50, null - br i1 %not33, label %if.then34, label %if.exit35 - -if.then34: ; preds = %noerr_block30 - store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var19, align 8 - br label %guard_block36 - -if.exit35: ; preds = %noerr_block30 - %51 = load %Head*, %Head** %temp31, align 8 - %52 = bitcast %Head* %51 to i8* - %53 = bitcast %Head* %value20 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %52, i8* align 8 %53, i32 8, i1 false) - br label %noerr_block37 - -guard_block36: ; preds = %if.then34 - %54 = load i64, i64* %error_var19, align 8 - ret i64 %54 - -noerr_block37: ; preds = %if.exit35 - %55 = load %Head*, %Head** %temp31, align 8 - store %Head* %55, %Head** %37, align 8 - %56 = bitcast %Doc* %0 to i8* - %57 = bitcast %Doc* %literal18 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %56, i8* align 8 %57, i32 8, i1 false) - ret i64 0 - -if.exit38: ; preds = %if.exit13 - %58 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %59 = load i64, i64* %58, align 8 - %uisitrunc = trunc i64 %59 to i32 - %60 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %61 = load i8*, i8** %60, align 8 - %62 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i32 0, i32 0), i32 %uisitrunc, i8* %61) - store i32 %62, i32* %len, align 4 - %63 = load i32, i32* %len, align 4 - %siuiext = sext i32 %63 to i64 - %add = add i64 %siuiext, 1 - %64 = call i8* @std_core_mem_malloc(i64 %add) #2 - store i8* %64, i8** %str, align 8 - %65 = load i8*, i8** %str, align 8 - %not39 = icmp eq i8* %65, null - br i1 %not39, label %if.then40, label %if.exit41 - -if.then40: ; preds = %if.exit38 - ret i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64) - -if.exit41: ; preds = %if.exit38 - %66 = load i8*, i8** %str, align 8 - %67 = load i32, i32* %len, align 4 - %siuiext42 = sext i32 %67 to i64 - %add43 = add i64 %siuiext42, 1 - %68 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %69 = load i64, i64* %68, align 8 - %uisitrunc44 = trunc i64 %69 to i32 - %70 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %71 = load i8*, i8** %70, align 8 - %72 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %66, i64 %add43, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i32 %uisitrunc44, i8* %71) - %73 = getelementptr inbounds %Doc, %Doc* %literal46, i32 0, i32 0 - %74 = bitcast %Head* %literal49 to %"char[]"** - store %"char[]"* null, %"char[]"** %74, align 8 - %75 = getelementptr inbounds %Head, %Head* %literal49, i32 0, i32 0 - %76 = load i8*, i8** %str, align 8 - %77 = load i32, i32* %len, align 4 - %sub = sub i32 %77, 1 - %sisiext = sext i32 %sub to i64 - %78 = add i64 %sisiext, 1 - %size = sub i64 %78, 0 - %ptroffset = getelementptr inbounds i8, i8* %76, i64 0 - %79 = insertvalue %"char[]" undef, i8* %ptroffset, 0 - %80 = insertvalue %"char[]" %79, i64 %size, 1 - store %"char[]" %80, %"char[]"* %value51, align 8 - %81 = call i8* @std_core_mem_malloc(i64 16) #2 - %ptrptr53 = bitcast i8* %81 to %"char[]"* - store %"char[]"* %ptrptr53, %"char[]"** %temp52, align 8 - %82 = load %"char[]"*, %"char[]"** %temp52, align 8 - %not54 = icmp eq %"char[]"* %82, null - br i1 %not54, label %if.then55, label %if.exit56 - -if.then55: ; preds = %if.exit41 - store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var50, align 8 - br label %guard_block57 - -if.exit56: ; preds = %if.exit41 - %83 = load %"char[]"*, %"char[]"** %temp52, align 8 - %84 = bitcast %"char[]"* %83 to i8* - %85 = bitcast %"char[]"* %value51 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %84, i8* align 8 %85, i32 16, i1 false) - br label %noerr_block58 - -guard_block57: ; preds = %if.then55 - %86 = load i64, i64* %error_var50, align 8 - ret i64 %86 - -noerr_block58: ; preds = %if.exit56 - %87 = load %"char[]"*, %"char[]"** %temp52, align 8 - store %"char[]"* %87, %"char[]"** %75, align 8 - %88 = bitcast %Head* %value48 to i8* - %89 = bitcast %Head* %literal49 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %88, i8* align 8 %89, i32 8, i1 false) - %90 = call i8* @std_core_mem_malloc(i64 8) #2 - %ptrptr60 = bitcast i8* %90 to %Head* - store %Head* %ptrptr60, %Head** %temp59, align 8 - %91 = load %Head*, %Head** %temp59, align 8 - %not61 = icmp eq %Head* %91, null - br i1 %not61, label %if.then62, label %if.exit63 - -if.then62: ; preds = %noerr_block58 - store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var47, align 8 - br label %guard_block64 - -if.exit63: ; preds = %noerr_block58 - %92 = load %Head*, %Head** %temp59, align 8 - %93 = bitcast %Head* %92 to i8* - %94 = bitcast %Head* %value48 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %93, i8* align 8 %94, i32 8, i1 false) - br label %noerr_block65 - -guard_block64: ; preds = %if.then62 - %95 = load i64, i64* %error_var47, align 8 - ret i64 %95 - -noerr_block65: ; preds = %if.exit63 - %96 = load %Head*, %Head** %temp59, align 8 - store %Head* %96, %Head** %73, align 8 - %97 = bitcast %Doc* %0 to i8* - %98 = bitcast %Doc* %literal46 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %97, i8* align 8 %98, i32 8, i1 false) - ret i64 0 -} - -; Function Attrs: nounwind -define { %"char[]"*, i8 } @test_buildSummary(%Head* %0) #0 { -entry: - %doc = alloca %Doc, align 8 - %literal = alloca %Summary, align 8 - %1 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0 - store %Head* %0, %Head** %1, align 8 - %2 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 0 - store %"char[]"* null, %"char[]"** %2, align 8 - %3 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 1 - store i8 0, i8* %3, align 8 - %4 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 0 - %5 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0 - %6 = load %Head*, %Head** %5, align 8 - %ptrbool = icmp ne %Head* %6, null - br i1 %ptrbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - %7 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0 - %8 = load %Head*, %Head** %7, align 8 - %9 = getelementptr inbounds %Head, %Head* %8, i32 0, i32 0 - %10 = load %"char[]"*, %"char[]"** %9, align 8 - %ptrptr = bitcast %"char[]"* %10 to i8* - br label %cond.phi - -cond.rhs: ; preds = %entry - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %cond.lhs - %val = phi i8* [ %ptrptr, %cond.lhs ], [ null, %cond.rhs ] - %ptrptr1 = bitcast i8* %val to %"char[]"* - store %"char[]"* %ptrptr1, %"char[]"** %4, align 8 - %11 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 1 - store i8 1, i8* %11, align 8 - %12 = bitcast %Summary* %literal to { %"char[]"*, i8 }* - %13 = load { %"char[]"*, i8 }, { %"char[]"*, i8 }* %12, align 8 - ret { %"char[]"*, i8 } %13 -} - -; Function Attrs: nounwind -define { %"char[]"*, i8 } @test_readAndBuildSummary(i8* %0, i64 %1) #0 { -entry: - %url = alloca %"char[]", align 8 - %retparam = alloca %Doc, align 8 - %result = alloca %Summary, align 8 - %literal = alloca %Summary, align 8 - %taddr = alloca %Summary, align 8 - %pair = bitcast %"char[]"* %url to { i8*, i64 }* - %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %2, align 8 - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - %4 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo = load i8*, i8** %4, align 8 - %5 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi = load i64, i64* %5, align 8 - %6 = call i64 @test_readDoc(%Doc* %retparam, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %6, 0 - br i1 %not_err, label %after_check, label %else_block - -after_check: ; preds = %entry - %7 = getelementptr inbounds %Doc, %Doc* %retparam, i32 0, i32 0 - %8 = load %Head*, %Head** %7, align 8 - %9 = call { %"char[]"*, i8 } @test_buildSummary(%Head* %8) - %10 = bitcast %Summary* %result to { %"char[]"*, i8 }* - store { %"char[]"*, i8 } %9, { %"char[]"*, i8 }* %10, align 8 - %11 = load %Summary, %Summary* %result, align 8 - br label %phi_block - -else_block: ; preds = %entry - %12 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 0 - store %"char[]"* null, %"char[]"** %12, align 8 - %13 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 1 - store i8 0, i8* %13, align 8 - %14 = load %Summary, %Summary* %literal, align 8 - br label %phi_block - -phi_block: ; preds = %else_block, %after_check - %val = phi %Summary [ %11, %after_check ], [ %14, %else_block ] - store %Summary %val, %Summary* %taddr, align 8 - %15 = bitcast %Summary* %taddr to { %"char[]"*, i8 }* - %16 = load { %"char[]"*, i8 }, { %"char[]"*, i8 }* %15, align 8 - ret { %"char[]"*, i8 } %16 -} - -; Function Attrs: nounwind -define i64 @test_isTitleNonEmpty(i8* %0, %Head* %1) #0 { -entry: - %doc = alloca %Doc, align 8 - %head = alloca %"char[]"*, align 8 - %reterr = alloca i64, align 8 - %2 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0 - store %Head* %1, %Head** %2, align 8 - %3 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0 - %4 = load %Head*, %Head** %3, align 8 - %not = icmp eq %Head* %4, null - br i1 %not, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i64 ptrtoint (%.fault* @"test_TitleResult$TITLE_MISSING" to i64) - -if.exit: ; preds = %entry - %5 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0 - %6 = load %Head*, %Head** %5, align 8 - %7 = getelementptr inbounds %Head, %Head* %6, i32 0, i32 0 - %8 = load %"char[]"*, %"char[]"** %7, align 8 - store %"char[]"* %8, %"char[]"** %head, align 8 - %9 = load %"char[]"*, %"char[]"** %head, align 8 - %not1 = icmp eq %"char[]"* %9, null - br i1 %not1, label %if.then2, label %if.exit3 - -if.then2: ; preds = %if.exit - ret i64 ptrtoint (%.fault* @"test_TitleResult$TITLE_MISSING" to i64) - -if.exit3: ; preds = %if.exit - %10 = load %"char[]"*, %"char[]"** %head, align 8 - %11 = getelementptr inbounds %"char[]", %"char[]"* %10, i32 0, i32 1 - %12 = load i64, i64* %11, align 8 - %lt = icmp ult i64 0, %12 - %13 = zext i1 %lt to i8 - store i8 %13, i8* %0, align 1 - ret i64 0 -} - -; Function Attrs: nounwind -define i64 @test_readWhetherTitleNonEmpty(i8* %0, i8* %1, i64 %2) #0 { -entry: - %url = alloca %"char[]", align 8 - %reterr = alloca i64, align 8 - %retparam = alloca i8, align 1 - %retparam1 = alloca %Doc, align 8 - %pair = bitcast %"char[]"* %url to { i8*, i64 }* - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %1, i8** %3, align 8 - %4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %2, i64* %4, align 8 - %5 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo = load i8*, i8** %5, align 8 - %6 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi = load i64, i64* %6, align 8 - %7 = call i64 @test_readDoc(%Doc* %retparam1, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %7, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %7, i64* %reterr, align 8 - br label %err_retblock - -after_check: ; preds = %entry - %8 = getelementptr inbounds %Doc, %Doc* %retparam1, i32 0, i32 0 - %9 = load %Head*, %Head** %8, align 8 - %10 = call i64 @test_isTitleNonEmpty(i8* %retparam, %Head* %9) - %not_err2 = icmp eq i64 %10, 0 - br i1 %not_err2, label %after_check4, label %assign_optional3 - -assign_optional3: ; preds = %after_check - store i64 %10, i64* %reterr, align 8 - br label %err_retblock - -after_check4: ; preds = %after_check - %11 = load i8, i8* %retparam, align 1 - store i8 %11, i8* %0, align 1 - ret i64 0 - -err_retblock: ; preds = %assign_optional3, %assign_optional - %12 = load i64, i64* %reterr, align 8 - ret i64 %12 -} - -; Function Attrs: nounwind -define i8* @test_bool_to_string(i8 zeroext %0) #0 { -entry: - %1 = trunc i8 %0 to i1 - %ternary = select i1 %1, %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i64 4 }, %"char[]" { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i32 0, i32 0), i64 5 } - %2 = extractvalue %"char[]" %ternary, 0 - ret i8* %2 -} - -; Function Attrs: nounwind -define i8* @test_nameFromError(i64 %0) #0 { -entry: - %switch = alloca i64, align 8 - store i64 %0, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %entry - %1 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.fault* @"test_TitleResult$TITLE_MISSING" to i64), %1 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0) - -next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (%.fault* @"test_ReadError$BAD_READ" to i64), %1 - br i1 %eq1, label %switch.case2, label %next_if3 - -switch.case2: ; preds = %next_if - ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i32 0, i32 0) - -next_if3: ; preds = %next_if - %eq4 = icmp eq i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), %1 - br i1 %eq4, label %switch.case5, label %next_if6 - -switch.case5: ; preds = %next_if3 - ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i32 0, i32 0) - -next_if6: ; preds = %next_if3 - br label %switch.default - -switch.default: ; preds = %next_if6 - ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i32 0, i32 0) -} - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %URLS = alloca %"char[][]", align 8 - %literal = alloca [5 x %"char[]"], align 16 - %.anon = alloca i64, align 8 - %.anon1 = alloca i64, align 8 - %url = alloca %"char[]", align 8 - %summary = alloca %Summary, align 8 - %result = alloca %Summary, align 8 - %title_sure = alloca %"char[]", align 8 - %has_title = alloca i8, align 1 - %has_title.f = alloca i64, align 8 - %retparam = alloca i8, align 1 - %0 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 0 - store %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i32 0, i32 0), i64 4 }, %"char[]"* %0, align 8 - %1 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 1 - store %"char[]" { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i32 0, i32 0), i64 11 }, %"char[]"* %1, align 8 - %2 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 2 - store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i32 0, i32 0), i64 13 }, %"char[]"* %2, align 8 - %3 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 3 - store %"char[]" { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i32 0, i32 0), i64 12 }, %"char[]"* %3, align 8 - %4 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 4 - store %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i32 0, i32 0), i64 4 }, %"char[]"* %4, align 8 - %5 = bitcast [5 x %"char[]"]* %literal to %"char[]"* - %6 = insertvalue %"char[][]" undef, %"char[]"* %5, 0 - %7 = insertvalue %"char[][]" %6, i64 5, 1 - store %"char[][]" %7, %"char[][]"* %URLS, align 8 - %8 = getelementptr inbounds %"char[][]", %"char[][]"* %URLS, i32 0, i32 1 - %9 = load i64, i64* %8, align 8 - store i64 %9, i64* %.anon, align 8 - store i64 0, i64* %.anon1, align 8 - br label %loop.cond - -loop.cond: ; preds = %phi_block12, %entry - %10 = load i64, i64* %.anon1, align 8 - %11 = load i64, i64* %.anon, align 8 - %lt = icmp ult i64 %10, %11 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %12 = getelementptr inbounds %"char[][]", %"char[][]"* %URLS, i32 0, i32 0 - %13 = load %"char[]"*, %"char[]"** %12, align 8 - %14 = load i64, i64* %.anon1, align 8 - %ptroffset = getelementptr inbounds %"char[]", %"char[]"* %13, i64 %14 - %15 = bitcast %"char[]"* %url to i8* - %16 = bitcast %"char[]"* %ptroffset to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %15, i8* align 8 %16, i32 16, i1 false) - %17 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %18 = load i64, i64* %17, align 8 - %uisitrunc = trunc i64 %18 to i32 - %19 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %20 = load i8*, i8** %19, align 8 - %21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.20, i32 0, i32 0), i32 %uisitrunc, i8* %20) - %22 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo = load i8*, i8** %22, align 8 - %23 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi = load i64, i64* %23, align 8 - %24 = call { %"char[]"*, i8 } @test_readAndBuildSummary(i8* %lo, i64 %hi) - %25 = bitcast %Summary* %result to { %"char[]"*, i8 }* - store { %"char[]"*, i8 } %24, { %"char[]"*, i8 }* %25, align 8 - %26 = bitcast %Summary* %summary to i8* - %27 = bitcast %Summary* %result to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %26, i8* align 8 %27, i32 16, i1 false) - %28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.21, i32 0, i32 0)) - %29 = load i8*, i8** @__stdoutp, align 8 - call void @test_Summary_print(%Summary* %summary, i8* %29) - %30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i32 0, i32 0)) - %31 = getelementptr inbounds %Summary, %Summary* %summary, i32 0, i32 0 - %32 = load %"char[]"*, %"char[]"** %31, align 8 - %ptrbool = icmp ne %"char[]"* %32, null - br i1 %ptrbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %loop.body - %33 = getelementptr inbounds %Summary, %Summary* %summary, i32 0, i32 0 - %34 = load %"char[]"*, %"char[]"** %33, align 8 - %35 = load %"char[]", %"char[]"* %34, align 8 - br label %cond.phi - -cond.rhs: ; preds = %loop.body - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %cond.lhs - %val = phi %"char[]" [ %35, %cond.lhs ], [ zeroinitializer, %cond.rhs ] - store %"char[]" %val, %"char[]"* %title_sure, align 8 - %36 = getelementptr inbounds %"char[]", %"char[]"* %title_sure, i32 0, i32 1 - %37 = load i64, i64* %36, align 8 - %uisitrunc2 = trunc i64 %37 to i32 - %38 = getelementptr inbounds %"char[]", %"char[]"* %title_sure, i32 0, i32 0 - %39 = load i8*, i8** %38, align 8 - %40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i32 0, i32 0), i32 %uisitrunc2, i8* %39) - %41 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0 - %lo3 = load i8*, i8** %41, align 8 - %42 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1 - %hi4 = load i64, i64* %42, align 8 - %43 = call i64 @test_readWhetherTitleNonEmpty(i8* %retparam, i8* %lo3, i64 %hi4) - %not_err = icmp eq i64 %43, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %cond.phi - store i64 %43, i64* %has_title.f, align 8 - br label %after_assign - -after_check: ; preds = %cond.phi - %44 = load i8, i8* %retparam, align 1 - store i8 %44, i8* %has_title, align 1 - store i64 0, i64* %has_title.f, align 8 - br label %after_assign - -after_assign: ; preds = %after_check, %assign_optional - %optval = load i64, i64* %has_title.f, align 8 - %not_err5 = icmp eq i64 %optval, 0 - br i1 %not_err5, label %after_check6, label %else_block - -after_check6: ; preds = %after_assign - %45 = load i8, i8* %has_title, align 1 - %46 = call i8* @test_bool_to_string(i8 %45) - br label %phi_block - -else_block: ; preds = %after_assign - %47 = load i64, i64* %has_title.f, align 8 - %48 = call i8* @test_nameFromError(i64 %47) - br label %phi_block - -phi_block: ; preds = %else_block, %after_check6 - %val7 = phi i8* [ %46, %after_check6 ], [ %48, %else_block ] - %optval8 = load i64, i64* %has_title.f, align 8 - %not_err9 = icmp eq i64 %optval8, 0 - br i1 %not_err9, label %after_check10, label %else_block11 - -after_check10: ; preds = %phi_block - %49 = load i8, i8* %has_title, align 1 - %50 = trunc i8 %49 to i1 - br label %phi_block12 - -else_block11: ; preds = %phi_block - br label %phi_block12 - -phi_block12: ; preds = %else_block11, %after_check10 - %val13 = phi i1 [ %50, %after_check10 ], [ false, %else_block11 ] - %ternary = select i1 %val13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.27, i32 0, i32 0) - %51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.25, i32 0, i32 0), i8* %val7, i8* %ternary) - %52 = load i64, i64* %.anon1, align 8 - %add = add i64 %52, 1 - store i64 %add, i64* %.anon1, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret void -} diff --git a/test/test_suite14/errors/error_semantic_fails.c3 b/test/test_suite14/errors/error_semantic_fails.c3 deleted file mode 100644 index bfafa510f..000000000 --- a/test/test_suite14/errors/error_semantic_fails.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fault Repeater -{ - A, - A // #error: This fault value was declared twice. -} diff --git a/test/test_suite14/errors/error_throw.c3 b/test/test_suite14/errors/error_throw.c3 deleted file mode 100644 index dacd9276b..000000000 --- a/test/test_suite14/errors/error_throw.c3 +++ /dev/null @@ -1,12 +0,0 @@ -module foo; - -fault Blurg -{ - Z -} - -fn void main() -{ - int! i = Blurg.Z!; - int! j = Blurg.Z!; -} \ No newline at end of file diff --git a/test/test_suite14/errors/error_union.c3 b/test/test_suite14/errors/error_union.c3 deleted file mode 100644 index b76a694c9..000000000 --- a/test/test_suite14/errors/error_union.c3 +++ /dev/null @@ -1,11 +0,0 @@ -module foo; - -fault Blurg -{ - X, Y, Z -} - -fn void main() -{ - anyerr foo; -} \ No newline at end of file diff --git a/test/test_suite14/errors/failable_catch.c3t b/test/test_suite14/errors/failable_catch.c3t deleted file mode 100644 index 683d45f13..000000000 --- a/test/test_suite14/errors/failable_catch.c3t +++ /dev/null @@ -1,151 +0,0 @@ -// #target: macos-x64 - -fault MyErr -{ - TEST -} - -macro foo(int x) -{ - if (x) return x; - return MyErr.TEST!; -} - -extern fn void printf(char*, ...); - -fn int main() -{ - int! a = foo(1); - - int! b = foo((a + 3) ?? 2); - int! c = foo(0); - printf("a = %d\n", a); - printf("b = %d\n", b); - printf("c = %d\n", c); - if (catch(c)) printf("c had error\n"); - c = 3; - printf("c = %d\n", c); - return 0; -} - -/* #expect: failable_catch.ll - -define i32 @main() #0 { -entry: - %a = alloca i32, align 4 - %a.f = alloca i64, align 8 - %x = alloca i32, align 4 - %blockret = alloca i32, align 4 - %b = alloca i32, align 4 - %b.f = alloca i64, align 8 - %x1 = alloca i32, align 4 - %blockret2 = alloca i32, align 4 - %c = alloca i32, align 4 - %c.f = alloca i64, align 8 - %x8 = alloca i32, align 4 - %blockret9 = alloca i32, align 4 - store i32 1, i32* %x, align 4 - %0 = load i32, i32* %x, align 4 - %intbool = icmp ne i32 %0, 0 - br i1 %intbool, label %if.then, label %if.exit -if.then: ; preds = %entry - %1 = load i32, i32* %x, align 4 - store i32 %1, i32* %blockret, align 4 - br label %expr_block.exit -if.exit: ; preds = %entry - store i64 ptrtoint (%.fault* @"failable_catch_MyErr$TEST" to i64), i64* %a.f, align 8 - br label %after_assign -expr_block.exit: ; preds = %if.then - %2 = load i32, i32* %blockret, align 4 - store i32 %2, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - br label %after_assign -after_assign: ; preds = %expr_block.exit, %if.exit - %optval = load i64, i64* %a.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %else_block -after_check: ; preds = %after_assign - %3 = load i32, i32* %a, align 4 - %add = add i32 %3, 3 - br label %phi_block -else_block: ; preds = %after_assign - br label %phi_block -phi_block: ; preds = %else_block, %after_check - %val = phi i32 [ %add, %after_check ], [ 2, %else_block ] - store i32 %val, i32* %x1, align 4 - %4 = load i32, i32* %x1, align 4 - %intbool3 = icmp ne i32 %4, 0 - br i1 %intbool3, label %if.then4, label %if.exit5 -if.then4: ; preds = %phi_block - %5 = load i32, i32* %x1, align 4 - store i32 %5, i32* %blockret2, align 4 - br label %expr_block.exit6 -if.exit5: ; preds = %phi_block - store i64 ptrtoint (%.fault* @"failable_catch_MyErr$TEST" to i64), i64* %b.f, align 8 - br label %after_assign7 -expr_block.exit6: ; preds = %if.then4 - %6 = load i32, i32* %blockret2, align 4 - store i32 %6, i32* %b, align 4 - store i64 0, i64* %b.f, align 8 - br label %after_assign7 -after_assign7: ; preds = %expr_block.exit6, %if.exit5 - store i32 0, i32* %x8, align 4 - %7 = load i32, i32* %x8, align 4 - %intbool10 = icmp ne i32 %7, 0 - br i1 %intbool10, label %if.then11, label %if.exit12 -if.then11: ; preds = %after_assign7 - %8 = load i32, i32* %x8, align 4 - store i32 %8, i32* %blockret9, align 4 - br label %expr_block.exit13 -if.exit12: ; preds = %after_assign7 - store i64 ptrtoint (%.fault* @"failable_catch_MyErr$TEST" to i64), i64* %c.f, align 8 - br label %after_assign14 -expr_block.exit13: ; preds = %if.then11 - %9 = load i32, i32* %blockret9, align 4 - store i32 %9, i32* %c, align 4 - store i64 0, i64* %c.f, align 8 - br label %after_assign14 -after_assign14: ; preds = %expr_block.exit13, %if.exit12 - %optval15 = load i64, i64* %a.f, align 8 - %not_err16 = icmp eq i64 %optval15, 0 - br i1 %not_err16, label %after_check17, label %voiderr -after_check17: ; preds = %after_assign14 - %10 = load i32, i32* %a, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 %10) - br label %voiderr -voiderr: ; preds = %after_check17, %after_assign14 - %optval18 = load i64, i64* %b.f, align 8 - %not_err19 = icmp eq i64 %optval18, 0 - br i1 %not_err19, label %after_check20, label %voiderr21 -after_check20: ; preds = %voiderr - %11 = load i32, i32* %b, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 %11) - br label %voiderr21 -voiderr21: ; preds = %after_check20, %voiderr - %optval22 = load i64, i64* %c.f, align 8 - %not_err23 = icmp eq i64 %optval22, 0 - br i1 %not_err23, label %after_check24, label %voiderr25 -after_check24: ; preds = %voiderr21 - %12 = load i32, i32* %c, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i32 %12) - br label %voiderr25 -voiderr25: ; preds = %after_check24, %voiderr21 - %13 = load i64, i64* %c.f, align 8 - %neq = icmp ne i64 %13, 0 - br i1 %neq, label %if.then26, label %if.exit27 -if.then26: ; preds = %voiderr25 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0)) - br label %if.exit27 -if.exit27: ; preds = %if.then26, %voiderr25 - store i32 3, i32* %c, align 4 - store i64 0, i64* %c.f, align 8 - %optval28 = load i64, i64* %c.f, align 8 - %not_err29 = icmp eq i64 %optval28, 0 - br i1 %not_err29, label %after_check30, label %voiderr31 -after_check30: ; preds = %if.exit27 - %14 = load i32, i32* %c, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 %14) - br label %voiderr31 -voiderr31: ; preds = %after_check30, %if.exit27 - ret i32 0 -} diff --git a/test/test_suite14/errors/general_error_regression.c3t b/test/test_suite14/errors/general_error_regression.c3t deleted file mode 100644 index 7f3da1d8f..000000000 --- a/test/test_suite14/errors/general_error_regression.c3t +++ /dev/null @@ -1,141 +0,0 @@ -// #target: macos-x64 -module foo; -import std::io; -import libc; -fault Foo -{ - X, - Y, - Z, - W, - W1 - - -} - -fault Foob -{ - X1, - Y2 -} - -define Bar = distinct int; - -enum MyEnum -{ - A, - B -} - -fn void Foo.hello(Foo *f) -{ - io::println("Hello from Foo"); -} - -fn void Bar.hello(Bar *b) -{ - io::println("Hello from Bar"); -} - -fn void MyEnum.hello(MyEnum *myenum) -{ - io::println("Hello from MyEnum"); -} -fn void main() -{ - Foo f = Foo.X; - Foo ef = Foo.Y; - anyerr x = f; - ulong z = (ulong)(x); - libc::printf("1: %p\n", z); - x = ef; - z = (ulong)(x); - libc::printf("2: %p\n", z); - x = Foo.W; - z = (ulong)(x); - libc::printf("21: %p\n", z); - x = Foo.W1; - z = (ulong)(x); - libc::printf("22: %p\n", z); - x = Foob.X1; - z = (ulong)(x); - libc::printf("3: %p\n", z); - x = Foob.Y2; - z = (ulong)(x); - libc::printf("4: %p\n", z); - Bar b; - MyEnum a = MyEnum.A; - f.hello(); - b.hello(); - a.hello(); -} - -/* #expect: foo.ll - -define void @foo_Foo_hello(i64* %0) #0 { -entry: - %1 = call i32 @std_io_println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i32 0, i32 0)) #1 - ret void -} - -define void @foo_Bar_hello(i32* %0) #0 { -entry: - %1 = call i32 @std_io_println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i32 0, i32 0)) #1 - ret void -} - -define void @foo_MyEnum_hello(i32* %0) #0 { -entry: - %1 = call i32 @std_io_println(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i32 0, i32 0)) #1 - ret void -} - -define void @foo_main() #0 { -entry: - %f = alloca i64, align 8 - %ef = alloca i64, align 8 - %x = alloca i64, align 8 - %z = alloca i64, align 8 - %b = alloca i32, align 4 - %a = alloca i32, align 4 - store i64 ptrtoint (%.fault* @"foo_Foo$X" to i64), i64* %f, align 8 - store i64 ptrtoint (%.fault* @"foo_Foo$Y" to i64), i64* %ef, align 8 - %0 = load i64, i64* %f, align 8 - store i64 %0, i64* %x, align 8 - %1 = load i64, i64* %x, align 8 - store i64 %1, i64* %z, align 8 - %2 = load i64, i64* %z, align 8 - %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i64 %2) - %4 = load i64, i64* %ef, align 8 - store i64 %4, i64* %x, align 8 - %5 = load i64, i64* %x, align 8 - store i64 %5, i64* %z, align 8 - %6 = load i64, i64* %z, align 8 - %7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i64 %6) - store i64 ptrtoint (%.fault* @"foo_Foo$W" to i64), i64* %x, align 8 - %8 = load i64, i64* %x, align 8 - store i64 %8, i64* %z, align 8 - %9 = load i64, i64* %z, align 8 - %10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i64 %9) - store i64 ptrtoint (%.fault* @"foo_Foo$W1" to i64), i64* %x, align 8 - %11 = load i64, i64* %x, align 8 - store i64 %11, i64* %z, align 8 - %12 = load i64, i64* %z, align 8 - %13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0), i64 %12) - store i64 ptrtoint (%.fault* @"foo_Foob$X1" to i64), i64* %x, align 8 - %14 = load i64, i64* %x, align 8 - store i64 %14, i64* %z, align 8 - %15 = load i64, i64* %z, align 8 - %16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i32 0, i32 0), i64 %15) - store i64 ptrtoint (%.fault* @"foo_Foob$Y2" to i64), i64* %x, align 8 - %17 = load i64, i64* %x, align 8 - store i64 %17, i64* %z, align 8 - %18 = load i64, i64* %z, align 8 - %19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i32 0, i32 0), i64 %18) - store i32 0, i32* %b, align 4 - store i32 0, i32* %a, align 4 - call void @foo_Foo_hello(i64* %f) - call void @foo_Bar_hello(i32* %b) - call void @foo_MyEnum_hello(i32* %a) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/illegal_use_of_failable.c3 b/test/test_suite14/errors/illegal_use_of_failable.c3 deleted file mode 100644 index 6d33a20ee..000000000 --- a/test/test_suite14/errors/illegal_use_of_failable.c3 +++ /dev/null @@ -1,14 +0,0 @@ -fn void syntaxErrors() -{ - int! i = 0; - while (i + 1) {} // #error: optional, but was 'int!' - if (i + 1) {} // #error: optional, but was 'int!' - for (int x = i;;) {} // #error: 'int!' to 'int' - for (int x = 0; x < i + 1;) {} // #error: optional, but was 'bool!'. - for (int x = 0; x < 10; x += i + 1) {} // #error: Cannot assign an optional value to a non-optional - switch (i + 1) // #error: optional, but was 'int!' - { - default: - i + 1; - } -} diff --git a/test/test_suite14/errors/macro_err.c3t b/test/test_suite14/errors/macro_err.c3t deleted file mode 100644 index 7f89c95f8..000000000 --- a/test/test_suite14/errors/macro_err.c3t +++ /dev/null @@ -1,54 +0,0 @@ -// #target: macos-x64 -module test; -import libc; -fn int! abc() -{ - return 1; -} -macro test() -{ - return abc()?; -} - -fn void main() -{ - libc::printf("%d\n", test() ?? 2); -} - -/* #expect: test.ll - - -define i64 @test_abc(i32* %0) #0 { -entry: - %reterr = alloca i64, align 8 - store i32 1, i32* %0, align 4 - ret i64 0 -} - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %error_var = alloca i64, align 8 - %retparam = alloca i32, align 4 - %0 = call i64 @test_abc(i32* %retparam) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %0, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - ret void - -noerr_block: ; preds = %after_check - %1 = load i32, i32* %retparam, align 4 - br label %phi_block - -phi_block: ; preds = %noerr_block - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %1) - ret void -} diff --git a/test/test_suite14/errors/macro_err2.c3t b/test/test_suite14/errors/macro_err2.c3t deleted file mode 100644 index d34314250..000000000 --- a/test/test_suite14/errors/macro_err2.c3t +++ /dev/null @@ -1,59 +0,0 @@ -// #target: macos-x64 -module test; -import libc; -fault Tester { FOO } - -fn int! abc() -{ - return Tester.FOO!; -} -macro test() -{ - defer libc::printf("Test2\n"); - return abc(); -} - -fn void main() -{ - defer libc::printf("Test1\n"); - libc::printf("%d\n", test() ?? 2); -} - -/* #expect: test.ll - -define i64 @test_abc(i32* %0) #0 { -entry: - ret i64 ptrtoint (%.fault* @"test_Tester$FOO" to i64) -} - -define void @test_main() #0 { -entry: - %blockret = alloca i32, align 4 - %retparam = alloca i32, align 4 - %0 = call i64 @test_abc(i32* %retparam) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %opt_block_cleanup - -after_check: ; preds = %entry - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0)) - %2 = load i32, i32* %retparam, align 4 - store i32 %2, i32* %blockret, align 4 - br label %expr_block.exit - -opt_block_cleanup: ; preds = %entry - %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0)) - br label %else_block - -expr_block.exit: ; preds = %after_check - %4 = load i32, i32* %blockret, align 4 - br label %phi_block - -else_block: ; preds = %opt_block_cleanup - br label %phi_block - -phi_block: ; preds = %else_block, %expr_block.exit - %val = phi i32 [ %4, %expr_block.exit ], [ 2, %else_block ] - %5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %val) - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0)) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/macro_err3.c3t b/test/test_suite14/errors/macro_err3.c3t deleted file mode 100644 index 590aebdde..000000000 --- a/test/test_suite14/errors/macro_err3.c3t +++ /dev/null @@ -1,37 +0,0 @@ -// #target: macos-x64 -module test; -import libc; -fault Tester { FOO } - - -macro test() -{ - defer libc::printf("Test2\n"); - return Tester.FOO!; -} - -fn void main() -{ - defer libc::printf("Test1\n"); - libc::printf("%d\n", test() ?? 2); -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %blockret = alloca i32, align 4 - br label %opt_block_cleanup - -opt_block_cleanup: ; preds = %entry - %0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0)) - br label %else_block - -else_block: ; preds = %opt_block_cleanup - br label %phi_block - -phi_block: ; preds = %else_block - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 2) - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0)) - ret void -} diff --git a/test/test_suite14/errors/missing_bang.c3 b/test/test_suite14/errors/missing_bang.c3 deleted file mode 100644 index 93d41fa64..000000000 --- a/test/test_suite14/errors/missing_bang.c3 +++ /dev/null @@ -1,7 +0,0 @@ - -fault Bob { FOO } - -fn int! test() -{ - return Bob.FOO; // #error: You need to add a trailing -} \ No newline at end of file diff --git a/test/test_suite14/errors/more_optional_tests.c3 b/test/test_suite14/errors/more_optional_tests.c3 deleted file mode 100644 index 141fbfc65..000000000 --- a/test/test_suite14/errors/more_optional_tests.c3 +++ /dev/null @@ -1,13 +0,0 @@ -module foo; - -fault Foo { ABC } - -fn void test() -{ - int x = Foo.ABC! ?? 123; -} - -fn void test2() -{ - int! y = Foo.ABC! ?? Foo.ABC!; -} \ No newline at end of file diff --git a/test/test_suite14/errors/no_common.c3 b/test/test_suite14/errors/no_common.c3 deleted file mode 100644 index 563fdafaa..000000000 --- a/test/test_suite14/errors/no_common.c3 +++ /dev/null @@ -1,13 +0,0 @@ -fn int! abc() -{ - return 1; -} -macro test() -{ - abc()?; -} - -fn void main() -{ - test() ?? 2; // #error: Cannot find a common type for 'void' and 'int' -} \ No newline at end of file diff --git a/test/test_suite14/errors/optional_chained_init.c3t b/test/test_suite14/errors/optional_chained_init.c3t deleted file mode 100644 index 914d6cff9..000000000 --- a/test/test_suite14/errors/optional_chained_init.c3t +++ /dev/null @@ -1,625 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fault Test { FOO } - -fn void test1() -{ - int! a = 1; - int! b = a = Test.FOO!; - if (catch err = a) io::printfn("A err was: %s", err); - if (catch err = b) io::printfn("B err was: %s", err); - io::printfn("A was: %s", a); - io::printfn("B was: %s", b); -} - -fn void test2() -{ - int! x = Test.FOO!; - int! a = 1; - int! b = a = x; - if (catch err = a) io::printfn("A err was: %s", err); - if (catch err = b) io::printfn("B err was: %s", err); - io::printfn("A was: %s", a); - io::printfn("B was: %s", b); -} - - -fn void test3() -{ - int! x = 23; - int! a = 1; - int! b = a = x; - if (catch err = a) io::printfn("A err was: %s", err); - if (catch err = b) io::printfn("B err was: %s", err); - io::printfn("A was: %s", a); - io::printfn("B was: %s", b); -} - -fn void main() -{ - test1(); - test2(); - test3(); -} - -/* #expect: test.ll - -; Function Attrs: nounwind -define void @test_test1() #0 { -entry: - %a = alloca i32, align 4 - %a.f = alloca i64, align 8 - %b = alloca i32, align 4 - %b.f = alloca i64, align 8 - %err = alloca i64, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %err3 = alloca i64, align 8 - %retparam12 = alloca i64, align 8 - %varargslots13 = alloca [1 x %variant], align 16 - %taddr14 = alloca %"variant[]", align 8 - %retparam21 = alloca i64, align 8 - %varargslots22 = alloca [1 x %variant], align 16 - %taddr26 = alloca %"variant[]", align 8 - %retparam32 = alloca i64, align 8 - %varargslots33 = alloca [1 x %variant], align 16 - %taddr37 = alloca %"variant[]", align 8 - store i32 1, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %a.f, align 8 - store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %b.f, align 8 - br label %after_assign - -after_assign: ; preds = %entry - br label %testblock - -testblock: ; preds = %after_assign - %optval = load i64, i64* %a.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %testblock - store i64 %optval, i64* %err, align 8 - br label %end_block - -after_check: ; preds = %testblock - store i64 0, i64* %err, align 8 - br label %end_block - -end_block: ; preds = %after_check, %assign_optional - %0 = load i64, i64* %err, align 8 - %neq = icmp ne i64 %0, 0 - br i1 %neq, label %if.then, label %if.exit - -if.then: ; preds = %end_block - %1 = bitcast i64* %err to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %4 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %3, %variant* %4, align 16 - %5 = bitcast [1 x %variant]* %varargslots to %variant* - %6 = insertvalue %"variant[]" undef, %variant* %5, 0 - %7 = insertvalue %"variant[]" %6, i64 1, 1 - store %"variant[]" %7, %"variant[]"* %taddr, align 8 - %8 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0 - %lo = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1 - %hi = load i64, i64* %10, align 8 - %11 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i64 13, i8* %lo, i64 %hi) - %not_err1 = icmp eq i64 %11, 0 - br i1 %not_err1, label %after_check2, label %voiderr - -after_check2: ; preds = %if.then - br label %voiderr - -voiderr: ; preds = %after_check2, %if.then - br label %if.exit - -if.exit: ; preds = %voiderr, %end_block - br label %testblock4 - -testblock4: ; preds = %if.exit - %optval5 = load i64, i64* %b.f, align 8 - %not_err6 = icmp eq i64 %optval5, 0 - br i1 %not_err6, label %after_check8, label %assign_optional7 - -assign_optional7: ; preds = %testblock4 - store i64 %optval5, i64* %err3, align 8 - br label %end_block9 - -after_check8: ; preds = %testblock4 - store i64 0, i64* %err3, align 8 - br label %end_block9 - -end_block9: ; preds = %after_check8, %assign_optional7 - %12 = load i64, i64* %err3, align 8 - %neq10 = icmp ne i64 %12, 0 - br i1 %neq10, label %if.then11, label %if.exit20 - -if.then11: ; preds = %end_block9 - %13 = bitcast i64* %err3 to i8* - %14 = insertvalue %variant undef, i8* %13, 0 - %15 = insertvalue %variant %14, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %16 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots13, i64 0, i64 0 - store %variant %15, %variant* %16, align 16 - %17 = bitcast [1 x %variant]* %varargslots13 to %variant* - %18 = insertvalue %"variant[]" undef, %variant* %17, 0 - %19 = insertvalue %"variant[]" %18, i64 1, 1 - store %"variant[]" %19, %"variant[]"* %taddr14, align 8 - %20 = bitcast %"variant[]"* %taddr14 to { i8*, i64 }* - %21 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %20, i32 0, i32 0 - %lo15 = load i8*, i8** %21, align 8 - %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %20, i32 0, i32 1 - %hi16 = load i64, i64* %22, align 8 - %23 = call i64 @std_io_printfn(i64* %retparam12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i64 13, i8* %lo15, i64 %hi16) - %not_err17 = icmp eq i64 %23, 0 - br i1 %not_err17, label %after_check18, label %voiderr19 - -after_check18: ; preds = %if.then11 - br label %voiderr19 - -voiderr19: ; preds = %after_check18, %if.then11 - br label %if.exit20 - -if.exit20: ; preds = %voiderr19, %end_block9 - %optval23 = load i64, i64* %a.f, align 8 - %not_err24 = icmp eq i64 %optval23, 0 - br i1 %not_err24, label %after_check25, label %voiderr31 - -after_check25: ; preds = %if.exit20 - %24 = bitcast i32* %a to i8* - %25 = insertvalue %variant undef, i8* %24, 0 - %26 = insertvalue %variant %25, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %27 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots22, i64 0, i64 0 - store %variant %26, %variant* %27, align 16 - %28 = bitcast [1 x %variant]* %varargslots22 to %variant* - %29 = insertvalue %"variant[]" undef, %variant* %28, 0 - %30 = insertvalue %"variant[]" %29, i64 1, 1 - store %"variant[]" %30, %"variant[]"* %taddr26, align 8 - %31 = bitcast %"variant[]"* %taddr26 to { i8*, i64 }* - %32 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %31, i32 0, i32 0 - %lo27 = load i8*, i8** %32, align 8 - %33 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %31, i32 0, i32 1 - %hi28 = load i64, i64* %33, align 8 - %34 = call i64 @std_io_printfn(i64* %retparam21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i64 9, i8* %lo27, i64 %hi28) - %not_err29 = icmp eq i64 %34, 0 - br i1 %not_err29, label %after_check30, label %voiderr31 - -after_check30: ; preds = %after_check25 - br label %voiderr31 - -voiderr31: ; preds = %after_check30, %after_check25, %if.exit20 - %optval34 = load i64, i64* %b.f, align 8 - %not_err35 = icmp eq i64 %optval34, 0 - br i1 %not_err35, label %after_check36, label %voiderr42 - -after_check36: ; preds = %voiderr31 - %35 = bitcast i32* %b to i8* - %36 = insertvalue %variant undef, i8* %35, 0 - %37 = insertvalue %variant %36, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %38 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots33, i64 0, i64 0 - store %variant %37, %variant* %38, align 16 - %39 = bitcast [1 x %variant]* %varargslots33 to %variant* - %40 = insertvalue %"variant[]" undef, %variant* %39, 0 - %41 = insertvalue %"variant[]" %40, i64 1, 1 - store %"variant[]" %41, %"variant[]"* %taddr37, align 8 - %42 = bitcast %"variant[]"* %taddr37 to { i8*, i64 }* - %43 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %42, i32 0, i32 0 - %lo38 = load i8*, i8** %43, align 8 - %44 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %42, i32 0, i32 1 - %hi39 = load i64, i64* %44, align 8 - %45 = call i64 @std_io_printfn(i64* %retparam32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i64 9, i8* %lo38, i64 %hi39) - %not_err40 = icmp eq i64 %45, 0 - br i1 %not_err40, label %after_check41, label %voiderr42 - -after_check41: ; preds = %after_check36 - br label %voiderr42 - -voiderr42: ; preds = %after_check41, %after_check36, %voiderr31 - ret void -} - -; Function Attrs: nounwind -define void @test_test2() #0 { -entry: - %x = alloca i32, align 4 - %x.f = alloca i64, align 8 - %a = alloca i32, align 4 - %a.f = alloca i64, align 8 - %b = alloca i32, align 4 - %b.f = alloca i64, align 8 - %err = alloca i64, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %err8 = alloca i64, align 8 - %retparam17 = alloca i64, align 8 - %varargslots18 = alloca [1 x %variant], align 16 - %taddr19 = alloca %"variant[]", align 8 - %retparam26 = alloca i64, align 8 - %varargslots27 = alloca [1 x %variant], align 16 - %taddr31 = alloca %"variant[]", align 8 - %retparam37 = alloca i64, align 8 - %varargslots38 = alloca [1 x %variant], align 16 - %taddr42 = alloca %"variant[]", align 8 - store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %x.f, align 8 - store i32 1, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - %optval = load i64, i64* %x.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %a.f, align 8 - br label %optional_assign_jump - -after_check: ; preds = %entry - %0 = load i32, i32* %x, align 4 - store i32 %0, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - br label %after_assign - -optional_assign_jump: ; preds = %assign_optional - %reload_err = load i64, i64* %a.f, align 8 - store i64 %reload_err, i64* %b.f, align 8 - br label %after_assign1 - -after_assign: ; preds = %after_check - store i32 %0, i32* %b, align 4 - store i64 0, i64* %b.f, align 8 - br label %after_assign1 - -after_assign1: ; preds = %after_assign, %optional_assign_jump - br label %testblock - -testblock: ; preds = %after_assign1 - %optval2 = load i64, i64* %a.f, align 8 - %not_err3 = icmp eq i64 %optval2, 0 - br i1 %not_err3, label %after_check5, label %assign_optional4 - -assign_optional4: ; preds = %testblock - store i64 %optval2, i64* %err, align 8 - br label %end_block - -after_check5: ; preds = %testblock - store i64 0, i64* %err, align 8 - br label %end_block - -end_block: ; preds = %after_check5, %assign_optional4 - %1 = load i64, i64* %err, align 8 - %neq = icmp ne i64 %1, 0 - br i1 %neq, label %if.then, label %if.exit - -if.then: ; preds = %end_block - %2 = bitcast i64* %err to i8* - %3 = insertvalue %variant undef, i8* %2, 0 - %4 = insertvalue %variant %3, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %5 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %4, %variant* %5, align 16 - %6 = bitcast [1 x %variant]* %varargslots to %variant* - %7 = insertvalue %"variant[]" undef, %variant* %6, 0 - %8 = insertvalue %"variant[]" %7, i64 1, 1 - store %"variant[]" %8, %"variant[]"* %taddr, align 8 - %9 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 0 - %lo = load i8*, i8** %10, align 8 - %11 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 1 - %hi = load i64, i64* %11, align 8 - %12 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i64 13, i8* %lo, i64 %hi) - %not_err6 = icmp eq i64 %12, 0 - br i1 %not_err6, label %after_check7, label %voiderr - -after_check7: ; preds = %if.then - br label %voiderr - -voiderr: ; preds = %after_check7, %if.then - br label %if.exit - -if.exit: ; preds = %voiderr, %end_block - br label %testblock9 - -testblock9: ; preds = %if.exit - %optval10 = load i64, i64* %b.f, align 8 - %not_err11 = icmp eq i64 %optval10, 0 - br i1 %not_err11, label %after_check13, label %assign_optional12 - -assign_optional12: ; preds = %testblock9 - store i64 %optval10, i64* %err8, align 8 - br label %end_block14 - -after_check13: ; preds = %testblock9 - store i64 0, i64* %err8, align 8 - br label %end_block14 - -end_block14: ; preds = %after_check13, %assign_optional12 - %13 = load i64, i64* %err8, align 8 - %neq15 = icmp ne i64 %13, 0 - br i1 %neq15, label %if.then16, label %if.exit25 - -if.then16: ; preds = %end_block14 - %14 = bitcast i64* %err8 to i8* - %15 = insertvalue %variant undef, i8* %14, 0 - %16 = insertvalue %variant %15, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %17 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots18, i64 0, i64 0 - store %variant %16, %variant* %17, align 16 - %18 = bitcast [1 x %variant]* %varargslots18 to %variant* - %19 = insertvalue %"variant[]" undef, %variant* %18, 0 - %20 = insertvalue %"variant[]" %19, i64 1, 1 - store %"variant[]" %20, %"variant[]"* %taddr19, align 8 - %21 = bitcast %"variant[]"* %taddr19 to { i8*, i64 }* - %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 0 - %lo20 = load i8*, i8** %22, align 8 - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 1 - %hi21 = load i64, i64* %23, align 8 - %24 = call i64 @std_io_printfn(i64* %retparam17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i64 13, i8* %lo20, i64 %hi21) - %not_err22 = icmp eq i64 %24, 0 - br i1 %not_err22, label %after_check23, label %voiderr24 - -after_check23: ; preds = %if.then16 - br label %voiderr24 - -voiderr24: ; preds = %after_check23, %if.then16 - br label %if.exit25 - -if.exit25: ; preds = %voiderr24, %end_block14 - %optval28 = load i64, i64* %a.f, align 8 - %not_err29 = icmp eq i64 %optval28, 0 - br i1 %not_err29, label %after_check30, label %voiderr36 - -after_check30: ; preds = %if.exit25 - %25 = bitcast i32* %a to i8* - %26 = insertvalue %variant undef, i8* %25, 0 - %27 = insertvalue %variant %26, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %28 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots27, i64 0, i64 0 - store %variant %27, %variant* %28, align 16 - %29 = bitcast [1 x %variant]* %varargslots27 to %variant* - %30 = insertvalue %"variant[]" undef, %variant* %29, 0 - %31 = insertvalue %"variant[]" %30, i64 1, 1 - store %"variant[]" %31, %"variant[]"* %taddr31, align 8 - %32 = bitcast %"variant[]"* %taddr31 to { i8*, i64 }* - %33 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 0 - %lo32 = load i8*, i8** %33, align 8 - %34 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 1 - %hi33 = load i64, i64* %34, align 8 - %35 = call i64 @std_io_printfn(i64* %retparam26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i64 9, i8* %lo32, i64 %hi33) - %not_err34 = icmp eq i64 %35, 0 - br i1 %not_err34, label %after_check35, label %voiderr36 - -after_check35: ; preds = %after_check30 - br label %voiderr36 - -voiderr36: ; preds = %after_check35, %after_check30, %if.exit25 - %optval39 = load i64, i64* %b.f, align 8 - %not_err40 = icmp eq i64 %optval39, 0 - br i1 %not_err40, label %after_check41, label %voiderr47 - -after_check41: ; preds = %voiderr36 - %36 = bitcast i32* %b to i8* - %37 = insertvalue %variant undef, i8* %36, 0 - %38 = insertvalue %variant %37, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %39 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots38, i64 0, i64 0 - store %variant %38, %variant* %39, align 16 - %40 = bitcast [1 x %variant]* %varargslots38 to %variant* - %41 = insertvalue %"variant[]" undef, %variant* %40, 0 - %42 = insertvalue %"variant[]" %41, i64 1, 1 - store %"variant[]" %42, %"variant[]"* %taddr42, align 8 - %43 = bitcast %"variant[]"* %taddr42 to { i8*, i64 }* - %44 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 0 - %lo43 = load i8*, i8** %44, align 8 - %45 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 1 - %hi44 = load i64, i64* %45, align 8 - %46 = call i64 @std_io_printfn(i64* %retparam37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0), i64 9, i8* %lo43, i64 %hi44) - %not_err45 = icmp eq i64 %46, 0 - br i1 %not_err45, label %after_check46, label %voiderr47 - -after_check46: ; preds = %after_check41 - br label %voiderr47 - -voiderr47: ; preds = %after_check46, %after_check41, %voiderr36 - ret void -} - -; Function Attrs: nounwind -define void @test_test3() #0 { -entry: - %x = alloca i32, align 4 - %x.f = alloca i64, align 8 - %a = alloca i32, align 4 - %a.f = alloca i64, align 8 - %b = alloca i32, align 4 - %b.f = alloca i64, align 8 - %err = alloca i64, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %err8 = alloca i64, align 8 - %retparam17 = alloca i64, align 8 - %varargslots18 = alloca [1 x %variant], align 16 - %taddr19 = alloca %"variant[]", align 8 - %retparam26 = alloca i64, align 8 - %varargslots27 = alloca [1 x %variant], align 16 - %taddr31 = alloca %"variant[]", align 8 - %retparam37 = alloca i64, align 8 - %varargslots38 = alloca [1 x %variant], align 16 - %taddr42 = alloca %"variant[]", align 8 - store i32 23, i32* %x, align 4 - store i64 0, i64* %x.f, align 8 - store i32 1, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - %optval = load i64, i64* %x.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %a.f, align 8 - br label %optional_assign_jump - -after_check: ; preds = %entry - %0 = load i32, i32* %x, align 4 - store i32 %0, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - br label %after_assign - -optional_assign_jump: ; preds = %assign_optional - %reload_err = load i64, i64* %a.f, align 8 - store i64 %reload_err, i64* %b.f, align 8 - br label %after_assign1 - -after_assign: ; preds = %after_check - store i32 %0, i32* %b, align 4 - store i64 0, i64* %b.f, align 8 - br label %after_assign1 - -after_assign1: ; preds = %after_assign, %optional_assign_jump - br label %testblock - -testblock: ; preds = %after_assign1 - %optval2 = load i64, i64* %a.f, align 8 - %not_err3 = icmp eq i64 %optval2, 0 - br i1 %not_err3, label %after_check5, label %assign_optional4 - -assign_optional4: ; preds = %testblock - store i64 %optval2, i64* %err, align 8 - br label %end_block - -after_check5: ; preds = %testblock - store i64 0, i64* %err, align 8 - br label %end_block - -end_block: ; preds = %after_check5, %assign_optional4 - %1 = load i64, i64* %err, align 8 - %neq = icmp ne i64 %1, 0 - br i1 %neq, label %if.then, label %if.exit - -if.then: ; preds = %end_block - %2 = bitcast i64* %err to i8* - %3 = insertvalue %variant undef, i8* %2, 0 - %4 = insertvalue %variant %3, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %5 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %4, %variant* %5, align 16 - %6 = bitcast [1 x %variant]* %varargslots to %variant* - %7 = insertvalue %"variant[]" undef, %variant* %6, 0 - %8 = insertvalue %"variant[]" %7, i64 1, 1 - store %"variant[]" %8, %"variant[]"* %taddr, align 8 - %9 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 0 - %lo = load i8*, i8** %10, align 8 - %11 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 1 - %hi = load i64, i64* %11, align 8 - %12 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i64 13, i8* %lo, i64 %hi) - %not_err6 = icmp eq i64 %12, 0 - br i1 %not_err6, label %after_check7, label %voiderr - -after_check7: ; preds = %if.then - br label %voiderr - -voiderr: ; preds = %after_check7, %if.then - br label %if.exit - -if.exit: ; preds = %voiderr, %end_block - br label %testblock9 - -testblock9: ; preds = %if.exit - %optval10 = load i64, i64* %b.f, align 8 - %not_err11 = icmp eq i64 %optval10, 0 - br i1 %not_err11, label %after_check13, label %assign_optional12 - -assign_optional12: ; preds = %testblock9 - store i64 %optval10, i64* %err8, align 8 - br label %end_block14 - -after_check13: ; preds = %testblock9 - store i64 0, i64* %err8, align 8 - br label %end_block14 - -end_block14: ; preds = %after_check13, %assign_optional12 - %13 = load i64, i64* %err8, align 8 - %neq15 = icmp ne i64 %13, 0 - br i1 %neq15, label %if.then16, label %if.exit25 - -if.then16: ; preds = %end_block14 - %14 = bitcast i64* %err8 to i8* - %15 = insertvalue %variant undef, i8* %14, 0 - %16 = insertvalue %variant %15, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %17 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots18, i64 0, i64 0 - store %variant %16, %variant* %17, align 16 - %18 = bitcast [1 x %variant]* %varargslots18 to %variant* - %19 = insertvalue %"variant[]" undef, %variant* %18, 0 - %20 = insertvalue %"variant[]" %19, i64 1, 1 - store %"variant[]" %20, %"variant[]"* %taddr19, align 8 - %21 = bitcast %"variant[]"* %taddr19 to { i8*, i64 }* - %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 0 - %lo20 = load i8*, i8** %22, align 8 - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 1 - %hi21 = load i64, i64* %23, align 8 - %24 = call i64 @std_io_printfn(i64* %retparam17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i32 0, i32 0), i64 13, i8* %lo20, i64 %hi21) - %not_err22 = icmp eq i64 %24, 0 - br i1 %not_err22, label %after_check23, label %voiderr24 - -after_check23: ; preds = %if.then16 - br label %voiderr24 - -voiderr24: ; preds = %after_check23, %if.then16 - br label %if.exit25 - -if.exit25: ; preds = %voiderr24, %end_block14 - %optval28 = load i64, i64* %a.f, align 8 - %not_err29 = icmp eq i64 %optval28, 0 - br i1 %not_err29, label %after_check30, label %voiderr36 - -after_check30: ; preds = %if.exit25 - %25 = bitcast i32* %a to i8* - %26 = insertvalue %variant undef, i8* %25, 0 - %27 = insertvalue %variant %26, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %28 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots27, i64 0, i64 0 - store %variant %27, %variant* %28, align 16 - %29 = bitcast [1 x %variant]* %varargslots27 to %variant* - %30 = insertvalue %"variant[]" undef, %variant* %29, 0 - %31 = insertvalue %"variant[]" %30, i64 1, 1 - store %"variant[]" %31, %"variant[]"* %taddr31, align 8 - %32 = bitcast %"variant[]"* %taddr31 to { i8*, i64 }* - %33 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 0 - %lo32 = load i8*, i8** %33, align 8 - %34 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 1 - %hi33 = load i64, i64* %34, align 8 - %35 = call i64 @std_io_printfn(i64* %retparam26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0), i64 9, i8* %lo32, i64 %hi33) - %not_err34 = icmp eq i64 %35, 0 - br i1 %not_err34, label %after_check35, label %voiderr36 - -after_check35: ; preds = %after_check30 - br label %voiderr36 - -voiderr36: ; preds = %after_check35, %after_check30, %if.exit25 - %optval39 = load i64, i64* %b.f, align 8 - %not_err40 = icmp eq i64 %optval39, 0 - br i1 %not_err40, label %after_check41, label %voiderr47 - -after_check41: ; preds = %voiderr36 - %36 = bitcast i32* %b to i8* - %37 = insertvalue %variant undef, i8* %36, 0 - %38 = insertvalue %variant %37, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %39 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots38, i64 0, i64 0 - store %variant %38, %variant* %39, align 16 - %40 = bitcast [1 x %variant]* %varargslots38 to %variant* - %41 = insertvalue %"variant[]" undef, %variant* %40, 0 - %42 = insertvalue %"variant[]" %41, i64 1, 1 - store %"variant[]" %42, %"variant[]"* %taddr42, align 8 - %43 = bitcast %"variant[]"* %taddr42 to { i8*, i64 }* - %44 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 0 - %lo43 = load i8*, i8** %44, align 8 - %45 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 1 - %hi44 = load i64, i64* %45, align 8 - %46 = call i64 @std_io_printfn(i64* %retparam37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i32 0, i32 0), i64 9, i8* %lo43, i64 %hi44) - %not_err45 = icmp eq i64 %46, 0 - br i1 %not_err45, label %after_check46, label %voiderr47 - -after_check46: ; preds = %after_check41 - br label %voiderr47 - -voiderr47: ; preds = %after_check46, %after_check41, %voiderr36 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/optional_inits.c3t b/test/test_suite14/errors/optional_inits.c3t deleted file mode 100644 index 4fe593f6c..000000000 --- a/test/test_suite14/errors/optional_inits.c3t +++ /dev/null @@ -1,119 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; -fault Foo -{ - MY_VAL1, - MY_VAL2, -} - -struct Bar -{ - int x; -} - -fn void! test1() @maydiscard -{ - Bar! x = Foo.MY_VAL1!; - Bar y = x?; -} - -fn void! test2() @maydiscard -{ - Bar! x = {}; - Bar y = x?; -} - -fn void main() -{ - test1(); - test2(); -} - -/* #expect: test.ll - -define i64 @test_test1() #0 { -entry: - %x = alloca %Bar, align 4 - %x.f = alloca i64, align 8 - %y = alloca %Bar, align 4 - %error_var = alloca i64, align 8 - %reterr = alloca i64, align 8 - store i64 ptrtoint (%.fault* @"test_Foo$MY_VAL1" to i64), i64* %x.f, align 8 - %optval = load i64, i64* %x.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %0 = load i64, i64* %error_var, align 8 - ret i64 %0 - -noerr_block: ; preds = %after_check - %1 = bitcast %Bar* %y to i8* - %2 = bitcast %Bar* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 %2, i32 4, i1 false) - ret i64 0 -} - -; Function Attrs: nounwind -define i64 @test_test2() #0 { -entry: - %x = alloca %Bar, align 4 - %x.f = alloca i64, align 8 - %y = alloca %Bar, align 4 - %error_var = alloca i64, align 8 - %reterr = alloca i64, align 8 - %0 = bitcast %Bar* %x to i32* - store i32 0, i32* %0, align 4 - store i64 0, i64* %x.f, align 8 - %optval = load i64, i64* %x.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %1 = load i64, i64* %error_var, align 8 - ret i64 %1 - -noerr_block: ; preds = %after_check - %2 = bitcast %Bar* %y to i8* - %3 = bitcast %Bar* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 4 %3, i32 4, i1 false) - ret i64 0 -} - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %0 = call i64 @test_test1() - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %1 = call i64 @test_test2() - %not_err1 = icmp eq i64 %1, 0 - br i1 %not_err1, label %after_check2, label %voiderr3 - -after_check2: ; preds = %voiderr - br label %voiderr3 - -voiderr3: ; preds = %after_check2, %voiderr - ret void -} diff --git a/test/test_suite14/errors/optional_taddr_and_access.c3t b/test/test_suite14/errors/optional_taddr_and_access.c3t deleted file mode 100644 index d7851c131..000000000 --- a/test/test_suite14/errors/optional_taddr_and_access.c3t +++ /dev/null @@ -1,121 +0,0 @@ -// #target: macos-x64 - -module test; -struct Foo -{ - int x, y; -} - -fault MyErr -{ - FOO -} - -extern fn int printf(char *c, ...); - -fn void main() -{ - int! z = 2; - Foo*! w = &&Foo{ z, 0 }; - printf("%d\n", w.x); - z = MyErr.FOO!; - w = &&Foo{ z, 0 }; - printf("Not visible: %d\n", w.x); -} - -/* #expect: test.ll - -%Foo = type { i32, i32 } - -@"ct$test_Foo" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"test_MyErr$FOO" = linkonce constant %.fault { i64 ptrtoint (%.introspect* @"ct$test_MyErr" to i64), %"char[]" { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.fault, i64 0, i64 0), i64 3 } }, align 8 -@.fault = internal constant [4 x i8] c"FOO\00", align 1 -@"ct$test_MyErr" = linkonce constant %.introspect { i8 9, i64 8, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8 -@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 -@.str.1 = private unnamed_addr constant [17 x i8] c"Not visible: %d\0A\00", align 1 - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %z = alloca i32, align 4 - %z.f = alloca i64, align 8 - %w = alloca %Foo*, align 8 - %w.f = alloca i64, align 8 - %literal = alloca %Foo, align 4 - %literal6 = alloca %Foo, align 4 - store i32 2, i32* %z, align 4 - store i64 0, i64* %z.f, align 8 - %0 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 0 - %optval = load i64, i64* %z.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %w.f, align 8 - br label %after_assign - -after_check: ; preds = %entry - %1 = load i32, i32* %z, align 4 - store i32 %1, i32* %0, align 4 - %2 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 1 - store i32 0, i32* %2, align 4 - store %Foo* %literal, %Foo** %w, align 8 - store i64 0, i64* %w.f, align 8 - br label %after_assign - -after_assign: ; preds = %after_check, %assign_optional - %optval1 = load i64, i64* %w.f, align 8 - %not_err2 = icmp eq i64 %optval1, 0 - br i1 %not_err2, label %after_check3, label %voiderr - -after_check3: ; preds = %after_assign - %3 = load %Foo*, %Foo** %w, align 8 - %4 = getelementptr inbounds %Foo, %Foo* %3, i32 0, i32 0 - %5 = load i32, i32* %4, align 4 - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %5) - br label %voiderr - -voiderr: ; preds = %after_check3, %after_assign - store i64 ptrtoint (%.fault* @"test_MyErr$FOO" to i64), i64* %z.f, align 8 - br label %voiderr5 - -voiderr5: ; preds = %voiderr - %7 = getelementptr inbounds %Foo, %Foo* %literal6, i32 0, i32 0 - %optval7 = load i64, i64* %z.f, align 8 - %not_err8 = icmp eq i64 %optval7, 0 - br i1 %not_err8, label %after_check10, label %assign_optional9 - -assign_optional9: ; preds = %voiderr5 - store i64 %optval7, i64* %w.f, align 8 - br label %after_assign11 - -after_check10: ; preds = %voiderr5 - %8 = load i32, i32* %z, align 4 - store i32 %8, i32* %7, align 4 - %9 = getelementptr inbounds %Foo, %Foo* %literal6, i32 0, i32 1 - store i32 0, i32* %9, align 4 - store %Foo* %literal6, %Foo** %w, align 8 - store i64 0, i64* %w.f, align 8 - br label %after_assign11 - -after_assign11: ; preds = %after_check10, %assign_optional9 - br label %voiderr12 - -voiderr12: ; preds = %after_assign11 - %optval13 = load i64, i64* %w.f, align 8 - %not_err14 = icmp eq i64 %optval13, 0 - br i1 %not_err14, label %after_check15, label %voiderr16 - -after_check15: ; preds = %voiderr12 - %10 = load %Foo*, %Foo** %w, align 8 - %11 = getelementptr inbounds %Foo, %Foo* %10, i32 0, i32 0 - %12 = load i32, i32* %11, align 4 - %13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i32 0, i32 0), i32 %12) - br label %voiderr16 - -voiderr16: ; preds = %after_check15, %voiderr12 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/optional_untyped_list.c3 b/test/test_suite14/errors/optional_untyped_list.c3 deleted file mode 100644 index c4c2f9581..000000000 --- a/test/test_suite14/errors/optional_untyped_list.c3 +++ /dev/null @@ -1,30 +0,0 @@ -module test; -struct Foo -{ - int x, y; -} - -fault MyErr -{ - FOO -} - -extern fn int printf(char *c, ...); - -fn void foo() -{ - int z = 2; - Foo*! w = &&{ z, 0 }; // #error: An untyped list can only have constant elements -} - -fn void foo2() -{ - int! z = 2; - Foo*! w = &&{ z, 0 }; // #error: An untyped list can only have constant elements -} - -fn void test() -{ - int! z = 2; - Foo*! w = &&Foo!{ z, 0 }; // #error: please remove the '!' -} \ No newline at end of file diff --git a/test/test_suite14/errors/optional_with_optional.c3t b/test/test_suite14/errors/optional_with_optional.c3t deleted file mode 100644 index 7959b1042..000000000 --- a/test/test_suite14/errors/optional_with_optional.c3t +++ /dev/null @@ -1,382 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fault Foo { ABC, DEF } - -fn void main() -{ - io::printfn("1:%d", get_a(1) ?? get_b(4) ?? -1); - io::printfn("2:%d", get_a(2) ?? get_b(4) ?? -1); - io::printfn("3:%d", get_a(1) ?? get_b(5) ?? -1); - io::printfn("4:%s", catch(Foo.ABC! ?? Foo.DEF!)); - io::printfn("5:%s", Foo.ABC! ?? 3); - io::printfn("6:%s", catch((3 > 2 ? Foo.ABC! : 4) ?? Foo.DEF!)); - io::printfn("7:%s", catch((3 < 2 ? Foo.ABC! : 4) ?? Foo.DEF!)); - long x = Foo.DEF! ?? 3; - io::printfn("8:%s", x); - int! xy = Foo.ABC! ?? Foo.DEF!; -} - -fn int! get_a(int x) -{ - if (x % 2) return Foo.ABC!; - return x * 2; -} - -fn int! get_b(int x) -{ - if (x % 2 == 0) return Foo.ABC!; - return x * 2; -} - -/* #expect: test.ll - - -define void @test_main() #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %retparam1 = alloca i32, align 4 - %retparam2 = alloca i32, align 4 - %taddr = alloca i32, align 4 - %taddr8 = alloca %"variant[]", align 8 - %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %variant], align 16 - %retparam13 = alloca i32, align 4 - %retparam17 = alloca i32, align 4 - %taddr25 = alloca i32, align 4 - %taddr26 = alloca %"variant[]", align 8 - %retparam32 = alloca i64, align 8 - %varargslots33 = alloca [1 x %variant], align 16 - %retparam34 = alloca i32, align 4 - %retparam38 = alloca i32, align 4 - %taddr46 = alloca i32, align 4 - %taddr47 = alloca %"variant[]", align 8 - %retparam53 = alloca i64, align 8 - %varargslots54 = alloca [1 x %variant], align 16 - %taddr55 = alloca i64, align 8 - %taddr56 = alloca %"variant[]", align 8 - %retparam62 = alloca i64, align 8 - %varargslots63 = alloca [1 x %variant], align 16 - %taddr64 = alloca i32, align 4 - %taddr65 = alloca %"variant[]", align 8 - %retparam71 = alloca i64, align 8 - %varargslots72 = alloca [1 x %variant], align 16 - %taddr73 = alloca i64, align 8 - %taddr74 = alloca %"variant[]", align 8 - %retparam80 = alloca i64, align 8 - %varargslots81 = alloca [1 x %variant], align 16 - %error_var = alloca i64, align 8 - %taddr84 = alloca %"variant[]", align 8 - %x = alloca i64, align 8 - %retparam90 = alloca i64, align 8 - %varargslots91 = alloca [1 x %variant], align 16 - %taddr92 = alloca %"variant[]", align 8 - %xy = alloca i32, align 4 - %xy.f = alloca i64, align 8 - %0 = call i64 @test_get_a(i32* %retparam1, i32 1) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %else_block - -after_check: ; preds = %entry - %1 = load i32, i32* %retparam1, align 4 - br label %phi_block - -else_block: ; preds = %entry - %2 = call i64 @test_get_b(i32* %retparam2, i32 4) - %not_err3 = icmp eq i64 %2, 0 - br i1 %not_err3, label %after_check4, label %else_block5 - -after_check4: ; preds = %else_block - %3 = load i32, i32* %retparam2, align 4 - br label %phi_block - -phi_block: ; preds = %after_check4, %after_check - %val = phi i32 [ %1, %after_check ], [ %3, %after_check4 ] - br label %phi_block6 - -else_block5: ; preds = %else_block - br label %phi_block6 - -phi_block6: ; preds = %else_block5, %phi_block - %val7 = phi i32 [ %val, %phi_block ], [ -1, %else_block5 ] - store i32 %val7, i32* %taddr, align 4 - %4 = bitcast i32* %taddr to i8* - %5 = insertvalue %variant undef, i8* %4, 0 - %6 = insertvalue %variant %5, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %7 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %6, %variant* %7, align 16 - %8 = bitcast [1 x %variant]* %varargslots to %variant* - %9 = insertvalue %"variant[]" undef, %variant* %8, 0 - %10 = insertvalue %"variant[]" %9, i64 1, 1 - store %"variant[]" %10, %"variant[]"* %taddr8, align 8 - %11 = bitcast %"variant[]"* %taddr8 to { i8*, i64 }* - %12 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %11, i32 0, i32 0 - %lo = load i8*, i8** %12, align 8 - %13 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %11, i32 0, i32 1 - %hi = load i64, i64* %13, align 8 - %14 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i64 4, i8* %lo, i64 %hi) - %not_err9 = icmp eq i64 %14, 0 - br i1 %not_err9, label %after_check10, label %voiderr - -after_check10: ; preds = %phi_block6 - br label %voiderr - -voiderr: ; preds = %after_check10, %phi_block6 - %15 = call i64 @test_get_a(i32* %retparam13, i32 2) - %not_err14 = icmp eq i64 %15, 0 - br i1 %not_err14, label %after_check15, label %else_block16 - -after_check15: ; preds = %voiderr - %16 = load i32, i32* %retparam13, align 4 - br label %phi_block20 - -else_block16: ; preds = %voiderr - %17 = call i64 @test_get_b(i32* %retparam17, i32 4) - %not_err18 = icmp eq i64 %17, 0 - br i1 %not_err18, label %after_check19, label %else_block22 - -after_check19: ; preds = %else_block16 - %18 = load i32, i32* %retparam17, align 4 - br label %phi_block20 - -phi_block20: ; preds = %after_check19, %after_check15 - %val21 = phi i32 [ %16, %after_check15 ], [ %18, %after_check19 ] - br label %phi_block23 - -else_block22: ; preds = %else_block16 - br label %phi_block23 - -phi_block23: ; preds = %else_block22, %phi_block20 - %val24 = phi i32 [ %val21, %phi_block20 ], [ -1, %else_block22 ] - store i32 %val24, i32* %taddr25, align 4 - %19 = bitcast i32* %taddr25 to i8* - %20 = insertvalue %variant undef, i8* %19, 0 - %21 = insertvalue %variant %20, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %22 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots12, i64 0, i64 0 - store %variant %21, %variant* %22, align 16 - %23 = bitcast [1 x %variant]* %varargslots12 to %variant* - %24 = insertvalue %"variant[]" undef, %variant* %23, 0 - %25 = insertvalue %"variant[]" %24, i64 1, 1 - store %"variant[]" %25, %"variant[]"* %taddr26, align 8 - %26 = bitcast %"variant[]"* %taddr26 to { i8*, i64 }* - %27 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %26, i32 0, i32 0 - %lo27 = load i8*, i8** %27, align 8 - %28 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %26, i32 0, i32 1 - %hi28 = load i64, i64* %28, align 8 - %29 = call i64 @std_io_printfn(i64* %retparam11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i64 4, i8* %lo27, i64 %hi28) - %not_err29 = icmp eq i64 %29, 0 - br i1 %not_err29, label %after_check30, label %voiderr31 - -after_check30: ; preds = %phi_block23 - br label %voiderr31 - -voiderr31: ; preds = %after_check30, %phi_block23 - %30 = call i64 @test_get_a(i32* %retparam34, i32 1) - %not_err35 = icmp eq i64 %30, 0 - br i1 %not_err35, label %after_check36, label %else_block37 - -after_check36: ; preds = %voiderr31 - %31 = load i32, i32* %retparam34, align 4 - br label %phi_block41 - -else_block37: ; preds = %voiderr31 - %32 = call i64 @test_get_b(i32* %retparam38, i32 5) - %not_err39 = icmp eq i64 %32, 0 - br i1 %not_err39, label %after_check40, label %else_block43 - -after_check40: ; preds = %else_block37 - %33 = load i32, i32* %retparam38, align 4 - br label %phi_block41 - -phi_block41: ; preds = %after_check40, %after_check36 - %val42 = phi i32 [ %31, %after_check36 ], [ %33, %after_check40 ] - br label %phi_block44 - -else_block43: ; preds = %else_block37 - br label %phi_block44 - -phi_block44: ; preds = %else_block43, %phi_block41 - %val45 = phi i32 [ %val42, %phi_block41 ], [ -1, %else_block43 ] - store i32 %val45, i32* %taddr46, align 4 - %34 = bitcast i32* %taddr46 to i8* - %35 = insertvalue %variant undef, i8* %34, 0 - %36 = insertvalue %variant %35, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %37 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots33, i64 0, i64 0 - store %variant %36, %variant* %37, align 16 - %38 = bitcast [1 x %variant]* %varargslots33 to %variant* - %39 = insertvalue %"variant[]" undef, %variant* %38, 0 - %40 = insertvalue %"variant[]" %39, i64 1, 1 - store %"variant[]" %40, %"variant[]"* %taddr47, align 8 - %41 = bitcast %"variant[]"* %taddr47 to { i8*, i64 }* - %42 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %41, i32 0, i32 0 - %lo48 = load i8*, i8** %42, align 8 - %43 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %41, i32 0, i32 1 - %hi49 = load i64, i64* %43, align 8 - %44 = call i64 @std_io_printfn(i64* %retparam32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i64 4, i8* %lo48, i64 %hi49) - %not_err50 = icmp eq i64 %44, 0 - br i1 %not_err50, label %after_check51, label %voiderr52 - -after_check51: ; preds = %phi_block44 - br label %voiderr52 - -voiderr52: ; preds = %after_check51, %phi_block44 - store i64 ptrtoint (%.fault* @"test_Foo$DEF" to i64), i64* %taddr55, align 8 - %45 = bitcast i64* %taddr55 to i8* - %46 = insertvalue %variant undef, i8* %45, 0 - %47 = insertvalue %variant %46, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %48 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots54, i64 0, i64 0 - store %variant %47, %variant* %48, align 16 - %49 = bitcast [1 x %variant]* %varargslots54 to %variant* - %50 = insertvalue %"variant[]" undef, %variant* %49, 0 - %51 = insertvalue %"variant[]" %50, i64 1, 1 - store %"variant[]" %51, %"variant[]"* %taddr56, align 8 - %52 = bitcast %"variant[]"* %taddr56 to { i8*, i64 }* - %53 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %52, i32 0, i32 0 - %lo57 = load i8*, i8** %53, align 8 - %54 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %52, i32 0, i32 1 - %hi58 = load i64, i64* %54, align 8 - %55 = call i64 @std_io_printfn(i64* %retparam53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i64 4, i8* %lo57, i64 %hi58) - %not_err59 = icmp eq i64 %55, 0 - br i1 %not_err59, label %after_check60, label %voiderr61 - -after_check60: ; preds = %voiderr52 - br label %voiderr61 - -voiderr61: ; preds = %after_check60, %voiderr52 - store i32 3, i32* %taddr64, align 4 - %56 = bitcast i32* %taddr64 to i8* - %57 = insertvalue %variant undef, i8* %56, 0 - %58 = insertvalue %variant %57, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %59 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots63, i64 0, i64 0 - store %variant %58, %variant* %59, align 16 - %60 = bitcast [1 x %variant]* %varargslots63 to %variant* - %61 = insertvalue %"variant[]" undef, %variant* %60, 0 - %62 = insertvalue %"variant[]" %61, i64 1, 1 - store %"variant[]" %62, %"variant[]"* %taddr65, align 8 - %63 = bitcast %"variant[]"* %taddr65 to { i8*, i64 }* - %64 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %63, i32 0, i32 0 - %lo66 = load i8*, i8** %64, align 8 - %65 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %63, i32 0, i32 1 - %hi67 = load i64, i64* %65, align 8 - %66 = call i64 @std_io_printfn(i64* %retparam62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i64 4, i8* %lo66, i64 %hi67) - %not_err68 = icmp eq i64 %66, 0 - br i1 %not_err68, label %after_check69, label %voiderr70 - -after_check69: ; preds = %voiderr61 - br label %voiderr70 - -voiderr70: ; preds = %after_check69, %voiderr61 - store i64 ptrtoint (%.fault* @"test_Foo$DEF" to i64), i64* %taddr73, align 8 - %67 = bitcast i64* %taddr73 to i8* - %68 = insertvalue %variant undef, i8* %67, 0 - %69 = insertvalue %variant %68, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %70 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots72, i64 0, i64 0 - store %variant %69, %variant* %70, align 16 - %71 = bitcast [1 x %variant]* %varargslots72 to %variant* - %72 = insertvalue %"variant[]" undef, %variant* %71, 0 - %73 = insertvalue %"variant[]" %72, i64 1, 1 - store %"variant[]" %73, %"variant[]"* %taddr74, align 8 - %74 = bitcast %"variant[]"* %taddr74 to { i8*, i64 }* - %75 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %74, i32 0, i32 0 - %lo75 = load i8*, i8** %75, align 8 - %76 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %74, i32 0, i32 1 - %hi76 = load i64, i64* %76, align 8 - %77 = call i64 @std_io_printfn(i64* %retparam71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i64 4, i8* %lo75, i64 %hi76) - %not_err77 = icmp eq i64 %77, 0 - br i1 %not_err77, label %after_check78, label %voiderr79 - -after_check78: ; preds = %voiderr70 - br label %voiderr79 - -voiderr79: ; preds = %after_check78, %voiderr70 - store i64 0, i64* %error_var, align 8 - br label %phi_block83 - -phi_block83: ; preds = %voiderr79 - br label %noerr_block - -noerr_block: ; preds = %phi_block83 - %78 = bitcast i64* %error_var to i8* - %79 = insertvalue %variant undef, i8* %78, 0 - %80 = insertvalue %variant %79, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 - %81 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots81, i64 0, i64 0 - store %variant %80, %variant* %81, align 16 - %82 = bitcast [1 x %variant]* %varargslots81 to %variant* - %83 = insertvalue %"variant[]" undef, %variant* %82, 0 - %84 = insertvalue %"variant[]" %83, i64 1, 1 - store %"variant[]" %84, %"variant[]"* %taddr84, align 8 - %85 = bitcast %"variant[]"* %taddr84 to { i8*, i64 }* - %86 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %85, i32 0, i32 0 - %lo85 = load i8*, i8** %86, align 8 - %87 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %85, i32 0, i32 1 - %hi86 = load i64, i64* %87, align 8 - %88 = call i64 @std_io_printfn(i64* %retparam80, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i64 4, i8* %lo85, i64 %hi86) - %not_err87 = icmp eq i64 %88, 0 - br i1 %not_err87, label %after_check88, label %voiderr89 - -after_check88: ; preds = %noerr_block - br label %voiderr89 - -voiderr89: ; preds = %after_check88, %noerr_block - store i64 3, i64* %x, align 8 - %89 = bitcast i64* %x to i8* - %90 = insertvalue %variant undef, i8* %89, 0 - %91 = insertvalue %variant %90, i64 ptrtoint (%.introspect* @"ct$long" to i64), 1 - %92 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots91, i64 0, i64 0 - store %variant %91, %variant* %92, align 16 - %93 = bitcast [1 x %variant]* %varargslots91 to %variant* - %94 = insertvalue %"variant[]" undef, %variant* %93, 0 - %95 = insertvalue %"variant[]" %94, i64 1, 1 - store %"variant[]" %95, %"variant[]"* %taddr92, align 8 - %96 = bitcast %"variant[]"* %taddr92 to { i8*, i64 }* - %97 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %96, i32 0, i32 0 - %lo93 = load i8*, i8** %97, align 8 - %98 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %96, i32 0, i32 1 - %hi94 = load i64, i64* %98, align 8 - %99 = call i64 @std_io_printfn(i64* %retparam90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i64 4, i8* %lo93, i64 %hi94) - %not_err95 = icmp eq i64 %99, 0 - br i1 %not_err95, label %after_check96, label %voiderr97 - -after_check96: ; preds = %voiderr89 - br label %voiderr97 - -voiderr97: ; preds = %after_check96, %voiderr89 - store i64 ptrtoint (%.fault* @"test_Foo$DEF" to i64), i64* %xy.f, align 8 - ret void -} - -; Function Attrs: nounwind -define i64 @test_get_a(i32* %0, i32 %1) #0 { -entry: - %reterr = alloca i64, align 8 - %smod = srem i32 %1, 2 - %intbool = icmp ne i32 %smod, 0 - br i1 %intbool, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i64 ptrtoint (%.fault* @"test_Foo$ABC" to i64) - -if.exit: ; preds = %entry - %mul = mul i32 %1, 2 - store i32 %mul, i32* %0, align 4 - ret i64 0 -} - -; Function Attrs: nounwind -define i64 @test_get_b(i32* %0, i32 %1) #0 { -entry: - %reterr = alloca i64, align 8 - %smod = srem i32 %1, 2 - %eq = icmp eq i32 %smod, 0 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i64 ptrtoint (%.fault* @"test_Foo$ABC" to i64) - -if.exit: ; preds = %entry - %mul = mul i32 %1, 2 - store i32 %mul, i32* %0, align 4 - ret i64 0 -} diff --git a/test/test_suite14/errors/or_and_rethrow.c3t b/test/test_suite14/errors/or_and_rethrow.c3t deleted file mode 100644 index 9e6b106cc..000000000 --- a/test/test_suite14/errors/or_and_rethrow.c3t +++ /dev/null @@ -1,185 +0,0 @@ -// #target: macos-x64 -module foo; -import std::io; - -fault Foo { ABC } - -fn void blurb() { io::println("Blurb");} - -macro int! tester() -{ - defer blurb(); - return Foo.ABC!; -} -fn void! test(int x) -{ - io::printfn("test(%d)", x); - if (x || (tester()?)) io::println("Ok1"); - io::println("Test next"); - if (tester()? || x) io::println("Ok?"); - io::println("Test ok"); -} - -fn void! test2(int x) -{ - io::printfn("test2(%d)", x); - if (x && (tester()?)) io::println("Ok1"); - io::println("Test next"); - if ((tester()?) && x) io::println("Ok?"); - io::println("Test ok"); -} - -fn void main() -{ - anyerr a = test(0); - anyerr b = test(1); - anyerr c = test2(0); - anyerr d = test2(1); -} - -/* #expect: foo.ll - -define i64 @foo_test(i32 %0) #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - %error_var = alloca i64, align 8 - %blockret = alloca i32, align 4 - %error_var2 = alloca i64, align 8 - %blockret3 = alloca i32, align 4 - %reterr = alloca i64, align 8 - store i32 %0, i32* %taddr, align 4 - %1 = bitcast i32* %taddr to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %4 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %3, %variant* %4, align 16 - %5 = bitcast [1 x %variant]* %varargslots to %variant* - %6 = insertvalue %"variant[]" undef, %variant* %5, 0 - %7 = insertvalue %"variant[]" %6, i64 1, 1 - store %"variant[]" %7, %"variant[]"* %taddr1, align 8 - %8 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0 - %lo = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1 - %hi = load i64, i64* %10, align 8 - %11 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i64 8, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %11, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %intbool = icmp ne i32 %0, 0 - br i1 %intbool, label %or.phi, label %or.rhs - -or.rhs: ; preds = %voiderr - store i64 ptrtoint (%.fault* @"foo_Foo$ABC" to i64), i64* %error_var, align 8 - br label %opt_block_cleanup - -opt_block_cleanup: ; preds = %or.rhs - call void @foo_blurb() - br label %guard_block - -guard_block: ; preds = %opt_block_cleanup - %12 = load i64, i64* %error_var, align 8 - ret i64 %12 - -or.phi: ; preds = %voiderr - br label %if.then - -if.then: ; preds = %or.phi - %13 = call i32 @std_io_println(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0)) #1 - br label %if.exit - -if.exit: ; preds = %if.then - %14 = call i32 @std_io_println(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0)) #1 - store i64 ptrtoint (%.fault* @"foo_Foo$ABC" to i64), i64* %error_var2, align 8 - br label %opt_block_cleanup4 - -opt_block_cleanup4: ; preds = %if.exit - call void @foo_blurb() - br label %guard_block5 - -guard_block5: ; preds = %opt_block_cleanup4 - %15 = load i64, i64* %error_var2, align 8 - ret i64 %15 - -if.exit7: ; No predecessors! - %16 = call i32 @std_io_println(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0)) #1 - ret i64 0 -} - -; Function Attrs: nounwind -define i64 @foo_test2(i32 %0) #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - %error_var = alloca i64, align 8 - %blockret = alloca i32, align 4 - %error_var2 = alloca i64, align 8 - %blockret3 = alloca i32, align 4 - %reterr = alloca i64, align 8 - store i32 %0, i32* %taddr, align 4 - %1 = bitcast i32* %taddr to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %4 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %3, %variant* %4, align 16 - %5 = bitcast [1 x %variant]* %varargslots to %variant* - %6 = insertvalue %"variant[]" undef, %variant* %5, 0 - %7 = insertvalue %"variant[]" %6, i64 1, 1 - store %"variant[]" %7, %"variant[]"* %taddr1, align 8 - %8 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0 - %lo = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1 - %hi = load i64, i64* %10, align 8 - %11 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i64 9, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %11, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %intbool = icmp ne i32 %0, 0 - br i1 %intbool, label %and.rhs, label %and.phi - -and.rhs: ; preds = %voiderr - store i64 ptrtoint (%.fault* @"foo_Foo$ABC" to i64), i64* %error_var, align 8 - br label %opt_block_cleanup - -opt_block_cleanup: ; preds = %and.rhs - call void @foo_blurb() - br label %guard_block - -guard_block: ; preds = %opt_block_cleanup - %12 = load i64, i64* %error_var, align 8 - ret i64 %12 - -and.phi: ; preds = %voiderr - br label %if.exit - -if.exit: ; preds = %and.phi - %13 = call i32 @std_io_println(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0)) #1 - store i64 ptrtoint (%.fault* @"foo_Foo$ABC" to i64), i64* %error_var2, align 8 - br label %opt_block_cleanup4 - -opt_block_cleanup4: ; preds = %if.exit - call void @foo_blurb() - br label %guard_block5 - -guard_block5: ; preds = %opt_block_cleanup4 - %14 = load i64, i64* %error_var2, align 8 - ret i64 %14 - -if.exit6: ; No predecessors! - %15 = call i32 @std_io_println(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0)) #1 - ret i64 0 -} diff --git a/test/test_suite14/errors/or_err_bool.c3t b/test/test_suite14/errors/or_err_bool.c3t deleted file mode 100644 index 26a68c9d7..000000000 --- a/test/test_suite14/errors/or_err_bool.c3t +++ /dev/null @@ -1,34 +0,0 @@ -// #target: macos-x64 - -module test; - -fn void tester() -{ - bool! x = false; - x ?? true; -} - -/* #expect: test.ll - -define void @test_tester() #0 { -entry: - %x = alloca i8, align 1 - %x.f = alloca i64, align 8 - store i8 0, i8* %x, align 1 - store i64 0, i64* %x.f, align 8 - %optval = load i64, i64* %x.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %else_block - -after_check: ; preds = %entry - %0 = load i8, i8* %x, align 1 - %1 = trunc i8 %0 to i1 - br label %phi_block - -else_block: ; preds = %entry - br label %phi_block - -phi_block: ; preds = %else_block, %after_check - %val = phi i1 [ %1, %after_check ], [ true, %else_block ] - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/precedence_err.c3 b/test/test_suite14/errors/precedence_err.c3 deleted file mode 100644 index 0d80271cb..000000000 --- a/test/test_suite14/errors/precedence_err.c3 +++ /dev/null @@ -1,5 +0,0 @@ - -fn void test() -{ - int x = 3 ^ 5 & 6; // #error: You need to add explicit parentheses to clarify precedence -} diff --git a/test/test_suite14/errors/printing_errors.c3t b/test/test_suite14/errors/printing_errors.c3t deleted file mode 100644 index df4a9c0e1..000000000 --- a/test/test_suite14/errors/printing_errors.c3t +++ /dev/null @@ -1,72 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fault Cde -{ - HELLO, - WORLD, -} -fn void main() -{ - anyerr x = Cde.WORLD; - io::printf("%s %s\n", Cde.HELLO.nameof, x.nameof); -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %x = alloca i64, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %variant], align 16 - %taddr = alloca [5 x i8]*, align 8 - %faultname_zero = alloca %"char[]", align 8 - %taddr1 = alloca %"variant[]", align 8 - store i64 ptrtoint (%.fault* @"test_Cde$WORLD" to i64), i64* %x, align 8 - store [5 x i8]* bitcast ([6 x i8]* @.str.2 to [5 x i8]*), [5 x i8]** %taddr, align 8 - %0 = bitcast [5 x i8]** %taddr to i8* - %1 = insertvalue %variant undef, i8* %0, 0 - %2 = insertvalue %variant %1, i64 ptrtoint (%.introspect* @"ct$p$a5$char" to i64), 1 - %3 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 0 - store %variant %2, %variant* %3, align 16 - %4 = load i64, i64* %x, align 8 - %eq = icmp eq i64 %4, 0 - br i1 %eq, label %faultname_no, label %faultname_ok - -faultname_no: ; preds = %entry - %5 = bitcast %"char[]"* %faultname_zero to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %5, i8 0, i64 16, i1 false) - br label %faultname_exit - -faultname_ok: ; preds = %entry - %6 = inttoptr i64 %4 to %.fault* - %7 = getelementptr inbounds %.fault, %.fault* %6, i32 0, i32 1 - br label %faultname_exit - -faultname_exit: ; preds = %faultname_ok, %faultname_no - %faultname = phi %"char[]"* [ %faultname_zero, %faultname_no ], [ %7, %faultname_ok ] - %8 = bitcast %"char[]"* %faultname to i8* - %9 = insertvalue %variant undef, i8* %8, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (%.introspect* @"ct$sa$char" to i64), 1 - %11 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 1 - store %variant %10, %variant* %11, align 16 - %12 = bitcast [2 x %variant]* %varargslots to %variant* - %13 = insertvalue %"variant[]" undef, %variant* %12, 0 - %14 = insertvalue %"variant[]" %13, i64 2, 1 - store %"variant[]" %14, %"variant[]"* %taddr1, align 8 - %15 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %16 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 0 - %lo = load i8*, i8** %16, align 8 - %17 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 1 - %hi = load i64, i64* %17, align 8 - %18 = call i64 @std_io_printf(i64* %retparam, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i64 6, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %18, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %faultname_exit - br label %voiderr - -voiderr: ; preds = %after_check, %faultname_exit - ret void -} diff --git a/test/test_suite14/errors/rethrow.c3t b/test/test_suite14/errors/rethrow.c3t deleted file mode 100644 index d5a950e3d..000000000 --- a/test/test_suite14/errors/rethrow.c3t +++ /dev/null @@ -1,34 +0,0 @@ -// #target: macos-x64 - -fn void! test() -{ - int! i; - i?; -} - -/* #expect: rethrow.ll - - %i = alloca i32, align 4 - %i.f = alloca i64, align 8 - %error_var = alloca i64, align 8 - %reterr = alloca i64, align 8 - store i64 0, i64* %i.f, align 8 - store i32 0, i32* %i, align 4 - %optval = load i64, i64* %i.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %0 = load i64, i64* %error_var, align 8 - ret i64 %0 - -noerr_block: ; preds = %after_check - ret i64 0 -} diff --git a/test/test_suite14/errors/rethrow_mingw.c3t b/test/test_suite14/errors/rethrow_mingw.c3t deleted file mode 100644 index b0000e5f5..000000000 --- a/test/test_suite14/errors/rethrow_mingw.c3t +++ /dev/null @@ -1,40 +0,0 @@ -// #target: mingw-x64 - -module rethrow; - -fn void! test() -{ - int! i; - i?; -} - -/* #expect: rethrow.ll - -define i64 @rethrow_test() #0 { -entry: - %i = alloca i32, align 4 - %i.f = alloca i64, align 8 - %error_var = alloca i64, align 8 - %reterr = alloca i64, align 8 - store i64 0, i64* %i.f, align 8 - store i32 0, i32* %i, align 4 - %optval = load i64, i64* %i.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %0 = load i64, i64* %error_var, align 8 - ret i64 %0 - -noerr_block: ; preds = %after_check - ret i64 0 -} - - diff --git a/test/test_suite14/errors/rethrow_no_err.c3 b/test/test_suite14/errors/rethrow_no_err.c3 deleted file mode 100644 index f1e3697c7..000000000 --- a/test/test_suite14/errors/rethrow_no_err.c3 +++ /dev/null @@ -1,17 +0,0 @@ - -fn void test() -{ - test()?; // #error: No optional to rethrow before '?' in the expression, please remove '?' - int i = 0; - if (i?) return; // #error: No optional to rethrow before '?' in the expression, please remove '?' - int! j = 0; - if (j?) return; // #error: This expression implicitly returns with an optional result, but the function - if ((j?)?) return; // #error: This expression implicitly returns with an optional result, but the function -} - -fn void! test2() -{ - int! j = 0; - if (j?) return; - if ((j?)?) return; // #error: No optional to rethrow before '?' in the expression, please remove '?' -} \ No newline at end of file diff --git a/test/test_suite14/errors/simple_static_failable.c3t b/test/test_suite14/errors/simple_static_failable.c3t deleted file mode 100644 index de3f5c634..000000000 --- a/test/test_suite14/errors/simple_static_failable.c3t +++ /dev/null @@ -1,24 +0,0 @@ -// #target: macos-x64 - -module foo; - -fault Blurg -{ - Y -} - -fn void main() -{ - static int! x = 120; - int! i = Blurg.Y!; -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %i = alloca i32, align 4 - %i.f = alloca i64, align 8 - store i64 ptrtoint (%.fault* @"foo_Blurg$Y" to i64), i64* %i.f, align 8 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/try_assign.c3t b/test/test_suite14/errors/try_assign.c3t deleted file mode 100644 index 0890d72cf..000000000 --- a/test/test_suite14/errors/try_assign.c3t +++ /dev/null @@ -1,152 +0,0 @@ -// #target: macos-x64 - -extern fn int! err(); -fault FooErr { QBERT } -extern fn int printf(char* fmt, ...); - -fn void main() -{ - int x = 123; - int! z = 234; - int! w; - int gh = 1; - if (try x = z && try gh = w) - { - printf("Success %d && %d!\n", x, gh); - } - if (try x = z + w) - { - printf("Test\n"); - } - anyerr e; - if (catch e = z) - { - printf("Oh noes!\n"); - } -} - -/* #expect: try_assign.ll - - -define void @try_assign_main() #0 { -entry: - %x = alloca i32, align 4 - %z = alloca i32, align 4 - %z.f = alloca i64, align 8 - %w = alloca i32, align 4 - %w.f = alloca i64, align 8 - %gh = alloca i32, align 4 - %e = alloca i64, align 8 - store i32 123, i32* %x, align 4 - store i32 234, i32* %z, align 4 - store i64 0, i64* %z.f, align 8 - store i64 0, i64* %w.f, align 8 - store i32 0, i32* %w, align 4 - store i32 1, i32* %gh, align 4 - %optval = load i64, i64* %z.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %catch_landing - -after_check: ; preds = %entry - %0 = load i32, i32* %z, align 4 - store i32 %0, i32* %x, align 4 - br label %phi_try_catch - -catch_landing: ; preds = %entry - br label %phi_try_catch - -phi_try_catch: ; preds = %catch_landing, %after_check - %val = phi i1 [ true, %after_check ], [ false, %catch_landing ] - br i1 %val, label %chain_next, label %fail_chain - -chain_next: ; preds = %phi_try_catch - %optval1 = load i64, i64* %w.f, align 8 - %not_err2 = icmp eq i64 %optval1, 0 - br i1 %not_err2, label %after_check3, label %catch_landing4 - -after_check3: ; preds = %chain_next - %1 = load i32, i32* %w, align 4 - store i32 %1, i32* %gh, align 4 - br label %phi_try_catch5 - -catch_landing4: ; preds = %chain_next - br label %phi_try_catch5 - -phi_try_catch5: ; preds = %catch_landing4, %after_check3 - %val6 = phi i1 [ true, %after_check3 ], [ false, %catch_landing4 ] - br i1 %val6, label %chain_next7, label %fail_chain - -chain_next7: ; preds = %phi_try_catch5 - br label %end_chain - -fail_chain: ; preds = %phi_try_catch5, %phi_try_catch - br label %end_chain - -end_chain: ; preds = %fail_chain, %chain_next7 - %chain.phi = phi i1 [ true, %chain_next7 ], [ false, %fail_chain ] - br i1 %chain.phi, label %if.then, label %if.exit - -if.then: ; preds = %end_chain - %2 = load i32, i32* %x, align 4 - %3 = load i32, i32* %gh, align 4 - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i32 0, i32 0), i32 %2, i32 %3) - br label %if.exit - -if.exit: ; preds = %if.then, %end_chain - %optval8 = load i64, i64* %z.f, align 8 - %not_err9 = icmp eq i64 %optval8, 0 - br i1 %not_err9, label %after_check10, label %catch_landing14 - -after_check10: ; preds = %if.exit - %5 = load i32, i32* %z, align 4 - %optval11 = load i64, i64* %w.f, align 8 - %not_err12 = icmp eq i64 %optval11, 0 - br i1 %not_err12, label %after_check13, label %catch_landing14 - -after_check13: ; preds = %after_check10 - %6 = load i32, i32* %w, align 4 - %add = add i32 %5, %6 - store i32 %add, i32* %x, align 4 - br label %phi_try_catch15 - -catch_landing14: ; preds = %after_check10, %if.exit - br label %phi_try_catch15 - -phi_try_catch15: ; preds = %catch_landing14, %after_check13 - %val16 = phi i1 [ true, %after_check13 ], [ false, %catch_landing14 ] - br i1 %val16, label %if.then17, label %if.exit18 - -if.then17: ; preds = %phi_try_catch15 - %7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0)) - br label %if.exit18 - -if.exit18: ; preds = %if.then17, %phi_try_catch15 - store i64 0, i64* %e, align 8 - br label %testblock - -testblock: ; preds = %if.exit18 - %optval19 = load i64, i64* %z.f, align 8 - %not_err20 = icmp eq i64 %optval19, 0 - br i1 %not_err20, label %after_check21, label %assign_optional - -assign_optional: ; preds = %testblock - store i64 %optval19, i64* %e, align 8 - br label %end_block - -after_check21: ; preds = %testblock - store i64 0, i64* %e, align 8 - br label %end_block - -end_block: ; preds = %after_check21, %assign_optional - %8 = load i64, i64* %e, align 8 - %neq = icmp ne i64 %8, 0 - br i1 %neq, label %if.then22, label %if.exit23 - -if.then22: ; preds = %end_block - %9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0)) - br label %if.exit23 - -if.exit23: ; preds = %if.then22, %end_block - ret void -} - diff --git a/test/test_suite14/errors/try_catch_if.c3t b/test/test_suite14/errors/try_catch_if.c3t deleted file mode 100644 index 030fe7611..000000000 --- a/test/test_suite14/errors/try_catch_if.c3t +++ /dev/null @@ -1,98 +0,0 @@ -// #target: macos-x64 - -fn int hello(int x) -{ - return x + 1; -} - -extern fn int printf(char *c, ...); - -fn int! tester() -{ - printf("In tester\n"); - return 222; -} - -fault Foo -{ - A -} -fn void test1() -{ - int! a = 123; - if (catch err = (a, tester())) - { - printf("Err\n"); - } - else - { - printf("Noerr %d\n", a); - } -} -fn void main() -{ - test1(); -} - -/* #expect: try_catch_if.ll - -define i64 @try_catch_if_tester(i32* %0) #0 { -entry: - %reterr = alloca i64, align 8 - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0)) - store i32 222, i32* %0, align 4 - ret i64 0 -} - -define void @try_catch_if_test1() #0 { -entry: - %a = alloca i32, align 4 - %a.f = alloca i64, align 8 - %err = alloca i64, align 8 - %retparam = alloca i32, align 4 - store i32 123, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - br label %testblock - -testblock: ; preds = %entry - %optval = load i64, i64* %a.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %testblock - store i64 %optval, i64* %err, align 8 - br label %end_block - -after_check: ; preds = %testblock - br label %testblock1 - -testblock1: ; preds = %after_check - %0 = call i64 @try_catch_if_tester(i32* %retparam) - %not_err2 = icmp eq i64 %0, 0 - br i1 %not_err2, label %after_check4, label %assign_optional3 - -assign_optional3: ; preds = %testblock1 - store i64 %0, i64* %err, align 8 - br label %end_block - -after_check4: ; preds = %testblock1 - store i64 0, i64* %err, align 8 - br label %end_block - -end_block: ; preds = %after_check4, %assign_optional3, %assign_optional - %1 = load i64, i64* %err, align 8 - %neq = icmp ne i64 %1, 0 - br i1 %neq, label %if.then, label %if.else - -if.then: ; preds = %end_block - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0)) - br label %if.exit - -if.else: ; preds = %end_block - %3 = load i32, i32* %a, align 4 - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i32 %3) - br label %if.exit - -if.exit: ; preds = %if.else, %if.then - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/try_catch_unwrapping_while_if.c3 b/test/test_suite14/errors/try_catch_unwrapping_while_if.c3 deleted file mode 100644 index faaf287d7..000000000 --- a/test/test_suite14/errors/try_catch_unwrapping_while_if.c3 +++ /dev/null @@ -1,98 +0,0 @@ -extern fn int printf(char* fmt, ...); - -extern fn int! err(); -fault FooErr -{ - X -} -fn void test1() -{ - int! z = 234; - if (try z) - { - int y = z; - z = 12; - z = FooErr.X!; // #error: The variable is unwrapped in this context - } -} - - -fn void test4() -{ - int! z = 234; - int! w = 123; - if (try z && try w && 1) - { - int y = z; - y = w; - } -} - -fn void test5() -{ - int! z = 234; - int! w = 123; - if (try z && try w) - { - int y = z; - } -} -fn void test5b() -{ - int! z = 234; - int! w = 123; - if (try z && try z) // #error: This variable is already unwrapped, so you cannot use 'try' on it again, please remove the 'try'. - { - int y = z; - } -} - -fn void test6() -{ - int! z = 234; - int! w = 123; - while (try z) - { - int y = z; - break; - } -} - -fn void test7() -{ - int! z = 234; - int! w = 123; - if (catch z) - { - } - else - { - int y = z; - } -} - -fn void test8() -{ - int! z = 234; - int! w = 123; - if (catch z) - { - } - else - { - int y = z; - } -} -fn void test9() -{ - int! z = 234; - int! w = 123; - anyerr e; - if (catch e = z) - { - } - else - { - int y = z; - } -} diff --git a/test/test_suite14/errors/try_unwrap_using_assert.c3t b/test/test_suite14/errors/try_unwrap_using_assert.c3t deleted file mode 100644 index 9974ae2df..000000000 --- a/test/test_suite14/errors/try_unwrap_using_assert.c3t +++ /dev/null @@ -1,41 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn int! maybe(); - -fn int tester(int n) -{ - int! num = maybe(); - assert(try num, "Hello"); - int x = num; - return num; -} - -/* #expect: test.ll - -define i32 @test_tester(i32 %0) #0 { -entry: - %num = alloca i32, align 4 - %num.f = alloca i64, align 8 - %retparam = alloca i32, align 4 - %x = alloca i32, align 4 - %1 = call i64 @maybe(i32* %retparam) - %not_err = icmp eq i64 %1, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %1, i64* %num.f, align 8 - br label %after_assign - -after_check: ; preds = %entry - %2 = load i32, i32* %retparam, align 4 - store i32 %2, i32* %num, align 4 - store i64 0, i64* %num.f, align 8 - br label %after_assign - -after_assign: ; preds = %after_check, %assign_optional - %3 = load i32, i32* %num, align 4 - store i32 %3, i32* %x, align 4 - %4 = load i32, i32* %num, align 4 - ret i32 %4 -} \ No newline at end of file diff --git a/test/test_suite14/errors/try_with_assign_to_failable.c3 b/test/test_suite14/errors/try_with_assign_to_failable.c3 deleted file mode 100644 index 191006004..000000000 --- a/test/test_suite14/errors/try_with_assign_to_failable.c3 +++ /dev/null @@ -1,6 +0,0 @@ -fn void test() -{ - int! z; - int! w; - try w = z; // #error: An unwrapping 'try' can only occur as the last element of a conditional, did you want 'try(expr) -} diff --git a/test/test_suite14/errors/try_with_chained_unwrap.c3t b/test/test_suite14/errors/try_with_chained_unwrap.c3t deleted file mode 100644 index d419e18e6..000000000 --- a/test/test_suite14/errors/try_with_chained_unwrap.c3t +++ /dev/null @@ -1,57 +0,0 @@ -// #target: macos-x64 - -extern fn char*! readLine(); -extern fn int! atoi(char*); - -extern fn int printf(char* fmt, ...); - -fn void main() -{ - int val; - if (try val = atoi(readLine())) - { - printf("You typed the number %d\n", val); - return; - } - printf("You didn't type an integer :(\n"); -} - -// #expect: try_with_chained_unwrap.ll - -define void @try_with_chained_unwrap_main() #0 { -entry: - %val = alloca i32, align 4 - %retparam = alloca i32, align 4 - %retparam1 = alloca i8*, align 8 - store i32 0, i32* %val, align 4 - %0 = call i64 @readLine(i8** %retparam1) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %catch_landing - -after_check: ; preds = %entry - %1 = load i8*, i8** %retparam1, align 8 - %2 = call i64 @atoi(i32* %retparam, i8* %1) - %not_err2 = icmp eq i64 %2, 0 - br i1 %not_err2, label %after_check3, label %catch_landing - -after_check3: ; preds = %after_check - %3 = load i32, i32* %retparam, align 4 - store i32 %3, i32* %val, align 4 - br label %phi_try_catch - -catch_landing: ; preds = %after_check, %entry - br label %phi_try_catch - -phi_try_catch: ; preds = %catch_landing, %after_check3 - %val4 = phi i1 [ true, %after_check3 ], [ false, %catch_landing ] - br i1 %val4, label %if.then, label %if.exit - -if.then: ; preds = %phi_try_catch - %4 = load i32, i32* %val, align 4 - %5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i32 0, i32 0), i32 %4) - ret void - -if.exit: ; preds = %phi_try_catch - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i32 0, i32 0)) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/errors/try_with_chained_unwrap_errors.c3 b/test/test_suite14/errors/try_with_chained_unwrap_errors.c3 deleted file mode 100644 index c57acffc1..000000000 --- a/test/test_suite14/errors/try_with_chained_unwrap_errors.c3 +++ /dev/null @@ -1,93 +0,0 @@ -fn void test() -{ - int! a; - int b; - if (try int b = a) {} // #error: 'b' would shadow a previous declaration. -} -fn void test2() -{ - int! a; - int b; - if (try b = a) {} - if (try test2 = a) {} // #error: You cannot assign a value to a function -} - -const int BAZ = 1; - -fn void test3() -{ - - int! a; - int b; - if (try BAZ = a) {} // #error: You cannot assign to a constant -} - - -fn void test4() -{ - - int! a; - int b; - if (try b = 1) {} // #error: remove 'try' -} - -fn void test5() -{ - - int! a; - int b; - if (try a = a) {} // #error: you use 'try' without '=' -} - -fn void test6() -{ - - int! a; - int b; - int*! x; - if (try *x = a) {} // #error: You cannot assign to a dereferenced optional. -} - - -fn void test7() -{ - int! a; - int b; - int*! x; - if (try foo::z = a) {} // #error: The variable may not have a path. -} - -fn void test8() -{ - int! a; - int b; - if (b == 0, try b = a && try b = a && b > 0) {} - if (try b = a && try b = a && b > 0) {} - if (try c = a && try c = a) { c++; } -} - -fn void test9() -{ - int! a = 11; - if (try z = a) - { - int g = z++; - } - else - { - z++; // #error: 'z' could not be found, did you spell it right? - } -} - -fn void test10() -{ - int! a = 11; - if (try a) - { - int g = a; - } - else - { - int g = a; // #error: 'int!' to 'int' - } -} \ No newline at end of file diff --git a/test/test_suite14/errors/try_with_unwrap.c3t b/test/test_suite14/errors/try_with_unwrap.c3t deleted file mode 100644 index 4759f09d3..000000000 --- a/test/test_suite14/errors/try_with_unwrap.c3t +++ /dev/null @@ -1,84 +0,0 @@ -// #target: macos-x64 -extern fn char*! readLine(); -extern fn int! atoi(char*); - -extern fn int printf(char* fmt, ...); - -fn void main() -{ - char*! line = readLine(); - if (try line) - { - int! val = atoi(line); - if (try val) - { - printf("You typed the number %d\n", val); - return; - } - } - printf("You didn't type an integer :(\n"); -} - -/* #expect: try_with_unwrap.ll - -define void @try_with_unwrap_main() #0 { -entry: - %line = alloca i8*, align 8 - %line.f = alloca i64, align 8 - %retparam = alloca i8*, align 8 - %val = alloca i32, align 4 - %val.f = alloca i64, align 8 - %retparam1 = alloca i32, align 4 - %0 = call i64 @readLine(i8** %retparam) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %0, i64* %line.f, align 8 - br label %after_assign - -after_check: ; preds = %entry - %1 = load i8*, i8** %retparam, align 8 - store i8* %1, i8** %line, align 8 - store i64 0, i64* %line.f, align 8 - br label %after_assign - -after_assign: ; preds = %after_check, %assign_optional - %load.err = load i64, i64* %line.f, align 8 - %result = icmp eq i64 %load.err, 0 - br i1 %result, label %if.then, label %if.exit9 - -if.then: ; preds = %after_assign - %2 = load i8*, i8** %line, align 8 - %3 = call i64 @atoi(i32* %retparam1, i8* %2) - %not_err2 = icmp eq i64 %3, 0 - br i1 %not_err2, label %after_check4, label %assign_optional3 - -assign_optional3: ; preds = %if.then - store i64 %3, i64* %val.f, align 8 - br label %after_assign5 - -after_check4: ; preds = %if.then - %4 = load i32, i32* %retparam1, align 4 - store i32 %4, i32* %val, align 4 - store i64 0, i64* %val.f, align 8 - br label %after_assign5 - -after_assign5: ; preds = %after_check4, %assign_optional3 - %load.err6 = load i64, i64* %val.f, align 8 - %result7 = icmp eq i64 %load.err6, 0 - br i1 %result7, label %if.then8, label %if.exit - -if.then8: ; preds = %after_assign5 - %5 = load i32, i32* %val, align 4 - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i32 0, i32 0), i32 %5) - ret void - -if.exit: ; preds = %after_assign5 - br label %if.exit9 - -if.exit9: ; preds = %if.exit, %after_assign - %7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i32 0, i32 0)) - ret void -} - diff --git a/test/test_suite14/errors/try_with_unwrapper.c3t b/test/test_suite14/errors/try_with_unwrapper.c3t deleted file mode 100644 index 7fff22c00..000000000 --- a/test/test_suite14/errors/try_with_unwrapper.c3t +++ /dev/null @@ -1,184 +0,0 @@ -// #target: macos-x64 - -fn int hello(int x) -{ - return x + 1; -} - -extern fn int printf(char *c, ...); - -fn int! tester() -{ - printf("In tester\n"); - return 222; -} - -fault Foo -{ - A -} -fn void test1() -{ - int! a = 11; - if (try int b = a && try int c = tester()) - { - printf("%d\n", hello(b)); - printf("%d\n", c); - } -} -fn void main() -{ - test1(); -} - -fn void test2() -{ - int! a; - if (try int b = a && hello(b)) - { - hello(b + 1); - } -} - -/* #expect: try_with_unwrapper.ll - - - -; Function Attrs: nounwind -define i32 @try_with_unwrapper_hello(i32 %0) #0 { -entry: - %add = add i32 %0, 1 - ret i32 %add -} - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define i64 @try_with_unwrapper_tester(i32* %0) #0 { -entry: - %reterr = alloca i64, align 8 - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0)) - store i32 222, i32* %0, align 4 - ret i64 0 -} - -; Function Attrs: nounwind -define void @try_with_unwrapper_test1() #0 { -entry: - %a = alloca i32, align 4 - %a.f = alloca i64, align 8 - %b = alloca i32, align 4 - %c = alloca i32, align 4 - %retparam = alloca i32, align 4 - store i32 11, i32* %a, align 4 - store i64 0, i64* %a.f, align 8 - store i32 0, i32* %b, align 4 - %optval = load i64, i64* %a.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %catch_landing - -after_check: ; preds = %entry - %0 = load i32, i32* %a, align 4 - store i32 %0, i32* %b, align 4 - br label %phi_try_catch - -catch_landing: ; preds = %entry - br label %phi_try_catch - -phi_try_catch: ; preds = %catch_landing, %after_check - %val = phi i1 [ true, %after_check ], [ false, %catch_landing ] - br i1 %val, label %chain_next, label %fail_chain - -chain_next: ; preds = %phi_try_catch - store i32 0, i32* %c, align 4 - %1 = call i64 @try_with_unwrapper_tester(i32* %retparam) - %not_err1 = icmp eq i64 %1, 0 - br i1 %not_err1, label %after_check2, label %catch_landing3 - -after_check2: ; preds = %chain_next - %2 = load i32, i32* %retparam, align 4 - store i32 %2, i32* %c, align 4 - br label %phi_try_catch4 - -catch_landing3: ; preds = %chain_next - br label %phi_try_catch4 - -phi_try_catch4: ; preds = %catch_landing3, %after_check2 - %val5 = phi i1 [ true, %after_check2 ], [ false, %catch_landing3 ] - br i1 %val5, label %chain_next6, label %fail_chain - -chain_next6: ; preds = %phi_try_catch4 - br label %end_chain - -fail_chain: ; preds = %phi_try_catch4, %phi_try_catch - br label %end_chain - -end_chain: ; preds = %fail_chain, %chain_next6 - %chain.phi = phi i1 [ true, %chain_next6 ], [ false, %fail_chain ] - br i1 %chain.phi, label %if.then, label %if.exit - -if.then: ; preds = %end_chain - %3 = load i32, i32* %b, align 4 - %4 = call i32 @try_with_unwrapper_hello(i32 %3) - %5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %4) - %6 = load i32, i32* %c, align 4 - %7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 %6) - br label %if.exit - -if.exit: ; preds = %if.then, %end_chain - ret void -} - - -; Function Attrs: nounwind -define void @try_with_unwrapper_test2() #0 { -entry: - %a = alloca i32, align 4 - %a.f = alloca i64, align 8 - %b = alloca i32, align 4 - store i64 0, i64* %a.f, align 8 - store i32 0, i32* %a, align 4 - store i32 0, i32* %b, align 4 - %optval = load i64, i64* %a.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %catch_landing - -after_check: ; preds = %entry - %0 = load i32, i32* %a, align 4 - store i32 %0, i32* %b, align 4 - br label %phi_try_catch - -catch_landing: ; preds = %entry - br label %phi_try_catch - -phi_try_catch: ; preds = %catch_landing, %after_check - %val = phi i1 [ true, %after_check ], [ false, %catch_landing ] - br i1 %val, label %chain_next, label %fail_chain - -chain_next: ; preds = %phi_try_catch - %1 = load i32, i32* %b, align 4 - %2 = call i32 @try_with_unwrapper_hello(i32 %1) - %intbool = icmp ne i32 %2, 0 - br i1 %intbool, label %chain_next1, label %fail_chain - -chain_next1: ; preds = %chain_next - br label %end_chain - -fail_chain: ; preds = %chain_next, %phi_try_catch - br label %end_chain - -end_chain: ; preds = %fail_chain, %chain_next1 - %chain.phi = phi i1 [ true, %chain_next1 ], [ false, %fail_chain ] - br i1 %chain.phi, label %if.then, label %if.exit - -if.then: ; preds = %end_chain - %3 = load i32, i32* %b, align 4 - %add = add i32 %3, 1 - %4 = call i32 @try_with_unwrapper_hello(i32 %add) - br label %if.exit - -if.exit: ; preds = %if.then, %end_chain - ret void -} - diff --git a/test/test_suite14/errors/try_with_weird_stuff.c3 b/test/test_suite14/errors/try_with_weird_stuff.c3 deleted file mode 100644 index 2cf0bdf0f..000000000 --- a/test/test_suite14/errors/try_with_weird_stuff.c3 +++ /dev/null @@ -1,16 +0,0 @@ -fn void test1() -{ - - int! a; - int b; - int*! x; - if (try int 1 = a) {} // #error: A new variable was expected. -} - -fn void test2() -{ - int! a; - int b; - int*! x; - if (try foo::z = a, b += 1) {} // #error: The 'try' must be placed last, can you change it? -} \ No newline at end of file diff --git a/test/test_suite14/examples/gameoflife.c3 b/test/test_suite14/examples/gameoflife.c3 deleted file mode 100644 index 676449291..000000000 --- a/test/test_suite14/examples/gameoflife.c3 +++ /dev/null @@ -1,90 +0,0 @@ -module game_of_life; - -extern fn void printf(char *fmt, ...); -extern fn int atoi(char *val); -extern void *__stdoutp; -extern fn void fflush(void *std); -extern fn int rand(); -extern fn void* malloc(usz size); -extern fn void usleep(int time); - - -struct GameBoard -{ - int h; - int w; - char* world; - char* temp; -} - -fn void GameBoard.show(GameBoard *board) -{ - - printf("\e[H"); - char* current = board.world; - for (int y = 0; y < board.h; y++) - { - for (int x = 0; x < board.w; x++) - { - printf(*current ? "\e[07m \e[m" : " "); - current++; - } - printf("\e[E"); - } - fflush(__stdoutp); -} - -fn void GameBoard.evolve(GameBoard *board) -{ - for (int y = 0; y < board.h; y++) - { - for (int x = 0; x < board.w; x++) - { - int n = 0; - for (int y1 = y - 1; y1 <= y + 1; y1++) - { - for (int x1 = x - 1; x1 <= x + 1; x1++) - { - int actualX = (x1 + board.w) % board.w; - int actualY = (y1 + board.h) % board.h; - if (board.world[actualX + actualY * board.w]) n++; - } - } - if (board.world[x + y * board.w]) n--; - board.temp[x + y * board.w] = (char)(n == 3 || (n == 2 && board.world[x + y * board.w])); - } - } - for (int i = 0; i < board.w * board.h; i++) - { - board.world[i] = board.temp[i]; - } -} - - -fn int main(int c, char** v) -{ - int w = 0; - int h = 0; - if (c > 1) w = atoi(v[1]); - if (c > 2) h = atoi(v[2]); - if (w <= 0) w = 30; - if (h <= 0) h = 30; - - GameBoard board; - board.w = w; - board.h = h; - board.world = malloc(h * w); - board.temp = malloc(h * w); - - for (int i = h * w - 1; i >= 0; i--) - { - board.world[i] = rand() % 10 == 0 ? 1 : 0; - } - for (int j = 0; j < 1000; j++) - { - board.show(); - board.evolve(); - usleep(200000); - } - return 1; -} \ No newline at end of file diff --git a/test/test_suite14/expression_block/expr_block_labelled_break.c3 b/test/test_suite14/expression_block/expr_block_labelled_break.c3 deleted file mode 100644 index 22738b1f4..000000000 --- a/test/test_suite14/expression_block/expr_block_labelled_break.c3 +++ /dev/null @@ -1,10 +0,0 @@ - -fn void test() -{ - for FOO: (int i = 0; i < 100; i++) - { - {| - if (i == 10) break FOO; // #error: You cannot break out of an expression block - |}; - } -} \ No newline at end of file diff --git a/test/test_suite14/expression_block/expression_block_break.c3 b/test/test_suite14/expression_block/expression_block_break.c3 deleted file mode 100644 index 6c558005d..000000000 --- a/test/test_suite14/expression_block/expression_block_break.c3 +++ /dev/null @@ -1,13 +0,0 @@ -module fe; -import std::io; -extern fn int printf(char *str, ...); - -fn int main() -{ - while(true) - { - return {| break; return 0; |}; // #error: There is no valid target for 'break', did you make a mistake - } - io::println("I didn't return."); - return 0; -} \ No newline at end of file diff --git a/test/test_suite14/expression_block/expression_block_no_end_return.c3 b/test/test_suite14/expression_block/expression_block_no_end_return.c3 deleted file mode 100644 index 19e7f74da..000000000 --- a/test/test_suite14/expression_block/expression_block_no_end_return.c3 +++ /dev/null @@ -1,8 +0,0 @@ -module foob; - -fn void main() -{ - {| - if (1) return 1; // #error: Expected a return statement following this statement - |}; -} diff --git a/test/test_suite14/expressions/2002-02-13-ConditionalInCall.c3t b/test/test_suite14/expressions/2002-02-13-ConditionalInCall.c3t deleted file mode 100644 index e922e42b5..000000000 --- a/test/test_suite14/expressions/2002-02-13-ConditionalInCall.c3t +++ /dev/null @@ -1,16 +0,0 @@ -// #target: macos-x64 - -module test; - -extern fn void foo(int, double, float); - -fn void bar(int x) -{ - foo(x, x ? 1.0 : 12.5, 1.0); -} - -/* #expect: test.ll - - %intbool = icmp ne i32 %0, 0 - %ternary = select i1 %intbool, double 1.000000e+00, double 1.250000e+01 - call void @foo(i32 %0, double %ternary, float 1.000000e+00) diff --git a/test/test_suite14/expressions/addr_compiles.c3t b/test/test_suite14/expressions/addr_compiles.c3t deleted file mode 100644 index eb7869d4b..000000000 --- a/test/test_suite14/expressions/addr_compiles.c3t +++ /dev/null @@ -1,144 +0,0 @@ -// #target: macos-x64 - -module test; - -extern fn void printf(char*, ...); - -fn void main() -{ - test(); - test2(); - test3(); -} - -fn void test() -{ - int f = 3; - int* x = &(((f))); - int* h = &&(f++); - printf("x = %d (4), h = %d (3)\n", *x, *h); -} - - -const int XX = 314; -fn void test2() -{ - int* w = &XX; - printf("w = %d (314)\n", *w); -} - -struct Foo -{ - int x; - int y; -} -fn void test3() -{ - Foo h = { 345, 555 }; - int* zx = &h.x; - int* zy = &h.y; - int[3] arr = { 333, 444, 999 }; - printf("zx = %d (345) zy = %d (555)\n", *zx, *zy); - arr[0]--; - arr[1]--; - arr[2]--; - int* d = &arr[2]; - int[]* e = &&arr[1..2]; - printf("d = %d (998) e = %d (443)\n", *d, (*e)[0]); -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - call void @test_test() - call void @test_test2() - call void @test_test3() - ret void -} - -; Function Attrs: nounwind -define void @test_test() #0 { -entry: - %f = alloca i32, align 4 - %x = alloca i32*, align 8 - %h = alloca i32*, align 8 - %taddr = alloca i32, align 4 - store i32 3, i32* %f, align 4 - store i32* %f, i32** %x, align 8 - %0 = load i32, i32* %f, align 4 - %add = add i32 %0, 1 - store i32 %add, i32* %f, align 4 - store i32 %0, i32* %taddr, align 4 - store i32* %taddr, i32** %h, align 8 - %1 = load i32*, i32** %x, align 8 - %2 = load i32, i32* %1, align 4 - %3 = load i32*, i32** %h, align 8 - %4 = load i32, i32* %3, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i32 0, i32 0), i32 %2, i32 %4) - ret void -} - -; Function Attrs: nounwind -define void @test_test2() #0 { -entry: - %w = alloca i32*, align 8 - store i32* @test_XX, i32** %w, align 8 - %0 = load i32*, i32** %w, align 8 - %1 = load i32, i32* %0, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i32 %1) - ret void -} - -; Function Attrs: nounwind -define void @test_test3() #0 { -entry: - %h = alloca %Foo, align 4 - %zx = alloca i32*, align 8 - %zy = alloca i32*, align 8 - %arr = alloca [3 x i32], align 4 - %d = alloca i32*, align 8 - %e = alloca %"int[]"*, align 8 - %taddr = alloca %"int[]", align 8 - %0 = bitcast %Foo* %h to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%Foo* @.__const to i8*), i32 8, i1 false) - %1 = getelementptr inbounds %Foo, %Foo* %h, i32 0, i32 0 - store i32* %1, i32** %zx, align 8 - %2 = getelementptr inbounds %Foo, %Foo* %h, i32 0, i32 1 - store i32* %2, i32** %zy, align 8 - %3 = bitcast [3 x i32]* %arr to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 bitcast ([3 x i32]* @.__const.2 to i8*), i32 12, i1 false) - %4 = load i32*, i32** %zx, align 8 - %5 = load i32, i32* %4, align 4 - %6 = load i32*, i32** %zy, align 8 - %7 = load i32, i32* %6, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i32 0, i32 0), i32 %5, i32 %7) - %8 = getelementptr inbounds [3 x i32], [3 x i32]* %arr, i64 0, i64 0 - %9 = load i32, i32* %8, align 4 - %sub = sub i32 %9, 1 - store i32 %sub, i32* %8, align 4 - %10 = getelementptr inbounds [3 x i32], [3 x i32]* %arr, i64 0, i64 1 - %11 = load i32, i32* %10, align 4 - %sub1 = sub i32 %11, 1 - store i32 %sub1, i32* %10, align 4 - %12 = getelementptr inbounds [3 x i32], [3 x i32]* %arr, i64 0, i64 2 - %13 = load i32, i32* %12, align 4 - %sub2 = sub i32 %13, 1 - store i32 %sub2, i32* %12, align 4 - %14 = getelementptr inbounds [3 x i32], [3 x i32]* %arr, i64 0, i64 2 - store i32* %14, i32** %d, align 8 - %15 = getelementptr inbounds [3 x i32], [3 x i32]* %arr, i64 0, i64 1 - %16 = insertvalue %"int[]" undef, i32* %15, 0 - %17 = insertvalue %"int[]" %16, i64 2, 1 - store %"int[]" %17, %"int[]"* %taddr, align 8 - store %"int[]"* %taddr, %"int[]"** %e, align 8 - %18 = load i32*, i32** %d, align 8 - %19 = load i32, i32* %18, align 4 - %20 = load %"int[]"*, %"int[]"** %e, align 8 - %21 = getelementptr inbounds %"int[]", %"int[]"* %20, i32 0, i32 0 - %22 = load i32*, i32** %21, align 8 - %ptroffset = getelementptr inbounds i32, i32* %22, i64 0 - %23 = load i32, i32* %ptroffset, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i32 0, i32 0), i32 %19, i32 %23) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/expressions/addr_of_fails.c3 b/test/test_suite14/expressions/addr_of_fails.c3 deleted file mode 100644 index ec43851b4..000000000 --- a/test/test_suite14/expressions/addr_of_fails.c3 +++ /dev/null @@ -1,78 +0,0 @@ -fn void test() -{ - int f; - int* x = &(((f))); - int* h = &&(f++); - int* z = &(f++); // #error: To take the address of a temporary value, use '&&' instead of '&' -} - - -fn void test2() -{ - int f; - var $foo; - int* x = &$foo; // #error: It's not possible to take the address of a compile time value -} - -int he; -macro int hello() -{ - return he; -} - -fn void test3() -{ - int* x = &hello(); // #error: To take the address of a temporary value, use '&&' instead of '&' -} - -fn void test3b() -{ - int* x = &hello; // #error: It is not possible to take the address of a macro. -} - -const X = 2; -const int XX = 3; -fn void test4() -{ - int* w = &XX; -} - -fn void test5() -{ - int* z = &X; // #error: The constant is not typed, either type it or use && to take the reference to a temporary. -} - -struct Foo -{ - int x; - int y; -} - -define heh = he; - -fn void test6() -{ - int* hee = &heh; - Foo h; - int* z = &h.x; - int[3] arr; - int* d = &arr[2]; - int[]* e = &arr[1..2]; // #error: To take the address of a temporary value, use '&&' instead of '&' -} - -define Baz = Foo; -define Bar = distinct int; -fault Err { FOO } -union Un { int x; } -enum MyEnum { BAR } - -fn void test7() -{ - &Baz; // #error: It is not possible to take the address of a type. - &Bar; // #error: It is not possible to take the address of a type. - &Err; // #error: It is not possible to take the address of a type. - &Un; // #error: It is not possible to take the address of a type. - &Err.FOO; // #error: To take the address of a temporary value, use '&&' instead of '&' - &MyEnum; // #error: It is not possible to take the address of a type. - &MyEnum.BAR; // #error: To take the address of a temporary value, use '&&' instead of '&' -} diff --git a/test/test_suite14/expressions/arithmetics.c3 b/test/test_suite14/expressions/arithmetics.c3 deleted file mode 100644 index 3644ed17e..000000000 --- a/test/test_suite14/expressions/arithmetics.c3 +++ /dev/null @@ -1,40 +0,0 @@ -module arithmetics; - -fn void testAdd(int a, int b) -{ - a = a + b; - a += b; - a += 1; -} - -fn void testSub(int a, int b) -{ - a = a - b; - a -= b; - a -= 1; -} - -fn void testMult(int a, int b) -{ - a = a * b; - a *= b; - a *= 1; -} - -fn void testDiv(int a, int b) -{ - a = a / b; - a /= b; - a /= 1; -} - -fn void testAssignment() -{ - ichar x = -3 - 5; - ichar c = -128; -} - -fn char test22() -{ - return 100; -} \ No newline at end of file diff --git a/test/test_suite14/expressions/arithmetics_sema_fail.c3 b/test/test_suite14/expressions/arithmetics_sema_fail.c3 deleted file mode 100644 index ffb6dda03..000000000 --- a/test/test_suite14/expressions/arithmetics_sema_fail.c3 +++ /dev/null @@ -1,91 +0,0 @@ - -fn void test7() -{ - double x = 1.2 / 0; // This is ok! NaN -} - -fn void test8() -{ - int y = 0 / 0; // #error: division by zero is not allowed -} - -fn void test9() -{ - int y = 0; - int x = y / 0; // #error: division by zero is not allowed -} - -fn void test10() -{ - 10 = 20; // #error: An assignable expression -} - -fn void test11() -{ - '10' = '20'; // #error: An assignable expression -} - -fn void test12() -{ - true = false; // #error: An assignable expression -} - -fn void test13() -{ - "a" = "b"; // #error: An assignable expression -} - -fn void test14() -{ - 1.2 = 1.3; // #error: An assignable expression -} - -fn void test15() -{ - null = null; // #error: An assignable expression -} - -fn void test16() -{ - int a = 0; - uint b = 2; - ushort c = 3; - a = a + c; - int g = a + b; -} - -fn void test17() -{ - char a = 100 + 300; // #error: '400' is out of range for 'char' -} - -fn void test18() -{ - char b = 100 + 156; // #error: '256' is out of range for 'char' -} - -fn void test19() -{ - ichar b = (-40) - 126; // #error: '-166' is out of range for 'ichar' -} - - - -fn void test20() -{ - ichar d = ((-128 - 10) + 10) - 2; // #error: '-130' is out of range for 'ichar' - ichar c = 100 * 100; // #error: '10000' is out of range for 'ichar' - ichar e = (-138 + 30); - ichar f = -138 + 30; - ichar g = -(128); - check(128); // #error: '128' is out of range for 'ichar' -} - -fn void check(ichar x) {} - - -fn char test22() -{ - return 300; // #error: '300' is out of range for 'char' -} - diff --git a/test/test_suite14/expressions/assign.c3 b/test/test_suite14/expressions/assign.c3 deleted file mode 100644 index 046ae8a8d..000000000 --- a/test/test_suite14/expressions/assign.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test1() -{ - int* p; - *p = 10; -} diff --git a/test/test_suite14/expressions/assign_deref_opt.c3 b/test/test_suite14/expressions/assign_deref_opt.c3 deleted file mode 100644 index 5f4584533..000000000 --- a/test/test_suite14/expressions/assign_deref_opt.c3 +++ /dev/null @@ -1,9 +0,0 @@ -module test; - -fn void main() -{ - int! a; - int*! b; - *b = a; // #error: You cannot assign to a dereferenced optional -} - diff --git a/test/test_suite14/expressions/assignability.c3 b/test/test_suite14/expressions/assignability.c3 deleted file mode 100644 index aeed1330d..000000000 --- a/test/test_suite14/expressions/assignability.c3 +++ /dev/null @@ -1,39 +0,0 @@ -define Number = int; - -fn void test1() -{ - 10 = 20; // #error: An assignable expression -} - -fn void test2() -{ - "foo" = "bar"; // #error: An assignable expression -} - -fn void test3() -{ - true = false; // #error: An assignable expression -} - -fn void test4() -{ - 'c' = 'd'; // #error: An assignable expression -} - -fn void test5() -{ - 3.14 = 2.14; // #error: An assignable expression -} - -fn void test21() -{ - int a = 0; - int b = 2; - a++ = b++; // #error: An assignable expression -} - -fn void test22() -{ - var $Type = void; - $Type = int; -} \ No newline at end of file diff --git a/test/test_suite14/expressions/assignment_precedence.c3t b/test/test_suite14/expressions/assignment_precedence.c3t deleted file mode 100644 index da7d5bc14..000000000 --- a/test/test_suite14/expressions/assignment_precedence.c3t +++ /dev/null @@ -1,23 +0,0 @@ -module prec; - -fn void test() -{ - int i = 1; - int j = 2; - int k = 3; - int l = i = j = k; -} - -// #expect: prec.ll - - %i = alloca i32, align 4 - %j = alloca i32, align 4 - %k = alloca i32, align 4 - %l = alloca i32, align 4 - store i32 1, i32* %i, align 4 - store i32 2, i32* %j, align 4 - store i32 3, i32* %k, align 4 - %0 = load i32, i32* %k, align 4 - store i32 %0, i32* %j, align 4 - store i32 %0, i32* %i, align 4 - store i32 %0, i32* %l, align 4 \ No newline at end of file diff --git a/test/test_suite14/expressions/bit_op_on_bool.c3t b/test/test_suite14/expressions/bit_op_on_bool.c3t deleted file mode 100644 index cd084d32c..000000000 --- a/test/test_suite14/expressions/bit_op_on_bool.c3t +++ /dev/null @@ -1,14 +0,0 @@ -// #target: macos-x64 -module bitop; - -fn bool is_newline_codepoint(uint codepoint) { - return (bool)((codepoint == 0x00_00_24_24) | (codepoint == 0x00_00_2B_92)); -} - -/* #expect: bitop.ll - - %eq = icmp eq i32 %0, 9252 - %eq1 = icmp eq i32 %0, 11154 - %or = or i1 %eq, %eq1 - %1 = zext i1 %or to i8 - ret i8 %1 diff --git a/test/test_suite14/expressions/bool_conversions.c3t b/test/test_suite14/expressions/bool_conversions.c3t deleted file mode 100644 index ef1cb53e1..000000000 --- a/test/test_suite14/expressions/bool_conversions.c3t +++ /dev/null @@ -1,33 +0,0 @@ -// #target: macos-x64 - -private fn bool f0_0(void* a0) { return (bool)a0; } - -fn int f0() { return (int)f0_0((void*)0x2); } - -define Test = fn void(); - -fn bool f1() { return (bool){| Test x = void; return x = (Test)0; |}; } - -/* #expect: bool_conversions.ll - -define internal zeroext i8 @bool_conversions_f0_0(i8* %0) #0 { -entry: - %ptrbool = icmp ne i8* %0, null - %1 = zext i1 %ptrbool to i8 - ret i8 %1 -} - -define i32 @bool_conversions_f0() #0 { -entry: - %0 = call i8 @bool_conversions_f0_0(i8* inttoptr (i64 2 to i8*)) - %1 = trunc i8 %0 to i1 - %boolsi = zext i1 %1 to i32 - ret i32 %boolsi -} - -define zeroext i8 @bool_conversions_f1() #0 { -entry: - %x = alloca void ()*, align 8 - store void ()* null, void ()** %x, align 8 - ret i8 0 -} diff --git a/test/test_suite14/expressions/call_arg_types.c3 b/test/test_suite14/expressions/call_arg_types.c3 deleted file mode 100644 index 405b175be..000000000 --- a/test/test_suite14/expressions/call_arg_types.c3 +++ /dev/null @@ -1,19 +0,0 @@ -fn void test2(ichar a) -{} - -fn void test1() -{ - test2(100); - ichar c = 1; - test2(c); - - int a = 1; - test2(a); // #error: 'ichar' - test2(100 + a); // #error: 'ichar' - - const int X = 120; - test2(X); - - test2(100 + 100); // #error: '200' is out of range for 'ichar' -} - diff --git a/test/test_suite14/expressions/call_inline.c3t b/test/test_suite14/expressions/call_inline.c3t deleted file mode 100644 index 65e8183b0..000000000 --- a/test/test_suite14/expressions/call_inline.c3t +++ /dev/null @@ -1,50 +0,0 @@ -// #target: macos-x64 -module inlineme; -import std::io; - -fn void test1() @inline -{ - io::println("Inline!"); -} - -fn void test2() @noinline -{ - io::println("No inline!"); -} - -fn void test3() -{ - io::println("Plain"); -} - -fn void main() -{ - test1() @inline; - test2() @inline; - test3() @inline; - test1() @noinline; - test2() @noinline; - test3() @noinline; - test1(); - test2(); - test3(); -} -// #expect: inlineme.ll - -entry: - call void @inlineme_test1() #2 - call void @inlineme_test2() #2 - call void @inlineme_test3() #2 - call void @inlineme_test1() #3 - call void @inlineme_test2() #3 - call void @inlineme_test3() #3 - call void @inlineme_test1() #2 - call void @inlineme_test2() - call void @inlineme_test3() - ret void -} - -attributes #0 = { nounwind } -attributes #1 = { noinline nounwind } -attributes #2 = { alwaysinline } -attributes #3 = { noinline } \ No newline at end of file diff --git a/test/test_suite14/expressions/casts/cast_const.c3 b/test/test_suite14/expressions/casts/cast_const.c3 deleted file mode 100644 index 1e9f68455..000000000 --- a/test/test_suite14/expressions/casts/cast_const.c3 +++ /dev/null @@ -1,6 +0,0 @@ -fn void test1() -{ - ichar a = (ichar)(256 + 1); - ushort b = (ushort)(65536+1); - ichar c = (ushort)(65536+400); // #error: truncate the value -} diff --git a/test/test_suite14/expressions/casts/cast_enum_to_various.c3 b/test/test_suite14/expressions/casts/cast_enum_to_various.c3 deleted file mode 100644 index 343719a6f..000000000 --- a/test/test_suite14/expressions/casts/cast_enum_to_various.c3 +++ /dev/null @@ -1,37 +0,0 @@ -struct Struct -{ - int x; -} - -enum Enum : uint -{ - A, B -} - -enum EnumB : char -{ - C, D -} - -define Func = fn void(Enum); - -fn void test1(Enum e) -{ - bool a = (bool)(e); - char b = (char)(e); - uint c = (uint)(e); - float d = (float)(e); - uint* f = (uint*)(e); // #error: 'uint*' -} - -fn void test2(Enum e) -{ - Struct* g = (Struct*)(e); // #error: 'Struct*' -} - -fn void test3(Enum e) -{ - EnumB h = (EnumB)(e); // #error: 'EnumB' - Func i = (Func)(e); // #error: 'Func' -} - diff --git a/test/test_suite14/expressions/casts/cast_expr.c3t b/test/test_suite14/expressions/casts/cast_expr.c3t deleted file mode 100644 index 32d8ee294..000000000 --- a/test/test_suite14/expressions/casts/cast_expr.c3t +++ /dev/null @@ -1,27 +0,0 @@ -module cast_expr; - -fn int main(int argc, char** argv) -{ - int a = 10; - - int b = (ichar)(20); - int c = (ichar)(a); - return 0; -} - -// #expect: cast_expr.ll - -define i32 @main - - %a = alloca i32 - %b = alloca i32 - %c = alloca i32 - - store i32 10, i32* %a - store i32 20, i32* %b - %2 = load i32, i32* %a - trunc i32 %2 to i8 - sext i8 %sisitrunc to i32 - store i32 %sisiext, i32* %c - ret i32 0 -} diff --git a/test/test_suite14/expressions/casts/cast_failable.c3 b/test/test_suite14/expressions/casts/cast_failable.c3 deleted file mode 100644 index 1a650a252..000000000 --- a/test/test_suite14/expressions/casts/cast_failable.c3 +++ /dev/null @@ -1,10 +0,0 @@ -fault MyErr -{ - FOO -} - -fn void test() -{ - int! x = (int!)(MyErr.FOO!); // #error: Casting to an optional type is not - int! y = MyErr.FOO!; -} \ No newline at end of file diff --git a/test/test_suite14/expressions/casts/cast_func_to_various.c3 b/test/test_suite14/expressions/casts/cast_func_to_various.c3 deleted file mode 100644 index 1a7acb57b..000000000 --- a/test/test_suite14/expressions/casts/cast_func_to_various.c3 +++ /dev/null @@ -1,45 +0,0 @@ -struct Struct -{ - int x; -} - -enum Enum : usz -{ - A, B -} - -define Func = fn void(int); -define FuncOther = fn bool(char*); -define FuncSame = fn void(int); - - -fn void test1(Func arg) -{ - bool a = (bool)(arg); - bool b = arg; // #error: 'Func' (fn void(int)) to 'bool' -} - -fn void test2(Func arg) -{ - ichar b = (ichar)(arg); // #error: 'Func' (fn void(int)) to 'ichar' -} - -fn void test3(Func arg) -{ - uint c = (uint)(arg); // #error: 'Func' (fn void(int)) to 'uint' -} - -fn void test4(Func arg) -{ - float d = (float)(arg); // #error: 'Func' (fn void(int)) to 'float' -} - -fn void test7(Func arg) -{ - usz g = (usz)(arg); - FuncOther k = (FuncOther)(arg); - FuncSame l = (FuncSame)(arg); - FuncOther ke = arg; // #error: 'Func' (fn void(int)) to 'FuncOther' (fn bool(char*)) - FuncSame fe = arg; - Enum j = (Enum)(arg); // #error: 'Func' (fn void(int)) to 'Enum' -} diff --git a/test/test_suite14/expressions/casts/cast_to_nonscalar.c3 b/test/test_suite14/expressions/casts/cast_to_nonscalar.c3 deleted file mode 100644 index 6a43d7a4c..000000000 --- a/test/test_suite14/expressions/casts/cast_to_nonscalar.c3 +++ /dev/null @@ -1,9 +0,0 @@ -struct Struct -{ - int x; -} - -fn void test1() -{ - int a = (Struct)(200); // #error: 'int' to 'Struct' -} diff --git a/test/test_suite14/expressions/casts/cast_unknown.c3 b/test/test_suite14/expressions/casts/cast_unknown.c3 deleted file mode 100644 index 31d34c792..000000000 --- a/test/test_suite14/expressions/casts/cast_unknown.c3 +++ /dev/null @@ -1,21 +0,0 @@ -define Number = int; - -fn void test1() -{ - int a = 10; - - int b = (Number)(a); - - int c = (Foo)(a); // #error: 'Foo' could not be found -} - -fn void test2() -{ - int d = (Number)(bar);; // #error: 'bar' could not be found -} - -fn void test3() -{ - int e = (Bar)( // #error: 'Bar' could not be found - faa); // #error: 'faa' could not be found -} diff --git a/test/test_suite14/expressions/casts/explicit_cast.c3 b/test/test_suite14/expressions/casts/explicit_cast.c3 deleted file mode 100644 index b374f02fe..000000000 --- a/test/test_suite14/expressions/casts/explicit_cast.c3 +++ /dev/null @@ -1,16 +0,0 @@ -define Number8 = char; -define Number32 = int; -define DNumber32 = distinct int; -fn void test1() -{ - int a = (ichar)(10); - int b = (ichar)(200); - int c = (int)(200); - ichar d = (int)(200); // #error: truncate the value -} - -fn void test2() -{ - char e = (Number32)(200); - char f = (DNumber32)(200); // #error: DNumber32 -} \ No newline at end of file diff --git a/test/test_suite14/expressions/casts/narrowing.c3 b/test/test_suite14/expressions/casts/narrowing.c3 deleted file mode 100644 index 983d0af78..000000000 --- a/test/test_suite14/expressions/casts/narrowing.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn int main() -{ - ushort x; - uint y; - ushort z = x + (ushort)(0x12); - return 0; -} \ No newline at end of file diff --git a/test/test_suite14/expressions/casts/struct_cast_and_distinct.c3 b/test/test_suite14/expressions/casts/struct_cast_and_distinct.c3 deleted file mode 100644 index 816212d51..000000000 --- a/test/test_suite14/expressions/casts/struct_cast_and_distinct.c3 +++ /dev/null @@ -1,32 +0,0 @@ -module test; - -define Foo = distinct int; - -fn void test1() -{ - int[2][*] x = { { 2, 3}, { 5, 6 }}; - Foo[2][2] y = x; // #error: can do an explicit -} - -fn void test2() -{ - int[2][*] x = { { 2, 3}, { 5, 6 }}; - Foo[2][2] y = (Foo[2][2])x; -} - - -fn void test3() -{ - int[2][*] x = { { 2, 3}, { 5, 6 }}; - Foo[2][2]* y = &x; // #error: can do an explicit -} - -struct Bar { int x; } - -struct Baz { int x; } - -fn void test4() -{ - Baz[2][*] x = { { { 2 } , { 3 } }, {{5}, {6} }}; - Bar[*][*] y = (Bar[2][2])x; -} diff --git a/test/test_suite14/expressions/chained_conditional.c3t b/test/test_suite14/expressions/chained_conditional.c3t deleted file mode 100644 index c44be3422..000000000 --- a/test/test_suite14/expressions/chained_conditional.c3t +++ /dev/null @@ -1,70 +0,0 @@ -// #target: macos-x64 -module chained; - -fn int foo() -{ - return 1; -} - -fn void test() -{ - int x = foo(); - int y = foo(); - int z = foo(); - if (x > 0 && y > 0 && z > 0) - { - foo(); - } - else - { - x++; - } -} - -// #expect: chained.ll - -entry: - %x = alloca i32, align 4 - %y = alloca i32, align 4 - %z = alloca i32, align 4 - %0 = call i32 @chained_foo() - store i32 %0, i32* %x, align 4 - %1 = call i32 @chained_foo() - store i32 %1, i32* %y, align 4 - %2 = call i32 @chained_foo() - store i32 %2, i32* %z, align 4 - %3 = load i32, i32* %x, align 4 - %gt = icmp sgt i32 %3, 0 - br i1 %gt, label %and.rhs, label %and.phi - -and.rhs: - %4 = load i32, i32* %y, align 4 - %gt1 = icmp sgt i32 %4, 0 - br label %and.phi - -and.phi: - %val = phi i1 [ false, %entry ], [ %gt1, %and.rhs ] - br i1 %val, label %and.rhs2, label %and.phi4 - -and.rhs2: - %5 = load i32, i32* %z, align 4 - %gt3 = icmp sgt i32 %5, 0 - br label %and.phi4 - -and.phi4: - %val5 = phi i1 [ false, %and.phi ], [ %gt3, %and.rhs2 ] - br i1 %val5, label %if.then, label %if.else - -if.then: - %6 = call i32 @chained_foo() - br label %if.exit - -if.else: - %7 = load i32, i32* %x, align 4 - %add = add i32 %7, 1 - store i32 %add, i32* %x, align 4 - br label %if.exit - -if.exit: - ret void -} diff --git a/test/test_suite14/expressions/chained_ternary.c3t b/test/test_suite14/expressions/chained_ternary.c3t deleted file mode 100644 index 798043661..000000000 --- a/test/test_suite14/expressions/chained_ternary.c3t +++ /dev/null @@ -1,228 +0,0 @@ -// #target: macos-x64 -module test; - -fault Test { FOO, BAR } - -fn void test() -{ - void* a; - void* b; - void* c; - a = !a ? a : !a ? b : c; - void*! x; - void*! y = !a ? x : b; - y = !a ? b : x; - y = !a ? x : x; - y = !a ? x : Test.FOO!; - y = !a ? Test.FOO! : x; - y = !a ? Test.FOO! : Test.BAR!; -} - -/* #expect: test.ll - - %0 = load i8*, i8** %a, align 8 - %not = icmp eq i8* %0, null - br i1 %not, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - %1 = load i8*, i8** %a, align 8 - br label %cond.phi4 - -cond.rhs: ; preds = %entry - %2 = load i8*, i8** %a, align 8 - %not1 = icmp eq i8* %2, null - br i1 %not1, label %cond.lhs2, label %cond.rhs3 - -cond.lhs2: ; preds = %cond.rhs - %3 = load i8*, i8** %b, align 8 - br label %cond.phi - -cond.rhs3: ; preds = %cond.rhs - %4 = load i8*, i8** %c, align 8 - br label %cond.phi - -cond.phi: ; preds = %cond.rhs3, %cond.lhs2 - %val = phi i8* [ %3, %cond.lhs2 ], [ %4, %cond.rhs3 ] - br label %cond.phi4 - -cond.phi4: ; preds = %cond.phi, %cond.lhs - %val5 = phi i8* [ %1, %cond.lhs ], [ %val, %cond.phi ] - store i8* %val5, i8** %a, align 8 - store i64 0, i64* %x.f, align 8 - store i8* null, i8** %x, align 8 - %5 = load i8*, i8** %a, align 8 - %not6 = icmp eq i8* %5, null - br i1 %not6, label %cond.lhs7, label %cond.rhs8 - -cond.lhs7: ; preds = %cond.phi4 - %optval = load i64, i64* %x.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %cond.lhs7 - store i64 %optval, i64* %y.f, align 8 - br label %after_assign - -after_check: ; preds = %cond.lhs7 - %6 = load i8*, i8** %x, align 8 - br label %cond.phi9 - -cond.rhs8: ; preds = %cond.phi4 - %7 = load i8*, i8** %b, align 8 - br label %cond.phi9 - -cond.phi9: ; preds = %cond.rhs8, %after_check - %val10 = phi i8* [ %6, %after_check ], [ %7, %cond.rhs8 ] - store i8* %val10, i8** %y, align 8 - store i64 0, i64* %y.f, align 8 - br label %after_assign - -after_assign: ; preds = %cond.phi9, %assign_optional - %8 = load i8*, i8** %a, align 8 - %not11 = icmp eq i8* %8, null - br i1 %not11, label %cond.lhs12, label %cond.rhs13 - -cond.lhs12: ; preds = %after_assign - %9 = load i8*, i8** %b, align 8 - br label %cond.phi18 - -cond.rhs13: ; preds = %after_assign - %optval14 = load i64, i64* %x.f, align 8 - %not_err15 = icmp eq i64 %optval14, 0 - br i1 %not_err15, label %after_check17, label %assign_optional16 - -assign_optional16: ; preds = %cond.rhs13 - store i64 %optval14, i64* %y.f, align 8 - br label %after_assign20 - -after_check17: ; preds = %cond.rhs13 - %10 = load i8*, i8** %x, align 8 - br label %cond.phi18 - -cond.phi18: ; preds = %after_check17, %cond.lhs12 - %val19 = phi i8* [ %9, %cond.lhs12 ], [ %10, %after_check17 ] - store i8* %val19, i8** %y, align 8 - store i64 0, i64* %y.f, align 8 - br label %after_assign20 - -after_assign20: ; preds = %cond.phi18, %assign_optional16 - br label %voiderr - -voiderr: ; preds = %after_assign20 - %11 = load i8*, i8** %a, align 8 - %not21 = icmp eq i8* %11, null - br i1 %not21, label %cond.lhs22, label %cond.rhs27 - -cond.lhs22: ; preds = %voiderr - %optval23 = load i64, i64* %x.f, align 8 - %not_err24 = icmp eq i64 %optval23, 0 - br i1 %not_err24, label %after_check26, label %assign_optional25 - -assign_optional25: ; preds = %cond.lhs22 - store i64 %optval23, i64* %y.f, align 8 - br label %after_assign34 - -after_check26: ; preds = %cond.lhs22 - %12 = load i8*, i8** %x, align 8 - br label %cond.phi32 - -cond.rhs27: ; preds = %voiderr - %optval28 = load i64, i64* %x.f, align 8 - %not_err29 = icmp eq i64 %optval28, 0 - br i1 %not_err29, label %after_check31, label %assign_optional30 - -assign_optional30: ; preds = %cond.rhs27 - store i64 %optval28, i64* %y.f, align 8 - br label %after_assign34 - -after_check31: ; preds = %cond.rhs27 - %13 = load i8*, i8** %x, align 8 - br label %cond.phi32 - -cond.phi32: ; preds = %after_check31, %after_check26 - %val33 = phi i8* [ %12, %after_check26 ], [ %13, %after_check31 ] - store i8* %val33, i8** %y, align 8 - store i64 0, i64* %y.f, align 8 - br label %after_assign34 - -after_assign34: ; preds = %cond.phi32, %assign_optional30, %assign_optional25 - br label %voiderr35 - -voiderr35: ; preds = %after_assign34 - %14 = load i8*, i8** %a, align 8 - %not36 = icmp eq i8* %14, null - br i1 %not36, label %cond.lhs37, label %cond.rhs42 - -cond.lhs37: ; preds = %voiderr35 - %optval38 = load i64, i64* %x.f, align 8 - %not_err39 = icmp eq i64 %optval38, 0 - br i1 %not_err39, label %after_check41, label %assign_optional40 - -assign_optional40: ; preds = %cond.lhs37 - store i64 %optval38, i64* %y.f, align 8 - br label %after_assign44 - -after_check41: ; preds = %cond.lhs37 - %15 = load i8*, i8** %x, align 8 - br label %cond.phi43 - -cond.rhs42: ; preds = %voiderr35 - store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %y.f, align 8 - br label %after_assign44 - -cond.phi43: ; preds = %after_check41 - store i8* %15, i8** %y, align 8 - store i64 0, i64* %y.f, align 8 - br label %after_assign44 - -after_assign44: ; preds = %cond.phi43, %cond.rhs42, %assign_optional40 - br label %voiderr45 - -voiderr45: ; preds = %after_assign44 - %16 = load i8*, i8** %a, align 8 - %not46 = icmp eq i8* %16, null - br i1 %not46, label %cond.lhs47, label %cond.rhs48 - -cond.lhs47: ; preds = %voiderr45 - store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %y.f, align 8 - br label %after_assign54 - -cond.rhs48: ; preds = %voiderr45 - %optval49 = load i64, i64* %x.f, align 8 - %not_err50 = icmp eq i64 %optval49, 0 - br i1 %not_err50, label %after_check52, label %assign_optional51 - -assign_optional51: ; preds = %cond.rhs48 - store i64 %optval49, i64* %y.f, align 8 - br label %after_assign54 - -after_check52: ; preds = %cond.rhs48 - %17 = load i8*, i8** %x, align 8 - br label %cond.phi53 - -cond.phi53: ; preds = %after_check52 - store i8* %17, i8** %y, align 8 - store i64 0, i64* %y.f, align 8 - br label %after_assign54 - -after_assign54: ; preds = %cond.phi53, %assign_optional51, %cond.lhs47 - br label %voiderr55 - -voiderr55: ; preds = %after_assign54 - %18 = load i8*, i8** %a, align 8 - %not56 = icmp eq i8* %18, null - br i1 %not56, label %cond.lhs57, label %cond.rhs58 - -cond.lhs57: ; preds = %voiderr55 - store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %y.f, align 8 - br label %after_assign60 - -cond.rhs58: ; preds = %voiderr55 - store i64 ptrtoint (%.fault* @"test_Test$BAR" to i64), i64* %y.f, align 8 - br label %after_assign60 - -after_assign60: ; preds = %cond.rhs58, %cond.lhs57 - br label %voiderr61 - -voiderr61: ; preds = %after_assign60 - ret void diff --git a/test/test_suite14/expressions/check_implict_conversion_signed_unsigned.c3t b/test/test_suite14/expressions/check_implict_conversion_signed_unsigned.c3t deleted file mode 100644 index 743750b98..000000000 --- a/test/test_suite14/expressions/check_implict_conversion_signed_unsigned.c3t +++ /dev/null @@ -1,23 +0,0 @@ -module check; - -fn int main() -{ - int a = 0; - ulong b = 3; - b - a; - return 1; -} - -// #expect: check.ll - -entry: - %a = alloca i32, align 4 - %b = alloca i64, align 8 - store i32 0, i32* %a, align 4 - store i64 3, i64* %b, align 8 - %0 = load i64, i64* %b, align 8 - %1 = load i32, i32* %a, align 4 - %sisiext = sext i32 %1 to i64 - %sub = sub i64 %0, %sisiext - ret i32 1 -} \ No newline at end of file diff --git a/test/test_suite14/expressions/elvis.c3t b/test/test_suite14/expressions/elvis.c3t deleted file mode 100644 index f5c2b52ce..000000000 --- a/test/test_suite14/expressions/elvis.c3t +++ /dev/null @@ -1,69 +0,0 @@ -fn int* elvis(int *x, int *y) -{ - return x ?: y; -} - - -fn int* elvis2(int *x, int *y) -{ - return x ?: (y ?: x); -} - -fn bool elvis3(bool x, bool y) -{ - return x ?: y; -} - - -// #expect: elvis.ll - -define i32* @elvis_elvis(i32* %0, i32* %1) #0 { -entry: - %ptrbool = icmp ne i32* %0, null - br i1 %ptrbool, label %cond.phi, label %cond.rhs - -cond.rhs: ; preds = %entry - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %entry - %val = phi i32* [ %0, %entry ], [ %1, %cond.rhs ] - ret i32* %val -} - -define i32* @elvis_elvis2(i32* %0, i32* %1) #0 { -entry: - %ptrbool = icmp ne i32* %0, null - br i1 %ptrbool, label %cond.phi3, label %cond.rhs - -cond.rhs: ; preds = %entry - %ptrbool1 = icmp ne i32* %1, null - br i1 %ptrbool1, label %cond.phi, label %cond.rhs2 - -cond.rhs2: ; preds = %cond.rhs - br label %cond.phi - -cond.phi: ; preds = %cond.rhs2, %cond.rhs - %val = phi i32* [ %1, %cond.rhs ], [ %0, %cond.rhs2 ] - br label %cond.phi3 - -cond.phi3: ; preds = %cond.phi, %entry - %val4 = phi i32* [ %0, %entry ], [ %val, %cond.phi ] - ret i32* %val4 -} - -define zeroext i8 @elvis_elvis3(i8 zeroext %0, i8 zeroext %1) #0 { -entry: - %2 = trunc i8 %0 to i1 - br i1 %2, label %cond.phi, label %cond.rhs - -cond.rhs: ; preds = %entry - %3 = trunc i8 %1 to i1 - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %entry - %val = phi i1 [ %2, %entry ], [ %3, %cond.rhs ] - %4 = zext i1 %val to i8 - ret i8 %4 -} - -attributes #0 = { nounwind } \ No newline at end of file diff --git a/test/test_suite14/expressions/fail_index_usize.c3 b/test/test_suite14/expressions/fail_index_usize.c3 deleted file mode 100644 index 80e6f0c40..000000000 --- a/test/test_suite14/expressions/fail_index_usize.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test(int* array, usz n) -{ - array[n] = 33; - n[array] = 33; // #error: Cannot index -} diff --git a/test/test_suite14/expressions/fmuladd.c3t b/test/test_suite14/expressions/fmuladd.c3t deleted file mode 100644 index 959ff8402..000000000 --- a/test/test_suite14/expressions/fmuladd.c3t +++ /dev/null @@ -1,56 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; - -fn float tester1(float a, float b, float c) -{ - return a * b + c; -} -fn float tester2(float a, float b, float c) -{ - return c + a * b; -} -fn float tester3(float a, float b, float c) -{ - c = -c; - return a * b - c; -} -fn float tester4(float a, float b, float c) -{ - c = -c; - return -c + a * b; -} - -fn float tester5(float a, float b, float c) -{ - c = -c; - return -(c - a * b); -} -fn float tester6(float a, float b, float c) -{ - c = -c; - return -(-a * b + c); -} - -fn void main() -{ - float a = 3.1; - float b = 1.4; - float c = 0.1; - io::printfn("%f", tester1(a, b, c)); - io::printfn("%f", tester2(a, b, c)); - io::printfn("%f", tester3(a, b, c)); - io::printfn("%f", tester4(a, b, c)); - io::printfn("%f", tester5(a, b, c)); - io::printfn("%f", tester6(a, b, c)); -} - -/* #expect: test.ll - - %3 = call float @llvm.fmuladd.f32(float %0, float %1, float %2) - %3 = call float @llvm.fmuladd.f32(float %0, float %1, float %2) - %6 = call float @llvm.fmuladd.f32(float %0, float %1, float %5) - %5 = call float @llvm.fmuladd.f32(float %0, float %1, float %fneg1) - %6 = call float @llvm.fmuladd.f32(float %0, float %1, float %5) - %5 = call float @llvm.fmuladd.f32(float %fneg1, float %1, float %4) diff --git a/test/test_suite14/expressions/fmuladd_err.c3t b/test/test_suite14/expressions/fmuladd_err.c3t deleted file mode 100644 index b98a89097..000000000 --- a/test/test_suite14/expressions/fmuladd_err.c3t +++ /dev/null @@ -1,75 +0,0 @@ -// #target: macos-x64 - -module test; - -fn float easeElasticIn(float t, float b, float c, float d) @inline // Ease: Elastic In -{ - if (t == 0.0f) return b; - if ((t/=d) == 1.0f) return (b + c); - - float p = d*0.3f; - float a = c; - float s = p/4.0f; - float postFix = a*$$pow(2.0f, 10.0f*(t-=1.0f)); - - return (-(postFix*$$sin((t*d-s)*(2.0f*3.14f)/p )) + b); -} - -/* #expect: test.ll - - -define float @test_easeElasticIn(float %0, float %1, float %2, float %3) #0 { -entry: - %t = alloca float, align 4 - %p = alloca float, align 4 - %a = alloca float, align 4 - %s = alloca float, align 4 - %postFix = alloca float, align 4 - store float %0, float* %t, align 4 - %4 = load float, float* %t, align 4 - %eq = fcmp oeq float %4, 0.000000e+00 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret float %1 - -if.exit: ; preds = %entry - %5 = load float, float* %t, align 4 - %fdiv = fdiv float %5, %3 - store float %fdiv, float* %t, align 4 - %eq1 = fcmp oeq float %fdiv, 1.000000e+00 - br i1 %eq1, label %if.then2, label %if.exit3 - -if.then2: ; preds = %if.exit - %fadd = fadd float %1, %2 - ret float %fadd - -if.exit3: ; preds = %if.exit - %fmul = fmul float %3, 0x3FD3333340000000 - store float %fmul, float* %p, align 4 - store float %2, float* %a, align 4 - %6 = load float, float* %p, align 4 - %fdiv4 = fdiv float %6, 4.000000e+00 - store float %fdiv4, float* %s, align 4 - %7 = load float, float* %a, align 4 - %8 = load float, float* %t, align 4 - %fsub = fsub float %8, 1.000000e+00 - store float %fsub, float* %t, align 4 - %fmul5 = fmul float 1.000000e+01, %fsub - %9 = call float @llvm.pow.f32(float 2.000000e+00, float %fmul5) - %fmul6 = fmul float %7, %9 - store float %fmul6, float* %postFix, align 4 - %10 = load float, float* %postFix, align 4 - %11 = load float, float* %t, align 4 - %12 = load float, float* %s, align 4 - %13 = fneg float %12 - %14 = call float @llvm.fmuladd.f32(float %11, float %3, float %13) - %fmul7 = fmul float %14, 0x40191EB860000000 - %15 = load float, float* %p, align 4 - %fdiv8 = fdiv float %fmul7, %15 - %16 = call float @llvm.sin.f32(float %fdiv8) - %17 = fneg float %1 - %18 = call float @llvm.fmuladd.f32(float %10, float %16, float %17) - %19 = fneg float %18 - ret float %19 -} diff --git a/test/test_suite14/expressions/folding_ptr.c3t b/test/test_suite14/expressions/folding_ptr.c3t deleted file mode 100644 index 2e2915a35..000000000 --- a/test/test_suite14/expressions/folding_ptr.c3t +++ /dev/null @@ -1,34 +0,0 @@ -// #target: macos-x64 -module test; -struct Test -{ - int x; -} - -extern Test *cfun; - -fn int f() -{ - if (!(cfun + 0)) return 0; - return cfun.x; -} - - -/* #expect: test.ll - -define i32 @test_f() #0 { -entry: - %0 = load %Test*, %Test** @cfun, align 8 - %ptroffset = getelementptr %Test, %Test* %0, i64 0 - %not = icmp eq %Test* %ptroffset, null - br i1 %not, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i32 0 - -if.exit: ; preds = %entry - %1 = load %Test*, %Test** @cfun, align 8 - %2 = getelementptr inbounds %Test, %Test* %1, i32 0, i32 0 - %3 = load i32, i32* %2, align 4 - ret i32 %3 -} diff --git a/test/test_suite14/expressions/incdec.c3t b/test/test_suite14/expressions/incdec.c3t deleted file mode 100644 index 39d42d8ed..000000000 --- a/test/test_suite14/expressions/incdec.c3t +++ /dev/null @@ -1,42 +0,0 @@ -fn void test(int* foo) -{ - foo++; - foo--; - int y = 10; - y++; - y--; - float z = 2.0; - z++; - ++z; - z--; -} - -// #expect: incdec.ll - - %foo = alloca i32*, align 8 - %y = alloca i32, align 4 - %z = alloca float, align 4 - store i32* %0, i32** %foo - %1 = load i32*, i32** %foo, align 8 - %ptroffset = getelementptr i32, i32* %1, i8 1 - store i32* %ptroffset, i32** %foo, align 8 - %2 = load i32*, i32** %foo, align 8 - %ptroffset1 = getelementptr i32, i32* %2, i8 -1 - store i32* %ptroffset1, i32** %foo, align 8 - store i32 10, i32* %y, align 4 - %3 = load i32, i32* %y, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %y, align 4 - %4 = load i32, i32* %y, align 4 - %sub = sub i32 %4, 1 - store i32 %sub, i32* %y, align 4 - store float 2.000000e+00, float* %z, align 4 - %5 = load float, float* %z, align 4 - %fincdec = fadd float %5, 1.000000e+00 - store float %fincdec, float* %z, align 4 - %6 = load float, float* %z, align 4 - %fincdec2 = fadd float %6, 1.000000e+00 - store float %fincdec2, float* %z, align 4 - %7 = load float, float* %z, align 4 - %fincdec3 = fadd float %7, -1.000000e+00 - store float %fincdec3, float* %z, align 4 \ No newline at end of file diff --git a/test/test_suite14/expressions/negate_int.c3 b/test/test_suite14/expressions/negate_int.c3 deleted file mode 100644 index da6a0702a..000000000 --- a/test/test_suite14/expressions/negate_int.c3 +++ /dev/null @@ -1,41 +0,0 @@ -fn void test1() -{ - short! a = 1; - try(-a); - short b = -a; // #error: 'int!' to 'short'. -} - -fn void test2() -{ - int! a = 1; - try(-a); - int b = -a; // #error: 'int!' to 'int' -} - -fn void test3() -{ - long! a = 1; - try(-a); - long b = -a; // #error: 'long!' to 'long' -} - -fn void test4() -{ - short! a = 1; - try(~a); - short b = ~a; // #error: 'short!' to 'short' -} - -fn void test5() -{ - int! a = 1; - try(~a); - int b = ~a; // #error: 'int!' to 'int' -} - -fn void test6() -{ - long! a = 1; - try(~a); - long b = ~a; // #error: 'long!' to 'long' -} diff --git a/test/test_suite14/expressions/no_valid_conversion_minus.c3 b/test/test_suite14/expressions/no_valid_conversion_minus.c3 deleted file mode 100644 index 68ad6a1c1..000000000 --- a/test/test_suite14/expressions/no_valid_conversion_minus.c3 +++ /dev/null @@ -1,10 +0,0 @@ -struct Foo -{ int j; } - -fn int main() -{ - int a = 0; - Foo f; - f - a; // #error: The subtraction 'Foo' - 'int' is not possible - return 1; -} \ No newline at end of file diff --git a/test/test_suite14/expressions/optional_ternary.c3t b/test/test_suite14/expressions/optional_ternary.c3t deleted file mode 100644 index 958d3e9d8..000000000 --- a/test/test_suite14/expressions/optional_ternary.c3t +++ /dev/null @@ -1,387 +0,0 @@ -// #target: macos-x64 - -module test; - -fault Foo -{ - X -} - -fn int! test(int i) -{ - return i ?: Foo.X!; -} - -fn int! test2(int i) -{ - return i ? Foo.X! : Foo.X!; -} - - -fn int! test3(int i) -{ - return i ? 2 : Foo.X!; -} - - -fn int! test4(int i) -{ - int! y = i; - return (y?) ?: Foo.X!; -} -fn int! test5(int i) -{ - int! y = i; - return (y?) ? Foo.X! : Foo.X!; -} - -fn int! test6(int i) -{ - int! y = i; - return (y?) ? 2 : Foo.X!; -} - -fn int! test7(int i) -{ - int! y = i; - return (y?) ? Foo.X! : 2; -} - -fn void main() -{ - test(1)!!; - test7(0)!!; - test6(1)!!; - int! i = test2(3); -} - -/* #expect: test.ll - - -define i64 @test_test(i32* %0, i32 %1) #0 { -entry: - %reterr = alloca i64, align 8 - %intbool = icmp ne i32 %1, 0 - br i1 %intbool, label %cond.phi, label %cond.rhs - -cond.rhs: ; preds = %entry - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.phi: ; preds = %entry - store i32 %1, i32* %0, align 4 - ret i64 0 - -err_retblock: ; preds = %cond.rhs - %2 = load i64, i64* %reterr, align 8 - ret i64 %2 -} - -; Function Attrs: nounwind -define i64 @test_test2(i32* %0, i32 %1) #0 { -entry: - %reterr = alloca i64, align 8 - %intbool = icmp ne i32 %1, 0 - br i1 %intbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.rhs: ; preds = %entry - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.phi: ; No predecessors! - store i32 undef, i32* %0, align 4 - ret i64 0 - -err_retblock: ; preds = %cond.rhs, %cond.lhs - %2 = load i64, i64* %reterr, align 8 - ret i64 %2 -} - -; Function Attrs: nounwind -define i64 @test_test3(i32* %0, i32 %1) #0 { -entry: - %reterr = alloca i64, align 8 - %intbool = icmp ne i32 %1, 0 - br i1 %intbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - br label %cond.phi - -cond.rhs: ; preds = %entry - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.phi: ; preds = %cond.lhs - store i32 2, i32* %0, align 4 - ret i64 0 - -err_retblock: ; preds = %cond.rhs - %2 = load i64, i64* %reterr, align 8 - ret i64 %2 -} - -; Function Attrs: nounwind -define i64 @test_test4(i32* %0, i32 %1) #0 { -entry: - %y = alloca i32, align 4 - %y.f = alloca i64, align 8 - %reterr = alloca i64, align 8 - %error_var = alloca i64, align 8 - store i32 %1, i32* %y, align 4 - store i64 0, i64* %y.f, align 8 - %optval = load i64, i64* %y.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %2 = load i64, i64* %error_var, align 8 - ret i64 %2 - -noerr_block: ; preds = %after_check - %3 = load i32, i32* %y, align 4 - %intbool = icmp ne i32 %3, 0 - br i1 %intbool, label %cond.phi, label %cond.rhs - -cond.rhs: ; preds = %noerr_block - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.phi: ; preds = %noerr_block - store i32 %3, i32* %0, align 4 - ret i64 0 - -err_retblock: ; preds = %cond.rhs - %4 = load i64, i64* %reterr, align 8 - ret i64 %4 -} - -; Function Attrs: nounwind -define i64 @test_test5(i32* %0, i32 %1) #0 { -entry: - %y = alloca i32, align 4 - %y.f = alloca i64, align 8 - %reterr = alloca i64, align 8 - %error_var = alloca i64, align 8 - store i32 %1, i32* %y, align 4 - store i64 0, i64* %y.f, align 8 - %optval = load i64, i64* %y.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %2 = load i64, i64* %error_var, align 8 - ret i64 %2 - -noerr_block: ; preds = %after_check - %3 = load i32, i32* %y, align 4 - %intbool = icmp ne i32 %3, 0 - br i1 %intbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %noerr_block - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.rhs: ; preds = %noerr_block - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.phi: ; No predecessors! - store i32 undef, i32* %0, align 4 - ret i64 0 - -err_retblock: ; preds = %cond.rhs, %cond.lhs - %4 = load i64, i64* %reterr, align 8 - ret i64 %4 -} - -; Function Attrs: nounwind -define i64 @test_test6(i32* %0, i32 %1) #0 { -entry: - %y = alloca i32, align 4 - %y.f = alloca i64, align 8 - %reterr = alloca i64, align 8 - %error_var = alloca i64, align 8 - store i32 %1, i32* %y, align 4 - store i64 0, i64* %y.f, align 8 - %optval = load i64, i64* %y.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %2 = load i64, i64* %error_var, align 8 - ret i64 %2 - -noerr_block: ; preds = %after_check - %3 = load i32, i32* %y, align 4 - %intbool = icmp ne i32 %3, 0 - br i1 %intbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %noerr_block - br label %cond.phi - -cond.rhs: ; preds = %noerr_block - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.phi: ; preds = %cond.lhs - store i32 2, i32* %0, align 4 - ret i64 0 - -err_retblock: ; preds = %cond.rhs - %4 = load i64, i64* %reterr, align 8 - ret i64 %4 -} - -; Function Attrs: nounwind -define i64 @test_test7(i32* %0, i32 %1) #0 { -entry: - %y = alloca i32, align 4 - %y.f = alloca i64, align 8 - %reterr = alloca i64, align 8 - %error_var = alloca i64, align 8 - store i32 %1, i32* %y, align 4 - store i64 0, i64* %y.f, align 8 - %optval = load i64, i64* %y.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %optval, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %2 = load i64, i64* %error_var, align 8 - ret i64 %2 - -noerr_block: ; preds = %after_check - %3 = load i32, i32* %y, align 4 - %intbool = icmp ne i32 %3, 0 - br i1 %intbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %noerr_block - store i64 ptrtoint (%.fault* @"test_Foo$X" to i64), i64* %reterr, align 8 - br label %err_retblock - -cond.rhs: ; preds = %noerr_block - br label %cond.phi - -cond.phi: ; preds = %cond.rhs - store i32 2, i32* %0, align 4 - ret i64 0 - -err_retblock: ; preds = %cond.lhs - %4 = load i64, i64* %reterr, align 8 - ret i64 %4 -} - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %error_var = alloca i64, align 8 - %retparam = alloca i32, align 4 - %error_var1 = alloca i64, align 8 - %retparam2 = alloca i32, align 4 - %error_var8 = alloca i64, align 8 - %retparam9 = alloca i32, align 4 - %i = alloca i32, align 4 - %i.f = alloca i64, align 8 - %retparam15 = alloca i32, align 4 - %0 = call i64 @test_test(i32* %retparam, i32 1) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %0, i64* %error_var, align 8 - br label %panic_block - -after_check: ; preds = %entry - %1 = load i32, i32* %retparam, align 4 - br label %noerr_block - -panic_block: ; preds = %assign_optional - %2 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %2(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.panic_msg, i64 0, i64 0), i64 27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.file, i64 0, i64 0), i64 19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.func, i64 0, i64 0), i64 4, i32 51) - unreachable - -noerr_block: ; preds = %after_check - %3 = call i64 @test_test7(i32* %retparam2, i32 0) - %not_err3 = icmp eq i64 %3, 0 - br i1 %not_err3, label %after_check5, label %assign_optional4 - -assign_optional4: ; preds = %noerr_block - store i64 %3, i64* %error_var1, align 8 - br label %panic_block6 - -after_check5: ; preds = %noerr_block - %4 = load i32, i32* %retparam2, align 4 - br label %noerr_block7 - -panic_block6: ; preds = %assign_optional4 - %5 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %5(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.panic_msg.1, i64 0, i64 0), i64 27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.file.2, i64 0, i64 0), i64 19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.func.3, i64 0, i64 0), i64 4, i32 52) - unreachable - -noerr_block7: ; preds = %after_check5 - %6 = call i64 @test_test6(i32* %retparam9, i32 1) - %not_err10 = icmp eq i64 %6, 0 - br i1 %not_err10, label %after_check12, label %assign_optional11 - -assign_optional11: ; preds = %noerr_block7 - store i64 %6, i64* %error_var8, align 8 - br label %panic_block13 - -after_check12: ; preds = %noerr_block7 - %7 = load i32, i32* %retparam9, align 4 - br label %noerr_block14 - -panic_block13: ; preds = %assign_optional11 - %8 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %8(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.panic_msg.4, i64 0, i64 0), i64 27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.file.5, i64 0, i64 0), i64 19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.func.6, i64 0, i64 0), i64 4, i32 53) - unreachable - -noerr_block14: ; preds = %after_check12 - %9 = call i64 @test_test2(i32* %retparam15, i32 3) - %not_err16 = icmp eq i64 %9, 0 - br i1 %not_err16, label %after_check18, label %assign_optional17 - -assign_optional17: ; preds = %noerr_block14 - store i64 %9, i64* %i.f, align 8 - br label %after_assign - -after_check18: ; preds = %noerr_block14 - %10 = load i32, i32* %retparam15, align 4 - store i32 %10, i32* %i, align 4 - store i64 0, i64* %i.f, align 8 - br label %after_assign - -after_assign: ; preds = %after_check18, %assign_optional17 - ret void -} diff --git a/test/test_suite14/expressions/parsed_numbers.c3t b/test/test_suite14/expressions/parsed_numbers.c3t deleted file mode 100644 index cb4e46d16..000000000 --- a/test/test_suite14/expressions/parsed_numbers.c3t +++ /dev/null @@ -1,13 +0,0 @@ -module numbers; - -double a = 0x1.1p+1; -double b = -12.3e-12; -double c = 0x1.1p-1; -double d = 12.3e+12; - -// #expect: numbers.ll - -@numbers_a = local_unnamed_addr global double 2.125000e+00, align 8 -@numbers_b = local_unnamed_addr global double -1.230000e-11, align 8 -@numbers_c = local_unnamed_addr global double 5.312500e-01, align 8 -@numbers_d = local_unnamed_addr global double 1.230000e+13, align 8 \ No newline at end of file diff --git a/test/test_suite14/expressions/pointer_access.c3t b/test/test_suite14/expressions/pointer_access.c3t deleted file mode 100644 index 77cf39af5..000000000 --- a/test/test_suite14/expressions/pointer_access.c3t +++ /dev/null @@ -1,106 +0,0 @@ -// #target: macos-x64 -extern fn void printf(char* c, ...); - -struct ExtraSimple -{ - int a; - int b; - struct c - { - double e; - double f0; - double f1; - double f; - double j; - } - struct - { - int r; - int s; - } - union - { - double o0; - int o1; - } - int g; -} - - -fn void testSimple() -{ - ExtraSimple a = { .c.j = 3.3 }; - a.c.j = 3.4; - printf("a = %d, c.e = %f, c.f = %f, c.j = %f, g = %d, o0 = %f, r = %d, s = %d\n", a.a, a.c.e, a.c.f, a.c.j, a.g, a.o0, a.r, a.s); -} - -// TODO these may be wrong. -/* #expect: pointer_access.ll - -%ExtraSimple = type { i32, i32, %c, %.anon, %.anon.0, i32 } -%c = type { double, double, double, double, double } -%.anon = type { i32, i32 } -%.anon.0 = type { double } - -@"ct$pointer_access_c" = linkonce constant %.introspect { i8 10, i64 40, i64 0, i64 5, [0 x i64] zeroinitializer }, align 8 -@"ct$pointer_access_$anon" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"ct$pointer_access_$anon.4" = linkonce constant %.introspect { i8 11, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"ct$pointer_access_ExtraSimple" = linkonce constant %.introspect { i8 10, i64 72, i64 0, i64 6, [0 x i64] zeroinitializer }, align 8 -@.str = private unnamed_addr constant [71 x i8] c"a = %d, c.e = %f, c.f = %f, c.j = %f, g = %d, o0 = %f, r = %d, s = %d\0A\00", align 1 - -define void @pointer_access_testSimple() #0 { -entry: - %a = alloca %ExtraSimple, align 8 - %0 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 0 - store i32 0, i32* %0, align 8 - %1 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 1 - store i32 0, i32* %1, align 4 - %2 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 2 - %3 = getelementptr inbounds %c, %c* %2, i32 0, i32 0 - store double 0.000000e+00, double* %3, align 8 - %4 = getelementptr inbounds %c, %c* %2, i32 0, i32 1 - store double 0.000000e+00, double* %4, align 8 - %5 = getelementptr inbounds %c, %c* %2, i32 0, i32 2 - store double 0.000000e+00, double* %5, align 8 - %6 = getelementptr inbounds %c, %c* %2, i32 0, i32 3 - store double 0.000000e+00, double* %6, align 8 - %7 = getelementptr inbounds %c, %c* %2, i32 0, i32 4 - store double 3.300000e+00, double* %7, align 8 - %8 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 3 - %9 = getelementptr inbounds %.anon, %.anon* %8, i32 0, i32 0 - store i32 0, i32* %9, align 8 - %10 = getelementptr inbounds %.anon, %.anon* %8, i32 0, i32 1 - store i32 0, i32* %10, align 4 - %11 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 4 - %12 = bitcast %.anon.0* %11 to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %12, i8 0, i64 8, i1 false) - %13 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 5 - store i32 0, i32* %13, align 8 - %14 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 2 - %15 = getelementptr inbounds %c, %c* %14, i32 0, i32 4 - store double 3.400000e+00, double* %15, align 8 - %16 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 0 - %17 = load i32, i32* %16, align 8 - %18 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 2 - %19 = getelementptr inbounds %c, %c* %18, i32 0, i32 0 - %20 = load double, double* %19, align 8 - %21 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 2 - %22 = getelementptr inbounds %c, %c* %21, i32 0, i32 3 - %23 = load double, double* %22, align 8 - %24 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 2 - %25 = getelementptr inbounds %c, %c* %24, i32 0, i32 4 - %26 = load double, double* %25, align 8 - %27 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 5 - %28 = load i32, i32* %27, align 8 - %29 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 4 - %30 = bitcast %.anon.0* %29 to double* - %31 = load double, double* %30, align 8 - %32 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 3 - %33 = getelementptr inbounds %.anon, %.anon* %32, i32 0, i32 0 - %34 = load i32, i32* %33, align 8 - %35 = getelementptr inbounds %ExtraSimple, %ExtraSimple* %a, i32 0, i32 3 - %36 = getelementptr inbounds %.anon, %.anon* %35, i32 0, i32 1 - %37 = load i32, i32* %36, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i32 0, i32 0), i32 %17, double %20, double %23, double %26, i32 %28, double %31, i32 %34, i32 %37) - ret void -} diff --git a/test/test_suite14/expressions/pointer_arith.c3 b/test/test_suite14/expressions/pointer_arith.c3 deleted file mode 100644 index 2338aa493..000000000 --- a/test/test_suite14/expressions/pointer_arith.c3 +++ /dev/null @@ -1,18 +0,0 @@ -fn void test1(ichar* cp) -{ - int a = 10; - - ichar* cp2 = cp - 10; - ichar* cp3 = cp + 10; - cp2 -= 10; - cp2 -= a; - cp3 += 10; - cp3 += a; - ichar* cp4 = cp - a; - cp2 - cp3; -} -fn void test2(ichar* cp) -{ - cp + 1; - cp * 1.0; // #error: 'ichar*' by 'double' -} \ No newline at end of file diff --git a/test/test_suite14/expressions/pointer_conv_error.c3 b/test/test_suite14/expressions/pointer_conv_error.c3 deleted file mode 100644 index 94ad43d44..000000000 --- a/test/test_suite14/expressions/pointer_conv_error.c3 +++ /dev/null @@ -1,18 +0,0 @@ -fn void test1() -{ - int myInt = 1; - int* p1 = myInt; // #error: 'int*' -} - -fn void test2() -{ - uint myUInt = 1; - int* p2 = myUInt; // #error: 'int*' -} - -fn void test3() -{ - uint myUInt = 1; - int* p2 = (int*)(myUInt); // #error: iptr -} - diff --git a/test/test_suite14/expressions/pointer_to_bool.c3 b/test/test_suite14/expressions/pointer_to_bool.c3 deleted file mode 100644 index fcdf1292d..000000000 --- a/test/test_suite14/expressions/pointer_to_bool.c3 +++ /dev/null @@ -1,9 +0,0 @@ -struct Struct -{ - char* ptr; -} - -fn void test1(Struct* s) -{ - if (s.ptr) {} -} \ No newline at end of file diff --git a/test/test_suite14/expressions/rvalues.c3 b/test/test_suite14/expressions/rvalues.c3 deleted file mode 100644 index fd4d9c237..000000000 --- a/test/test_suite14/expressions/rvalues.c3 +++ /dev/null @@ -1,16 +0,0 @@ -macro void hello($bar) -{ - $bar; -} -const FOO = 1 + 2; -fn void test() -{ - var $Foo = int; - var $Bar = $Foo; - $Bar x; - hello(1); - var $foo = 1; - $foo; - FOO; -} - diff --git a/test/test_suite14/expressions/simple_float_sub_neg.c3t b/test/test_suite14/expressions/simple_float_sub_neg.c3t deleted file mode 100644 index 73d01cbd0..000000000 --- a/test/test_suite14/expressions/simple_float_sub_neg.c3t +++ /dev/null @@ -1,17 +0,0 @@ -module simple_float_sub_neg; - -fn double test(double a, double b, double c, double d) -{ - return -(a-b) - (c-d); -} - -// #expect: simple_float_sub_neg.ll - -define double @simple_float_sub_neg_test(double %0, double %1, double %2, double %3) #0 { -entry: - %fsub = fsub double %0, %1 - %fneg = fneg double %fsub - %fsub1 = fsub double %2, %3 - %fsub2 = fsub double %fneg, %fsub1 - ret double %fsub2 -} diff --git a/test/test_suite14/expressions/strings.c3t b/test/test_suite14/expressions/strings.c3t deleted file mode 100644 index e73306b83..000000000 --- a/test/test_suite14/expressions/strings.c3t +++ /dev/null @@ -1,10 +0,0 @@ -module test; - -fn char* foo() -{ - return "*** Word \"%s\" on line %d is not"; -} - -// #expect: test.ll - -@.str = private unnamed_addr constant [32 x i8] c"*** Word \22%s\22 on line %d is not\00" \ No newline at end of file diff --git a/test/test_suite14/expressions/ternary_bool.c3t b/test/test_suite14/expressions/ternary_bool.c3t deleted file mode 100644 index 4b31bd5dd..000000000 --- a/test/test_suite14/expressions/ternary_bool.c3t +++ /dev/null @@ -1,112 +0,0 @@ -// #target: macos-x64 - -extern fn void printf(char *, ...); - -fn void main() -{ - - bool b = true; - bool* c = &b; - if (*c ? *c : *c) printf("Woa!\n"); - if (b ? b : b) printf("Woa!\n"); - if (*c ?: *c) printf("Woa!\n"); - if (b ?: b) printf("Woa!\n"); -} - -/* #expect: ternary_bool.ll - -define void @ternary_bool_main() #0 { -entry: - %b = alloca i8, align 1 - %c = alloca i8*, align 8 - store i8 1, i8* %b, align 1 - store i8* %b, i8** %c, align 8 - %0 = load i8*, i8** %c, align 8 - %1 = load i8, i8* %0, align 1 - %2 = trunc i8 %1 to i1 - br i1 %2, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - %3 = load i8*, i8** %c, align 8 - %4 = load i8, i8* %3, align 1 - %5 = trunc i8 %4 to i1 - br label %cond.phi - -cond.rhs: ; preds = %entry - %6 = load i8*, i8** %c, align 8 - %7 = load i8, i8* %6, align 1 - %8 = trunc i8 %7 to i1 - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %cond.lhs - %val = phi i1 [ %5, %cond.lhs ], [ %8, %cond.rhs ] - br i1 %val, label %if.then, label %if.exit - -if.then: ; preds = %cond.phi - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0)) - br label %if.exit - -if.exit: ; preds = %if.then, %cond.phi - %9 = load i8, i8* %b, align 1 - %10 = trunc i8 %9 to i1 - br i1 %10, label %cond.lhs1, label %cond.rhs2 - -cond.lhs1: ; preds = %if.exit - %11 = load i8, i8* %b, align 1 - %12 = trunc i8 %11 to i1 - br label %cond.phi3 - -cond.rhs2: ; preds = %if.exit - %13 = load i8, i8* %b, align 1 - %14 = trunc i8 %13 to i1 - br label %cond.phi3 - -cond.phi3: ; preds = %cond.rhs2, %cond.lhs1 - %val4 = phi i1 [ %12, %cond.lhs1 ], [ %14, %cond.rhs2 ] - br i1 %val4, label %if.then5, label %if.exit6 - -if.then5: ; preds = %cond.phi3 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0)) - br label %if.exit6 - -if.exit6: ; preds = %if.then5, %cond.phi3 - %15 = load i8*, i8** %c, align 8 - %16 = load i8, i8* %15, align 1 - %17 = trunc i8 %16 to i1 - br i1 %17, label %cond.phi8, label %cond.rhs7 - -cond.rhs7: ; preds = %if.exit6 - %18 = load i8*, i8** %c, align 8 - %19 = load i8, i8* %18, align 1 - %20 = trunc i8 %19 to i1 - br label %cond.phi8 - -cond.phi8: ; preds = %cond.rhs7, %if.exit6 - %val9 = phi i1 [ %17, %if.exit6 ], [ %20, %cond.rhs7 ] - br i1 %val9, label %if.then10, label %if.exit11 - -if.then10: ; preds = %cond.phi8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0)) - br label %if.exit11 - -if.exit11: ; preds = %if.then10, %cond.phi8 - %21 = load i8, i8* %b, align 1 - %22 = trunc i8 %21 to i1 - br i1 %22, label %cond.phi13, label %cond.rhs12 - -cond.rhs12: ; preds = %if.exit11 - %23 = load i8, i8* %b, align 1 - %24 = trunc i8 %23 to i1 - br label %cond.phi13 - -cond.phi13: ; preds = %cond.rhs12, %if.exit11 - %val14 = phi i1 [ %22, %if.exit11 ], [ %24, %cond.rhs12 ] - br i1 %val14, label %if.then15, label %if.exit16 - -if.then15: ; preds = %cond.phi13 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0)) - br label %if.exit16 - -if.exit16: ; preds = %if.then15, %cond.phi13 - ret void -} diff --git a/test/test_suite14/expressions/ternary_no_ident.c3 b/test/test_suite14/expressions/ternary_no_ident.c3 deleted file mode 100644 index dbd2e7457..000000000 --- a/test/test_suite14/expressions/ternary_no_ident.c3 +++ /dev/null @@ -1,14 +0,0 @@ -fn void test1() -{ - int a = (i ? 1 : 1); // #error: 'i' could not be found, did you spell it right -} - -fn void test2() -{ - int a = (1 ? i : 2); // #error: 'i' could not be found, did you spell it right -} - -fn void test3() -{ - int a = (1 ? 2 : i); // #error: 'i' could not be found, did you spell it right -} diff --git a/test/test_suite14/expressions/type_support.c3t b/test/test_suite14/expressions/type_support.c3t deleted file mode 100644 index a472c459a..000000000 --- a/test/test_suite14/expressions/type_support.c3t +++ /dev/null @@ -1,77 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; - -macro print_type_info(...) -{ - $for (var $i = 0; $i < $vacount; $i++): - io::printfn("type: %s", $vatype($i).nameof); - io::printfn("%s.sizeof = %d", $vatype($i).nameof, $vatype($i).sizeof); - io::printfn("%s.min = %s", $vatype($i).nameof, $vatype($i).min); - io::printfn("%s.max = %s\n", $vatype($i).nameof, $vatype($i).max); - $endfor; -} - -fn void main() -{ - io::printfn("Unsigned integers:"); - print_type_info(char, ushort, uint, ulong, uptr, usz, usz); - io::printfn("Signed integers:"); - print_type_info(ichar, short, int, long, iptr, isz, isz); - io::printfn("Floats:"); - print_type_info(float, double); -} - -/* #expect: test.ll - - -i64 0 -i64 1 -i8 0 -i8 -1 -i16 0 -i16 -1 -i64 4 -i64 2 -i32 0 -i32 -1 -i64 8 -i64 0 -i64 -1 -i64 8 -i64 0 -i64 -1 -i64 8 -i64 0 -i64 -1 -i64 8 -i64 0 -i64 -1 -i64 1 -i8 -128 -i8 127 -i64 2 -i16 -32768 -i16 32767 -i64 4 -i32 -2147483648 -i32 2147483647 -i64 8 -i64 -9223372036854775808 -i64 9223372036854775807 -i64 8 -i64 -9223372036854775808 -i64 9223372036854775807 -i64 8 -i64 -9223372036854775808 -i64 9223372036854775807 -i64 8 -i64 -9223372036854775808 -i64 9223372036854775807 -i64 4 -float 0xC7EFFFFFE0000000 -float 0x47EFFFFFE0000000 -i64 8 -double 0xFFEFFFFFFFFFFFFF -double 0x7FEFFFFFFFFFFFFF \ No newline at end of file diff --git a/test/test_suite14/expressions/unsafe_comparisons.c3 b/test/test_suite14/expressions/unsafe_comparisons.c3 deleted file mode 100644 index 013b889e9..000000000 --- a/test/test_suite14/expressions/unsafe_comparisons.c3 +++ /dev/null @@ -1,41 +0,0 @@ -module test; - -fn bool test1(uint x) -{ - return x < 0; // #error: Comparing 'unsigned expression < 0' can never be true -} - -fn bool test2(uint x) -{ - return x <= 0; // #error: 'unsigned expression <= 0' is the same as expr == 0 -} - -fn bool test3(uint x) -{ - return x == -1; // #error: Comparing an unsigned value with a negative constant -} - -fn bool test4(uint x) -{ - return 0 > x ; // #error: '0 > unsigned expression' can never be true -} - -fn bool test5(uint x) -{ - return 0 >= x; // #error: '0 >= unsigned expression' is the same as 0 == expr -} - -fn bool test6(uint x) -{ - return -1 == x; // #error: an unsigned value with a negative constant -} - -macro obfuscate(x, $foo) -{ - return $foo == x; -} - -fn bool test7(uint x) -{ - return obfuscate(x, -1); -} \ No newline at end of file diff --git a/test/test_suite14/floats/convert_float.c3t b/test/test_suite14/floats/convert_float.c3t deleted file mode 100644 index dfe0fdd62..000000000 --- a/test/test_suite14/floats/convert_float.c3t +++ /dev/null @@ -1,24 +0,0 @@ -// #target: macos-x64 -module foo; - -fn void test() -{ - float x = 12; - x *= -1; - double y = x; -} - -/* #expect: foo.ll -define void @foo_test() #0 { -entry: - %x = alloca float, align 4 - %y = alloca double, align 8 - store float 1.200000e+01, float* %x, align 4 - %0 = load float, float* %x, align 4 - %fmul = fmul float %0, -1.000000e+00 - store float %fmul, float* %x, align 4 - %1 = load float, float* %x, align 4 - %fpfpext = fpext float %1 to double - store double %fpfpext, double* %y, align 8 - ret void -} diff --git a/test/test_suite14/floats/explicit_float_truncation_needed.c3 b/test/test_suite14/floats/explicit_float_truncation_needed.c3 deleted file mode 100644 index 72774ec8c..000000000 --- a/test/test_suite14/floats/explicit_float_truncation_needed.c3 +++ /dev/null @@ -1,4 +0,0 @@ -fn void test() -{ - float x = 0x7FFFFFFFFFFF.0p+400; // #error: The value '3.63419e+134' is out of range for 'float' -} \ No newline at end of file diff --git a/test/test_suite14/floats/float_exceeding_size.c3 b/test/test_suite14/floats/float_exceeding_size.c3 deleted file mode 100644 index 88867f28f..000000000 --- a/test/test_suite14/floats/float_exceeding_size.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test() -{ - float x = 0x7FFFFFFFFFFF.0p+40000; // #error: The float value is out of range. - -} \ No newline at end of file diff --git a/test/test_suite14/floats/inf_nan.c3t b/test/test_suite14/floats/inf_nan.c3t deleted file mode 100644 index b3a776a76..000000000 --- a/test/test_suite14/floats/inf_nan.c3t +++ /dev/null @@ -1,26 +0,0 @@ -module fe; - -fn void main() -{ - float z = float.inf + 100; - double z2 = double.inf; - float g = float.nan; - double g2 = double.nan; - double x = (double)(z); -} - -// #expect: fe.ll - - %z = alloca float, align 4 - %z2 = alloca double, align 8 - %g = alloca float, align 4 - %g2 = alloca double, align 8 - %x = alloca double, align 8 - store float 0x7FF0000000000000, float* %z, align 4 - store double 0x7FF0000000000000, double* %z2, align 8 - store float 0x7FF8000000000000, float* %g, align 4 - store double 0x7FF8000000000000, double* %g2, align 8 - %0 = load float, float* %z, align 4 - %fpfpext = fpext float %0 to double - store double %fpfpext, double* %x, align 8 - ret void \ No newline at end of file diff --git a/test/test_suite14/from_docs/examples_defer.c3t b/test/test_suite14/from_docs/examples_defer.c3t deleted file mode 100644 index 31e7136ce..000000000 --- a/test/test_suite14/from_docs/examples_defer.c3t +++ /dev/null @@ -1,61 +0,0 @@ -// #target: macos-x64 -module defer1; -import std::io; - -fn void test(int x) -{ - defer io::println(); - defer io::print("A"); - if (x == 1) return; - { - defer io::print("B"); - if (x == 0) return; - } - io::print("!"); -} - -fn void main() -{ - test(1); // Prints "A" - test(0); // Prints "BA" - test(10); // Prints "B!A" -} - -/* #expect: defer1.ll - -define void @defer1_test(i32 %0) #0 { -entry: - %eq = icmp eq i32 %0, 1 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - %1 = call i32 @std_io_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)) - %2 = call i32 @std_io_println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0)) #1 - ret void - -if.exit: ; preds = %entry - %eq1 = icmp eq i32 %0, 0 - br i1 %eq1, label %if.then2, label %if.exit3 - -if.then2: ; preds = %if.exit - %3 = call i32 @std_io_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0)) - %4 = call i32 @std_io_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0)) - %5 = call i32 @std_io_println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0)) #1 - ret void - -if.exit3: ; preds = %if.exit - %6 = call i32 @std_io_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0)) - %7 = call i32 @std_io_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0)) - %8 = call i32 @std_io_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0)) - %9 = call i32 @std_io_println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i32 0, i32 0)) #1 - ret void -} - -; Function Attrs: nounwind -define void @defer1_main() #0 { -entry: - call void @defer1_test(i32 1) - call void @defer1_test(i32 0) - call void @defer1_test(i32 10) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/from_docs/examples_forswitch.c3t b/test/test_suite14/from_docs/examples_forswitch.c3t deleted file mode 100644 index 446c24e63..000000000 --- a/test/test_suite14/from_docs/examples_forswitch.c3t +++ /dev/null @@ -1,237 +0,0 @@ -// #target: macos-x64 -module examples; -import libc; -import std::io; - -fn void example_for() -{ - // the for-loop is the same as C99. - for (int i = 0; i < 10; i++) - { - libc::printf("%d\n", i); - } - - // also equal - for (;;) - { - // .. - } -} - -enum Height : uint -{ - LOW, - MEDIUM, - HIGH, -} - -fn void demo_enum(Height h) -{ - switch (h) - { - case LOW: - case MEDIUM: - io::println("Not high"); - // Implicit break. - case HIGH: - io::println("High"); - } - - // This also works - switch (h) - { - case LOW: - case MEDIUM: - io::println("Not high"); - // Implicit break. - case Height.HIGH: - io::println("High"); - } - - // Completely empty cases are not allowed. - switch (h) - { - case LOW: - break; // Explicit break required, since switches can't be empty. - case MEDIUM: - io::println("Medium"); - case HIGH: - break; - } - - // special checking of switching on enum types - switch (h) - { - case LOW: - case MEDIUM: - case HIGH: - break; - default: // warning: default label in switch which covers all enumeration value - break; - } - - // Using "nextcase" will fallthrough to the next case statement, - // and each case statement starts its own scope. - switch (h) - { - case LOW: - int a = 1; - io::println("A"); - nextcase; - case MEDIUM: - int a = 2; - io::println("B"); - nextcase; - case HIGH: - // a is not defined here - io::println("C"); - } -} -/* #expect: examples.ll - -define void @examples_example_for() #0 { -entry: - %i = alloca i32, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %0 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %0, 10 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %1 = load i32, i32* %i, align 4 - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %1) - %3 = load i32, i32* %i, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %4 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %4(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.panic_msg, i64 0, i64 0), i64 19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.file, i64 0, i64 0), i64 21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.func, i64 0, i64 0), i64 11, i32 14) - unreachable - -unreachable_block: ; No predecessors! - ret void -} - -; Function Attrs: nounwind -define void @examples_demo_enum(i32 %0) #0 { -entry: - %switch = alloca i32, align 4 - %switch2 = alloca i32, align 4 - %switch7 = alloca i32, align 4 - %switch13 = alloca i32, align 4 - %switch17 = alloca i32, align 4 - %a = alloca i32, align 4 - %a21 = alloca i32, align 4 - store i32 %0, i32* %switch, align 4 - br label %switch.entry - -switch.entry: ; preds = %entry - %1 = load i32, i32* %switch, align 4 - switch i32 %1, label %switch.exit [ - i32 0, label %switch.case - i32 1, label %switch.case - i32 2, label %switch.case1 - ] - -switch.case: ; preds = %switch.entry, %switch.entry - %2 = call i32 @std_io_println(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0)) #1 - br label %switch.exit - -switch.case1: ; preds = %switch.entry - %3 = call i32 @std_io_println(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0)) #1 - br label %switch.exit - -switch.exit: ; preds = %switch.case1, %switch.case, %switch.entry - store i32 %0, i32* %switch2, align 4 - br label %switch.entry3 - -switch.entry3: ; preds = %switch.exit - %4 = load i32, i32* %switch2, align 4 - switch i32 %4, label %switch.exit6 [ - i32 0, label %switch.case4 - i32 1, label %switch.case4 - i32 2, label %switch.case5 - ] - -switch.case4: ; preds = %switch.entry3, %switch.entry3 - %5 = call i32 @std_io_println(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0)) #1 - br label %switch.exit6 - -switch.case5: ; preds = %switch.entry3 - %6 = call i32 @std_io_println(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0)) #1 - br label %switch.exit6 - -switch.exit6: ; preds = %switch.case5, %switch.case4, %switch.entry3 - store i32 %0, i32* %switch7, align 4 - br label %switch.entry8 - -switch.entry8: ; preds = %switch.exit6 - %7 = load i32, i32* %switch7, align 4 - switch i32 %7, label %switch.exit12 [ - i32 0, label %switch.case9 - i32 1, label %switch.case10 - i32 2, label %switch.case11 - ] - -switch.case9: ; preds = %switch.entry8 - br label %switch.exit12 - -switch.case10: ; preds = %switch.entry8 - %8 = call i32 @std_io_println(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0)) #1 - br label %switch.exit12 - -switch.case11: ; preds = %switch.entry8 - br label %switch.exit12 - -switch.exit12: ; preds = %switch.case11, %switch.case10, %switch.case9, %switch.entry8 - store i32 %0, i32* %switch13, align 4 - br label %switch.entry14 - -switch.entry14: ; preds = %switch.exit12 - %9 = load i32, i32* %switch13, align 4 - switch i32 %9, label %switch.default [ - i32 0, label %switch.case15 - i32 1, label %switch.case15 - i32 2, label %switch.case15 - ] - -switch.case15: ; preds = %switch.entry14, %switch.entry14, %switch.entry14 - br label %switch.exit16 - -switch.default: ; preds = %switch.entry14 - br label %switch.exit16 - -switch.exit16: ; preds = %switch.default, %switch.case15 - store i32 %0, i32* %switch17, align 4 - br label %switch.entry18 - -switch.entry18: ; preds = %switch.exit16 - %10 = load i32, i32* %switch17, align 4 - switch i32 %10, label %switch.exit23 [ - i32 0, label %switch.case19 - i32 1, label %switch.case20 - i32 2, label %switch.case22 - ] - -switch.case19: ; preds = %switch.entry18 - store i32 1, i32* %a, align 4 - %11 = call i32 @std_io_println(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0)) #1 - br label %switch.case20 - -switch.case20: ; preds = %switch.entry18, %switch.case19 - store i32 2, i32* %a21, align 4 - %12 = call i32 @std_io_println(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0)) #1 - br label %switch.case22 - -switch.case22: ; preds = %switch.entry18, %switch.case20 - %13 = call i32 @std_io_println(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0)) #1 - br label %switch.exit23 - -switch.exit23: ; preds = %switch.case22, %switch.entry18 - ret void -} diff --git a/test/test_suite14/from_docs/examples_functionpointer.c3t b/test/test_suite14/from_docs/examples_functionpointer.c3t deleted file mode 100644 index 81e152e89..000000000 --- a/test/test_suite14/from_docs/examples_functionpointer.c3t +++ /dev/null @@ -1,33 +0,0 @@ -// #target: macos-x64 - -module demo; -define Callback = fn int(char* text, int value); - -fn int my_callback(char* text, int value) -{ - return 0; -} - -Callback cb = &my_callback; - -fn void main() -{ - int result = cb("demo", 123); - // .. -} - -// #expect: demo.ll - -define i32 @demo_my_callback(i8* %0, i32 %1) #0 { -entry: - ret i32 0 -} - -define void @demo_main() #0 { -entry: - %result = alloca i32, align 4 - %0 = load i32 (i8*, i32)*, i32 (i8*, i32)** @demo_cb, align 8 - %1 = call i32 %0(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 123) - store i32 %1, i32* %result, align 4 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/from_docs/examples_if_catch.c3t b/test/test_suite14/from_docs/examples_if_catch.c3t deleted file mode 100644 index 5a82a6fa7..000000000 --- a/test/test_suite14/from_docs/examples_if_catch.c3t +++ /dev/null @@ -1,163 +0,0 @@ -// #target: macos-x64 -module demo; -import libc; -import std::io; - -fault MathError -{ - DIVISION_BY_ZERO -} - -fn int foo() { return 123; } -fn int bar() { return 0; } - -fn double! divide(int a, int b) -{ - if (b == 0) return MathError.DIVISION_BY_ZERO!; - return (double)(a) / (double)(b); - -} - -// Rethrowing an error uses "?" suffix -fn void! testMayError() -{ - divide(foo(), bar())?; -} - -fn void main() -{ - // ratio has a failable type. - double! ratio = divide(foo(), bar()); - - // Handle the error - if (catch err = ratio) - { - case MathError.DIVISION_BY_ZERO: - libc::printf("Division by zero\n"); - return; - default: - libc::printf("Unexpected error!"); - return; - } - // Flow typing makes "ratio" - // have the type double here. - libc::printf("Ratio was %f\n", ratio); -} - -/* #expect: demo.ll - - -define i64 @demo_divide(double* %0, i32 %1, i32 %2) #0 { -entry: - %reterr = alloca i64, align 8 - %eq = icmp eq i32 %2, 0 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i64 ptrtoint (%.fault* @"demo_MathError$DIVISION_BY_ZERO" to i64) - -if.exit: ; preds = %entry - %sifp = sitofp i32 %1 to double - %sifp1 = sitofp i32 %2 to double - %fdiv = fdiv double %sifp, %sifp1 - store double %fdiv, double* %0, align 8 - ret i64 0 -} - -; Function Attrs: nounwind -define i64 @demo_testMayError() #0 { -entry: - %error_var = alloca i64, align 8 - %retparam = alloca double, align 8 - %reterr = alloca i64, align 8 - %0 = call i32 @demo_foo() - %1 = call i32 @demo_bar() - %2 = call i64 @demo_divide(double* %retparam, i32 %0, i32 %1) - %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %2, i64* %error_var, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - %3 = load i64, i64* %error_var, align 8 - ret i64 %3 - -noerr_block: ; preds = %after_check - ret i64 0 -} - -; Function Attrs: nounwind -define void @demo_main() #0 { -entry: - %ratio = alloca double, align 8 - %ratio.f = alloca i64, align 8 - %retparam = alloca double, align 8 - %err = alloca i64, align 8 - %switch = alloca i64, align 8 - %0 = call i32 @demo_foo() - %1 = call i32 @demo_bar() - %2 = call i64 @demo_divide(double* %retparam, i32 %0, i32 %1) - %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %2, i64* %ratio.f, align 8 - br label %after_assign - -after_check: ; preds = %entry - %3 = load double, double* %retparam, align 8 - store double %3, double* %ratio, align 8 - store i64 0, i64* %ratio.f, align 8 - br label %after_assign - -after_assign: ; preds = %after_check, %assign_optional - br label %testblock - -testblock: ; preds = %after_assign - %optval = load i64, i64* %ratio.f, align 8 - %not_err1 = icmp eq i64 %optval, 0 - br i1 %not_err1, label %after_check3, label %assign_optional2 - -assign_optional2: ; preds = %testblock - store i64 %optval, i64* %err, align 8 - br label %end_block - -after_check3: ; preds = %testblock - store i64 0, i64* %err, align 8 - br label %end_block - -end_block: ; preds = %after_check3, %assign_optional2 - %4 = load i64, i64* %err, align 8 - %neq = icmp ne i64 %4, 0 - br i1 %neq, label %if.then, label %if.exit - -if.then: ; preds = %end_block - store i64 %4, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %if.then - %5 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.fault* @"demo_MathError$DIVISION_BY_ZERO" to i64), %5 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i32 0, i32 0)) - ret void - -next_if: ; preds = %switch.entry - br label %switch.default - -switch.default: ; preds = %next_if - %7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0)) - ret void - -if.exit: ; preds = %end_block - %8 = load double, double* %ratio, align 8 - %9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0), double %8) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/from_docs/examples_macro_function.c3t b/test/test_suite14/from_docs/examples_macro_function.c3t deleted file mode 100644 index 2e071cb37..000000000 --- a/test/test_suite14/from_docs/examples_macro_function.c3t +++ /dev/null @@ -1,50 +0,0 @@ -// #target: macos-x64 -module example; -import std::io; - -macro foo(a, b) -{ - return a(b); -} - -fn int square(int x) -{ - return x * x; -} - -fn int test() -{ - int a = 2; - int b = 3; - return foo(&square, 2) + a + b; // 9 - // return foo(square, 2) + a + b; - // Error the symbol "square" cannot be used as an argument. -} - -/* #expect: example.ll - -define i32 @example_square(i32 %0) #0 { -entry: - %mul = mul i32 %0, %0 - ret i32 %mul -} - -define i32 @example_test() #0 { -entry: - %a = alloca i32, align 4 - %b = alloca i32, align 4 - %a1 = alloca i32 (i32)*, align 8 - %b2 = alloca i32, align 4 - store i32 2, i32* %a, align 4 - store i32 3, i32* %b, align 4 - store i32 (i32)* @example_square, i32 (i32)** %a1, align 8 - store i32 2, i32* %b2, align 4 - %0 = load i32 (i32)*, i32 (i32)** %a1, align 8 - %1 = load i32, i32* %b2, align 4 - %2 = call i32 %0(i32 %1) - %3 = load i32, i32* %a, align 4 - %add = add i32 %2, %3 - %4 = load i32, i32* %b, align 4 - %add3 = add i32 %add, %4 - ret i32 %add3 -} \ No newline at end of file diff --git a/test/test_suite14/from_docs/examples_struct.c3 b/test/test_suite14/from_docs/examples_struct.c3 deleted file mode 100644 index dccc7d404..000000000 --- a/test/test_suite14/from_docs/examples_struct.c3 +++ /dev/null @@ -1,46 +0,0 @@ -define Callback = fn int(char c); -struct Person { int i; } -struct Company { int j; } -enum Status : int -{ - IDLE, - BUSY, - DONE, -} - -struct MyData -{ - char* name; - Callback open; - Callback close; - //Status status; - - // named sub-structs (x.other.value) - struct other - { - int value; - int status; // ok, no name clash with other status - } - - // anonymous sub-structs (x.value) - struct - { - int value; - int status; // error, name clash with other status in MyData - } - - // anonymous union (x.person) - union - { - Person* person; - Company* company; - } - - // named sub-unions (x.either.this) - union either - { - int this; - bool or; - char* that; - } -} \ No newline at end of file diff --git a/test/test_suite14/functions/after_vararg.c3 b/test/test_suite14/functions/after_vararg.c3 deleted file mode 100644 index 8fee2a86b..000000000 --- a/test/test_suite14/functions/after_vararg.c3 +++ /dev/null @@ -1,3 +0,0 @@ -fn void test1(int... x, int) { } // #error: A parameter name was expected -fn void test2(x..., int) { } // #error: A parameter name was expected -extern fn void test3(int a, ..., int y); // #error: C-style varargs cannot be followed by regular parameters. \ No newline at end of file diff --git a/test/test_suite14/functions/assorted_tests.c3t b/test/test_suite14/functions/assorted_tests.c3t deleted file mode 100644 index a19405ecb..000000000 --- a/test/test_suite14/functions/assorted_tests.c3t +++ /dev/null @@ -1,112 +0,0 @@ -module test; - -fn int foo1() -{ - char *pp = void; - uint w_cnt = void; - - w_cnt += *pp; - - return (int)(w_cnt); -} - -extern fn void test2(int, double, float); - -fn void foo2(int x) -{ - test2(x, x ? 1.0 : 12.5, 1.0); -} - -fn int trys(ichar* s, int x) -{ - int asa = void; - double val = void; - int lls = void; - if (x) - { - asa = lls + asa; - } - else - { - } - return asa + (int)(val); -} - -struct InternalFPF -{ - char type; -} - -fn void setInternalFPFZero(InternalFPF* dest) @noinline -{ - dest.type = 0; -} - -fn void denormalize(InternalFPF* ptr) -{ - setInternalFPFZero(ptr); -} - - -/* #expect: test.ll - -define i32 @test_foo1() #0 { -entry: - %pp = alloca i8*, align 8 - %w_cnt = alloca i32, align 4 - %0 = load i32, i32* %w_cnt, align 4 - %1 = load i8*, i8** %pp, align 8 - %2 = load i8, i8* %1, align 1 - %zext = zext i8 %2 to i32 - %add = add i32 %0, %zext - store i32 %add, i32* %w_cnt, align 4 - %3 = load i32, i32* %w_cnt, align 4 - ret i32 %3 -} - -define void @test_foo2(i32 %0) #0 { -entry: - %intbool = icmp ne i32 %0, 0 - %ternary = select i1 %intbool, double 1.000000e+00, double 1.250000e+01 - call void @test2(i32 %0, double %ternary, float 1.000000e+00) - ret void -} - -define i32 @test_trys(i8* %0, i32 %1) #0 { -entry: - %asa = alloca i32, align 4 - %val = alloca double, align 8 - %lls = alloca i32, align 4 - %intbool = icmp ne i32 %1, 0 - br i1 %intbool, label %if.then, label %if.exit - -if.then: ; preds = %entry - %2 = load i32, i32* %lls, align 4 - %3 = load i32, i32* %asa, align 4 - %add = add i32 %2, %3 - store i32 %add, i32* %asa, align 4 - br label %if.exit - -if.exit: ; preds = %if.then, %entry - %4 = load i32, i32* %asa, align 4 - %5 = load double, double* %val, align 8 - %fpsi = fptosi double %5 to i32 - %add1 = add i32 %4, %fpsi - ret i32 %add1 -} - -define void @test_setInternalFPFZero(%InternalFPF* %0) #1 { -entry: - %1 = getelementptr inbounds %InternalFPF, %InternalFPF* %0, i32 0, i32 0 - store i8 0, i8* %1, align 1 - ret void -} - -define void @test_denormalize(%InternalFPF* %0) #0 { -entry: - call void @test_setInternalFPFZero(%InternalFPF* %0) - ret void -} - -attributes #0 = { nounwind } -attributes #1 = { noinline nounwind } \ No newline at end of file diff --git a/test/test_suite14/functions/body_argument_fail.c3 b/test/test_suite14/functions/body_argument_fail.c3 deleted file mode 100644 index 7af99bcf5..000000000 --- a/test/test_suite14/functions/body_argument_fail.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void foo1(int... x;) {} // #error: Expected ')' -fn void foo2(... x;) {} // #error: Expected ')' -fn void foo3(... x;) {} // #error: Expected ')' -fn void foo4(;) {} // #error: Expected ')' -fn void foo5(int x;) {} // #error: Expected ')' \ No newline at end of file diff --git a/test/test_suite14/functions/default_param_fail.c3 b/test/test_suite14/functions/default_param_fail.c3 deleted file mode 100644 index 621265af7..000000000 --- a/test/test_suite14/functions/default_param_fail.c3 +++ /dev/null @@ -1,11 +0,0 @@ - -int z; - -fault MyError -{ - FOO, -} - -fn void test(int a = z) {} - -fn void test2(int b = MyError.FOO!) {} \ No newline at end of file diff --git a/test/test_suite14/functions/defered_default_arguments.c3t b/test/test_suite14/functions/defered_default_arguments.c3t deleted file mode 100644 index e7ecc1211..000000000 --- a/test/test_suite14/functions/defered_default_arguments.c3t +++ /dev/null @@ -1,57 +0,0 @@ -module test; -import std::io; -import test2; - -fn void test(int a = test2::bar(), int b = test2::foo()) -{ - io::printf("%d %d\n", a, b); -} - -module test2; - -fn int foo() -{ - static int x = 0; - return ++x; -} - -macro int bar() -{ - static int x = 0; - return ++x; -} - -module test3; -import test; -import std::io; - -fn void main() -{ - test::test(1, 2); - test::test(.a = 3); - test::test(1, .b = 32); - test::test(); - test::test(); -} - -// #expect: test3.ll - -entry: - call void @test_test(i32 1, i32 2) - %0 = call i32 @test2_foo() - call void @test_test(i32 3, i32 %0) - call void @test_test(i32 1, i32 32) - %1 = load i32, i32* @"main$x", align 4 - %add = add i32 %1, 1 - store i32 %add, i32* @"main$x", align 4 - %2 = call i32 @test2_foo() - call void @test_test(i32 %add, i32 %2) - %3 = load i32, i32* @"main$x.1", align 4 - %add1 = add i32 %3, 1 - store i32 %add1, i32* @"main$x.1", align 4 - %4 = call i32 @test2_foo() - call void @test_test(i32 %add1, i32 %4) - ret void -} - - diff --git a/test/test_suite14/functions/double_return.c3t b/test/test_suite14/functions/double_return.c3t deleted file mode 100644 index 752700bce..000000000 --- a/test/test_suite14/functions/double_return.c3t +++ /dev/null @@ -1,13 +0,0 @@ -module double_return; - -fn int test(bool pos, bool color) -{ - return 0; - return (int)(pos && color); -} - -// #expect: double_return.ll - -entry: - ret i32 0 -} diff --git a/test/test_suite14/functions/failable_param.c3 b/test/test_suite14/functions/failable_param.c3 deleted file mode 100644 index 40633fcaf..000000000 --- a/test/test_suite14/functions/failable_param.c3 +++ /dev/null @@ -1,3 +0,0 @@ -module test; - -fn void test4(void!); // #error: Parameters may not be optional. diff --git a/test/test_suite14/functions/func_ptr_conversion_alias.c3t b/test/test_suite14/functions/func_ptr_conversion_alias.c3t deleted file mode 100644 index 876cc3450..000000000 --- a/test/test_suite14/functions/func_ptr_conversion_alias.c3t +++ /dev/null @@ -1,20 +0,0 @@ -module test; - -define Callback = fn void(); -define Callback2 = fn void(); - -define GetCallback = fn Callback2**[][123]*(); - -fn Callback**[][123]* tester() -{ - return null; -} - -GetCallback x = &tester; - - -define GetCallbackOpt = fn Callback2!(); - -fn Callback2! tester2() => null; - -GetCallbackOpt y = &tester2; \ No newline at end of file diff --git a/test/test_suite14/functions/func_ptr_conversions_and_names.c3t b/test/test_suite14/functions/func_ptr_conversions_and_names.c3t deleted file mode 100644 index 2cc3d8c06..000000000 --- a/test/test_suite14/functions/func_ptr_conversions_and_names.c3t +++ /dev/null @@ -1,294 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -define Func = fn int(int y); -define FuncOther = fn bool(char*); -define FuncSame = fn int(int z = 444); - -fn int test(int a) { return a; } -fn int test2(int b = 3) { return b; } - -fn int! test3(int b = 3) { return b; } -fn int! test4(int b = 3) { return b; } - -fn void main() -{ - Func a = &test; - Func b = &test2; - io::printfn("%d", a(.y = 123)); - io::printfn("%d", (&test2)()); - FuncSame z = &test2; - io::printfn("%d", z()); - io::printfn("%s", $typeof(b ? &test2 : &test).qnameof); - io::printfn("%s", $typeof(b ? &test2 : &test).nameof); - io::printfn("%s", $typeof(&test2).qnameof); - io::printfn("%s", $typeof(&test2).nameof); - io::printfn("%s", $typeof(b ? &test4 : &test3).nameof); - - $typeof(b ? &test2 : &test) y = &test2; - typeid zfoke = $typeof(y).typeid; -} - - -/* #expect: test.ll - -@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 -@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1 -@.str.2 = private unnamed_addr constant [3 x i8] c"%d\00", align 1 -@.str.3 = private unnamed_addr constant [3 x i8] c"%s\00", align 1 -@.str.4 = private unnamed_addr constant [13 x i8] c"fn int(int)*\00", align 1 -@"ct$char" = linkonce constant %.introspect { i8 3, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$a12$char" = linkonce constant %.introspect { i8 15, i64 12, i64 ptrtoint (%.introspect* @"ct$char" to i64), i64 12, [0 x i64] zeroinitializer }, align 8 -@"ct$p$a12$char" = linkonce constant %.introspect { i8 19, i64 8, i64 ptrtoint (%.introspect* @"ct$a12$char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 -@.str.5 = private unnamed_addr constant [3 x i8] c"%s\00", align 1 -@.str.6 = private unnamed_addr constant [13 x i8] c"fn int(int)*\00", align 1 -@.str.7 = private unnamed_addr constant [3 x i8] c"%s\00", align 1 -@.str.8 = private unnamed_addr constant [13 x i8] c"test::test2*\00", align 1 -@.str.9 = private unnamed_addr constant [3 x i8] c"%s\00", align 1 -@.str.10 = private unnamed_addr constant [7 x i8] c"test2*\00", align 1 -@"ct$a6$char" = linkonce constant %.introspect { i8 15, i64 6, i64 ptrtoint (%.introspect* @"ct$char" to i64), i64 6, [0 x i64] zeroinitializer }, align 8 -@"ct$p$a6$char" = linkonce constant %.introspect { i8 19, i64 8, i64 ptrtoint (%.introspect* @"ct$a6$char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 -@.str.11 = private unnamed_addr constant [3 x i8] c"%s\00", align 1 -@.str.12 = private unnamed_addr constant [14 x i8] c"fn int!(int)*\00", align 1 -@"ct$a13$char" = linkonce constant %.introspect { i8 15, i64 13, i64 ptrtoint (%.introspect* @"ct$char" to i64), i64 13, [0 x i64] zeroinitializer }, align 8 -@"ct$p$a13$char" = linkonce constant %.introspect { i8 19, i64 8, i64 ptrtoint (%.introspect* @"ct$a13$char" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$fn$int$int$" = linkonce constant %.introspect { i8 13, i64 8, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$p$fn$int$int$" = linkonce constant %.introspect { i8 19, i64 8, i64 ptrtoint (%.introspect* @"ct$fn$int$int$" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 - - -define void @test_main() #0 { -entry: - %a = alloca i32 (i32)*, align 8 - %b = alloca i32 (i32)*, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [1 x %variant], align 16 - %taddr4 = alloca i32, align 4 - %taddr5 = alloca %"variant[]", align 8 - %z = alloca i32 (i32)*, align 8 - %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %variant], align 16 - %taddr13 = alloca i32, align 4 - %taddr14 = alloca %"variant[]", align 8 - %retparam20 = alloca i64, align 8 - %varargslots21 = alloca [1 x %variant], align 16 - %taddr22 = alloca [12 x i8]*, align 8 - %taddr23 = alloca %"variant[]", align 8 - %retparam29 = alloca i64, align 8 - %varargslots30 = alloca [1 x %variant], align 16 - %taddr31 = alloca [12 x i8]*, align 8 - %taddr32 = alloca %"variant[]", align 8 - %retparam38 = alloca i64, align 8 - %varargslots39 = alloca [1 x %variant], align 16 - %taddr40 = alloca [12 x i8]*, align 8 - %taddr41 = alloca %"variant[]", align 8 - %retparam47 = alloca i64, align 8 - %varargslots48 = alloca [1 x %variant], align 16 - %taddr49 = alloca [6 x i8]*, align 8 - %taddr50 = alloca %"variant[]", align 8 - %retparam56 = alloca i64, align 8 - %varargslots57 = alloca [1 x %variant], align 16 - %taddr58 = alloca [13 x i8]*, align 8 - %taddr59 = alloca %"variant[]", align 8 - %y = alloca i32 (i32)*, align 8 - %zfoke = alloca i64, align 8 - store i32 (i32)* @test_test, i32 (i32)** %a, align 8 - store i32 (i32)* @test_test2, i32 (i32)** %b, align 8 - %0 = load i32 (i32)*, i32 (i32)** %a, align 8 - %1 = call i32 %0(i32 123) - store i32 %1, i32* %taddr, align 4 - %2 = bitcast i32* %taddr to i8* - %3 = insertvalue %variant undef, i8* %2, 0 - %4 = insertvalue %variant %3, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %5 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %4, %variant* %5, align 16 - %6 = bitcast [1 x %variant]* %varargslots to %variant* - %7 = insertvalue %"variant[]" undef, %variant* %6, 0 - %8 = insertvalue %"variant[]" %7, i64 1, 1 - store %"variant[]" %8, %"variant[]"* %taddr1, align 8 - %9 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 0 - %lo = load i8*, i8** %10, align 8 - %11 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 1 - %hi = load i64, i64* %11, align 8 - %12 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i64 2, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %12, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %13 = call i32 @test_test2(i32 3) - store i32 %13, i32* %taddr4, align 4 - %14 = bitcast i32* %taddr4 to i8* - %15 = insertvalue %variant undef, i8* %14, 0 - %16 = insertvalue %variant %15, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %17 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots3, i64 0, i64 0 - store %variant %16, %variant* %17, align 16 - %18 = bitcast [1 x %variant]* %varargslots3 to %variant* - %19 = insertvalue %"variant[]" undef, %variant* %18, 0 - %20 = insertvalue %"variant[]" %19, i64 1, 1 - store %"variant[]" %20, %"variant[]"* %taddr5, align 8 - %21 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 0 - %lo6 = load i8*, i8** %22, align 8 - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 1 - %hi7 = load i64, i64* %23, align 8 - %24 = call i64 @std_io_printfn(i64* %retparam2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i64 2, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %24, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %voiderr - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %voiderr - store i32 (i32)* @test_test2, i32 (i32)** %z, align 8 - %25 = load i32 (i32)*, i32 (i32)** %z, align 8 - %26 = call i32 %25(i32 444) - store i32 %26, i32* %taddr13, align 4 - %27 = bitcast i32* %taddr13 to i8* - %28 = insertvalue %variant undef, i8* %27, 0 - %29 = insertvalue %variant %28, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %30 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots12, i64 0, i64 0 - store %variant %29, %variant* %30, align 16 - %31 = bitcast [1 x %variant]* %varargslots12 to %variant* - %32 = insertvalue %"variant[]" undef, %variant* %31, 0 - %33 = insertvalue %"variant[]" %32, i64 1, 1 - store %"variant[]" %33, %"variant[]"* %taddr14, align 8 - %34 = bitcast %"variant[]"* %taddr14 to { i8*, i64 }* - %35 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %34, i32 0, i32 0 - %lo15 = load i8*, i8** %35, align 8 - %36 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %34, i32 0, i32 1 - %hi16 = load i64, i64* %36, align 8 - %37 = call i64 @std_io_printfn(i64* %retparam11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i64 2, i8* %lo15, i64 %hi16) - %not_err17 = icmp eq i64 %37, 0 - br i1 %not_err17, label %after_check18, label %voiderr19 - -after_check18: ; preds = %voiderr10 - br label %voiderr19 - -voiderr19: ; preds = %after_check18, %voiderr10 - store [12 x i8]* bitcast ([13 x i8]* @.str.4 to [12 x i8]*), [12 x i8]** %taddr22, align 8 - %38 = bitcast [12 x i8]** %taddr22 to i8* - %39 = insertvalue %variant undef, i8* %38, 0 - %40 = insertvalue %variant %39, i64 ptrtoint (%.introspect* @"ct$p$a12$char" to i64), 1 - %41 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots21, i64 0, i64 0 - store %variant %40, %variant* %41, align 16 - %42 = bitcast [1 x %variant]* %varargslots21 to %variant* - %43 = insertvalue %"variant[]" undef, %variant* %42, 0 - %44 = insertvalue %"variant[]" %43, i64 1, 1 - store %"variant[]" %44, %"variant[]"* %taddr23, align 8 - %45 = bitcast %"variant[]"* %taddr23 to { i8*, i64 }* - %46 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 0 - %lo24 = load i8*, i8** %46, align 8 - %47 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 1 - %hi25 = load i64, i64* %47, align 8 - %48 = call i64 @std_io_printfn(i64* %retparam20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i64 2, i8* %lo24, i64 %hi25) - %not_err26 = icmp eq i64 %48, 0 - br i1 %not_err26, label %after_check27, label %voiderr28 - -after_check27: ; preds = %voiderr19 - br label %voiderr28 - -voiderr28: ; preds = %after_check27, %voiderr19 - store [12 x i8]* bitcast ([13 x i8]* @.str.6 to [12 x i8]*), [12 x i8]** %taddr31, align 8 - %49 = bitcast [12 x i8]** %taddr31 to i8* - %50 = insertvalue %variant undef, i8* %49, 0 - %51 = insertvalue %variant %50, i64 ptrtoint (%.introspect* @"ct$p$a12$char" to i64), 1 - %52 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots30, i64 0, i64 0 - store %variant %51, %variant* %52, align 16 - %53 = bitcast [1 x %variant]* %varargslots30 to %variant* - %54 = insertvalue %"variant[]" undef, %variant* %53, 0 - %55 = insertvalue %"variant[]" %54, i64 1, 1 - store %"variant[]" %55, %"variant[]"* %taddr32, align 8 - %56 = bitcast %"variant[]"* %taddr32 to { i8*, i64 }* - %57 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %56, i32 0, i32 0 - %lo33 = load i8*, i8** %57, align 8 - %58 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %56, i32 0, i32 1 - %hi34 = load i64, i64* %58, align 8 - %59 = call i64 @std_io_printfn(i64* %retparam29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i64 2, i8* %lo33, i64 %hi34) - %not_err35 = icmp eq i64 %59, 0 - br i1 %not_err35, label %after_check36, label %voiderr37 - -after_check36: ; preds = %voiderr28 - br label %voiderr37 - -voiderr37: ; preds = %after_check36, %voiderr28 - store [12 x i8]* bitcast ([13 x i8]* @.str.8 to [12 x i8]*), [12 x i8]** %taddr40, align 8 - %60 = bitcast [12 x i8]** %taddr40 to i8* - %61 = insertvalue %variant undef, i8* %60, 0 - %62 = insertvalue %variant %61, i64 ptrtoint (%.introspect* @"ct$p$a12$char" to i64), 1 - %63 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots39, i64 0, i64 0 - store %variant %62, %variant* %63, align 16 - %64 = bitcast [1 x %variant]* %varargslots39 to %variant* - %65 = insertvalue %"variant[]" undef, %variant* %64, 0 - %66 = insertvalue %"variant[]" %65, i64 1, 1 - store %"variant[]" %66, %"variant[]"* %taddr41, align 8 - %67 = bitcast %"variant[]"* %taddr41 to { i8*, i64 }* - %68 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %67, i32 0, i32 0 - %lo42 = load i8*, i8** %68, align 8 - %69 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %67, i32 0, i32 1 - %hi43 = load i64, i64* %69, align 8 - %70 = call i64 @std_io_printfn(i64* %retparam38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i64 2, i8* %lo42, i64 %hi43) - %not_err44 = icmp eq i64 %70, 0 - br i1 %not_err44, label %after_check45, label %voiderr46 - -after_check45: ; preds = %voiderr37 - br label %voiderr46 - -voiderr46: ; preds = %after_check45, %voiderr37 - store [6 x i8]* bitcast ([7 x i8]* @.str.10 to [6 x i8]*), [6 x i8]** %taddr49, align 8 - %71 = bitcast [6 x i8]** %taddr49 to i8* - %72 = insertvalue %variant undef, i8* %71, 0 - %73 = insertvalue %variant %72, i64 ptrtoint (%.introspect* @"ct$p$a6$char" to i64), 1 - %74 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots48, i64 0, i64 0 - store %variant %73, %variant* %74, align 16 - %75 = bitcast [1 x %variant]* %varargslots48 to %variant* - %76 = insertvalue %"variant[]" undef, %variant* %75, 0 - %77 = insertvalue %"variant[]" %76, i64 1, 1 - store %"variant[]" %77, %"variant[]"* %taddr50, align 8 - %78 = bitcast %"variant[]"* %taddr50 to { i8*, i64 }* - %79 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %78, i32 0, i32 0 - %lo51 = load i8*, i8** %79, align 8 - %80 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %78, i32 0, i32 1 - %hi52 = load i64, i64* %80, align 8 - %81 = call i64 @std_io_printfn(i64* %retparam47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i64 2, i8* %lo51, i64 %hi52) - %not_err53 = icmp eq i64 %81, 0 - br i1 %not_err53, label %after_check54, label %voiderr55 - -after_check54: ; preds = %voiderr46 - br label %voiderr55 - -voiderr55: ; preds = %after_check54, %voiderr46 - store [13 x i8]* bitcast ([14 x i8]* @.str.12 to [13 x i8]*), [13 x i8]** %taddr58, align 8 - %82 = bitcast [13 x i8]** %taddr58 to i8* - %83 = insertvalue %variant undef, i8* %82, 0 - %84 = insertvalue %variant %83, i64 ptrtoint (%.introspect* @"ct$p$a13$char" to i64), 1 - %85 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots57, i64 0, i64 0 - store %variant %84, %variant* %85, align 16 - %86 = bitcast [1 x %variant]* %varargslots57 to %variant* - %87 = insertvalue %"variant[]" undef, %variant* %86, 0 - %88 = insertvalue %"variant[]" %87, i64 1, 1 - store %"variant[]" %88, %"variant[]"* %taddr59, align 8 - %89 = bitcast %"variant[]"* %taddr59 to { i8*, i64 }* - %90 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %89, i32 0, i32 0 - %lo60 = load i8*, i8** %90, align 8 - %91 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %89, i32 0, i32 1 - %hi61 = load i64, i64* %91, align 8 - %92 = call i64 @std_io_printfn(i64* %retparam56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i64 2, i8* %lo60, i64 %hi61) - %not_err62 = icmp eq i64 %92, 0 - br i1 %not_err62, label %after_check63, label %voiderr64 - -after_check63: ; preds = %voiderr55 - br label %voiderr64 - -voiderr64: ; preds = %after_check63, %voiderr55 - store i32 (i32)* @test_test2, i32 (i32)** %y, align 8 - store i64 ptrtoint (%.introspect* @"ct$p$fn$int$int$" to i64), i64* %zfoke, align 8 - ret void -} diff --git a/test/test_suite14/functions/invalid_param.c3 b/test/test_suite14/functions/invalid_param.c3 deleted file mode 100644 index 7a75e9586..000000000 --- a/test/test_suite14/functions/invalid_param.c3 +++ /dev/null @@ -1 +0,0 @@ -fn void foo(int ABC) { } // #error: Parameter names may not be all uppercase. diff --git a/test/test_suite14/functions/macro_arguments.c3 b/test/test_suite14/functions/macro_arguments.c3 deleted file mode 100644 index b893f9081..000000000 --- a/test/test_suite14/functions/macro_arguments.c3 +++ /dev/null @@ -1,12 +0,0 @@ - -fn void foo1(int #foo) { } // #error: Only regular parameters are allowed for functions. - -fn void foo2(int $foo) { } // #error: Only regular parameters are allowed for functions. - -fn void foo3(bar) { } // #error: Only typed parameters are allowed for functions - -fn void foo4($Type) { } // #error: Only regular parameters are allowed for functions. - -fn void foo8(int &foo) {} // #error: Only regular parameters are allowed for functions. - -fn void foo9(int x, int x) {} // #error: Duplicate parameter name 'x'. \ No newline at end of file diff --git a/test/test_suite14/functions/missing_first_paren.c3 b/test/test_suite14/functions/missing_first_paren.c3 deleted file mode 100644 index 384625bd2..000000000 --- a/test/test_suite14/functions/missing_first_paren.c3 +++ /dev/null @@ -1,3 +0,0 @@ -fn void foo) // #error: Expected '(' -{ -} diff --git a/test/test_suite14/functions/missing_return.c3 b/test/test_suite14/functions/missing_return.c3 deleted file mode 100644 index d1028c19b..000000000 --- a/test/test_suite14/functions/missing_return.c3 +++ /dev/null @@ -1,3 +0,0 @@ -fn int test1() // #error: Missing return statement at the end of -{ -} \ No newline at end of file diff --git a/test/test_suite14/functions/naked_function.c3t b/test/test_suite14/functions/naked_function.c3t deleted file mode 100644 index 55830a596..000000000 --- a/test/test_suite14/functions/naked_function.c3t +++ /dev/null @@ -1,15 +0,0 @@ -// #target: macos-x64 - -fn void test(int i) @naked -{ - -} - -/* #expect: naked_function.ll - -define void @naked_function_test(i32 %0) #0 { -entry: - ret void -} - -attributes #0 = { naked nounwind } \ No newline at end of file diff --git a/test/test_suite14/functions/naked_function_fail.c3 b/test/test_suite14/functions/naked_function_fail.c3 deleted file mode 100644 index df2b693f7..000000000 --- a/test/test_suite14/functions/naked_function_fail.c3 +++ /dev/null @@ -1,4 +0,0 @@ -fn void test() @naked -{ - int i; // #error: Only asm statements are allowed inside of a naked function -} \ No newline at end of file diff --git a/test/test_suite14/functions/returning_void.c3t b/test/test_suite14/functions/returning_void.c3t deleted file mode 100644 index 887a270ae..000000000 --- a/test/test_suite14/functions/returning_void.c3t +++ /dev/null @@ -1,20 +0,0 @@ -fn void test1() -{ - int x; - if (x == 0) return; - return test1(); -} -// #expect: returning_void.ll - - %x = alloca i32, align 4 - store i32 0, i32* %x, align 4 - %0 = load i32, i32* %x, align 4 - %eq = icmp eq i32 %0, 0 - br i1 %eq, label %if.then, label %if.exit - -if.then: - ret void - -if.exit: - call void @returning_void_test1() - ret void diff --git a/test/test_suite14/functions/simple_test.c3t b/test/test_suite14/functions/simple_test.c3t deleted file mode 100644 index 03e4aab76..000000000 --- a/test/test_suite14/functions/simple_test.c3t +++ /dev/null @@ -1,30 +0,0 @@ -// #target: macos-x64 - -fn int foo() -{ - char *pp; - uint w_cnt; - - w_cnt += *pp; - - return w_cnt; -} - -/* #expect: simple_test.ll - - -define i32 @simple_test_foo() #0 { -entry: - %pp = alloca i8*, align 8 - %w_cnt = alloca i32, align 4 - store i8* null, i8** %pp, align 8 - store i32 0, i32* %w_cnt, align 4 - %0 = load i32, i32* %w_cnt, align 4 - %1 = load i8*, i8** %pp, align 8 - %2 = load i8, i8* %1, align 1 - %zext = zext i8 %2 to i32 - %add = add i32 %0, %zext - store i32 %add, i32* %w_cnt, align 4 - %3 = load i32, i32* %w_cnt, align 4 - ret i32 %3 -} \ No newline at end of file diff --git a/test/test_suite14/functions/splat.c3t b/test/test_suite14/functions/splat.c3t deleted file mode 100644 index 3a7bd0ddb..000000000 --- a/test/test_suite14/functions/splat.c3t +++ /dev/null @@ -1,69 +0,0 @@ -// #target: macos-x64 -module splat; - -extern fn int sum_us(int... x); - -fn void test() -{ - sum_us(1, 2, 3); - int[3] x = { 1, 2, 3 }; - int[] z = &x; - sum_us(...x); - sum_us(...z); - sum_us(); -} - -/* #expect: splat.ll - - %varargslots = alloca [3 x i32], align 4 - %taddr = alloca %"int[]", align 8 - %x = alloca [3 x i32], align 4 - %z = alloca %"int[]", align 8 - %taddr1 = alloca %"int[]", align 8 - %taddr6 = alloca %"int[]", align 8 - %0 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 0 - store i32 1, i32* %0, align 4 - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 1 - store i32 2, i32* %1, align 4 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 2 - store i32 3, i32* %2, align 4 - %3 = bitcast [3 x i32]* %varargslots to i32* - %4 = insertvalue %"int[]" undef, i32* %3, 0 - %5 = insertvalue %"int[]" %4, i64 3, 1 - store %"int[]" %5, %"int[]"* %taddr, align 8 - %6 = bitcast %"int[]"* %taddr to { i8*, i64 }* - %7 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %6, i32 0, i32 0 - %lo = load i8*, i8** %7, align 8 - %8 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %6, i32 0, i32 1 - %hi = load i64, i64* %8, align 8 - %9 = call i32 @sum_us(i8* %lo, i64 %hi) - %10 = bitcast [3 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %10, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %11 = bitcast [3 x i32]* %x to i32* - %12 = insertvalue %"int[]" undef, i32* %11, 0 - %13 = insertvalue %"int[]" %12, i64 3, 1 - store %"int[]" %13, %"int[]"* %z, align 8 - %14 = bitcast [3 x i32]* %x to i32* - %15 = insertvalue %"int[]" undef, i32* %14, 0 - %16 = insertvalue %"int[]" %15, i64 3, 1 - store %"int[]" %16, %"int[]"* %taddr1, align 8 - %17 = bitcast %"int[]"* %taddr1 to { i8*, i64 }* - %18 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 0 - %lo2 = load i8*, i8** %18, align 8 - %19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 1 - %hi3 = load i64, i64* %19, align 8 - %20 = call i32 @sum_us(i8* %lo2, i64 %hi3) - %21 = bitcast %"int[]"* %z to { i8*, i64 }* - %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 0 - %lo4 = load i8*, i8** %22, align 8 - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %21, i32 0, i32 1 - %hi5 = load i64, i64* %23, align 8 - %24 = call i32 @sum_us(i8* %lo4, i64 %hi5) - store %"int[]" zeroinitializer, %"int[]"* %taddr6, align 8 - %25 = bitcast %"int[]"* %taddr6 to { i8*, i64 }* - %26 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %25, i32 0, i32 0 - %lo7 = load i8*, i8** %26, align 8 - %27 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %25, i32 0, i32 1 - %hi8 = load i64, i64* %27, align 8 - %28 = call i32 @sum_us(i8* %lo7, i64 %hi8) - ret void diff --git a/test/test_suite14/functions/splat_aarch64.c3t b/test/test_suite14/functions/splat_aarch64.c3t deleted file mode 100644 index 42a088556..000000000 --- a/test/test_suite14/functions/splat_aarch64.c3t +++ /dev/null @@ -1,64 +0,0 @@ -// #target: linux-aarch64 -module splat; - -extern fn int sum_us(int... x); - -fn void test() -{ - sum_us(1, 2, 3); - int[3] x = { 1, 2, 3 }; - int[] z = &x; - sum_us(...x); - sum_us(...z); - sum_us(); -} - -/* #expect: splat.ll - -%"int[]" = type { i32*, i64 } - -declare i32 @sum_us([2 x i64]) #0 - -define void @splat_test() #0 { -entry: - %varargslots = alloca [3 x i32], align 4 - %taddr = alloca %"int[]", align 8 - %x = alloca [3 x i32], align 4 - %z = alloca %"int[]", align 8 - %taddr1 = alloca %"int[]", align 8 - %taddr2 = alloca %"int[]", align 8 - %0 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 0 - store i32 1, i32* %0, align 4 - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 1 - store i32 2, i32* %1, align 4 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 2 - store i32 3, i32* %2, align 4 - %3 = bitcast [3 x i32]* %varargslots to i32* - %4 = insertvalue %"int[]" undef, i32* %3, 0 - %5 = insertvalue %"int[]" %4, i64 3, 1 - store %"int[]" %5, %"int[]"* %taddr, align 8 - %6 = bitcast %"int[]"* %taddr to [2 x i64]* - %7 = load [2 x i64], [2 x i64]* %6, align 8 - %8 = call i32 @sum_us([2 x i64] %7) - %9 = bitcast [3 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %9, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %10 = bitcast [3 x i32]* %x to i32* - %11 = insertvalue %"int[]" undef, i32* %10, 0 - %12 = insertvalue %"int[]" %11, i64 3, 1 - store %"int[]" %12, %"int[]"* %z, align 8 - %13 = bitcast [3 x i32]* %x to i32* - %14 = insertvalue %"int[]" undef, i32* %13, 0 - %15 = insertvalue %"int[]" %14, i64 3, 1 - store %"int[]" %15, %"int[]"* %taddr1, align 8 - %16 = bitcast %"int[]"* %taddr1 to [2 x i64]* - %17 = load [2 x i64], [2 x i64]* %16, align 8 - %18 = call i32 @sum_us([2 x i64] %17) - %19 = bitcast %"int[]"* %z to [2 x i64]* - %20 = load [2 x i64], [2 x i64]* %19, align 8 - %21 = call i32 @sum_us([2 x i64] %20) - store %"int[]" zeroinitializer, %"int[]"* %taddr2, align 8 - %22 = bitcast %"int[]"* %taddr2 to [2 x i64]* - %23 = load [2 x i64], [2 x i64]* %22, align 8 - %24 = call i32 @sum_us([2 x i64] %23) - ret void -} diff --git a/test/test_suite14/functions/splat_mingw.c3t b/test/test_suite14/functions/splat_mingw.c3t deleted file mode 100644 index 2e630a581..000000000 --- a/test/test_suite14/functions/splat_mingw.c3t +++ /dev/null @@ -1,55 +0,0 @@ -// #target: mingw-x64 -module splat; - -extern fn int sum_us(int... x); - -fn void test() -{ - sum_us(1, 2, 3); - int[3] x = { 1, 2, 3 }; - int[] z = &x; - sum_us(...x); - sum_us(...z); - sum_us(); -} - -/* #expect: splat.ll - -declare i32 @sum_us(%"int[]"* align 8) #0 - - %varargslots = alloca [3 x i32], align 4 - %indirectarg = alloca %"int[]", align 8 - %x = alloca [3 x i32], align 4 - %z = alloca %"int[]", align 8 - %indirectarg1 = alloca %"int[]", align 8 - %indirectarg2 = alloca %"int[]", align 8 - %indirectarg3 = alloca %"int[]", align 8 - %0 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 0 - store i32 1, i32* %0, align 4 - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 1 - store i32 2, i32* %1, align 4 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %varargslots, i64 0, i64 2 - store i32 3, i32* %2, align 4 - %3 = bitcast [3 x i32]* %varargslots to i32* - %4 = insertvalue %"int[]" undef, i32* %3, 0 - %5 = insertvalue %"int[]" %4, i64 3, 1 - store %"int[]" %5, %"int[]"* %indirectarg, align 8 - %6 = call i32 @sum_us(%"int[]"* align 8 %indirectarg) - %7 = bitcast [3 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %8 = bitcast [3 x i32]* %x to i32* - %9 = insertvalue %"int[]" undef, i32* %8, 0 - %10 = insertvalue %"int[]" %9, i64 3, 1 - store %"int[]" %10, %"int[]"* %z, align 8 - %11 = bitcast [3 x i32]* %x to i32* - %12 = insertvalue %"int[]" undef, i32* %11, 0 - %13 = insertvalue %"int[]" %12, i64 3, 1 - store %"int[]" %13, %"int[]"* %indirectarg1, align 8 - %14 = call i32 @sum_us(%"int[]"* align 8 %indirectarg1) - %15 = bitcast %"int[]"* %indirectarg2 to i8* - %16 = bitcast %"int[]"* %z to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %15, i8* align 8 %16, i32 16, i1 false) - %17 = call i32 @sum_us(%"int[]"* align 8 %indirectarg2) - store %"int[]" zeroinitializer, %"int[]"* %indirectarg3, align 8 - %18 = call i32 @sum_us(%"int[]"* align 8 %indirectarg3) - ret void diff --git a/test/test_suite14/functions/static_vars.c3t b/test/test_suite14/functions/static_vars.c3t deleted file mode 100644 index 3c164b321..000000000 --- a/test/test_suite14/functions/static_vars.c3t +++ /dev/null @@ -1,23 +0,0 @@ -module foo; - -fn int test() -{ - static int x = 1; - tlocal int y = 2; - x++; - return x; -} - -/* #expect: foo.ll - -@"test$x" = internal unnamed_addr global i32 1, align 4 -@"test$y" = internal thread_local(localdynamic) unnamed_addr global i32 2, align 4 - -define i32 @foo_test() #0 { -entry: - %0 = load i32, i32* @"test$x", align 4 - %add = add i32 %0, 1 - store i32 %add, i32* @"test$x", align 4 - %1 = load i32, i32* @"test$x", align 4 - ret i32 %1 -} diff --git a/test/test_suite14/functions/test_regression.c3t b/test/test_suite14/functions/test_regression.c3t deleted file mode 100644 index 51584818d..000000000 --- a/test/test_suite14/functions/test_regression.c3t +++ /dev/null @@ -1,691 +0,0 @@ -// #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; -define oopsDouble = test2::argh; -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; -define getValueDouble = test2::getValue; -define IntBlob = test2::Blob; -define DoubleBlob = Blob; -define getMultInt = test2::getMult; -define getMultDouble = test2::getMult; - -define IntArray = List; -define IntList = LinkedList; - -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; - -fn void hello() -{ - printf("Hello baby\n"); - printf("Mult %f\n", doubleMult(11.1)); -} - -module foo ; - -fn Type check(Type i) -{ - return i * i; -} - -module test2 ; - -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 { i32*, i64 } -%LinkedList = type { i64, %Node*, %Node* } -%Node = type { %Node*, %Node*, i32 } -%List = type { i64, i64, %Allocator*, i32* } -%Allocator = type { i64 (i8**, %Allocator*, i64, i64, i64, i8*, i32)* } -%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 (%.introspect* @"ct$int" to i64), i64 3, [3 x %"char[]"] [%"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.enum.0, i64 0, i64 0), i64 4 }, %"char[]" { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.enum.1, i64 0, i64 0), i64 5 }, %"char[]" { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.enum.2, i64 0, i64 0), i64 3 }] }, align 8 - -define void @test_Foo2_printme(%Foo2* %0) #0 { -entry: - %1 = getelementptr inbounds %Foo2, %Foo2* %0, i32 0, i32 0 - %2 = load i32, i32* %1, align 4 - %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.21, i32 0, i32 0), i32 %2) - ret void -} - -; Function Attrs: nounwind -define i32 @test_Foo2_mutate(%Foo2* %0) #0 { -entry: - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i32 0, i32 0)) - %2 = getelementptr inbounds %Foo2, %Foo2* %0, i32 0, i32 0 - %3 = load i32, i32* %2, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %2, align 4 - ret i32 %add -} - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define void @test_helloWorld() #0 { -entry: - %0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0)) - ret void -} - -; Function Attrs: nounwind -define i32 @test_test_static() #0 { -entry: - %0 = load i32, i32* @"test_static$x", align 4 - %add = add i32 %0, 1 - store i32 %add, i32* @"test_static$x", align 4 - %1 = load i32, i32* @"test_static$x", align 4 - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i32 %1) - %3 = load i32, i32* @"test_static$x", align 4 - ret i32 %3 -} - -; Function Attrs: nounwind -define i32 @test_helo(double %0, %Bobo* byval(%Bobo) align 8 %1) #0 { -entry: - %de = alloca [3 x i32], align 4 - %c = alloca %Bobo, align 4 - %indirectarg = alloca %Bobo, align 8 - %2 = bitcast [3 x i32]* %de to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %3 = bitcast %Bobo* %c to i8* - %4 = bitcast %Bobo* %1 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) - %5 = bitcast %Bobo* %indirectarg to i8* - %6 = bitcast %Bobo* %c to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %5, i8* align 4 %6, i32 20, i1 false) - %7 = call i32 @test_helo(double 1.000000e+00, %Bobo* 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, i32* %a, align 4 - %2 = load i32, i32* %a, align 4 - %ashr = ashr i32 %2, %1 - %3 = freeze i32 %ashr - store i32 %3, i32* %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, i32* %a, align 4 - ret i32 %4 -} - -; Function Attrs: nounwind -define i32 @test_sum_us(i8* %0, i64 %1) #0 { -entry: - %x = alloca %"int[]", align 8 - %sum = alloca i32, align 4 - %taddr = alloca %"int[]", align 8 - %pair = bitcast %"int[]"* %x to { i8*, i64 }* - %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %2, align 8 - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - store i32 0, i32* %sum, align 4 - %4 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 1 - %5 = load i64, i64* %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, i32* %sum, align 4 - %7 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 0 - %8 = load i32*, i32** %7, align 8 - %ptroffset = getelementptr inbounds i32, i32* %8, i64 0 - %9 = load i32, i32* %ptroffset, align 4 - %10 = load %"int[]", %"int[]"* %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, i32* %11, i64 1 - %14 = insertvalue %"int[]" undef, i32* %ptroffset1, 0 - %15 = insertvalue %"int[]" %14, i64 %size, 1 - store %"int[]" %15, %"int[]"* %taddr, align 8 - %16 = bitcast %"int[]"* %taddr to { i8*, i64 }* - %17 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %16, i32 0, i32 0 - %lo = load i8*, i8** %17, align 8 - %18 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %16, i32 0, i32 1 - %hi = load i64, i64* %18, align 8 - %19 = call i32 @test_sum_us(i8* %lo, i64 %hi) - %add = add i32 %9, %19 - %add2 = add i32 %6, %add - store i32 %add2, i32* %sum, align 4 - %20 = load i32, i32* %sum, align 4 - ret i32 %20 -} - -; Function Attrs: nounwind -define i32 @test_sumd(i8* %0, i64 %1) #0 { -entry: - %x = alloca %"int[]", align 8 - %sum = alloca i32, align 4 - %i = alloca i32, align 4 - %pair = bitcast %"int[]"* %x to { i8*, i64 }* - %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %2, align 8 - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - store i32 0, i32* %sum, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %4 = load i32, i32* %i, align 4 - %sisiext = sext i32 %4 to i64 - %5 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 1 - %6 = load i64, i64* %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, i32* %sum, align 4 - %8 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 0 - %9 = load i32*, i32** %8, align 8 - %10 = load i32, i32* %i, align 4 - %sisiext1 = sext i32 %10 to i64 - %ptroffset = getelementptr inbounds i32, i32* %9, i64 %sisiext1 - %11 = load i32, i32* %ptroffset, align 4 - %add = add i32 %7, %11 - store i32 %add, i32* %sum, align 4 - %12 = load i32, i32* %i, align 4 - %add2 = add i32 %12, 1 - store i32 %add2, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %13 = load i32, i32* %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 - %ddx = alloca %Foo, align 4 - %fro = alloca i32, align 4 - %x = alloca [4 x i32], align 16 - %taddr = alloca %"int[]", align 8 - %z = alloca %"int[]", align 8 - %de = alloca [3 x i32], align 4 - %taddr10 = alloca %"int[]", align 8 - %varargslots = alloca [4 x i32], align 16 - %taddr15 = alloca %"int[]", align 8 - %varargslots18 = alloca [1 x i32], align 4 - %taddr19 = alloca %"int[]", align 8 - %taddr22 = alloca %"int[]", align 8 - %a1 = alloca i32 (double, %Bobo*)*, align 8 - %b2 = alloca i32 (double, %Bobo*)*, 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() - %3 = bitcast %LinkedList* %list to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %3, i8 0, i64 24, i1 false) - call void @"std_array_linkedlist$$int_LinkedList_push"(%LinkedList* %list, i32 10) - call void @"std_array_linkedlist$$int_LinkedList_push"(%LinkedList* %list, i32 15) - call void @"std_array_linkedlist$$int_LinkedList_push"(%LinkedList* %list, i32 30) - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %4 = load i32, i32* %i, align 4 - %5 = call i64 @"std_array_linkedlist$$int_LinkedList_len"(%LinkedList* %list) #3 - %uisitrunc = trunc i64 %5 to i32 - %lt = icmp slt i32 %4, %uisitrunc - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %6 = load i32, i32* %i, align 4 - %7 = load i32, i32* %i, align 4 - %siuiext = sext i32 %7 to i64 - %8 = call i32 @"std_array_linkedlist$$int_LinkedList_get"(%LinkedList* %list, i64 %siuiext) - %9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i32 0, i32 0), i32 %6, i32 %8) - %10 = load i32, i32* %i, align 4 - %add = add i32 %10, 1 - store i32 %add, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - call void @"std_array_linkedlist$$int_LinkedList_free"(%LinkedList* %list) - %11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0), i32 3) - store i32 3, i32* %elements, align 4 - %12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0)) - %13 = bitcast %List* %array to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %13, i8 0, i64 32, i1 false) - call void @"std_array_list$$int_List_append"(%List* %array, i32 100) - call void @"std_array_list$$int_List_append"(%List* %array, i32 200) - call void @"std_array_list$$int_List_append"(%List* %array, i32 400) - call void @"std_array_list$$int_List_push"(%List* %array, i32 600) #3 - call void @"std_array_list$$int_List_insert_at"(%List* %array, i64 2, i32 300) - store i32 0, i32* %i1, align 4 - br label %loop.cond2 - -loop.cond2: ; preds = %loop.body5, %loop.exit - %14 = load i32, i32* %i1, align 4 - %15 = call i64 @"std_array_list$$int_List_len"(%List* %array) - %uisitrunc3 = trunc i64 %15 to i32 - %lt4 = icmp slt i32 %14, %uisitrunc3 - br i1 %lt4, label %loop.body5, label %loop.exit8 - -loop.body5: ; preds = %loop.cond2 - %16 = load i32, i32* %i1, align 4 - %17 = load i32, i32* %i1, align 4 - %siuiext6 = sext i32 %17 to i64 - %18 = call i32 @"std_array_list$$int_List_get"(%List* %array, i64 %siuiext6) - %19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i32 0, i32 0), i32 %16, i32 %18) - %20 = load i32, i32* %i1, align 4 - %add7 = add i32 %20, 1 - store i32 %add7, i32* %i1, align 4 - br label %loop.cond2 - -loop.exit8: ; preds = %loop.cond2 - call void @"std_array_list$$int_List_free"(%List* %array) - %21 = bitcast %Blob* %a to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %21, i8* align 4 bitcast (%Blob* @.__const.6 to i8*), i32 4, i1 false) - %22 = bitcast %Blob.0* %b to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %22, i8* align 8 bitcast (%Blob.0* @.__const.7 to i8*), i32 8, i1 false) - %23 = getelementptr inbounds %Blob, %Blob* %a, i32 0, i32 0 - %24 = load i32, i32* %23, align 4 - %25 = call i32 @"test2$$int_getValue"(i32 %24) - %26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i32 0, i32 0), i32 %25) - %27 = getelementptr inbounds %Blob.0, %Blob.0* %b, i32 0, i32 0 - %28 = load double, double* %27, align 8 - %29 = call double @"test2$$double_getValue"(double %28) - %30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), double %29) - %31 = call i32 @"test2$$int_getMult"(i32 25) - %32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i32 0, i32 0), i32 %31) - %33 = call double @"test2$$double_getMult"(double 3.300000e+00) - %34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i32 0, i32 0), double %33) - call void @test_helloWorld() - %35 = getelementptr inbounds %Foo, %Foo* %ddx, i32 0, i32 0 - store i32 0, i32* %35, align 4 - %36 = getelementptr inbounds %Foo, %Foo* %ddx, i32 0, i32 1 - store i32 0, i32* %36, align 4 - store i32 3, i32* %fro, align 4 - %37 = bitcast [4 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %37, i8* align 16 bitcast ([4 x i32]* @.__const.12 to i8*), i32 16, i1 false) - %38 = load i32, i32* %fro, align 4 - %39 = bitcast [4 x i32]* %x to i32* - %40 = insertvalue %"int[]" undef, i32* %39, 0 - %41 = insertvalue %"int[]" %40, i64 4, 1 - store %"int[]" %41, %"int[]"* %taddr, align 8 - %42 = bitcast %"int[]"* %taddr to { i8*, i64 }* - %43 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %42, i32 0, i32 0 - %lo = load i8*, i8** %43, align 8 - %44 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %42, i32 0, i32 1 - %hi = load i64, i64* %44, align 8 - %45 = call i32 @test_sum_us(i8* %lo, i64 %hi) - %46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i32 0, i32 0), i32 %45) - %add9 = add i32 %38, %46 - store i32 %add9, i32* %fro, align 4 - %47 = load i32, i32* %fro, align 4 - %48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i32 %47) - %49 = bitcast [4 x i32]* %x to i32* - %50 = insertvalue %"int[]" undef, i32* %49, 0 - %51 = insertvalue %"int[]" %50, i64 4, 1 - store %"int[]" %51, %"int[]"* %z, align 8 - %52 = bitcast [3 x i32]* %de to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %52, i8* align 4 bitcast ([3 x i32]* @.__const.15 to i8*), i32 12, i1 false) - %53 = bitcast [4 x i32]* %x to i32* - %54 = insertvalue %"int[]" undef, i32* %53, 0 - %55 = insertvalue %"int[]" %54, i64 4, 1 - store %"int[]" %55, %"int[]"* %taddr10, align 8 - %56 = bitcast %"int[]"* %taddr10 to { i8*, i64 }* - %57 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %56, i32 0, i32 0 - %lo11 = load i8*, i8** %57, align 8 - %58 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %56, i32 0, i32 1 - %hi12 = load i64, i64* %58, align 8 - %59 = call i32 @test_sum_us(i8* %lo11, i64 %hi12) - %60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i32 0, i32 0), i32 %59) - %61 = bitcast %"int[]"* %z to { i8*, i64 }* - %62 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %61, i32 0, i32 0 - %lo13 = load i8*, i8** %62, align 8 - %63 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %61, i32 0, i32 1 - %hi14 = load i64, i64* %63, align 8 - %64 = call i32 @test_sum_us(i8* %lo13, i64 %hi14) - %65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.17, i32 0, i32 0), i32 %64) - %66 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 0 - store i32 1, i32* %66, align 4 - %67 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 1 - store i32 2, i32* %67, align 4 - %68 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 2 - store i32 4, i32* %68, align 4 - %69 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 3 - store i32 5, i32* %69, align 4 - %70 = bitcast [4 x i32]* %varargslots to i32* - %71 = insertvalue %"int[]" undef, i32* %70, 0 - %72 = insertvalue %"int[]" %71, i64 4, 1 - store %"int[]" %72, %"int[]"* %taddr15, align 8 - %73 = bitcast %"int[]"* %taddr15 to { i8*, i64 }* - %74 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %73, i32 0, i32 0 - %lo16 = load i8*, i8** %74, align 8 - %75 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %73, i32 0, i32 1 - %hi17 = load i64, i64* %75, align 8 - %76 = call i32 @test_sum_us(i8* %lo16, i64 %hi17) - %77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i32 0, i32 0), i32 %76) - %78 = getelementptr inbounds [1 x i32], [1 x i32]* %varargslots18, i64 0, i64 0 - store i32 1, i32* %78, align 4 - %79 = bitcast [1 x i32]* %varargslots18 to i32* - %80 = insertvalue %"int[]" undef, i32* %79, 0 - %81 = insertvalue %"int[]" %80, i64 1, 1 - store %"int[]" %81, %"int[]"* %taddr19, align 8 - %82 = bitcast %"int[]"* %taddr19 to { i8*, i64 }* - %83 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %82, i32 0, i32 0 - %lo20 = load i8*, i8** %83, align 8 - %84 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %82, i32 0, i32 1 - %hi21 = load i64, i64* %84, align 8 - %85 = call i32 @test_sum_us(i8* %lo20, i64 %hi21) - %86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i32 0, i32 0), i32 %85) - store %"int[]" zeroinitializer, %"int[]"* %taddr22, align 8 - %87 = bitcast %"int[]"* %taddr22 to { i8*, i64 }* - %88 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %87, i32 0, i32 0 - %lo23 = load i8*, i8** %88, align 8 - %89 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %87, i32 0, i32 1 - %hi24 = load i64, i64* %89, align 8 - %90 = call i32 @test_sum_us(i8* %lo23, i64 %hi24) - %91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i32 0, i32 0), i32 %90) - store i32 (double, %Bobo*)* null, i32 (double, %Bobo*)** %a1, align 8 - store i32 (double, %Bobo*)* null, i32 (double, %Bobo*)** %b2, align 8 - ret void -} - -// #expect: hello_world.ll - -define void @hello_world_hello() -entry: - %0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0)) - %1 = call double @"foo$$double_check"(double 1.110000e+01) - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), 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, %Blob* %blob, i32 0, i32 0 - store i32 %0, i32* %1, align 4 - %2 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0 - %3 = load i32, i32* %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, %Blob* %blob, i32 0, i32 0 - store double %0, double* %1, align 8 - %2 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0 - %3 = load double, double* %2, align 8 - ret double %3 \ No newline at end of file diff --git a/test/test_suite14/functions/test_regression_mingw.c3t b/test/test_suite14/functions/test_regression_mingw.c3t deleted file mode 100644 index 06ea0e5df..000000000 --- a/test/test_suite14/functions/test_regression_mingw.c3t +++ /dev/null @@ -1,728 +0,0 @@ -// #target: mingw-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; -define oopsDouble = test2::argh; -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; -define getValueDouble = test2::getValue; -define IntBlob = test2::Blob; -define DoubleBlob = Blob; -define getMultInt = test2::getMult; -define getMultDouble = test2::getMult; - -define IntArray = List; -define IntList = LinkedList; - -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; - -fn void hello() -{ - printf("Hello baby\n"); - printf("Mult %f\n", doubleMult(11.1)); -} - -module foo ; - -fn Type check(Type i) -{ - return i * i; -} - -module test2 ; - -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 { i32*, i64 } -%LinkedList = type { i64, %Node*, %Node* } -%Node = type { %Node*, %Node*, i32 } -%List = type { i64, i64, %Allocator*, i32* } -%Foo = type { i32, i32 } - -$"ct$test_Bobo" = comdat any - -$"ct$test_Blob" = comdat any - -$"ct$test_Foor" = comdat any - -$"ct$test_Foo2" = comdat any - -$"ct$test_Foo" = comdat any - -$"ct$int" = comdat any - -$"ct$test_MyEnum" = comdat any - -@"ct$test_Bobo" = linkonce constant %.introspect { i8 10, i64 20, i64 0, i64 6, [0 x i64] zeroinitializer }, comdat, align 8 -@"ct$test_Blob" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, comdat, align 8 -@"ct$test_Foor" = linkonce constant %.introspect { i8 11, i64 16, i64 0, i64 2, [0 x i64] zeroinitializer }, comdat, align 8 -@"ct$test_Foo2" = linkonce constant %.introspect { i8 10, i64 4, i64 0, i64 1, [0 x i64] zeroinitializer }, comdat, align 8 -@"ct$test_Foo" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, comdat, align 8 -@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, comdat, align 8 -@"ct$test_MyEnum" = linkonce constant { i8, i64, i64, i64, [3 x %"char[]"] } { i8 8, i64 4, i64 ptrtoint (%.introspect* @"ct$int" to i64), i64 3, [3 x %"char[]"] [%"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.enum.0, i64 0, i64 0), i64 4 }, %"char[]" { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.enum.1, i64 0, i64 0), i64 5 }, %"char[]" { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.enum.2, i64 0, i64 0), i64 3 }] }, comdat, align 8 -@.str = private unnamed_addr constant [13 x i8] c"helloWorld!\0A\00", align 1 -@"test_static$x" = internal unnamed_addr global i32 1, align 4 -@.str.1 = private unnamed_addr constant [16 x i8] c"Test static %d\0A\00", align 1 -@.__const = private unnamed_addr constant [3 x i32] [i32 1, i32 2, i32 3], align 4 -@.str.2 = private unnamed_addr constant [17 x i8] c"Element[%d]: %d\0A\00", align 1 -@.str.3 = private unnamed_addr constant [14 x i8] c"Elements: %d\0A\00", align 1 -@.str.4 = private unnamed_addr constant [7 x i8] c"Hello\0A\00", align 1 -@.str.5 = private unnamed_addr constant [17 x i8] c"Element[%d]: %d\0A\00", align 1 -@.__const.6 = private unnamed_addr constant %Blob { i32 42 }, align 4 -@.__const.7 = private unnamed_addr constant %Blob.0 { double 3.330000e+01 }, align 8 -@.str.8 = private unnamed_addr constant [10 x i8] c"a was %d\0A\00", align 1 -@.str.9 = private unnamed_addr constant [10 x i8] c"b was %f\0A\00", align 1 -@.str.10 = private unnamed_addr constant [17 x i8] c"Mult int was %d\0A\00", align 1 -@.str.11 = private unnamed_addr constant [20 x i8] c"Mult double was %f\0A\00", align 1 -@.__const.12 = private unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 3], align 16 -@.str.13 = private unnamed_addr constant [20 x i8] c"1Vararg4splatA: %d\0A\00", align 1 -@.str.14 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 -@.__const.15 = private unnamed_addr constant [3 x i32] [i32 1, i32 2, i32 3], align 4 -@.str.16 = private unnamed_addr constant [19 x i8] c"Vararg4splatB: %d\0A\00", align 1 -@.str.17 = private unnamed_addr constant [19 x i8] c"Vararg4splatC: %d\0A\00", align 1 -@.str.18 = private unnamed_addr constant [13 x i8] c"Vararg4: %d\0A\00", align 1 -@.str.19 = private unnamed_addr constant [13 x i8] c"Vararg1: %d\0A\00", align 1 -@.str.20 = private unnamed_addr constant [13 x i8] c"Vararg0: %d\0A\00", align 1 -@.str.21 = private unnamed_addr constant [12 x i8] c"Foo is: %d\0A\00", align 1 -@.str.22 = private unnamed_addr constant [9 x i8] c"Mutating\00", align 1 - -; Function Attrs: nounwind -define void @test_Foo2_printme(%Foo2* %0) #0 { -entry: - %1 = getelementptr inbounds %Foo2, %Foo2* %0, i32 0, i32 0 - %2 = load i32, i32* %1, align 4 - %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.21, i32 0, i32 0), i32 %2) - ret void -} - -; Function Attrs: nounwind -define i32 @test_Foo2_mutate(%Foo2* %0) #0 { -entry: - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i32 0, i32 0)) - %2 = getelementptr inbounds %Foo2, %Foo2* %0, i32 0, i32 0 - %3 = load i32, i32* %2, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %2, align 4 - ret i32 %add -} - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define void @test_helloWorld() #0 { -entry: - %0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0)) - ret void -} - -; Function Attrs: nounwind -define i32 @test_test_static() #0 { -entry: - %0 = load i32, i32* @"test_static$x", align 4 - %add = add i32 %0, 1 - store i32 %add, i32* @"test_static$x", align 4 - %1 = load i32, i32* @"test_static$x", align 4 - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i32 %1) - %3 = load i32, i32* @"test_static$x", align 4 - ret i32 %3 -} - -; Function Attrs: nounwind -define i32 @test_helo(double %0, %Bobo* align 4 %1) #0 { -entry: - %de = alloca [3 x i32], align 4 - %c = alloca %Bobo, align 4 - %indirectarg = alloca %Bobo, align 4 - %2 = bitcast [3 x i32]* %de to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %3 = bitcast %Bobo* %c to i8* - %4 = bitcast %Bobo* %1 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 20, i1 false) - %5 = bitcast %Bobo* %indirectarg to i8* - %6 = bitcast %Bobo* %c to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false) - %7 = call i32 @test_helo(double 1.000000e+00, %Bobo* align 4 %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, i32* %a, align 4 - %2 = load i32, i32* %a, align 4 - %ashr = ashr i32 %2, %1 - %3 = freeze i32 %ashr - store i32 %3, i32* %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, i32* %a, align 4 - ret i32 %4 -} - -; Function Attrs: nounwind -define i32 @test_sum_us(%"int[]"* align 8 %0) #0 { -entry: - %sum = alloca i32, align 4 - %indirectarg = alloca %"int[]", align 8 - store i32 0, i32* %sum, align 4 - %1 = getelementptr inbounds %"int[]", %"int[]"* %0, i32 0, i32 1 - %2 = load i64, i64* %1, align 8 - %eq = icmp eq i64 0, %2 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - ret i32 0 - -if.exit: ; preds = %entry - %3 = load i32, i32* %sum, align 4 - %4 = getelementptr inbounds %"int[]", %"int[]"* %0, i32 0, i32 0 - %5 = load i32*, i32** %4, align 8 - %ptroffset = getelementptr inbounds i32, i32* %5, i64 0 - %6 = load i32, i32* %ptroffset, align 4 - %7 = load %"int[]", %"int[]"* %0, align 8 - %8 = extractvalue %"int[]" %7, 0 - %9 = extractvalue %"int[]" %7, 1 - %sub = sub i64 %9, 1 - %10 = add i64 %sub, 1 - %size = sub i64 %10, 1 - %ptroffset1 = getelementptr inbounds i32, i32* %8, i64 1 - %11 = insertvalue %"int[]" undef, i32* %ptroffset1, 0 - %12 = insertvalue %"int[]" %11, i64 %size, 1 - store %"int[]" %12, %"int[]"* %indirectarg, align 8 - %13 = call i32 @test_sum_us(%"int[]"* align 8 %indirectarg) - %add = add i32 %6, %13 - %add2 = add i32 %3, %add - store i32 %add2, i32* %sum, align 4 - %14 = load i32, i32* %sum, align 4 - ret i32 %14 -} - -; Function Attrs: nounwind -define i32 @test_sumd(%"int[]"* align 8 %0) #0 { -entry: - %sum = alloca i32, align 4 - %i = alloca i32, align 4 - store i32 0, i32* %sum, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %1 = load i32, i32* %i, align 4 - %sisiext = sext i32 %1 to i64 - %2 = getelementptr inbounds %"int[]", %"int[]"* %0, i32 0, i32 1 - %3 = load i64, i64* %2, align 8 - %lt = icmp slt i64 %sisiext, %3 - %check = icmp slt i64 %3, 0 - %siui-lt = or i1 %check, %lt - br i1 %siui-lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %4 = load i32, i32* %sum, align 4 - %5 = getelementptr inbounds %"int[]", %"int[]"* %0, i32 0, i32 0 - %6 = load i32*, i32** %5, align 8 - %7 = load i32, i32* %i, align 4 - %sisiext1 = sext i32 %7 to i64 - %ptroffset = getelementptr inbounds i32, i32* %6, i64 %sisiext1 - %8 = load i32, i32* %ptroffset, align 4 - %add = add i32 %4, %8 - store i32 %add, i32* %sum, align 4 - %9 = load i32, i32* %i, align 4 - %add2 = add i32 %9, 1 - store i32 %add2, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %10 = load i32, i32* %sum, align 4 - ret i32 %10 -} - -; 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 - %ddx = alloca %Foo, align 4 - %fro = alloca i32, align 4 - %x = alloca [4 x i32], align 16 - %indirectarg = alloca %"int[]", align 8 - %z = alloca %"int[]", align 8 - %de = alloca [3 x i32], align 4 - %indirectarg10 = alloca %"int[]", align 8 - %indirectarg11 = alloca %"int[]", align 8 - %varargslots = alloca [4 x i32], align 16 - %indirectarg12 = alloca %"int[]", align 8 - %varargslots13 = alloca [1 x i32], align 4 - %indirectarg14 = alloca %"int[]", align 8 - %indirectarg15 = alloca %"int[]", align 8 - %a1 = alloca i32 (double, %Bobo*)*, align 8 - %b2 = alloca i32 (double, %Bobo*)*, 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() - %3 = bitcast %LinkedList* %list to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %3, i8 0, i64 24, i1 false) - call void @"std_array_linkedlist$$int_LinkedList_push"(%LinkedList* %list, i32 10) - call void @"std_array_linkedlist$$int_LinkedList_push"(%LinkedList* %list, i32 15) - call void @"std_array_linkedlist$$int_LinkedList_push"(%LinkedList* %list, i32 30) - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %4 = load i32, i32* %i, align 4 - %5 = call i64 @"std_array_linkedlist$$int_LinkedList_len"(%LinkedList* %list) #3 - %uisitrunc = trunc i64 %5 to i32 - %lt = icmp slt i32 %4, %uisitrunc - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %6 = load i32, i32* %i, align 4 - %7 = load i32, i32* %i, align 4 - %siuiext = sext i32 %7 to i64 - %8 = call i32 @"std_array_linkedlist$$int_LinkedList_get"(%LinkedList* %list, i64 %siuiext) - %9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i32 0, i32 0), i32 %6, i32 %8) - %10 = load i32, i32* %i, align 4 - %add = add i32 %10, 1 - store i32 %add, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - call void @"std_array_linkedlist$$int_LinkedList_free"(%LinkedList* %list) - %11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0), i32 3) - store i32 3, i32* %elements, align 4 - %12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0)) - %13 = bitcast %List* %array to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %13, i8 0, i64 32, i1 false) - call void @"std_array_list$$int_List_append"(%List* %array, i32 100) - call void @"std_array_list$$int_List_append"(%List* %array, i32 200) - call void @"std_array_list$$int_List_append"(%List* %array, i32 400) - call void @"std_array_list$$int_List_push"(%List* %array, i32 600) #3 - call void @"std_array_list$$int_List_insert_at"(%List* %array, i64 2, i32 300) - store i32 0, i32* %i1, align 4 - br label %loop.cond2 - -loop.cond2: ; preds = %loop.body5, %loop.exit - %14 = load i32, i32* %i1, align 4 - %15 = call i64 @"std_array_list$$int_List_len"(%List* %array) - %uisitrunc3 = trunc i64 %15 to i32 - %lt4 = icmp slt i32 %14, %uisitrunc3 - br i1 %lt4, label %loop.body5, label %loop.exit8 - -loop.body5: ; preds = %loop.cond2 - %16 = load i32, i32* %i1, align 4 - %17 = load i32, i32* %i1, align 4 - %siuiext6 = sext i32 %17 to i64 - %18 = call i32 @"std_array_list$$int_List_get"(%List* %array, i64 %siuiext6) - %19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i32 0, i32 0), i32 %16, i32 %18) - %20 = load i32, i32* %i1, align 4 - %add7 = add i32 %20, 1 - store i32 %add7, i32* %i1, align 4 - br label %loop.cond2 - -loop.exit8: ; preds = %loop.cond2 - call void @"std_array_list$$int_List_free"(%List* %array) - %21 = bitcast %Blob* %a to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %21, i8* align 4 bitcast (%Blob* @.__const.6 to i8*), i32 4, i1 false) - %22 = bitcast %Blob.0* %b to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %22, i8* align 8 bitcast (%Blob.0* @.__const.7 to i8*), i32 8, i1 false) - %23 = getelementptr inbounds %Blob, %Blob* %a, i32 0, i32 0 - %24 = load i32, i32* %23, align 4 - %25 = call i32 @"test2$$int_getValue"(i32 %24) - %26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i32 0, i32 0), i32 %25) - %27 = getelementptr inbounds %Blob.0, %Blob.0* %b, i32 0, i32 0 - %28 = bitcast double* %27 to i64* - %29 = load i64, i64* %28, align 8 - %30 = call double @"test2$$double_getValue"(i64 %29) - %31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), double %30) - %32 = call i32 @"test2$$int_getMult"(i32 25) - %33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i32 0, i32 0), i32 %32) - %34 = call double @"test2$$double_getMult"(double 3.300000e+00) - %35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i32 0, i32 0), double %34) - call void @test_helloWorld() - %36 = getelementptr inbounds %Foo, %Foo* %ddx, i32 0, i32 0 - store i32 0, i32* %36, align 4 - %37 = getelementptr inbounds %Foo, %Foo* %ddx, i32 0, i32 1 - store i32 0, i32* %37, align 4 - store i32 3, i32* %fro, align 4 - %38 = bitcast [4 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %38, i8* align 16 bitcast ([4 x i32]* @.__const.12 to i8*), i32 16, i1 false) - %39 = load i32, i32* %fro, align 4 - %40 = bitcast [4 x i32]* %x to i32* - %41 = insertvalue %"int[]" undef, i32* %40, 0 - %42 = insertvalue %"int[]" %41, i64 4, 1 - store %"int[]" %42, %"int[]"* %indirectarg, align 8 - %43 = call i32 @test_sum_us(%"int[]"* align 8 %indirectarg) - %44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i32 0, i32 0), i32 %43) - %add9 = add i32 %39, %44 - store i32 %add9, i32* %fro, align 4 - %45 = load i32, i32* %fro, align 4 - %46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i32 %45) - %47 = bitcast [4 x i32]* %x to i32* - %48 = insertvalue %"int[]" undef, i32* %47, 0 - %49 = insertvalue %"int[]" %48, i64 4, 1 - store %"int[]" %49, %"int[]"* %z, align 8 - %50 = bitcast [3 x i32]* %de to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %50, i8* align 4 bitcast ([3 x i32]* @.__const.15 to i8*), i32 12, i1 false) - %51 = bitcast [4 x i32]* %x to i32* - %52 = insertvalue %"int[]" undef, i32* %51, 0 - %53 = insertvalue %"int[]" %52, i64 4, 1 - store %"int[]" %53, %"int[]"* %indirectarg10, align 8 - %54 = call i32 @test_sum_us(%"int[]"* align 8 %indirectarg10) - %55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i32 0, i32 0), i32 %54) - %56 = bitcast %"int[]"* %indirectarg11 to i8* - %57 = bitcast %"int[]"* %z to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %56, i8* align 8 %57, i32 16, i1 false) - %58 = call i32 @test_sum_us(%"int[]"* align 8 %indirectarg11) - %59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.17, i32 0, i32 0), i32 %58) - %60 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 0 - store i32 1, i32* %60, align 4 - %61 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 1 - store i32 2, i32* %61, align 4 - %62 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 2 - store i32 4, i32* %62, align 4 - %63 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 3 - store i32 5, i32* %63, align 4 - %64 = bitcast [4 x i32]* %varargslots to i32* - %65 = insertvalue %"int[]" undef, i32* %64, 0 - %66 = insertvalue %"int[]" %65, i64 4, 1 - store %"int[]" %66, %"int[]"* %indirectarg12, align 8 - %67 = call i32 @test_sum_us(%"int[]"* align 8 %indirectarg12) - %68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i32 0, i32 0), i32 %67) - %69 = getelementptr inbounds [1 x i32], [1 x i32]* %varargslots13, i64 0, i64 0 - store i32 1, i32* %69, align 4 - %70 = bitcast [1 x i32]* %varargslots13 to i32* - %71 = insertvalue %"int[]" undef, i32* %70, 0 - %72 = insertvalue %"int[]" %71, i64 1, 1 - store %"int[]" %72, %"int[]"* %indirectarg14, align 8 - %73 = call i32 @test_sum_us(%"int[]"* align 8 %indirectarg14) - %74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i32 0, i32 0), i32 %73) - store %"int[]" zeroinitializer, %"int[]"* %indirectarg15, align 8 - %75 = call i32 @test_sum_us(%"int[]"* align 8 %indirectarg15) - %76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i32 0, i32 0), i32 %75) - store i32 (double, %Bobo*)* null, i32 (double, %Bobo*)** %a1, align 8 - store i32 (double, %Bobo*)* null, i32 (double, %Bobo*)** %b2, align 8 - ret void -} - -declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 - -declare void @hello_world_hello() - -declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #2 - -declare void @"std_array_linkedlist$$int_LinkedList_push"(%LinkedList*, i32) - -declare i64 @"std_array_linkedlist$$int_LinkedList_len"(%LinkedList*) - -declare i32 @"std_array_linkedlist$$int_LinkedList_get"(%LinkedList*, i64) - -declare void @"std_array_linkedlist$$int_LinkedList_free"(%LinkedList*) - -declare void @"std_array_list$$int_List_append"(%List*, i32) - -declare void @"std_array_list$$int_List_push"(%List*, i32) - -declare void @"std_array_list$$int_List_insert_at"(%List*, i64, i32) - -declare i64 @"std_array_list$$int_List_len"(%List*) - -declare i32 @"std_array_list$$int_List_get"(%List*, i64) - -declare void @"std_array_list$$int_List_free"(%List*) - -declare i32 @"test2$$int_getValue"(i32) - -declare double @"test2$$double_getValue"(i64) - -declare i32 @"test2$$int_getMult"(i32) - -declare double @"test2$$double_getMult"(double) - - -// #expect: hello_world.ll - -define void @hello_world_hello() #0 { -entry: - %0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0)) - %1 = call double @"foo$$double_check"(double 1.110000e+01) - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), 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) -entry: - %mul = mul i32 %0, %0 - ret i32 %mul - -define i32 @"test2$$int_hello"() -entry: - ret i32 1 -} - -define i32 @"test2$$int_getValue"(i32 %0) -entry: - %blob = alloca %Blob, align 4 - %1 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0 - store i32 %0, i32* %1, align 4 - %2 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0 - %3 = load i32, i32* %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"(i64 %0) -entry: - %blob = alloca %Blob, align 8 - %1 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0 - %2 = bitcast double* %1 to i64* - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0 - %4 = load double, double* %3, align 8 - ret double %4 - diff --git a/test/test_suite14/functions/too_many_params.c3 b/test/test_suite14/functions/too_many_params.c3 deleted file mode 100644 index 1c63bfe6a..000000000 --- a/test/test_suite14/functions/too_many_params.c3 +++ /dev/null @@ -1,30 +0,0 @@ -import std::io; -define Tester = fn int(int x, int y, int z); - -fn int test1( - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // 20 - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // 100 - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // #error: The number of params exceeded the max of 127. To accept more arguments, consider using varargs - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int // 200 -) { return 1; } - -fn int test2( - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // 20 - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // 100 - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // #error: The number of params exceeded the max of 127. - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // - int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // 200 - int... x -) { return 1; } - diff --git a/test/test_suite14/functions/typeless_varargs.c3t b/test/test_suite14/functions/typeless_varargs.c3t deleted file mode 100644 index 98f7adef1..000000000 --- a/test/test_suite14/functions/typeless_varargs.c3t +++ /dev/null @@ -1,106 +0,0 @@ -// #target: macos-x64 - -module test; - -extern fn void printf(char*, ...); - -fn void retest(foo...) -{ - test(...foo); -} -fn void test(foo...) -{ - printf("Foo1 was: %d\n", *((int*)foo[0])); -} -fn int main() -{ - int i = 1; - test(1); - retest(1); - return 1; -} - -/* #expect: test.ll - -define void @test_retest(i8* %0, i64 %1) #0 { -entry: - %foo = alloca %"variant[]", align 8 - %pair = bitcast %"variant[]"* %foo to { i8*, i64 }* - %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %2, align 8 - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - %4 = bitcast %"variant[]"* %foo to { i8*, i64 }* - %5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %4, i32 0, i32 0 - %lo = load i8*, i8** %5, align 8 - %6 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %4, i32 0, i32 1 - %hi = load i64, i64* %6, align 8 - call void @test_test(i8* %lo, i64 %hi) - ret void -} - -; Function Attrs: nounwind -define void @test_test(i8* %0, i64 %1) #0 { -entry: - %foo = alloca %"variant[]", align 8 - %pair = bitcast %"variant[]"* %foo to { i8*, i64 }* - %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %2, align 8 - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - %4 = getelementptr inbounds %"variant[]", %"variant[]"* %foo, i32 0, i32 0 - %5 = load %variant*, %variant** %4, align 8 - %ptroffset = getelementptr inbounds %variant, %variant* %5, i64 0 - %6 = getelementptr inbounds %variant, %variant* %ptroffset, i32 0, i32 0 - %7 = bitcast i8** %6 to i32** - %8 = load i32*, i32** %7, align 8 - %9 = load i32, i32* %8, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i32 %9) - ret void -} - -; Function Attrs: nounwind -define i32 @main() #0 { -entry: - %i = alloca i32, align 4 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - %varargslots2 = alloca [1 x %variant], align 16 - %taddr3 = alloca i32, align 4 - %taddr4 = alloca %"variant[]", align 8 - store i32 1, i32* %i, align 4 - store i32 1, i32* %taddr, align 4 - %0 = bitcast i32* %taddr to i8* - %1 = insertvalue %variant undef, i8* %0, 0 - %2 = insertvalue %variant %1, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %3 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %2, %variant* %3, align 16 - %4 = bitcast [1 x %variant]* %varargslots to %variant* - %5 = insertvalue %"variant[]" undef, %variant* %4, 0 - %6 = insertvalue %"variant[]" %5, i64 1, 1 - store %"variant[]" %6, %"variant[]"* %taddr1, align 8 - %7 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %8 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %7, i32 0, i32 0 - %lo = load i8*, i8** %8, align 8 - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %7, i32 0, i32 1 - %hi = load i64, i64* %9, align 8 - call void @test_test(i8* %lo, i64 %hi) - store i32 1, i32* %taddr3, align 4 - %10 = bitcast i32* %taddr3 to i8* - %11 = insertvalue %variant undef, i8* %10, 0 - %12 = insertvalue %variant %11, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %13 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots2, i64 0, i64 0 - store %variant %12, %variant* %13, align 16 - %14 = bitcast [1 x %variant]* %varargslots2 to %variant* - %15 = insertvalue %"variant[]" undef, %variant* %14, 0 - %16 = insertvalue %"variant[]" %15, i64 1, 1 - store %"variant[]" %16, %"variant[]"* %taddr4, align 8 - %17 = bitcast %"variant[]"* %taddr4 to { i8*, i64 }* - %18 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 0 - %lo5 = load i8*, i8** %18, align 8 - %19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 1 - %hi6 = load i64, i64* %19, align 8 - call void @test_retest(i8* %lo5, i64 %hi6) - ret i32 1 -} diff --git a/test/test_suite14/functions/vararg_and_named_tests.c3 b/test/test_suite14/functions/vararg_and_named_tests.c3 deleted file mode 100644 index 1c4ee62c7..000000000 --- a/test/test_suite14/functions/vararg_and_named_tests.c3 +++ /dev/null @@ -1,53 +0,0 @@ -// #target: macos-x64 -module foo; - -extern fn void printf(char* format, ...); - -fn void test(int x, int... y, int z = 2) -{ -} - -fn void test2(int x, int... y, int z) -{ -} - -fn void a() -{ - test(.z = 32, 3); // #error: Named arguments must be placed after positional arguments -} - -fn void b() -{ - test(1, .x = 3); // #error: The parameter 'x' was already set. -} - -fn void c() -{ - test(1); -} - -fn void d() -{ - test2(1, .z = 3); - test2(1, 2, 3); // #error: Expected '.z = ...' after this argument -} - - -fn void single(int x) {} - -fn void e() -{ - single(); // #error: This call expected a parameter of type 'int' -} - -fn void multiple(int x, int y) {} - -fn void f() -{ - multiple(1); // #error: Expected 1 more argument after this one -} - -fn void g() -{ - multiple(); // #error: 'multiple' expects 2 parameters, but none was provided -} \ No newline at end of file diff --git a/test/test_suite14/functions/vararg_argument_fails.c3 b/test/test_suite14/functions/vararg_argument_fails.c3 deleted file mode 100644 index 1a7916389..000000000 --- a/test/test_suite14/functions/vararg_argument_fails.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void foo5(..., ...) {} // #error: Only a single variadic parameter is allowed - -fn void foo6(int ..., int ...) {} // #error: Only a single variadic parameter is allowed - -fn void foo7(int... x, int ... y) {} // #error: Only a single variadic parameter is allowed \ No newline at end of file diff --git a/test/test_suite14/functions/varargs.c3t b/test/test_suite14/functions/varargs.c3t deleted file mode 100644 index 75ac34113..000000000 --- a/test/test_suite14/functions/varargs.c3t +++ /dev/null @@ -1,38 +0,0 @@ -module varargs; - -extern fn void printf(char* c, ...); - -fn void test() -{ - printf("%d\n", true); - printf("%d\n", 123); - printf("%f\n", 12.3); - ichar x1 = -123; - bool b = false; - float z1 = 12.3; - printf("%d\n", b); - printf("%d\n", x1); - printf("%f\n", z1); -} - -// #expect: varargs.ll - - %x1 = alloca i8, align 1 - %b = alloca i8, align 1 - %z1 = alloca float, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 1) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 123) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), double 1.230000e+01) - store i8 -123, i8* %x1, align 1 - store i8 0, i8* %b, align 1 - store float 0x40289999A0000000, float* %z1, align 4 - %0 = load i8, i8* %b, align 1 - %1 = trunc i8 %0 to i1 - %boolsi = zext i1 %1 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 %boolsi) - %2 = load i8, i8* %x1, align 1 - %sisiext = sext i8 %2 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i32 %sisiext) - %3 = load float, float* %z1, align 4 - %fpfpext = fpext float %3 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), double %fpfpext) \ No newline at end of file diff --git a/test/test_suite14/functions/varargs_followed_by_named.c3t b/test/test_suite14/functions/varargs_followed_by_named.c3t deleted file mode 100644 index fdb21d683..000000000 --- a/test/test_suite14/functions/varargs_followed_by_named.c3t +++ /dev/null @@ -1,149 +0,0 @@ -// #target: macos-x64 -module foo; - -extern fn void printf(char* format, ...); - -fn void test(int x, int... y, int z = 2) -{ - printf("Got %d %d %d %d\n", x, (int)y.len, z, y[0]); -} -fn void test2(int x, y..., int z = 2) -{ - printf("Got %d %d %d\n", x, (int)y.len, z); -} - -fn void main() -{ - test(3, 4, 5, .z = 123); - test2(3, 4, 5, .z = 123); - test(3, 4, 5); - test2(3, 4, 5); -} - -/* #expect: foo.ll - - -define void @foo_test(i32 %0, i8* %1, i64 %2, i32 %3) #0 { -entry: - %y = alloca %"int[]", align 8 - %pair = bitcast %"int[]"* %y to { i8*, i64 }* - %4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %1, i8** %4, align 8 - %5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %2, i64* %5, align 8 - %6 = getelementptr inbounds %"int[]", %"int[]"* %y, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - %uisitrunc = trunc i64 %7 to i32 - %8 = getelementptr inbounds %"int[]", %"int[]"* %y, i32 0, i32 0 - %9 = load i32*, i32** %8, align 8 - %ptroffset = getelementptr inbounds i32, i32* %9, i64 0 - %10 = load i32, i32* %ptroffset, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i32 %0, i32 %uisitrunc, i32 %3, i32 %10) - ret void -} - -define void @foo_test2(i32 %0, i8* %1, i64 %2, i32 %3) #0 { -entry: - %y = alloca %"variant[]", align 8 - %pair = bitcast %"variant[]"* %y to { i8*, i64 }* - %4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %1, i8** %4, align 8 - %5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %2, i64* %5, align 8 - %6 = getelementptr inbounds %"variant[]", %"variant[]"* %y, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - %uisitrunc = trunc i64 %7 to i32 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i32 %0, i32 %uisitrunc, i32 %3) - ret void -} - -define void @foo_main() #0 { -entry: - %varargslots = alloca [2 x i32], align 4 - %taddr = alloca %"int[]", align 8 - %varargslots1 = alloca [2 x %variant], align 16 - %taddr2 = alloca i32, align 4 - %taddr3 = alloca i32, align 4 - %taddr4 = alloca %"variant[]", align 8 - %varargslots7 = alloca [2 x i32], align 4 - %taddr8 = alloca %"int[]", align 8 - %varargslots11 = alloca [2 x %variant], align 16 - %taddr12 = alloca i32, align 4 - %taddr13 = alloca i32, align 4 - %taddr14 = alloca %"variant[]", align 8 - %0 = getelementptr inbounds [2 x i32], [2 x i32]* %varargslots, i64 0, i64 0 - store i32 4, i32* %0, align 4 - %1 = getelementptr inbounds [2 x i32], [2 x i32]* %varargslots, i64 0, i64 1 - store i32 5, i32* %1, align 4 - %2 = bitcast [2 x i32]* %varargslots to i32* - %3 = insertvalue %"int[]" undef, i32* %2, 0 - %4 = insertvalue %"int[]" %3, i64 2, 1 - store %"int[]" %4, %"int[]"* %taddr, align 8 - %5 = bitcast %"int[]"* %taddr to { i8*, i64 }* - %6 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %5, i32 0, i32 0 - %lo = load i8*, i8** %6, align 8 - %7 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %5, i32 0, i32 1 - %hi = load i64, i64* %7, align 8 - call void @foo_test(i32 3, i8* %lo, i64 %hi, i32 123) - store i32 4, i32* %taddr2, align 4 - %8 = bitcast i32* %taddr2 to i8* - %9 = insertvalue %variant undef, i8* %8, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %11 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots1, i64 0, i64 0 - store %variant %10, %variant* %11, align 16 - store i32 5, i32* %taddr3, align 4 - %12 = bitcast i32* %taddr3 to i8* - %13 = insertvalue %variant undef, i8* %12, 0 - %14 = insertvalue %variant %13, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %15 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots1, i64 0, i64 1 - store %variant %14, %variant* %15, align 16 - %16 = bitcast [2 x %variant]* %varargslots1 to %variant* - %17 = insertvalue %"variant[]" undef, %variant* %16, 0 - %18 = insertvalue %"variant[]" %17, i64 2, 1 - store %"variant[]" %18, %"variant[]"* %taddr4, align 8 - %19 = bitcast %"variant[]"* %taddr4 to { i8*, i64 }* - %20 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %19, i32 0, i32 0 - %lo5 = load i8*, i8** %20, align 8 - %21 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %19, i32 0, i32 1 - %hi6 = load i64, i64* %21, align 8 - call void @foo_test2(i32 3, i8* %lo5, i64 %hi6, i32 123) - %22 = getelementptr inbounds [2 x i32], [2 x i32]* %varargslots7, i64 0, i64 0 - store i32 4, i32* %22, align 4 - %23 = getelementptr inbounds [2 x i32], [2 x i32]* %varargslots7, i64 0, i64 1 - store i32 5, i32* %23, align 4 - %24 = bitcast [2 x i32]* %varargslots7 to i32* - %25 = insertvalue %"int[]" undef, i32* %24, 0 - %26 = insertvalue %"int[]" %25, i64 2, 1 - store %"int[]" %26, %"int[]"* %taddr8, align 8 - %27 = bitcast %"int[]"* %taddr8 to { i8*, i64 }* - %28 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %27, i32 0, i32 0 - %lo9 = load i8*, i8** %28, align 8 - %29 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %27, i32 0, i32 1 - %hi10 = load i64, i64* %29, align 8 - call void @foo_test(i32 3, i8* %lo9, i64 %hi10, i32 2) - store i32 4, i32* %taddr12, align 4 - %30 = bitcast i32* %taddr12 to i8* - %31 = insertvalue %variant undef, i8* %30, 0 - %32 = insertvalue %variant %31, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %33 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots11, i64 0, i64 0 - store %variant %32, %variant* %33, align 16 - store i32 5, i32* %taddr13, align 4 - %34 = bitcast i32* %taddr13 to i8* - %35 = insertvalue %variant undef, i8* %34, 0 - %36 = insertvalue %variant %35, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %37 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots11, i64 0, i64 1 - store %variant %36, %variant* %37, align 16 - %38 = bitcast [2 x %variant]* %varargslots11 to %variant* - %39 = insertvalue %"variant[]" undef, %variant* %38, 0 - %40 = insertvalue %"variant[]" %39, i64 2, 1 - store %"variant[]" %40, %"variant[]"* %taddr14, align 8 - %41 = bitcast %"variant[]"* %taddr14 to { i8*, i64 }* - %42 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %41, i32 0, i32 0 - %lo15 = load i8*, i8** %42, align 8 - %43 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %41, i32 0, i32 1 - %hi16 = load i64, i64* %43, align 8 - call void @foo_test2(i32 3, i8* %lo15, i64 %hi16, i32 2) - ret void -} - - diff --git a/test/test_suite14/functions/void_params.c3 b/test/test_suite14/functions/void_params.c3 deleted file mode 100644 index e52d2c9a6..000000000 --- a/test/test_suite14/functions/void_params.c3 +++ /dev/null @@ -1,2 +0,0 @@ -fn void test(int, void) {} // #error: Parameters may not be of type 'void'. -fn void test3(void); // #error: C-style 'foo(void)' style argument declarations are not valid \ No newline at end of file diff --git a/test/test_suite14/generic/enum_set_test.c3t b/test/test_suite14/generic/enum_set_test.c3t deleted file mode 100644 index f42e7993b..000000000 --- a/test/test_suite14/generic/enum_set_test.c3t +++ /dev/null @@ -1,178 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -import std::enumset; - -define AbcEnumSet = EnumSet; - -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 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i8, align 1 - %taddr1 = alloca %"variant[]", align 8 - %retparam2 = alloca i64, align 8 - %varargslots3 = alloca [1 x %variant], align 16 - %taddr4 = alloca i8, align 1 - %taddr5 = alloca %"variant[]", align 8 - %retparam11 = alloca i64, align 8 - %varargslots12 = alloca [1 x %variant], align 16 - %taddr13 = alloca i8, align 1 - %taddr14 = alloca %"variant[]", align 8 - %set2 = alloca i32, align 4 - %retparam20 = alloca i64, align 8 - %varargslots21 = alloca [1 x %variant], align 16 - %taddr22 = alloca i8, align 1 - %taddr23 = alloca %"variant[]", align 8 - %retparam29 = alloca i64, align 8 - %varargslots30 = alloca [1 x %variant], align 16 - %taddr31 = alloca i8, align 1 - %taddr32 = alloca %"variant[]", align 8 - store i32 0, i32* %set, align 4 - %0 = call i8 @"std_enumset$$test_Abc_EnumSet_has"(i32* %set, i32 1) - store i8 %0, i8* %taddr, align 1 - %1 = insertvalue %variant undef, i8* %taddr, 0 - %2 = insertvalue %variant %1, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %3 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %2, %variant* %3, align 16 - %4 = bitcast [1 x %variant]* %varargslots to %variant* - %5 = insertvalue %"variant[]" undef, %variant* %4, 0 - %6 = insertvalue %"variant[]" %5, i64 1, 1 - store %"variant[]" %6, %"variant[]"* %taddr1, align 8 - %7 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %8 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %7, i32 0, i32 0 - %lo = load i8*, i8** %8, align 8 - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %7, i32 0, i32 1 - %hi = load i64, i64* %9, align 8 - %10 = call i64 @std_io_printf(i64* %retparam, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0), i64 14, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %10, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - call void @"std_enumset$$test_Abc_EnumSet_add"(i32* %set, i32 0) - %11 = call i8 @"std_enumset$$test_Abc_EnumSet_has"(i32* %set, i32 1) - store i8 %11, i8* %taddr4, align 1 - %12 = insertvalue %variant undef, i8* %taddr4, 0 - %13 = insertvalue %variant %12, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %14 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots3, i64 0, i64 0 - store %variant %13, %variant* %14, align 16 - %15 = bitcast [1 x %variant]* %varargslots3 to %variant* - %16 = insertvalue %"variant[]" undef, %variant* %15, 0 - %17 = insertvalue %"variant[]" %16, i64 1, 1 - store %"variant[]" %17, %"variant[]"* %taddr5, align 8 - %18 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 0 - %lo6 = load i8*, i8** %19, align 8 - %20 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 1 - %hi7 = load i64, i64* %20, align 8 - %21 = call i64 @std_io_printf(i64* %retparam2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i64 14, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %21, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %voiderr - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %voiderr - call void @"std_enumset$$test_Abc_EnumSet_add"(i32* %set, i32 1) - %22 = call i8 @"std_enumset$$test_Abc_EnumSet_has"(i32* %set, i32 1) - store i8 %22, i8* %taddr13, align 1 - %23 = insertvalue %variant undef, i8* %taddr13, 0 - %24 = insertvalue %variant %23, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %25 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots12, i64 0, i64 0 - store %variant %24, %variant* %25, align 16 - %26 = bitcast [1 x %variant]* %varargslots12 to %variant* - %27 = insertvalue %"variant[]" undef, %variant* %26, 0 - %28 = insertvalue %"variant[]" %27, i64 1, 1 - store %"variant[]" %28, %"variant[]"* %taddr14, align 8 - %29 = bitcast %"variant[]"* %taddr14 to { i8*, i64 }* - %30 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %29, i32 0, i32 0 - %lo15 = load i8*, i8** %30, align 8 - %31 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %29, i32 0, i32 1 - %hi16 = load i64, i64* %31, align 8 - %32 = call i64 @std_io_printf(i64* %retparam11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0), i64 14, i8* %lo15, i64 %hi16) - %not_err17 = icmp eq i64 %32, 0 - br i1 %not_err17, label %after_check18, label %voiderr19 - -after_check18: ; preds = %voiderr10 - br label %voiderr19 - -voiderr19: ; preds = %after_check18, %voiderr10 - store i32 0, i32* %set2, align 4 - %33 = load i32, i32* %set, align 4 - call void @"std_enumset$$test_Abc_EnumSet_add_all"(i32* %set2, i32 %33) - %34 = call i8 @"std_enumset$$test_Abc_EnumSet_has"(i32* %set2, i32 1) - store i8 %34, i8* %taddr22, align 1 - %35 = insertvalue %variant undef, i8* %taddr22, 0 - %36 = insertvalue %variant %35, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %37 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots21, i64 0, i64 0 - store %variant %36, %variant* %37, align 16 - %38 = bitcast [1 x %variant]* %varargslots21 to %variant* - %39 = insertvalue %"variant[]" undef, %variant* %38, 0 - %40 = insertvalue %"variant[]" %39, i64 1, 1 - store %"variant[]" %40, %"variant[]"* %taddr23, align 8 - %41 = bitcast %"variant[]"* %taddr23 to { i8*, i64 }* - %42 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %41, i32 0, i32 0 - %lo24 = load i8*, i8** %42, align 8 - %43 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %41, i32 0, i32 1 - %hi25 = load i64, i64* %43, align 8 - %44 = call i64 @std_io_printf(i64* %retparam20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i32 0, i32 0), i64 14, i8* %lo24, i64 %hi25) - %not_err26 = icmp eq i64 %44, 0 - br i1 %not_err26, label %after_check27, label %voiderr28 - -after_check27: ; preds = %voiderr19 - br label %voiderr28 - -voiderr28: ; preds = %after_check27, %voiderr19 - %45 = load i32, i32* %set2, align 4 - call void @"std_enumset$$test_Abc_EnumSet_remove_all"(i32* %set, i32 %45) - %46 = call i8 @"std_enumset$$test_Abc_EnumSet_has"(i32* %set, i32 1) - store i8 %46, i8* %taddr31, align 1 - %47 = insertvalue %variant undef, i8* %taddr31, 0 - %48 = insertvalue %variant %47, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %49 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots30, i64 0, i64 0 - store %variant %48, %variant* %49, align 16 - %50 = bitcast [1 x %variant]* %varargslots30 to %variant* - %51 = insertvalue %"variant[]" undef, %variant* %50, 0 - %52 = insertvalue %"variant[]" %51, i64 1, 1 - store %"variant[]" %52, %"variant[]"* %taddr32, align 8 - %53 = bitcast %"variant[]"* %taddr32 to { i8*, i64 }* - %54 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %53, i32 0, i32 0 - %lo33 = load i8*, i8** %54, align 8 - %55 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %53, i32 0, i32 1 - %hi34 = load i64, i64* %55, align 8 - %56 = call i64 @std_io_printf(i64* %retparam29, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i64 14, i8* %lo33, i64 %hi34) - %not_err35 = icmp eq i64 %56, 0 - br i1 %not_err35, label %after_check36, label %voiderr37 - -after_check36: ; preds = %voiderr28 - br label %voiderr37 - -voiderr37: ; preds = %after_check36, %voiderr28 - ret void -} diff --git a/test/test_suite14/generic/generic_copy.c3t b/test/test_suite14/generic/generic_copy.c3t deleted file mode 100644 index ede601329..000000000 --- a/test/test_suite14/generic/generic_copy.c3t +++ /dev/null @@ -1,12 +0,0 @@ -module foo; - -fn void abc() -{ - int i; - defer { i++; } -} - -module tester; -import foo; - -define abc_my = foo::abc; \ No newline at end of file diff --git a/test/test_suite14/generic/generic_idents.c3t b/test/test_suite14/generic/generic_idents.c3t deleted file mode 100644 index 0cdd133a5..000000000 --- a/test/test_suite14/generic/generic_idents.c3t +++ /dev/null @@ -1,69 +0,0 @@ -module gen ; - -fn Type mult(Type x) -{ - return x * x; -} - -fn Type addMult(Type x, Type a, Type b) -{ - return x * a + b; -} - -module test; -import gen; - -define intMult = gen::mult; -define doubleAddMult = gen::addMult; - -fn int getIt(int i) -{ - return intMult(i) + 1; -} - -fn double getIt2(double i) -{ - return doubleAddMult(i, 2, 3); -} - -/* #expect: gen.int.ll - -define i32 @"gen$$int_mult"(i32 %0) #0 { -entry: - %mul = mul i32 %0, %0 - ret i32 %mul -} - -define i32 @"gen$$int_addMult"(i32 %0, i32 %1, i32 %2) #0 { -entry: - %mul = mul i32 %0, %1 - %add = add i32 %mul, %2 - ret i32 %add -} - - -// #expect: test.ll - -define i32 @test_getIt(i32 %0) #0 { -entry: - %1 = call i32 @"gen$$int_mult"(i32 %0) - %add = add i32 %1, 1 - ret i32 %add -} - -define double @test_getIt2(double %0) #0 { -entry: - %1 = call double @"gen$$double_addMult"(double %0, double 2.000000e+00, double 3.000000e+00) - ret double %1 -} - -declare i32 @"gen$$int_mult"(i32) - -declare double @"gen$$double_addMult"(double, double, double) - -// #expect: gen.double.ll - -define double @"gen$$double_addMult"(double %0, double %1, double %2) -entry: - %3 = call double @llvm.fmuladd.f64(double %0, double %1, double %2) - ret double %3 diff --git a/test/test_suite14/generic/generic_num.c3t b/test/test_suite14/generic/generic_num.c3t deleted file mode 100644 index 82826dad0..000000000 --- a/test/test_suite14/generic/generic_num.c3t +++ /dev/null @@ -1,53 +0,0 @@ -// #target: macos-x64 -module hello; - -fn Type x(Type t) -{ - return t * t + FOO; -} - -module test; -import hello; -define xint = hello::x; - -import std::io; - -fn void main() -{ - io::printfn("%d", xint(4)); -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - %0 = call i32 @"hello$$int._123_x"(i32 4) - store i32 %0, i32* %taddr, align 4 - %1 = bitcast i32* %taddr to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %4 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %3, %variant* %4, align 16 - %5 = bitcast [1 x %variant]* %varargslots to %variant* - %6 = insertvalue %"variant[]" undef, %variant* %5, 0 - %7 = insertvalue %"variant[]" %6, i64 1, 1 - store %"variant[]" %7, %"variant[]"* %taddr1, align 8 - %8 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0 - %lo = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1 - %hi = load i64, i64* %10, align 8 - %11 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i64 2, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %11, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - ret void -} \ No newline at end of file diff --git a/test/test_suite14/globals/external_global.c3t b/test/test_suite14/globals/external_global.c3t deleted file mode 100644 index eca23cf05..000000000 --- a/test/test_suite14/globals/external_global.c3t +++ /dev/null @@ -1,34 +0,0 @@ -module test; - -struct MinInfo -{ - long offset; - uint file_attr; -} - -struct UzGlobs -{ - ichar answerbuf; - MinInfo[1] info; - MinInfo* pInfo; -} - -extern UzGlobs g; - -fn int extract_or_test_files() -{ - g.pInfo = &g.info; - return 0; -} - -// #expect: test.ll - -%UzGlobs = type { i8, [1 x %MinInfo], %MinInfo* } -%MinInfo = type { i64, i32 } - -@g = external global %UzGlobs, align 8 - -entry: - store %MinInfo* getelementptr inbounds (%UzGlobs, %UzGlobs* @g, i32 0, i32 1, i32 0), %MinInfo** getelementptr inbounds (%UzGlobs, %UzGlobs* @g, i32 0, i32 2), align 8 - ret i32 0 -} \ No newline at end of file diff --git a/test/test_suite14/globals/global_align.c3t b/test/test_suite14/globals/global_align.c3t deleted file mode 100644 index 9efcc00b0..000000000 --- a/test/test_suite14/globals/global_align.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 - -module abc; - -int foo @align(32); - -fn void test() -{ - int x = foo; -} - -// #expect: abc.ll - -@abc_foo = local_unnamed_addr global i32 0, align 32 - -define void @abc_test() #0 { -entry: - %x = alloca i32, align 4 - %0 = load i32, i32* @abc_foo, align 32 - store i32 %0, i32* %x, align 4 - ret void -} diff --git a/test/test_suite14/globals/global_extname.c3t b/test/test_suite14/globals/global_extname.c3t deleted file mode 100644 index 6de9b442d..000000000 --- a/test/test_suite14/globals/global_extname.c3t +++ /dev/null @@ -1,7 +0,0 @@ -module foo; - -int baz @extname("foobar") = 123; - -// #expect: foo.ll - -@foobar = local_unnamed_addr global i32 123, align 4 \ No newline at end of file diff --git a/test/test_suite14/globals/global_init.c3 b/test/test_suite14/globals/global_init.c3 deleted file mode 100644 index eec62d316..000000000 --- a/test/test_suite14/globals/global_init.c3 +++ /dev/null @@ -1,22 +0,0 @@ -// TODO string str = "hello"; -char* str2 = "hello"; -String str3 = "hello"; - - -int[2] a1 = { 1, 2 }; - -int[2] a2 = 30; // #error: 'int' to 'int[2]' - -ichar[*] a; // #error: Inferred array types can only be used in declarations with initializers - -ichar ca = 0; -ichar cb = 1; - -ichar cc = 127; -ichar cd = -128; - -ichar ce = 128; // #error: The value '128' is out of range for 'ichar' -ichar cf = -129; // #error: The value '-129' is out of range for 'ichar' - -ichar cg = 70000; // #error: The value '70000' is out of range for 'ichar' -ichar ch = -70000; // #error: The value '-70000' is out of range for 'ichar' \ No newline at end of file diff --git a/test/test_suite14/globals/misplaced_const.c3 b/test/test_suite14/globals/misplaced_const.c3 deleted file mode 100644 index 6ea51e0c8..000000000 --- a/test/test_suite14/globals/misplaced_const.c3 +++ /dev/null @@ -1,6 +0,0 @@ -const FOO = 3; -int BAR = 4; // #error: This looks like a constant variable, did you forget 'const'? - -const BAZ = "ofke"; - -FOOBAR; // #error: Expected the start of a global declaration here \ No newline at end of file diff --git a/test/test_suite14/globals/recursive_globals.c3 b/test/test_suite14/globals/recursive_globals.c3 deleted file mode 100644 index d6d2a725f..000000000 --- a/test/test_suite14/globals/recursive_globals.c3 +++ /dev/null @@ -1,3 +0,0 @@ -void *x = &x; - -int y = 1 + y; // #error: This looks like the initialization of the variable was circular. \ No newline at end of file diff --git a/test/test_suite14/globals/recursive_locals.c3 b/test/test_suite14/globals/recursive_locals.c3 deleted file mode 100644 index 1709dbf9f..000000000 --- a/test/test_suite14/globals/recursive_locals.c3 +++ /dev/null @@ -1,13 +0,0 @@ - -struct List -{ - int x; - List* next; -} - -const List A = { 7, &B }; -const List B = { 8, &A }; - -extern List d; - -List c = { 7, &d }; diff --git a/test/test_suite14/globals/self_referencing_local.c3 b/test/test_suite14/globals/self_referencing_local.c3 deleted file mode 100644 index 6da61b7a8..000000000 --- a/test/test_suite14/globals/self_referencing_local.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test() -{ - void* x = &x; - int y = y; // #error: This looks like the initialization of the variable was circular. -} \ No newline at end of file diff --git a/test/test_suite14/globals/static_global.c3 b/test/test_suite14/globals/static_global.c3 deleted file mode 100644 index cdeaf9872..000000000 --- a/test/test_suite14/globals/static_global.c3 +++ /dev/null @@ -1 +0,0 @@ -static int ifej; // #error: 'static' can only used with local variables \ No newline at end of file diff --git a/test/test_suite14/import/access_other_module.c3t b/test/test_suite14/import/access_other_module.c3t deleted file mode 100644 index 71cf2d00d..000000000 --- a/test/test_suite14/import/access_other_module.c3t +++ /dev/null @@ -1,23 +0,0 @@ -// #target: macos-x64 -module foo; -import libc; -fn void main() -{ - void* foekf = &libc::printf; - int* xok = &libc::EXIT_SUCCESS; -} - -/* #expect: foo.ll - -@libc_EXIT_SUCCESS = external global i32, align 4 - -define void @foo_main() #0 { -entry: - %foekf = alloca i8*, align 8 - %xok = alloca i32*, align 8 - store i8* bitcast (i32 (i8*, ...)* @printf to i8*), i8** %foekf, align 8 - store i32* @libc_EXIT_SUCCESS, i32** %xok, align 8 - ret void -} - -declare i32 @printf(i8*, ...) \ No newline at end of file diff --git a/test/test_suite14/import/autoimport.c3 b/test/test_suite14/import/autoimport.c3 deleted file mode 100644 index 8b80f199e..000000000 --- a/test/test_suite14/import/autoimport.c3 +++ /dev/null @@ -1,36 +0,0 @@ -module foo; - -fn int test() @builtin -{ - return 1; -} - -macro int testm() @builtin -{ - return 1; -} - -fn int test1() -{ - return 1; -} - -macro int testm1() -{ - return 1; -} - -module bar; -import foo; - -fn void main() -{ - testm(); - test(); -} - -fn void main2() -{ - testm1(); // #error: Macros from other modules must be prefixed with the module nam - test1(); // #error: Functions from other modules must be prefixed with the module nam -} \ No newline at end of file diff --git a/test/test_suite14/import/import_error.c3 b/test/test_suite14/import/import_error.c3 deleted file mode 100644 index 4be9e0f7c..000000000 --- a/test/test_suite14/import/import_error.c3 +++ /dev/null @@ -1,6 +0,0 @@ -module test; -import std::core::mem; -import hello_world; // #error: No module named -import test; // #error: Importing the current - -fn void hello() { } \ No newline at end of file diff --git a/test/test_suite14/import/import_error_multi.c3 b/test/test_suite14/import/import_error_multi.c3 deleted file mode 100644 index e6a761a42..000000000 --- a/test/test_suite14/import/import_error_multi.c3 +++ /dev/null @@ -1 +0,0 @@ -import foo, ; // #error: Another module name was expected after \ No newline at end of file diff --git a/test/test_suite14/import/import_error_out_of_order.c3 b/test/test_suite14/import/import_error_out_of_order.c3 deleted file mode 100644 index cee46debc..000000000 --- a/test/test_suite14/import/import_error_out_of_order.c3 +++ /dev/null @@ -1,9 +0,0 @@ -module foo; - -fn void hello() {} - -$if (true): - -import bar; // #error: 'import' may not appear inside a compile - -$endif; \ No newline at end of file diff --git a/test/test_suite14/import/import_error_string.c3 b/test/test_suite14/import/import_error_string.c3 deleted file mode 100644 index 1810dcfe3..000000000 --- a/test/test_suite14/import/import_error_string.c3 +++ /dev/null @@ -1 +0,0 @@ -import "Hello my friend"; // #error: An import should be followed by a plain identifier, not a string. Did you accidentally put the module name between ""? \ No newline at end of file diff --git a/test/test_suite14/import/import_implicit.c3 b/test/test_suite14/import/import_implicit.c3 deleted file mode 100644 index e88d58023..000000000 --- a/test/test_suite14/import/import_implicit.c3 +++ /dev/null @@ -1,17 +0,0 @@ -module abc; - -struct Foo -{ - int a; - int b; -} - -fn void test() {} - -module dde; - -fn void test() -{ - abc::test(); // #error: Did you mean the function 'abc::test' - Foo f; // #error: Did you mean the struct 'Foo' -} \ No newline at end of file diff --git a/test/test_suite14/import/import_same.c3 b/test/test_suite14/import/import_same.c3 deleted file mode 100644 index 96bd65b50..000000000 --- a/test/test_suite14/import/import_same.c3 +++ /dev/null @@ -1,10 +0,0 @@ -module foo::abc; -import bar; - -fn int test1() -{ - return abc::test(); -} - -module bar::abc; -fn int test() { return 1; } \ No newline at end of file diff --git a/test/test_suite14/import/import_works.c3t b/test/test_suite14/import/import_works.c3t deleted file mode 100644 index c524cd8cf..000000000 --- a/test/test_suite14/import/import_works.c3t +++ /dev/null @@ -1,3 +0,0 @@ -import std::io, std::core::mem; - -int foo = 1; \ No newline at end of file diff --git a/test/test_suite14/initialize/initialize_bad_prio.c3 b/test/test_suite14/initialize/initialize_bad_prio.c3 deleted file mode 100644 index 97674d114..000000000 --- a/test/test_suite14/initialize/initialize_bad_prio.c3 +++ /dev/null @@ -1,16 +0,0 @@ - -static initialize @priority("hello") // #error: Expected an argument to '@priority' -{ -} - -static initialize @priority(1, 2) // #error: Too many arguments for -{ -} - -static initialize @priority(0) // #error: Expected an argument to '@priority' -{ -} - -static initialize @priority(65536) // #error: Expected an argument to '@priority' -{ -} \ No newline at end of file diff --git a/test/test_suite14/initialize/initialize_finalize.c3t b/test/test_suite14/initialize/initialize_finalize.c3t deleted file mode 100644 index 7e15bce28..000000000 --- a/test/test_suite14/initialize/initialize_finalize.c3t +++ /dev/null @@ -1,62 +0,0 @@ -// #target: linux-x64 -module test; -import std::io; - -fn void main() -{ - io::println("Hello, world!"); -} -extern fn void puts(char*); - -static initialize @priority(300) -{ - puts("Hello startup2"); -} -static initialize -{ - puts("Let's start main..."); -} -static initialize @priority(200) -{ - puts("Hello startup"); -} - -static initialize -{} - -static finalize -{ - puts("Bye bye"); -} - -/* #expect: test.ll - -@llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 300, void ()* @.static_initialize.0, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @.static_initialize.1, i8* null }, { i32, void ()*, i8* } { i32 200, void ()* @.static_initialize.2, i8* null }] -@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @.static_finalize.0, i8* null }] - -define internal void @.static_initialize.0() { -entry: - call void @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0)) - ret void -} - -; Function Attrs: nounwind -declare void @puts(i8*) #0 - -define internal void @.static_initialize.1() { -entry: - call void @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0)) - ret void -} - -define internal void @.static_initialize.2() { -entry: - call void @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0)) - ret void -} - -define internal void @.static_finalize.0() { -entry: - call void @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0)) - ret void -} diff --git a/test/test_suite14/initialize/initialize_jump.c3 b/test/test_suite14/initialize/initialize_jump.c3 deleted file mode 100644 index 4c254d2ee..000000000 --- a/test/test_suite14/initialize/initialize_jump.c3 +++ /dev/null @@ -1,9 +0,0 @@ -static initialize -{ - return; // This is fine -} - -static initialize -{ - return 123; // #error: It is not possible to convert 'int' to 'void' -} \ No newline at end of file diff --git a/test/test_suite14/initialize/initialize_parse_error.c3 b/test/test_suite14/initialize/initialize_parse_error.c3 deleted file mode 100644 index b1b361c91..000000000 --- a/test/test_suite14/initialize/initialize_parse_error.c3 +++ /dev/null @@ -1 +0,0 @@ -static foo {} ; // #error: Expected 'static initialize' diff --git a/test/test_suite14/initialize/initialize_prio.c3 b/test/test_suite14/initialize/initialize_prio.c3 deleted file mode 100644 index 87f929f01..000000000 --- a/test/test_suite14/initialize/initialize_prio.c3 +++ /dev/null @@ -1,3 +0,0 @@ -static initialize @priority() // #error: An expression was expected. -{ -} diff --git a/test/test_suite14/initialize/initializer_var.c3t b/test/test_suite14/initialize/initializer_var.c3t deleted file mode 100644 index 38348df72..000000000 --- a/test/test_suite14/initialize/initializer_var.c3t +++ /dev/null @@ -1,7 +0,0 @@ -module test; - -static initialize -{ - int a; - a = 1; -} diff --git a/test/test_suite14/initializer_lists/disallowed_lists.c3 b/test/test_suite14/initializer_lists/disallowed_lists.c3 deleted file mode 100644 index 6f2225099..000000000 --- a/test/test_suite14/initializer_lists/disallowed_lists.c3 +++ /dev/null @@ -1,8 +0,0 @@ -fn void test() -{ - char* hello = "123"; - String a = { '1', '2', '3' }; - char[*] b = { '1', '2', '3' }; - char[3] c = { '1', '2', '3' }; - char* d = { '1', '2', '3' }; // #error: Pointers cannot be initialized using an initializer list, instead you need to take the address of an array -} \ No newline at end of file diff --git a/test/test_suite14/initializer_lists/fasta.c3t b/test/test_suite14/initializer_lists/fasta.c3t deleted file mode 100644 index a45a02858..000000000 --- a/test/test_suite14/initializer_lists/fasta.c3t +++ /dev/null @@ -1,370 +0,0 @@ -// #target: macos-x64 -module fasta; - -const IM = 139968u; -const IA = 3877u; -const IC = 29573u; -const SEED = 42u; - -uint seed = SEED; - -fn float fasta_rand(float maxval) -{ - seed = (seed * IA + IC) % IM; - return maxval * seed / IM; -} - -private char[] alu = - "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" - "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" - "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" - "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" - "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" - "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" - "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; - -extern fn int atoi(char *s); -extern fn int printf(char *s, ...); -extern fn void putchar(int c); - -char[] iub = "acgtBDHKMNRSVWY"; -double[] iub_p = { - 0.27, - 0.12, - 0.12, - 0.27, - 0.02, - 0.02, - 0.02, - 0.02, - 0.02, - 0.02, - 0.02, - 0.02, - 0.02, - 0.02, - 0.02 }; - -char[] homosapiens = "acgt"; -double[] homosapiens_p = { - 0.3029549426680, - 0.1979883004921, - 0.1975473066391, - 0.3015094502008 -}; - -const LINELEN = 60; - -// slowest character-at-a-time output -fn void repeat_fasta(char[] seq, int n) -{ - usz len = seq.len; - int i = void; - for (i = 0; i < n; i++) - { - putchar(seq[i % len]); - if (i % LINELEN == LINELEN - 1) putchar('\n'); - } - if (i % LINELEN != 0) putchar('\n'); -} - -fn void random_fasta(char[] symb, double[] probability, int n) -{ - assert(symb.len == probability.len); - int len = probability.len; - int i = void; - for (i = 0; i < n; i++) - { - double v = fasta_rand(1.0); - /* slowest idiomatic linear lookup. Fast if len is short though. */ - int j = void; - for (j = 0; j < len - 1; j++) - { - v -= probability[j]; - if (v < 0) break; - } - putchar(symb[j]); - if (i % LINELEN == LINELEN - 1) putchar('\n'); - } - if (i % LINELEN != 0) putchar('\n'); -} - -fn int main(int argc, char **argv) -{ - int n = 1000; - if (argc > 1) n = atoi(argv[1]); - - printf(">ONE Homo sapiens alu\n"); - repeat_fasta(alu, n * 2); - - printf(">TWO IUB ambiguity codes\n"); - random_fasta(iub, iub_p, n * 3); - - printf(">THREE Homo sapiens frequency\n"); - random_fasta(homosapiens, homosapiens_p, n * 5); - return 0; -} - -/* #expect: fasta.ll - -%"char[]" = type { i8*, i64 } -%"double[]" = type { double*, i64 } - -@fasta_IM = local_unnamed_addr constant i32 139968, align 4 -@fasta_IA = local_unnamed_addr constant i32 3877, align 4 -@fasta_IC = local_unnamed_addr constant i32 29573, align 4 -@fasta_SEED = local_unnamed_addr constant i32 42, align 4 -@fasta_seed = local_unnamed_addr global i32 42, align 4 -@.str = private unnamed_addr constant [288 x i8] c"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA\00", align 1 -@fasta_alu = protected unnamed_addr global %"char[]" { i8* getelementptr inbounds ([288 x i8], [288 x i8]* @.str, i32 0, i32 0), i64 287 }, align 8 -@.str.11 = private unnamed_addr constant [16 x i8] c"acgtBDHKMNRSVWY\00", align 1 -@fasta_iub = local_unnamed_addr global %"char[]" { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i32 0, i32 0), i64 15 }, align 8 -@.taddr = private global [15 x double] [double 2.700000e-01, double 1.200000e-01, double 1.200000e-01, double 2.700000e-01, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02, double 2.000000e-02], align 8 -@fasta_iub_p = local_unnamed_addr global %"double[]" { double* getelementptr inbounds ([15 x double], [15 x double]* @.taddr, i32 0, i32 0), i64 15 }, align 8 -@.str.12 = private unnamed_addr constant [5 x i8] c"acgt\00", align 1 -@fasta_homosapiens = local_unnamed_addr global %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i32 0, i32 0), i64 4 }, align 8 -@.taddr.13 = private global [4 x double] [double 0x3FD3639D20BAEB5B, double 0x3FC957AE3DCD561B, double 0x3FC9493AEAB6C2BF, double 0x3FD34BEE4B030838], align 8 -@fasta_homosapiens_p = local_unnamed_addr global %"double[]" { double* getelementptr inbounds ([4 x double], [4 x double]* @.taddr.13, i32 0, i32 0), i64 4 }, align 8 -@fasta_LINELEN = local_unnamed_addr constant i32 60, align 4 -@.str.14 = private unnamed_addr constant [23 x i8] c">ONE Homo sapiens alu\0A\00", align 1 -@.str.15 = private unnamed_addr constant [26 x i8] c">TWO IUB ambiguity codes\0A\00", align 1 -@.str.16 = private unnamed_addr constant [31 x i8] c">THREE Homo sapiens frequency\0A\00", align 1 - -; Function Attrs: nounwind -define float @fasta_fasta_rand(float %0) #0 { -entry: - %1 = load i32, i32* @fasta_seed, align 4 - %mul = mul i32 %1, 3877 - %add = add i32 %mul, 29573 - %umod = urem i32 %add, 139968 - store i32 %umod, i32* @fasta_seed, align 4 - %2 = load i32, i32* @fasta_seed, align 4 - %uifp = uitofp i32 %2 to float - %fmul = fmul float %0, %uifp - %fdiv = fdiv float %fmul, 1.399680e+05 - ret float %fdiv -} - -; Function Attrs: nounwind -declare i32 @atoi(i8*) #0 - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -declare void @putchar(i32) #0 - -; Function Attrs: nounwind -define void @fasta_repeat_fasta(i8* %0, i64 %1, i32 %2) #0 { -entry: - %seq = alloca %"char[]", align 8 - %len = alloca i64, align 8 - %i = alloca i32, align 4 - %pair = bitcast %"char[]"* %seq to { i8*, i64 }* - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %3, align 8 - %4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %4, align 8 - %5 = getelementptr inbounds %"char[]", %"char[]"* %seq, i32 0, i32 1 - %6 = load i64, i64* %5, align 8 - store i64 %6, i64* %len, align 8 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %if.exit, %entry - %7 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %7, %2 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %8 = getelementptr inbounds %"char[]", %"char[]"* %seq, i32 0, i32 0 - %9 = load i8*, i8** %8, align 8 - %10 = load i32, i32* %i, align 4 - %sisiext = sext i32 %10 to i64 - %11 = load i64, i64* %len, align 8 - %smod = srem i64 %sisiext, %11 - %ptroffset = getelementptr inbounds i8, i8* %9, i64 %smod - %12 = load i8, i8* %ptroffset, align 1 - %uisiext = zext i8 %12 to i32 - call void @putchar(i32 %uisiext) - %13 = load i32, i32* %i, align 4 - %smod1 = srem i32 %13, 60 - %eq = icmp eq i32 %smod1, 59 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - call void @putchar(i32 10) - br label %if.exit - -if.exit: ; preds = %if.then, %loop.body - %14 = load i32, i32* %i, align 4 - %add = add i32 %14, 1 - store i32 %add, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %15 = load i32, i32* %i, align 4 - %smod2 = srem i32 %15, 60 - %neq = icmp ne i32 %smod2, 0 - br i1 %neq, label %if.then3, label %if.exit4 - -if.then3: ; preds = %loop.exit - call void @putchar(i32 10) - br label %if.exit4 - -if.exit4: ; preds = %if.then3, %loop.exit - ret void -} - -; Function Attrs: nounwind -define void @fasta_random_fasta(i8* %0, i64 %1, i8* %2, i64 %3, i32 %4) #0 { -entry: - %symb = alloca %"char[]", align 8 - %probability = alloca %"double[]", align 8 - %len = alloca i32, align 4 - %i = alloca i32, align 4 - %v = alloca double, align 8 - %j = alloca i32, align 4 - %pair = bitcast %"char[]"* %symb to { i8*, i64 }* - %5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %5, align 8 - %6 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %6, align 8 - %pair1 = bitcast %"double[]"* %probability to { i8*, i64 }* - %7 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 0 - store i8* %2, i8** %7, align 8 - %8 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 1 - store i64 %3, i64* %8, align 8 - %9 = getelementptr inbounds %"char[]", %"char[]"* %symb, i32 0, i32 1 - %10 = load i64, i64* %9, align 8 - %11 = getelementptr inbounds %"double[]", %"double[]"* %probability, i32 0, i32 1 - %12 = load i64, i64* %11, align 8 - %eq = icmp eq i64 %10, %12 - call void @llvm.assume(i1 %eq) - %13 = getelementptr inbounds %"double[]", %"double[]"* %probability, i32 0, i32 1 - %14 = load i64, i64* %13, align 8 - %uisitrunc = trunc i64 %14 to i32 - store i32 %uisitrunc, i32* %len, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %if.exit10, %entry - %15 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %15, %4 - br i1 %lt, label %loop.body, label %loop.exit12 - -loop.body: ; preds = %loop.cond - %16 = call float @fasta_fasta_rand(float 1.000000e+00) - %fpfpext = fpext float %16 to double - store double %fpfpext, double* %v, align 8 - store i32 0, i32* %j, align 4 - br label %loop.cond2 - -loop.cond2: ; preds = %if.exit, %loop.body - %17 = load i32, i32* %j, align 4 - %18 = load i32, i32* %len, align 4 - %sub = sub i32 %18, 1 - %lt3 = icmp slt i32 %17, %sub - br i1 %lt3, label %loop.body4, label %loop.exit - -loop.body4: ; preds = %loop.cond2 - %19 = load double, double* %v, align 8 - %20 = getelementptr inbounds %"double[]", %"double[]"* %probability, i32 0, i32 0 - %21 = load double*, double** %20, align 8 - %22 = load i32, i32* %j, align 4 - %sisiext = sext i32 %22 to i64 - %ptroffset = getelementptr inbounds double, double* %21, i64 %sisiext - %23 = load double, double* %ptroffset, align 8 - %fsub = fsub double %19, %23 - store double %fsub, double* %v, align 8 - %24 = load double, double* %v, align 8 - %lt5 = fcmp olt double %24, 0.000000e+00 - br i1 %lt5, label %if.then, label %if.exit - -if.then: ; preds = %loop.body4 - br label %loop.exit - -if.exit: ; preds = %loop.body4 - %25 = load i32, i32* %j, align 4 - %add = add i32 %25, 1 - store i32 %add, i32* %j, align 4 - br label %loop.cond2 - -loop.exit: ; preds = %if.then, %loop.cond2 - %26 = getelementptr inbounds %"char[]", %"char[]"* %symb, i32 0, i32 0 - %27 = load i8*, i8** %26, align 8 - %28 = load i32, i32* %j, align 4 - %sisiext6 = sext i32 %28 to i64 - %ptroffset7 = getelementptr inbounds i8, i8* %27, i64 %sisiext6 - %29 = load i8, i8* %ptroffset7, align 1 - %uisiext = zext i8 %29 to i32 - call void @putchar(i32 %uisiext) - %30 = load i32, i32* %i, align 4 - %smod = srem i32 %30, 60 - %eq8 = icmp eq i32 %smod, 59 - br i1 %eq8, label %if.then9, label %if.exit10 - -if.then9: ; preds = %loop.exit - call void @putchar(i32 10) - br label %if.exit10 - -if.exit10: ; preds = %if.then9, %loop.exit - %31 = load i32, i32* %i, align 4 - %add11 = add i32 %31, 1 - store i32 %add11, i32* %i, align 4 - br label %loop.cond - -loop.exit12: ; preds = %loop.cond - %32 = load i32, i32* %i, align 4 - %smod13 = srem i32 %32, 60 - %neq = icmp ne i32 %smod13, 0 - br i1 %neq, label %if.then14, label %if.exit15 - -if.then14: ; preds = %loop.exit12 - call void @putchar(i32 10) - br label %if.exit15 - -if.exit15: ; preds = %if.then14, %loop.exit12 - ret void -} - -; Function Attrs: nounwind -define i32 @main(i32 %0, i8** %1) #0 { -entry: - %n = alloca i32, align 4 - store i32 1000, i32* %n, align 4 - %gt = icmp sgt i32 %0, 1 - br i1 %gt, label %if.then, label %if.exit - -if.then: ; preds = %entry - %ptroffset = getelementptr inbounds i8*, i8** %1, i64 1 - %2 = load i8*, i8** %ptroffset, align 8 - %3 = call i32 @atoi(i8* %2) - store i32 %3, i32* %n, align 4 - br label %if.exit - -if.exit: ; preds = %if.then, %entry - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i32 0, i32 0)) - %lo = load i8*, i8** getelementptr inbounds (%"char[]", %"char[]"* @fasta_alu, i32 0, i32 0), align 8 - %hi = load i64, i64* getelementptr inbounds (%"char[]", %"char[]"* @fasta_alu, i32 0, i32 1), align 8 - %5 = load i32, i32* %n, align 4 - %mul = mul i32 %5, 2 - call void @fasta_repeat_fasta(i8* %lo, i64 %hi, i32 %mul) - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i32 0, i32 0)) - %lo1 = load i8*, i8** getelementptr inbounds (%"char[]", %"char[]"* @fasta_iub, i32 0, i32 0), align 8 - %hi2 = load i64, i64* getelementptr inbounds (%"char[]", %"char[]"* @fasta_iub, i32 0, i32 1), align 8 - %lo3 = load i8*, i8** getelementptr inbounds ({ i8*, i64 }, { i8*, i64 }* bitcast (%"double[]"* @fasta_iub_p to { i8*, i64 }*), i32 0, i32 0), align 8 - %hi4 = load i64, i64* getelementptr inbounds ({ i8*, i64 }, { i8*, i64 }* bitcast (%"double[]"* @fasta_iub_p to { i8*, i64 }*), i32 0, i32 1), align 8 - %7 = load i32, i32* %n, align 4 - %mul5 = mul i32 %7, 3 - call void @fasta_random_fasta(i8* %lo1, i64 %hi2, i8* %lo3, i64 %hi4, i32 %mul5) - %8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.16, i32 0, i32 0)) - %lo6 = load i8*, i8** getelementptr inbounds (%"char[]", %"char[]"* @fasta_homosapiens, i32 0, i32 0), align 8 - %hi7 = load i64, i64* getelementptr inbounds (%"char[]", %"char[]"* @fasta_homosapiens, i32 0, i32 1), align 8 - %lo8 = load i8*, i8** getelementptr inbounds ({ i8*, i64 }, { i8*, i64 }* bitcast (%"double[]"* @fasta_homosapiens_p to { i8*, i64 }*), i32 0, i32 0), align 8 - %hi9 = load i64, i64* getelementptr inbounds ({ i8*, i64 }, { i8*, i64 }* bitcast (%"double[]"* @fasta_homosapiens_p to { i8*, i64 }*), i32 0, i32 1), align 8 - %9 = load i32, i32* %n, align 4 - %mul10 = mul i32 %9, 5 - call void @fasta_random_fasta(i8* %lo6, i64 %hi7, i8* %lo8, i64 %hi9, i32 %mul10) - ret i32 0 -} \ No newline at end of file diff --git a/test/test_suite14/initializer_lists/general_tests.c3t b/test/test_suite14/initializer_lists/general_tests.c3t deleted file mode 100644 index 13fe0bba3..000000000 --- a/test/test_suite14/initializer_lists/general_tests.c3t +++ /dev/null @@ -1,90 +0,0 @@ -// #target: macos-x64 - -union Baz -{ - int x; - double y; -} -struct Bar -{ - int x; - int y; -} - -fn int test() -{ - Baz ffe = { .x = 1 }; - int[1] azz = {}; - var $foo = { 11, 22, 33 }; - static int foo1 = $foo[1]; - int foo2 = $foo[2]; - var $foos = { "Hello!" }; - char* str = $foos[0]; - bool x = ! int[] { 1, 2, 3 }; - Bar b = {}; - Baz z = {}; - int[] sub = {}; - Bar[] foo = {}; - Baz[3] baz = {}; - return 1; -} - - -/* #expect: general_tests.ll - -%Baz = type { double } -%Bar = type { i32, i32 } -%"int[]" = type { i32*, i64 } -%"Bar[]" = type { %Bar*, i64 } - -@"ct$general_tests_Baz" = linkonce constant %.introspect { i8 11, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"ct$general_tests_Bar" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@.__const = private unnamed_addr constant { i32, [4 x i8] } { i32 1, [4 x i8] undef }, align 8 -@"test$foo1" = internal unnamed_addr global i32 22, align 4 -@.str = private unnamed_addr constant [7 x i8] c"Hello!\00", align 1 - -; Function Attrs: nounwind -define i32 @general_tests_test() #0 { -entry: - %ffe = alloca %Baz, align 8 - %azz = alloca [1 x i32], align 4 - %foo2 = alloca i32, align 4 - %str = alloca i8*, align 8 - %x = alloca i8, align 1 - %literal = alloca [3 x i32], align 4 - %b = alloca %Bar, align 4 - %z = alloca %Baz, align 8 - %sub = alloca %"int[]", align 8 - %foo = alloca %"Bar[]", align 8 - %baz = alloca [3 x %Baz], align 16 - %0 = bitcast %Baz* %ffe to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %0, i8* align 8 bitcast ({ i32, [4 x i8] }* @.__const to i8*), i32 8, i1 false) - %1 = getelementptr inbounds [1 x i32], [1 x i32]* %azz, i64 0, i64 0 - store i32 0, i32* %1, align 4 - store i32 33, i32* %foo2, align 4 - store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8** %str, align 8 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %literal, i64 0, i64 0 - store i32 1, i32* %2, align 4 - %3 = getelementptr inbounds [3 x i32], [3 x i32]* %literal, i64 0, i64 1 - store i32 2, i32* %3, align 4 - %4 = getelementptr inbounds [3 x i32], [3 x i32]* %literal, i64 0, i64 2 - store i32 3, i32* %4, align 4 - %5 = bitcast [3 x i32]* %literal to i32* - %6 = insertvalue %"int[]" undef, i32* %5, 0 - %7 = insertvalue %"int[]" %6, i64 3, 1 - %8 = extractvalue %"int[]" %7, 1 - %not = icmp eq i64 %8, 0 - %9 = zext i1 %not to i8 - store i8 %9, i8* %x, align 1 - %10 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 0 - store i32 0, i32* %10, align 4 - %11 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1 - store i32 0, i32* %11, align 4 - %12 = bitcast %Baz* %z to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %12, i8 0, i64 8, i1 false) - store %"int[]" zeroinitializer, %"int[]"* %sub, align 8 - store %"Bar[]" zeroinitializer, %"Bar[]"* %foo, align 8 - %13 = bitcast [3 x %Baz]* %baz to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %13, i8 0, i64 24, i1 false) - ret i32 1 -} \ No newline at end of file diff --git a/test/test_suite14/initializer_lists/indexing_into_complist.c3 b/test/test_suite14/initializer_lists/indexing_into_complist.c3 deleted file mode 100644 index 0fa56f3ab..000000000 --- a/test/test_suite14/initializer_lists/indexing_into_complist.c3 +++ /dev/null @@ -1,28 +0,0 @@ -fn void test() -{ - char* c = { 1, 3, "hello"}[2]; - int x; - int z = { 1, 3 }[x]; // #error: To subscript an untyped list a compile time integer index is needed -} - -fn void test2() -{ - int z = { 1, 3 }[-1]; // #error: The index may not be negative -} - -fn void test3() -{ - int z = { 1, 3 }[0xFFFF_FFFF_FFFF_FFFFu64]; // #error: The index is out of range. -} - -fn void test4() -{ - int z = { 1, 3 }[2]; // #error: An index of '2' is out of range, a value between 0 and 1 was expected. - int z2 = { 1 }[2]; // #error: An index of '2' is out of range, a value of 0 was expected. -} - -fn void test5() -{ - int z = { 1, 3 }[^4]; // #error: An index of '4' from the end is out of range, a value between 1 and 2 was expected - int z2 = { 1 }[^4]; // #error: An index of '4' from the end is out of range, a value of 1 was expected. -} diff --git a/test/test_suite14/initializer_lists/initializers_to_macros.c3 b/test/test_suite14/initializer_lists/initializers_to_macros.c3 deleted file mode 100644 index 4b5a31f18..000000000 --- a/test/test_suite14/initializer_lists/initializers_to_macros.c3 +++ /dev/null @@ -1,11 +0,0 @@ - -macro test(foo) -{ - $typeof(foo) x = foo; -} - -fn void main() -{ - test(int[] { 1, 2 }); - test({ 1, 2 }); // #error: A value of type 'untyped_list' can only be passed as a compile time parameter. -} \ No newline at end of file diff --git a/test/test_suite14/initializer_lists/ranges_to_dynamic.c3t b/test/test_suite14/initializer_lists/ranges_to_dynamic.c3t deleted file mode 100644 index 8d64221af..000000000 --- a/test/test_suite14/initializer_lists/ranges_to_dynamic.c3t +++ /dev/null @@ -1,65 +0,0 @@ -// #target: mingw-x64 -module test; - -extern fn void printf(char*, ...); - -fn void test(int x) -{ - int[10] y = { [0..3] = 4, [6..8] = x }; - foreach (int v : y) - { - printf("%d\n", v); - } -} - -fn void main() -{ - test(101); -} - -/* #expect: test.ll - -define void @test_test(i32 %0) #0 { -entry: - %y = alloca [10 x i32], align 16 - %.anon = alloca i64, align 8 - %v = alloca i32, align 4 - %1 = bitcast [10 x i32]* %y to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 40, i1 false) - %2 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 0 - store i32 4, i32* %2, align 4 - %3 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 1 - store i32 4, i32* %3, align 4 - %4 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 2 - store i32 4, i32* %4, align 4 - %5 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 3 - store i32 4, i32* %5, align 4 - %6 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 6 - store i32 %0, i32* %6, align 4 - %7 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 7 - store i32 %0, i32* %7, align 4 - %8 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 8 - store i32 %0, i32* %8, align 4 - store i64 0, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %9 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 10, %9 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %10 = load i64, i64* %.anon, align 8 - %11 = getelementptr inbounds [10 x i32], [10 x i32]* %y, i64 0, i64 %10 - %12 = load i32, i32* %11, align 4 - store i32 %12, i32* %v, align 4 - %13 = load i32, i32* %v, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %13) - %14 = load i64, i64* %.anon, align 8 - %add = add i64 %14, 1 - store i64 %add, i64* %.anon, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret void -} \ No newline at end of file diff --git a/test/test_suite14/initializer_lists/statics.c3t b/test/test_suite14/initializer_lists/statics.c3t deleted file mode 100644 index 6f906bd51..000000000 --- a/test/test_suite14/initializer_lists/statics.c3t +++ /dev/null @@ -1,92 +0,0 @@ -// #target: macos-x64 -import std::io; -import libc; -union Baz -{ - int x; - double y; -} -struct Bar -{ - int x; - int y; -} - - -fn void test() -{ - Bar[] b = { { 1, 2 } }; - static Bar[] c = { { 1, 2 } }; - libc::printf("%d %d\n", b[0].y, c[0].y); - b[0].y += 1; - c[0].y += 1; - -} -fn int main() -{ - test(); - test(); - test(); - return 1; -} - -/* #expect: statics.ll - -%Bar = type { i32, i32 } -%"Bar[]" = type { %Bar*, i64 } - -@"ct$statics_Baz" = linkonce constant %.introspect { i8 11, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"ct$statics_Bar" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@.taddr = private global [1 x %Bar] [%Bar { i32 1, i32 2 }], align 8 -@"test$c" = internal unnamed_addr global %"Bar[]" { %Bar* getelementptr inbounds ([1 x %Bar], [1 x %Bar]* @.taddr, i32 0, i32 0), i64 1 }, align 8 -@.str = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1 - -define void @statics_test() #0 { -entry: - %b = alloca %"Bar[]", align 8 - %literal = alloca [1 x %Bar], align 4 - %0 = getelementptr inbounds [1 x %Bar], [1 x %Bar]* %literal, i64 0, i64 0 - %1 = getelementptr inbounds %Bar, %Bar* %0, i32 0, i32 0 - store i32 1, i32* %1, align 4 - %2 = getelementptr inbounds %Bar, %Bar* %0, i32 0, i32 1 - store i32 2, i32* %2, align 4 - %3 = bitcast [1 x %Bar]* %literal to %Bar* - %4 = insertvalue %"Bar[]" undef, %Bar* %3, 0 - %5 = insertvalue %"Bar[]" %4, i64 1, 1 - store %"Bar[]" %5, %"Bar[]"* %b, align 8 - %6 = getelementptr inbounds %"Bar[]", %"Bar[]"* %b, i32 0, i32 0 - %7 = load %Bar*, %Bar** %6, align 8 - %ptroffset = getelementptr inbounds %Bar, %Bar* %7, i64 0 - %8 = getelementptr inbounds %Bar, %Bar* %ptroffset, i32 0, i32 1 - %9 = load i32, i32* %8, align 4 - %10 = load %Bar*, %Bar** getelementptr inbounds (%"Bar[]", %"Bar[]"* @"test$c", i32 0, i32 0), align 8 - %ptroffset1 = getelementptr inbounds %Bar, %Bar* %10, i64 0 - %11 = getelementptr inbounds %Bar, %Bar* %ptroffset1, i32 0, i32 1 - %12 = load i32, i32* %11, align 4 - %13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i32 %9, i32 %12) - %14 = getelementptr inbounds %"Bar[]", %"Bar[]"* %b, i32 0, i32 0 - %15 = load %Bar*, %Bar** %14, align 8 - %ptroffset2 = getelementptr inbounds %Bar, %Bar* %15, i64 0 - %16 = getelementptr inbounds %Bar, %Bar* %ptroffset2, i32 0, i32 1 - %17 = load i32, i32* %16, align 4 - %add = add i32 %17, 1 - store i32 %add, i32* %16, align 4 - %18 = load %Bar*, %Bar** getelementptr inbounds (%"Bar[]", %"Bar[]"* @"test$c", i32 0, i32 0), align 8 - %ptroffset3 = getelementptr inbounds %Bar, %Bar* %18, i64 0 - %19 = getelementptr inbounds %Bar, %Bar* %ptroffset3, i32 0, i32 1 - %20 = load i32, i32* %19, align 4 - %add4 = add i32 %20, 1 - store i32 %add4, i32* %19, align 4 - ret void -} - -; Function Attrs: nounwind -define i32 @main() #0 { -entry: - call void @statics_test() - call void @statics_test() - call void @statics_test() - ret i32 1 -} - -declare i32 @printf(i8*, ...) diff --git a/test/test_suite14/initializer_lists/subarrays.c3t b/test/test_suite14/initializer_lists/subarrays.c3t deleted file mode 100644 index 9696251ad..000000000 --- a/test/test_suite14/initializer_lists/subarrays.c3t +++ /dev/null @@ -1,169 +0,0 @@ -// #target: macos-x64 - -import std::io; -import std::core::mem; -import libc; -union Baz -{ - int x; - double y; -} -struct Bar -{ - int x; - int y; -} - - -Bar[] arrbar = { { 3, 4 }, { 8, 9 }}; -int[] xd = { 1, 2 }; -int* fofeo = &&(int[2]{ 3, 4 }); - -fn int main() -{ - Bar w = arrbar[1]; - libc::printf("%d\n", arrbar[1].x); - int[] x = { 1, 2, 3 }; - int* y = &&(int[3]{ 123, 234, 567 }); - io::println("Start:"); - libc::printf("X len: %d mid element %d\n", (int)(x.len), x[1]); - libc::printf("Y mid element %d\n", y[1]); - libc::printf("Fofeo second element %d\n", fofeo[1]); - Baz ffe = { .x = 1 }; - int[1] azz = {}; - - //var $foo = { 1, 2, 3 }; - bool xy = ! int[] { 1, 2, 3 }; - if (!xy) io::println("Ok"); - Bar b = {}; - Baz z = {}; - int[] sub = {}; - Bar[] foo = {}; - Baz[3] baz = {}; - return 1; -} - -/* #expect: subarrays.ll - -%Bar = type { i32, i32 } -%"Bar[]" = type { %Bar*, i64 } -%"int[]" = type { i32*, i64 } -%Baz = type { double } - -@"ct$subarrays_Baz" = linkonce constant %.introspect { i8 11, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"ct$subarrays_Bar" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@.taddr = private global [2 x %Bar] [%Bar { i32 3, i32 4 }, %Bar { i32 8, i32 9 }], align 8 -@subarrays_arrbar = local_unnamed_addr global %"Bar[]" { %Bar* getelementptr inbounds ([2 x %Bar], [2 x %Bar]* @.taddr, i32 0, i32 0), i64 2 }, align 8 -@.taddr.3 = private global [2 x i32] [i32 1, i32 2], align 4 -@subarrays_xd = local_unnamed_addr global %"int[]" { i32* getelementptr inbounds ([2 x i32], [2 x i32]* @.taddr.3, i32 0, i32 0), i64 2 }, align 8 -@.taddr.4 = private global [2 x i32] [i32 3, i32 4], align 4 -@subarrays_fofeo = local_unnamed_addr global i32* getelementptr inbounds ([2 x i32], [2 x i32]* @.taddr.4, i32 0, i32 0), align 8 -@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 -@.str.5 = private unnamed_addr constant [7 x i8] c"Start:\00", align 1 -@.str.6 = private unnamed_addr constant [26 x i8] c"X len: %d mid element %d\0A\00", align 1 -@.str.7 = private unnamed_addr constant [18 x i8] c"Y mid element %d\0A\00", align 1 -@.str.8 = private unnamed_addr constant [25 x i8] c"Fofeo second element %d\0A\00", align 1 -@.__const = private unnamed_addr constant { i32, [4 x i8] } { i32 1, [4 x i8] undef }, align 8 -@.str.9 = private unnamed_addr constant [3 x i8] c"Ok\00", align 1 - -; Function Attrs: nounwind -define i32 @main() #0 { -entry: - %w = alloca %Bar, align 4 - %x = alloca %"int[]", align 8 - %literal = alloca [3 x i32], align 4 - %y = alloca i32*, align 8 - %literal2 = alloca [3 x i32], align 4 - %ffe = alloca %Baz, align 8 - %azz = alloca [1 x i32], align 4 - %xy = alloca i8, align 1 - %literal6 = alloca [3 x i32], align 4 - %b = alloca %Bar, align 4 - %z = alloca %Baz, align 8 - %sub = alloca %"int[]", align 8 - %foo = alloca %"Bar[]", align 8 - %baz = alloca [3 x %Baz], align 16 - %0 = load %Bar*, %Bar** getelementptr inbounds (%"Bar[]", %"Bar[]"* @subarrays_arrbar, i32 0, i32 0), align 8 - %ptroffset = getelementptr inbounds %Bar, %Bar* %0, i64 1 - %1 = bitcast %Bar* %w to i8* - %2 = bitcast %Bar* %ptroffset to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 %2, i32 8, i1 false) - %3 = load %Bar*, %Bar** getelementptr inbounds (%"Bar[]", %"Bar[]"* @subarrays_arrbar, i32 0, i32 0), align 8 - %ptroffset1 = getelementptr inbounds %Bar, %Bar* %3, i64 1 - %4 = getelementptr inbounds %Bar, %Bar* %ptroffset1, i32 0, i32 0 - %5 = load i32, i32* %4, align 4 - %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %5) - %7 = getelementptr inbounds [3 x i32], [3 x i32]* %literal, i64 0, i64 0 - store i32 1, i32* %7, align 4 - %8 = getelementptr inbounds [3 x i32], [3 x i32]* %literal, i64 0, i64 1 - store i32 2, i32* %8, align 4 - %9 = getelementptr inbounds [3 x i32], [3 x i32]* %literal, i64 0, i64 2 - store i32 3, i32* %9, align 4 - %10 = bitcast [3 x i32]* %literal to i32* - %11 = insertvalue %"int[]" undef, i32* %10, 0 - %12 = insertvalue %"int[]" %11, i64 3, 1 - store %"int[]" %12, %"int[]"* %x, align 8 - %13 = getelementptr inbounds [3 x i32], [3 x i32]* %literal2, i64 0, i64 0 - store i32 123, i32* %13, align 4 - %14 = getelementptr inbounds [3 x i32], [3 x i32]* %literal2, i64 0, i64 1 - store i32 234, i32* %14, align 4 - %15 = getelementptr inbounds [3 x i32], [3 x i32]* %literal2, i64 0, i64 2 - store i32 567, i32* %15, align 4 - %ptrptr = bitcast [3 x i32]* %literal2 to i32* - store i32* %ptrptr, i32** %y, align 8 - %16 = call i32 @std_io_println(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0)) #3 - %17 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 1 - %18 = load i64, i64* %17, align 8 - %uisitrunc = trunc i64 %18 to i32 - %19 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 0 - %20 = load i32*, i32** %19, align 8 - %ptroffset3 = getelementptr inbounds i32, i32* %20, i64 1 - %21 = load i32, i32* %ptroffset3, align 4 - %22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i32 0, i32 0), i32 %uisitrunc, i32 %21) - %23 = load i32*, i32** %y, align 8 - %ptroffset4 = getelementptr inbounds i32, i32* %23, i64 1 - %24 = load i32, i32* %ptroffset4, align 4 - %25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i32 0, i32 0), i32 %24) - %26 = load i32*, i32** @subarrays_fofeo, align 8 - %ptroffset5 = getelementptr inbounds i32, i32* %26, i64 1 - %27 = load i32, i32* %ptroffset5, align 4 - %28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i32 0, i32 0), i32 %27) - %29 = bitcast %Baz* %ffe to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %29, i8* align 8 bitcast ({ i32, [4 x i8] }* @.__const to i8*), i32 8, i1 false) - %30 = getelementptr inbounds [1 x i32], [1 x i32]* %azz, i64 0, i64 0 - store i32 0, i32* %30, align 4 - %31 = getelementptr inbounds [3 x i32], [3 x i32]* %literal6, i64 0, i64 0 - store i32 1, i32* %31, align 4 - %32 = getelementptr inbounds [3 x i32], [3 x i32]* %literal6, i64 0, i64 1 - store i32 2, i32* %32, align 4 - %33 = getelementptr inbounds [3 x i32], [3 x i32]* %literal6, i64 0, i64 2 - store i32 3, i32* %33, align 4 - %34 = bitcast [3 x i32]* %literal6 to i32* - %35 = insertvalue %"int[]" undef, i32* %34, 0 - %36 = insertvalue %"int[]" %35, i64 3, 1 - %37 = extractvalue %"int[]" %36, 1 - %not = icmp eq i64 %37, 0 - %38 = zext i1 %not to i8 - store i8 %38, i8* %xy, align 1 - %39 = load i8, i8* %xy, align 1 - %40 = trunc i8 %39 to i1 - %not7 = xor i1 %40, true - br i1 %not7, label %if.then, label %if.exit - -if.then: ; preds = %entry - %41 = call i32 @std_io_println(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0)) #3 - br label %if.exit - -if.exit: ; preds = %if.then, %entry - %42 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 0 - store i32 0, i32* %42, align 4 - %43 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1 - store i32 0, i32* %43, align 4 - %44 = bitcast %Baz* %z to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %44, i8 0, i64 8, i1 false) - store %"int[]" zeroinitializer, %"int[]"* %sub, align 8 - store %"Bar[]" zeroinitializer, %"Bar[]"* %foo, align 8 - %45 = bitcast [3 x %Baz]* %baz to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %45, i8 0, i64 24, i1 false) - ret i32 1 -} diff --git a/test/test_suite14/initializer_lists/zero_inferred_array.c3 b/test/test_suite14/initializer_lists/zero_inferred_array.c3 deleted file mode 100644 index 4c41938f1..000000000 --- a/test/test_suite14/initializer_lists/zero_inferred_array.c3 +++ /dev/null @@ -1,4 +0,0 @@ -fn void test() -{ - int[*] a = {}; // #error: Zero length -} \ No newline at end of file diff --git a/test/test_suite14/initializer_lists/zero_init.c3t b/test/test_suite14/initializer_lists/zero_init.c3t deleted file mode 100644 index 78605540f..000000000 --- a/test/test_suite14/initializer_lists/zero_init.c3t +++ /dev/null @@ -1,61 +0,0 @@ -// #target: macos-x64 - -union Baz -{ - int x; - double y; -} -struct Bar -{ - int x; - int y; -} - -struct Mega -{ - int[10] z; -} - -fn int test() -{ - Mega m = {}; - int[1] azz = {}; - Bar b = {}; - Baz z = {}; - int[] sub = {}; - Bar[] foo = {}; - Baz[3] baz = {}; - return 1; -} - -// #expect: zero_init.ll - -%Mega = type { [10 x i32] } -%Bar = type { i32, i32 } -%Baz = type { double } - -define i32 @zero_init_test() #0 { -entry: - %m = alloca %Mega, align 4 - %azz = alloca [1 x i32], align 4 - %b = alloca %Bar, align 4 - %z = alloca %Baz, align 8 - %sub = alloca %"int[]", align 8 - %foo = alloca %"Bar[]", align 8 - %baz = alloca [3 x %Baz], align 16 - %0 = bitcast %Mega* %m to i8* - call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 40, i1 false) - %1 = getelementptr inbounds [1 x i32], [1 x i32]* %azz, i64 0, i64 0 - store i32 0, i32* %1, align 4 - %2 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 0 - store i32 0, i32* %2, align 4 - %3 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1 - store i32 0, i32* %3, align 4 - %4 = bitcast %Baz* %z to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %4, i8 0, i64 8, i1 false) - store %"int[]" zeroinitializer, %"int[]"* %sub, align 8 - store %"Bar[]" zeroinitializer, %"Bar[]"* %foo, align 8 - %5 = bitcast [3 x %Baz]* %baz to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %5, i8 0, i64 24, i1 false) - ret i32 1 -} diff --git a/test/test_suite14/lambda/lambda_in_macro.c3t b/test/test_suite14/lambda/lambda_in_macro.c3t deleted file mode 100644 index e35f8bf90..000000000 --- a/test/test_suite14/lambda/lambda_in_macro.c3t +++ /dev/null @@ -1,45 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -define Callback1 = fn double(double x); -define Callback2 = fn int(int y); - -macro test2(y) -{ - var $Type = $typeof(y); - return fn $Type($typeof(y) x) { return x * x; }; -} - -macro test($Type) -{ - $Type z = fn (x) { return x * x; }; - return z; -} - -fn void main() -{ - io::printfn("val: %d", test(Callback2)(3)); - io::printfn("val: %s", test(Callback1)(3.3)); - io::printfn("val: %s", test(Callback1)(3.3)); - io::printfn("val: %d", test2(1)(3)); - io::printfn("val: %d", test2(1)(3)); - io::printfn("val: %s", test2(1.0)(3.3)); -} - -/* #expect: test.ll - - store i32 (i32)* @"test_test$lambda1", i32 (i32)** %z, align 8 - %1 = call i32 %0(i32 3) - store double (double)* @"test_test$lambda2", double (double)** %z4, align 8 - %14 = call double %13(double 3.300000e+00) - store double (double)* @"test_test$lambda2", double (double)** %z14, align 8 - %27 = call double %26(double 3.300000e+00) - %39 = call i32 @"test_test2$lambda3"(i32 3) - %51 = call i32 @"test_test2$lambda3"(i32 3) - %63 = call double @"test_test2$lambda4"(double 3.300000e+00) - -define internal double @"test_test2$lambda4"(double %0) #0 { -define internal i32 @"test_test2$lambda3"(i32 %0) #0 { -define internal double @"test_test$lambda2"(double %0) #0 { -define internal i32 @"test_test$lambda1"(i32 %0) #0 { diff --git a/test/test_suite14/lambda/nested_lambda_def.c3t b/test/test_suite14/lambda/nested_lambda_def.c3t deleted file mode 100644 index 461bb709c..000000000 --- a/test/test_suite14/lambda/nested_lambda_def.c3t +++ /dev/null @@ -1,87 +0,0 @@ -// #target: macos-x64 -module abc; -import bar; -import std::io; - -fn int xy(Callback a) => a(); - -fn void main() -{ - const Callback F = bar::get_callback(); - int z = xy(F); - z = xy(F); - io::printfn("val: %d", z); -} - -module foo; -import bar; -import std::io; - -private int xz = 0; - - -macro Callback get_callback() -{ - return fn int() { return bar::get_callback2()(); }; -} - -macro Callback get_callback2() -{ - return fn int() { io::printfn("Hello"); return ++xz; }; -} - -module bar; -import foo; -define Callback = fn int(); - -macro Callback get_callback() -{ - return fn int() { return foo::get_callback()(); }; -} - -macro Callback get_callback2() -{ - return fn int() { return foo::get_callback2()(); }; -} - -/* #expect: abc.ll - - store i32 ()* @"bar_get_callback$lambda1", i32 ()** %F, align 8 - %0 = call i32 @abc_xy(i32 ()* @"bar_get_callback$lambda1") - %1 = call i32 @abc_xy(i32 ()* @"bar_get_callback$lambda1") - -declare i32 @"bar_get_callback$lambda1"() - -// #expect: foo.ll - -define i32 @"foo_get_callback$lambda1"() #0 { -entry: - %0 = call i32 @"bar_get_callback2$lambda2"() - ret i32 %0 -} -define i32 @"foo_get_callback2$lambda2"() #0 { - - %4 = load i32, i32* @foo_xz, align 4 - %add = add i32 %4, 1 - store i32 %add, i32* @foo_xz, align 4 - ret i32 %add -} -declare i32 @"bar_get_callback2$lambda2"() - -// #expect: bar.ll - -define i32 @"bar_get_callback$lambda1"() #0 { -entry: - %0 = call i32 @"foo_get_callback$lambda1"() - ret i32 %0 -} - -define i32 @"bar_get_callback2$lambda2"() #0 { -entry: - %0 = call i32 @"foo_get_callback2$lambda2"() - ret i32 %0 -} - -declare i32 @"foo_get_callback$lambda1"() -declare i32 @"foo_get_callback2$lambda2"() - diff --git a/test/test_suite14/lambda/simple_lambda.c3t b/test/test_suite14/lambda/simple_lambda.c3t deleted file mode 100644 index a0a0f197d..000000000 --- a/test/test_suite14/lambda/simple_lambda.c3t +++ /dev/null @@ -1,29 +0,0 @@ -// #target: macos-x64 -import std::io; -import std::math::vector; -import std::math; - -define Callback = fn int(); - -fn int xy(Callback a) => a(); - -fn void main() -{ - const Callback F = fn int() { io::printfn("Hello"); return 23; }; - int z = xy(F); - io::printfn("%d", z); - int y = xy(fn () { return 3; }); -} - -/* #expect: simple_lambda.ll - -define void @simple_lambda_main() #0 { -entry: - %F = alloca i32 ()*, align 8 - %z = alloca i32, align 4 - store i32 ()* @"simple_lambda_main$lambda1", i32 ()** %F, align 8 - %0 = call i32 @simple_lambda_xy(i32 ()* @"simple_lambda_main$lambda1") - %12 = call i32 @simple_lambda_xy(i32 ()* @"simple_lambda_main$lambda2") - -define internal i32 @"simple_lambda_main$lambda2"() #0 -define internal i32 @"simple_lambda_main$lambda1"() #0 \ No newline at end of file diff --git a/test/test_suite14/lexing/expected_directive.c3 b/test/test_suite14/lexing/expected_directive.c3 deleted file mode 100644 index 57f71a053..000000000 --- a/test/test_suite14/lexing/expected_directive.c3 +++ /dev/null @@ -1,4 +0,0 @@ -/** -@hello -@param feij > 0 // #error: Expected end of line. -*/ diff --git a/test/test_suite14/lexing/invalid_hex_in_hexarray.c3 b/test/test_suite14/lexing/invalid_hex_in_hexarray.c3 deleted file mode 100644 index 536515a37..000000000 --- a/test/test_suite14/lexing/invalid_hex_in_hexarray.c3 +++ /dev/null @@ -1 +0,0 @@ -x"abcé" // #error: This isn't a valid hexadecimal digit \ No newline at end of file diff --git a/test/test_suite14/lexing/invalid_hex_in_hexarray2.c3 b/test/test_suite14/lexing/invalid_hex_in_hexarray2.c3 deleted file mode 100644 index eb571c8b2..000000000 --- a/test/test_suite14/lexing/invalid_hex_in_hexarray2.c3 +++ /dev/null @@ -1 +0,0 @@ -x"abcg" // #error: 'g' isn't a valid hexadecimal digit \ No newline at end of file diff --git a/test/test_suite14/lexing/no_builtin.c3 b/test/test_suite14/lexing/no_builtin.c3 deleted file mode 100644 index 09ff7d6d9..000000000 --- a/test/test_suite14/lexing/no_builtin.c3 +++ /dev/null @@ -1,2 +0,0 @@ - -$$1 // #error: Expected a letter after \ No newline at end of file diff --git a/test/test_suite14/literals/bad_bitwidth.c3 b/test/test_suite14/literals/bad_bitwidth.c3 deleted file mode 100644 index e5cf75f34..000000000 --- a/test/test_suite14/literals/bad_bitwidth.c3 +++ /dev/null @@ -1,4 +0,0 @@ -int i = 4i15; // #error: Integer type suffix should be i8, i16, i32, i64 or i128 -int j = 4i1024; // #error: Integer type suffix should be i8, i16, i32, i64 or i128 -int k = 4i65536; // #error: Integer type suffix should be i8, i16, i32, i64 or i128 -int l = 4i016; // #error: Integer type suffix should be i8, i16, i32, i64 or i128 \ No newline at end of file diff --git a/test/test_suite14/literals/bin_literal.c3t b/test/test_suite14/literals/bin_literal.c3t deleted file mode 100644 index 09ca91bcd..000000000 --- a/test/test_suite14/literals/bin_literal.c3t +++ /dev/null @@ -1,121 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -import std::bits; -fn void main() -{ - int a = 123; - int b = -23; - int c = $$min(a, b); - int d = $$max(a, b); - io::printfn("%d %d", c, d); - char z = 0b1101_1101; - io::printfn("%b %b %b", z, z.rotr(1), z.rotl(1)); -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %a = alloca i32, align 4 - %b = alloca i32, align 4 - %c = alloca i32, align 4 - %d = alloca i32, align 4 - %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %z = alloca i8, align 1 - %retparam1 = alloca i64, align 8 - %varargslots2 = alloca [3 x %variant], align 16 - %i = alloca i8, align 1 - %shift = alloca i8, align 1 - %taddr3 = alloca i8, align 1 - %i4 = alloca i8, align 1 - %shift5 = alloca i8, align 1 - %taddr6 = alloca i8, align 1 - %taddr7 = alloca %"variant[]", align 8 - store i32 123, i32* %a, align 4 - store i32 -23, i32* %b, align 4 - %0 = load i32, i32* %a, align 4 - %1 = load i32, i32* %b, align 4 - %2 = call i32 @llvm.smin.i32(i32 %0, i32 %1) - store i32 %2, i32* %c, align 4 - %3 = load i32, i32* %a, align 4 - %4 = load i32, i32* %b, align 4 - %5 = call i32 @llvm.smax.i32(i32 %3, i32 %4) - store i32 %5, i32* %d, align 4 - %6 = bitcast i32* %c to i8* - %7 = insertvalue %variant undef, i8* %6, 0 - %8 = insertvalue %variant %7, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %9 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 0 - store %variant %8, %variant* %9, align 16 - %10 = bitcast i32* %d to i8* - %11 = insertvalue %variant undef, i8* %10, 0 - %12 = insertvalue %variant %11, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %13 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 1 - store %variant %12, %variant* %13, align 16 - %14 = bitcast [2 x %variant]* %varargslots to %variant* - %15 = insertvalue %"variant[]" undef, %variant* %14, 0 - %16 = insertvalue %"variant[]" %15, i64 2, 1 - store %"variant[]" %16, %"variant[]"* %taddr, align 8 - %17 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %18 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 0 - %lo = load i8*, i8** %18, align 8 - %19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 1 - %hi = load i64, i64* %19, align 8 - %20 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 5, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %20, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - store i8 -35, i8* %z, align 1 - %21 = insertvalue %variant undef, i8* %z, 0 - %22 = insertvalue %variant %21, i64 ptrtoint (%.introspect* @"ct$char" to i64), 1 - %23 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots2, i64 0, i64 0 - store %variant %22, %variant* %23, align 16 - %24 = load i8, i8* %z, align 1 - store i8 %24, i8* %i, align 1 - store i8 1, i8* %shift, align 1 - %25 = load i8, i8* %i, align 1 - %26 = load i8, i8* %i, align 1 - %27 = load i8, i8* %shift, align 1 - %28 = call i8 @llvm.fshr.i8(i8 %25, i8 %26, i8 %27) - store i8 %28, i8* %taddr3, align 1 - %29 = insertvalue %variant undef, i8* %taddr3, 0 - %30 = insertvalue %variant %29, i64 ptrtoint (%.introspect* @"ct$char" to i64), 1 - %31 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots2, i64 0, i64 1 - store %variant %30, %variant* %31, align 16 - %32 = load i8, i8* %z, align 1 - store i8 %32, i8* %i4, align 1 - store i8 1, i8* %shift5, align 1 - %33 = load i8, i8* %i4, align 1 - %34 = load i8, i8* %i4, align 1 - %35 = load i8, i8* %shift5, align 1 - %36 = call i8 @llvm.fshl.i8(i8 %33, i8 %34, i8 %35) - store i8 %36, i8* %taddr6, align 1 - %37 = insertvalue %variant undef, i8* %taddr6, 0 - %38 = insertvalue %variant %37, i64 ptrtoint (%.introspect* @"ct$char" to i64), 1 - %39 = getelementptr inbounds [3 x %variant], [3 x %variant]* %varargslots2, i64 0, i64 2 - store %variant %38, %variant* %39, align 16 - %40 = bitcast [3 x %variant]* %varargslots2 to %variant* - %41 = insertvalue %"variant[]" undef, %variant* %40, 0 - %42 = insertvalue %"variant[]" %41, i64 3, 1 - store %"variant[]" %42, %"variant[]"* %taddr7, align 8 - %43 = bitcast %"variant[]"* %taddr7 to { i8*, i64 }* - %44 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 0 - %lo8 = load i8*, i8** %44, align 8 - %45 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 1 - %hi9 = load i64, i64* %45, align 8 - %46 = call i64 @std_io_printfn(i64* %retparam1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i64 8, i8* %lo8, i64 %hi9) - %not_err10 = icmp eq i64 %46, 0 - br i1 %not_err10, label %after_check11, label %voiderr12 - -after_check11: ; preds = %voiderr - br label %voiderr12 - -voiderr12: ; preds = %after_check11, %voiderr - ret void -} diff --git a/test/test_suite14/literals/literal_general.c3t b/test/test_suite14/literals/literal_general.c3t deleted file mode 100644 index d623f4585..000000000 --- a/test/test_suite14/literals/literal_general.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 -module foo; - -int aa = 'ä'; -int x = 'ABCD'; -uint y = 'Helo'; -ushort z = '\x31\x32'; -int d = '\u0031'; -char b = '\x40'; -uint abc = '\U133222AB'; -uint foo = '謝'; - -/* #expect: foo.ll - -@foo_aa = local_unnamed_addr global i32 228, align 4 -@foo_x = local_unnamed_addr global i32 1094861636, align 4 -@foo_y = local_unnamed_addr global i32 1214606447, align 4 -@foo_z = local_unnamed_addr global i16 12594, align 2 -@foo_d = local_unnamed_addr global i32 49, align 4 -@foo_b = local_unnamed_addr global i8 64, align 1 -@foo_abc = local_unnamed_addr global i32 322052779, align 4 -@foo_foo = local_unnamed_addr global i32 35613, align 4 diff --git a/test/test_suite14/literals/multi_unicode.c3 b/test/test_suite14/literals/multi_unicode.c3 deleted file mode 100644 index 4d328167c..000000000 --- a/test/test_suite14/literals/multi_unicode.c3 +++ /dev/null @@ -1 +0,0 @@ -int d = '\u0031\u0032\u0033\u0034'; // #error: can only contain one character \ No newline at end of file diff --git a/test/test_suite14/literals/radix_numbers_errors.c3 b/test/test_suite14/literals/radix_numbers_errors.c3 deleted file mode 100644 index a37970238..000000000 --- a/test/test_suite14/literals/radix_numbers_errors.c3 +++ /dev/null @@ -1,17 +0,0 @@ -0o8 // #error: An expression starting with '0o' should be followed by octal numbers (0-7). - -0o% // #error: An expression starting with '0o' should be followed by octal numbers (0-7). - -0o08 // #error: An expression starting with '0o' should be followed by octal numbers (0-7). - -0b2 // #error: An expression starting with '0b' should be followed by binary digits - -0b# // #error: An expression starting with '0b' should be followed by binary digits - -0b12 // #error: An expression starting with '0b' should be followed by binary digits - -0xg // #error: '0x' starts a hexadecimal number, so the next character should be 0-9, a-f or A-F. - -0x! // #error: '0x' starts a hexadecimal number, so the next character should be 0-9, a-f or A-F. - -0b // #error: An expression starting with '0b' should be followed by binary digits diff --git a/test/test_suite14/literals/too_small.c3 b/test/test_suite14/literals/too_small.c3 deleted file mode 100644 index 129389d4d..000000000 --- a/test/test_suite14/literals/too_small.c3 +++ /dev/null @@ -1,2 +0,0 @@ -char aa = 'ä'; -short hmm = '謝'; // #error: unicode character \ No newline at end of file diff --git a/test/test_suite14/macro_methods/access.c3 b/test/test_suite14/macro_methods/access.c3 deleted file mode 100644 index 153445d93..000000000 --- a/test/test_suite14/macro_methods/access.c3 +++ /dev/null @@ -1,35 +0,0 @@ -struct An1 -{ - An3 x; -} - -struct An3 -{ - An2 y; -} - -struct An2 -{ - int z; -} - -extern fn void printf(char *string); - -macro void An2.@helloWorld(An2 &an2) -{ - printf("An2 hello\n"); -} - -fn void check() -{ - printf("Checking\n"); -} - - -fn void main() -{ - An1 an; - an.x.y.@helloWorld(); - An2 a; - a.@helloWorld(); -} \ No newline at end of file diff --git a/test/test_suite14/macro_methods/macro_method_different_args.c3t b/test/test_suite14/macro_methods/macro_method_different_args.c3t deleted file mode 100644 index ea8356e07..000000000 --- a/test/test_suite14/macro_methods/macro_method_different_args.c3t +++ /dev/null @@ -1,65 +0,0 @@ -// #target: macos-x64 -module foo; - -extern fn void printf(char* fmt, ...); -struct Foo -{ - int x; -} - -macro void Foo.@hello(Foo &this) { this.x = 3; printf("-%d\n", this.x); } -macro void Foo.hello(Foo* this) { this.x = 4; printf("-%d\n", this.x); } -macro void Foo.hello2(Foo this) { this.x = 5; printf("-%d\n", this.x); } - -fn void main() -{ - Foo a; - a.@hello(); - printf("%d\n", a.x); - a.hello(); - printf("%d\n", a.x); - a.hello2(); - printf("%d\n", a.x); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %a = alloca %Foo, align 4 - %this = alloca %Foo*, align 8 - %this1 = alloca %Foo, align 4 - %0 = bitcast %Foo* %a to i32* - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds %Foo, %Foo* %a, i32 0, i32 0 - store i32 3, i32* %1, align 4 - %2 = getelementptr inbounds %Foo, %Foo* %a, i32 0, i32 0 - %3 = load i32, i32* %2, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 %3) - %4 = getelementptr inbounds %Foo, %Foo* %a, i32 0, i32 0 - %5 = load i32, i32* %4, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %5) - store %Foo* %a, %Foo** %this, align 8 - %6 = load %Foo*, %Foo** %this, align 8 - %7 = getelementptr inbounds %Foo, %Foo* %6, i32 0, i32 0 - store i32 4, i32* %7, align 4 - %8 = load %Foo*, %Foo** %this, align 8 - %9 = getelementptr inbounds %Foo, %Foo* %8, i32 0, i32 0 - %10 = load i32, i32* %9, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 %10) - %11 = getelementptr inbounds %Foo, %Foo* %a, i32 0, i32 0 - %12 = load i32, i32* %11, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 %12) - %13 = bitcast %Foo* %this1 to i8* - %14 = bitcast %Foo* %a to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %13, i8* align 4 %14, i32 4, i1 false) - %15 = getelementptr inbounds %Foo, %Foo* %this1, i32 0, i32 0 - store i32 5, i32* %15, align 4 - %16 = getelementptr inbounds %Foo, %Foo* %this1, i32 0, i32 0 - %17 = load i32, i32* %16, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i32 %17) - %18 = getelementptr inbounds %Foo, %Foo* %a, i32 0, i32 0 - %19 = load i32, i32* %18, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 %19) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/macro_methods/macro_method_fails.c3 b/test/test_suite14/macro_methods/macro_method_fails.c3 deleted file mode 100644 index 780b4f24f..000000000 --- a/test/test_suite14/macro_methods/macro_method_fails.c3 +++ /dev/null @@ -1,46 +0,0 @@ -struct An1 -{ - An3 x; -} - -struct An3 -{ - An2 y; -} - -struct An2 -{ - int y; -} - -extern fn void printf(char* string); - -macro void An2.@helloWorld(An2 &an2) -{ - printf("An2 hello\n"); -} - -fn void check() -{ - printf("Checking\n"); -} - - -fn void test1() -{ - An1 an; - an.x.y.@helloWorld; // #error: macro name must be followed by '(' -} - -fn void test2() -{ - An2 a; - a.@helloWorld; // #error: A macro name must be followed by '(' -} - -fn void test3() -{ - An2 a; - a.@helloWorld.b; // #error: There is no member or method 'b' on 'void' -} - diff --git a/test/test_suite14/macro_methods/macro_method_first_param.c3 b/test/test_suite14/macro_methods/macro_method_first_param.c3 deleted file mode 100644 index 58267b9a5..000000000 --- a/test/test_suite14/macro_methods/macro_method_first_param.c3 +++ /dev/null @@ -1,4 +0,0 @@ - -struct Foo { int y; } - -macro Foo.text(...) => f.y; // #error: The first parameter to this method must \ No newline at end of file diff --git a/test/test_suite14/macro_methods/macro_methods_defined_twice.c3 b/test/test_suite14/macro_methods/macro_methods_defined_twice.c3 deleted file mode 100644 index ebfd29857..000000000 --- a/test/test_suite14/macro_methods/macro_methods_defined_twice.c3 +++ /dev/null @@ -1,32 +0,0 @@ -module foo; - -struct Bar -{ - int x; -} - -module baz; -import foo; -import std::io; - -macro void foo::Bar.@test(Bar &bar) -{ - io::println("Inside of baz::Bar.test"); -} - -module bad; -import foo; -macro void Bar.@test(Bar &bar) // #error: This macro method is already defined for 'Bar'. -{ - io::println("Inside of baz::Bar.test"); -} - -module abc; -import foo; - -fn void main() -{ - Bar bar; - bar.@test(); -} - diff --git a/test/test_suite14/macros/hash_ident.c3 b/test/test_suite14/macros/hash_ident.c3 deleted file mode 100644 index 4dfa36bd1..000000000 --- a/test/test_suite14/macros/hash_ident.c3 +++ /dev/null @@ -1,25 +0,0 @@ -macro int @cofefe(#a) -{ - int y = 0; - return #a + #a; -} - -private int abc = 1; - -fn int xx() -{ - abc++; - return abc; -} - -fn void main() -{ - var $x = 0; - int x = 0; - @cofefe(x += 1); - @cofefe(xx()); - @cofefe($x += 1); - $assert($x == 2); - @cofefe(y += 1); // #error: 'y' could not be found -} - diff --git a/test/test_suite14/macros/macro_body_as_value.c3 b/test/test_suite14/macros/macro_body_as_value.c3 deleted file mode 100644 index b8df768a4..000000000 --- a/test/test_suite14/macros/macro_body_as_value.c3 +++ /dev/null @@ -1,12 +0,0 @@ -macro @foo4(;@body) -{ - @body; // #error: must be followed by () -} - -fn void test() -{ - @foo4() - { - int x = 0; - }; -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_body_defer.c3t b/test/test_suite14/macros/macro_body_defer.c3t deleted file mode 100644 index 99f483c9a..000000000 --- a/test/test_suite14/macros/macro_body_defer.c3t +++ /dev/null @@ -1,123 +0,0 @@ -// #target: macos-x64 -module foo; -extern fn void printf(char*,...); - -fn int! foo() { return 1; } - -macro @foo_test(int i; @body()) -{ - defer printf("%d\n", i); - @body(); - defer printf("2:%d\n", i); -} - -macro foo_defer() -{ - defer printf("A\n"); - printf("B\n"); - defer printf("C\n"); -} -fn void! main() -{ - foo_defer(); - @foo_test(34) { - defer printf("inside_defer\n"); - }; - while (1) - { - defer printf("outside\n"); - @foo_test(3) - { - defer printf("Inside will it jump?\n"); - printf("3-test\n"); - break; - }; - } - while (1) - { - defer printf("outside2\n"); - printf("--\n"); - @foo_test(3) - { - defer printf("Inside will it jump?\n"); - printf("--3\n"); - return; - }; - } - printf("Should not reach\n"); -} - -/* #expect: foo.ll - -define i64 @foo_foo(i32* %0) #0 { -entry: - %reterr = alloca i64, align 8 - store i32 1, i32* %0, align 4 - ret i64 0 -} - -define i64 @foo_main() #0 { -entry: - %i = alloca i32, align 4 - %i1 = alloca i32, align 4 - %i3 = alloca i32, align 4 - %reterr = alloca i64, align 8 - %reterr5 = alloca i64, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0)) - store i32 34, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0)) - %0 = load i32, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i32 %0) - %1 = load i32, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 %1) - br label %loop.body - -loop.body: ; preds = %entry - store i32 3, i32* %i1, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i32 0, i32 0)) - %2 = load i32, i32* %i1, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i32 %2) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0)) - br label %loop.exit - -loop.exit: ; preds = %loop.body - br label %loop.body2 - -loop.body2: ; preds = %loop.exit - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0)) - store i32 3, i32* %i3, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i32 0, i32 0)) - %3 = load i32, i32* %i3, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i32 %3) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i32 0, i32 0)) - ret i64 0 - -loop.exit4: ; No predecessors! - call void (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i32 0, i32 0)) - ret i64 0 -} - -; Function Attrs: nounwind -define i32 @main(i32 %0, i8** %1) #0 { -entry: - %2 = call i64 @foo_main() - %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %2, i64* %error_var, align 8 - br label %noerr_block - -after_check: ; preds = %entry - br label %noerr_block - -noerr_block: ; preds = %after_check, %assign_optional - %3 = load i64, i64* %error_var, align 8 - %neq = icmp ne i64 %3, 0 - %ternary = select i1 %neq, i32 1, i32 0 - ret i32 %ternary -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_body_errors.c3 b/test/test_suite14/macros/macro_body_errors.c3 deleted file mode 100644 index de4de1fa2..000000000 --- a/test/test_suite14/macros/macro_body_errors.c3 +++ /dev/null @@ -1,7 +0,0 @@ - -macro foo1(;) { } // #error: Expected an ending ')' or a block parameter on the - -macro foo2(;@body()) {} - -macro foo3(;@body) {} - diff --git a/test/test_suite14/macros/macro_calls_prefix.c3 b/test/test_suite14/macros/macro_calls_prefix.c3 deleted file mode 100644 index 6d93d08af..000000000 --- a/test/test_suite14/macros/macro_calls_prefix.c3 +++ /dev/null @@ -1,11 +0,0 @@ -macro foo(a, $b, $Type) {} - -macro @foo2(a, $b, $Type) {} - -macro bar(&x) // #error: Ref and expression parameters -{} - -macro baz(#y) {} // #error: Ref and expression parameters - -macro baz2(a; @body()) {} // #error: Names of macros - diff --git a/test/test_suite14/macros/macro_common.c3t b/test/test_suite14/macros/macro_common.c3t deleted file mode 100644 index 1d477bde1..000000000 --- a/test/test_suite14/macros/macro_common.c3t +++ /dev/null @@ -1,52 +0,0 @@ -module test; - -macro frab(x) -{ - if (!x) return 0; - return 0.0; -} - -fn void test2() -{ - frab(1); - frab(0); -} - -/* #expect: test.ll - -define void @test_test2() #0 { -entry: - %x = alloca i32, align 4 - %blockret = alloca double, align 8 - %x1 = alloca i32, align 4 - %blockret2 = alloca double, align 8 - store i32 1, i32* %x, align 4 - %0 = load i32, i32* %x, align 4 - %not = icmp eq i32 %0, 0 - br i1 %not, label %if.then, label %if.exit - -if.then: ; preds = %entry - store double 0.000000e+00, double* %blockret, align 8 - br label %expr_block.exit - -if.exit: ; preds = %entry - store double 0.000000e+00, double* %blockret, align 8 - br label %expr_block.exit - -expr_block.exit: ; preds = %if.exit, %if.then - store i32 0, i32* %x1, align 4 - %1 = load i32, i32* %x1, align 4 - %not3 = icmp eq i32 %1, 0 - br i1 %not3, label %if.then4, label %if.exit5 - -if.then4: ; preds = %expr_block.exit - store double 0.000000e+00, double* %blockret2, align 8 - br label %expr_block.exit6 - -if.exit5: ; preds = %expr_block.exit - store double 0.000000e+00, double* %blockret2, align 8 - br label %expr_block.exit6 - -expr_block.exit6: ; preds = %if.exit5, %if.then4 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_convert_literal.c3 b/test/test_suite14/macros/macro_convert_literal.c3 deleted file mode 100644 index 25d7900c6..000000000 --- a/test/test_suite14/macros/macro_convert_literal.c3 +++ /dev/null @@ -1,12 +0,0 @@ -module foo; -import libc; - -macro foo(y) -{ - return y * y; -} - -fn void main() -{ - libc::printf("%d\n", foo(10)); -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_defer_exit.c3t b/test/test_suite14/macros/macro_defer_exit.c3t deleted file mode 100644 index 27506384a..000000000 --- a/test/test_suite14/macros/macro_defer_exit.c3t +++ /dev/null @@ -1,83 +0,0 @@ -// #target: macos-x64 -module foo; -extern fn void printf(char*,...); - -macro int abc(x) -{ - defer printf("Out x %d\n", x); - x *= 2; - if (x > 100) return x = x - 100; - printf("Normal end\n"); - return x; -} - -fn void main() -{ - defer printf("On exit\n"); - abc(123); - abc(3); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %x = alloca i32, align 4 - %blockret = alloca i32, align 4 - %x1 = alloca i32, align 4 - %blockret2 = alloca i32, align 4 - store i32 123, i32* %x, align 4 - %0 = load i32, i32* %x, align 4 - %mul = mul i32 %0, 2 - store i32 %mul, i32* %x, align 4 - %1 = load i32, i32* %x, align 4 - %gt = icmp sgt i32 %1, 100 - br i1 %gt, label %if.then, label %if.exit - -if.then: ; preds = %entry - %2 = load i32, i32* %x, align 4 - %sub = sub i32 %2, 100 - store i32 %sub, i32* %x, align 4 - %3 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i32 %3) - store i32 %sub, i32* %blockret, align 4 - br label %expr_block.exit - -if.exit: ; preds = %entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0)) - %4 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i32 %4) - %5 = load i32, i32* %x, align 4 - store i32 %5, i32* %blockret, align 4 - br label %expr_block.exit - -expr_block.exit: ; preds = %if.exit, %if.then - store i32 3, i32* %x1, align 4 - %6 = load i32, i32* %x1, align 4 - %mul3 = mul i32 %6, 2 - store i32 %mul3, i32* %x1, align 4 - %7 = load i32, i32* %x1, align 4 - %gt4 = icmp sgt i32 %7, 100 - br i1 %gt4, label %if.then5, label %if.exit7 - -if.then5: ; preds = %expr_block.exit - %8 = load i32, i32* %x1, align 4 - %sub6 = sub i32 %8, 100 - store i32 %sub6, i32* %x1, align 4 - %9 = load i32, i32* %x1, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i32 %9) - store i32 %sub6, i32* %blockret2, align 4 - br label %expr_block.exit8 - -if.exit7: ; preds = %expr_block.exit - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0)) - %10 = load i32, i32* %x1, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i32 %10) - %11 = load i32, i32* %x1, align 4 - store i32 %11, i32* %blockret2, align 4 - br label %expr_block.exit8 - -expr_block.exit8: ; preds = %if.exit7, %if.then5 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0)) - ret void -} diff --git a/test/test_suite14/macros/macro_defer_scope.c3t b/test/test_suite14/macros/macro_defer_scope.c3t deleted file mode 100644 index 9fa2788a2..000000000 --- a/test/test_suite14/macros/macro_defer_scope.c3t +++ /dev/null @@ -1,43 +0,0 @@ -// #target: macos-x64 -module foo; -macro int @cofefe(#a) -{ - int x = 0; - defer printf("Was here\n"); - return #a + #a; -} - -extern fn int printf(char *, ...); - -fn void main() -{ - int x = 0; - @cofefe(x += 1); - printf("%d\n", x); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %x = alloca i32, align 4 - %blockret = alloca i32, align 4 - %x1 = alloca i32, align 4 - store i32 0, i32* %x, align 4 - store i32 0, i32* %x1, align 4 - %0 = load i32, i32* %x, align 4 - %add = add i32 %0, 1 - store i32 %add, i32* %x, align 4 - %1 = load i32, i32* %x, align 4 - %add2 = add i32 %1, 1 - store i32 %add2, i32* %x, align 4 - %add3 = add i32 %add, %add2 - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0)) - store i32 %add3, i32* %blockret, align 4 - br label %expr_block.exit - -expr_block.exit: ; preds = %entry - %3 = load i32, i32* %x, align 4 - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %3) - ret void -} diff --git a/test/test_suite14/macros/macro_defer_with_body.c3t b/test/test_suite14/macros/macro_defer_with_body.c3t deleted file mode 100644 index bf7698fc3..000000000 --- a/test/test_suite14/macros/macro_defer_with_body.c3t +++ /dev/null @@ -1,55 +0,0 @@ -module foo; -macro int @cofefe(a; @body(x)) -{ - @body(a); - @body(a); - return 1; -} - -extern fn int printf(char *, ...); - -fn void main() -{ - int x = 0; - @cofefe(1; int y) - { - defer printf("defer: %d\n", x++); - printf("%d\n", x++); - }; - printf("Done!\n"); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %x = alloca i32, align 4 - %a = alloca i32, align 4 - %y = alloca i32, align 4 - store i32 0, i32* %x, align 4 - store i32 1, i32* %a, align 4 - %0 = load i32, i32* %a, align 4 - store i32 %0, i32* %y, align 4 - %1 = load i32, i32* %x, align 4 - %add = add i32 %1, 1 - store i32 %add, i32* %x, align 4 - %2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %1) - %3 = load i32, i32* %x, align 4 - %add1 = add i32 %3, 1 - store i32 %add1, i32* %x, align 4 - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i32 %3) - %5 = load i32, i32* %a, align 4 - store i32 %5, i32* %y, align 4 - %6 = load i32, i32* %x, align 4 - %add2 = add i32 %6, 1 - store i32 %add2, i32* %x, align 4 - %7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 %6) - %8 = load i32, i32* %x, align 4 - %add3 = add i32 %8, 1 - store i32 %add3, i32* %x, align 4 - %9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i32 %8) - %10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0)) - ret void -} - - diff --git a/test/test_suite14/macros/macro_failable_return_rethrow.c3t b/test/test_suite14/macros/macro_failable_return_rethrow.c3t deleted file mode 100644 index 0366af5d7..000000000 --- a/test/test_suite14/macros/macro_failable_return_rethrow.c3t +++ /dev/null @@ -1,49 +0,0 @@ -// #target: macos-x64 -module test; -fn int! xy() -{ - return 1; -} -macro int! foo() -{ - xy()?; - return 1; -} -fn void main() -{ - foo()!!; -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %error_var = alloca i64, align 8 - %blockret = alloca i32, align 4 - %error_var1 = alloca i64, align 8 - %retparam = alloca i32, align 4 - %0 = call i64 @test_xy(i32* %retparam) - %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %entry - store i64 %0, i64* %error_var1, align 8 - br label %guard_block - -after_check: ; preds = %entry - br label %noerr_block - -guard_block: ; preds = %assign_optional - ret void - -noerr_block: ; preds = %after_check - store i32 1, i32* %blockret, align 4 - br label %expr_block.exit - -expr_block.exit: ; preds = %noerr_block - %1 = load i32, i32* %blockret, align 4 - br label %noerr_block2 - -noerr_block2: ; preds = %expr_block.exit - ret void -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_import_res_private.c3t b/test/test_suite14/macros/macro_import_res_private.c3t deleted file mode 100644 index 95bfa9cd3..000000000 --- a/test/test_suite14/macros/macro_import_res_private.c3t +++ /dev/null @@ -1,26 +0,0 @@ -// #target: macos-x64 -module foo; -private fn void foo1() -{} - -module bar; -import private foo; -macro bar1() -{ - foo::foo1(); -} - -module baz; -import bar; -fn void test() -{ - bar::bar1(); -} - -/* #expect: baz.ll - -define void @baz_test() #0 { -entry: - call void @foo_foo1() - ret void -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_import_resolution.c3 b/test/test_suite14/macros/macro_import_resolution.c3 deleted file mode 100644 index 1772389fd..000000000 --- a/test/test_suite14/macros/macro_import_resolution.c3 +++ /dev/null @@ -1,13 +0,0 @@ -module foo; -import bar; -fn void run() -{ - bar::test(); -} - -module bar; -import baz; -macro test() { baz::test(); } - -module baz; -fn void test() {} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_missing_return.c3 b/test/test_suite14/macros/macro_missing_return.c3 deleted file mode 100644 index af0f4e982..000000000 --- a/test/test_suite14/macros/macro_missing_return.c3 +++ /dev/null @@ -1,12 +0,0 @@ -module test; -import std::io; - -macro int foo(int y) // #error: Missing return -{ - if (y > 5) return y; -} - -fn void main() -{ - int x = foo(3); -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_nested_labels.c3t b/test/test_suite14/macros/macro_nested_labels.c3t deleted file mode 100644 index 40f919364..000000000 --- a/test/test_suite14/macros/macro_nested_labels.c3t +++ /dev/null @@ -1,356 +0,0 @@ -module test; - -extern fn void printf(char *string, ...); - -macro checker(int x, $i) -{ - var $indent = 3 - $i; - for (int i = 0; i < $indent; i++) printf(" "); - printf("Enter %d\n", $i); - while FOO: (x-- > 0) - { - for (int i = 0; i < $indent; i++) printf(" "); - printf("Helo %d\n", x); - $if ($i > 0): - checker(x, $i - 1); - $endif; - if (x % 2 == 0) break FOO; - } - for (int i = 0; i < $indent; i++) printf(" "); - printf("Exit %d\n", $i); -} - -fn void main() -{ - int ab = 7; - checker(ab, 3); -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %ab = alloca i32, align 4 - %x = alloca i32, align 4 - %i = alloca i32, align 4 - %i3 = alloca i32, align 4 - %x9 = alloca i32, align 4 - %i10 = alloca i32, align 4 - %i20 = alloca i32, align 4 - %x26 = alloca i32, align 4 - %i27 = alloca i32, align 4 - %i37 = alloca i32, align 4 - %x43 = alloca i32, align 4 - %i44 = alloca i32, align 4 - %i54 = alloca i32, align 4 - %i61 = alloca i32, align 4 - %i72 = alloca i32, align 4 - %i83 = alloca i32, align 4 - %i94 = alloca i32, align 4 - store i32 7, i32* %ab, align 4 - %0 = load i32, i32* %ab, align 4 - store i32 %0, i32* %x, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %1 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %1, 0 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)) - %2 = load i32, i32* %i, align 4 - %add = add i32 %2, 1 - store i32 %add, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 3) - br label %loop.cond1 - -loop.cond1: ; preds = %if.exit92, %loop.exit - %3 = load i32, i32* %x, align 4 - %sub = sub i32 %3, 1 - store i32 %sub, i32* %x, align 4 - %gt = icmp sgt i32 %3, 0 - br i1 %gt, label %loop.body2, label %loop.exit93 - -loop.body2: ; preds = %loop.cond1 - store i32 0, i32* %i3, align 4 - br label %loop.cond4 - -loop.cond4: ; preds = %loop.body6, %loop.body2 - %4 = load i32, i32* %i3, align 4 - %lt5 = icmp slt i32 %4, 0 - br i1 %lt5, label %loop.body6, label %loop.exit8 - -loop.body6: ; preds = %loop.cond4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0)) - %5 = load i32, i32* %i3, align 4 - %add7 = add i32 %5, 1 - store i32 %add7, i32* %i3, align 4 - br label %loop.cond4 - -loop.exit8: ; preds = %loop.cond4 - %6 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i32 %6) - %7 = load i32, i32* %x, align 4 - store i32 %7, i32* %x9, align 4 - store i32 0, i32* %i10, align 4 - br label %loop.cond11 - -loop.cond11: ; preds = %loop.body13, %loop.exit8 - %8 = load i32, i32* %i10, align 4 - %lt12 = icmp slt i32 %8, 1 - br i1 %lt12, label %loop.body13, label %loop.exit15 - -loop.body13: ; preds = %loop.cond11 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0)) - %9 = load i32, i32* %i10, align 4 - %add14 = add i32 %9, 1 - store i32 %add14, i32* %i10, align 4 - br label %loop.cond11 - -loop.exit15: ; preds = %loop.cond11 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i32 2) - br label %loop.cond16 - -loop.cond16: ; preds = %if.exit81, %loop.exit15 - %10 = load i32, i32* %x9, align 4 - %sub17 = sub i32 %10, 1 - store i32 %sub17, i32* %x9, align 4 - %gt18 = icmp sgt i32 %10, 0 - br i1 %gt18, label %loop.body19, label %loop.exit82 - -loop.body19: ; preds = %loop.cond16 - store i32 0, i32* %i20, align 4 - br label %loop.cond21 - -loop.cond21: ; preds = %loop.body23, %loop.body19 - %11 = load i32, i32* %i20, align 4 - %lt22 = icmp slt i32 %11, 1 - br i1 %lt22, label %loop.body23, label %loop.exit25 - -loop.body23: ; preds = %loop.cond21 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0)) - %12 = load i32, i32* %i20, align 4 - %add24 = add i32 %12, 1 - store i32 %add24, i32* %i20, align 4 - br label %loop.cond21 - -loop.exit25: ; preds = %loop.cond21 - %13 = load i32, i32* %x9, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i32 0, i32 0), i32 %13) - %14 = load i32, i32* %x9, align 4 - store i32 %14, i32* %x26, align 4 - store i32 0, i32* %i27, align 4 - br label %loop.cond28 - -loop.cond28: ; preds = %loop.body30, %loop.exit25 - %15 = load i32, i32* %i27, align 4 - %lt29 = icmp slt i32 %15, 2 - br i1 %lt29, label %loop.body30, label %loop.exit32 - -loop.body30: ; preds = %loop.cond28 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0)) - %16 = load i32, i32* %i27, align 4 - %add31 = add i32 %16, 1 - store i32 %add31, i32* %i27, align 4 - br label %loop.cond28 - -loop.exit32: ; preds = %loop.cond28 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), i32 1) - br label %loop.cond33 - -loop.cond33: ; preds = %if.exit70, %loop.exit32 - %17 = load i32, i32* %x26, align 4 - %sub34 = sub i32 %17, 1 - store i32 %sub34, i32* %x26, align 4 - %gt35 = icmp sgt i32 %17, 0 - br i1 %gt35, label %loop.body36, label %loop.exit71 - -loop.body36: ; preds = %loop.cond33 - store i32 0, i32* %i37, align 4 - br label %loop.cond38 - -loop.cond38: ; preds = %loop.body40, %loop.body36 - %18 = load i32, i32* %i37, align 4 - %lt39 = icmp slt i32 %18, 2 - br i1 %lt39, label %loop.body40, label %loop.exit42 - -loop.body40: ; preds = %loop.cond38 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i32 0, i32 0)) - %19 = load i32, i32* %i37, align 4 - %add41 = add i32 %19, 1 - store i32 %add41, i32* %i37, align 4 - br label %loop.cond38 - -loop.exit42: ; preds = %loop.cond38 - %20 = load i32, i32* %x26, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0), i32 %20) - %21 = load i32, i32* %x26, align 4 - store i32 %21, i32* %x43, align 4 - store i32 0, i32* %i44, align 4 - br label %loop.cond45 - -loop.cond45: ; preds = %loop.body47, %loop.exit42 - %22 = load i32, i32* %i44, align 4 - %lt46 = icmp slt i32 %22, 3 - br i1 %lt46, label %loop.body47, label %loop.exit49 - -loop.body47: ; preds = %loop.cond45 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i32 0, i32 0)) - %23 = load i32, i32* %i44, align 4 - %add48 = add i32 %23, 1 - store i32 %add48, i32* %i44, align 4 - br label %loop.cond45 - -loop.exit49: ; preds = %loop.cond45 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i32 0, i32 0), i32 0) - br label %loop.cond50 - -loop.cond50: ; preds = %if.exit, %loop.exit49 - %24 = load i32, i32* %x43, align 4 - %sub51 = sub i32 %24, 1 - store i32 %sub51, i32* %x43, align 4 - %gt52 = icmp sgt i32 %24, 0 - br i1 %gt52, label %loop.body53, label %loop.exit60 - -loop.body53: ; preds = %loop.cond50 - store i32 0, i32* %i54, align 4 - br label %loop.cond55 - -loop.cond55: ; preds = %loop.body57, %loop.body53 - %25 = load i32, i32* %i54, align 4 - %lt56 = icmp slt i32 %25, 3 - br i1 %lt56, label %loop.body57, label %loop.exit59 - -loop.body57: ; preds = %loop.cond55 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i32 0, i32 0)) - %26 = load i32, i32* %i54, align 4 - %add58 = add i32 %26, 1 - store i32 %add58, i32* %i54, align 4 - br label %loop.cond55 - -loop.exit59: ; preds = %loop.cond55 - %27 = load i32, i32* %x43, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i32 0, i32 0), i32 %27) - %28 = load i32, i32* %x43, align 4 - %smod = srem i32 %28, 2 - %eq = icmp eq i32 %smod, 0 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %loop.exit59 - br label %loop.exit60 - -if.exit: ; preds = %loop.exit59 - br label %loop.cond50 - -loop.exit60: ; preds = %if.then, %loop.cond50 - store i32 0, i32* %i61, align 4 - br label %loop.cond62 - -loop.cond62: ; preds = %loop.body64, %loop.exit60 - %29 = load i32, i32* %i61, align 4 - %lt63 = icmp slt i32 %29, 3 - br i1 %lt63, label %loop.body64, label %loop.exit66 - -loop.body64: ; preds = %loop.cond62 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i32 0, i32 0)) - %30 = load i32, i32* %i61, align 4 - %add65 = add i32 %30, 1 - store i32 %add65, i32* %i61, align 4 - br label %loop.cond62 - -loop.exit66: ; preds = %loop.cond62 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i32 0, i32 0), i32 0) - %31 = load i32, i32* %x26, align 4 - %smod67 = srem i32 %31, 2 - %eq68 = icmp eq i32 %smod67, 0 - br i1 %eq68, label %if.then69, label %if.exit70 - -if.then69: ; preds = %loop.exit66 - br label %loop.exit71 - -if.exit70: ; preds = %loop.exit66 - br label %loop.cond33 - -loop.exit71: ; preds = %if.then69, %loop.cond33 - store i32 0, i32* %i72, align 4 - br label %loop.cond73 - -loop.cond73: ; preds = %loop.body75, %loop.exit71 - %32 = load i32, i32* %i72, align 4 - %lt74 = icmp slt i32 %32, 2 - br i1 %lt74, label %loop.body75, label %loop.exit77 - -loop.body75: ; preds = %loop.cond73 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i32 0, i32 0)) - %33 = load i32, i32* %i72, align 4 - %add76 = add i32 %33, 1 - store i32 %add76, i32* %i72, align 4 - br label %loop.cond73 - -loop.exit77: ; preds = %loop.cond73 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i32 0, i32 0), i32 1) - %34 = load i32, i32* %x9, align 4 - %smod78 = srem i32 %34, 2 - %eq79 = icmp eq i32 %smod78, 0 - br i1 %eq79, label %if.then80, label %if.exit81 - -if.then80: ; preds = %loop.exit77 - br label %loop.exit82 - -if.exit81: ; preds = %loop.exit77 - br label %loop.cond16 - -loop.exit82: ; preds = %if.then80, %loop.cond16 - store i32 0, i32* %i83, align 4 - br label %loop.cond84 - -loop.cond84: ; preds = %loop.body86, %loop.exit82 - %35 = load i32, i32* %i83, align 4 - %lt85 = icmp slt i32 %35, 1 - br i1 %lt85, label %loop.body86, label %loop.exit88 - -loop.body86: ; preds = %loop.cond84 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.20, i32 0, i32 0)) - %36 = load i32, i32* %i83, align 4 - %add87 = add i32 %36, 1 - store i32 %add87, i32* %i83, align 4 - br label %loop.cond84 - -loop.exit88: ; preds = %loop.cond84 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i32 0, i32 0), i32 2) - %37 = load i32, i32* %x, align 4 - %smod89 = srem i32 %37, 2 - %eq90 = icmp eq i32 %smod89, 0 - br i1 %eq90, label %if.then91, label %if.exit92 - -if.then91: ; preds = %loop.exit88 - br label %loop.exit93 - -if.exit92: ; preds = %loop.exit88 - br label %loop.cond1 - -loop.exit93: ; preds = %if.then91, %loop.cond1 - store i32 0, i32* %i94, align 4 - br label %loop.cond95 - -loop.cond95: ; preds = %loop.body97, %loop.exit93 - %38 = load i32, i32* %i94, align 4 - %lt96 = icmp slt i32 %38, 0 - br i1 %lt96, label %loop.body97, label %loop.exit99 - -loop.body97: ; preds = %loop.cond95 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i32 0, i32 0)) - %39 = load i32, i32* %i94, align 4 - %add98 = add i32 %39, 1 - store i32 %add98, i32* %i94, align 4 - br label %loop.cond95 - -loop.exit99: ; preds = %loop.cond95 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.23, i32 0, i32 0), i32 3) - ret void -} diff --git a/test/test_suite14/macros/macro_resolution.c3 b/test/test_suite14/macros/macro_resolution.c3 deleted file mode 100644 index 37f80b138..000000000 --- a/test/test_suite14/macros/macro_resolution.c3 +++ /dev/null @@ -1,24 +0,0 @@ -module foo; -import bar; -fn void run() -{ - bar::test(); -} - -fn void run2() -{ - bar::test2(); -} - -private fn void tester() {} - -module bar; -macro test() -{ - tester(); // #error: 'tester' could not be found, did you spell it right -} - -macro test2() -{ - foo::tester(); // #error: 'foo::tester' could not be found, did you spell -} diff --git a/test/test_suite14/macros/macro_rtype.c3 b/test/test_suite14/macros/macro_rtype.c3 deleted file mode 100644 index 394d71612..000000000 --- a/test/test_suite14/macros/macro_rtype.c3 +++ /dev/null @@ -1,9 +0,0 @@ -macro int frob() -{ - return 0.0; // #error: int -} - -fn void test1() -{ - frob(); -} \ No newline at end of file diff --git a/test/test_suite14/macros/macro_typed_varargs.c3t b/test/test_suite14/macros/macro_typed_varargs.c3t deleted file mode 100644 index f0d058148..000000000 --- a/test/test_suite14/macros/macro_typed_varargs.c3t +++ /dev/null @@ -1,194 +0,0 @@ -// #target: macos-x64 - -module test; - -import std::io; - -macro foo(int... x) -{ - foreach (i : x) - { - io::printfn("%d", i); - } -} - -macro foo2(x...) -{ - foreach (i : x) - { - io::printfn("%d", *(int*)i); - } -} - -fn void main() -{ - foo(1, -1, 3141, 999 + 1); - foo2(1, -1, 3141, 999 + 1); -} - -/* #expect: test.ll - - -define void @test_main() #0 { -entry: - %x = alloca %"int[]", align 8 - %literal = alloca [4 x i32], align 16 - %.anon = alloca i64, align 8 - %.anon1 = alloca i64, align 8 - %i = alloca i32, align 4 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %x2 = alloca %"variant[]", align 8 - %literal3 = alloca [4 x %variant], align 16 - %taddr4 = alloca i32, align 4 - %taddr5 = alloca i32, align 4 - %taddr6 = alloca i32, align 4 - %taddr7 = alloca i32, align 4 - %.anon8 = alloca i64, align 8 - %.anon9 = alloca i64, align 8 - %i13 = alloca %variant, align 8 - %retparam15 = alloca i64, align 8 - %varargslots16 = alloca [1 x %variant], align 16 - %taddr17 = alloca %"variant[]", align 8 - %0 = getelementptr inbounds [4 x i32], [4 x i32]* %literal, i64 0, i64 0 - store i32 1, i32* %0, align 4 - %1 = getelementptr inbounds [4 x i32], [4 x i32]* %literal, i64 0, i64 1 - store i32 -1, i32* %1, align 4 - %2 = getelementptr inbounds [4 x i32], [4 x i32]* %literal, i64 0, i64 2 - store i32 3141, i32* %2, align 4 - %3 = getelementptr inbounds [4 x i32], [4 x i32]* %literal, i64 0, i64 3 - store i32 1000, i32* %3, align 4 - %4 = bitcast [4 x i32]* %literal to i32* - %5 = insertvalue %"int[]" undef, i32* %4, 0 - %6 = insertvalue %"int[]" %5, i64 4, 1 - store %"int[]" %6, %"int[]"* %x, align 8 - %7 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 1 - %8 = load i64, i64* %7, align 8 - store i64 %8, i64* %.anon, align 8 - store i64 0, i64* %.anon1, align 8 - br label %loop.cond - -loop.cond: ; preds = %voiderr, %entry - %9 = load i64, i64* %.anon1, align 8 - %10 = load i64, i64* %.anon, align 8 - %lt = icmp ult i64 %9, %10 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %11 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 0 - %12 = load i32*, i32** %11, align 8 - %13 = load i64, i64* %.anon1, align 8 - %ptroffset = getelementptr inbounds i32, i32* %12, i64 %13 - %14 = load i32, i32* %ptroffset, align 4 - store i32 %14, i32* %i, align 4 - %15 = bitcast i32* %i to i8* - %16 = insertvalue %variant undef, i8* %15, 0 - %17 = insertvalue %variant %16, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %18 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %17, %variant* %18, align 16 - %19 = bitcast [1 x %variant]* %varargslots to %variant* - %20 = insertvalue %"variant[]" undef, %variant* %19, 0 - %21 = insertvalue %"variant[]" %20, i64 1, 1 - store %"variant[]" %21, %"variant[]"* %taddr, align 8 - %22 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %22, i32 0, i32 0 - %lo = load i8*, i8** %23, align 8 - %24 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %22, i32 0, i32 1 - %hi = load i64, i64* %24, align 8 - %25 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i64 2, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %25, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %loop.body - br label %voiderr - -voiderr: ; preds = %after_check, %loop.body - %26 = load i64, i64* %.anon1, align 8 - %add = add i64 %26, 1 - store i64 %add, i64* %.anon1, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %27 = getelementptr inbounds [4 x %variant], [4 x %variant]* %literal3, i64 0, i64 0 - store i32 1, i32* %taddr4, align 4 - %28 = bitcast i32* %taddr4 to i8* - %29 = insertvalue %variant undef, i8* %28, 0 - %30 = insertvalue %variant %29, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %30, %variant* %27, align 8 - %31 = getelementptr inbounds [4 x %variant], [4 x %variant]* %literal3, i64 0, i64 1 - store i32 -1, i32* %taddr5, align 4 - %32 = bitcast i32* %taddr5 to i8* - %33 = insertvalue %variant undef, i8* %32, 0 - %34 = insertvalue %variant %33, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %34, %variant* %31, align 8 - %35 = getelementptr inbounds [4 x %variant], [4 x %variant]* %literal3, i64 0, i64 2 - store i32 3141, i32* %taddr6, align 4 - %36 = bitcast i32* %taddr6 to i8* - %37 = insertvalue %variant undef, i8* %36, 0 - %38 = insertvalue %variant %37, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %38, %variant* %35, align 8 - %39 = getelementptr inbounds [4 x %variant], [4 x %variant]* %literal3, i64 0, i64 3 - store i32 1000, i32* %taddr7, align 4 - %40 = bitcast i32* %taddr7 to i8* - %41 = insertvalue %variant undef, i8* %40, 0 - %42 = insertvalue %variant %41, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %42, %variant* %39, align 8 - %43 = bitcast [4 x %variant]* %literal3 to %variant* - %44 = insertvalue %"variant[]" undef, %variant* %43, 0 - %45 = insertvalue %"variant[]" %44, i64 4, 1 - store %"variant[]" %45, %"variant[]"* %x2, align 8 - %46 = getelementptr inbounds %"variant[]", %"variant[]"* %x2, i32 0, i32 1 - %47 = load i64, i64* %46, align 8 - store i64 %47, i64* %.anon8, align 8 - store i64 0, i64* %.anon9, align 8 - br label %loop.cond10 - -loop.cond10: ; preds = %voiderr22, %loop.exit - %48 = load i64, i64* %.anon9, align 8 - %49 = load i64, i64* %.anon8, align 8 - %lt11 = icmp ult i64 %48, %49 - br i1 %lt11, label %loop.body12, label %loop.exit24 - -loop.body12: ; preds = %loop.cond10 - %50 = getelementptr inbounds %"variant[]", %"variant[]"* %x2, i32 0, i32 0 - %51 = load %variant*, %variant** %50, align 8 - %52 = load i64, i64* %.anon9, align 8 - %ptroffset14 = getelementptr inbounds %variant, %variant* %51, i64 %52 - %53 = bitcast %variant* %i13 to i8* - %54 = bitcast %variant* %ptroffset14 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %53, i8* align 8 %54, i32 16, i1 false) - %55 = getelementptr inbounds %variant, %variant* %i13, i32 0, i32 0 - %56 = bitcast i8** %55 to i32** - %57 = load i32*, i32** %56, align 8 - %58 = bitcast i32* %57 to i8* - %59 = insertvalue %variant undef, i8* %58, 0 - %60 = insertvalue %variant %59, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %61 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots16, i64 0, i64 0 - store %variant %60, %variant* %61, align 16 - %62 = bitcast [1 x %variant]* %varargslots16 to %variant* - %63 = insertvalue %"variant[]" undef, %variant* %62, 0 - %64 = insertvalue %"variant[]" %63, i64 1, 1 - store %"variant[]" %64, %"variant[]"* %taddr17, align 8 - %65 = bitcast %"variant[]"* %taddr17 to { i8*, i64 }* - %66 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %65, i32 0, i32 0 - %lo18 = load i8*, i8** %66, align 8 - %67 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %65, i32 0, i32 1 - %hi19 = load i64, i64* %67, align 8 - %68 = call i64 @std_io_printfn(i64* %retparam15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i64 2, i8* %lo18, i64 %hi19) - %not_err20 = icmp eq i64 %68, 0 - br i1 %not_err20, label %after_check21, label %voiderr22 - -after_check21: ; preds = %loop.body12 - br label %voiderr22 - -voiderr22: ; preds = %after_check21, %loop.body12 - %69 = load i64, i64* %.anon9, align 8 - %add23 = add i64 %69, 1 - store i64 %add23, i64* %.anon9, align 8 - br label %loop.cond10 - -loop.exit24: ; preds = %loop.cond10 - ret void -} - diff --git a/test/test_suite14/macros/macro_untyped_varargs.c3 b/test/test_suite14/macros/macro_untyped_varargs.c3 deleted file mode 100644 index 2084ccac4..000000000 --- a/test/test_suite14/macros/macro_untyped_varargs.c3 +++ /dev/null @@ -1,25 +0,0 @@ -macro foo(...) -{ - $vaarg("hello"); // #error: Expected the argument index here - int x; - $vaarg(x); // #error: Vararg functions need a constant argument - $vaarg(-1); // #error: negative - $vaarg(100); // #error: varargs exist -} - -macro foo2(...) -{ - $vaconst(0); -} - -macro foo3(...) -{ - $vatype(0) a; -} -fn void main() -{ - foo(1, -1, 3141, 999 + 1); - int x; - foo2(x); // #error: This argument needs to be a compile time constant - foo3(3); // #error: The argument was not a type. -} diff --git a/test/test_suite14/macros/macro_untyped_varargs_2.c3t b/test/test_suite14/macros/macro_untyped_varargs_2.c3t deleted file mode 100644 index 58643834d..000000000 --- a/test/test_suite14/macros/macro_untyped_varargs_2.c3t +++ /dev/null @@ -1,384 +0,0 @@ -// #target: macos-x64 - -module test; - -import std::io; - -macro @foo(...) -{ - int i = $vaarg(1) + $vaarg(1); - int j = $vaexpr(2) + $vaexpr(2); - $for (var $i = 0; $i < $vacount; $i++): - io::printfn("%d", $vaarg($i)); - $endfor; -} - -macro foo2(...) -{ - $for (var $i = 0; $i < $vacount; $i++): - { - $vatype($i) x; - } - io::printfn("%s", $vatype($i).nameof); - $endfor; -} - -macro foo3(...) -{ - var $x = 0; - $for (var $i = 0; $i < $vacount; $i++): - $x += $vaconst($i); - $endfor; - return $x; -} - -macro @foo4(...) -{ - $typeof($varef(0)) a = $varef(0); - $varef(0) = $varef(1); - $varef(1) = a; -} -fn int ping(int val) -{ - io::printfn("Ping[%d]", val); - return val; -} - -fn void main() -{ - @foo(ping(1), ping(-1), ping(3141), ping(999 + 1)); - foo2(int, double); - var $x = foo3(1, 4, 100); - io::printfn("%d", $x); - int x = 123; - int y = 33; - @foo4(x, y); - io::printfn("%d, %d", x, y); - @foo4(x, y); - io::printfn("%d, %d", x, y); -} - -/* #expect: test.ll - -define i32 @test_ping(i32 %0) #0 { -entry: - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca i32, align 4 - %taddr1 = alloca %"variant[]", align 8 - store i32 %0, i32* %taddr, align 4 - %1 = bitcast i32* %taddr to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %4 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %3, %variant* %4, align 16 - %5 = bitcast [1 x %variant]* %varargslots to %variant* - %6 = insertvalue %"variant[]" undef, %variant* %5, 0 - %7 = insertvalue %"variant[]" %6, i64 1, 1 - store %"variant[]" %7, %"variant[]"* %taddr1, align 8 - %8 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0 - %lo = load i8*, i8** %9, align 8 - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1 - %hi = load i64, i64* %10, align 8 - %11 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i64 8, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %11, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - ret i32 %0 -} - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %.anon = alloca i32, align 4 - %.anon1 = alloca i32, align 4 - %.anon2 = alloca i32, align 4 - %.anon3 = alloca i32, align 4 - %i = alloca i32, align 4 - %j = alloca i32, align 4 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %retparam5 = alloca i64, align 8 - %varargslots6 = alloca [1 x %variant], align 16 - %taddr7 = alloca %"variant[]", align 8 - %retparam13 = alloca i64, align 8 - %varargslots14 = alloca [1 x %variant], align 16 - %taddr15 = alloca %"variant[]", align 8 - %retparam21 = alloca i64, align 8 - %varargslots22 = alloca [1 x %variant], align 16 - %taddr23 = alloca %"variant[]", align 8 - %x = alloca i32, align 4 - %retparam29 = alloca i64, align 8 - %varargslots30 = alloca [1 x %variant], align 16 - %taddr31 = alloca [3 x i8]*, align 8 - %taddr32 = alloca %"variant[]", align 8 - %x38 = alloca double, align 8 - %retparam39 = alloca i64, align 8 - %varargslots40 = alloca [1 x %variant], align 16 - %taddr41 = alloca [6 x i8]*, align 8 - %taddr42 = alloca %"variant[]", align 8 - %retparam48 = alloca i64, align 8 - %varargslots49 = alloca [1 x %variant], align 16 - %taddr50 = alloca i32, align 4 - %taddr51 = alloca %"variant[]", align 8 - %x57 = alloca i32, align 4 - %y = alloca i32, align 4 - %a = alloca i32, align 4 - %retparam58 = alloca i64, align 8 - %varargslots59 = alloca [2 x %variant], align 16 - %taddr60 = alloca %"variant[]", align 8 - %a66 = alloca i32, align 4 - %retparam67 = alloca i64, align 8 - %varargslots68 = alloca [2 x %variant], align 16 - %taddr69 = alloca %"variant[]", align 8 - %0 = call i32 @test_ping(i32 -1) - store i32 %0, i32* %.anon, align 4 - %1 = call i32 @test_ping(i32 1) - store i32 %1, i32* %.anon1, align 4 - %2 = call i32 @test_ping(i32 3141) - store i32 %2, i32* %.anon2, align 4 - %3 = call i32 @test_ping(i32 1000) - store i32 %3, i32* %.anon3, align 4 - %4 = load i32, i32* %.anon, align 4 - %5 = load i32, i32* %.anon, align 4 - %add = add i32 %4, %5 - store i32 %add, i32* %i, align 4 - %6 = call i32 @test_ping(i32 3141) - %7 = call i32 @test_ping(i32 3141) - %add4 = add i32 %6, %7 - store i32 %add4, i32* %j, align 4 - %8 = bitcast i32* %.anon1 to i8* - %9 = insertvalue %variant undef, i8* %8, 0 - %10 = insertvalue %variant %9, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %11 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %10, %variant* %11, align 16 - %12 = bitcast [1 x %variant]* %varargslots to %variant* - %13 = insertvalue %"variant[]" undef, %variant* %12, 0 - %14 = insertvalue %"variant[]" %13, i64 1, 1 - store %"variant[]" %14, %"variant[]"* %taddr, align 8 - %15 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %16 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 0 - %lo = load i8*, i8** %16, align 8 - %17 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %15, i32 0, i32 1 - %hi = load i64, i64* %17, align 8 - %18 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i64 2, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %18, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %19 = bitcast i32* %.anon to i8* - %20 = insertvalue %variant undef, i8* %19, 0 - %21 = insertvalue %variant %20, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %22 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots6, i64 0, i64 0 - store %variant %21, %variant* %22, align 16 - %23 = bitcast [1 x %variant]* %varargslots6 to %variant* - %24 = insertvalue %"variant[]" undef, %variant* %23, 0 - %25 = insertvalue %"variant[]" %24, i64 1, 1 - store %"variant[]" %25, %"variant[]"* %taddr7, align 8 - %26 = bitcast %"variant[]"* %taddr7 to { i8*, i64 }* - %27 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %26, i32 0, i32 0 - %lo8 = load i8*, i8** %27, align 8 - %28 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %26, i32 0, i32 1 - %hi9 = load i64, i64* %28, align 8 - %29 = call i64 @std_io_printfn(i64* %retparam5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i64 2, i8* %lo8, i64 %hi9) - %not_err10 = icmp eq i64 %29, 0 - br i1 %not_err10, label %after_check11, label %voiderr12 - -after_check11: ; preds = %voiderr - br label %voiderr12 - -voiderr12: ; preds = %after_check11, %voiderr - %30 = bitcast i32* %.anon2 to i8* - %31 = insertvalue %variant undef, i8* %30, 0 - %32 = insertvalue %variant %31, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %33 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots14, i64 0, i64 0 - store %variant %32, %variant* %33, align 16 - %34 = bitcast [1 x %variant]* %varargslots14 to %variant* - %35 = insertvalue %"variant[]" undef, %variant* %34, 0 - %36 = insertvalue %"variant[]" %35, i64 1, 1 - store %"variant[]" %36, %"variant[]"* %taddr15, align 8 - %37 = bitcast %"variant[]"* %taddr15 to { i8*, i64 }* - %38 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %37, i32 0, i32 0 - %lo16 = load i8*, i8** %38, align 8 - %39 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %37, i32 0, i32 1 - %hi17 = load i64, i64* %39, align 8 - %40 = call i64 @std_io_printfn(i64* %retparam13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i64 2, i8* %lo16, i64 %hi17) - %not_err18 = icmp eq i64 %40, 0 - br i1 %not_err18, label %after_check19, label %voiderr20 - -after_check19: ; preds = %voiderr12 - br label %voiderr20 - -voiderr20: ; preds = %after_check19, %voiderr12 - %41 = bitcast i32* %.anon3 to i8* - %42 = insertvalue %variant undef, i8* %41, 0 - %43 = insertvalue %variant %42, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %44 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots22, i64 0, i64 0 - store %variant %43, %variant* %44, align 16 - %45 = bitcast [1 x %variant]* %varargslots22 to %variant* - %46 = insertvalue %"variant[]" undef, %variant* %45, 0 - %47 = insertvalue %"variant[]" %46, i64 1, 1 - store %"variant[]" %47, %"variant[]"* %taddr23, align 8 - %48 = bitcast %"variant[]"* %taddr23 to { i8*, i64 }* - %49 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %48, i32 0, i32 0 - %lo24 = load i8*, i8** %49, align 8 - %50 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %48, i32 0, i32 1 - %hi25 = load i64, i64* %50, align 8 - %51 = call i64 @std_io_printfn(i64* %retparam21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i64 2, i8* %lo24, i64 %hi25) - %not_err26 = icmp eq i64 %51, 0 - br i1 %not_err26, label %after_check27, label %voiderr28 - -after_check27: ; preds = %voiderr20 - br label %voiderr28 - -voiderr28: ; preds = %after_check27, %voiderr20 - store i32 0, i32* %x, align 4 - store [3 x i8]* bitcast ([4 x i8]* @.str.6 to [3 x i8]*), [3 x i8]** %taddr31, align 8 - %52 = bitcast [3 x i8]** %taddr31 to i8* - %53 = insertvalue %variant undef, i8* %52, 0 - %54 = insertvalue %variant %53, i64 ptrtoint (%.introspect* @"ct$p$a3$char" to i64), 1 - %55 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots30, i64 0, i64 0 - store %variant %54, %variant* %55, align 16 - %56 = bitcast [1 x %variant]* %varargslots30 to %variant* - %57 = insertvalue %"variant[]" undef, %variant* %56, 0 - %58 = insertvalue %"variant[]" %57, i64 1, 1 - store %"variant[]" %58, %"variant[]"* %taddr32, align 8 - %59 = bitcast %"variant[]"* %taddr32 to { i8*, i64 }* - %60 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %59, i32 0, i32 0 - %lo33 = load i8*, i8** %60, align 8 - %61 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %59, i32 0, i32 1 - %hi34 = load i64, i64* %61, align 8 - %62 = call i64 @std_io_printfn(i64* %retparam29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i64 2, i8* %lo33, i64 %hi34) - %not_err35 = icmp eq i64 %62, 0 - br i1 %not_err35, label %after_check36, label %voiderr37 - -after_check36: ; preds = %voiderr28 - br label %voiderr37 - -voiderr37: ; preds = %after_check36, %voiderr28 - store double 0.000000e+00, double* %x38, align 8 - store [6 x i8]* bitcast ([7 x i8]* @.str.8 to [6 x i8]*), [6 x i8]** %taddr41, align 8 - %63 = bitcast [6 x i8]** %taddr41 to i8* - %64 = insertvalue %variant undef, i8* %63, 0 - %65 = insertvalue %variant %64, i64 ptrtoint (%.introspect* @"ct$p$a6$char" to i64), 1 - %66 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots40, i64 0, i64 0 - store %variant %65, %variant* %66, align 16 - %67 = bitcast [1 x %variant]* %varargslots40 to %variant* - %68 = insertvalue %"variant[]" undef, %variant* %67, 0 - %69 = insertvalue %"variant[]" %68, i64 1, 1 - store %"variant[]" %69, %"variant[]"* %taddr42, align 8 - %70 = bitcast %"variant[]"* %taddr42 to { i8*, i64 }* - %71 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %70, i32 0, i32 0 - %lo43 = load i8*, i8** %71, align 8 - %72 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %70, i32 0, i32 1 - %hi44 = load i64, i64* %72, align 8 - %73 = call i64 @std_io_printfn(i64* %retparam39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i64 2, i8* %lo43, i64 %hi44) - %not_err45 = icmp eq i64 %73, 0 - br i1 %not_err45, label %after_check46, label %voiderr47 - -after_check46: ; preds = %voiderr37 - br label %voiderr47 - -voiderr47: ; preds = %after_check46, %voiderr37 - store i32 105, i32* %taddr50, align 4 - %74 = bitcast i32* %taddr50 to i8* - %75 = insertvalue %variant undef, i8* %74, 0 - %76 = insertvalue %variant %75, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %77 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots49, i64 0, i64 0 - store %variant %76, %variant* %77, align 16 - %78 = bitcast [1 x %variant]* %varargslots49 to %variant* - %79 = insertvalue %"variant[]" undef, %variant* %78, 0 - %80 = insertvalue %"variant[]" %79, i64 1, 1 - store %"variant[]" %80, %"variant[]"* %taddr51, align 8 - %81 = bitcast %"variant[]"* %taddr51 to { i8*, i64 }* - %82 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %81, i32 0, i32 0 - %lo52 = load i8*, i8** %82, align 8 - %83 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %81, i32 0, i32 1 - %hi53 = load i64, i64* %83, align 8 - %84 = call i64 @std_io_printfn(i64* %retparam48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i64 2, i8* %lo52, i64 %hi53) - %not_err54 = icmp eq i64 %84, 0 - br i1 %not_err54, label %after_check55, label %voiderr56 - -after_check55: ; preds = %voiderr47 - br label %voiderr56 - -voiderr56: ; preds = %after_check55, %voiderr47 - store i32 123, i32* %x57, align 4 - store i32 33, i32* %y, align 4 - %85 = load i32, i32* %x57, align 4 - store i32 %85, i32* %a, align 4 - %86 = load i32, i32* %y, align 4 - store i32 %86, i32* %x57, align 4 - %87 = load i32, i32* %a, align 4 - store i32 %87, i32* %y, align 4 - %88 = bitcast i32* %x57 to i8* - %89 = insertvalue %variant undef, i8* %88, 0 - %90 = insertvalue %variant %89, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %91 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots59, i64 0, i64 0 - store %variant %90, %variant* %91, align 16 - %92 = bitcast i32* %y to i8* - %93 = insertvalue %variant undef, i8* %92, 0 - %94 = insertvalue %variant %93, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %95 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots59, i64 0, i64 1 - store %variant %94, %variant* %95, align 16 - %96 = bitcast [2 x %variant]* %varargslots59 to %variant* - %97 = insertvalue %"variant[]" undef, %variant* %96, 0 - %98 = insertvalue %"variant[]" %97, i64 2, 1 - store %"variant[]" %98, %"variant[]"* %taddr60, align 8 - %99 = bitcast %"variant[]"* %taddr60 to { i8*, i64 }* - %100 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %99, i32 0, i32 0 - %lo61 = load i8*, i8** %100, align 8 - %101 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %99, i32 0, i32 1 - %hi62 = load i64, i64* %101, align 8 - %102 = call i64 @std_io_printfn(i64* %retparam58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i32 0, i32 0), i64 6, i8* %lo61, i64 %hi62) - %not_err63 = icmp eq i64 %102, 0 - br i1 %not_err63, label %after_check64, label %voiderr65 - -after_check64: ; preds = %voiderr56 - br label %voiderr65 - -voiderr65: ; preds = %after_check64, %voiderr56 - %103 = load i32, i32* %x57, align 4 - store i32 %103, i32* %a66, align 4 - %104 = load i32, i32* %y, align 4 - store i32 %104, i32* %x57, align 4 - %105 = load i32, i32* %a66, align 4 - store i32 %105, i32* %y, align 4 - %106 = bitcast i32* %x57 to i8* - %107 = insertvalue %variant undef, i8* %106, 0 - %108 = insertvalue %variant %107, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %109 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots68, i64 0, i64 0 - store %variant %108, %variant* %109, align 16 - %110 = bitcast i32* %y to i8* - %111 = insertvalue %variant undef, i8* %110, 0 - %112 = insertvalue %variant %111, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %113 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots68, i64 0, i64 1 - store %variant %112, %variant* %113, align 16 - %114 = bitcast [2 x %variant]* %varargslots68 to %variant* - %115 = insertvalue %"variant[]" undef, %variant* %114, 0 - %116 = insertvalue %"variant[]" %115, i64 2, 1 - store %"variant[]" %116, %"variant[]"* %taddr69, align 8 - %117 = bitcast %"variant[]"* %taddr69 to { i8*, i64 }* - %118 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %117, i32 0, i32 0 - %lo70 = load i8*, i8** %118, align 8 - %119 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %117, i32 0, i32 1 - %hi71 = load i64, i64* %119, align 8 - %120 = call i64 @std_io_printfn(i64* %retparam67, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i32 0, i32 0), i64 6, i8* %lo70, i64 %hi71) - %not_err72 = icmp eq i64 %120, 0 - br i1 %not_err72, label %after_check73, label %voiderr74 - -after_check73: ; preds = %voiderr65 - br label %voiderr74 - -voiderr74: ; preds = %after_check73, %voiderr65 - ret void -} diff --git a/test/test_suite14/macros/macro_vasplat.c3t b/test/test_suite14/macros/macro_vasplat.c3t deleted file mode 100644 index 703022449..000000000 --- a/test/test_suite14/macros/macro_vasplat.c3t +++ /dev/null @@ -1,753 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -macro @hello(...) -{ - int[*] a = { 1, $vasplat(), 3 }; - foreach (i, x : a) io::printfn("%d: %d", i, x); -} - -macro @hello1(...) -{ - int[*] a = { 1, $vasplat() }; - foreach (i, x : a) io::printfn("x:%d: %d", i, x); -} - -macro @hello2(...) -{ - int[*] a = { $vasplat(), 888 }; - foreach (i, x : a) io::printfn("x:%d: %d", i, x); -} - -macro @hello3(...) -{ - int[*] a = { $vasplat() }; - foreach (i, x : a) io::printfn("x:%d: %d", i, x); -} - -macro @hello4(...) -{ - int[*] a = { 5, $vasplat(2..4), 77 }; - foreach (i, x : a) io::printfn("y:%d: %d", i, x); -} - -macro @hello5(...) -{ - int[*] a = { 5, $vasplat(2..), 77 }; - foreach (i, x : a) io::printfn("y:%d: %d", i, x); - int[*] b = { 55, $vasplat(2..^2), 88 }; - foreach (i, x : b) io::printfn("z:%d: %d", i, x); - int[*] c = { 55, $vasplat(0:^2), 88 }; - foreach (i, x : c) io::printfn("zz:%d: %d", i, x); -} - -macro @hello6(...) -{ - @hello(66, $vasplat()); -} -fn void main() -{ - @hello1(223, 326); - @hello1(); - @hello(26, 36); - @hello(); - @hello2(2123, 3326); - @hello2(); - @hello3(2123, 3326); - @hello4(1, 2, 3, 4, 5, 6, 7, 8); - @hello5(1, 2, 3, 4, 5, 6, 7, 8); - @hello6(1, 2, 3); -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %a = alloca [3 x i32], align 4 - %.anon = alloca i64, align 8 - %i = alloca i64, align 8 - %x = alloca i32, align 4 - %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %a1 = alloca [1 x i32], align 4 - %.anon2 = alloca i64, align 8 - %i6 = alloca i64, align 8 - %x7 = alloca i32, align 4 - %retparam8 = alloca i64, align 8 - %varargslots9 = alloca [2 x %variant], align 16 - %taddr10 = alloca %"variant[]", align 8 - %a18 = alloca [4 x i32], align 16 - %.anon19 = alloca i64, align 8 - %i23 = alloca i64, align 8 - %x24 = alloca i32, align 4 - %retparam25 = alloca i64, align 8 - %varargslots26 = alloca [2 x %variant], align 16 - %taddr27 = alloca %"variant[]", align 8 - %a35 = alloca [2 x i32], align 4 - %.anon36 = alloca i64, align 8 - %i40 = alloca i64, align 8 - %x41 = alloca i32, align 4 - %retparam42 = alloca i64, align 8 - %varargslots43 = alloca [2 x %variant], align 16 - %taddr44 = alloca %"variant[]", align 8 - %a52 = alloca [3 x i32], align 4 - %.anon53 = alloca i64, align 8 - %i57 = alloca i64, align 8 - %x58 = alloca i32, align 4 - %retparam59 = alloca i64, align 8 - %varargslots60 = alloca [2 x %variant], align 16 - %taddr61 = alloca %"variant[]", align 8 - %a69 = alloca [1 x i32], align 4 - %.anon70 = alloca i64, align 8 - %i74 = alloca i64, align 8 - %x75 = alloca i32, align 4 - %retparam76 = alloca i64, align 8 - %varargslots77 = alloca [2 x %variant], align 16 - %taddr78 = alloca %"variant[]", align 8 - %a86 = alloca [2 x i32], align 4 - %.anon87 = alloca i64, align 8 - %i91 = alloca i64, align 8 - %x92 = alloca i32, align 4 - %retparam93 = alloca i64, align 8 - %varargslots94 = alloca [2 x %variant], align 16 - %taddr95 = alloca %"variant[]", align 8 - %a103 = alloca [5 x i32], align 16 - %.anon104 = alloca i64, align 8 - %i108 = alloca i64, align 8 - %x109 = alloca i32, align 4 - %retparam110 = alloca i64, align 8 - %varargslots111 = alloca [2 x %variant], align 16 - %taddr112 = alloca %"variant[]", align 8 - %a120 = alloca [8 x i32], align 16 - %.anon121 = alloca i64, align 8 - %i125 = alloca i64, align 8 - %x126 = alloca i32, align 4 - %retparam127 = alloca i64, align 8 - %varargslots128 = alloca [2 x %variant], align 16 - %taddr129 = alloca %"variant[]", align 8 - %b = alloca [7 x i32], align 16 - %.anon137 = alloca i64, align 8 - %i141 = alloca i64, align 8 - %x142 = alloca i32, align 4 - %retparam143 = alloca i64, align 8 - %varargslots144 = alloca [2 x %variant], align 16 - %taddr145 = alloca %"variant[]", align 8 - %c = alloca [8 x i32], align 16 - %.anon153 = alloca i64, align 8 - %i157 = alloca i64, align 8 - %x158 = alloca i32, align 4 - %retparam159 = alloca i64, align 8 - %varargslots160 = alloca [2 x %variant], align 16 - %taddr161 = alloca %"variant[]", align 8 - %a169 = alloca [6 x i32], align 16 - %.anon170 = alloca i64, align 8 - %i174 = alloca i64, align 8 - %x175 = alloca i32, align 4 - %retparam176 = alloca i64, align 8 - %varargslots177 = alloca [2 x %variant], align 16 - %taddr178 = alloca %"variant[]", align 8 - %0 = bitcast [3 x i32]* %a to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - store i64 0, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %voiderr, %entry - %1 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 3, %1 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %2 = load i64, i64* %.anon, align 8 - store i64 %2, i64* %i, align 8 - %3 = load i64, i64* %.anon, align 8 - %4 = getelementptr inbounds [3 x i32], [3 x i32]* %a, i64 0, i64 %3 - %5 = load i32, i32* %4, align 4 - store i32 %5, i32* %x, align 4 - %6 = bitcast i64* %i to i8* - %7 = insertvalue %variant undef, i8* %6, 0 - %8 = insertvalue %variant %7, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %9 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 0 - store %variant %8, %variant* %9, align 16 - %10 = bitcast i32* %x to i8* - %11 = insertvalue %variant undef, i8* %10, 0 - %12 = insertvalue %variant %11, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %13 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 1 - store %variant %12, %variant* %13, align 16 - %14 = bitcast [2 x %variant]* %varargslots to %variant* - %15 = insertvalue %"variant[]" undef, %variant* %14, 0 - %16 = insertvalue %"variant[]" %15, i64 2, 1 - store %"variant[]" %16, %"variant[]"* %taddr, align 8 - %17 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %18 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 0 - %lo = load i8*, i8** %18, align 8 - %19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %17, i32 0, i32 1 - %hi = load i64, i64* %19, align 8 - %20 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i64 8, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %20, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %loop.body - br label %voiderr - -voiderr: ; preds = %after_check, %loop.body - %21 = load i64, i64* %.anon, align 8 - %add = add i64 %21, 1 - store i64 %add, i64* %.anon, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %22 = bitcast [1 x i32]* %a1 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %22, i8* align 4 bitcast ([1 x i32]* @.__const.1 to i8*), i32 4, i1 false) - store i64 0, i64* %.anon2, align 8 - br label %loop.cond3 - -loop.cond3: ; preds = %voiderr15, %loop.exit - %23 = load i64, i64* %.anon2, align 8 - %gt4 = icmp ugt i64 1, %23 - br i1 %gt4, label %loop.body5, label %loop.exit17 - -loop.body5: ; preds = %loop.cond3 - %24 = load i64, i64* %.anon2, align 8 - store i64 %24, i64* %i6, align 8 - %25 = load i64, i64* %.anon2, align 8 - %26 = getelementptr inbounds [1 x i32], [1 x i32]* %a1, i64 0, i64 %25 - %27 = load i32, i32* %26, align 4 - store i32 %27, i32* %x7, align 4 - %28 = bitcast i64* %i6 to i8* - %29 = insertvalue %variant undef, i8* %28, 0 - %30 = insertvalue %variant %29, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %31 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots9, i64 0, i64 0 - store %variant %30, %variant* %31, align 16 - %32 = bitcast i32* %x7 to i8* - %33 = insertvalue %variant undef, i8* %32, 0 - %34 = insertvalue %variant %33, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %35 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots9, i64 0, i64 1 - store %variant %34, %variant* %35, align 16 - %36 = bitcast [2 x %variant]* %varargslots9 to %variant* - %37 = insertvalue %"variant[]" undef, %variant* %36, 0 - %38 = insertvalue %"variant[]" %37, i64 2, 1 - store %"variant[]" %38, %"variant[]"* %taddr10, align 8 - %39 = bitcast %"variant[]"* %taddr10 to { i8*, i64 }* - %40 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %39, i32 0, i32 0 - %lo11 = load i8*, i8** %40, align 8 - %41 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %39, i32 0, i32 1 - %hi12 = load i64, i64* %41, align 8 - %42 = call i64 @std_io_printfn(i64* %retparam8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i64 8, i8* %lo11, i64 %hi12) - %not_err13 = icmp eq i64 %42, 0 - br i1 %not_err13, label %after_check14, label %voiderr15 - -after_check14: ; preds = %loop.body5 - br label %voiderr15 - -voiderr15: ; preds = %after_check14, %loop.body5 - %43 = load i64, i64* %.anon2, align 8 - %add16 = add i64 %43, 1 - store i64 %add16, i64* %.anon2, align 8 - br label %loop.cond3 - -loop.exit17: ; preds = %loop.cond3 - %44 = bitcast [4 x i32]* %a18 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %44, i8* align 16 bitcast ([4 x i32]* @.__const.3 to i8*), i32 16, i1 false) - store i64 0, i64* %.anon19, align 8 - br label %loop.cond20 - -loop.cond20: ; preds = %voiderr32, %loop.exit17 - %45 = load i64, i64* %.anon19, align 8 - %gt21 = icmp ugt i64 4, %45 - br i1 %gt21, label %loop.body22, label %loop.exit34 - -loop.body22: ; preds = %loop.cond20 - %46 = load i64, i64* %.anon19, align 8 - store i64 %46, i64* %i23, align 8 - %47 = load i64, i64* %.anon19, align 8 - %48 = getelementptr inbounds [4 x i32], [4 x i32]* %a18, i64 0, i64 %47 - %49 = load i32, i32* %48, align 4 - store i32 %49, i32* %x24, align 4 - %50 = bitcast i64* %i23 to i8* - %51 = insertvalue %variant undef, i8* %50, 0 - %52 = insertvalue %variant %51, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %53 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots26, i64 0, i64 0 - store %variant %52, %variant* %53, align 16 - %54 = bitcast i32* %x24 to i8* - %55 = insertvalue %variant undef, i8* %54, 0 - %56 = insertvalue %variant %55, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %57 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots26, i64 0, i64 1 - store %variant %56, %variant* %57, align 16 - %58 = bitcast [2 x %variant]* %varargslots26 to %variant* - %59 = insertvalue %"variant[]" undef, %variant* %58, 0 - %60 = insertvalue %"variant[]" %59, i64 2, 1 - store %"variant[]" %60, %"variant[]"* %taddr27, align 8 - %61 = bitcast %"variant[]"* %taddr27 to { i8*, i64 }* - %62 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %61, i32 0, i32 0 - %lo28 = load i8*, i8** %62, align 8 - %63 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %61, i32 0, i32 1 - %hi29 = load i64, i64* %63, align 8 - %64 = call i64 @std_io_printfn(i64* %retparam25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i64 6, i8* %lo28, i64 %hi29) - %not_err30 = icmp eq i64 %64, 0 - br i1 %not_err30, label %after_check31, label %voiderr32 - -after_check31: ; preds = %loop.body22 - br label %voiderr32 - -voiderr32: ; preds = %after_check31, %loop.body22 - %65 = load i64, i64* %.anon19, align 8 - %add33 = add i64 %65, 1 - store i64 %add33, i64* %.anon19, align 8 - br label %loop.cond20 - -loop.exit34: ; preds = %loop.cond20 - %66 = bitcast [2 x i32]* %a35 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %66, i8* align 4 bitcast ([2 x i32]* @.__const.5 to i8*), i32 8, i1 false) - store i64 0, i64* %.anon36, align 8 - br label %loop.cond37 - -loop.cond37: ; preds = %voiderr49, %loop.exit34 - %67 = load i64, i64* %.anon36, align 8 - %gt38 = icmp ugt i64 2, %67 - br i1 %gt38, label %loop.body39, label %loop.exit51 - -loop.body39: ; preds = %loop.cond37 - %68 = load i64, i64* %.anon36, align 8 - store i64 %68, i64* %i40, align 8 - %69 = load i64, i64* %.anon36, align 8 - %70 = getelementptr inbounds [2 x i32], [2 x i32]* %a35, i64 0, i64 %69 - %71 = load i32, i32* %70, align 4 - store i32 %71, i32* %x41, align 4 - %72 = bitcast i64* %i40 to i8* - %73 = insertvalue %variant undef, i8* %72, 0 - %74 = insertvalue %variant %73, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %75 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots43, i64 0, i64 0 - store %variant %74, %variant* %75, align 16 - %76 = bitcast i32* %x41 to i8* - %77 = insertvalue %variant undef, i8* %76, 0 - %78 = insertvalue %variant %77, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %79 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots43, i64 0, i64 1 - store %variant %78, %variant* %79, align 16 - %80 = bitcast [2 x %variant]* %varargslots43 to %variant* - %81 = insertvalue %"variant[]" undef, %variant* %80, 0 - %82 = insertvalue %"variant[]" %81, i64 2, 1 - store %"variant[]" %82, %"variant[]"* %taddr44, align 8 - %83 = bitcast %"variant[]"* %taddr44 to { i8*, i64 }* - %84 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %83, i32 0, i32 0 - %lo45 = load i8*, i8** %84, align 8 - %85 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %83, i32 0, i32 1 - %hi46 = load i64, i64* %85, align 8 - %86 = call i64 @std_io_printfn(i64* %retparam42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i64 6, i8* %lo45, i64 %hi46) - %not_err47 = icmp eq i64 %86, 0 - br i1 %not_err47, label %after_check48, label %voiderr49 - -after_check48: ; preds = %loop.body39 - br label %voiderr49 - -voiderr49: ; preds = %after_check48, %loop.body39 - %87 = load i64, i64* %.anon36, align 8 - %add50 = add i64 %87, 1 - store i64 %add50, i64* %.anon36, align 8 - br label %loop.cond37 - -loop.exit51: ; preds = %loop.cond37 - %88 = bitcast [3 x i32]* %a52 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %88, i8* align 4 bitcast ([3 x i32]* @.__const.7 to i8*), i32 12, i1 false) - store i64 0, i64* %.anon53, align 8 - br label %loop.cond54 - -loop.cond54: ; preds = %voiderr66, %loop.exit51 - %89 = load i64, i64* %.anon53, align 8 - %gt55 = icmp ugt i64 3, %89 - br i1 %gt55, label %loop.body56, label %loop.exit68 - -loop.body56: ; preds = %loop.cond54 - %90 = load i64, i64* %.anon53, align 8 - store i64 %90, i64* %i57, align 8 - %91 = load i64, i64* %.anon53, align 8 - %92 = getelementptr inbounds [3 x i32], [3 x i32]* %a52, i64 0, i64 %91 - %93 = load i32, i32* %92, align 4 - store i32 %93, i32* %x58, align 4 - %94 = bitcast i64* %i57 to i8* - %95 = insertvalue %variant undef, i8* %94, 0 - %96 = insertvalue %variant %95, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %97 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots60, i64 0, i64 0 - store %variant %96, %variant* %97, align 16 - %98 = bitcast i32* %x58 to i8* - %99 = insertvalue %variant undef, i8* %98, 0 - %100 = insertvalue %variant %99, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %101 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots60, i64 0, i64 1 - store %variant %100, %variant* %101, align 16 - %102 = bitcast [2 x %variant]* %varargslots60 to %variant* - %103 = insertvalue %"variant[]" undef, %variant* %102, 0 - %104 = insertvalue %"variant[]" %103, i64 2, 1 - store %"variant[]" %104, %"variant[]"* %taddr61, align 8 - %105 = bitcast %"variant[]"* %taddr61 to { i8*, i64 }* - %106 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %105, i32 0, i32 0 - %lo62 = load i8*, i8** %106, align 8 - %107 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %105, i32 0, i32 1 - %hi63 = load i64, i64* %107, align 8 - %108 = call i64 @std_io_printfn(i64* %retparam59, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i64 8, i8* %lo62, i64 %hi63) - %not_err64 = icmp eq i64 %108, 0 - br i1 %not_err64, label %after_check65, label %voiderr66 - -after_check65: ; preds = %loop.body56 - br label %voiderr66 - -voiderr66: ; preds = %after_check65, %loop.body56 - %109 = load i64, i64* %.anon53, align 8 - %add67 = add i64 %109, 1 - store i64 %add67, i64* %.anon53, align 8 - br label %loop.cond54 - -loop.exit68: ; preds = %loop.cond54 - %110 = bitcast [1 x i32]* %a69 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %110, i8* align 4 bitcast ([1 x i32]* @.__const.9 to i8*), i32 4, i1 false) - store i64 0, i64* %.anon70, align 8 - br label %loop.cond71 - -loop.cond71: ; preds = %voiderr83, %loop.exit68 - %111 = load i64, i64* %.anon70, align 8 - %gt72 = icmp ugt i64 1, %111 - br i1 %gt72, label %loop.body73, label %loop.exit85 - -loop.body73: ; preds = %loop.cond71 - %112 = load i64, i64* %.anon70, align 8 - store i64 %112, i64* %i74, align 8 - %113 = load i64, i64* %.anon70, align 8 - %114 = getelementptr inbounds [1 x i32], [1 x i32]* %a69, i64 0, i64 %113 - %115 = load i32, i32* %114, align 4 - store i32 %115, i32* %x75, align 4 - %116 = bitcast i64* %i74 to i8* - %117 = insertvalue %variant undef, i8* %116, 0 - %118 = insertvalue %variant %117, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %119 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots77, i64 0, i64 0 - store %variant %118, %variant* %119, align 16 - %120 = bitcast i32* %x75 to i8* - %121 = insertvalue %variant undef, i8* %120, 0 - %122 = insertvalue %variant %121, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %123 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots77, i64 0, i64 1 - store %variant %122, %variant* %123, align 16 - %124 = bitcast [2 x %variant]* %varargslots77 to %variant* - %125 = insertvalue %"variant[]" undef, %variant* %124, 0 - %126 = insertvalue %"variant[]" %125, i64 2, 1 - store %"variant[]" %126, %"variant[]"* %taddr78, align 8 - %127 = bitcast %"variant[]"* %taddr78 to { i8*, i64 }* - %128 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %127, i32 0, i32 0 - %lo79 = load i8*, i8** %128, align 8 - %129 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %127, i32 0, i32 1 - %hi80 = load i64, i64* %129, align 8 - %130 = call i64 @std_io_printfn(i64* %retparam76, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i64 8, i8* %lo79, i64 %hi80) - %not_err81 = icmp eq i64 %130, 0 - br i1 %not_err81, label %after_check82, label %voiderr83 - -after_check82: ; preds = %loop.body73 - br label %voiderr83 - -voiderr83: ; preds = %after_check82, %loop.body73 - %131 = load i64, i64* %.anon70, align 8 - %add84 = add i64 %131, 1 - store i64 %add84, i64* %.anon70, align 8 - br label %loop.cond71 - -loop.exit85: ; preds = %loop.cond71 - %132 = bitcast [2 x i32]* %a86 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %132, i8* align 4 bitcast ([2 x i32]* @.__const.11 to i8*), i32 8, i1 false) - store i64 0, i64* %.anon87, align 8 - br label %loop.cond88 - -loop.cond88: ; preds = %voiderr100, %loop.exit85 - %133 = load i64, i64* %.anon87, align 8 - %gt89 = icmp ugt i64 2, %133 - br i1 %gt89, label %loop.body90, label %loop.exit102 - -loop.body90: ; preds = %loop.cond88 - %134 = load i64, i64* %.anon87, align 8 - store i64 %134, i64* %i91, align 8 - %135 = load i64, i64* %.anon87, align 8 - %136 = getelementptr inbounds [2 x i32], [2 x i32]* %a86, i64 0, i64 %135 - %137 = load i32, i32* %136, align 4 - store i32 %137, i32* %x92, align 4 - %138 = bitcast i64* %i91 to i8* - %139 = insertvalue %variant undef, i8* %138, 0 - %140 = insertvalue %variant %139, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %141 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots94, i64 0, i64 0 - store %variant %140, %variant* %141, align 16 - %142 = bitcast i32* %x92 to i8* - %143 = insertvalue %variant undef, i8* %142, 0 - %144 = insertvalue %variant %143, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %145 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots94, i64 0, i64 1 - store %variant %144, %variant* %145, align 16 - %146 = bitcast [2 x %variant]* %varargslots94 to %variant* - %147 = insertvalue %"variant[]" undef, %variant* %146, 0 - %148 = insertvalue %"variant[]" %147, i64 2, 1 - store %"variant[]" %148, %"variant[]"* %taddr95, align 8 - %149 = bitcast %"variant[]"* %taddr95 to { i8*, i64 }* - %150 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %149, i32 0, i32 0 - %lo96 = load i8*, i8** %150, align 8 - %151 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %149, i32 0, i32 1 - %hi97 = load i64, i64* %151, align 8 - %152 = call i64 @std_io_printfn(i64* %retparam93, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i32 0, i32 0), i64 8, i8* %lo96, i64 %hi97) - %not_err98 = icmp eq i64 %152, 0 - br i1 %not_err98, label %after_check99, label %voiderr100 - -after_check99: ; preds = %loop.body90 - br label %voiderr100 - -voiderr100: ; preds = %after_check99, %loop.body90 - %153 = load i64, i64* %.anon87, align 8 - %add101 = add i64 %153, 1 - store i64 %add101, i64* %.anon87, align 8 - br label %loop.cond88 - -loop.exit102: ; preds = %loop.cond88 - %154 = bitcast [5 x i32]* %a103 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %154, i8* align 16 bitcast ([5 x i32]* @.__const.13 to i8*), i32 20, i1 false) - store i64 0, i64* %.anon104, align 8 - br label %loop.cond105 - -loop.cond105: ; preds = %voiderr117, %loop.exit102 - %155 = load i64, i64* %.anon104, align 8 - %gt106 = icmp ugt i64 5, %155 - br i1 %gt106, label %loop.body107, label %loop.exit119 - -loop.body107: ; preds = %loop.cond105 - %156 = load i64, i64* %.anon104, align 8 - store i64 %156, i64* %i108, align 8 - %157 = load i64, i64* %.anon104, align 8 - %158 = getelementptr inbounds [5 x i32], [5 x i32]* %a103, i64 0, i64 %157 - %159 = load i32, i32* %158, align 4 - store i32 %159, i32* %x109, align 4 - %160 = bitcast i64* %i108 to i8* - %161 = insertvalue %variant undef, i8* %160, 0 - %162 = insertvalue %variant %161, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %163 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots111, i64 0, i64 0 - store %variant %162, %variant* %163, align 16 - %164 = bitcast i32* %x109 to i8* - %165 = insertvalue %variant undef, i8* %164, 0 - %166 = insertvalue %variant %165, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %167 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots111, i64 0, i64 1 - store %variant %166, %variant* %167, align 16 - %168 = bitcast [2 x %variant]* %varargslots111 to %variant* - %169 = insertvalue %"variant[]" undef, %variant* %168, 0 - %170 = insertvalue %"variant[]" %169, i64 2, 1 - store %"variant[]" %170, %"variant[]"* %taddr112, align 8 - %171 = bitcast %"variant[]"* %taddr112 to { i8*, i64 }* - %172 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %171, i32 0, i32 0 - %lo113 = load i8*, i8** %172, align 8 - %173 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %171, i32 0, i32 1 - %hi114 = load i64, i64* %173, align 8 - %174 = call i64 @std_io_printfn(i64* %retparam110, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i32 0, i32 0), i64 8, i8* %lo113, i64 %hi114) - %not_err115 = icmp eq i64 %174, 0 - br i1 %not_err115, label %after_check116, label %voiderr117 - -after_check116: ; preds = %loop.body107 - br label %voiderr117 - -voiderr117: ; preds = %after_check116, %loop.body107 - %175 = load i64, i64* %.anon104, align 8 - %add118 = add i64 %175, 1 - store i64 %add118, i64* %.anon104, align 8 - br label %loop.cond105 - -loop.exit119: ; preds = %loop.cond105 - %176 = bitcast [8 x i32]* %a120 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %176, i8* align 16 bitcast ([8 x i32]* @.__const.15 to i8*), i32 32, i1 false) - store i64 0, i64* %.anon121, align 8 - br label %loop.cond122 - -loop.cond122: ; preds = %voiderr134, %loop.exit119 - %177 = load i64, i64* %.anon121, align 8 - %gt123 = icmp ugt i64 8, %177 - br i1 %gt123, label %loop.body124, label %loop.exit136 - -loop.body124: ; preds = %loop.cond122 - %178 = load i64, i64* %.anon121, align 8 - store i64 %178, i64* %i125, align 8 - %179 = load i64, i64* %.anon121, align 8 - %180 = getelementptr inbounds [8 x i32], [8 x i32]* %a120, i64 0, i64 %179 - %181 = load i32, i32* %180, align 4 - store i32 %181, i32* %x126, align 4 - %182 = bitcast i64* %i125 to i8* - %183 = insertvalue %variant undef, i8* %182, 0 - %184 = insertvalue %variant %183, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %185 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots128, i64 0, i64 0 - store %variant %184, %variant* %185, align 16 - %186 = bitcast i32* %x126 to i8* - %187 = insertvalue %variant undef, i8* %186, 0 - %188 = insertvalue %variant %187, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %189 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots128, i64 0, i64 1 - store %variant %188, %variant* %189, align 16 - %190 = bitcast [2 x %variant]* %varargslots128 to %variant* - %191 = insertvalue %"variant[]" undef, %variant* %190, 0 - %192 = insertvalue %"variant[]" %191, i64 2, 1 - store %"variant[]" %192, %"variant[]"* %taddr129, align 8 - %193 = bitcast %"variant[]"* %taddr129 to { i8*, i64 }* - %194 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %193, i32 0, i32 0 - %lo130 = load i8*, i8** %194, align 8 - %195 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %193, i32 0, i32 1 - %hi131 = load i64, i64* %195, align 8 - %196 = call i64 @std_io_printfn(i64* %retparam127, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i32 0, i32 0), i64 8, i8* %lo130, i64 %hi131) - %not_err132 = icmp eq i64 %196, 0 - br i1 %not_err132, label %after_check133, label %voiderr134 - -after_check133: ; preds = %loop.body124 - br label %voiderr134 - -voiderr134: ; preds = %after_check133, %loop.body124 - %197 = load i64, i64* %.anon121, align 8 - %add135 = add i64 %197, 1 - store i64 %add135, i64* %.anon121, align 8 - br label %loop.cond122 - -loop.exit136: ; preds = %loop.cond122 - %198 = bitcast [7 x i32]* %b to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %198, i8* align 16 bitcast ([7 x i32]* @.__const.17 to i8*), i32 28, i1 false) - store i64 0, i64* %.anon137, align 8 - br label %loop.cond138 - -loop.cond138: ; preds = %voiderr150, %loop.exit136 - %199 = load i64, i64* %.anon137, align 8 - %gt139 = icmp ugt i64 7, %199 - br i1 %gt139, label %loop.body140, label %loop.exit152 - -loop.body140: ; preds = %loop.cond138 - %200 = load i64, i64* %.anon137, align 8 - store i64 %200, i64* %i141, align 8 - %201 = load i64, i64* %.anon137, align 8 - %202 = getelementptr inbounds [7 x i32], [7 x i32]* %b, i64 0, i64 %201 - %203 = load i32, i32* %202, align 4 - store i32 %203, i32* %x142, align 4 - %204 = bitcast i64* %i141 to i8* - %205 = insertvalue %variant undef, i8* %204, 0 - %206 = insertvalue %variant %205, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %207 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots144, i64 0, i64 0 - store %variant %206, %variant* %207, align 16 - %208 = bitcast i32* %x142 to i8* - %209 = insertvalue %variant undef, i8* %208, 0 - %210 = insertvalue %variant %209, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %211 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots144, i64 0, i64 1 - store %variant %210, %variant* %211, align 16 - %212 = bitcast [2 x %variant]* %varargslots144 to %variant* - %213 = insertvalue %"variant[]" undef, %variant* %212, 0 - %214 = insertvalue %"variant[]" %213, i64 2, 1 - store %"variant[]" %214, %"variant[]"* %taddr145, align 8 - %215 = bitcast %"variant[]"* %taddr145 to { i8*, i64 }* - %216 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %215, i32 0, i32 0 - %lo146 = load i8*, i8** %216, align 8 - %217 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %215, i32 0, i32 1 - %hi147 = load i64, i64* %217, align 8 - %218 = call i64 @std_io_printfn(i64* %retparam143, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i32 0, i32 0), i64 8, i8* %lo146, i64 %hi147) - %not_err148 = icmp eq i64 %218, 0 - br i1 %not_err148, label %after_check149, label %voiderr150 - -after_check149: ; preds = %loop.body140 - br label %voiderr150 - -voiderr150: ; preds = %after_check149, %loop.body140 - %219 = load i64, i64* %.anon137, align 8 - %add151 = add i64 %219, 1 - store i64 %add151, i64* %.anon137, align 8 - br label %loop.cond138 - -loop.exit152: ; preds = %loop.cond138 - %220 = bitcast [8 x i32]* %c to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %220, i8* align 16 bitcast ([8 x i32]* @.__const.19 to i8*), i32 32, i1 false) - store i64 0, i64* %.anon153, align 8 - br label %loop.cond154 - -loop.cond154: ; preds = %voiderr166, %loop.exit152 - %221 = load i64, i64* %.anon153, align 8 - %gt155 = icmp ugt i64 8, %221 - br i1 %gt155, label %loop.body156, label %loop.exit168 - -loop.body156: ; preds = %loop.cond154 - %222 = load i64, i64* %.anon153, align 8 - store i64 %222, i64* %i157, align 8 - %223 = load i64, i64* %.anon153, align 8 - %224 = getelementptr inbounds [8 x i32], [8 x i32]* %c, i64 0, i64 %223 - %225 = load i32, i32* %224, align 4 - store i32 %225, i32* %x158, align 4 - %226 = bitcast i64* %i157 to i8* - %227 = insertvalue %variant undef, i8* %226, 0 - %228 = insertvalue %variant %227, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %229 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots160, i64 0, i64 0 - store %variant %228, %variant* %229, align 16 - %230 = bitcast i32* %x158 to i8* - %231 = insertvalue %variant undef, i8* %230, 0 - %232 = insertvalue %variant %231, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %233 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots160, i64 0, i64 1 - store %variant %232, %variant* %233, align 16 - %234 = bitcast [2 x %variant]* %varargslots160 to %variant* - %235 = insertvalue %"variant[]" undef, %variant* %234, 0 - %236 = insertvalue %"variant[]" %235, i64 2, 1 - store %"variant[]" %236, %"variant[]"* %taddr161, align 8 - %237 = bitcast %"variant[]"* %taddr161 to { i8*, i64 }* - %238 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %237, i32 0, i32 0 - %lo162 = load i8*, i8** %238, align 8 - %239 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %237, i32 0, i32 1 - %hi163 = load i64, i64* %239, align 8 - %240 = call i64 @std_io_printfn(i64* %retparam159, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i32 0, i32 0), i64 9, i8* %lo162, i64 %hi163) - %not_err164 = icmp eq i64 %240, 0 - br i1 %not_err164, label %after_check165, label %voiderr166 - -after_check165: ; preds = %loop.body156 - br label %voiderr166 - -voiderr166: ; preds = %after_check165, %loop.body156 - %241 = load i64, i64* %.anon153, align 8 - %add167 = add i64 %241, 1 - store i64 %add167, i64* %.anon153, align 8 - br label %loop.cond154 - -loop.exit168: ; preds = %loop.cond154 - %242 = bitcast [6 x i32]* %a169 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %242, i8* align 16 bitcast ([6 x i32]* @.__const.21 to i8*), i32 24, i1 false) - store i64 0, i64* %.anon170, align 8 - br label %loop.cond171 - -loop.cond171: ; preds = %voiderr183, %loop.exit168 - %243 = load i64, i64* %.anon170, align 8 - %gt172 = icmp ugt i64 6, %243 - br i1 %gt172, label %loop.body173, label %loop.exit185 - -loop.body173: ; preds = %loop.cond171 - %244 = load i64, i64* %.anon170, align 8 - store i64 %244, i64* %i174, align 8 - %245 = load i64, i64* %.anon170, align 8 - %246 = getelementptr inbounds [6 x i32], [6 x i32]* %a169, i64 0, i64 %245 - %247 = load i32, i32* %246, align 4 - store i32 %247, i32* %x175, align 4 - %248 = bitcast i64* %i174 to i8* - %249 = insertvalue %variant undef, i8* %248, 0 - %250 = insertvalue %variant %249, i64 ptrtoint (%.introspect* @"ct$ulong" to i64), 1 - %251 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots177, i64 0, i64 0 - store %variant %250, %variant* %251, align 16 - %252 = bitcast i32* %x175 to i8* - %253 = insertvalue %variant undef, i8* %252, 0 - %254 = insertvalue %variant %253, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %255 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots177, i64 0, i64 1 - store %variant %254, %variant* %255, align 16 - %256 = bitcast [2 x %variant]* %varargslots177 to %variant* - %257 = insertvalue %"variant[]" undef, %variant* %256, 0 - %258 = insertvalue %"variant[]" %257, i64 2, 1 - store %"variant[]" %258, %"variant[]"* %taddr178, align 8 - %259 = bitcast %"variant[]"* %taddr178 to { i8*, i64 }* - %260 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %259, i32 0, i32 0 - %lo179 = load i8*, i8** %260, align 8 - %261 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %259, i32 0, i32 1 - %hi180 = load i64, i64* %261, align 8 - %262 = call i64 @std_io_printfn(i64* %retparam176, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i32 0, i32 0), i64 6, i8* %lo179, i64 %hi180) - %not_err181 = icmp eq i64 %262, 0 - br i1 %not_err181, label %after_check182, label %voiderr183 - -after_check182: ; preds = %loop.body173 - br label %voiderr183 - -voiderr183: ; preds = %after_check182, %loop.body173 - %263 = load i64, i64* %.anon170, align 8 - %add184 = add i64 %263, 1 - store i64 %add184, i64* %.anon170, align 8 - br label %loop.cond171 - -loop.exit185: ; preds = %loop.cond171 - ret void -} - diff --git a/test/test_suite14/macros/macro_with_body.c3t b/test/test_suite14/macros/macro_with_body.c3t deleted file mode 100644 index 070c26b32..000000000 --- a/test/test_suite14/macros/macro_with_body.c3t +++ /dev/null @@ -1,108 +0,0 @@ -module withbody; - - -extern fn int printf(char *, ...); - -struct Foo -{ - int x; -} - -fn int Foo.mutate(Foo *foo) -{ - printf("Mutating\n"); - return 10 * ++foo.x; -} - -macro @macro_with_body(foo, &x; @body(x, y)) -{ - x = foo.x; - @body(foo.mutate(), x); -} - -macro @repeat(int times; @body(x)) -{ - for (int i = 0; i < times; i++) - { - @body(i + 1); - } -} - -fn void main() -{ - Foo f = { 33 }; - int y; - @macro_with_body(f, y; int x, int dy) - { - printf("Got values %d, %d\n", x, dy); - }; - @repeat(10; int loop) - { - printf("Repeat %d\n", loop); - }; - -} - -/* #expect: withbody.ll - -define i32 @withbody_Foo_mutate(%Foo* %0) #0 { -entry: - %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0)) - %2 = getelementptr inbounds %Foo, %Foo* %0, i32 0, i32 0 - %3 = load i32, i32* %2, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %2, align 4 - %mul = mul i32 10, %add - ret i32 %mul -} - -define void @withbody_main() #0 { -entry: - %f = alloca %Foo, align 4 - %y = alloca i32, align 4 - %foo = alloca %Foo, align 4 - %x = alloca i32, align 4 - %dy = alloca i32, align 4 - %times = alloca i32, align 4 - %i = alloca i32, align 4 - %loop = alloca i32, align 4 - %0 = bitcast %Foo* %f to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%Foo* @.__const to i8*), i32 4, i1 false) - store i32 0, i32* %y, align 4 - %1 = bitcast %Foo* %foo to i8* - %2 = bitcast %Foo* %f to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 %2, i32 4, i1 false) - %3 = getelementptr inbounds %Foo, %Foo* %foo, i32 0, i32 0 - %4 = load i32, i32* %3, align 4 - store i32 %4, i32* %y, align 4 - %5 = call i32 @withbody_Foo_mutate(%Foo* %foo) - store i32 %5, i32* %x, align 4 - %6 = load i32, i32* %y, align 4 - store i32 %6, i32* %dy, align 4 - %7 = load i32, i32* %x, align 4 - %8 = load i32, i32* %dy, align 4 - %9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i32 0, i32 0), i32 %7, i32 %8) - store i32 10, i32* %times, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %10 = load i32, i32* %i, align 4 - %11 = load i32, i32* %times, align 4 - %lt = icmp slt i32 %10, %11 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %12 = load i32, i32* %i, align 4 - %add = add i32 %12, 1 - store i32 %add, i32* %loop, align 4 - %13 = load i32, i32* %loop, align 4 - %14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i32 %13) - %15 = load i32, i32* %i, align 4 - %add1 = add i32 %15, 1 - store i32 %add1, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret void -} diff --git a/test/test_suite14/macros/modify_ct_param.c3 b/test/test_suite14/macros/modify_ct_param.c3 deleted file mode 100644 index 80219fe80..000000000 --- a/test/test_suite14/macros/modify_ct_param.c3 +++ /dev/null @@ -1,13 +0,0 @@ -module test; - -macro test($baz, $Type) -{ - $baz = 123; - $Type = int; -} -fn void main() -{ - var $foo = 1; - $foo = 4; - test(4, double); -} diff --git a/test/test_suite14/macros/no_body.c3 b/test/test_suite14/macros/no_body.c3 deleted file mode 100644 index 6a71cf27f..000000000 --- a/test/test_suite14/macros/no_body.c3 +++ /dev/null @@ -1,50 +0,0 @@ -module test; - -extern fn int printf(char *, ...); - -macro @foo(x; @body(y)) -{ - @body(x); -} - -fn void test() -{ - @foo(10); // #error: Expected call to have a trailing statement, did you forget to add it? -} - -fn void test3() -{ - @foo(10) // #error: Not enough parameters - { - }; -} - -fn void test5() -{ - @foo(10; int a, int b) // #error: Too many parameters for the macro body, expected - { - }; -} -macro foo_no(x) -{ - return x; -} - -fn void test2() -{ - foo_no(10) // #error: This macro does not support trailing statements - { - printf("foek"); - }; -} - -macro foo2(x) -{ - @body(x); // #error: '@body' could not be found, did you spell it right? -} - -fn void test4() -{ - foo2(10); -} - diff --git a/test/test_suite14/macros/type_params.c3t b/test/test_suite14/macros/type_params.c3t deleted file mode 100644 index d364460be..000000000 --- a/test/test_suite14/macros/type_params.c3t +++ /dev/null @@ -1,42 +0,0 @@ -// #target: macos-x64 -macro foo($Foo) -{ - $Foo a; - return a; -} - -define Bar = short; -fn void test() -{ - int x = foo(int); - var $Foo = double; - double d = foo($Foo); - double d2 = foo($typeof(d)); - short z = foo(Bar); -} - - -/* #expect: type_params.ll - - %x = alloca i32, align 4 - %a = alloca i32, align 4 - %d = alloca double, align 8 - %a1 = alloca double, align 8 - %d2 = alloca double, align 8 - %a2 = alloca double, align 8 - %z = alloca i16, align 2 - %a3 = alloca i16, align 2 - store i32 0, i32* %a, align 4 - %0 = load i32, i32* %a, align 4 - store i32 %0, i32* %x, align 4 - store double 0.000000e+00, double* %a1, align 8 - %1 = load double, double* %a1, align 8 - store double %1, double* %d, align 8 - store double 0.000000e+00, double* %a2, align 8 - %2 = load double, double* %a2, align 8 - store double %2, double* %d2, align 8 - store i16 0, i16* %a3, align 2 - %3 = load i16, i16* %a3, align 2 - store i16 %3, i16* %z, align 2 - ret void -} diff --git a/test/test_suite14/macros/userland_bitcast.c3t b/test/test_suite14/macros/userland_bitcast.c3t deleted file mode 100644 index 9816bbfc8..000000000 --- a/test/test_suite14/macros/userland_bitcast.c3t +++ /dev/null @@ -1,344 +0,0 @@ -// #target: macos-x64 - -macro testbitcast(expr, $Type) -{ - $assert($sizeof(expr) == $Type.sizeof, "Cannot bitcast between types of different size."); - $Type x = void; - var $size = (usz)($sizeof(expr)); - - $if ($alignof(expr) >= 8 && $Type.alignof >= 8): - ulong *b = (ulong*)(&expr); - ulong *to = (ulong*)(&x); - for (usz i = 0; i < $size; i += 8) - { - to[i] = b[i]; - } - $elif ($alignof(expr) >= 4 && $Type.alignof >= 4): - uint* b = (uint*)(&expr); - uint* to = (uint*)(&x); - for (usz i = 0; i < $size; i += 4) - { - to[i] = b[i]; - } - $elif ($alignof(expr) >= 2 && $Type.alignof >= 2): - ushort* b = (ushort*)(&expr); - ushort* to = (ushort*)(&x); - for (usz i = 0; i < $size; i += 2) - { - to[i] = b[i]; - } - $else: - char* b = (char*)(&expr); - char* to = (char*)(&x); - for (usz i = 0; i < $size; i++) - { - to[i] = b[i]; - } - $endif; - return x; -} - -extern fn void printf(char*, ...); - -struct Foo -{ - short a; - char b; - char c; - short d; - short e; -} - -fn ulong testFoo(short x) -{ - Foo z; - z.a = x; - return testbitcast(z, ulong); -} - -fn char[4] test(float x) -{ - return testbitcast(x, char[4]); -} - -fn void main() -{ - float f = 12.353; - int i = testbitcast(f, int); - float f2 = testbitcast(i, float); - printf("%f => %d => %f\n", f, i, f2); - double d = 12.353e267; - ulong l = testbitcast(d, ulong); - double d2 = testbitcast(d, double); - printf("%e => %llu => %e\n", d, l, d2); - -} - -/* #expect: userland_bitcast.ll - -%Foo = type { i16, i8, i8, i16, i16 } - -@"ct$userland_bitcast_Foo" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 5, [0 x i64] zeroinitializer }, align 8 -@.str = private unnamed_addr constant [16 x i8] c"%f => %d => %f\0A\00", align 1 -@.str.1 = private unnamed_addr constant [18 x i8] c"%e => %llu => %e\0A\00", align 1 - -define i64 @userland_bitcast_testFoo(i16 signext %0) #0 { -entry: - %z = alloca %Foo, align 2 - %expr = alloca %Foo, align 2 - %x = alloca i64, align 8 - %b = alloca i16*, align 8 - %to = alloca i16*, align 8 - %i = alloca i64, align 8 - %1 = getelementptr inbounds %Foo, %Foo* %z, i32 0, i32 0 - store i16 0, i16* %1, align 2 - %2 = getelementptr inbounds %Foo, %Foo* %z, i32 0, i32 1 - store i8 0, i8* %2, align 2 - %3 = getelementptr inbounds %Foo, %Foo* %z, i32 0, i32 2 - store i8 0, i8* %3, align 1 - %4 = getelementptr inbounds %Foo, %Foo* %z, i32 0, i32 3 - store i16 0, i16* %4, align 2 - %5 = getelementptr inbounds %Foo, %Foo* %z, i32 0, i32 4 - store i16 0, i16* %5, align 2 - %6 = getelementptr inbounds %Foo, %Foo* %z, i32 0, i32 0 - store i16 %0, i16* %6, align 2 - %7 = bitcast %Foo* %expr to i8* - %8 = bitcast %Foo* %z to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %7, i8* align 2 %8, i32 8, i1 false) - %ptrptr = bitcast %Foo* %expr to i16* - store i16* %ptrptr, i16** %b, align 8 - %ptrptr1 = bitcast i64* %x to i16* - store i16* %ptrptr1, i16** %to, align 8 - store i64 0, i64* %i, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %9 = load i64, i64* %i, align 8 - %lt = icmp ult i64 %9, 8 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %10 = load i16*, i16** %to, align 8 - %11 = load i64, i64* %i, align 8 - %ptroffset = getelementptr inbounds i16, i16* %10, i64 %11 - %12 = load i16*, i16** %b, align 8 - %13 = load i64, i64* %i, align 8 - %ptroffset2 = getelementptr inbounds i16, i16* %12, i64 %13 - %14 = load i16, i16* %ptroffset2, align 2 - store i16 %14, i16* %ptroffset, align 2 - %15 = load i64, i64* %i, align 8 - %add = add i64 %15, 2 - store i64 %add, i64* %i, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %16 = load i64, i64* %x, align 8 - ret i64 %16 -} - -; Function Attrs: nounwind -define i32 @userland_bitcast_test(float %0) #0 { -entry: - %expr = alloca float, align 4 - %x = alloca [4 x i8], align 1 - %b = alloca i8*, align 8 - %to = alloca i8*, align 8 - %i = alloca i64, align 8 - store float %0, float* %expr, align 4 - %ptrptr = bitcast float* %expr to i8* - store i8* %ptrptr, i8** %b, align 8 - %ptrptr1 = bitcast [4 x i8]* %x to i8* - store i8* %ptrptr1, i8** %to, align 8 - store i64 0, i64* %i, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %1 = load i64, i64* %i, align 8 - %lt = icmp ult i64 %1, 4 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %2 = load i8*, i8** %to, align 8 - %3 = load i64, i64* %i, align 8 - %ptroffset = getelementptr inbounds i8, i8* %2, i64 %3 - %4 = load i8*, i8** %b, align 8 - %5 = load i64, i64* %i, align 8 - %ptroffset2 = getelementptr inbounds i8, i8* %4, i64 %5 - %6 = load i8, i8* %ptroffset2, align 1 - store i8 %6, i8* %ptroffset, align 1 - %7 = load i64, i64* %i, align 8 - %add = add i64 %7, 1 - store i64 %add, i64* %i, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %8 = bitcast [4 x i8]* %x to i32* - %9 = load i32, i32* %8, align 1 - ret i32 %9 -} - -; Function Attrs: nounwind -define void @userland_bitcast_main() #0 { -entry: - %f = alloca float, align 4 - %i = alloca i32, align 4 - %expr = alloca float, align 4 - %x = alloca i32, align 4 - %b = alloca i32*, align 8 - %to = alloca i32*, align 8 - %i1 = alloca i64, align 8 - %f2 = alloca float, align 4 - %expr3 = alloca i32, align 4 - %x4 = alloca float, align 4 - %b5 = alloca i32*, align 8 - %to6 = alloca i32*, align 8 - %i8 = alloca i64, align 8 - %d = alloca double, align 8 - %l = alloca i64, align 8 - %expr17 = alloca double, align 8 - %x18 = alloca i64, align 8 - %b19 = alloca i64*, align 8 - %to21 = alloca i64*, align 8 - %i22 = alloca i64, align 8 - %d2 = alloca double, align 8 - %expr30 = alloca double, align 8 - %x31 = alloca double, align 8 - %b32 = alloca i64*, align 8 - %to34 = alloca i64*, align 8 - %i36 = alloca i64, align 8 - store float 0x4028B4BC60000000, float* %f, align 4 - %0 = load float, float* %f, align 4 - store float %0, float* %expr, align 4 - %ptrptr = bitcast float* %expr to i32* - store i32* %ptrptr, i32** %b, align 8 - store i32* %x, i32** %to, align 8 - store i64 0, i64* %i1, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %1 = load i64, i64* %i1, align 8 - %lt = icmp ult i64 %1, 4 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %2 = load i32*, i32** %to, align 8 - %3 = load i64, i64* %i1, align 8 - %ptroffset = getelementptr inbounds i32, i32* %2, i64 %3 - %4 = load i32*, i32** %b, align 8 - %5 = load i64, i64* %i1, align 8 - %ptroffset2 = getelementptr inbounds i32, i32* %4, i64 %5 - %6 = load i32, i32* %ptroffset2, align 4 - store i32 %6, i32* %ptroffset, align 4 - %7 = load i64, i64* %i1, align 8 - %add = add i64 %7, 4 - store i64 %add, i64* %i1, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %8 = load i32, i32* %x, align 4 - store i32 %8, i32* %i, align 4 - %9 = load i32, i32* %i, align 4 - store i32 %9, i32* %expr3, align 4 - store i32* %expr3, i32** %b5, align 8 - %ptrptr7 = bitcast float* %x4 to i32* - store i32* %ptrptr7, i32** %to6, align 8 - store i64 0, i64* %i8, align 8 - br label %loop.cond9 - -loop.cond9: ; preds = %loop.body11, %loop.exit - %10 = load i64, i64* %i8, align 8 - %lt10 = icmp ult i64 %10, 4 - br i1 %lt10, label %loop.body11, label %loop.exit15 - -loop.body11: ; preds = %loop.cond9 - %11 = load i32*, i32** %to6, align 8 - %12 = load i64, i64* %i8, align 8 - %ptroffset12 = getelementptr inbounds i32, i32* %11, i64 %12 - %13 = load i32*, i32** %b5, align 8 - %14 = load i64, i64* %i8, align 8 - %ptroffset13 = getelementptr inbounds i32, i32* %13, i64 %14 - %15 = load i32, i32* %ptroffset13, align 4 - store i32 %15, i32* %ptroffset12, align 4 - %16 = load i64, i64* %i8, align 8 - %add14 = add i64 %16, 4 - store i64 %add14, i64* %i8, align 8 - br label %loop.cond9 - -loop.exit15: ; preds = %loop.cond9 - %17 = load float, float* %x4, align 4 - store float %17, float* %f2, align 4 - %18 = load float, float* %f, align 4 - %fpfpext = fpext float %18 to double - %19 = load i32, i32* %i, align 4 - %20 = load float, float* %f2, align 4 - %fpfpext16 = fpext float %20 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i32 0, i32 0), double %fpfpext, i32 %19, double %fpfpext16) - store double 1.235300e+268, double* %d, align 8 - %21 = load double, double* %d, align 8 - store double %21, double* %expr17, align 8 - %ptrptr20 = bitcast double* %expr17 to i64* - store i64* %ptrptr20, i64** %b19, align 8 - store i64* %x18, i64** %to21, align 8 - store i64 0, i64* %i22, align 8 - br label %loop.cond23 - -loop.cond23: ; preds = %loop.body25, %loop.exit15 - %22 = load i64, i64* %i22, align 8 - %lt24 = icmp ult i64 %22, 8 - br i1 %lt24, label %loop.body25, label %loop.exit29 - -loop.body25: ; preds = %loop.cond23 - %23 = load i64*, i64** %to21, align 8 - %24 = load i64, i64* %i22, align 8 - %ptroffset26 = getelementptr inbounds i64, i64* %23, i64 %24 - %25 = load i64*, i64** %b19, align 8 - %26 = load i64, i64* %i22, align 8 - %ptroffset27 = getelementptr inbounds i64, i64* %25, i64 %26 - %27 = load i64, i64* %ptroffset27, align 8 - store i64 %27, i64* %ptroffset26, align 8 - %28 = load i64, i64* %i22, align 8 - %add28 = add i64 %28, 8 - store i64 %add28, i64* %i22, align 8 - br label %loop.cond23 - -loop.exit29: ; preds = %loop.cond23 - %29 = load i64, i64* %x18, align 8 - store i64 %29, i64* %l, align 8 - %30 = load double, double* %d, align 8 - store double %30, double* %expr30, align 8 - %ptrptr33 = bitcast double* %expr30 to i64* - store i64* %ptrptr33, i64** %b32, align 8 - %ptrptr35 = bitcast double* %x31 to i64* - store i64* %ptrptr35, i64** %to34, align 8 - store i64 0, i64* %i36, align 8 - br label %loop.cond37 - -loop.cond37: ; preds = %loop.body39, %loop.exit29 - %31 = load i64, i64* %i36, align 8 - %lt38 = icmp ult i64 %31, 8 - br i1 %lt38, label %loop.body39, label %loop.exit43 - -loop.body39: ; preds = %loop.cond37 - %32 = load i64*, i64** %to34, align 8 - %33 = load i64, i64* %i36, align 8 - %ptroffset40 = getelementptr inbounds i64, i64* %32, i64 %33 - %34 = load i64*, i64** %b32, align 8 - %35 = load i64, i64* %i36, align 8 - %ptroffset41 = getelementptr inbounds i64, i64* %34, i64 %35 - %36 = load i64, i64* %ptroffset41, align 8 - store i64 %36, i64* %ptroffset40, align 8 - %37 = load i64, i64* %i36, align 8 - %add42 = add i64 %37, 8 - store i64 %add42, i64* %i36, align 8 - br label %loop.cond37 - -loop.exit43: ; preds = %loop.cond37 - %38 = load double, double* %x31, align 8 - store double %38, double* %d2, align 8 - %39 = load double, double* %d, align 8 - %40 = load i64, i64* %l, align 8 - %41 = load double, double* %d2, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0), double %39, i64 %40, double %41) - ret void -} - diff --git a/test/test_suite14/methods/access.c3 b/test/test_suite14/methods/access.c3 deleted file mode 100644 index ab3391c11..000000000 --- a/test/test_suite14/methods/access.c3 +++ /dev/null @@ -1,37 +0,0 @@ -extern fn void printf(...); - -struct An1 -{ - An3 x; -} - -struct An3 -{ - An2 y; -} - -define AnCall = fn void(); - -struct An2 -{ - AnCall t; -} - -fn void An2.helloWorld(An2 *an2) -{ - printf("An2 hello\n"); -} - -fn void check() -{ - printf("Checking\n"); -} - - -fn void main() -{ - An1 an; - an.x.y.helloWorld(); - an.x.y.t = ✓ - an.x.y.t(); -} \ No newline at end of file diff --git a/test/test_suite14/methods/enum_distinct_err_methods.c3t b/test/test_suite14/methods/enum_distinct_err_methods.c3t deleted file mode 100644 index fa30379b2..000000000 --- a/test/test_suite14/methods/enum_distinct_err_methods.c3t +++ /dev/null @@ -1,76 +0,0 @@ -// #target: macos-x64 - -module foo; -import std::io; - -fault Foo -{ - X -} - -define Bar = distinct int; - -enum MyEnum -{ - A, - B -} - -fn void Foo.hello(Foo *f) -{ - io::println("Hello from Foo"); -} - -fn void Bar.hello(Bar *b) -{ - io::println("Hello from Bar"); -} - -fn void MyEnum.hello(MyEnum *myenum) -{ - io::println("Hello from MyEnum"); -} -fn int main() -{ - Foo f; - Bar b; - MyEnum a = MyEnum.A; - f.hello(); - b.hello(); - a.hello(); - return 0; -} - -/* #expect: foo.ll - -define void @foo_Foo_hello(i64* %0) #0 { -entry: - %1 = call i32 @std_io_println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0)) #1 - ret void -} - -define void @foo_Bar_hello(i32* %0) #0 { -entry: - %1 = call i32 @std_io_println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0)) #1 - ret void -} - -define void @foo_MyEnum_hello(i32* %0) #0 { -entry: - %1 = call i32 @std_io_println(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0)) #1 - ret void -} - -define i32 @main() #0 { -entry: - %f = alloca i64, align 8 - %b = alloca i32, align 4 - %a = alloca i32, align 4 - store i64 0, i64* %f, align 8 - store i32 0, i32* %b, align 4 - store i32 0, i32* %a, align 4 - call void @foo_Foo_hello(i64* %f) - call void @foo_Bar_hello(i32* %b) - call void @foo_MyEnum_hello(i32* %a) - ret i32 0 -} diff --git a/test/test_suite14/methods/extension_method.c3t b/test/test_suite14/methods/extension_method.c3t deleted file mode 100644 index c1a3a9a02..000000000 --- a/test/test_suite14/methods/extension_method.c3t +++ /dev/null @@ -1,39 +0,0 @@ -module foo; - -struct Bar -{ - int x; -} - -module baz; -import foo; -import std::io; - -fn void foo::Bar.test(Bar *bar) -{ - io::println("Inside of baz::Bar.test"); -} - -module abc; -import foo; -import baz; - -fn int main() -{ - Bar bar; - bar.test(); - return 0; -} - -// #expect: abc.ll - - -define i32 @main() -entry: - %bar = alloca %Bar, align 4 - %0 = bitcast %Bar* %bar to i32* - store i32 0, i32* %0, align 4 - call void @foo_Bar_test(%Bar* %bar) - ret i32 0 - -declare void @foo_Bar_test(%Bar*) diff --git a/test/test_suite14/methods/extension_method_already_exist.c3 b/test/test_suite14/methods/extension_method_already_exist.c3 deleted file mode 100644 index beccdbca1..000000000 --- a/test/test_suite14/methods/extension_method_already_exist.c3 +++ /dev/null @@ -1,30 +0,0 @@ -module foo; - -fn void Bar.test(Bar *bar) -{ - io::println("Inside of baz::Bar.test"); -} - -struct Bar -{ - int x; -} - -module baz; -import foo; -import std::io; - -fn void foo::Bar.test(Bar *bar) // #error: This method is already defined for 'Bar' -{ - io::println("Inside of baz::Bar.test"); -} - -module abc; -import foo; -import baz; - -fn void main() -{ - Bar bar; - bar.test(); -} \ No newline at end of file diff --git a/test/test_suite14/methods/extension_method_generic.c3 b/test/test_suite14/methods/extension_method_generic.c3 deleted file mode 100644 index 35c460999..000000000 --- a/test/test_suite14/methods/extension_method_generic.c3 +++ /dev/null @@ -1,28 +0,0 @@ -module compiler_c3; -import std::array::list; - -define IntArray = List; - -extern fn void printf(char*, ...); - -fn void IntArray.someFunc(IntArray *this, usz param) { -//do something - this.push((int)param); -} - -fn int main(String[] argv) -{ - IntArray stk; - stk.someFunc(256); - - for (int i = 0; i < 256; i++) { - stk.push(i); - } - - for (;!stk.is_empty();) { - int value = stk.pop(); - printf("%i\n", value); - } - - return 0; -} \ No newline at end of file diff --git a/test/test_suite14/methods/extension_method_in_other_modules.c3t b/test/test_suite14/methods/extension_method_in_other_modules.c3t deleted file mode 100644 index 771549b60..000000000 --- a/test/test_suite14/methods/extension_method_in_other_modules.c3t +++ /dev/null @@ -1,43 +0,0 @@ -// #target: macos-x64 -module foob; -struct Foo -{ - int x; -} -fn void Foo.test(Foo* f) -{} - -module baz; -import foob; -fn void Foo.test2(Foo* f, int x) -{} -fn void main() -{ - Foo f; - f.test(); - f.test2(123); -} - -/* #expect: foob.ll - -define void @foob_Foo_test(%Foo* %0) #0 { -entry: - ret void -} - -// #expect: baz.ll - -define void @foob_Foo_test2(%Foo* %0, i32 %1) #0 { -entry: - ret void -} - -define void @baz_main() #0 { -entry: - %f = alloca %Foo, align 4 - %0 = bitcast %Foo* %f to i32* - store i32 0, i32* %0, align 4 - call void @foob_Foo_test(%Foo* %f) - call void @foob_Foo_test2(%Foo* %f, i32 123) - ret void -} diff --git a/test/test_suite14/methods/methods_defined_twice.c3 b/test/test_suite14/methods/methods_defined_twice.c3 deleted file mode 100644 index b03f6580c..000000000 --- a/test/test_suite14/methods/methods_defined_twice.c3 +++ /dev/null @@ -1,31 +0,0 @@ -module foo; - -struct Bar -{ - int x; -} - -module baz; -import foo; -import std::io; - -fn void foo::Bar.test(Bar *bar) -{ - io::println("Inside of baz::Bar.test"); -} - -fn void Bar.test(Bar *bar) // #error: This method is already defined for -{ - io::println("Inside of baz::Bar.test"); -} - -module abc; -import foo; -import baz; - -fn void main() -{ - Bar bar; - bar.test(); -} - diff --git a/test/test_suite14/module/missing_semi.c3 b/test/test_suite14/module/missing_semi.c3 deleted file mode 100644 index ce8ae0942..000000000 --- a/test/test_suite14/module/missing_semi.c3 +++ /dev/null @@ -1,3 +0,0 @@ -module test // #error: Expected ';' - -int a; \ No newline at end of file diff --git a/test/test_suite14/module/module_bad_path_ident.c3 b/test/test_suite14/module/module_bad_path_ident.c3 deleted file mode 100644 index 3897c998c..000000000 --- a/test/test_suite14/module/module_bad_path_ident.c3 +++ /dev/null @@ -1 +0,0 @@ -module big::MONEY; // #error: The elements of a module path must consist of only lower \ No newline at end of file diff --git a/test/test_suite14/module/module_bad_path_invalid.c3 b/test/test_suite14/module/module_bad_path_invalid.c3 deleted file mode 100644 index 1554c001d..000000000 --- a/test/test_suite14/module/module_bad_path_invalid.c3 +++ /dev/null @@ -1 +0,0 @@ -module abc::&&; // #error: Each '::' must be followed by a regular lower case sub module name \ No newline at end of file diff --git a/test/test_suite14/module/module_bad_path_keyword.c3 b/test/test_suite14/module/module_bad_path_keyword.c3 deleted file mode 100644 index 918aa7389..000000000 --- a/test/test_suite14/module/module_bad_path_keyword.c3 +++ /dev/null @@ -1 +0,0 @@ -module abc::if::while; // #error: The module path cannot contain a reserved keyword, try another name \ No newline at end of file diff --git a/test/test_suite14/module/module_error_string.c3 b/test/test_suite14/module/module_error_string.c3 deleted file mode 100644 index ceb869c56..000000000 --- a/test/test_suite14/module/module_error_string.c3 +++ /dev/null @@ -1 +0,0 @@ -module "Hello my friend"; // #error: 'module' should be followed by a plain identifier, not a string. Did you accidentally put the module name between ""? \ No newline at end of file diff --git a/test/test_suite14/module/module_start_bad_ident.c3 b/test/test_suite14/module/module_start_bad_ident.c3 deleted file mode 100644 index 3502724ba..000000000 --- a/test/test_suite14/module/module_start_bad_ident.c3 +++ /dev/null @@ -1 +0,0 @@ -module BIG::MONEY; // #error: The module name must consist of only lower case letters \ No newline at end of file diff --git a/test/test_suite14/module/module_start_invalid.c3 b/test/test_suite14/module/module_start_invalid.c3 deleted file mode 100644 index 1c8e68bb9..000000000 --- a/test/test_suite14/module/module_start_invalid.c3 +++ /dev/null @@ -1 +0,0 @@ -module &&; // #error: 'module' should be followed by a module name \ No newline at end of file diff --git a/test/test_suite14/module/module_start_keyword.c3 b/test/test_suite14/module/module_start_keyword.c3 deleted file mode 100644 index 84ff3d77c..000000000 --- a/test/test_suite14/module/module_start_keyword.c3 +++ /dev/null @@ -1 +0,0 @@ -module if::hello; // #error: The module name cannot contain a reserved keyword \ No newline at end of file diff --git a/test/test_suite14/module/private_module.c3 b/test/test_suite14/module/private_module.c3 deleted file mode 100644 index b29de1f17..000000000 --- a/test/test_suite14/module/private_module.c3 +++ /dev/null @@ -1 +0,0 @@ -module private foo; \ No newline at end of file diff --git a/test/test_suite14/module/unknown_modules.c3 b/test/test_suite14/module/unknown_modules.c3 deleted file mode 100644 index a800c0fc8..000000000 --- a/test/test_suite14/module/unknown_modules.c3 +++ /dev/null @@ -1,4 +0,0 @@ -module test; - -import foo; // #error: No module named 'foo' could be found -import bar; // #error: No module named 'bar' could be found \ No newline at end of file diff --git a/test/test_suite14/overloading/set_overload.c3t b/test/test_suite14/overloading/set_overload.c3t deleted file mode 100644 index 88d086303..000000000 --- a/test/test_suite14/overloading/set_overload.c3t +++ /dev/null @@ -1,25 +0,0 @@ -// #target: macos-x64 - -module test; -import std::map; - -define IntMap = HashMap; - -fn void main() -{ - IntMap map; - map.set("Hello", 4); - map["Bye"] = 5; -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %map = alloca %HashMap, align 8 - %0 = bitcast %HashMap* %map to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %0, i8 0, i64 40, i1 false) - %1 = call i8 @"std_map$$sa$char.int_HashMap_set"(%HashMap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 5, i32 4) - %2 = call i8 @"std_map$$sa$char.int_HashMap_set"(%HashMap* %map, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i64 3, i32 5) - ret void -} diff --git a/test/test_suite14/pointers/array_pointer_decay.c3t b/test/test_suite14/pointers/array_pointer_decay.c3t deleted file mode 100644 index 377c1c4b3..000000000 --- a/test/test_suite14/pointers/array_pointer_decay.c3t +++ /dev/null @@ -1,84 +0,0 @@ -// #target: macos-x64 -module foo; -extern fn void printf(char*, ...); - -fn void main() -{ - int[3] x; - int[3]* y = &x; - int* z = y; - int[] sub = y; - int[3] y1 = y[1]; - int z1 = z[1]; - int* xx = &x + 1; - int[3]* yy = (int[3]*)(xx); - int* zz = yy - 1; - printf("%p = %p = %p, %p = %p\n", y, z, zz, &(*y)[1], xx); - x[1] = 123; - printf("%d = %d\n", x[1], z[1]); -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %x = alloca [3 x i32], align 4 - %y = alloca [3 x i32]*, align 8 - %z = alloca i32*, align 8 - %sub = alloca %"int[]", align 8 - %y1 = alloca [3 x i32], align 4 - %z1 = alloca i32, align 4 - %xx = alloca i32*, align 8 - %yy = alloca [3 x i32]*, align 8 - %zz = alloca i32*, align 8 - %0 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 0 - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - store i32 0, i32* %1, align 4 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 2 - store i32 0, i32* %2, align 4 - store [3 x i32]* %x, [3 x i32]** %y, align 8 - %3 = load [3 x i32]*, [3 x i32]** %y, align 8 - %ptrptr = bitcast [3 x i32]* %3 to i32* - store i32* %ptrptr, i32** %z, align 8 - %4 = load [3 x i32]*, [3 x i32]** %y, align 8 - %5 = bitcast [3 x i32]* %4 to i32* - %6 = insertvalue %"int[]" undef, i32* %5, 0 - %7 = insertvalue %"int[]" %6, i64 3, 1 - store %"int[]" %7, %"int[]"* %sub, align 8 - %8 = load [3 x i32]*, [3 x i32]** %y, align 8 - %ptroffset = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 1 - %9 = bitcast [3 x i32]* %y1 to i8* - %10 = bitcast [3 x i32]* %ptroffset to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %9, i8* align 4 %10, i32 12, i1 false) - %11 = load i32*, i32** %z, align 8 - %ptroffset1 = getelementptr inbounds i32, i32* %11, i64 1 - %12 = load i32, i32* %ptroffset1, align 4 - store i32 %12, i32* %z1, align 4 - %ptrptr2 = bitcast [3 x i32]* %x to i32* - %ptroffset3 = getelementptr i32, i32* %ptrptr2, i64 1 - store i32* %ptroffset3, i32** %xx, align 8 - %13 = load i32*, i32** %xx, align 8 - %ptrptr4 = bitcast i32* %13 to [3 x i32]* - store [3 x i32]* %ptrptr4, [3 x i32]** %yy, align 8 - %14 = load [3 x i32]*, [3 x i32]** %yy, align 8 - %ptrptr5 = bitcast [3 x i32]* %14 to i32* - %ptroffset6 = getelementptr i32, i32* %ptrptr5, i64 -1 - store i32* %ptroffset6, i32** %zz, align 8 - %15 = load [3 x i32]*, [3 x i32]** %y, align 8 - %16 = load i32*, i32** %z, align 8 - %17 = load i32*, i32** %zz, align 8 - %18 = load [3 x i32]*, [3 x i32]** %y, align 8 - %19 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i64 0, i64 1 - %20 = load i32*, i32** %xx, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), [3 x i32]* %15, i32* %16, i32* %17, i32* %19, i32* %20) - %21 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - store i32 123, i32* %21, align 4 - %22 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - %23 = load i32, i32* %22, align 4 - %24 = load i32*, i32** %z, align 8 - %ptroffset7 = getelementptr inbounds i32, i32* %24, i64 1 - %25 = load i32, i32* %ptroffset7, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i32 %23, i32 %25) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/pointers/const_pointer.c3t b/test/test_suite14/pointers/const_pointer.c3t deleted file mode 100644 index 3bbc0fa69..000000000 --- a/test/test_suite14/pointers/const_pointer.c3t +++ /dev/null @@ -1,16 +0,0 @@ -// #target: macos-x64 - -module const_pointer; - -private double foo = 17; -private double bar = 12.0; -private float xx = 12.0; - -private void*[3] data = { &foo, &bar, &xx }; - -/* #expect: const_pointer.ll - -@const_pointer_foo = protected global double 1.700000e+01, align 8 -@const_pointer_bar = protected global double 1.200000e+01, align 8 -@const_pointer_xx = protected global float 1.200000e+01, align 4 -@const_pointer_data = protected unnamed_addr global [3 x i8*] [i8* bitcast (double* @const_pointer_foo to i8*), i8* bitcast (double* @const_pointer_bar to i8*), i8* bitcast (float* @const_pointer_xx to i8*)], align 16 diff --git a/test/test_suite14/pointers/pointer_index.c3t b/test/test_suite14/pointers/pointer_index.c3t deleted file mode 100644 index edcd6c111..000000000 --- a/test/test_suite14/pointers/pointer_index.c3t +++ /dev/null @@ -1,78 +0,0 @@ -module pointer_index; - -fn void test1(int* x) -{ - int a = x[0]; - int b = *x; - int c = x[1]; - int d = x[-1]; -} - -fn void test2(char* x) -{ - char a = x[0]; - char b = *x; - char c = x[1]; -} - -fn void test3(long* x) -{ - long a = x[0]; - long b = *x; - long c = x[1]; -} - -/* #expect: pointer_index.ll - -define void @pointer_index_test1(i32* %0) #0 { -entry: - %a = alloca i32, align 4 - %b = alloca i32, align 4 - %c = alloca i32, align 4 - %d = alloca i32, align 4 - %ptroffset = getelementptr inbounds i32, i32* %0, i64 0 - %1 = load i32, i32* %ptroffset, align 4 - store i32 %1, i32* %a, align 4 - %2 = load i32, i32* %0, align 4 - store i32 %2, i32* %b, align 4 - %ptroffset1 = getelementptr inbounds i32, i32* %0, i64 1 - %3 = load i32, i32* %ptroffset1, align 4 - store i32 %3, i32* %c, align 4 - %ptroffset2 = getelementptr inbounds i32, i32* %0, i64 -1 - %4 = load i32, i32* %ptroffset2, align 4 - store i32 %4, i32* %d, align 4 - ret void -} - -; Function Attrs: nounwind -define void @pointer_index_test2(i8* %0) #0 { -entry: - %a = alloca i8, align 1 - %b = alloca i8, align 1 - %c = alloca i8, align 1 - %ptroffset = getelementptr inbounds i8, i8* %0, i64 0 - %1 = load i8, i8* %ptroffset, align 1 - store i8 %1, i8* %a, align 1 - %2 = load i8, i8* %0, align 1 - store i8 %2, i8* %b, align 1 - %ptroffset1 = getelementptr inbounds i8, i8* %0, i64 1 - %3 = load i8, i8* %ptroffset1, align 1 - store i8 %3, i8* %c, align 1 - ret void -} - -define void @pointer_index_test3(i64* %0) #0 { -entry: - %a = alloca i64, align 8 - %b = alloca i64, align 8 - %c = alloca i64, align 8 - %ptroffset = getelementptr inbounds i64, i64* %0, i64 0 - %1 = load i64, i64* %ptroffset, align 8 - store i64 %1, i64* %a, align 8 - %2 = load i64, i64* %0, align 8 - store i64 %2, i64* %b, align 8 - %ptroffset1 = getelementptr inbounds i64, i64* %0, i64 1 - %3 = load i64, i64* %ptroffset1, align 8 - store i64 %3, i64* %c, align 8 - ret void -} diff --git a/test/test_suite14/pointers/subarray_variant_to_ptr.c3t b/test/test_suite14/pointers/subarray_variant_to_ptr.c3t deleted file mode 100644 index a537f98ac..000000000 --- a/test/test_suite14/pointers/subarray_variant_to_ptr.c3t +++ /dev/null @@ -1,105 +0,0 @@ -// #target: macos-x64 -module foo; - -extern fn void printf(char*, ...); - -fn void test1(variant z) -{ - int* w = z.ptr; - printf("%d\n", *w); -} - -fn void test2(int[] z) -{ - int* w = z.ptr; - printf("%d\n", *w); -} - -fn void main() -{ - int x = 123; - int y = 293483; - int[2] w = { 144, 772 }; - test1(&x); - test2(w[..]); -} - -/* #expect: foo.ll - -%variant = type { i8*, i64 } -%"int[]" = type { i32*, i64 } - -@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 - -define void @foo_test1(i64 %0, i8* %1) #0 { -entry: - %z = alloca %variant, align 8 - %w = alloca i32*, align 8 - %pair = bitcast %variant* %z to { i64, i8* }* - %2 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 0 - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 1 - store i8* %1, i8** %3, align 8 - %4 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 0 - %5 = load i8*, i8** %4, align 8 - %ptrptr = bitcast i8* %5 to i32* - store i32* %ptrptr, i32** %w, align 8 - %6 = load i32*, i32** %w, align 8 - %7 = load i32, i32* %6, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %7) - ret void -} - -; Function Attrs: nounwind -define void @foo_test2(i8* %0, i64 %1) #0 { -entry: - %z = alloca %"int[]", align 8 - %w = alloca i32*, align 8 - %pair = bitcast %"int[]"* %z to { i8*, i64 }* - %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %2, align 8 - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - %4 = getelementptr inbounds %"int[]", %"int[]"* %z, i32 0, i32 0 - %5 = load i32*, i32** %4, align 8 - store i32* %5, i32** %w, align 8 - %6 = load i32*, i32** %w, align 8 - %7 = load i32, i32* %6, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %7) - ret void -} - -; Function Attrs: nounwind -define void @foo_main() #0 { -entry: - %x = alloca i32, align 4 - %y = alloca i32, align 4 - %w = alloca [2 x i32], align 4 - %taddr = alloca %variant, align 8 - %taddr1 = alloca %"int[]", align 8 - store i32 123, i32* %x, align 4 - store i32 293483, i32* %y, align 4 - %0 = bitcast [2 x i32]* %w to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([2 x i32]* @.__const to i8*), i32 8, i1 false) - %1 = bitcast i32* %x to i8* - %2 = insertvalue %variant undef, i8* %1, 0 - %3 = insertvalue %variant %2, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %3, %variant* %taddr, align 8 - %4 = bitcast %variant* %taddr to { i64, i8* }* - %5 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %4, i32 0, i32 0 - %lo = load i64, i64* %5, align 8 - %6 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %4, i32 0, i32 1 - %hi = load i8*, i8** %6, align 8 - call void @foo_test1(i64 %lo, i8* %hi) - %7 = getelementptr inbounds [2 x i32], [2 x i32]* %w, i64 0, i64 0 - %8 = insertvalue %"int[]" undef, i32* %7, 0 - %9 = insertvalue %"int[]" %8, i64 2, 1 - store %"int[]" %9, %"int[]"* %taddr1, align 8 - %10 = bitcast %"int[]"* %taddr1 to { i8*, i64 }* - %11 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %10, i32 0, i32 0 - %lo2 = load i8*, i8** %11, align 8 - %12 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %10, i32 0, i32 1 - %hi3 = load i64, i64* %12, align 8 - call void @foo_test2(i8* %lo2, i64 %hi3) - ret void -} \ No newline at end of file diff --git a/test/test_suite14/precedence/required_parens.c3 b/test/test_suite14/precedence/required_parens.c3 deleted file mode 100644 index 176469480..000000000 --- a/test/test_suite14/precedence/required_parens.c3 +++ /dev/null @@ -1,13 +0,0 @@ -module foo; -import std::io; - -fn void main() -{ - int i = 0; - int j = i ^ i | i; // #error: You need to add explicit parentheses to clarify precedence. - bool x = i == j == i; // #error: You need to add explicit parentheses to clarify precedence. - int k = i >> j << k; // #error: You need to add explicit parentheses to clarify precedence. - bool xk = i && j || i; - int y = i + j + i; - int yy = i * i / i + i - i; -} \ No newline at end of file diff --git a/test/test_suite14/regression/crash_on_right_paren_macro.c3 b/test/test_suite14/regression/crash_on_right_paren_macro.c3 deleted file mode 100644 index 9605bf231..000000000 --- a/test/test_suite14/regression/crash_on_right_paren_macro.c3 +++ /dev/null @@ -1,6 +0,0 @@ -macro void hello($b$Bar x; // #error: Expected ')' - @hello(1); - var $foo = 1; - $foo; - FOO; -} diff --git a/test/test_suite14/safe/deref.c3t b/test/test_suite14/safe/deref.c3t deleted file mode 100644 index 8c54dc36f..000000000 --- a/test/test_suite14/safe/deref.c3t +++ /dev/null @@ -1,31 +0,0 @@ -// #safe: yes -// #target: macos-x64 -module foo; - -fn void main() -{ - int* x; - int y = *x; -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %x = alloca i32*, align 8 - %y = alloca i32, align 4 - store i32* null, i32** %x, align 8 - %0 = load i32*, i32** %x, align 8 - %checknull = icmp eq i32* %0, null - br i1 %checknull, label %panic, label %checkok - -panic: ; preds = %entry - %1 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %1(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.panic_msg, i64 0, i64 0), i64 27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.file, i64 0, i64 0), i64 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.func, i64 0, i64 0), i64 4, i32 6) - br label %checkok - -checkok: ; preds = %panic, %entry - %2 = load i32, i32* %0, align 4 - store i32 %2, i32* %y, align 4 - ret void -} diff --git a/test/test_suite14/slices/slice_assign.c3t b/test/test_suite14/slices/slice_assign.c3t deleted file mode 100644 index f89d4f9a4..000000000 --- a/test/test_suite14/slices/slice_assign.c3t +++ /dev/null @@ -1,79 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn void printf(char*, ...); - -fn void main() -{ - int[8] x; - x[0..1] = 3; - x[1..2] = 5; - x[5..7] = 52; - foreach (i : x) - { - printf("%d\n", i); - } - x[0..7] = 123; -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %x = alloca [8 x i32], align 16 - %.anon = alloca i64, align 8 - %i = alloca i32, align 4 - %0 = bitcast [8 x i32]* %x to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %0, i8 0, i64 32, i1 false) - %1 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 0 - store i32 3, i32* %1, align 4 - %2 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 1 - store i32 3, i32* %2, align 4 - %3 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 1 - store i32 5, i32* %3, align 4 - %4 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 2 - store i32 5, i32* %4, align 4 - %5 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 5 - store i32 52, i32* %5, align 4 - %6 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 6 - store i32 52, i32* %6, align 4 - %7 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 7 - store i32 52, i32* %7, align 4 - store i64 0, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %8 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 8, %8 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %9 = load i64, i64* %.anon, align 8 - %10 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 %9 - %11 = load i32, i32* %10, align 4 - store i32 %11, i32* %i, align 4 - %12 = load i32, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %12) - %13 = load i64, i64* %.anon, align 8 - %add = add i64 %13, 1 - store i64 %add, i64* %.anon, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - br label %cond - -cond: ; preds = %assign, %loop.exit - %14 = phi i64 [ 0, %loop.exit ], [ %add1, %assign ] - %lt = icmp slt i64 %14, 8 - br i1 %lt, label %assign, label %exit - -assign: ; preds = %cond - %15 = getelementptr inbounds [8 x i32], [8 x i32]* %x, i64 0, i64 %14 - store i32 123, i32* %15, align 4 - %add1 = add i64 %14, 1 - br label %cond - -exit: ; preds = %cond - ret void -} - diff --git a/test/test_suite14/slices/slice_to_slice_assign.c3t b/test/test_suite14/slices/slice_to_slice_assign.c3t deleted file mode 100644 index 3ba7e642f..000000000 --- a/test/test_suite14/slices/slice_to_slice_assign.c3t +++ /dev/null @@ -1,254 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn void main() -{ - int[*] z = { 1, 2, 3, 4, 5, 6, 7 }; - int[6] y; - y[1..3] = z[3..5]; - io::printfn("%s %s", y, z); - y[4..] = z[5..6]; - io::printfn("%s %s", y, z); - int[][] a = { int[] { 1 } }; - int[][] b = { int[] { 2 } }; - io::printfn("%s", a); - a[0..0] = b[0..0]; - io::printfn("%s", a); - a[0..0] = y[2..4]; - io::printfn("%s", a); -} -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %z = alloca [7 x i32], align 16 - %y = alloca [6 x i32], align 16 - %taddr = alloca %"int[]", align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %variant], align 16 - %taddr1 = alloca %"variant[]", align 8 - %taddr2 = alloca %"int[]", align 8 - %retparam3 = alloca i64, align 8 - %varargslots4 = alloca [2 x %variant], align 16 - %taddr5 = alloca %"variant[]", align 8 - %a = alloca %"int[][]", align 8 - %literal = alloca [1 x %"int[]"], align 16 - %literal11 = alloca [1 x i32], align 4 - %b = alloca %"int[][]", align 8 - %literal12 = alloca [1 x %"int[]"], align 16 - %literal13 = alloca [1 x i32], align 4 - %retparam14 = alloca i64, align 8 - %varargslots15 = alloca [1 x %variant], align 16 - %taddr16 = alloca %"variant[]", align 8 - %taddr23 = alloca %"int[][]", align 8 - %retparam24 = alloca i64, align 8 - %varargslots25 = alloca [1 x %variant], align 16 - %taddr26 = alloca %"variant[]", align 8 - %retparam33 = alloca i64, align 8 - %varargslots34 = alloca [1 x %variant], align 16 - %taddr35 = alloca %"variant[]", align 8 - %0 = bitcast [7 x i32]* %z to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %0, i8* align 16 bitcast ([7 x i32]* @.__const to i8*), i32 28, i1 false) - %1 = bitcast [6 x i32]* %y to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 24, i1 false) - %2 = getelementptr inbounds [7 x i32], [7 x i32]* %z, i64 0, i64 3 - %3 = insertvalue %"int[]" undef, i32* %2, 0 - %4 = insertvalue %"int[]" %3, i64 3, 1 - %5 = getelementptr inbounds [6 x i32], [6 x i32]* %y, i64 0, i64 1 - %6 = insertvalue %"int[]" undef, i32* %5, 0 - %7 = insertvalue %"int[]" %6, i64 3, 1 - %8 = extractvalue %"int[]" %7, 0 - %9 = extractvalue %"int[]" %4, 0 - store %"int[]" %4, %"int[]"* %taddr, align 8 - %10 = getelementptr inbounds %"int[]", %"int[]"* %taddr, i32 0, i32 1 - %11 = load i64, i64* %10, align 8 - %12 = mul i64 %11, 4 - %13 = bitcast i32* %8 to i8* - %14 = bitcast i32* %9 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %13, i8* align 4 %14, i64 %12, i1 false) - %15 = bitcast [6 x i32]* %y to i8* - %16 = insertvalue %variant undef, i8* %15, 0 - %17 = insertvalue %variant %16, i64 ptrtoint (%.introspect* @"ct$a6$int" to i64), 1 - %18 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 0 - store %variant %17, %variant* %18, align 16 - %19 = bitcast [7 x i32]* %z to i8* - %20 = insertvalue %variant undef, i8* %19, 0 - %21 = insertvalue %variant %20, i64 ptrtoint (%.introspect* @"ct$a7$int" to i64), 1 - %22 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 1 - store %variant %21, %variant* %22, align 16 - %23 = bitcast [2 x %variant]* %varargslots to %variant* - %24 = insertvalue %"variant[]" undef, %variant* %23, 0 - %25 = insertvalue %"variant[]" %24, i64 2, 1 - store %"variant[]" %25, %"variant[]"* %taddr1, align 8 - %26 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %27 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %26, i32 0, i32 0 - %lo = load i8*, i8** %27, align 8 - %28 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %26, i32 0, i32 1 - %hi = load i64, i64* %28, align 8 - %29 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 5, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %29, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %30 = getelementptr inbounds [7 x i32], [7 x i32]* %z, i64 0, i64 5 - %31 = insertvalue %"int[]" undef, i32* %30, 0 - %32 = insertvalue %"int[]" %31, i64 2, 1 - %33 = getelementptr inbounds [6 x i32], [6 x i32]* %y, i64 0, i64 4 - %34 = insertvalue %"int[]" undef, i32* %33, 0 - %35 = insertvalue %"int[]" %34, i64 2, 1 - %36 = extractvalue %"int[]" %35, 0 - %37 = extractvalue %"int[]" %32, 0 - store %"int[]" %32, %"int[]"* %taddr2, align 8 - %38 = getelementptr inbounds %"int[]", %"int[]"* %taddr2, i32 0, i32 1 - %39 = load i64, i64* %38, align 8 - %40 = mul i64 %39, 4 - %41 = bitcast i32* %36 to i8* - %42 = bitcast i32* %37 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %41, i8* align 4 %42, i64 %40, i1 false) - %43 = bitcast [6 x i32]* %y to i8* - %44 = insertvalue %variant undef, i8* %43, 0 - %45 = insertvalue %variant %44, i64 ptrtoint (%.introspect* @"ct$a6$int" to i64), 1 - %46 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots4, i64 0, i64 0 - store %variant %45, %variant* %46, align 16 - %47 = bitcast [7 x i32]* %z to i8* - %48 = insertvalue %variant undef, i8* %47, 0 - %49 = insertvalue %variant %48, i64 ptrtoint (%.introspect* @"ct$a7$int" to i64), 1 - %50 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots4, i64 0, i64 1 - store %variant %49, %variant* %50, align 16 - %51 = bitcast [2 x %variant]* %varargslots4 to %variant* - %52 = insertvalue %"variant[]" undef, %variant* %51, 0 - %53 = insertvalue %"variant[]" %52, i64 2, 1 - store %"variant[]" %53, %"variant[]"* %taddr5, align 8 - %54 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %55 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %54, i32 0, i32 0 - %lo6 = load i8*, i8** %55, align 8 - %56 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %54, i32 0, i32 1 - %hi7 = load i64, i64* %56, align 8 - %57 = call i64 @std_io_printfn(i64* %retparam3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i64 5, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %57, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %voiderr - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %voiderr - %58 = getelementptr inbounds [1 x %"int[]"], [1 x %"int[]"]* %literal, i64 0, i64 0 - %59 = getelementptr inbounds [1 x i32], [1 x i32]* %literal11, i64 0, i64 0 - store i32 1, i32* %59, align 4 - %60 = bitcast [1 x i32]* %literal11 to i32* - %61 = insertvalue %"int[]" undef, i32* %60, 0 - %62 = insertvalue %"int[]" %61, i64 1, 1 - store %"int[]" %62, %"int[]"* %58, align 8 - %63 = bitcast [1 x %"int[]"]* %literal to %"int[]"* - %64 = insertvalue %"int[][]" undef, %"int[]"* %63, 0 - %65 = insertvalue %"int[][]" %64, i64 1, 1 - store %"int[][]" %65, %"int[][]"* %a, align 8 - %66 = getelementptr inbounds [1 x %"int[]"], [1 x %"int[]"]* %literal12, i64 0, i64 0 - %67 = getelementptr inbounds [1 x i32], [1 x i32]* %literal13, i64 0, i64 0 - store i32 2, i32* %67, align 4 - %68 = bitcast [1 x i32]* %literal13 to i32* - %69 = insertvalue %"int[]" undef, i32* %68, 0 - %70 = insertvalue %"int[]" %69, i64 1, 1 - store %"int[]" %70, %"int[]"* %66, align 8 - %71 = bitcast [1 x %"int[]"]* %literal12 to %"int[]"* - %72 = insertvalue %"int[][]" undef, %"int[]"* %71, 0 - %73 = insertvalue %"int[][]" %72, i64 1, 1 - store %"int[][]" %73, %"int[][]"* %b, align 8 - %74 = bitcast %"int[][]"* %a to i8* - %75 = insertvalue %variant undef, i8* %74, 0 - %76 = insertvalue %variant %75, i64 ptrtoint (%.introspect* @"ct$sa$sa$int" to i64), 1 - %77 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots15, i64 0, i64 0 - store %variant %76, %variant* %77, align 16 - %78 = bitcast [1 x %variant]* %varargslots15 to %variant* - %79 = insertvalue %"variant[]" undef, %variant* %78, 0 - %80 = insertvalue %"variant[]" %79, i64 1, 1 - store %"variant[]" %80, %"variant[]"* %taddr16, align 8 - %81 = bitcast %"variant[]"* %taddr16 to { i8*, i64 }* - %82 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %81, i32 0, i32 0 - %lo17 = load i8*, i8** %82, align 8 - %83 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %81, i32 0, i32 1 - %hi18 = load i64, i64* %83, align 8 - %84 = call i64 @std_io_printfn(i64* %retparam14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i64 2, i8* %lo17, i64 %hi18) - %not_err19 = icmp eq i64 %84, 0 - br i1 %not_err19, label %after_check20, label %voiderr21 - -after_check20: ; preds = %voiderr10 - br label %voiderr21 - -voiderr21: ; preds = %after_check20, %voiderr10 - %85 = load %"int[][]", %"int[][]"* %b, align 8 - %86 = extractvalue %"int[][]" %85, 0 - %ptroffset = getelementptr inbounds %"int[]", %"int[]"* %86, i64 0 - %87 = insertvalue %"int[][]" undef, %"int[]"* %ptroffset, 0 - %88 = insertvalue %"int[][]" %87, i64 1, 1 - %89 = load %"int[][]", %"int[][]"* %a, align 8 - %90 = extractvalue %"int[][]" %89, 0 - %ptroffset22 = getelementptr inbounds %"int[]", %"int[]"* %90, i64 0 - %91 = insertvalue %"int[][]" undef, %"int[]"* %ptroffset22, 0 - %92 = insertvalue %"int[][]" %91, i64 1, 1 - %93 = extractvalue %"int[][]" %92, 0 - %94 = extractvalue %"int[][]" %88, 0 - store %"int[][]" %88, %"int[][]"* %taddr23, align 8 - %95 = getelementptr inbounds %"int[][]", %"int[][]"* %taddr23, i32 0, i32 1 - %96 = load i64, i64* %95, align 8 - %97 = mul i64 %96, 16 - %98 = bitcast %"int[]"* %93 to i8* - %99 = bitcast %"int[]"* %94 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %98, i8* align 8 %99, i64 %97, i1 false) - %100 = bitcast %"int[][]"* %a to i8* - %101 = insertvalue %variant undef, i8* %100, 0 - %102 = insertvalue %variant %101, i64 ptrtoint (%.introspect* @"ct$sa$sa$int" to i64), 1 - %103 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots25, i64 0, i64 0 - store %variant %102, %variant* %103, align 16 - %104 = bitcast [1 x %variant]* %varargslots25 to %variant* - %105 = insertvalue %"variant[]" undef, %variant* %104, 0 - %106 = insertvalue %"variant[]" %105, i64 1, 1 - store %"variant[]" %106, %"variant[]"* %taddr26, align 8 - %107 = bitcast %"variant[]"* %taddr26 to { i8*, i64 }* - %108 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %107, i32 0, i32 0 - %lo27 = load i8*, i8** %108, align 8 - %109 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %107, i32 0, i32 1 - %hi28 = load i64, i64* %109, align 8 - %110 = call i64 @std_io_printfn(i64* %retparam24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i64 2, i8* %lo27, i64 %hi28) - %not_err29 = icmp eq i64 %110, 0 - br i1 %not_err29, label %after_check30, label %voiderr31 - -after_check30: ; preds = %voiderr21 - br label %voiderr31 - -voiderr31: ; preds = %after_check30, %voiderr21 - %111 = getelementptr inbounds [6 x i32], [6 x i32]* %y, i64 0, i64 2 - %112 = insertvalue %"int[]" undef, i32* %111, 0 - %113 = insertvalue %"int[]" %112, i64 3, 1 - %114 = load %"int[][]", %"int[][]"* %a, align 8 - %115 = extractvalue %"int[][]" %114, 0 - %ptroffset32 = getelementptr inbounds %"int[]", %"int[]"* %115, i64 0 - store %"int[]" %113, %"int[]"* %ptroffset32, align 8 - %116 = bitcast %"int[][]"* %a to i8* - %117 = insertvalue %variant undef, i8* %116, 0 - %118 = insertvalue %variant %117, i64 ptrtoint (%.introspect* @"ct$sa$sa$int" to i64), 1 - %119 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots34, i64 0, i64 0 - store %variant %118, %variant* %119, align 16 - %120 = bitcast [1 x %variant]* %varargslots34 to %variant* - %121 = insertvalue %"variant[]" undef, %variant* %120, 0 - %122 = insertvalue %"variant[]" %121, i64 1, 1 - store %"variant[]" %122, %"variant[]"* %taddr35, align 8 - %123 = bitcast %"variant[]"* %taddr35 to { i8*, i64 }* - %124 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %123, i32 0, i32 0 - %lo36 = load i8*, i8** %124, align 8 - %125 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %123, i32 0, i32 1 - %hi37 = load i64, i64* %125, align 8 - %126 = call i64 @std_io_printfn(i64* %retparam33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i64 2, i8* %lo36, i64 %hi37) - %not_err38 = icmp eq i64 %126, 0 - br i1 %not_err38, label %after_check39, label %voiderr40 - -after_check39: ; preds = %voiderr31 - br label %voiderr40 - -voiderr40: ; preds = %after_check39, %voiderr31 - ret void -} diff --git a/test/test_suite14/slices/slice_to_slice_vector_assign.c3t b/test/test_suite14/slices/slice_to_slice_vector_assign.c3t deleted file mode 100644 index 408b30b79..000000000 --- a/test/test_suite14/slices/slice_to_slice_vector_assign.c3t +++ /dev/null @@ -1,252 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; - -fn void main() -{ - int[<*>] z = { 1, 2, 3, 4, 5, 6, 7 }; - int[<6>] y; - y[1..3] = z[3..5]; - io::printfn("%s %s", y, z); - y[4..] = z[5..6]; - io::printfn("%s %s", y, z); - int[][] a = { int[] { 1 } }; - int[][] b = { int[] { 2 } }; - io::printfn("%s", a); - a[0..0] = b[0..0]; - io::printfn("%s", a); - a[0..0] = y[2..4]; - io::printfn("%s", a); -} -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %z = alloca <7 x i32>, align 32 - %y = alloca <6 x i32>, align 32 - %taddr = alloca %"int[]", align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %variant], align 16 - %taddr1 = alloca %"variant[]", align 8 - %taddr2 = alloca %"int[]", align 8 - %retparam3 = alloca i64, align 8 - %varargslots4 = alloca [2 x %variant], align 16 - %taddr5 = alloca %"variant[]", align 8 - %a = alloca %"int[][]", align 8 - %literal = alloca [1 x %"int[]"], align 16 - %literal11 = alloca [1 x i32], align 4 - %b = alloca %"int[][]", align 8 - %literal12 = alloca [1 x %"int[]"], align 16 - %literal13 = alloca [1 x i32], align 4 - %retparam14 = alloca i64, align 8 - %varargslots15 = alloca [1 x %variant], align 16 - %taddr16 = alloca %"variant[]", align 8 - %taddr23 = alloca %"int[][]", align 8 - %retparam24 = alloca i64, align 8 - %varargslots25 = alloca [1 x %variant], align 16 - %taddr26 = alloca %"variant[]", align 8 - %retparam33 = alloca i64, align 8 - %varargslots34 = alloca [1 x %variant], align 16 - %taddr35 = alloca %"variant[]", align 8 - store <7 x i32> , <7 x i32>* %z, align 32 - store <6 x i32> zeroinitializer, <6 x i32>* %y, align 32 - %0 = getelementptr inbounds <7 x i32>, <7 x i32>* %z, i64 0, i64 3 - %1 = insertvalue %"int[]" undef, i32* %0, 0 - %2 = insertvalue %"int[]" %1, i64 3, 1 - %3 = getelementptr inbounds <6 x i32>, <6 x i32>* %y, i64 0, i64 1 - %4 = insertvalue %"int[]" undef, i32* %3, 0 - %5 = insertvalue %"int[]" %4, i64 3, 1 - %6 = extractvalue %"int[]" %5, 0 - %7 = extractvalue %"int[]" %2, 0 - store %"int[]" %2, %"int[]"* %taddr, align 8 - %8 = getelementptr inbounds %"int[]", %"int[]"* %taddr, i32 0, i32 1 - %9 = load i64, i64* %8, align 8 - %10 = mul i64 %9, 4 - %11 = bitcast i32* %6 to i8* - %12 = bitcast i32* %7 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %11, i8* align 4 %12, i64 %10, i1 false) - %13 = bitcast <6 x i32>* %y to i8* - %14 = insertvalue %variant undef, i8* %13, 0 - %15 = insertvalue %variant %14, i64 ptrtoint (%.introspect* @"ct$v6$int" to i64), 1 - %16 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 0 - store %variant %15, %variant* %16, align 16 - %17 = bitcast <7 x i32>* %z to i8* - %18 = insertvalue %variant undef, i8* %17, 0 - %19 = insertvalue %variant %18, i64 ptrtoint (%.introspect* @"ct$v7$int" to i64), 1 - %20 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 1 - store %variant %19, %variant* %20, align 16 - %21 = bitcast [2 x %variant]* %varargslots to %variant* - %22 = insertvalue %"variant[]" undef, %variant* %21, 0 - %23 = insertvalue %"variant[]" %22, i64 2, 1 - store %"variant[]" %23, %"variant[]"* %taddr1, align 8 - %24 = bitcast %"variant[]"* %taddr1 to { i8*, i64 }* - %25 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %24, i32 0, i32 0 - %lo = load i8*, i8** %25, align 8 - %26 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %24, i32 0, i32 1 - %hi = load i64, i64* %26, align 8 - %27 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 5, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %27, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %28 = getelementptr inbounds <7 x i32>, <7 x i32>* %z, i64 0, i64 5 - %29 = insertvalue %"int[]" undef, i32* %28, 0 - %30 = insertvalue %"int[]" %29, i64 2, 1 - %31 = getelementptr inbounds <6 x i32>, <6 x i32>* %y, i64 0, i64 4 - %32 = insertvalue %"int[]" undef, i32* %31, 0 - %33 = insertvalue %"int[]" %32, i64 2, 1 - %34 = extractvalue %"int[]" %33, 0 - %35 = extractvalue %"int[]" %30, 0 - store %"int[]" %30, %"int[]"* %taddr2, align 8 - %36 = getelementptr inbounds %"int[]", %"int[]"* %taddr2, i32 0, i32 1 - %37 = load i64, i64* %36, align 8 - %38 = mul i64 %37, 4 - %39 = bitcast i32* %34 to i8* - %40 = bitcast i32* %35 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %39, i8* align 4 %40, i64 %38, i1 false) - %41 = bitcast <6 x i32>* %y to i8* - %42 = insertvalue %variant undef, i8* %41, 0 - %43 = insertvalue %variant %42, i64 ptrtoint (%.introspect* @"ct$v6$int" to i64), 1 - %44 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots4, i64 0, i64 0 - store %variant %43, %variant* %44, align 16 - %45 = bitcast <7 x i32>* %z to i8* - %46 = insertvalue %variant undef, i8* %45, 0 - %47 = insertvalue %variant %46, i64 ptrtoint (%.introspect* @"ct$v7$int" to i64), 1 - %48 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots4, i64 0, i64 1 - store %variant %47, %variant* %48, align 16 - %49 = bitcast [2 x %variant]* %varargslots4 to %variant* - %50 = insertvalue %"variant[]" undef, %variant* %49, 0 - %51 = insertvalue %"variant[]" %50, i64 2, 1 - store %"variant[]" %51, %"variant[]"* %taddr5, align 8 - %52 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %53 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %52, i32 0, i32 0 - %lo6 = load i8*, i8** %53, align 8 - %54 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %52, i32 0, i32 1 - %hi7 = load i64, i64* %54, align 8 - %55 = call i64 @std_io_printfn(i64* %retparam3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i64 5, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %55, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %voiderr - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %voiderr - %56 = getelementptr inbounds [1 x %"int[]"], [1 x %"int[]"]* %literal, i64 0, i64 0 - %57 = getelementptr inbounds [1 x i32], [1 x i32]* %literal11, i64 0, i64 0 - store i32 1, i32* %57, align 4 - %58 = bitcast [1 x i32]* %literal11 to i32* - %59 = insertvalue %"int[]" undef, i32* %58, 0 - %60 = insertvalue %"int[]" %59, i64 1, 1 - store %"int[]" %60, %"int[]"* %56, align 8 - %61 = bitcast [1 x %"int[]"]* %literal to %"int[]"* - %62 = insertvalue %"int[][]" undef, %"int[]"* %61, 0 - %63 = insertvalue %"int[][]" %62, i64 1, 1 - store %"int[][]" %63, %"int[][]"* %a, align 8 - %64 = getelementptr inbounds [1 x %"int[]"], [1 x %"int[]"]* %literal12, i64 0, i64 0 - %65 = getelementptr inbounds [1 x i32], [1 x i32]* %literal13, i64 0, i64 0 - store i32 2, i32* %65, align 4 - %66 = bitcast [1 x i32]* %literal13 to i32* - %67 = insertvalue %"int[]" undef, i32* %66, 0 - %68 = insertvalue %"int[]" %67, i64 1, 1 - store %"int[]" %68, %"int[]"* %64, align 8 - %69 = bitcast [1 x %"int[]"]* %literal12 to %"int[]"* - %70 = insertvalue %"int[][]" undef, %"int[]"* %69, 0 - %71 = insertvalue %"int[][]" %70, i64 1, 1 - store %"int[][]" %71, %"int[][]"* %b, align 8 - %72 = bitcast %"int[][]"* %a to i8* - %73 = insertvalue %variant undef, i8* %72, 0 - %74 = insertvalue %variant %73, i64 ptrtoint (%.introspect* @"ct$sa$sa$int" to i64), 1 - %75 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots15, i64 0, i64 0 - store %variant %74, %variant* %75, align 16 - %76 = bitcast [1 x %variant]* %varargslots15 to %variant* - %77 = insertvalue %"variant[]" undef, %variant* %76, 0 - %78 = insertvalue %"variant[]" %77, i64 1, 1 - store %"variant[]" %78, %"variant[]"* %taddr16, align 8 - %79 = bitcast %"variant[]"* %taddr16 to { i8*, i64 }* - %80 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %79, i32 0, i32 0 - %lo17 = load i8*, i8** %80, align 8 - %81 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %79, i32 0, i32 1 - %hi18 = load i64, i64* %81, align 8 - %82 = call i64 @std_io_printfn(i64* %retparam14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i64 2, i8* %lo17, i64 %hi18) - %not_err19 = icmp eq i64 %82, 0 - br i1 %not_err19, label %after_check20, label %voiderr21 - -after_check20: ; preds = %voiderr10 - br label %voiderr21 - -voiderr21: ; preds = %after_check20, %voiderr10 - %83 = load %"int[][]", %"int[][]"* %b, align 8 - %84 = extractvalue %"int[][]" %83, 0 - %ptroffset = getelementptr inbounds %"int[]", %"int[]"* %84, i64 0 - %85 = insertvalue %"int[][]" undef, %"int[]"* %ptroffset, 0 - %86 = insertvalue %"int[][]" %85, i64 1, 1 - %87 = load %"int[][]", %"int[][]"* %a, align 8 - %88 = extractvalue %"int[][]" %87, 0 - %ptroffset22 = getelementptr inbounds %"int[]", %"int[]"* %88, i64 0 - %89 = insertvalue %"int[][]" undef, %"int[]"* %ptroffset22, 0 - %90 = insertvalue %"int[][]" %89, i64 1, 1 - %91 = extractvalue %"int[][]" %90, 0 - %92 = extractvalue %"int[][]" %86, 0 - store %"int[][]" %86, %"int[][]"* %taddr23, align 8 - %93 = getelementptr inbounds %"int[][]", %"int[][]"* %taddr23, i32 0, i32 1 - %94 = load i64, i64* %93, align 8 - %95 = mul i64 %94, 16 - %96 = bitcast %"int[]"* %91 to i8* - %97 = bitcast %"int[]"* %92 to i8* - call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %96, i8* align 8 %97, i64 %95, i1 false) - %98 = bitcast %"int[][]"* %a to i8* - %99 = insertvalue %variant undef, i8* %98, 0 - %100 = insertvalue %variant %99, i64 ptrtoint (%.introspect* @"ct$sa$sa$int" to i64), 1 - %101 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots25, i64 0, i64 0 - store %variant %100, %variant* %101, align 16 - %102 = bitcast [1 x %variant]* %varargslots25 to %variant* - %103 = insertvalue %"variant[]" undef, %variant* %102, 0 - %104 = insertvalue %"variant[]" %103, i64 1, 1 - store %"variant[]" %104, %"variant[]"* %taddr26, align 8 - %105 = bitcast %"variant[]"* %taddr26 to { i8*, i64 }* - %106 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %105, i32 0, i32 0 - %lo27 = load i8*, i8** %106, align 8 - %107 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %105, i32 0, i32 1 - %hi28 = load i64, i64* %107, align 8 - %108 = call i64 @std_io_printfn(i64* %retparam24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i64 2, i8* %lo27, i64 %hi28) - %not_err29 = icmp eq i64 %108, 0 - br i1 %not_err29, label %after_check30, label %voiderr31 - -after_check30: ; preds = %voiderr21 - br label %voiderr31 - -voiderr31: ; preds = %after_check30, %voiderr21 - %109 = getelementptr inbounds <6 x i32>, <6 x i32>* %y, i64 0, i64 2 - %110 = insertvalue %"int[]" undef, i32* %109, 0 - %111 = insertvalue %"int[]" %110, i64 3, 1 - %112 = load %"int[][]", %"int[][]"* %a, align 8 - %113 = extractvalue %"int[][]" %112, 0 - %ptroffset32 = getelementptr inbounds %"int[]", %"int[]"* %113, i64 0 - store %"int[]" %111, %"int[]"* %ptroffset32, align 8 - %114 = bitcast %"int[][]"* %a to i8* - %115 = insertvalue %variant undef, i8* %114, 0 - %116 = insertvalue %variant %115, i64 ptrtoint (%.introspect* @"ct$sa$sa$int" to i64), 1 - %117 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots34, i64 0, i64 0 - store %variant %116, %variant* %117, align 16 - %118 = bitcast [1 x %variant]* %varargslots34 to %variant* - %119 = insertvalue %"variant[]" undef, %variant* %118, 0 - %120 = insertvalue %"variant[]" %119, i64 1, 1 - store %"variant[]" %120, %"variant[]"* %taddr35, align 8 - %121 = bitcast %"variant[]"* %taddr35 to { i8*, i64 }* - %122 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %121, i32 0, i32 0 - %lo36 = load i8*, i8** %122, align 8 - %123 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %121, i32 0, i32 1 - %hi37 = load i64, i64* %123, align 8 - %124 = call i64 @std_io_printfn(i64* %retparam33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i64 2, i8* %lo36, i64 %hi37) - %not_err38 = icmp eq i64 %124, 0 - br i1 %not_err38, label %after_check39, label %voiderr40 - -after_check39: ; preds = %voiderr31 - br label %voiderr40 - -voiderr40: ; preds = %after_check39, %voiderr31 - ret void -} diff --git a/test/test_suite14/statements/binary_fail.c3 b/test/test_suite14/statements/binary_fail.c3 deleted file mode 100644 index 4e124de8d..000000000 --- a/test/test_suite14/statements/binary_fail.c3 +++ /dev/null @@ -1,8 +0,0 @@ -fn void test() -{ - float a; - float b; - int *c; - int *d; - if (a + c) return; // #error: A value of type 'float' cannot be added to 'int*', an integer was expected here -} \ No newline at end of file diff --git a/test/test_suite14/statements/call_missing_paren.c3 b/test/test_suite14/statements/call_missing_paren.c3 deleted file mode 100644 index 3bcb40748..000000000 --- a/test/test_suite14/statements/call_missing_paren.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn void foo(int a) {} - -fn int main() -{ - foo(10, foo(); // #error: Did you forget a ')' before this - return 0; -} \ No newline at end of file diff --git a/test/test_suite14/statements/comparison_widening.c3t b/test/test_suite14/statements/comparison_widening.c3t deleted file mode 100644 index 2ceef4f9a..000000000 --- a/test/test_suite14/statements/comparison_widening.c3t +++ /dev/null @@ -1,34 +0,0 @@ -// #target: macos-x64 - -fn void test1() -{ - char a = 1; - int b = 2; - char c = b > a ? 1u8 : 0u8; - int d = b ?: 1; -} - -/* #expect: comparison_widening.ll - -define void @comparison_widening_test1() #0 { -entry: - %a = alloca i8, align 1 - %b = alloca i32, align 4 - %c = alloca i8, align 1 - %d = alloca i32, align 4 - store i8 1, i8* %a, align 1 - store i32 2, i32* %b, align 4 - %0 = load i32, i32* %b, align 4 - %1 = load i8, i8* %a, align 1 - %zext = zext i8 %1 to i32 - %gt = icmp sgt i32 %0, %zext - %check = icmp sge i32 %zext, 0 - %siui-gt = and i1 %check, %gt - %ternary = select i1 %siui-gt, i8 1, i8 0 - store i8 %ternary, i8* %c, align 1 - %2 = load i32, i32* %b, align 4 - %intbool = icmp ne i32 %2, 0 - %ternary1 = select i1 %intbool, i32 %2, i32 1 - store i32 %ternary1, i32* %d, align 4 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/conditional_return.c3 b/test/test_suite14/statements/conditional_return.c3 deleted file mode 100644 index 1337d5c26..000000000 --- a/test/test_suite14/statements/conditional_return.c3 +++ /dev/null @@ -1,12 +0,0 @@ -fn int testReturnWithConditional() -{ - int i = 0; - if (i > 0) - { - return 1; - } - else - { - return 2; - } -} \ No newline at end of file diff --git a/test/test_suite14/statements/const_statements.c3t b/test/test_suite14/statements/const_statements.c3t deleted file mode 100644 index 7c99ac72c..000000000 --- a/test/test_suite14/statements/const_statements.c3t +++ /dev/null @@ -1,15 +0,0 @@ -// #target: macos-x64 - -module test; -fn void main() -{ - var $x = { { 1, 2 } }; - $x; -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/custom_foreach_with_ref.c3t b/test/test_suite14/statements/custom_foreach_with_ref.c3t deleted file mode 100644 index 78cc03d63..000000000 --- a/test/test_suite14/statements/custom_foreach_with_ref.c3t +++ /dev/null @@ -1,481 +0,0 @@ -// #target: macos-x64 -module foo; - -struct Foo -{ - int[3] a; -} - -extern fn void printf(char*, ...); - -macro int* Foo.@operator_element_at_ref(Foo &f, int a) @operator(&[]) -{ - return &f.a[a]; -} - -macro int Foo.@operator_len(Foo &f) @operator(len) -{ - return 3; -} - -macro int Foo.@operator_element_at(Foo &f, int a) @operator([]) -{ - return f.a[a]; -} - -fn int[5] getFields() -{ - printf("getFields\n"); - return int[5] { 3, 5, 2, 10, 111}; -} -fn Foo *call(Foo *f) -{ - printf("Call made\n"); - return f; -} -fn void main() -{ - Foo x = { { 1, 5, 7} }; - printf("%d %d %d\n", x[0], x[1], x[2]); - foreach (i, int y : *call(&x)) - { - printf("Hello %d: %d\n", i, y); - } - foreach (i, int* &y : x) - { - *y += 1; - printf("Hello %d: %d\n", i, *y); - } - foreach (i, int y : x) - { - printf("After one %d: %d\n", i, y); - } - - foreach (i, int y : &x) - { - printf("By pointer %d: %d\n", i, y); - } - - foreach (i, int y : x) - { - printf("Adding %d: %d\n", i, y); - i++; - } - - foreach(i, y : int[5] { 1, 2, 10, 111, 123 } ) - { - printf("Adding %d: %d\n", i, y); - i++; - } - foreach(i, y : getFields() ) - { - printf("Pull value %d: %d\n", i, y); - } - foreach(i, y : &&getFields()) - { - printf("Pull value tempptr %d: %d\n", i, y); - } - printf("%d %d\n", x[0], x[1]); - int* y = &x[1]; - *y += 1; - printf("%d %d\n", x[0], x[1]); -} - -/* #expect: foo.ll - -%Foo = type { [3 x i32] } - -@"ct$foo_Foo" = linkonce constant %.introspect { i8 10, i64 12, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8 -@.str = private unnamed_addr constant [11 x i8] c"getFields\0A\00", align 1 -@.str.1 = private unnamed_addr constant [11 x i8] c"Call made\0A\00", align 1 -@.__const = private unnamed_addr constant %Foo { [3 x i32] [i32 1, i32 5, i32 7] }, align 4 -@.str.2 = private unnamed_addr constant [10 x i8] c"%d %d %d\0A\00", align 1 -@.str.3 = private unnamed_addr constant [14 x i8] c"Hello %d: %d\0A\00", align 1 -@.str.4 = private unnamed_addr constant [14 x i8] c"Hello %d: %d\0A\00", align 1 -@.str.5 = private unnamed_addr constant [18 x i8] c"After one %d: %d\0A\00", align 1 -@.str.6 = private unnamed_addr constant [19 x i8] c"By pointer %d: %d\0A\00", align 1 -@.str.7 = private unnamed_addr constant [15 x i8] c"Adding %d: %d\0A\00", align 1 -@.__const.8 = private unnamed_addr constant [5 x i32] [i32 1, i32 2, i32 10, i32 111, i32 123], align 16 -@.str.9 = private unnamed_addr constant [15 x i8] c"Adding %d: %d\0A\00", align 1 -@.str.10 = private unnamed_addr constant [19 x i8] c"Pull value %d: %d\0A\00", align 1 -@.str.11 = private unnamed_addr constant [27 x i8] c"Pull value tempptr %d: %d\0A\00", align 1 -@.str.12 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1 -@.str.13 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1 - -define void @foo_getFields([5 x i32]* noalias sret([5 x i32]) align 4 %0) #0 { -entry: - %literal = alloca [5 x i32], align 16 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0)) - %1 = getelementptr inbounds [5 x i32], [5 x i32]* %literal, i64 0, i64 0 - store i32 3, i32* %1, align 4 - %2 = getelementptr inbounds [5 x i32], [5 x i32]* %literal, i64 0, i64 1 - store i32 5, i32* %2, align 4 - %3 = getelementptr inbounds [5 x i32], [5 x i32]* %literal, i64 0, i64 2 - store i32 2, i32* %3, align 4 - %4 = getelementptr inbounds [5 x i32], [5 x i32]* %literal, i64 0, i64 3 - store i32 10, i32* %4, align 4 - %5 = getelementptr inbounds [5 x i32], [5 x i32]* %literal, i64 0, i64 4 - store i32 111, i32* %5, align 4 - %6 = bitcast [5 x i32]* %0 to i8* - %7 = bitcast [5 x i32]* %literal to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 20, i1 false) - ret void -} - -; Function Attrs: nounwind -define %Foo* @foo_call(%Foo* %0) #0 { -entry: - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0)) - ret %Foo* %0 -} -define void @foo_main() #0 { -entry: - %x = alloca %Foo, align 4 - %a = alloca i32, align 4 - %a1 = alloca i32, align 4 - %a3 = alloca i32, align 4 - %.anon = alloca %Foo*, align 8 - %.anon5 = alloca i32, align 4 - %.anon6 = alloca i32, align 4 - %i = alloca i32, align 4 - %y = alloca i32, align 4 - %a7 = alloca i32, align 4 - %.anon9 = alloca i32, align 4 - %.anon10 = alloca i32, align 4 - %i14 = alloca i32, align 4 - %y15 = alloca i32*, align 8 - %a16 = alloca i32, align 4 - %.anon21 = alloca i32, align 4 - %.anon22 = alloca i32, align 4 - %i26 = alloca i32, align 4 - %y27 = alloca i32, align 4 - %a28 = alloca i32, align 4 - %.anon32 = alloca i32, align 4 - %.anon33 = alloca i32, align 4 - %i37 = alloca i32, align 4 - %y38 = alloca i32, align 4 - %a39 = alloca i32, align 4 - %.anon43 = alloca i32, align 4 - %.anon44 = alloca i32, align 4 - %i48 = alloca i32, align 4 - %y49 = alloca i32, align 4 - %a50 = alloca i32, align 4 - %.anon55 = alloca [5 x i32], align 16 - %.anon56 = alloca i64, align 8 - %i59 = alloca i64, align 8 - %y60 = alloca i32, align 4 - %.anon64 = alloca [5 x i32], align 16 - %.anon65 = alloca i64, align 8 - %i69 = alloca i64, align 8 - %y70 = alloca i32, align 4 - %.anon73 = alloca [5 x i32]*, align 8 - %sretparam = alloca [5 x i32], align 4 - %.anon74 = alloca i64, align 8 - %i78 = alloca i64, align 8 - %y79 = alloca i32, align 4 - %a82 = alloca i32, align 4 - %a84 = alloca i32, align 4 - %y86 = alloca i32*, align 8 - %a87 = alloca i32, align 4 - %a90 = alloca i32, align 4 - %a92 = alloca i32, align 4 - %0 = bitcast %Foo* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%Foo* @.__const to i8*), i32 12, i1 false) - store i32 0, i32* %a, align 4 - %1 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %2 = load i32, i32* %a, align 4 - %sisiext = sext i32 %2 to i64 - %3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %sisiext - %4 = load i32, i32* %3, align 4 - store i32 1, i32* %a1, align 4 - %5 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %6 = load i32, i32* %a1, align 4 - %sisiext2 = sext i32 %6 to i64 - %7 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 %sisiext2 - %8 = load i32, i32* %7, align 4 - store i32 2, i32* %a3, align 4 - %9 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %10 = load i32, i32* %a3, align 4 - %sisiext4 = sext i32 %10 to i64 - %11 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 %sisiext4 - %12 = load i32, i32* %11, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i32 %4, i32 %8, i32 %12) - %13 = call %Foo* @foo_call(%Foo* %x) - store %Foo* %13, %Foo** %.anon, align 8 - store i32 3, i32* %.anon5, align 4 - store i32 0, i32* %.anon6, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %14 = load i32, i32* %.anon6, align 4 - %15 = load i32, i32* %.anon5, align 4 - %lt = icmp slt i32 %14, %15 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %16 = load i32, i32* %.anon6, align 4 - store i32 %16, i32* %i, align 4 - %17 = load %Foo*, %Foo** %.anon, align 8 - %18 = load i32, i32* %.anon6, align 4 - store i32 %18, i32* %a7, align 4 - %19 = getelementptr inbounds %Foo, %Foo* %17, i32 0, i32 0 - %20 = load i32, i32* %a7, align 4 - %sisiext8 = sext i32 %20 to i64 - %21 = getelementptr inbounds [3 x i32], [3 x i32]* %19, i64 0, i64 %sisiext8 - %22 = load i32, i32* %21, align 4 - store i32 %22, i32* %y, align 4 - %23 = load i32, i32* %i, align 4 - %24 = load i32, i32* %y, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0), i32 %23, i32 %24) - %25 = load i32, i32* %.anon6, align 4 - %add = add i32 %25, 1 - store i32 %add, i32* %.anon6, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - store i32 3, i32* %.anon9, align 4 - store i32 0, i32* %.anon10, align 4 - br label %loop.cond11 - -loop.cond11: ; preds = %loop.body13, %loop.exit - %26 = load i32, i32* %.anon10, align 4 - %27 = load i32, i32* %.anon9, align 4 - %lt12 = icmp slt i32 %26, %27 - br i1 %lt12, label %loop.body13, label %loop.exit20 - -loop.body13: ; preds = %loop.cond11 - %28 = load i32, i32* %.anon10, align 4 - store i32 %28, i32* %i14, align 4 - %29 = load i32, i32* %.anon10, align 4 - store i32 %29, i32* %a16, align 4 - %30 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %31 = load i32, i32* %a16, align 4 - %sisiext17 = sext i32 %31 to i64 - %32 = getelementptr inbounds [3 x i32], [3 x i32]* %30, i64 0, i64 %sisiext17 - store i32* %32, i32** %y15, align 8 - %33 = load i32*, i32** %y15, align 8 - %34 = load i32, i32* %33, align 4 - %add18 = add i32 %34, 1 - store i32 %add18, i32* %33, align 4 - %35 = load i32, i32* %i14, align 4 - %36 = load i32*, i32** %y15, align 8 - %37 = load i32, i32* %36, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i32 %35, i32 %37) - %38 = load i32, i32* %.anon10, align 4 - %add19 = add i32 %38, 1 - store i32 %add19, i32* %.anon10, align 4 - br label %loop.cond11 - -loop.exit20: ; preds = %loop.cond11 - store i32 3, i32* %.anon21, align 4 - store i32 0, i32* %.anon22, align 4 - br label %loop.cond23 - -loop.cond23: ; preds = %loop.body25, %loop.exit20 - %39 = load i32, i32* %.anon22, align 4 - %40 = load i32, i32* %.anon21, align 4 - %lt24 = icmp slt i32 %39, %40 - br i1 %lt24, label %loop.body25, label %loop.exit31 - -loop.body25: ; preds = %loop.cond23 - %41 = load i32, i32* %.anon22, align 4 - store i32 %41, i32* %i26, align 4 - %42 = load i32, i32* %.anon22, align 4 - store i32 %42, i32* %a28, align 4 - %43 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %44 = load i32, i32* %a28, align 4 - %sisiext29 = sext i32 %44 to i64 - %45 = getelementptr inbounds [3 x i32], [3 x i32]* %43, i64 0, i64 %sisiext29 - %46 = load i32, i32* %45, align 4 - store i32 %46, i32* %y27, align 4 - %47 = load i32, i32* %i26, align 4 - %48 = load i32, i32* %y27, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i32 0, i32 0), i32 %47, i32 %48) - %49 = load i32, i32* %.anon22, align 4 - %add30 = add i32 %49, 1 - store i32 %add30, i32* %.anon22, align 4 - br label %loop.cond23 - -loop.exit31: ; preds = %loop.cond23 - store i32 3, i32* %.anon32, align 4 - store i32 0, i32* %.anon33, align 4 - br label %loop.cond34 - -loop.cond34: ; preds = %loop.body36, %loop.exit31 - %50 = load i32, i32* %.anon33, align 4 - %51 = load i32, i32* %.anon32, align 4 - %lt35 = icmp slt i32 %50, %51 - br i1 %lt35, label %loop.body36, label %loop.exit42 - -loop.body36: ; preds = %loop.cond34 - %52 = load i32, i32* %.anon33, align 4 - store i32 %52, i32* %i37, align 4 - %53 = load i32, i32* %.anon33, align 4 - store i32 %53, i32* %a39, align 4 - %54 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %55 = load i32, i32* %a39, align 4 - %sisiext40 = sext i32 %55 to i64 - %56 = getelementptr inbounds [3 x i32], [3 x i32]* %54, i64 0, i64 %sisiext40 - %57 = load i32, i32* %56, align 4 - store i32 %57, i32* %y38, align 4 - %58 = load i32, i32* %i37, align 4 - %59 = load i32, i32* %y38, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i32 0, i32 0), i32 %58, i32 %59) - %60 = load i32, i32* %.anon33, align 4 - %add41 = add i32 %60, 1 - store i32 %add41, i32* %.anon33, align 4 - br label %loop.cond34 - -loop.exit42: ; preds = %loop.cond34 - store i32 3, i32* %.anon43, align 4 - store i32 0, i32* %.anon44, align 4 - br label %loop.cond45 - -loop.cond45: ; preds = %loop.body47, %loop.exit42 - %61 = load i32, i32* %.anon44, align 4 - %62 = load i32, i32* %.anon43, align 4 - %lt46 = icmp slt i32 %61, %62 - br i1 %lt46, label %loop.body47, label %loop.exit54 - -loop.body47: ; preds = %loop.cond45 - %63 = load i32, i32* %.anon44, align 4 - store i32 %63, i32* %i48, align 4 - %64 = load i32, i32* %.anon44, align 4 - store i32 %64, i32* %a50, align 4 - %65 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %66 = load i32, i32* %a50, align 4 - %sisiext51 = sext i32 %66 to i64 - %67 = getelementptr inbounds [3 x i32], [3 x i32]* %65, i64 0, i64 %sisiext51 - %68 = load i32, i32* %67, align 4 - store i32 %68, i32* %y49, align 4 - %69 = load i32, i32* %i48, align 4 - %70 = load i32, i32* %y49, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i32 0, i32 0), i32 %69, i32 %70) - %71 = load i32, i32* %i48, align 4 - %add52 = add i32 %71, 1 - store i32 %add52, i32* %i48, align 4 - %72 = load i32, i32* %.anon44, align 4 - %add53 = add i32 %72, 1 - store i32 %add53, i32* %.anon44, align 4 - br label %loop.cond45 - -loop.exit54: ; preds = %loop.cond45 - %73 = bitcast [5 x i32]* %.anon55 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %73, i8* align 16 bitcast ([5 x i32]* @.__const.8 to i8*), i32 20, i1 false) - store i64 0, i64* %.anon56, align 8 - br label %loop.cond57 - -loop.cond57: ; preds = %loop.body58, %loop.exit54 - %74 = load i64, i64* %.anon56, align 8 - %gt = icmp ugt i64 5, %74 - br i1 %gt, label %loop.body58, label %loop.exit63 - -loop.body58: ; preds = %loop.cond57 - %75 = load i64, i64* %.anon56, align 8 - store i64 %75, i64* %i59, align 8 - %76 = load i64, i64* %.anon56, align 8 - %77 = getelementptr inbounds [5 x i32], [5 x i32]* %.anon55, i64 0, i64 %76 - %78 = load i32, i32* %77, align 4 - store i32 %78, i32* %y60, align 4 - %79 = load i64, i64* %i59, align 8 - %80 = load i32, i32* %y60, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i32 0, i32 0), i64 %79, i32 %80) - %81 = load i64, i64* %i59, align 8 - %add61 = add i64 %81, 1 - store i64 %add61, i64* %i59, align 8 - %82 = load i64, i64* %.anon56, align 8 - %add62 = add i64 %82, 1 - store i64 %add62, i64* %.anon56, align 8 - br label %loop.cond57 - -loop.exit63: ; preds = %loop.cond57 - call void @foo_getFields([5 x i32]* sret([5 x i32]) align 4 %.anon64) - store i64 0, i64* %.anon65, align 8 - br label %loop.cond66 - -loop.cond66: ; preds = %loop.body68, %loop.exit63 - %83 = load i64, i64* %.anon65, align 8 - %gt67 = icmp ugt i64 5, %83 - br i1 %gt67, label %loop.body68, label %loop.exit72 - -loop.body68: ; preds = %loop.cond66 - %84 = load i64, i64* %.anon65, align 8 - store i64 %84, i64* %i69, align 8 - %85 = load i64, i64* %.anon65, align 8 - %86 = getelementptr inbounds [5 x i32], [5 x i32]* %.anon64, i64 0, i64 %85 - %87 = load i32, i32* %86, align 4 - store i32 %87, i32* %y70, align 4 - %88 = load i64, i64* %i69, align 8 - %89 = load i32, i32* %y70, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i32 0, i32 0), i64 %88, i32 %89) - %90 = load i64, i64* %.anon65, align 8 - %add71 = add i64 %90, 1 - store i64 %add71, i64* %.anon65, align 8 - br label %loop.cond66 - -loop.exit72: ; preds = %loop.cond66 - call void @foo_getFields([5 x i32]* sret([5 x i32]) align 4 %sretparam) - store [5 x i32]* %sretparam, [5 x i32]** %.anon73, align 8 - store i64 0, i64* %.anon74, align 8 - br label %loop.cond75 - -loop.cond75: ; preds = %loop.body77, %loop.exit72 - %91 = load i64, i64* %.anon74, align 8 - %gt76 = icmp ugt i64 5, %91 - br i1 %gt76, label %loop.body77, label %loop.exit81 - -loop.body77: ; preds = %loop.cond75 - %92 = load i64, i64* %.anon74, align 8 - store i64 %92, i64* %i78, align 8 - %93 = load [5 x i32]*, [5 x i32]** %.anon73, align 8 - %94 = load i64, i64* %.anon74, align 8 - %95 = getelementptr inbounds [5 x i32], [5 x i32]* %93, i64 0, i64 %94 - %96 = load i32, i32* %95, align 4 - store i32 %96, i32* %y79, align 4 - %97 = load i64, i64* %i78, align 8 - %98 = load i32, i32* %y79, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i32 0, i32 0), i64 %97, i32 %98) - %99 = load i64, i64* %.anon74, align 8 - %add80 = add i64 %99, 1 - store i64 %add80, i64* %.anon74, align 8 - br label %loop.cond75 - -loop.exit81: ; preds = %loop.cond75 - store i32 0, i32* %a82, align 4 - %100 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %101 = load i32, i32* %a82, align 4 - %sisiext83 = sext i32 %101 to i64 - %102 = getelementptr inbounds [3 x i32], [3 x i32]* %100, i64 0, i64 %sisiext83 - %103 = load i32, i32* %102, align 4 - store i32 1, i32* %a84, align 4 - %104 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %105 = load i32, i32* %a84, align 4 - %sisiext85 = sext i32 %105 to i64 - %106 = getelementptr inbounds [3 x i32], [3 x i32]* %104, i64 0, i64 %sisiext85 - %107 = load i32, i32* %106, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i32 0, i32 0), i32 %103, i32 %107) - store i32 1, i32* %a87, align 4 - %108 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %109 = load i32, i32* %a87, align 4 - %sisiext88 = sext i32 %109 to i64 - %110 = getelementptr inbounds [3 x i32], [3 x i32]* %108, i64 0, i64 %sisiext88 - store i32* %110, i32** %y86, align 8 - %111 = load i32*, i32** %y86, align 8 - %112 = load i32, i32* %111, align 4 - %add89 = add i32 %112, 1 - store i32 %add89, i32* %111, align 4 - store i32 0, i32* %a90, align 4 - %113 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %114 = load i32, i32* %a90, align 4 - %sisiext91 = sext i32 %114 to i64 - %115 = getelementptr inbounds [3 x i32], [3 x i32]* %113, i64 0, i64 %sisiext91 - %116 = load i32, i32* %115, align 4 - store i32 1, i32* %a92, align 4 - %117 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %118 = load i32, i32* %a92, align 4 - %sisiext93 = sext i32 %118 to i64 - %119 = getelementptr inbounds [3 x i32], [3 x i32]* %117, i64 0, i64 %sisiext93 - %120 = load i32, i32* %119, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i32 0, i32 0), i32 %116, i32 %120) - ret void -} diff --git a/test/test_suite14/statements/default_args.c3 b/test/test_suite14/statements/default_args.c3 deleted file mode 100644 index 2c9aaa347..000000000 --- a/test/test_suite14/statements/default_args.c3 +++ /dev/null @@ -1,4 +0,0 @@ - -define Foo = fn void(int a = 10); -fn int abc() { return 1; } -define Foo2 = fn void(int a = abc()); diff --git a/test/test_suite14/statements/defer_break.c3t b/test/test_suite14/statements/defer_break.c3t deleted file mode 100644 index 33eb2c9f6..000000000 --- a/test/test_suite14/statements/defer_break.c3t +++ /dev/null @@ -1,114 +0,0 @@ -module foo; - -extern fn void printf(char* message, ...); - -fn void defer1() {} -fn void defer2() {} -fn void defer3() {} -fn void defer4() {} -fn void defer5() {} -fn void defer6() {} -fn void defer7() {} -fn void defer8() {} -fn void defer9() {} -fn void defer10() {} -fn void defer11() {} - -fn int main(int argc, char** argv) -{ - int a = 0; - { - defer do { - if (a == 1) break; - defer1(); - } while(0); - defer2(); - } - defer defer3(); - while (a) - { - defer defer4(); - if (argc == 1) break; - defer defer5(); - defer6(); - } - defer defer7(); - while (a) - { - defer defer8(); - if (argc == 1) break; - defer defer9(); - defer10(); - break; - defer11(); - } - return 0; -} - -/* #expect: foo.ll - -define i32 @main(i32 %0, i8** %1) #0 { -entry: - %a = alloca i32, align 4 - store i32 0, i32* %a, align 4 - call void @foo_defer2() - %2 = load i32, i32* %a, align 4 - %eq = icmp eq i32 %2, 1 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - br label %loop.exit - -if.exit: ; preds = %entry - call void @foo_defer1() - br label %loop.exit - -loop.exit: ; preds = %if.exit, %if.then - br label %loop.cond - -loop.cond: ; preds = %if.exit3, %loop.exit - %3 = load i32, i32* %a, align 4 - %intbool = icmp ne i32 %3, 0 - br i1 %intbool, label %loop.body, label %loop.exit4 - -loop.body: ; preds = %loop.cond - %eq1 = icmp eq i32 %0, 1 - br i1 %eq1, label %if.then2, label %if.exit3 - -if.then2: ; preds = %loop.body - call void @foo_defer4() - br label %loop.exit4 - -if.exit3: ; preds = %loop.body - call void @foo_defer6() - call void @foo_defer5() - call void @foo_defer4() - br label %loop.cond - -loop.exit4: ; preds = %if.then2, %loop.cond - br label %loop.cond5 - -loop.cond5: ; preds = %loop.exit4 - %4 = load i32, i32* %a, align 4 - %intbool6 = icmp ne i32 %4, 0 - br i1 %intbool6, label %loop.body7, label %loop.exit11 - -loop.body7: ; preds = %loop.cond5 - %eq8 = icmp eq i32 %0, 1 - br i1 %eq8, label %if.then9, label %if.exit10 - -if.then9: ; preds = %loop.body7 - call void @foo_defer8() - br label %loop.exit11 - -if.exit10: ; preds = %loop.body7 - call void @foo_defer10() - call void @foo_defer9() - call void @foo_defer8() - br label %loop.exit11 - -loop.exit11: ; preds = %if.exit10, %if.then9, %loop.cond5 - call void @foo_defer7() - call void @foo_defer3() - ret i32 0 -} \ No newline at end of file diff --git a/test/test_suite14/statements/defer_break_simple.c3t b/test/test_suite14/statements/defer_break_simple.c3t deleted file mode 100644 index d361d72b8..000000000 --- a/test/test_suite14/statements/defer_break_simple.c3t +++ /dev/null @@ -1,60 +0,0 @@ -// #target: macos-x64 -module test; - -fn void test2() {} -fn void testA() {} -fn void testB() {} -fn void test3() {} - -fn int main(int argc, char** argv) -{ - int a = 0; - while (a) - { - defer test2(); - defer - { - testA(); - testB(); - } - if (argc == 1) break; - test3(); - } - return 0; -} - -/* #expect: test.ll - - - -define i32 @main(i32 %0, i8** %1) #0 { -entry: - %a = alloca i32, align 4 - store i32 0, i32* %a, align 4 - br label %loop.cond - -loop.cond: ; preds = %if.exit, %entry - %2 = load i32, i32* %a, align 4 - %intbool = icmp ne i32 %2, 0 - br i1 %intbool, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %eq = icmp eq i32 %0, 1 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - call void @test_testA() - call void @test_testB() - call void @test_test2() - br label %loop.exit - -if.exit: ; preds = %loop.body - call void @test_test3() - call void @test_testA() - call void @test_testB() - call void @test_test2() - br label %loop.cond - -loop.exit: ; preds = %if.then, %loop.cond - ret i32 0 -} diff --git a/test/test_suite14/statements/defer_break_switch.c3t b/test/test_suite14/statements/defer_break_switch.c3t deleted file mode 100644 index 76be862d3..000000000 --- a/test/test_suite14/statements/defer_break_switch.c3t +++ /dev/null @@ -1,59 +0,0 @@ - -fn void test1() -{} - -fn void test2() -{} - -fn void test(int i) -{ - bool b = true; - switch (i) - { - case 1: - defer test2(); - if (b) break; - test1(); - case 2: - test1(); - } -} - -/* #expect: defer_break_switch.ll - -define void @defer_break_switch_test(i32 %0) #0 { -entry: - %b = alloca i8, align 1 - %switch = alloca i32, align 4 - store i8 1, i8* %b, align 1 - store i32 %0, i32* %switch, align 4 - br label %switch.entry - -switch.entry: ; preds = %entry - %1 = load i32, i32* %switch, align 4 - switch i32 %1, label %switch.exit [ - i32 1, label %switch.case - i32 2, label %switch.case1 - ] - -switch.case: ; preds = %switch.entry - %2 = load i8, i8* %b, align 1 - %3 = trunc i8 %2 to i1 - br i1 %3, label %if.then, label %if.exit - -if.then: ; preds = %switch.case - call void @defer_break_switch_test2() - br label %switch.exit - -if.exit: ; preds = %switch.case - call void @defer_break_switch_test1() - call void @defer_break_switch_test2() - br label %switch.exit - -switch.case1: ; preds = %switch.entry - call void @defer_break_switch_test1() - br label %switch.exit - -switch.exit: ; preds = %switch.case1, %if.exit, %if.then, %switch.entry - ret void -} diff --git a/test/test_suite14/statements/defer_do_while.c3t b/test/test_suite14/statements/defer_do_while.c3t deleted file mode 100644 index 0902d19c7..000000000 --- a/test/test_suite14/statements/defer_do_while.c3t +++ /dev/null @@ -1,38 +0,0 @@ -// #target: macos-x64 -module foo; - -fn void test() -{ - int a; - do - { - a++; - defer a++; - } while(a < 10); -} - -/* #expect: foo.ll - -define void @foo_test() #0 { -entry: - %a = alloca i32, align 4 - store i32 0, i32* %a, align 4 - br label %loop.body - -loop.cond: ; preds = %loop.body - %0 = load i32, i32* %a, align 4 - %lt = icmp slt i32 %0, 10 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond, %entry - %1 = load i32, i32* %a, align 4 - %add = add i32 %1, 1 - store i32 %add, i32* %a, align 4 - %2 = load i32, i32* %a, align 4 - %add1 = add i32 %2, 1 - store i32 %add1, i32* %a, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/defer_in_block.c3t b/test/test_suite14/statements/defer_in_block.c3t deleted file mode 100644 index f21d4509d..000000000 --- a/test/test_suite14/statements/defer_in_block.c3t +++ /dev/null @@ -1,71 +0,0 @@ -// #target: macos-x64 -module foo; -extern fn void printf(char*,...); - -fn void test(int x) -{ - defer printf("---\n"); - {| - defer printf("Hello %d\n", x); - x *= 2; - if (x < 100) return; - x *= 10000; - |}; - printf("+++\n"); - if (x == 0) - { - printf("0x\n"); - return; - } - if (x == 1) return; -} - -fn void main() -{ - test(123); - test(1); - test(0); -} -/* #expect: foo.ll - -define void @foo_test(i32 %0) #0 { -entry: - %x = alloca i32, align 4 - store i32 %0, i32* %x, align 4 - %1 = load i32, i32* %x, align 4 - %mul = mul i32 %1, 2 - store i32 %mul, i32* %x, align 4 - %2 = load i32, i32* %x, align 4 - %lt = icmp slt i32 %2, 100 - br i1 %lt, label %if.then, label %if.exit -if.then: ; preds = %entry - %3 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i32 %3) - br label %expr_block.exit -if.exit: ; preds = %entry - %4 = load i32, i32* %x, align 4 - %mul1 = mul i32 %4, 10000 - store i32 %mul1, i32* %x, align 4 - %5 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 %5) - br label %expr_block.exit -expr_block.exit: ; preds = %if.exit, %if.then - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0)) - %6 = load i32, i32* %x, align 4 - %eq = icmp eq i32 %6, 0 - br i1 %eq, label %if.then2, label %if.exit3 -if.then2: ; preds = %expr_block.exit - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0)) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0)) - ret void -if.exit3: ; preds = %expr_block.exit - %7 = load i32, i32* %x, align 4 - %eq4 = icmp eq i32 %7, 1 - br i1 %eq4, label %if.then5, label %if.exit6 -if.then5: ; preds = %if.exit3 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0)) - ret void -if.exit6: ; preds = %if.exit3 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0)) - ret void -} diff --git a/test/test_suite14/statements/defer_in_defer.c3t b/test/test_suite14/statements/defer_in_defer.c3t deleted file mode 100644 index e61cfb5ad..000000000 --- a/test/test_suite14/statements/defer_in_defer.c3t +++ /dev/null @@ -1,38 +0,0 @@ - -fn void test1() {} -fn void test2() {} -fn void test3() {} -fn void test4() {} - -fn void test() -{ - defer - { - defer test1(); - test2(); - defer test3(); - } - test4(); -} - -fn void test_line() -{ - defer { defer test1(); } -} - -// #expect: defer_in_defer.ll - -define void @defer_in_defer_test() #0 { -entry: - call void @defer_in_defer_test4() - call void @defer_in_defer_test2() - call void @defer_in_defer_test3() - call void @defer_in_defer_test1() - ret void -} - -define void @defer_in_defer_test_line() #0 { -entry: - call void @defer_in_defer_test1() - ret void -} diff --git a/test/test_suite14/statements/defer_in_defer2.c3t b/test/test_suite14/statements/defer_in_defer2.c3t deleted file mode 100644 index 78223bc23..000000000 --- a/test/test_suite14/statements/defer_in_defer2.c3t +++ /dev/null @@ -1,120 +0,0 @@ -// #target: macos-x64 - -module test; -extern fn void printf(char*,...); - -fn void test(int x) -{ - defer - { - do - { - defer printf("Hello %d\n", x); - x *= 2; - if (x < 100) break; - x *= 10000; - }; - } - if (x == 1) - { - printf("1x\n"); - return; - } - if (x == 0) return; -} - -fn void main() -{ - test(123); - test(1); - test(0); -} - -/* #expect: test.ll - -define void @test_test(i32 %0) #0 { -entry: - %x = alloca i32, align 4 - store i32 %0, i32* %x, align 4 - %1 = load i32, i32* %x, align 4 - %eq = icmp eq i32 %1, 1 - br i1 %eq, label %if.then, label %if.exit3 - -if.then: ; preds = %entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0)) - %2 = load i32, i32* %x, align 4 - %mul = mul i32 %2, 2 - store i32 %mul, i32* %x, align 4 - %3 = load i32, i32* %x, align 4 - %lt = icmp slt i32 %3, 100 - br i1 %lt, label %if.then1, label %if.exit - -if.then1: ; preds = %if.then - %4 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 %4) - br label %loop.exit - -if.exit: ; preds = %if.then - %5 = load i32, i32* %x, align 4 - %mul2 = mul i32 %5, 10000 - store i32 %mul2, i32* %x, align 4 - %6 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i32 %6) - br label %loop.exit - -loop.exit: ; preds = %if.exit, %if.then1 - ret void - -if.exit3: ; preds = %entry - %7 = load i32, i32* %x, align 4 - %eq4 = icmp eq i32 %7, 0 - br i1 %eq4, label %if.then5, label %if.exit12 - -if.then5: ; preds = %if.exit3 - %8 = load i32, i32* %x, align 4 - %mul6 = mul i32 %8, 2 - store i32 %mul6, i32* %x, align 4 - %9 = load i32, i32* %x, align 4 - %lt7 = icmp slt i32 %9, 100 - br i1 %lt7, label %if.then8, label %if.exit9 - -if.then8: ; preds = %if.then5 - %10 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i32 %10) - br label %loop.exit11 - -if.exit9: ; preds = %if.then5 - %11 = load i32, i32* %x, align 4 - %mul10 = mul i32 %11, 10000 - store i32 %mul10, i32* %x, align 4 - %12 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i32 %12) - br label %loop.exit11 - -loop.exit11: ; preds = %if.exit9, %if.then8 - ret void - -if.exit12: ; preds = %if.exit3 - %13 = load i32, i32* %x, align 4 - %mul13 = mul i32 %13, 2 - store i32 %mul13, i32* %x, align 4 - %14 = load i32, i32* %x, align 4 - %lt14 = icmp slt i32 %14, 100 - br i1 %lt14, label %if.then15, label %if.exit16 - -if.then15: ; preds = %if.exit12 - %15 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i32 %15) - br label %loop.exit18 - -if.exit16: ; preds = %if.exit12 - %16 = load i32, i32* %x, align 4 - %mul17 = mul i32 %16, 10000 - store i32 %mul17, i32* %x, align 4 - %17 = load i32, i32* %x, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i32 %17) - br label %loop.exit18 - -loop.exit18: ; preds = %if.exit16, %if.then15 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/defer_next_switch.c3t b/test/test_suite14/statements/defer_next_switch.c3t deleted file mode 100644 index f752ba0df..000000000 --- a/test/test_suite14/statements/defer_next_switch.c3t +++ /dev/null @@ -1,59 +0,0 @@ - -fn void test1() -{} - -fn void test2() -{} - -fn void test(int i) -{ - bool b = true; - switch (i) - { - case 1: - defer test2(); - if (b) nextcase; - test1(); - case 2: - test1(); - } -} - -/* #expect: defer_next_switch.ll - -define void @defer_next_switch_test(i32 %0) #0 { -entry: - %b = alloca i8, align 1 - %switch = alloca i32, align 4 - store i8 1, i8* %b, align 1 - store i32 %0, i32* %switch, align 4 - br label %switch.entry - -switch.entry: ; preds = %entry - %1 = load i32, i32* %switch, align 4 - switch i32 %1, label %switch.exit [ - i32 1, label %switch.case - i32 2, label %switch.case1 - ] - -switch.case: ; preds = %switch.entry - %2 = load i8, i8* %b, align 1 - %3 = trunc i8 %2 to i1 - br i1 %3, label %if.then, label %if.exit - -if.then: ; preds = %switch.case - call void @defer_next_switch_test2() - br label %switch.case1 - -if.exit: ; preds = %switch.case - call void @defer_next_switch_test1() - call void @defer_next_switch_test2() - br label %switch.exit - -switch.case1: ; preds = %switch.entry, %if.then - call void @defer_next_switch_test1() - br label %switch.exit - -switch.exit: ; preds = %switch.case1, %if.exit, %switch.entry - ret void -} diff --git a/test/test_suite14/statements/defer_return.c3t b/test/test_suite14/statements/defer_return.c3t deleted file mode 100644 index b20533e6f..000000000 --- a/test/test_suite14/statements/defer_return.c3t +++ /dev/null @@ -1,100 +0,0 @@ -// #target: macos-x64 -module test; -fn void test1() {} -fn void test2() {} -fn void test3() {} -fn void test4() {} -fn void test5() {} -fn void test6() {} -fn void test7() {} -fn void test8() {} -fn void test9() {} - -fn int main(int argc, char **argv) -{ - defer test1(); - int a = 0; - while (a) - { - defer test2(); - if (argc == 1) return a + argc; - defer test3(); - test4(); - } - defer test5(); - while (a) - { - defer test6(); - if (argc == 1) return a + 2; - defer test7(); - test8(); - return 2 + 2; - defer test9(); - } - return 0 + argc; -} - -/* #expect: test.ll - -define i32 @main(i32 %0, i8** %1) #0 { -entry: - %a = alloca i32, align 4 - store i32 0, i32* %a, align 4 - br label %loop.cond - -loop.cond: ; preds = %if.exit, %entry - %2 = load i32, i32* %a, align 4 - %intbool = icmp ne i32 %2, 0 - br i1 %intbool, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %eq = icmp eq i32 %0, 1 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - %3 = load i32, i32* %a, align 4 - %add = add i32 %3, %0 - call void @test_test2() - call void @test_test1() - ret i32 %add - -if.exit: ; preds = %loop.body - call void @test_test4() - call void @test_test3() - call void @test_test2() - br label %loop.cond - -loop.exit: ; preds = %loop.cond - br label %loop.cond1 - -loop.cond1: ; preds = %loop.exit - %4 = load i32, i32* %a, align 4 - %intbool2 = icmp ne i32 %4, 0 - br i1 %intbool2, label %loop.body3, label %loop.exit8 - -loop.body3: ; preds = %loop.cond1 - %eq4 = icmp eq i32 %0, 1 - br i1 %eq4, label %if.then5, label %if.exit7 - -if.then5: ; preds = %loop.body3 - %5 = load i32, i32* %a, align 4 - %add6 = add i32 %5, 2 - call void @test_test6() - call void @test_test5() - call void @test_test1() - ret i32 %add6 - -if.exit7: ; preds = %loop.body3 - call void @test_test8() - call void @test_test7() - call void @test_test6() - call void @test_test5() - call void @test_test1() - ret i32 4 - -loop.exit8: ; preds = %loop.cond1 - %add9 = add i32 0, %0 - call void @test_test5() - call void @test_test1() - ret i32 %add9 -} \ No newline at end of file diff --git a/test/test_suite14/statements/defer_test.c3 b/test/test_suite14/statements/defer_test.c3 deleted file mode 100644 index 81b9bf3e9..000000000 --- a/test/test_suite14/statements/defer_test.c3 +++ /dev/null @@ -1,9 +0,0 @@ -fn void test() -{ - int i = 0; - defer - { - i = i + 1; - } - return; -} \ No newline at end of file diff --git a/test/test_suite14/statements/defer_with_loop.c3t b/test/test_suite14/statements/defer_with_loop.c3t deleted file mode 100644 index 67da269ef..000000000 --- a/test/test_suite14/statements/defer_with_loop.c3t +++ /dev/null @@ -1,108 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn void printf(char*,...); - -fn void test(int x) -{ - defer - { - for (int i = 0; i < 3; i++) - { - printf("%d\n", x + i); - } - } - if (x == 1) - { - printf("1x\n"); - return; - } - if (x == 0) return; -} - -fn void main() -{ - test(123); - test(1); - test(0); -} - -/* #expect: test.ll - -define void @test_test(i32 %0) #0 { -entry: - %i = alloca i32, align 4 - %i4 = alloca i32, align 4 - %i12 = alloca i32, align 4 - %eq = icmp eq i32 %0, 1 - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0)) - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %if.then - %1 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %1, 3 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %2 = load i32, i32* %i, align 4 - %add = add i32 %0, %2 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 %add) - %3 = load i32, i32* %i, align 4 - %add1 = add i32 %3, 1 - store i32 %add1, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret void - -if.exit: ; preds = %entry - %eq2 = icmp eq i32 %0, 0 - br i1 %eq2, label %if.then3, label %if.exit11 - -if.then3: ; preds = %if.exit - store i32 0, i32* %i4, align 4 - br label %loop.cond5 - -loop.cond5: ; preds = %loop.body7, %if.then3 - %4 = load i32, i32* %i4, align 4 - %lt6 = icmp slt i32 %4, 3 - br i1 %lt6, label %loop.body7, label %loop.exit10 - -loop.body7: ; preds = %loop.cond5 - %5 = load i32, i32* %i4, align 4 - %add8 = add i32 %0, %5 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 %add8) - %6 = load i32, i32* %i4, align 4 - %add9 = add i32 %6, 1 - store i32 %add9, i32* %i4, align 4 - br label %loop.cond5 - -loop.exit10: ; preds = %loop.cond5 - ret void - -if.exit11: ; preds = %if.exit - store i32 0, i32* %i12, align 4 - br label %loop.cond13 - -loop.cond13: ; preds = %loop.body15, %if.exit11 - %7 = load i32, i32* %i12, align 4 - %lt14 = icmp slt i32 %7, 3 - br i1 %lt14, label %loop.body15, label %loop.exit18 - -loop.body15: ; preds = %loop.cond13 - %8 = load i32, i32* %i12, align 4 - %add16 = add i32 %0, %8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 %add16) - %9 = load i32, i32* %i12, align 4 - %add17 = add i32 %9, 1 - store i32 %add17, i32* %i12, align 4 - br label %loop.cond13 - -loop.exit18: ; preds = %loop.cond13 - ret void -} - diff --git a/test/test_suite14/statements/do_without_compound.c3 b/test/test_suite14/statements/do_without_compound.c3 deleted file mode 100644 index b37b73729..000000000 --- a/test/test_suite14/statements/do_without_compound.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test1() -{ - do test1(); while(1); // #error: A do loop must use { } around its body -} - diff --git a/test/test_suite14/statements/fallthough_do.c3t b/test/test_suite14/statements/fallthough_do.c3t deleted file mode 100644 index d37601048..000000000 --- a/test/test_suite14/statements/fallthough_do.c3t +++ /dev/null @@ -1,80 +0,0 @@ -// #target: macos-x64 - -module foo; -fn int test() -{ - static int x = 0; - return 1 + x++; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - int i = 10; - do - { - printf("%d\n", test()); - } while (false); - do - { - printf("%d, %d\n", i, test()); - }; - do - { - if (i < 0) continue; - printf("A\n", i, test()); - }; - do - { - if (i < 0) break; - printf("B\n", i, test()); - }; - -} - -/* #expect: foo.ll - -@"test$x" = internal unnamed_addr global i32 0, align 4 -@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 -@.str.1 = private unnamed_addr constant [8 x i8] c"%d, %d\0A\00", align 1 - -define void @foo_main() #0 { -entry: - %i = alloca i32, align 4 - store i32 10, i32* %i, align 4 - %0 = call i32 @foo_test() - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %0) - %1 = load i32, i32* %i, align 4 - %2 = call i32 @foo_test() - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 %1, i32 %2) - %3 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %3, 0 - br i1 %lt, label %if.then, label %if.exit - -if.then: ; preds = %entry - br label %loop.exit - -if.exit: ; preds = %entry - %4 = load i32, i32* %i, align 4 - %5 = call i32 @foo_test() - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i32 %4, i32 %5) - br label %loop.exit - -loop.exit: ; preds = %if.exit, %if.then - %6 = load i32, i32* %i, align 4 - %lt1 = icmp slt i32 %6, 0 - br i1 %lt1, label %if.then2, label %if.exit3 - -if.then2: ; preds = %loop.exit - br label %loop.exit4 - -if.exit3: ; preds = %loop.exit - %7 = load i32, i32* %i, align 4 - %8 = call i32 @foo_test() - call void (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i32 %7, i32 %8) - br label %loop.exit4 - -loop.exit4: ; preds = %if.exit3, %if.then2 - ret void -} diff --git a/test/test_suite14/statements/for.c3 b/test/test_suite14/statements/for.c3 deleted file mode 100644 index 3dc2e9a52..000000000 --- a/test/test_suite14/statements/for.c3 +++ /dev/null @@ -1,27 +0,0 @@ -module for_test; - - - -fn int test1() -{ - for (int x = 0;;) - { - } - return 0; -} - -fn int test2() -{ - for (int x = 0; 1 ;) - { - } - return 0; -} - -fn int test3() -{ - for (; 1 ;2) - { - } - return 0; -} diff --git a/test/test_suite14/statements/for_empty.c3 b/test/test_suite14/statements/for_empty.c3 deleted file mode 100644 index 3536032da..000000000 --- a/test/test_suite14/statements/for_empty.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn int main() -{ - for (;;); - - for (;;) {} - return 0; -} \ No newline at end of file diff --git a/test/test_suite14/statements/for_errors.c3 b/test/test_suite14/statements/for_errors.c3 deleted file mode 100644 index c013a65bc..000000000 --- a/test/test_suite14/statements/for_errors.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn void foo() {} - -fn int main() -{ - for (; foo() ; ) {} // #error: Expected a boolean expression - return 0; -} \ No newline at end of file diff --git a/test/test_suite14/statements/for_with_extra_declarations.c3 b/test/test_suite14/statements/for_with_extra_declarations.c3 deleted file mode 100644 index 12a04a1f7..000000000 --- a/test/test_suite14/statements/for_with_extra_declarations.c3 +++ /dev/null @@ -1,17 +0,0 @@ -fn void test() -{ - int j; - for (int i = 0; i < 10; i++) - { - - } - for (int i = 0, int foo = 0; i < 10; i++) - { - - } - - for (int i = 0, j = 1; i < 10; i++, j++) - { - - } -} \ No newline at end of file diff --git a/test/test_suite14/statements/foreach_break.c3t b/test/test_suite14/statements/foreach_break.c3t deleted file mode 100644 index c735dbc40..000000000 --- a/test/test_suite14/statements/foreach_break.c3t +++ /dev/null @@ -1,74 +0,0 @@ -// #target: macos-x64 -module test; - -fn void test() -{ - int[3] x; - int g = 0; - foreach (z : x) - { - if (z > 0) break; - if (z == 1) continue; - g += z; - } -} - -/* #expect: test.ll - -define void @test_test() #0 { -entry: - %x = alloca [3 x i32], align 4 - %g = alloca i32, align 4 - %.anon = alloca i64, align 8 - %z = alloca i32, align 4 - %0 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 0 - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - store i32 0, i32* %1, align 4 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 2 - store i32 0, i32* %2, align 4 - store i32 0, i32* %g, align 4 - store i64 0, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.inc, %entry - %3 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 3, %3 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %4 = load i64, i64* %.anon, align 8 - %5 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 %4 - %6 = load i32, i32* %5, align 4 - store i32 %6, i32* %z, align 4 - %7 = load i32, i32* %z, align 4 - %gt1 = icmp sgt i32 %7, 0 - br i1 %gt1, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - br label %loop.exit - -if.exit: ; preds = %loop.body - %8 = load i32, i32* %z, align 4 - %eq = icmp eq i32 %8, 1 - br i1 %eq, label %if.then2, label %if.exit3 - -if.then2: ; preds = %if.exit - br label %loop.inc - -if.exit3: ; preds = %if.exit - %9 = load i32, i32* %g, align 4 - %10 = load i32, i32* %z, align 4 - %add = add i32 %9, %10 - store i32 %add, i32* %g, align 4 - br label %loop.inc - -loop.inc: ; preds = %if.exit3, %if.then2 - %11 = load i64, i64* %.anon, align 8 - %add4 = add i64 %11, 1 - store i64 %add4, i64* %.anon, align 8 - br label %loop.cond - -loop.exit: ; preds = %if.then, %loop.cond - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/foreach_common.c3t b/test/test_suite14/statements/foreach_common.c3t deleted file mode 100644 index 2c74a61a7..000000000 --- a/test/test_suite14/statements/foreach_common.c3t +++ /dev/null @@ -1,377 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn void printf(char*, ...); - -fn void main() -{ - float[3] foo = { 2, 4.5, 8 }; - float[<3>] foo2 = { 2, 4.5, 8 }; - foreach (a : foo) - { - printf("Value: %f\n", a); - } - foreach (float* &a : foo) - { - *a *= 2; - printf("Value: %f\n", *a); - } - foreach (void* &a : foo) - { - printf("Value: %f\n", *((float*)(a))); - } - foreach (i, a : foo) - { - printf("Value[%d]: %f\n", i, a); - } - foreach (char i, double a : foo) - { - printf("Value2[%d]: %f\n", i, a); - } - foreach (double a : foo) - { - printf("Value3: %f\n", a); - } - - foreach (a : foo2) - { - printf("Value: %f\n", a); - } - foreach (float* &a : foo2) - { - *a *= 2; - printf("Value: %f\n", *a); - } - foreach (i, a : foo2) - { - printf("Value[%d]: %f\n", i, a); - } - foreach (char i, double a : foo2) - { - printf("Value2[%d]: %f\n", i, a); - } - foreach (double a : foo2) - { - printf("Value3: %f\n", a); - } -} - -/* #expect: test.ll - -entry: - %foo = alloca [3 x float], align 4 - %foo2 = alloca <3 x float>, align 16 - %.anon = alloca i64, align 8 - %a = alloca float, align 4 - %.anon1 = alloca i64, align 8 - %a5 = alloca float*, align 8 - %.anon9 = alloca i64, align 8 - %a13 = alloca i8*, align 8 - %.anon18 = alloca i64, align 8 - %i = alloca i64, align 8 - %a22 = alloca float, align 4 - %.anon26 = alloca i64, align 8 - %i30 = alloca i8, align 1 - %a31 = alloca double, align 8 - %.anon35 = alloca i64, align 8 - %a39 = alloca double, align 8 - %.anon43 = alloca i64, align 8 - %.anon44 = alloca i64, align 8 - %a47 = alloca float, align 4 - %.anon51 = alloca i64, align 8 - %.anon52 = alloca i64, align 8 - %a56 = alloca float*, align 8 - %.anon61 = alloca i64, align 8 - %.anon62 = alloca i64, align 8 - %i66 = alloca i64, align 8 - %a67 = alloca float, align 4 - %.anon71 = alloca i64, align 8 - %.anon72 = alloca i64, align 8 - %i76 = alloca i8, align 1 - %a78 = alloca double, align 8 - %.anon83 = alloca i64, align 8 - %.anon84 = alloca i64, align 8 - %a88 = alloca double, align 8 - %0 = bitcast [3 x float]* %foo to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x float]* @.__const to i8*), i32 12, i1 false) - store <3 x float> , <3 x float>* %foo2, align 16 - store i64 0, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %1 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 3, %1 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %2 = load i64, i64* %.anon, align 8 - %3 = getelementptr inbounds [3 x float], [3 x float]* %foo, i64 0, i64 %2 - %4 = load float, float* %3, align 4 - store float %4, float* %a, align 4 - %5 = load float, float* %a, align 4 - %fpfpext = fpext float %5 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), double %fpfpext) - %6 = load i64, i64* %.anon, align 8 - %add = add i64 %6, 1 - store i64 %add, i64* %.anon, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - store i64 0, i64* %.anon1, align 8 - br label %loop.cond2 - -loop.cond2: ; preds = %loop.body4, %loop.exit - %7 = load i64, i64* %.anon1, align 8 - %gt3 = icmp ugt i64 3, %7 - br i1 %gt3, label %loop.body4, label %loop.exit8 - -loop.body4: ; preds = %loop.cond2 - %8 = load i64, i64* %.anon1, align 8 - %9 = getelementptr inbounds [3 x float], [3 x float]* %foo, i64 0, i64 %8 - store float* %9, float** %a5, align 8 - %10 = load float*, float** %a5, align 8 - %11 = load float, float* %10, align 4 - %fmul = fmul float %11, 2.000000e+00 - store float %fmul, float* %10, align 4 - %12 = load float*, float** %a5, align 8 - %13 = load float, float* %12, align 4 - %fpfpext6 = fpext float %13 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), double %fpfpext6) - %14 = load i64, i64* %.anon1, align 8 - %add7 = add i64 %14, 1 - store i64 %add7, i64* %.anon1, align 8 - br label %loop.cond2 - -loop.exit8: ; preds = %loop.cond2 - store i64 0, i64* %.anon9, align 8 - br label %loop.cond10 - -loop.cond10: ; preds = %loop.body12, %loop.exit8 - %15 = load i64, i64* %.anon9, align 8 - %gt11 = icmp ugt i64 3, %15 - br i1 %gt11, label %loop.body12, label %loop.exit17 - -loop.body12: ; preds = %loop.cond10 - %16 = load i64, i64* %.anon9, align 8 - %17 = getelementptr inbounds [3 x float], [3 x float]* %foo, i64 0, i64 %16 - %ptrptr = bitcast float* %17 to i8* - store i8* %ptrptr, i8** %a13, align 8 - %18 = load i8*, i8** %a13, align 8 - %ptrptr14 = bitcast i8* %18 to float* - %19 = load float, float* %ptrptr14, align 4 - %fpfpext15 = fpext float %19 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), double %fpfpext15) - %20 = load i64, i64* %.anon9, align 8 - %add16 = add i64 %20, 1 - store i64 %add16, i64* %.anon9, align 8 - br label %loop.cond10 - -loop.exit17: ; preds = %loop.cond10 - store i64 0, i64* %.anon18, align 8 - br label %loop.cond19 - -loop.cond19: ; preds = %loop.body21, %loop.exit17 - %21 = load i64, i64* %.anon18, align 8 - %gt20 = icmp ugt i64 3, %21 - br i1 %gt20, label %loop.body21, label %loop.exit25 - -loop.body21: ; preds = %loop.cond19 - %22 = load i64, i64* %.anon18, align 8 - store i64 %22, i64* %i, align 8 - %23 = load i64, i64* %.anon18, align 8 - %24 = getelementptr inbounds [3 x float], [3 x float]* %foo, i64 0, i64 %23 - %25 = load float, float* %24, align 4 - store float %25, float* %a22, align 4 - %26 = load i64, i64* %i, align 8 - %27 = load float, float* %a22, align 4 - %fpfpext23 = fpext float %27 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i32 0, i32 0), i64 %26, double %fpfpext23) - %28 = load i64, i64* %.anon18, align 8 - %add24 = add i64 %28, 1 - store i64 %add24, i64* %.anon18, align 8 - br label %loop.cond19 - -loop.exit25: ; preds = %loop.cond19 - store i64 0, i64* %.anon26, align 8 - br label %loop.cond27 - -loop.cond27: ; preds = %loop.body29, %loop.exit25 - %29 = load i64, i64* %.anon26, align 8 - %gt28 = icmp ugt i64 3, %29 - br i1 %gt28, label %loop.body29, label %loop.exit34 - -loop.body29: ; preds = %loop.cond27 - %30 = load i64, i64* %.anon26, align 8 - %ztrunc = trunc i64 %30 to i8 - store i8 %ztrunc, i8* %i30, align 1 - %31 = load i64, i64* %.anon26, align 8 - %32 = getelementptr inbounds [3 x float], [3 x float]* %foo, i64 0, i64 %31 - %33 = load float, float* %32, align 4 - %fpfpext32 = fpext float %33 to double - store double %fpfpext32, double* %a31, align 8 - %34 = load i8, i8* %i30, align 1 - %uisiext = zext i8 %34 to i32 - %35 = load double, double* %a31, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0), i32 %uisiext, double %35) - %36 = load i64, i64* %.anon26, align 8 - %add33 = add i64 %36, 1 - store i64 %add33, i64* %.anon26, align 8 - br label %loop.cond27 - -loop.exit34: ; preds = %loop.cond27 - store i64 0, i64* %.anon35, align 8 - br label %loop.cond36 - -loop.cond36: ; preds = %loop.body38, %loop.exit34 - %37 = load i64, i64* %.anon35, align 8 - %gt37 = icmp ugt i64 3, %37 - br i1 %gt37, label %loop.body38, label %loop.exit42 - -loop.body38: ; preds = %loop.cond36 - %38 = load i64, i64* %.anon35, align 8 - %39 = getelementptr inbounds [3 x float], [3 x float]* %foo, i64 0, i64 %38 - %40 = load float, float* %39, align 4 - %fpfpext40 = fpext float %40 to double - store double %fpfpext40, double* %a39, align 8 - %41 = load double, double* %a39, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i32 0, i32 0), double %41) - %42 = load i64, i64* %.anon35, align 8 - %add41 = add i64 %42, 1 - store i64 %add41, i64* %.anon35, align 8 - br label %loop.cond36 - -loop.exit42: ; preds = %loop.cond36 - store i64 3, i64* %.anon43, align 8 - store i64 0, i64* %.anon44, align 8 - br label %loop.cond45 - -loop.cond45: ; preds = %loop.body46, %loop.exit42 - %43 = load i64, i64* %.anon44, align 8 - %44 = load i64, i64* %.anon43, align 8 - %lt = icmp ult i64 %43, %44 - br i1 %lt, label %loop.body46, label %loop.exit50 - -loop.body46: ; preds = %loop.cond45 - %45 = load <3 x float>, <3 x float>* %foo2, align 16 - %46 = load i64, i64* %.anon44, align 8 - %47 = extractelement <3 x float> %45, i64 %46 - store float %47, float* %a47, align 4 - %48 = load float, float* %a47, align 4 - %fpfpext48 = fpext float %48 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), double %fpfpext48) - %49 = load i64, i64* %.anon44, align 8 - %add49 = add i64 %49, 1 - store i64 %add49, i64* %.anon44, align 8 - br label %loop.cond45 - -loop.exit50: ; preds = %loop.cond45 - store i64 3, i64* %.anon51, align 8 - store i64 0, i64* %.anon52, align 8 - br label %loop.cond53 - -loop.cond53: ; preds = %loop.body55, %loop.exit50 - %50 = load i64, i64* %.anon52, align 8 - %51 = load i64, i64* %.anon51, align 8 - %lt54 = icmp ult i64 %50, %51 - br i1 %lt54, label %loop.body55, label %loop.exit60 - -loop.body55: ; preds = %loop.cond53 - %52 = load i64, i64* %.anon52, align 8 - %53 = getelementptr inbounds <3 x float>, <3 x float>* %foo2, i64 0, i64 %52 - store float* %53, float** %a56, align 8 - %54 = load float*, float** %a56, align 8 - %55 = load float, float* %54, align 4 - %fmul57 = fmul float %55, 2.000000e+00 - store float %fmul57, float* %54, align 4 - %56 = load float*, float** %a56, align 8 - %57 = load float, float* %56, align 4 - %fpfpext58 = fpext float %57 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0), double %fpfpext58) - %58 = load i64, i64* %.anon52, align 8 - %add59 = add i64 %58, 1 - store i64 %add59, i64* %.anon52, align 8 - br label %loop.cond53 - -loop.exit60: ; preds = %loop.cond53 - store i64 3, i64* %.anon61, align 8 - store i64 0, i64* %.anon62, align 8 - br label %loop.cond63 - -loop.cond63: ; preds = %loop.body65, %loop.exit60 - %59 = load i64, i64* %.anon62, align 8 - %60 = load i64, i64* %.anon61, align 8 - %lt64 = icmp ult i64 %59, %60 - br i1 %lt64, label %loop.body65, label %loop.exit70 - -loop.body65: ; preds = %loop.cond63 - %61 = load i64, i64* %.anon62, align 8 - store i64 %61, i64* %i66, align 8 - %62 = load <3 x float>, <3 x float>* %foo2, align 16 - %63 = load i64, i64* %.anon62, align 8 - %64 = extractelement <3 x float> %62, i64 %63 - store float %64, float* %a67, align 4 - %65 = load i64, i64* %i66, align 8 - %66 = load float, float* %a67, align 4 - %fpfpext68 = fpext float %66 to double - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i32 0, i32 0), i64 %65, double %fpfpext68) - %67 = load i64, i64* %.anon62, align 8 - %add69 = add i64 %67, 1 - store i64 %add69, i64* %.anon62, align 8 - br label %loop.cond63 - -loop.exit70: ; preds = %loop.cond63 - store i64 3, i64* %.anon71, align 8 - store i64 0, i64* %.anon72, align 8 - br label %loop.cond73 - -loop.cond73: ; preds = %loop.body75, %loop.exit70 - %68 = load i64, i64* %.anon72, align 8 - %69 = load i64, i64* %.anon71, align 8 - %lt74 = icmp ult i64 %68, %69 - br i1 %lt74, label %loop.body75, label %loop.exit82 - -loop.body75: ; preds = %loop.cond73 - %70 = load i64, i64* %.anon72, align 8 - %ztrunc77 = trunc i64 %70 to i8 - store i8 %ztrunc77, i8* %i76, align 1 - %71 = load <3 x float>, <3 x float>* %foo2, align 16 - %72 = load i64, i64* %.anon72, align 8 - %73 = extractelement <3 x float> %71, i64 %72 - %fpfpext79 = fpext float %73 to double - store double %fpfpext79, double* %a78, align 8 - %74 = load i8, i8* %i76, align 1 - %uisiext80 = zext i8 %74 to i32 - %75 = load double, double* %a78, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i32 0, i32 0), i32 %uisiext80, double %75) - %76 = load i64, i64* %.anon72, align 8 - %add81 = add i64 %76, 1 - store i64 %add81, i64* %.anon72, align 8 - br label %loop.cond73 - -loop.exit82: ; preds = %loop.cond73 - store i64 3, i64* %.anon83, align 8 - store i64 0, i64* %.anon84, align 8 - br label %loop.cond85 - -loop.cond85: ; preds = %loop.body87, %loop.exit82 - %77 = load i64, i64* %.anon84, align 8 - %78 = load i64, i64* %.anon83, align 8 - %lt86 = icmp ult i64 %77, %78 - br i1 %lt86, label %loop.body87, label %loop.exit91 - -loop.body87: ; preds = %loop.cond85 - %79 = load <3 x float>, <3 x float>* %foo2, align 16 - %80 = load i64, i64* %.anon84, align 8 - %81 = extractelement <3 x float> %79, i64 %80 - %fpfpext89 = fpext float %81 to double - store double %fpfpext89, double* %a88, align 8 - %82 = load double, double* %a88, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), double %82) - %83 = load i64, i64* %.anon84, align 8 - %add90 = add i64 %83, 1 - store i64 %add90, i64* %.anon84, align 8 - br label %loop.cond85 - -loop.exit91: ; preds = %loop.cond85 - ret void -} diff --git a/test/test_suite14/statements/foreach_custom.c3t b/test/test_suite14/statements/foreach_custom.c3t deleted file mode 100644 index 481036d1a..000000000 --- a/test/test_suite14/statements/foreach_custom.c3t +++ /dev/null @@ -1,94 +0,0 @@ -// #target: macos-x64 - -module test; -struct Foo -{ - int[] x; -} - -macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) -{ - return foo.x[index]; -} - -macro usz Foo.@operator_len(Foo &foo) @operator(len) -{ - return foo.x.len; -} - -fn void main() -{ - int[*] i = { 1, 3, 10 }; - Foo x = { &i }; - foreach FOO: (int f : x) { - printf("%d\n", f); - while (1) - { - break FOO; - } - } -} - -extern fn int printf(char *fmt, ...); - -/* #expect: test.ll - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %i = alloca [3 x i32], align 4 - %x = alloca %Foo, align 8 - %.anon = alloca i64, align 8 - %.anon1 = alloca i64, align 8 - %f = alloca i32, align 4 - %index = alloca i64, align 8 - %0 = bitcast [3 x i32]* %i to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %2 = bitcast [3 x i32]* %i to i32* - %3 = insertvalue %"int[]" undef, i32* %2, 0 - %4 = insertvalue %"int[]" %3, i64 3, 1 - store %"int[]" %4, %"int[]"* %1, align 8 - %5 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %6 = getelementptr inbounds %"int[]", %"int[]"* %5, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - store i64 %7, i64* %.anon, align 8 - store i64 0, i64* %.anon1, align 8 - br label %loop.cond - -loop.cond: ; preds = %entry - %8 = load i64, i64* %.anon1, align 8 - %9 = load i64, i64* %.anon, align 8 - %lt = icmp ult i64 %8, %9 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %10 = load i64, i64* %.anon1, align 8 - store i64 %10, i64* %index, align 8 - %11 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %12 = getelementptr inbounds %"int[]", %"int[]"* %11, i32 0, i32 0 - %13 = load i32*, i32** %12, align 8 - %14 = load i64, i64* %index, align 8 - %ptroffset = getelementptr inbounds i32, i32* %13, i64 %14 - %15 = load i32, i32* %ptroffset, align 4 - store i32 %15, i32* %f, align 4 - %16 = load i32, i32* %f, align 4 - %17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %16) - br label %loop.body2 - -loop.body2: ; preds = %loop.body - br label %loop.exit - -loop.exit: ; preds = %loop.body2, %loop.cond - ret void -} - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @test_main() - ret i32 0 -} diff --git a/test/test_suite14/statements/foreach_custom_errors.c3 b/test/test_suite14/statements/foreach_custom_errors.c3 deleted file mode 100644 index 127d0df9f..000000000 --- a/test/test_suite14/statements/foreach_custom_errors.c3 +++ /dev/null @@ -1,15 +0,0 @@ -fn void test1() -{ - int x; - foreach (a : x) { }; // #error: It's not possible to enumerate an expression of type 'int' -} - -define Test1 = distinct int; - -fn void test2() -{ - Test1 x; - foreach (a : x) { }; // #error: It's not possible to enumerate an expression of type 'Test1' -} - - diff --git a/test/test_suite14/statements/foreach_custom_macro.c3t b/test/test_suite14/statements/foreach_custom_macro.c3t deleted file mode 100644 index 449c9be9e..000000000 --- a/test/test_suite14/statements/foreach_custom_macro.c3t +++ /dev/null @@ -1,82 +0,0 @@ -// #target: macos-x64 -module foo; -struct Foo -{ - int[] x; -} - -macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) -{ - return foo.x[index]; -} - -macro usz Foo.@operator_len(Foo &foo) @operator(len) -{ - return foo.x.len; -} - -fn void main() -{ - int[*] i = { 1, 3, 10 }; - Foo x = { &i }; - foreach FOO: (int f : x) { - printf("%d\n", f); - while (1) - { - break FOO; - } - } -} - -extern fn int printf(char *fmt, ...); - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %i = alloca [3 x i32], align 4 - %x = alloca %Foo, align 8 - %.anon = alloca i64, align 8 - %.anon1 = alloca i64, align 8 - %f = alloca i32, align 4 - %index = alloca i64, align 8 - %0 = bitcast [3 x i32]* %i to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %2 = bitcast [3 x i32]* %i to i32* - %3 = insertvalue %"int[]" undef, i32* %2, 0 - %4 = insertvalue %"int[]" %3, i64 3, 1 - store %"int[]" %4, %"int[]"* %1, align 8 - %5 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %6 = getelementptr inbounds %"int[]", %"int[]"* %5, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - store i64 %7, i64* %.anon, align 8 - store i64 0, i64* %.anon1, align 8 - br label %loop.cond - -loop.cond: ; preds = %entry - %8 = load i64, i64* %.anon1, align 8 - %9 = load i64, i64* %.anon, align 8 - %lt = icmp ult i64 %8, %9 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %10 = load i64, i64* %.anon1, align 8 - store i64 %10, i64* %index, align 8 - %11 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %12 = getelementptr inbounds %"int[]", %"int[]"* %11, i32 0, i32 0 - %13 = load i32*, i32** %12, align 8 - %14 = load i64, i64* %index, align 8 - %ptroffset = getelementptr inbounds i32, i32* %13, i64 %14 - %15 = load i32, i32* %ptroffset, align 4 - store i32 %15, i32* %f, align 4 - %16 = load i32, i32* %f, align 4 - %17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %16) - br label %loop.body2 - -loop.body2: ; preds = %loop.body - br label %loop.exit - -loop.exit: ; preds = %loop.body2, %loop.cond - ret void -} diff --git a/test/test_suite14/statements/foreach_errors.c3 b/test/test_suite14/statements/foreach_errors.c3 deleted file mode 100644 index 1b07279d9..000000000 --- a/test/test_suite14/statements/foreach_errors.c3 +++ /dev/null @@ -1,54 +0,0 @@ -module test; - -extern fn void foo(); -int[3] z; - -fn void test1() -{ - int x; - foreach (a : x) // #error: It's not possible to enumerate an expression of type 'int'. - { - foo(); - } -} - -fn void test2() -{ - foreach (a : z) foo(); - foreach (i, a : z) foo(); - foreach (double i, a : z); // #error: Index must be an integer type, 'double' is not valid. -} - -fn void test3() -{ - foreach (&a : z) foo(); - foreach (&i, &a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'? -} - -fn void test4() -{ - foreach (&a : z) foo(); - foreach (&i, a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'? -} - -fn void test5() -{ - foreach (int! y : z) foo(); // #error: The variable may not be an optional. -} - -fn void test6() -{ - foreach (int! i, y : z) foo(); // #error: The index may not be an optional. -} - -fn void test7() -{ - foreach (int a : { 1, 2, 3 }) foo(); - foreach (a : { 1, 2, 3 }) foo(); // #error: Add the type of your variable here if you want to iterate over -} - -fn void test8() -{ - foreach (int a : { z }) foo(); // #error: 'int[3]' to 'int' -} - diff --git a/test/test_suite14/statements/foreach_more_implementations.c3t b/test/test_suite14/statements/foreach_more_implementations.c3t deleted file mode 100644 index 92b8bf26f..000000000 --- a/test/test_suite14/statements/foreach_more_implementations.c3t +++ /dev/null @@ -1,185 +0,0 @@ -// #target: macos-x64 -module test; - -import std::io; -struct Vector -{ - usz size; - int* elements; -} - -macro int Vector.get(Vector* vector, usz element) @operator([]) -{ - return vector.elements[element]; -} - -macro int* Vector.get_ref(Vector* vector, usz element) @operator(&[]) -{ - return &vector.elements[element]; -} - -macro usz Vector.size(Vector vector) @operator(len) { - return vector.size; -} - -fn void main() -{ - int[2] x = { 1, 2 }; - Vector v = { 2, &x }; - - foreach (int* &ref : v) - { - std::io::printf("%d\n", *ref); - *ref += 2; - } - foreach (int i : v) - { - std::io::printf("%d\n", i); - } -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %x = alloca [2 x i32], align 4 - %v = alloca %Vector, align 8 - %.anon = alloca i64, align 8 - %vector = alloca %Vector, align 8 - %.anon1 = alloca i64, align 8 - %ref = alloca i32*, align 8 - %vector2 = alloca %Vector*, align 8 - %element = alloca i64, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %.anon4 = alloca i64, align 8 - %vector5 = alloca %Vector, align 8 - %.anon6 = alloca i64, align 8 - %i = alloca i32, align 4 - %vector10 = alloca %Vector*, align 8 - %element11 = alloca i64, align 8 - %retparam13 = alloca i64, align 8 - %varargslots14 = alloca [1 x %variant], align 16 - %taddr15 = alloca %"variant[]", align 8 - %0 = bitcast [2 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([2 x i32]* @.__const to i8*), i32 8, i1 false) - %1 = getelementptr inbounds %Vector, %Vector* %v, i32 0, i32 0 - store i64 2, i64* %1, align 8 - %2 = getelementptr inbounds %Vector, %Vector* %v, i32 0, i32 1 - %ptrptr = bitcast [2 x i32]* %x to i32* - store i32* %ptrptr, i32** %2, align 8 - %3 = bitcast %Vector* %vector to i8* - %4 = bitcast %Vector* %v to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %3, i8* align 8 %4, i32 16, i1 false) - %5 = getelementptr inbounds %Vector, %Vector* %vector, i32 0, i32 0 - %6 = load i64, i64* %5, align 8 - store i64 %6, i64* %.anon, align 8 - store i64 0, i64* %.anon1, align 8 - br label %loop.cond - -loop.cond: ; preds = %voiderr, %entry - %7 = load i64, i64* %.anon1, align 8 - %8 = load i64, i64* %.anon, align 8 - %lt = icmp ult i64 %7, %8 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - store %Vector* %v, %Vector** %vector2, align 8 - %9 = load i64, i64* %.anon1, align 8 - store i64 %9, i64* %element, align 8 - %10 = load %Vector*, %Vector** %vector2, align 8 - %11 = getelementptr inbounds %Vector, %Vector* %10, i32 0, i32 1 - %12 = load i32*, i32** %11, align 8 - %13 = load i64, i64* %element, align 8 - %ptroffset = getelementptr inbounds i32, i32* %12, i64 %13 - store i32* %ptroffset, i32** %ref, align 8 - %14 = load i32*, i32** %ref, align 8 - %15 = bitcast i32* %14 to i8* - %16 = insertvalue %variant undef, i8* %15, 0 - %17 = insertvalue %variant %16, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %18 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %17, %variant* %18, align 16 - %19 = bitcast [1 x %variant]* %varargslots to %variant* - %20 = insertvalue %"variant[]" undef, %variant* %19, 0 - %21 = insertvalue %"variant[]" %20, i64 1, 1 - store %"variant[]" %21, %"variant[]"* %taddr, align 8 - %22 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %23 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %22, i32 0, i32 0 - %lo = load i8*, i8** %23, align 8 - %24 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %22, i32 0, i32 1 - %hi = load i64, i64* %24, align 8 - %25 = call i64 @std_io_printf(i64* %retparam, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %25, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %loop.body - br label %voiderr - -voiderr: ; preds = %after_check, %loop.body - %26 = load i32*, i32** %ref, align 8 - %27 = load i32, i32* %26, align 4 - %add = add i32 %27, 2 - store i32 %add, i32* %26, align 4 - %28 = load i64, i64* %.anon1, align 8 - %add3 = add i64 %28, 1 - store i64 %add3, i64* %.anon1, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %29 = bitcast %Vector* %vector5 to i8* - %30 = bitcast %Vector* %v to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %29, i8* align 8 %30, i32 16, i1 false) - %31 = getelementptr inbounds %Vector, %Vector* %vector5, i32 0, i32 0 - %32 = load i64, i64* %31, align 8 - store i64 %32, i64* %.anon4, align 8 - store i64 0, i64* %.anon6, align 8 - br label %loop.cond7 - -loop.cond7: ; preds = %voiderr20, %loop.exit - %33 = load i64, i64* %.anon6, align 8 - %34 = load i64, i64* %.anon4, align 8 - %lt8 = icmp ult i64 %33, %34 - br i1 %lt8, label %loop.body9, label %loop.exit22 - -loop.body9: ; preds = %loop.cond7 - store %Vector* %v, %Vector** %vector10, align 8 - %35 = load i64, i64* %.anon6, align 8 - store i64 %35, i64* %element11, align 8 - %36 = load %Vector*, %Vector** %vector10, align 8 - %37 = getelementptr inbounds %Vector, %Vector* %36, i32 0, i32 1 - %38 = load i32*, i32** %37, align 8 - %39 = load i64, i64* %element11, align 8 - %ptroffset12 = getelementptr inbounds i32, i32* %38, i64 %39 - %40 = load i32, i32* %ptroffset12, align 4 - store i32 %40, i32* %i, align 4 - %41 = bitcast i32* %i to i8* - %42 = insertvalue %variant undef, i8* %41, 0 - %43 = insertvalue %variant %42, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %44 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots14, i64 0, i64 0 - store %variant %43, %variant* %44, align 16 - %45 = bitcast [1 x %variant]* %varargslots14 to %variant* - %46 = insertvalue %"variant[]" undef, %variant* %45, 0 - %47 = insertvalue %"variant[]" %46, i64 1, 1 - store %"variant[]" %47, %"variant[]"* %taddr15, align 8 - %48 = bitcast %"variant[]"* %taddr15 to { i8*, i64 }* - %49 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %48, i32 0, i32 0 - %lo16 = load i8*, i8** %49, align 8 - %50 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %48, i32 0, i32 1 - %hi17 = load i64, i64* %50, align 8 - %51 = call i64 @std_io_printf(i64* %retparam13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i64 3, i8* %lo16, i64 %hi17) - %not_err18 = icmp eq i64 %51, 0 - br i1 %not_err18, label %after_check19, label %voiderr20 - -after_check19: ; preds = %loop.body9 - br label %voiderr20 - -voiderr20: ; preds = %after_check19, %loop.body9 - %52 = load i64, i64* %.anon6, align 8 - %add21 = add i64 %52, 1 - store i64 %add21, i64* %.anon6, align 8 - br label %loop.cond7 - -loop.exit22: ; preds = %loop.cond7 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/foreach_parse_error.c3 b/test/test_suite14/statements/foreach_parse_error.c3 deleted file mode 100644 index 4a761601a..000000000 --- a/test/test_suite14/statements/foreach_parse_error.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test9() -{ - foreach (int a : { [2] = 1 }) foo(); - foreach (int a : { [2] = 2, 1 }) foo(); // #error: Normal initialization cannot be mixed with designated initialization. -} \ No newline at end of file diff --git a/test/test_suite14/statements/foreach_r_break.c3t b/test/test_suite14/statements/foreach_r_break.c3t deleted file mode 100644 index 7254b5908..000000000 --- a/test/test_suite14/statements/foreach_r_break.c3t +++ /dev/null @@ -1,72 +0,0 @@ -// #target: macos-x64 -module test; - -fn void test() -{ - int[3] x; - int g = 0; - foreach_r (z : x) - { - if (z > 0) break; - if (z == 1) continue; - g += z; - } -} - -/* #expect: test.ll - -; Function Attrs: nounwind -define void @test_test() #0 { -entry: - %x = alloca [3 x i32], align 4 - %g = alloca i32, align 4 - %.anon = alloca i64, align 8 - %z = alloca i32, align 4 - %0 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 0 - store i32 0, i32* %0, align 4 - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - store i32 0, i32* %1, align 4 - %2 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 2 - store i32 0, i32* %2, align 4 - store i32 0, i32* %g, align 4 - store i64 3, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %if.exit3, %if.then2, %entry - %3 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 %3, 0 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %4 = load i64, i64* %.anon, align 8 - %sub = sub i64 %4, 1 - store i64 %sub, i64* %.anon, align 8 - %5 = load i64, i64* %.anon, align 8 - %6 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 %5 - %7 = load i32, i32* %6, align 4 - store i32 %7, i32* %z, align 4 - %8 = load i32, i32* %z, align 4 - %gt1 = icmp sgt i32 %8, 0 - br i1 %gt1, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - br label %loop.exit - -if.exit: ; preds = %loop.body - %9 = load i32, i32* %z, align 4 - %eq = icmp eq i32 %9, 1 - br i1 %eq, label %if.then2, label %if.exit3 - -if.then2: ; preds = %if.exit - br label %loop.cond - -if.exit3: ; preds = %if.exit - %10 = load i32, i32* %g, align 4 - %11 = load i32, i32* %z, align 4 - %add = add i32 %10, %11 - store i32 %add, i32* %g, align 4 - br label %loop.cond - -loop.exit: ; preds = %if.then, %loop.cond - ret void -} diff --git a/test/test_suite14/statements/foreach_r_common.c3t b/test/test_suite14/statements/foreach_r_common.c3t deleted file mode 100644 index 46bc068e7..000000000 --- a/test/test_suite14/statements/foreach_r_common.c3t +++ /dev/null @@ -1,112 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn void printf(char*, ...); - -fn void main() -{ - float[3] foo = { 2, 4.5, 8 }; - float[<3>] foo2 = { 2, 4.5, 8 }; - foreach_r (a : foo) - { - printf("Value: %f\n", a); - } - foreach_r (float* &a : foo) - { - *a *= 2; - printf("Value: %f\n", *a); - } - foreach_r (void* &a : foo) - { - printf("Value: %f\n", *((float*)(a))); - } - foreach_r (i, a : foo) - { - printf("Value[%d]: %f\n", i, a); - } - foreach_r (char i, double a : foo) - { - printf("Value2[%d]: %f\n", i, a); - } - foreach_r (double a : foo) - { - printf("Value3: %f\n", a); - } - - foreach_r (a : foo2) - { - printf("Value: %f\n", a); - } - foreach_r (float* &a : foo2) - { - *a *= 2; - printf("Value: %f\n", *a); - } - foreach_r (i, a : foo2) - { - printf("Value[%d]: %f\n", i, a); - } - foreach_r (char i, double a : foo2) - { - printf("Value2[%d]: %f\n", i, a); - } - foreach_r (double a : foo2) - { - printf("Value3: %f\n", a); - } -} - -/* #expect: test.ll - -entry: - %foo = alloca [3 x float], align 4 - %foo2 = alloca <3 x float>, align 16 - %.anon = alloca i64, align 8 - %a = alloca float, align 4 - %.anon1 = alloca i64, align 8 - %a6 = alloca float*, align 8 - %.anon9 = alloca i64, align 8 - %a14 = alloca i8*, align 8 - %.anon18 = alloca i64, align 8 - %66 = load i64, i64* %.anon69, align 8 - %sub73 = sub i64 %66, 1 - store i64 %sub73, i64* %.anon69, align 8 - %67 = load i64, i64* %.anon69, align 8 - %ztrunc75 = trunc i64 %67 to i8 - store i8 %ztrunc75, i8* %i74, align 1 - %68 = load <3 x float>, <3 x float>* %foo2, align 16 - %69 = load i64, i64* %.anon69, align 8 - %70 = extractelement <3 x float> %68, i64 %69 - %fpfpext77 = fpext float %70 to double - store double %fpfpext77, double* %a76, align 8 - %71 = load i8, i8* %i74, align 1 - %uisiext78 = zext i8 %71 to i32 - %72 = load double, double* %a76, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i32 0, i32 0), i32 %uisiext78, double %72) - br label %loop.cond70 - -loop.exit79: ; preds = %loop.cond70 - store i64 3, i64* %.anon80, align 8 - br label %loop.cond81 - -loop.cond81: ; preds = %loop.body83, %loop.exit79 - %73 = load i64, i64* %.anon80, align 8 - %gt82 = icmp ugt i64 %73, 0 - br i1 %gt82, label %loop.body83, label %loop.exit87 - -loop.body83: ; preds = %loop.cond81 - %74 = load i64, i64* %.anon80, align 8 - %sub84 = sub i64 %74, 1 - store i64 %sub84, i64* %.anon80, align 8 - %75 = load <3 x float>, <3 x float>* %foo2, align 16 - %76 = load i64, i64* %.anon80, align 8 - %77 = extractelement <3 x float> %75, i64 %76 - %fpfpext86 = fpext float %77 to double - store double %fpfpext86, double* %a85, align 8 - %78 = load double, double* %a85, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), double %78) - br label %loop.cond81 - -loop.exit87: ; preds = %loop.cond81 - ret void -} diff --git a/test/test_suite14/statements/foreach_r_custom.c3t b/test/test_suite14/statements/foreach_r_custom.c3t deleted file mode 100644 index 646ae4287..000000000 --- a/test/test_suite14/statements/foreach_r_custom.c3t +++ /dev/null @@ -1,94 +0,0 @@ -// #target: macos-x64 - -module test; -struct Foo -{ - int[] x; -} - -macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) -{ - return foo.x[index]; -} - -macro usz Foo.@operator_len(Foo &foo) @operator(len) -{ - return foo.x.len; -} - -fn void main() -{ - int[*] i = { 1, 3, 10 }; - Foo x = { &i }; - foreach_r FOO: (int f : x) { - printf("%d\n", f); - while (1) - { - break FOO; - } - } -} - -extern fn int printf(char *fmt, ...); - -/* #expect: test.ll - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %i = alloca [3 x i32], align 4 - %x = alloca %Foo, align 8 - %.anon = alloca i64, align 8 - %f = alloca i32, align 4 - %index = alloca i64, align 8 - %0 = bitcast [3 x i32]* %i to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %2 = bitcast [3 x i32]* %i to i32* - %3 = insertvalue %"int[]" undef, i32* %2, 0 - %4 = insertvalue %"int[]" %3, i64 3, 1 - store %"int[]" %4, %"int[]"* %1, align 8 - %5 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %6 = getelementptr inbounds %"int[]", %"int[]"* %5, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - store i64 %7, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %entry - %8 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 %8, 0 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %9 = load i64, i64* %.anon, align 8 - %sub = sub i64 %9, 1 - store i64 %sub, i64* %.anon, align 8 - %10 = load i64, i64* %.anon, align 8 - store i64 %10, i64* %index, align 8 - %11 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %12 = getelementptr inbounds %"int[]", %"int[]"* %11, i32 0, i32 0 - %13 = load i32*, i32** %12, align 8 - %14 = load i64, i64* %index, align 8 - %ptroffset = getelementptr inbounds i32, i32* %13, i64 %14 - %15 = load i32, i32* %ptroffset, align 4 - store i32 %15, i32* %f, align 4 - %16 = load i32, i32* %f, align 4 - %17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %16) - br label %loop.body1 - -loop.body1: ; preds = %loop.body - br label %loop.exit - -loop.exit: ; preds = %loop.body1, %loop.cond - ret void -} - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @test_main() - ret i32 0 -} diff --git a/test/test_suite14/statements/foreach_r_custom_errors.c3 b/test/test_suite14/statements/foreach_r_custom_errors.c3 deleted file mode 100644 index 81d59d474..000000000 --- a/test/test_suite14/statements/foreach_r_custom_errors.c3 +++ /dev/null @@ -1,15 +0,0 @@ -fn void test1() -{ - int x; - foreach_r (a : x) { }; // #error: It's not possible to enumerate an expression of type 'int' -} - -define Test1 = distinct int; - -fn void test2() -{ - Test1 x; - foreach_r (a : x) { }; // #error: It's not possible to enumerate an expression of type 'Test1' -} - - diff --git a/test/test_suite14/statements/foreach_r_custom_macro.c3t b/test/test_suite14/statements/foreach_r_custom_macro.c3t deleted file mode 100644 index 72bd73583..000000000 --- a/test/test_suite14/statements/foreach_r_custom_macro.c3t +++ /dev/null @@ -1,93 +0,0 @@ -// #target: macos-x64 -module test; -struct Foo -{ - int[] x; -} - -macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) -{ - return foo.x[index]; -} - -macro usz Foo.@operator_len(Foo &foo) @operator(len) -{ - return foo.x.len; -} - -fn void main() -{ - int[*] i = { 1, 3, 10 }; - Foo x = { &i }; - foreach_r FOO: (int f : x) { - printf("%d\n", f); - while (1) - { - break FOO; - } - } -} - -extern fn int printf(char *fmt, ...); - -/* #expect: test.ll - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %i = alloca [3 x i32], align 4 - %x = alloca %Foo, align 8 - %.anon = alloca i64, align 8 - %f = alloca i32, align 4 - %index = alloca i64, align 8 - %0 = bitcast [3 x i32]* %i to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %2 = bitcast [3 x i32]* %i to i32* - %3 = insertvalue %"int[]" undef, i32* %2, 0 - %4 = insertvalue %"int[]" %3, i64 3, 1 - store %"int[]" %4, %"int[]"* %1, align 8 - %5 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %6 = getelementptr inbounds %"int[]", %"int[]"* %5, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - store i64 %7, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %entry - %8 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 %8, 0 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %9 = load i64, i64* %.anon, align 8 - %sub = sub i64 %9, 1 - store i64 %sub, i64* %.anon, align 8 - %10 = load i64, i64* %.anon, align 8 - store i64 %10, i64* %index, align 8 - %11 = getelementptr inbounds %Foo, %Foo* %x, i32 0, i32 0 - %12 = getelementptr inbounds %"int[]", %"int[]"* %11, i32 0, i32 0 - %13 = load i32*, i32** %12, align 8 - %14 = load i64, i64* %index, align 8 - %ptroffset = getelementptr inbounds i32, i32* %13, i64 %14 - %15 = load i32, i32* %ptroffset, align 4 - store i32 %15, i32* %f, align 4 - %16 = load i32, i32* %f, align 4 - %17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %16) - br label %loop.body1 - -loop.body1: ; preds = %loop.body - br label %loop.exit - -loop.exit: ; preds = %loop.body1, %loop.cond - ret void -} - -; Function Attrs: nounwind -declare i32 @printf(i8*, ...) #0 - -; Function Attrs: nounwind -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @test_main() - ret i32 0 -} diff --git a/test/test_suite14/statements/foreach_r_errors.c3 b/test/test_suite14/statements/foreach_r_errors.c3 deleted file mode 100644 index 490a8ba06..000000000 --- a/test/test_suite14/statements/foreach_r_errors.c3 +++ /dev/null @@ -1,54 +0,0 @@ -module test; - -extern fn void foo(); -int[3] z; - -fn void test1() -{ - int x; - foreach_r (a : x) // #error: It's not possible to enumerate an expression of type 'int'. - { - foo(); - } -} - -fn void test2() -{ - foreach_r (a : z) foo(); - foreach_r (i, a : z) foo(); - foreach_r (double i, a : z); // #error: Index must be an integer type, 'double' is not valid. -} - -fn void test3() -{ - foreach_r (&a : z) foo(); - foreach_r (&i, &a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'? -} - -fn void test4() -{ - foreach_r (&a : z) foo(); - foreach_r (&i, a : z) foo(); // #error: The index cannot be held by reference, did you accidentally add a '&'? -} - -fn void test5() -{ - foreach_r (int! y : z) foo(); // #error: The variable may not be an optional. -} - -fn void test6() -{ - foreach_r (int! i, y : z) foo(); // #error: The index may not be an optional. -} - -fn void test7() -{ - foreach_r (int a : { 1, 2, 3 }) foo(); - foreach_r (a : { 1, 2, 3 }) foo(); // #error: Add the type of your variable here if you want to iterate over -} - -fn void test8() -{ - foreach_r (int a : { z }) foo(); // #error: 'int[3]' to 'int' -} - diff --git a/test/test_suite14/statements/foreach_r_parse_error.c3 b/test/test_suite14/statements/foreach_r_parse_error.c3 deleted file mode 100644 index a7a00b965..000000000 --- a/test/test_suite14/statements/foreach_r_parse_error.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn void test9() -{ - foreach_r (int a : { [2] = 1 }) foo(); - foreach_r (int a : { [2] = 2, 1 }) foo(); // #error: Normal initialization cannot be mixed with designated initialization. -} \ No newline at end of file diff --git a/test/test_suite14/statements/foreach_r_with_error.c3 b/test/test_suite14/statements/foreach_r_with_error.c3 deleted file mode 100644 index cbed085c8..000000000 --- a/test/test_suite14/statements/foreach_r_with_error.c3 +++ /dev/null @@ -1,12 +0,0 @@ -module test; - -fn void test() -{ - int[3]! x; - int g; - foreach_r (z : x) // #error: The expression may not be optional. - { - g += z; - x[0] = 1; - } -} diff --git a/test/test_suite14/statements/foreach_with_error.c3 b/test/test_suite14/statements/foreach_with_error.c3 deleted file mode 100644 index 4737c8b9d..000000000 --- a/test/test_suite14/statements/foreach_with_error.c3 +++ /dev/null @@ -1,12 +0,0 @@ -module test; - -fn void test() -{ - int[3]! x; - int g; - foreach (z : x) // #error: The expression may not be optional. - { - g += z; - x[0] = 1; - } -} diff --git a/test/test_suite14/statements/foreach_wrong_index.c3 b/test/test_suite14/statements/foreach_wrong_index.c3 deleted file mode 100644 index 67f1580b3..000000000 --- a/test/test_suite14/statements/foreach_wrong_index.c3 +++ /dev/null @@ -1,27 +0,0 @@ -import std::io; - -struct Foo -{ - int[3] elements; -} - -fn int Foo.at(Foo *vector, float index) @operator([]) -{ - return 1; -} - -fn int Foo.len(Foo *vector) @operator(len) -{ - return 3; -} - -fn void main() -{ - - Foo f; - io::printfn("%s", f[12.2]); - foreach (int i, value : f) // #error: Only integer - { - io::printfn("v[%s] = %s", i, value); - } -} \ No newline at end of file diff --git a/test/test_suite14/statements/if_decl.c3 b/test/test_suite14/statements/if_decl.c3 deleted file mode 100644 index ad245ec61..000000000 --- a/test/test_suite14/statements/if_decl.c3 +++ /dev/null @@ -1,5 +0,0 @@ -fn int main() -{ - if (int a) {} // #error: Expected a declaration with initializer - return 0; -} diff --git a/test/test_suite14/statements/if_single.c3 b/test/test_suite14/statements/if_single.c3 deleted file mode 100644 index 94ae517ca..000000000 --- a/test/test_suite14/statements/if_single.c3 +++ /dev/null @@ -1,29 +0,0 @@ -fn void test() -{ - int x = 0; - if (x < 0) x++; - if (x < - 0) x++; - if (x < 0 - && x < 0) x++; - - - if (x < 0) x++; // #error: if-statements with an 'else' must use '{ }' even around a single statement. - else { x++; }; - - if (x < 0) - { - x++; - } - else x++; // #error: An 'else' must use '{ }' even around a single statement. - - if (x < 0) - { - x++; - } - else if (x > 0) - { - x++; - } - -} \ No newline at end of file diff --git a/test/test_suite14/statements/if_tests.c3t b/test/test_suite14/statements/if_tests.c3t deleted file mode 100644 index 153203ad7..000000000 --- a/test/test_suite14/statements/if_tests.c3t +++ /dev/null @@ -1,71 +0,0 @@ -module iftest; - -fn void test1(int x) -{ - if (x > 0) - { - defer x += 1; - } - else - {} -} - -fn void test2(int x) -{ - if (x > 0) - { - } - else - {} -} - -fn void test3(int x) -{ - if (x > 0) - {} - else { x += 1; } -} - -// #expect: iftest.ll - -define void @iftest_test1(i32 %0) #0 { -entry: - %x = alloca i32, align 4 - store i32 %0, i32* %x, align 4 - %1 = load i32, i32* %x, align 4 - %gt = icmp sgt i32 %1, 0 - br i1 %gt, label %if.then, label %if.exit - -if.then: ; preds = %entry - %2 = load i32, i32* %x, align 4 - %add = add i32 %2, 1 - store i32 %add, i32* %x, align 4 - br label %if.exit - -if.exit: ; preds = %if.then, %entry - ret void -} - -define void @iftest_test2(i32 %0) #0 { -entry: - %gt = icmp sgt i32 %0, 0 - ret void -} - -define void @iftest_test3(i32 %0) #0 { -entry: - %x = alloca i32, align 4 - store i32 %0, i32* %x, align 4 - %1 = load i32, i32* %x, align 4 - %gt = icmp sgt i32 %1, 0 - br i1 %gt, label %if.exit, label %if.else - -if.else: ; preds = %entry - %2 = load i32, i32* %x, align 4 - %add = add i32 %2, 1 - store i32 %add, i32* %x, align 4 - br label %if.exit - -if.exit: ; preds = %if.else, %entry - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/if_while_do_error.c3 b/test/test_suite14/statements/if_while_do_error.c3 deleted file mode 100644 index 3658e1d8b..000000000 --- a/test/test_suite14/statements/if_while_do_error.c3 +++ /dev/null @@ -1,34 +0,0 @@ -module test; - -fn void test1() -{ - bool! x = false; - if (x) // #error: optional, but was 'bool! - { - x = 100; - } -} - -fn void test2() -{ - bool! x = false; - while (x) // #error: optional, but was 'bool! - { - x = false; - } -} - -fn void test3() -{ - bool! x = false; - double y = 1; - do - { - y = y + 1; - } while (y); - do - { - x = !x; - } - while (x); // #error: 'bool!' cannot be implicitly converted to a regular boolean value -} \ No newline at end of file diff --git a/test/test_suite14/statements/infinite_do_while.c3t b/test/test_suite14/statements/infinite_do_while.c3t deleted file mode 100644 index 9b461e87b..000000000 --- a/test/test_suite14/statements/infinite_do_while.c3t +++ /dev/null @@ -1,45 +0,0 @@ -// #target: macos-x64 -module test; -int x; -fn void test1() -{ - while (true) { - testx(); - } -} -fn void test2() -{ - do { - testx(); - } while (true); -} -fn void testx() {} - -fn void main() -{} - -/* #expect: test.ll - -define void @test_test1() #0 { -entry: - br label %loop.body - -loop.body: ; preds = %loop.body, %entry - call void @test_testx() - br label %loop.body - -loop.exit: ; No predecessors! - ret void -} - -define void @test_test2() #0 { -entry: - br label %loop.body - -loop.body: ; preds = %loop.body, %entry - call void @test_testx() - br label %loop.body - -loop.exit: ; No predecessors! - ret void -} diff --git a/test/test_suite14/statements/label_errors.c3 b/test/test_suite14/statements/label_errors.c3 deleted file mode 100644 index 792363085..000000000 --- a/test/test_suite14/statements/label_errors.c3 +++ /dev/null @@ -1,24 +0,0 @@ - -fn int main() -{ - do FOO: - { - while FOO: (1) // #error: would shadow a previous declaration - { - return 1; - } - }; - return 0; -} - - -fn void test1() -{ - do FOO: - { - while (1) - { - break BAR; // #error: A labelled statement with the name 'BAR' can't be found in the current scope - } - }; -} \ No newline at end of file diff --git a/test/test_suite14/statements/labelled_continue_for.c3t b/test/test_suite14/statements/labelled_continue_for.c3t deleted file mode 100644 index 5ceb5be9b..000000000 --- a/test/test_suite14/statements/labelled_continue_for.c3t +++ /dev/null @@ -1,71 +0,0 @@ -// #target: macos-x64 -fn void errored() -{} - -fn void test() {} - -fn void testBreak() -{ - for FOO: (int i = 0; i < 10; i++) - { - for (int j = 0; j < 10; j++) - { - for BAR: (int k = 0; k < 10; k++) - { - test(); - continue FOO; - } - errored(); - } - errored(); - } -} - -/* #expect: labelled_continue_for.ll - - -define void @labelled_continue_for_testBreak() #0 { -entry: - %i = alloca i32, align 4 - %j = alloca i32, align 4 - %k = alloca i32, align 4 - store i32 0, i32* %i, align 4 - br label %loop.cond -loop.cond: ; preds = %loop.inc, %entry - %0 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %0, 10 - br i1 %lt, label %loop.body, label %loop.exit9 -loop.body: ; preds = %loop.cond - store i32 0, i32* %j, align 4 - br label %loop.cond1 -loop.cond1: ; preds = %loop.exit, %loop.body - %1 = load i32, i32* %j, align 4 - %lt2 = icmp slt i32 %1, 10 - br i1 %lt2, label %loop.body3, label %loop.exit7 -loop.body3: ; preds = %loop.cond1 - store i32 0, i32* %k, align 4 - br label %loop.cond4 -loop.cond4: ; preds = %loop.body3 - %2 = load i32, i32* %k, align 4 - %lt5 = icmp slt i32 %2, 10 - br i1 %lt5, label %loop.body6, label %loop.exit -loop.body6: ; preds = %loop.cond4 - call void @labelled_continue_for_test() - br label %loop.inc -loop.exit: ; preds = %loop.cond4 - call void @labelled_continue_for_errored() - %3 = load i32, i32* %j, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %j, align 4 - br label %loop.cond1 -loop.exit7: ; preds = %loop.cond1 - call void @labelled_continue_for_errored() - br label %loop.inc -loop.inc: ; preds = %loop.exit7, %loop.body6 - %4 = load i32, i32* %i, align 4 - %add8 = add i32 %4, 1 - store i32 %add8, i32* %i, align 4 - br label %loop.cond -loop.exit9: ; preds = %loop.cond - ret void -} diff --git a/test/test_suite14/statements/nextcase_no_switch.c3 b/test/test_suite14/statements/nextcase_no_switch.c3 deleted file mode 100644 index 945851159..000000000 --- a/test/test_suite14/statements/nextcase_no_switch.c3 +++ /dev/null @@ -1,31 +0,0 @@ -module test; -fn void foo() -{ - nextcase 3; // #error: No matching switch could be found -} - -fn int foo2(double b, int x) -{ - switch (x) - { - case 1: - nextcase 2; - case 2: - break; - case 3: - defer { nextcase 2; } // #error: No matching switch could be found - } - return 1; -} - -fn int foo3(double b, int x) -{ - switch FOO: (x) - { - case 2: - break; - case 3: - {| nextcase FOO: 2; |}; // #error: You cannot use nextcase to exit - } - return 1; -} \ No newline at end of file diff --git a/test/test_suite14/statements/ranged_switch.c3t b/test/test_suite14/statements/ranged_switch.c3t deleted file mode 100644 index 4b36be425..000000000 --- a/test/test_suite14/statements/ranged_switch.c3t +++ /dev/null @@ -1,202 +0,0 @@ -// #target: macos-x64 - -module foo; - -extern fn void printf(char*, ...); - -fn void main() -{ - for (int i = 0; i < 12; i++) - { - switch (i) - { - case 1 .. 3: - printf("1-3\n"); - case 7 .. 277: - printf("7-277 %d\n", i); - case 4 .. 5: - printf("4-5 %d\n", i); - case 6: - printf("6 %d\n", i); - default: - printf("Something else: %d\n", i); - nextcase 5; - } - } - for (int i = 0; i < 12; i++) - { - switch (i) - { - case 1 .. 3: - printf("1-3\n"); - case 4 .. 6: - printf("4-6 %d\n", i); - default: - printf("Something else: %d\n", i); - nextcase 5; - } - } - bool x = false; - switch (x) - { - case true: - printf("Was true!\n"); - case false: - printf("Was false!\n"); - } -} - -/* #expect: foo.ll - -define void @foo_main() #0 { -entry: - %i = alloca i32, align 4 - %switch = alloca i32, align 4 - %i11 = alloca i32, align 4 - %switch15 = alloca i32, align 4 - %x = alloca i8, align 1 - %switch23 = alloca i8, align 1 - store i32 0, i32* %i, align 4 - br label %loop.cond - -loop.cond: ; preds = %switch.exit, %entry - %0 = load i32, i32* %i, align 4 - %lt = icmp slt i32 %0, 12 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %1 = load i32, i32* %i, align 4 - store i32 %1, i32* %switch, align 4 - br label %switch.entry - -switch.entry: ; preds = %loop.body - %2 = load i32, i32* %switch, align 4 - %le = icmp sle i32 1, %2 - %ge = icmp sge i32 3, %2 - %3 = and i1 %le, %ge - br i1 %3, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0)) - br label %switch.exit - -next_if: ; preds = %switch.entry - %le1 = icmp sle i32 7, %2 - %ge2 = icmp sge i32 277, %2 - %4 = and i1 %le1, %ge2 - br i1 %4, label %switch.case3, label %next_if4 - -switch.case3: ; preds = %next_if - %5 = load i32, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 %5) - br label %switch.exit - -next_if4: ; preds = %next_if - %le5 = icmp sle i32 4, %2 - %ge6 = icmp sge i32 5, %2 - %6 = and i1 %le5, %ge6 - br i1 %6, label %switch.case7, label %next_if8 - -switch.case7: ; preds = %switch.default, %next_if4 - %7 = load i32, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i32 %7) - br label %switch.exit - -next_if8: ; preds = %next_if4 - %eq = icmp eq i32 6, %2 - br i1 %eq, label %switch.case9, label %next_if10 - -switch.case9: ; preds = %next_if8 - %8 = load i32, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i32 %8) - br label %switch.exit - -next_if10: ; preds = %next_if8 - br label %switch.default - -switch.default: ; preds = %next_if10 - %9 = load i32, i32* %i, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i32 0, i32 0), i32 %9) - br label %switch.case7 - -switch.exit: ; preds = %switch.case9, %switch.case7, %switch.case3, %switch.case - %10 = load i32, i32* %i, align 4 - %add = add i32 %10, 1 - store i32 %add, i32* %i, align 4 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - store i32 0, i32* %i11, align 4 - br label %loop.cond12 - -loop.cond12: ; preds = %switch.exit20, %loop.exit - %11 = load i32, i32* %i11, align 4 - %lt13 = icmp slt i32 %11, 12 - br i1 %lt13, label %loop.body14, label %loop.exit22 - -loop.body14: ; preds = %loop.cond12 - %12 = load i32, i32* %i11, align 4 - store i32 %12, i32* %switch15, align 4 - br label %switch.entry16 - -switch.entry16: ; preds = %loop.body14 - %13 = load i32, i32* %switch15, align 4 - switch i32 %13, label %switch.default19 [ - i32 1, label %switch.case17 - i32 2, label %switch.case17 - i32 3, label %switch.case17 - i32 4, label %switch.case18 - i32 5, label %switch.case18 - i32 6, label %switch.case18 - ] - -switch.case17: ; preds = %switch.entry16, %switch.entry16, %switch.entry16 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0)) - br label %switch.exit20 - -switch.case18: ; preds = %switch.default19, %switch.entry16, %switch.entry16, %switch.entry16 - %14 = load i32, i32* %i11, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i32 %14) - br label %switch.exit20 - -switch.default19: ; preds = %switch.entry16 - %15 = load i32, i32* %i11, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i32 0, i32 0), i32 %15) - br label %switch.case18 - -switch.exit20: ; preds = %switch.case18, %switch.case17 - %16 = load i32, i32* %i11, align 4 - %add21 = add i32 %16, 1 - store i32 %add21, i32* %i11, align 4 - br label %loop.cond12 - -loop.exit22: ; preds = %loop.cond12 - store i8 0, i8* %x, align 1 - %17 = load i8, i8* %x, align 1 - store i8 %17, i8* %switch23, align 1 - br label %switch.entry24 - -switch.entry24: ; preds = %loop.exit22 - %18 = load i8, i8* %switch23, align 1 - %19 = trunc i8 %18 to i1 - %eq25 = icmp eq i1 true, %19 - br i1 %eq25, label %switch.case26, label %next_if27 - -switch.case26: ; preds = %switch.entry24 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i32 0, i32 0)) - br label %switch.exit31 - -next_if27: ; preds = %switch.entry24 - %eq28 = icmp eq i1 false, %19 - br i1 %eq28, label %switch.case29, label %next_if30 - -switch.case29: ; preds = %next_if27 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i32 0, i32 0)) - br label %switch.exit31 - -next_if30: ; preds = %next_if27 - br label %switch.exit31 - -switch.exit31: ; preds = %next_if30, %switch.case29, %switch.case26 - ret void -} diff --git a/test/test_suite14/statements/return_stmt.c3 b/test/test_suite14/statements/return_stmt.c3 deleted file mode 100644 index 51da39f94..000000000 --- a/test/test_suite14/statements/return_stmt.c3 +++ /dev/null @@ -1,11 +0,0 @@ -fn void testNoReturn() -{ - int i = 0; - i = -i; -} - -fn int testReturn() -{ - int i = 0; - return i; -} \ No newline at end of file diff --git a/test/test_suite14/statements/return_switch.c3t b/test/test_suite14/statements/return_switch.c3t deleted file mode 100644 index 40b43ea6b..000000000 --- a/test/test_suite14/statements/return_switch.c3t +++ /dev/null @@ -1,36 +0,0 @@ -fn int testReturnSwitch() -{ - int i = 0; - switch (i) - { - case 0: - case 3: - case 1: - return 2; - case 2: - return 3; - default: - return 4; - } -} - -// #expect: return_switch.ll - -switch.entry: - %1 = load i32, i32* %switch - switch i32 %1, label %switch.default [ - i32 0, label %switch.case - i32 3, label %switch.case - i32 1, label %switch.case - i32 2, label %switch.case1 - ] - -switch.case: - ret i32 2 - -switch.case1: - ret i32 3 - -switch.default: - ret i32 4 -} \ No newline at end of file diff --git a/test/test_suite14/statements/return_with_other_at_end.c3 b/test/test_suite14/statements/return_with_other_at_end.c3 deleted file mode 100644 index 09c6384e6..000000000 --- a/test/test_suite14/statements/return_with_other_at_end.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn int testReturnWithOtherAtEnd() -{ - int i = 0; - return i; - if (i == 10) i++; - i = i + 2; -} diff --git a/test/test_suite14/statements/simple_do.c3t b/test/test_suite14/statements/simple_do.c3t deleted file mode 100644 index 132605831..000000000 --- a/test/test_suite14/statements/simple_do.c3t +++ /dev/null @@ -1,84 +0,0 @@ -// #target: macos-x64 - -module foo; -fn int test() -{ - static int x = 0; - return 1 + x++; -} - -extern fn void printf(char*, ...); - -fn void main() -{ - int i = 10; - do - { - printf("%d\n", test()); - if (i > 100) break; - } while (i-- > 0); - i = 1; - do - { - printf("%d, %d\n", i, test()); - if (i % 3 == 0) break; - } while (i++ < 100); -} - -// #expect: foo.ll - -define void @foo_main() #0 { -entry: - %i = alloca i32, align 4 - store i32 10, i32* %i, align 4 - br label %loop.body - -loop.cond: ; preds = %if.exit - %0 = load i32, i32* %i, align 4 - %sub = sub i32 %0, 1 - store i32 %sub, i32* %i, align 4 - %gt = icmp sgt i32 %0, 0 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond, %entry - %1 = call i32 @foo_test() - call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %1) - %2 = load i32, i32* %i, align 4 - %gt1 = icmp sgt i32 %2, 100 - br i1 %gt1, label %if.then, label %if.exit - -if.then: ; preds = %loop.body - br label %loop.exit - -if.exit: ; preds = %loop.body - br label %loop.cond - -loop.exit: ; preds = %if.then, %loop.cond - store i32 1, i32* %i, align 4 - br label %loop.body3 - -loop.cond2: ; preds = %if.exit5 - %3 = load i32, i32* %i, align 4 - %add = add i32 %3, 1 - store i32 %add, i32* %i, align 4 - %lt = icmp slt i32 %3, 100 - br i1 %lt, label %loop.body3, label %loop.exit6 - -loop.body3: ; preds = %loop.cond2, %loop.exit - %4 = load i32, i32* %i, align 4 - %5 = call i32 @foo_test() - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 %4, i32 %5) - %6 = load i32, i32* %i, align 4 - %smod = srem i32 %6, 3 - %eq = icmp eq i32 %smod, 0 - br i1 %eq, label %if.then4, label %if.exit5 - -if.then4: ; preds = %loop.body3 - br label %loop.exit6 - -if.exit5: ; preds = %loop.body3 - br label %loop.cond2 - -loop.exit6: ; preds = %if.then4, %loop.cond2 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/switch_error_range.c3 b/test/test_suite14/statements/switch_error_range.c3 deleted file mode 100644 index fe39cce9d..000000000 --- a/test/test_suite14/statements/switch_error_range.c3 +++ /dev/null @@ -1,12 +0,0 @@ -module foo; - -fn void test() -{ - int i; - switch (i) - { - case 15..13: // #error: The range is not valid because the first value (15) is greater than the second (13) - i++; - return; - } -} \ No newline at end of file diff --git a/test/test_suite14/statements/switch_errors.c3 b/test/test_suite14/statements/switch_errors.c3 deleted file mode 100644 index 43a401ead..000000000 --- a/test/test_suite14/statements/switch_errors.c3 +++ /dev/null @@ -1,160 +0,0 @@ - -enum Foo -{ - A, B -} - -enum Bar -{ - B -} - -fn void test_other_enum() -{ - Foo f = A; - switch (f) - { - case Foo.A: - break; - case B: - break; - case Bar.B: // #error: to 'Foo' - break; - } -} - -fn void test_check_nums() -{ - Foo f = A; - switch (f) - { - case (Foo)(1): - break; - case (Foo)(0): - break; - } -} - -fn void test_scope(int i) -{ - switch (i) - { - case 1: - int a = 0; - break; - case 2: - test_scope(a + 1); // #error: 'a' could not be found, did you spell it right - } -} - -fn void test_duplicate_case(int i) -{ - switch (i) - { - case 1: - break; - case 2: - break; - case 1: // #error: same case value appears - break; - } -} - -fn void test_duplicate_case2(Foo i) -{ - switch (i) - { - case A: - break; - case (Foo)(1): - break; - case A: // #error: same case value appears - break; - } -} - -fn void test_duplicate_case3(Foo i) -{ - switch (i) - { - case A: - break; - case (Foo)(0): // #error: same case value appears - break; - } -} - -enum Baz -{ - A, B, C, D -} - -fn void test_missing_all_cases(Baz x) -{ - switch (x) // -error: 4 enumeration values not handled in switch: A, B, C, ... - { - } -} - -fn void test_missing_some_cases(Baz x) -{ - switch (x) // -error: 4 enumeration B, C and D not handled in switch - { - case A: - break; - } -} - -fn void test_missing_some_cases2(Baz x) -{ - switch (x) // -error: 4 enumeration B and D not handled in switch - { - case C: - case A: - break; - } -} - -fn void test_missing_some_cases3(Baz x) -{ - switch (x) // -error: 4 enumeration B and D not handled in switch - { - case B: - case C: - case A: - break; - } -} - -fn void test_missing_no_cases(Baz x) -{ - switch (x) - { - default: - break; - } -} - -fault MathError -{ - DIVISION_BY_ZERO -} - -// Rethrowing an error uses "!!" suffix -fn void! testMayError() -{ -} - -fn void main() -{ - // Handle the error - switch (catch err = testMayError()) // #error: Catch unwrapping is only allowed - { - case MathError.DIVISION_BY_ZERO: - libc::printf("Division by zero\n"); - return; - default: - libc::printf("Unexpected error!"); - return; - } -} \ No newline at end of file diff --git a/test/test_suite14/statements/various_switching.c3t b/test/test_suite14/statements/various_switching.c3t deleted file mode 100644 index 758c6c146..000000000 --- a/test/test_suite14/statements/various_switching.c3t +++ /dev/null @@ -1,244 +0,0 @@ -// #target: macos-x64 -module mymodule; - -extern fn void printf(char *, ...); - -fault HelloErr -{ - FOO, -} -fault ByeErr -{ - BAR, - BAZ -} - -fn void test() -{ - int! x = ByeErr.BAR!; - - typeid z = int.typeid; - if (catch err = x) - { - case HelloErr.FOO: - printf("Hello\n"); - case ByeErr.BAR: - printf("Bye\n"); - default: - printf("Noerrmatch\n"); - } - switch (z) - { - case int: - printf("Was int!\n"); - case bool: - nextcase double; - case double: - nextcase; - default: - printf("Wasn't int :(\n"); - } - int a = 1; - int b = 2; - int zy = b + a; - switch (zy) - { - case a: - printf("Got a\n"); - case b: - printf("Got b\n"); - default: - printf("None of the above\n"); - } - switch - { - case a < 0: - printf("A negative\n"); - case a == 1: - printf("A is 1\n"); - default: - printf("Unexpected a\n"); - } -} -fn void main() -{ - test(); - printf("Hello!\n"); -} - -/* #expect: mymodule.ll - -define void @mymodule_test() #0 { -entry: - %x = alloca i32, align 4 - %x.f = alloca i64, align 8 - %z = alloca i64, align 8 - %err = alloca i64, align 8 - %switch = alloca i64, align 8 - %switch4 = alloca i64, align 8 - %a = alloca i32, align 4 - %b = alloca i32, align 4 - %zy = alloca i32, align 4 - %switch17 = alloca i32, align 4 - %switch27 = alloca i8, align 1 - store i64 ptrtoint (%.fault* @"mymodule_ByeErr$BAR" to i64), i64* %x.f, align 8 - store i64 ptrtoint (%.introspect* @"ct$int" to i64), i64* %z, align 8 - br label %testblock - -testblock: ; preds = %entry - %optval = load i64, i64* %x.f, align 8 - %not_err = icmp eq i64 %optval, 0 - br i1 %not_err, label %after_check, label %assign_optional - -assign_optional: ; preds = %testblock - store i64 %optval, i64* %err, align 8 - br label %end_block - -after_check: ; preds = %testblock - store i64 0, i64* %err, align 8 - br label %end_block - -end_block: ; preds = %after_check, %assign_optional - %0 = load i64, i64* %err, align 8 - %neq = icmp ne i64 %0, 0 - br i1 %neq, label %if.then, label %if.exit - -if.then: ; preds = %end_block - store i64 %0, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %if.then - %1 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.fault* @"mymodule_HelloErr$FOO" to i64), %1 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0)) - br label %switch.exit - -next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (%.fault* @"mymodule_ByeErr$BAR" to i64), %1 - br i1 %eq1, label %switch.case2, label %next_if3 - -switch.case2: ; preds = %next_if - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)) - br label %switch.exit - -next_if3: ; preds = %next_if - br label %switch.default - -switch.default: ; preds = %next_if3 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.default, %switch.case2, %switch.case - br label %if.exit - -if.exit: ; preds = %switch.exit, %end_block - %2 = load i64, i64* %z, align 8 - store i64 %2, i64* %switch4, align 8 - br label %switch.entry5 - -switch.entry5: ; preds = %if.exit - %3 = load i64, i64* %switch4, align 8 - %eq6 = icmp eq i64 ptrtoint (%.introspect* @"ct$int" to i64), %3 - br i1 %eq6, label %switch.case7, label %next_if8 - -switch.case7: ; preds = %switch.entry5 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0)) - br label %switch.exit16 - -next_if8: ; preds = %switch.entry5 - %eq9 = icmp eq i64 ptrtoint (%.introspect* @"ct$bool" to i64), %3 - br i1 %eq9, label %switch.case10, label %next_if11 - -switch.case10: ; preds = %next_if8 - br label %switch.case13 - -next_if11: ; preds = %next_if8 - %eq12 = icmp eq i64 ptrtoint (%.introspect* @"ct$double" to i64), %3 - br i1 %eq12, label %switch.case13, label %next_if14 - -switch.case13: ; preds = %next_if11, %switch.case10 - br label %switch.default15 - -next_if14: ; preds = %next_if11 - br label %switch.default15 - -switch.default15: ; preds = %next_if14, %switch.case13 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i32 0, i32 0)) - br label %switch.exit16 - -switch.exit16: ; preds = %switch.default15, %switch.case7 - store i32 1, i32* %a, align 4 - store i32 2, i32* %b, align 4 - %4 = load i32, i32* %b, align 4 - %5 = load i32, i32* %a, align 4 - %add = add i32 %4, %5 - store i32 %add, i32* %zy, align 4 - %6 = load i32, i32* %zy, align 4 - store i32 %6, i32* %switch17, align 4 - br label %switch.entry18 - -switch.entry18: ; preds = %switch.exit16 - %7 = load i32, i32* %switch17, align 4 - %8 = load i32, i32* %a, align 4 - %eq19 = icmp eq i32 %8, %7 - br i1 %eq19, label %switch.case20, label %next_if21 - -switch.case20: ; preds = %switch.entry18 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0)) - br label %switch.exit26 - -next_if21: ; preds = %switch.entry18 - %9 = load i32, i32* %b, align 4 - %eq22 = icmp eq i32 %9, %7 - br i1 %eq22, label %switch.case23, label %next_if24 - -switch.case23: ; preds = %next_if21 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0)) - br label %switch.exit26 - -next_if24: ; preds = %next_if21 - br label %switch.default25 - -switch.default25: ; preds = %next_if24 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i32 0, i32 0)) - br label %switch.exit26 - -switch.exit26: ; preds = %switch.default25, %switch.case23, %switch.case20 - store i8 1, i8* %switch27, align 1 - br label %switch.entry28 - -switch.entry28: ; preds = %switch.exit26 - %10 = load i8, i8* %switch27, align 1 - %11 = trunc i8 %10 to i1 - %12 = load i32, i32* %a, align 4 - %lt = icmp slt i32 %12, 0 - %eq29 = icmp eq i1 %lt, %11 - br i1 %eq29, label %switch.case30, label %next_if31 - -switch.case30: ; preds = %switch.entry28 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0)) - br label %switch.exit37 - -next_if31: ; preds = %switch.entry28 - %13 = load i32, i32* %a, align 4 - %eq32 = icmp eq i32 %13, 1 - %eq33 = icmp eq i1 %eq32, %11 - br i1 %eq33, label %switch.case34, label %next_if35 - -switch.case34: ; preds = %next_if31 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i32 0, i32 0)) - br label %switch.exit37 - -next_if35: ; preds = %next_if31 - br label %switch.default36 - -switch.default36: ; preds = %next_if35 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i32 0, i32 0)) - br label %switch.exit37 - -switch.exit37: ; preds = %switch.default36, %switch.case34, %switch.case30 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/statements/while_statement_placement.c3 b/test/test_suite14/statements/while_statement_placement.c3 deleted file mode 100644 index 66473b6eb..000000000 --- a/test/test_suite14/statements/while_statement_placement.c3 +++ /dev/null @@ -1,11 +0,0 @@ -fn void test1() -{ - int a; - while (1) a++; - while (1) - { - a++; - } - while (1) - a++; // #error: must be placed on the same line -} \ No newline at end of file diff --git a/test/test_suite14/statements/while_switch.c3t b/test/test_suite14/statements/while_switch.c3t deleted file mode 100644 index 855ddbfa7..000000000 --- a/test/test_suite14/statements/while_switch.c3t +++ /dev/null @@ -1,81 +0,0 @@ -// #target: macos-x64 -module test; - -extern fn int printf(char*, ...); -extern fn int foo(); - -fn int main() -{ - while (foo()) - { - switch (foo()) - { - case 0: - case 1: - case 2: - case 3: - printf("3"); - nextcase; - case 4: - printf("4"); - nextcase; - case 5: - case 6: - default: - break; - } - } - return 0; -} - -/* #expect: test.ll - - -@.str = private unnamed_addr constant [2 x i8] c"3\00", align 1 -@.str.1 = private unnamed_addr constant [2 x i8] c"4\00", align 1 - -define i32 @main() #0 { -entry: - %switch = alloca i32, align 4 - br label %loop.cond - -loop.cond: ; preds = %switch.exit, %entry - %0 = call i32 @foo() - %intbool = icmp ne i32 %0, 0 - br i1 %intbool, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %1 = call i32 @foo() - store i32 %1, i32* %switch, align 4 - br label %switch.entry - -switch.entry: ; preds = %loop.body - %2 = load i32, i32* %switch, align 4 - switch i32 %2, label %switch.default [ - i32 0, label %switch.case - i32 1, label %switch.case - i32 2, label %switch.case - i32 3, label %switch.case - i32 4, label %switch.case1 - i32 5, label %switch.default - i32 6, label %switch.default - ] - -switch.case: ; preds = %switch.entry, %switch.entry, %switch.entry, %switch.entry - %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)) - br label %switch.case1 - -switch.case1: ; preds = %switch.entry, %switch.case - %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)) - br label %switch.default - -switch.default: ; preds = %switch.entry, %switch.entry, %switch.case1, %switch.entry - br label %switch.exit - -switch.exit: ; preds = %switch.default - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret i32 0 -} - diff --git a/test/test_suite14/stdlib/ascii.c3 b/test/test_suite14/stdlib/ascii.c3 deleted file mode 100644 index 8390b1160..000000000 --- a/test/test_suite14/stdlib/ascii.c3 +++ /dev/null @@ -1,26 +0,0 @@ -import std::io; -import std::ascii; - -fn void main() -{ - for(char c = 0; c < 255; c++) - { - io::printfn("%c (%s) is...:", c, c); - io::printfn("lower: %s; upper: %s; digit: %s; bdigit: %s; odigit: %s; xdigit: %s; alpha: %s; print: %s; graph: %s; space: %s; alnum: %s; punct: %s; blank: %s; cntrl: %s;", - c.is_lower(), c.is_upper(), c.is_digit(), c.is_bdigit(), c.is_odigit(), c.is_xdigit(), c.is_alpha(), c.is_print(), - c.is_graph(), c.is_space(), c.is_alnum(), c.is_punct(), c.is_blank(), c.is_cntrl()); - } - - foreach(c : "0123456789abcdefghijklmnopqrstuvwxyz") - { - io::printfn("'%c'.to_upper(): %c", c, c.to_upper()); - } - foreach(c : "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") - { - io::printfn("'%c'.to_lower(): %c", c, c.to_lower()); - } -} - - - - diff --git a/test/test_suite14/stdlib/map.c3t b/test/test_suite14/stdlib/map.c3t deleted file mode 100644 index e90aad3b5..000000000 --- a/test/test_suite14/stdlib/map.c3t +++ /dev/null @@ -1,587 +0,0 @@ -// #target: macos-x64 - -module test; -import std::io; -import std::map; - -struct Foo { int x; void* bar; } - -define IntFooMap = std::map::HashMap; -define IntDoubleMap = std::map::HashMap; - -fn char[] Foo.to_string(Foo* foo, Allocator* allocator = mem::current_allocator()) -{ - VarString s = string::new_with_capacity(128, allocator); - s.printf("{%s, %p}", foo.x, foo.bar); - return s.str(); -} - -static initialize -{ - io::formatter_register_type(Foo); -} - -fn void main() -{ - IntFooMap map; - map.tinit(); - io::printfn("Map size: %d", map.count); - map.set(1, Foo { 1, null }); - io::printfn("Map size: %d", map.count); - map.set(1, Foo { 2, null }); - io::printfn("Map size: %d", map.count); - io::printfn("Val: %d", map.get(1).x); - io::printfn("Has 1: %s", map.has_key(1)); - io::printfn("Has 2: %s", map.has_key(2)); - map.set(7, Foo { 4, null }); - io::printfn("Values: %s", map.value_list()); - IntDoubleMap map2; - map2.tinit(); - map2.set(4, 1.3); - io::printfn("Map find: %s", map2.has_value(1.3)); - io::printfn("Map find: %s", map2.has_value(1.2)); - map2.set(100, 3.4); - io::printfn("%s", map2.key_list()); - io::printfn("%s", map2.value_list()); - @pool() - { - IntDoubleMap map3; - map3.tinit(); - map3.set(5, 3.2); - map3.set(7, 5.2); - io::printfn("%s", map3.key_list()); - }; -} - -/* #expect: test.ll - - -@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @.static_initialize.0, i8* null }] - -define internal void @.static_initialize.0() { -entry: - %0 = load i64, i64* getelementptr inbounds (%HashMap, %HashMap* @std_io_tostring_functions, i32 0, i32 0, i32 1), align 8 - %not = icmp eq i64 %0, 0 - br i1 %not, label %if.then, label %if.exit - -if.then: ; preds = %entry - %1 = load %Allocator*, %Allocator** @std_core_mem_thread_allocator, align 8 - call void @"std_map$$typeid.p$std_io$ToStringFunction_HashMap_init"(%HashMap* @std_io_tostring_functions, i32 - br label %if.exit - -if.exit: ; preds = %if.then, %entry - %2 = call i8 @"std_map$$typeid.p$std_io$ToStringFunction_HashMap_set"(%HashMap* @std_io_tostring_functions, i64 ptrtoint (%.introspect* @"ct$test_Foo" to i64), { i8*, i64 } (i8*, %Allocator*)* bitcast ({ i8*, i64 } (%Foo*, %Allocator*)* @test_Foo_to_string to { i8*, i64 } (i8*, %Allocator*)*)) - ret void -} - -declare void @"std_map$$typeid.p$std_io$ToStringFunction_HashMap_init"(%HashMap*, i32, float, %Allocator*) #0 - -declare zeroext i8 @"std_map$$typeid.p$std_io$ToStringFunction_HashMap_set"(%HashMap*, i64, { i8*, i64 } (i8*, %Allocator*)*) #0 - -; Function Attrs: nounwind -define { i8*, i64 } @test_Foo_to_string(%Foo* %0, %Allocator* %1) #0 { -entry: - %s = alloca i8*, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [2 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %result = alloca %"char[]", align 8 - %2 = call i8* @std_core_string_new_with_capacity(i64 128, %Allocator* %1) - store i8* %2, i8** %s, align 8 - %3 = getelementptr inbounds %Foo, %Foo* %0, i32 0, i32 0 - %4 = bitcast i32* %3 to i8* - %5 = insertvalue %variant undef, i8* %4, 0 - %6 = insertvalue %variant %5, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %7 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 0 - store %variant %6, %variant* %7, align 16 - %8 = getelementptr inbounds %Foo, %Foo* %0, i32 0, i32 1 - %9 = bitcast i8** %8 to i8* - %10 = insertvalue %variant undef, i8* %9, 0 - %11 = insertvalue %variant %10, i64 ptrtoint (%.introspect* @"ct$p$void" to i64), 1 - %12 = getelementptr inbounds [2 x %variant], [2 x %variant]* %varargslots, i64 0, i64 1 - store %variant %11, %variant* %12, align 16 - %13 = bitcast [2 x %variant]* %varargslots to %variant* - %14 = insertvalue %"variant[]" undef, %variant* %13, 0 - %15 = insertvalue %"variant[]" %14, i64 2, 1 - store %"variant[]" %15, %"variant[]"* %taddr, align 8 - %16 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %17 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %16, i32 0, i32 0 - %lo = load i8*, i8** %17, align 8 - %18 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %16, i32 0, i32 1 - %hi = load i64, i64* %18, align 8 - %19 = call i64 @std_core_string_VarString_printf(i64* %retparam, i8** %s, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i32 0, i32 0), i64 8, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %19, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %20 = load i8*, i8** %s, align 8 - %21 = call { i8*, i64 } @std_core_string_VarString_str(i8* %20) - %22 = bitcast %"char[]"* %result to { i8*, i64 }* - store { i8*, i64 } %21, { i8*, i64 }* %22, align 8 - %23 = bitcast %"char[]"* %result to { i8*, i64 }* - %24 = load { i8*, i64 }, { i8*, i64 }* %23, align 8 - ret { i8*, i64 } %24 -} - -; Function Attrs: nounwind -define void @test_main() #0 { -entry: - %map = alloca %HashMap.0, align 8 - %retparam = alloca i64, align 8 - %varargslots = alloca [1 x %variant], align 16 - %taddr = alloca %"variant[]", align 8 - %literal = alloca %Foo, align 8 - %retparam3 = alloca i64, align 8 - %varargslots4 = alloca [1 x %variant], align 16 - %taddr5 = alloca %"variant[]", align 8 - %literal11 = alloca %Foo, align 8 - %retparam14 = alloca i64, align 8 - %varargslots15 = alloca [1 x %variant], align 16 - %taddr16 = alloca %"variant[]", align 8 - %retparam22 = alloca i64, align 8 - %varargslots23 = alloca [1 x %variant], align 16 - %retparam24 = alloca %Foo, align 8 - %taddr27 = alloca %"variant[]", align 8 - %retparam33 = alloca i64, align 8 - %varargslots34 = alloca [1 x %variant], align 16 - %taddr35 = alloca i8, align 1 - %taddr36 = alloca %"variant[]", align 8 - %retparam42 = alloca i64, align 8 - %varargslots43 = alloca [1 x %variant], align 16 - %taddr44 = alloca i8, align 1 - %taddr45 = alloca %"variant[]", align 8 - %literal51 = alloca %Foo, align 8 - %retparam54 = alloca i64, align 8 - %varargslots55 = alloca [1 x %variant], align 16 - %result = alloca %"Foo[]", align 8 - %taddr56 = alloca %"variant[]", align 8 - %map2 = alloca %HashMap.3, align 8 - %retparam62 = alloca i64, align 8 - %varargslots63 = alloca [1 x %variant], align 16 - %taddr64 = alloca i8, align 1 - %taddr65 = alloca %"variant[]", align 8 - %retparam71 = alloca i64, align 8 - %varargslots72 = alloca [1 x %variant], align 16 - %taddr73 = alloca i8, align 1 - %taddr74 = alloca %"variant[]", align 8 - %retparam80 = alloca i64, align 8 - %varargslots81 = alloca [1 x %variant], align 16 - %result82 = alloca %"int[]", align 8 - %taddr83 = alloca %"variant[]", align 8 - %retparam89 = alloca i64, align 8 - %varargslots90 = alloca [1 x %variant], align 16 - %result91 = alloca %"double[]", align 8 - %taddr92 = alloca %"variant[]", align 8 - %temp = alloca %TempAllocator*, align 8 - %error_var = alloca i64, align 8 - %retparam98 = alloca %TempAllocator*, align 8 - %mark = alloca i64, align 8 - %map3 = alloca %HashMap.3, align 8 - %retparam101 = alloca i64, align 8 - %varargslots102 = alloca [1 x %variant], align 16 - %result103 = alloca %"int[]", align 8 - %taddr104 = alloca %"variant[]", align 8 - %0 = bitcast %HashMap.0* %map to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %0, i8 0, i64 40, i1 false) - call void @"std_map$$int.test_Foo_HashMap_tinit"(%HashMap.0* %map, i32 16, float 7.500000e-01) - %1 = getelementptr inbounds %HashMap.0, %HashMap.0* %map, i32 0, i32 2 - %2 = bitcast i32* %1 to i8* - %3 = insertvalue %variant undef, i8* %2, 0 - %4 = insertvalue %variant %3, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %5 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 - store %variant %4, %variant* %5, align 16 - %6 = bitcast [1 x %variant]* %varargslots to %variant* - %7 = insertvalue %"variant[]" undef, %variant* %6, 0 - %8 = insertvalue %"variant[]" %7, i64 1, 1 - store %"variant[]" %8, %"variant[]"* %taddr, align 8 - %9 = bitcast %"variant[]"* %taddr to { i8*, i64 }* - %10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 0 - %lo = load i8*, i8** %10, align 8 - %11 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 1 - %hi = load i64, i64* %11, align 8 - %12 = call i64 @std_io_printfn(i64* %retparam, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i64 12, i8* %lo, i64 %hi) - %not_err = icmp eq i64 %12, 0 - br i1 %not_err, label %after_check, label %voiderr - -after_check: ; preds = %entry - br label %voiderr - -voiderr: ; preds = %after_check, %entry - %13 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 0 - store i32 1, i32* %13, align 8 - %14 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 1 - store i8* null, i8** %14, align 8 - %15 = bitcast %Foo* %literal to { i64, i8* }* - %16 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %15, i32 0, i32 0 - %lo1 = load i64, i64* %16, align 8 - %17 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %15, i32 0, i32 1 - %hi2 = load i8*, i8** %17, align 8 - %18 = call i8 @"std_map$$int.test_Foo_HashMap_set"(%HashMap.0* %map, i32 1, i64 %lo1, i8* %hi2) - %19 = getelementptr inbounds %HashMap.0, %HashMap.0* %map, i32 0, i32 2 - %20 = bitcast i32* %19 to i8* - %21 = insertvalue %variant undef, i8* %20, 0 - %22 = insertvalue %variant %21, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %23 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots4, i64 0, i64 0 - store %variant %22, %variant* %23, align 16 - %24 = bitcast [1 x %variant]* %varargslots4 to %variant* - %25 = insertvalue %"variant[]" undef, %variant* %24, 0 - %26 = insertvalue %"variant[]" %25, i64 1, 1 - store %"variant[]" %26, %"variant[]"* %taddr5, align 8 - %27 = bitcast %"variant[]"* %taddr5 to { i8*, i64 }* - %28 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %27, i32 0, i32 0 - %lo6 = load i8*, i8** %28, align 8 - %29 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %27, i32 0, i32 1 - %hi7 = load i64, i64* %29, align 8 - %30 = call i64 @std_io_printfn(i64* %retparam3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0), i64 12, i8* %lo6, i64 %hi7) - %not_err8 = icmp eq i64 %30, 0 - br i1 %not_err8, label %after_check9, label %voiderr10 - -after_check9: ; preds = %voiderr - br label %voiderr10 - -voiderr10: ; preds = %after_check9, %voiderr - %31 = getelementptr inbounds %Foo, %Foo* %literal11, i32 0, i32 0 - store i32 2, i32* %31, align 8 - %32 = getelementptr inbounds %Foo, %Foo* %literal11, i32 0, i32 1 - store i8* null, i8** %32, align 8 - %33 = bitcast %Foo* %literal11 to { i64, i8* }* - %34 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %33, i32 0, i32 0 - %lo12 = load i64, i64* %34, align 8 - %35 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %33, i32 0, i32 1 - %hi13 = load i8*, i8** %35, align 8 - %36 = call i8 @"std_map$$int.test_Foo_HashMap_set"(%HashMap.0* %map, i32 1, i64 %lo12, i8* %hi13) - %37 = getelementptr inbounds %HashMap.0, %HashMap.0* %map, i32 0, i32 2 - %38 = bitcast i32* %37 to i8* - %39 = insertvalue %variant undef, i8* %38, 0 - %40 = insertvalue %variant %39, i64 ptrtoint (%.introspect* @"ct$uint" to i64), 1 - %41 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots15, i64 0, i64 0 - store %variant %40, %variant* %41, align 16 - %42 = bitcast [1 x %variant]* %varargslots15 to %variant* - %43 = insertvalue %"variant[]" undef, %variant* %42, 0 - %44 = insertvalue %"variant[]" %43, i64 1, 1 - store %"variant[]" %44, %"variant[]"* %taddr16, align 8 - %45 = bitcast %"variant[]"* %taddr16 to { i8*, i64 }* - %46 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 0 - %lo17 = load i8*, i8** %46, align 8 - %47 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 1 - %hi18 = load i64, i64* %47, align 8 - %48 = call i64 @std_io_printfn(i64* %retparam14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0), i64 12, i8* %lo17, i64 %hi18) - %not_err19 = icmp eq i64 %48, 0 - br i1 %not_err19, label %after_check20, label %voiderr21 - -after_check20: ; preds = %voiderr10 - br label %voiderr21 - -voiderr21: ; preds = %after_check20, %voiderr10 - %49 = call i64 @"std_map$$int.test_Foo_HashMap_get"(%Foo* %retparam24, %HashMap.0* %map, i32 1) - %not_err25 = icmp eq i64 %49, 0 - br i1 %not_err25, label %after_check26, label %voiderr32 - -after_check26: ; preds = %voiderr21 - %50 = getelementptr inbounds %Foo, %Foo* %retparam24, i32 0, i32 0 - %51 = bitcast i32* %50 to i8* - %52 = insertvalue %variant undef, i8* %51, 0 - %53 = insertvalue %variant %52, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - %54 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots23, i64 0, i64 0 - store %variant %53, %variant* %54, align 16 - %55 = bitcast [1 x %variant]* %varargslots23 to %variant* - %56 = insertvalue %"variant[]" undef, %variant* %55, 0 - %57 = insertvalue %"variant[]" %56, i64 1, 1 - store %"variant[]" %57, %"variant[]"* %taddr27, align 8 - %58 = bitcast %"variant[]"* %taddr27 to { i8*, i64 }* - %59 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %58, i32 0, i32 0 - %lo28 = load i8*, i8** %59, align 8 - %60 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %58, i32 0, i32 1 - %hi29 = load i64, i64* %60, align 8 - %61 = call i64 @std_io_printfn(i64* %retparam22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i64 7, i8* %lo28, i64 %hi29) - %not_err30 = icmp eq i64 %61, 0 - br i1 %not_err30, label %after_check31, label %voiderr32 - -after_check31: ; preds = %after_check26 - br label %voiderr32 - -voiderr32: ; preds = %after_check31, %after_check26, %voiderr21 - %62 = call i8 @"std_map$$int.test_Foo_HashMap_has_key"(%HashMap.0* %map, i32 1) - store i8 %62, i8* %taddr35, align 1 - %63 = insertvalue %variant undef, i8* %taddr35, 0 - %64 = insertvalue %variant %63, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %65 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots34, i64 0, i64 0 - store %variant %64, %variant* %65, align 16 - %66 = bitcast [1 x %variant]* %varargslots34 to %variant* - %67 = insertvalue %"variant[]" undef, %variant* %66, 0 - %68 = insertvalue %"variant[]" %67, i64 1, 1 - store %"variant[]" %68, %"variant[]"* %taddr36, align 8 - %69 = bitcast %"variant[]"* %taddr36 to { i8*, i64 }* - %70 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %69, i32 0, i32 0 - %lo37 = load i8*, i8** %70, align 8 - %71 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %69, i32 0, i32 1 - %hi38 = load i64, i64* %71, align 8 - %72 = call i64 @std_io_printfn(i64* %retparam33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i64 9, i8* %lo37, i64 %hi38) - %not_err39 = icmp eq i64 %72, 0 - br i1 %not_err39, label %after_check40, label %voiderr41 - -after_check40: ; preds = %voiderr32 - br label %voiderr41 - -voiderr41: ; preds = %after_check40, %voiderr32 - %73 = call i8 @"std_map$$int.test_Foo_HashMap_has_key"(%HashMap.0* %map, i32 2) - store i8 %73, i8* %taddr44, align 1 - %74 = insertvalue %variant undef, i8* %taddr44, 0 - %75 = insertvalue %variant %74, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %76 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots43, i64 0, i64 0 - store %variant %75, %variant* %76, align 16 - %77 = bitcast [1 x %variant]* %varargslots43 to %variant* - %78 = insertvalue %"variant[]" undef, %variant* %77, 0 - %79 = insertvalue %"variant[]" %78, i64 1, 1 - store %"variant[]" %79, %"variant[]"* %taddr45, align 8 - %80 = bitcast %"variant[]"* %taddr45 to { i8*, i64 }* - %81 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %80, i32 0, i32 0 - %lo46 = load i8*, i8** %81, align 8 - %82 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %80, i32 0, i32 1 - %hi47 = load i64, i64* %82, align 8 - %83 = call i64 @std_io_printfn(i64* %retparam42, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i64 9, i8* %lo46, i64 %hi47) - %not_err48 = icmp eq i64 %83, 0 - br i1 %not_err48, label %after_check49, label %voiderr50 - -after_check49: ; preds = %voiderr41 - br label %voiderr50 - -voiderr50: ; preds = %after_check49, %voiderr41 - %84 = getelementptr inbounds %Foo, %Foo* %literal51, i32 0, i32 0 - store i32 4, i32* %84, align 8 - %85 = getelementptr inbounds %Foo, %Foo* %literal51, i32 0, i32 1 - store i8* null, i8** %85, align 8 - %86 = bitcast %Foo* %literal51 to { i64, i8* }* - %87 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %86, i32 0, i32 0 - %lo52 = load i64, i64* %87, align 8 - %88 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %86, i32 0, i32 1 - %hi53 = load i8*, i8** %88, align 8 - %89 = call i8 @"std_map$$int.test_Foo_HashMap_set"(%HashMap.0* %map, i32 7, i64 %lo52, i8* %hi53) - %90 = load %Allocator*, %Allocator** @std_core_mem_thread_allocator, align 8 - %91 = call { i8*, i64 } @"std_map$$int.test_Foo_HashMap_value_list"(%HashMap.0* %map, %Allocator* %90) - %92 = bitcast %"Foo[]"* %result to { i8*, i64 }* - store { i8*, i64 } %91, { i8*, i64 }* %92, align 8 - %93 = bitcast %"Foo[]"* %result to i8* - %94 = insertvalue %variant undef, i8* %93, 0 - %95 = insertvalue %variant %94, i64 ptrtoint (%.introspect* @"ct$sa$test_Foo" to i64), 1 - %96 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots55, i64 0, i64 0 - store %variant %95, %variant* %96, align 16 - %97 = bitcast [1 x %variant]* %varargslots55 to %variant* - %98 = insertvalue %"variant[]" undef, %variant* %97, 0 - %99 = insertvalue %"variant[]" %98, i64 1, 1 - store %"variant[]" %99, %"variant[]"* %taddr56, align 8 - %100 = bitcast %"variant[]"* %taddr56 to { i8*, i64 }* - %101 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %100, i32 0, i32 0 - %lo57 = load i8*, i8** %101, align 8 - %102 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %100, i32 0, i32 1 - %hi58 = load i64, i64* %102, align 8 - %103 = call i64 @std_io_printfn(i64* %retparam54, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), i64 10, i8* %lo57, i64 %hi58) - %not_err59 = icmp eq i64 %103, 0 - br i1 %not_err59, label %after_check60, label %voiderr61 - -after_check60: ; preds = %voiderr50 - br label %voiderr61 - -voiderr61: ; preds = %after_check60, %voiderr50 - %104 = bitcast %HashMap.3* %map2 to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %104, i8 0, i64 40, i1 false) - call void @"std_map$$int.double_HashMap_tinit"(%HashMap.3* %map2, i32 16, float 7.500000e-01) - %105 = call i8 @"std_map$$int.double_HashMap_set"(%HashMap.3* %map2, i32 4, double 1.300000e+00) - %106 = call i8 @"std_map$$int.double_HashMap_has_value"(%HashMap.3* %map2, double 1.300000e+00) - store i8 %106, i8* %taddr64, align 1 - %107 = insertvalue %variant undef, i8* %taddr64, 0 - %108 = insertvalue %variant %107, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %109 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots63, i64 0, i64 0 - store %variant %108, %variant* %109, align 16 - %110 = bitcast [1 x %variant]* %varargslots63 to %variant* - %111 = insertvalue %"variant[]" undef, %variant* %110, 0 - %112 = insertvalue %"variant[]" %111, i64 1, 1 - store %"variant[]" %112, %"variant[]"* %taddr65, align 8 - %113 = bitcast %"variant[]"* %taddr65 to { i8*, i64 }* - %114 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %113, i32 0, i32 0 - %lo66 = load i8*, i8** %114, align 8 - %115 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %113, i32 0, i32 1 - %hi67 = load i64, i64* %115, align 8 - %116 = call i64 @std_io_printfn(i64* %retparam62, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i32 0, i32 0), i64 12, i8* %lo66, i64 %hi67) - %not_err68 = icmp eq i64 %116, 0 - br i1 %not_err68, label %after_check69, label %voiderr70 - -after_check69: ; preds = %voiderr61 - br label %voiderr70 - -voiderr70: ; preds = %after_check69, %voiderr61 - %117 = call i8 @"std_map$$int.double_HashMap_has_value"(%HashMap.3* %map2, double 1.200000e+00) - store i8 %117, i8* %taddr73, align 1 - %118 = insertvalue %variant undef, i8* %taddr73, 0 - %119 = insertvalue %variant %118, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - %120 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots72, i64 0, i64 0 - store %variant %119, %variant* %120, align 16 - %121 = bitcast [1 x %variant]* %varargslots72 to %variant* - %122 = insertvalue %"variant[]" undef, %variant* %121, 0 - %123 = insertvalue %"variant[]" %122, i64 1, 1 - store %"variant[]" %123, %"variant[]"* %taddr74, align 8 - %124 = bitcast %"variant[]"* %taddr74 to { i8*, i64 }* - %125 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %124, i32 0, i32 0 - %lo75 = load i8*, i8** %125, align 8 - %126 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %124, i32 0, i32 1 - %hi76 = load i64, i64* %126, align 8 - %127 = call i64 @std_io_printfn(i64* %retparam71, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i32 0, i32 0), i64 12, i8* %lo75, i64 %hi76) - %not_err77 = icmp eq i64 %127, 0 - br i1 %not_err77, label %after_check78, label %voiderr79 - -after_check78: ; preds = %voiderr70 - br label %voiderr79 - -voiderr79: ; preds = %after_check78, %voiderr70 - %128 = call i8 @"std_map$$int.double_HashMap_set"(%HashMap.3* %map2, i32 100, double 3.400000e+00) - %129 = load %Allocator*, %Allocator** @std_core_mem_thread_allocator, align 8 - %130 = call { i8*, i64 } @"std_map$$int.double_HashMap_key_list"(%HashMap.3* %map2, %Allocator* %129) - %131 = bitcast %"int[]"* %result82 to { i8*, i64 }* - store { i8*, i64 } %130, { i8*, i64 }* %131, align 8 - %132 = bitcast %"int[]"* %result82 to i8* - %133 = insertvalue %variant undef, i8* %132, 0 - %134 = insertvalue %variant %133, i64 ptrtoint (%.introspect* @"ct$sa$int" to i64), 1 - %135 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots81, i64 0, i64 0 - store %variant %134, %variant* %135, align 16 - %136 = bitcast [1 x %variant]* %varargslots81 to %variant* - %137 = insertvalue %"variant[]" undef, %variant* %136, 0 - %138 = insertvalue %"variant[]" %137, i64 1, 1 - store %"variant[]" %138, %"variant[]"* %taddr83, align 8 - %139 = bitcast %"variant[]"* %taddr83 to { i8*, i64 }* - %140 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %139, i32 0, i32 0 - %lo84 = load i8*, i8** %140, align 8 - %141 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %139, i32 0, i32 1 - %hi85 = load i64, i64* %141, align 8 - %142 = call i64 @std_io_printfn(i64* %retparam80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i64 2, i8* %lo84, i64 %hi85) - %not_err86 = icmp eq i64 %142, 0 - br i1 %not_err86, label %after_check87, label %voiderr88 - -after_check87: ; preds = %voiderr79 - br label %voiderr88 - -voiderr88: ; preds = %after_check87, %voiderr79 - %143 = load %Allocator*, %Allocator** @std_core_mem_thread_allocator, align 8 - %144 = call { i8*, i64 } @"std_map$$int.double_HashMap_value_list"(%HashMap.3* %map2, %Allocator* %143) - %145 = bitcast %"double[]"* %result91 to { i8*, i64 }* - store { i8*, i64 } %144, { i8*, i64 }* %145, align 8 - %146 = bitcast %"double[]"* %result91 to i8* - %147 = insertvalue %variant undef, i8* %146, 0 - %148 = insertvalue %variant %147, i64 ptrtoint (%.introspect* @"ct$sa$double" to i64), 1 - %149 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots90, i64 0, i64 0 - store %variant %148, %variant* %149, align 16 - %150 = bitcast [1 x %variant]* %varargslots90 to %variant* - %151 = insertvalue %"variant[]" undef, %variant* %150, 0 - %152 = insertvalue %"variant[]" %151, i64 1, 1 - store %"variant[]" %152, %"variant[]"* %taddr92, align 8 - %153 = bitcast %"variant[]"* %taddr92 to { i8*, i64 }* - %154 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %153, i32 0, i32 0 - %lo93 = load i8*, i8** %154, align 8 - %155 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %153, i32 0, i32 1 - %hi94 = load i64, i64* %155, align 8 - %156 = call i64 @std_io_printfn(i64* %retparam89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i32 0, i32 0), i64 2, i8* %lo93, i64 %hi94) - %not_err95 = icmp eq i64 %156, 0 - br i1 %not_err95, label %after_check96, label %voiderr97 - -after_check96: ; preds = %voiderr88 - br label %voiderr97 - -voiderr97: ; preds = %after_check96, %voiderr88 - %157 = load %TempAllocator*, %TempAllocator** @std_core_mem_thread_temp_allocator, align 8 - %not = icmp eq %TempAllocator* %157, null - br i1 %not, label %if.then, label %if.exit - -if.then: ; preds = %voiderr97 - %158 = call i64 @std_core_mem_allocator_new_temp(%TempAllocator** %retparam98, i64 262144, %Allocator* @std_core_mem_allocator__SYSTEM_ALLOCATOR) - %not_err99 = icmp eq i64 %158, 0 - br i1 %not_err99, label %after_check100, label %assign_optional - -assign_optional: ; preds = %if.then - store i64 %158, i64* %error_var, align 8 - br label %panic_block - -after_check100: ; preds = %if.then - %159 = load %TempAllocator*, %TempAllocator** %retparam98, align 8 - br label %noerr_block - -panic_block: ; preds = %assign_optional - %160 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %160(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.panic_msg, i64 0, i64 0), i64 27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.file, i64 0, i64 0), i64 6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.func, i64 0, i64 0), i64 4, i32 280) - unreachable - -noerr_block: ; preds = %after_check100 - store %TempAllocator* %159, %TempAllocator** @std_core_mem_thread_temp_allocator, align 8 - br label %if.exit - -if.exit: ; preds = %noerr_block, %voiderr97 - %161 = load %TempAllocator*, %TempAllocator** @std_core_mem_thread_temp_allocator, align 8 - store %TempAllocator* %161, %TempAllocator** %temp, align 8 - %162 = load %TempAllocator*, %TempAllocator** %temp, align 8 - %163 = getelementptr inbounds %TempAllocator, %TempAllocator* %162, i32 0, i32 3 - %164 = load i64, i64* %163, align 8 - store i64 %164, i64* %mark, align 8 - %165 = bitcast %HashMap.3* %map3 to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %165, i8 0, i64 40, i1 false) - call void @"std_map$$int.double_HashMap_tinit"(%HashMap.3* %map3, i32 16, float 7.500000e-01) - %166 = call i8 @"std_map$$int.double_HashMap_set"(%HashMap.3* %map3, i32 5, double 3.200000e+00) - %167 = call i8 @"std_map$$int.double_HashMap_set"(%HashMap.3* %map3, i32 7, double 5.200000e+00) - %168 = load %Allocator*, %Allocator** @std_core_mem_thread_allocator, align 8 - %169 = call { i8*, i64 } @"std_map$$int.double_HashMap_key_list"(%HashMap.3* %map3, %Allocator* %168) - %170 = bitcast %"int[]"* %result103 to { i8*, i64 }* - store { i8*, i64 } %169, { i8*, i64 }* %170, align 8 - %171 = bitcast %"int[]"* %result103 to i8* - %172 = insertvalue %variant undef, i8* %171, 0 - %173 = insertvalue %variant %172, i64 ptrtoint (%.introspect* @"ct$sa$int" to i64), 1 - %174 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots102, i64 0, i64 0 - store %variant %173, %variant* %174, align 16 - %175 = bitcast [1 x %variant]* %varargslots102 to %variant* - %176 = insertvalue %"variant[]" undef, %variant* %175, 0 - %177 = insertvalue %"variant[]" %176, i64 1, 1 - store %"variant[]" %177, %"variant[]"* %taddr104, align 8 - %178 = bitcast %"variant[]"* %taddr104 to { i8*, i64 }* - %179 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %178, i32 0, i32 0 - %lo105 = load i8*, i8** %179, align 8 - %180 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %178, i32 0, i32 1 - %hi106 = load i64, i64* %180, align 8 - %181 = call i64 @std_io_printfn(i64* %retparam101, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i64 2, i8* %lo105, i64 %hi106) - %not_err107 = icmp eq i64 %181, 0 - br i1 %not_err107, label %after_check108, label %voiderr109 - -after_check108: ; preds = %if.exit - br label %voiderr109 - -voiderr109: ; preds = %after_check108, %if.exit - %182 = load %TempAllocator*, %TempAllocator** %temp, align 8 - %183 = getelementptr inbounds %TempAllocator, %TempAllocator* %182, i32 0, i32 0 - %184 = load i64, i64* %mark, align 8 - call void @std_core_mem_allocator_Allocator_reset(%Allocator* %183, i64 %184) - ret void -} - -; Function Attrs: nounwind -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @test_main() - ret i32 0 -} - -; Function Attrs: argmemonly nofree nounwind willreturn writeonly -declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #1 - -declare void @"std_map$$int.test_Foo_HashMap_tinit"(%HashMap.0*, i32, float) - -declare i64 @std_io_printfn(i64*, i8*, i64, i8*, i64) - -declare zeroext i8 @"std_map$$int.test_Foo_HashMap_set"(%HashMap.0*, i32, i64, i8*) - -declare i64 @"std_map$$int.test_Foo_HashMap_get"(%Foo*, %HashMap.0*, i32) - -declare zeroext i8 @"std_map$$int.test_Foo_HashMap_has_key"(%HashMap.0*, i32) - -declare { i8*, i64 } @"std_map$$int.test_Foo_HashMap_value_list"(%HashMap.0*, %Allocator*) - -declare void @"std_map$$int.double_HashMap_tinit"(%HashMap.3*, i32, float) - -declare zeroext i8 @"std_map$$int.double_HashMap_set"(%HashMap.3*, i32, double) \ No newline at end of file diff --git a/test/test_suite14/stdlib/memcomp.c3t b/test/test_suite14/stdlib/memcomp.c3t deleted file mode 100644 index 1b9dfd516..000000000 --- a/test/test_suite14/stdlib/memcomp.c3t +++ /dev/null @@ -1,16 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -import libc; - -fn void main() -{ - int[] ab = { 3, 5, 6, 10, 0x0b2399 }; - int[] cd = { 3, 5, 6, 10, 0x0b2399 }; - char[] x = "hello world!"; - char[] y = "hello world?"; - io::printfn("is matching: %s", mem::equals(ab, cd)); - io::printfn("is matching: %s", mem::equals(x, y)); - io::printfn("is matching: %s", mem::equals(x.ptr, y.ptr, x.len)); - io::printfn("is matching: %s", mem::equals(ab.ptr, cd.ptr, ab.len * 4, 4)); -} \ No newline at end of file diff --git a/test/test_suite14/stdlib/minmax.c3 b/test/test_suite14/stdlib/minmax.c3 deleted file mode 100644 index b8bfa7446..000000000 --- a/test/test_suite14/stdlib/minmax.c3 +++ /dev/null @@ -1,9 +0,0 @@ -import std::io; - -fn void main() -{ - io::printfn("min(-1, 1) == %s", min(-1, 1)); - io::printfn("max(-1, 1) == %s", max(-1, 1)); - io::printfn("min(-1, 0, 1) == %s", min(-1, 0, 1)); - io::printfn("max(-1, 0, 1) == %s", max(-1, 0, 1)); -} diff --git a/test/test_suite14/stdlib/print_env_defines.c3 b/test/test_suite14/stdlib/print_env_defines.c3 deleted file mode 100644 index e764da65e..000000000 --- a/test/test_suite14/stdlib/print_env_defines.c3 +++ /dev/null @@ -1,15 +0,0 @@ -import std::io; - -fn void main() -{ - io::printfn("LLVM version: %s", env::LLVM_VERSION); - io::printfn("Optimization level: %s", env::COMPILER_OPT_LEVEL); - io::printfn("Safe mode: %s", env::COMPILER_SAFE_MODE); - io::printfn("OS type: %s", env::OS_TYPE); - io::printfn("Big endian: %s", env::BIG_ENDIAN); - io::printfn("i128 support: %s", env::I128_NATIVE_SUPPORT); - io::printfn("f16 support: %s", env::F16_SUPPORT); - io::printfn("f128 support: %s", env::F128_SUPPORT); - io::printfn("Benchmarking: %s", env::BENCHMARKING); - io::printfn("Testing: %s", env::TESTING); -} \ No newline at end of file diff --git a/test/test_suite14/stdlib/priorityqueue.c3t b/test/test_suite14/stdlib/priorityqueue.c3t deleted file mode 100644 index 8ab896035..000000000 --- a/test/test_suite14/stdlib/priorityqueue.c3t +++ /dev/null @@ -1,32 +0,0 @@ -// #target: macos-x64 -module test; -import std::io; -import std::math; -import std::priorityqueue; - -define FooPriorityQueue = PriorityQueue; - -fn void main() -{ - - FooPriorityQueue agh; - agh.max = true; - agh.push(Foo { 3 }); - agh.push(Foo { 101 }); - agh.push(Foo { 10 }); - while (try f = agh.pop()) io::printf("%s\n", f.x); -} - -struct Foo -{ - int x; -} - -fn bool Foo.less(Foo* x, Foo y) @inline -{ - return x.x < y.x; -} - -// #expect: test.ll - -%PriorityQueue = type { %List, i8 } diff --git a/test/test_suite14/stdlib/rounding_mode.c3 b/test/test_suite14/stdlib/rounding_mode.c3 deleted file mode 100644 index f955b1795..000000000 --- a/test/test_suite14/stdlib/rounding_mode.c3 +++ /dev/null @@ -1,30 +0,0 @@ -import std::io; -import std::math; - -fn void main() -{ - io::printfn("Current rounding mode: %s", $$get_rounding_mode()); - float f1 = 11.5; - float f2 = -11.5; - - foreach (int mode : RoundingMode.values) - { - $$set_rounding_mode(mode); - io::printfn("Rounding mode: %s", $$get_rounding_mode()); - - io::printfn(" ceil(%s) == %s", f1, math::ceil(f1)); - io::printfn(" ceil(%s) == %s", f2, math::ceil(f2)); - io::printfn(" floor(%s) == %s", f1, math::floor(f1)); - io::printfn(" floor(%s) == %s", f2, math::floor(f2)); - io::printfn(" nearbyint(%s) == %s", f1, math::nearbyint(f1)); - io::printfn(" nearbyint(%s) == %s", f2, math::nearbyint(f2)); - io::printfn(" rint(%s) == %s", f1, math::rint(f1)); - io::printfn(" rint(%s) == %s", f2, math::rint(f2)); - io::printfn(" round(%s) == %s", f1, math::round(f1)); - io::printfn(" round(%s) == %s", f2, math::round(f2)); - io::printfn(" roundeven(%s) == %s", f1, math::roundeven(f1)); - io::printfn(" roundeven(%s) == %s", f2, math::roundeven(f2)); - io::printfn(" trunc(%s) == %s", f1, math::trunc(f1)); - io::printfn(" trunc(%s) == %s", f2, math::trunc(f2)); - } -} diff --git a/test/test_suite14/strings/literal_errors.c3 b/test/test_suite14/strings/literal_errors.c3 deleted file mode 100644 index 805772c4a..000000000 --- a/test/test_suite14/strings/literal_errors.c3 +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 - -char bar = '\xaf'; -char bar = '\x0F'; - -char bar = '\xgh'; // #error: Expected a two character - -char baz = '\ueeof'; // #error: Expected a four char -char eofk = '\u233'; // #error: Expected a four char - -char zab = '\Uaokdokok'; // #error: Expected an eight -char zab = '\Uaokdooekfoekfekfkeofkekok'; // #error: Expected an eight -char eofkq = '\UaUfko'; // #error: Expected an eight - -char x1 = '\u0023a'; // #error: Character literals with '\u' can only contain one character -char x2 = '\U00000023a'; // #error: Character literals with '\U' can only contain one character - -char x = 'äö'; // #error: may only contain one character -char feokf = '\9'; // #error: Invalid escape sequence '\9' -char fje = '123456789012345678'; // #error: The character literal exceeds 16 characters. - -char foekfe = ''; // #error: The character literal was empty \ No newline at end of file diff --git a/test/test_suite14/strings/literal_hex_ok.c3 b/test/test_suite14/strings/literal_hex_ok.c3 deleted file mode 100644 index 943edca35..000000000 --- a/test/test_suite14/strings/literal_hex_ok.c3 +++ /dev/null @@ -1,3 +0,0 @@ -char bar1 = '\xaf'; -ichar bar2 = '\x0F'; -ushort bar4 = '\u0FaF'; diff --git a/test/test_suite14/strings/literal_to_subarray.c3t b/test/test_suite14/strings/literal_to_subarray.c3t deleted file mode 100644 index 15477a67d..000000000 --- a/test/test_suite14/strings/literal_to_subarray.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 - -char[] y = "hello"; - -fn void test() -{ - char[] x = "world"; -} - -/* #expect: literal_to_subarray.ll - -%"char[]" = type { i8*, i64 } -@.str = private unnamed_addr constant [6 x i8] c"hello\00", align 1 -@literal_to_subarray_y = local_unnamed_addr global %"char[]" { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 5 }, align 8 -@.str.1 = private unnamed_addr constant [6 x i8] c"world\00", align 1 -; Function Attrs: nounwind -define void @literal_to_subarray_test() #0 { -entry: - %x = alloca %"char[]", align 8 - store %"char[]" { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i64 5 }, %"char[]"* %x, align 8 - ret void -} diff --git a/test/test_suite14/strings/multiline_strings.c3t b/test/test_suite14/strings/multiline_strings.c3t deleted file mode 100644 index 5b087a023..000000000 --- a/test/test_suite14/strings/multiline_strings.c3t +++ /dev/null @@ -1,18 +0,0 @@ -// #target: macos-x64 - -// This will depend on platform source file line endings -char *message2 = ` - ``oh`` superman - where are you now? -`; - -char *message3 = "Hfo\u0044ke"; -char *message4 = "\x64\x6f\x63\x75\x6d\x65\x6e\x74"; - - -// #expect: multiline_strings.ll - - -@.str = private unnamed_addr constant [41 x i8] c"\0A `oh` superman\0A where are you now?\0A\00", align 1 -@.str.3 = private unnamed_addr constant [7 x i8] c"HfoDke\00", align 1 -@.str.4 = private unnamed_addr constant [9 x i8] c"document\00", align 1 \ No newline at end of file diff --git a/test/test_suite14/strings/string_escape.c3t b/test/test_suite14/strings/string_escape.c3t deleted file mode 100644 index 404136fa3..000000000 --- a/test/test_suite14/strings/string_escape.c3t +++ /dev/null @@ -1,22 +0,0 @@ -// #target: macos-x64 -fn void main() -{ - char *s = "Hello\0 world!" " now"; -} - -/* #expect: string_escape.ll - -@.str = private unnamed_addr constant [18 x i8] c"Hello\00 world! now\00", align 1 - -define void @string_escape_main() #0 { -entry: - %s = alloca i8*, align 8 - store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i32 0, i32 0), i8** %s, align 8 - ret void -} - -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @string_escape_main() - ret i32 0 -} \ No newline at end of file diff --git a/test/test_suite14/strings/string_len.c3t b/test/test_suite14/strings/string_len.c3t deleted file mode 100644 index e4594a8ea..000000000 --- a/test/test_suite14/strings/string_len.c3t +++ /dev/null @@ -1,7 +0,0 @@ -// #target: macos-x64 - -int i = "123".len; - -/* #expect: string_len.ll - -@string_len_i = local_unnamed_addr global i32 3, align 4 \ No newline at end of file diff --git a/test/test_suite14/strings/string_to_array.c3t b/test/test_suite14/strings/string_to_array.c3t deleted file mode 100644 index c5cdd6308..000000000 --- a/test/test_suite14/strings/string_to_array.c3t +++ /dev/null @@ -1,25 +0,0 @@ -// #target: macos-x64 -module foo; - -fn int main() -{ - char[2] x = "ab"; - char[*] y = "abc"; - return 0; -} - -/* #expect: foo.ll - -@.str = private unnamed_addr constant [3 x i8] c"ab\00", align 1 -@.str.1 = private unnamed_addr constant [4 x i8] c"abc\00", align 1 - -define i32 @main() #0 { -entry: - %x = alloca [2 x i8], align 1 - %y = alloca [3 x i8], align 1 - %0 = bitcast [2 x i8]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %0, i8* align 1 getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32 2, i1 false) - %1 = bitcast [3 x i8]* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %1, i8* align 1 getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 3, i1 false) - ret i32 0 -} diff --git a/test/test_suite14/struct/duplicate_member.c3 b/test/test_suite14/struct/duplicate_member.c3 deleted file mode 100644 index 345871af5..000000000 --- a/test/test_suite14/struct/duplicate_member.c3 +++ /dev/null @@ -1,69 +0,0 @@ -// @warnings{no-unused} -module test; - -struct Aa -{ - int a; - int a; // #error: Duplicate member name 'a' -} - -struct Bb -{ - int a; - struct a // #error: Duplicate member name 'a' - { - int b; - } -} - -union Cc -{ - int a; - int a; // #error: Duplicate member name 'a' - - struct b - { - int c; - int c; // #error: Duplicate member name 'c' - } -} - -struct Dd -{ - int b; - int a; - struct - { - union - { - short a; // #error: Duplicate member name 'a' - int b; // #error: Duplicate member name 'b' - } - } -} - -union Ee -{ - int a; - struct - { - short a; // #error: Duplicate member name 'a' - } -} - -struct Ff -{ - struct - { - int a; - } - struct b - { - int a; - } - union - { - int a; // #error: Duplicate member name 'a' - } -} - diff --git a/test/test_suite14/struct/flex_array_struct_err.c3 b/test/test_suite14/struct/flex_array_struct_err.c3 deleted file mode 100644 index 59faccf3b..000000000 --- a/test/test_suite14/struct/flex_array_struct_err.c3 +++ /dev/null @@ -1,31 +0,0 @@ -struct Foo -{ - int x; - int[*] y; // #error: flexible array member must be the last element - int z; -} - -struct Bar -{ - int[*] y; // #error: flexible array member cannot be the only element -} - -struct Baz -{ - int y; - int[*] z; -} - -struct BazContainerOk -{ - int z; - Baz c; -} - -struct BazContainer -{ - Baz c; // #error: A struct member with a flexible array must be the last element. - int y; -} - -Baz[5] ab; // #error: Arrays of structs with flexible array members is not allowed. \ No newline at end of file diff --git a/test/test_suite14/struct/func_return_struct.c3 b/test/test_suite14/struct/func_return_struct.c3 deleted file mode 100644 index 66ae003b3..000000000 --- a/test/test_suite14/struct/func_return_struct.c3 +++ /dev/null @@ -1,12 +0,0 @@ -struct Test -{ - int i; - short s1, s2; -} - -extern fn Test func_returning_struct(); - -fn void loop() -{ - func_returning_struct(); -} diff --git a/test/test_suite14/struct/member_access.c3 b/test/test_suite14/struct/member_access.c3 deleted file mode 100644 index c434fef35..000000000 --- a/test/test_suite14/struct/member_access.c3 +++ /dev/null @@ -1,87 +0,0 @@ -module test; - - -struct Multi -{ - int a, b, c; -} - -struct Point -{ - int a; - struct bb - { - int b; - } - struct - { - int b; - int c; - struct - { - Point* p; - } - } - union - { - int d; - short e; - } - union uu { - int d; - ushort e; - } -} - - -fn void tester() -{ - Multi m; - m.a = 1; - Point p; - p.a = 1; - p.bb.b = 2; - p.b = 3; - p.c = 4; - p.p = null; - p.d = 5; - p.e = 6; - p.uu.d = 7; - p.uu.e = 8; - Point *p2 = &p; - p2.bb.b = 3; - p = { .a = 1, .bb.b = 3, .e = 2 }; - - Point* pp = &p; - pp.a = 20; -} - -struct Aa1 -{ - struct bb - { - int b; - } - struct - { - int c; - } -} - -fn void test_conversion_struct() -{ - Aa1 a1; - int aa = a1.bb; // #error: 'bb' into 'int' -} - -struct Struct -{ - int a; -} - -fn void myfunc() -{ - Struct s; - s.b = 10; // #error: There is no field or method 'Struct.b' -} - diff --git a/test/test_suite14/struct/member_expr.c3 b/test/test_suite14/struct/member_expr.c3 deleted file mode 100644 index 77782deda..000000000 --- a/test/test_suite14/struct/member_expr.c3 +++ /dev/null @@ -1,31 +0,0 @@ - -define Func = fn int(int); - -define Func2 = fn int(Foo*, int); - -struct Foo -{ - int a; - Func callback; -} - -fn int Foo.func2(Foo* f, int i) -{ - return f.a + i; -} - -fn void test_unknown_member() -{ - int a = Foo.b; // #error: No method or inner struct/union 'Foo.b' found. -} - - -fn void test_nonstatic_stuct_func1() -{ - Func2 a = &Foo.func2; -} - -fn void test_nonstatic_stuct_func2() -{ - int b = Foo.func2(null, 2); -} diff --git a/test/test_suite14/struct/nested_struct_init.c3t b/test/test_suite14/struct/nested_struct_init.c3t deleted file mode 100644 index fff61d8fc..000000000 --- a/test/test_suite14/struct/nested_struct_init.c3t +++ /dev/null @@ -1,89 +0,0 @@ -// #target: macos-x64 -module foo; -import libc; - -struct Matrix2x2 -{ - union - { - struct { - float m00, m01, m10, m11; - } - float[4] m; - } -} - -struct Matrix2x2_b -{ - union - { - float[4] m; - struct { - float m00, m01, m10, m11; - } - } -} - -fn void main() -{ - Matrix2x2 m = { 1, 2, 3, 4 }; - Matrix2x2_b m2 = { { 1, 2, 3, 4 } }; - libc::printf("%f %f %f %f\n", m.m00, m.m[1], m.m10, m.m[3]); -} -/* #expect: foo.ll - -%Matrix2x2 = type { %.anon } -%.anon = type { %.anon.0 } -%.anon.0 = type { float, float, float, float } -%Matrix2x2_b = type { %.anon.1 } -%.anon.1 = type { [4 x float] } - -@"ct$foo_$anon" = linkonce constant %.introspect { i8 10, i64 16, i64 0, i64 4, [0 x i64] zeroinitializer }, align 8 -@"ct$foo_$anon.3" = linkonce constant %.introspect { i8 11, i64 16, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"ct$foo_Matrix2x2" = linkonce constant %.introspect { i8 10, i64 16, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8 -@"ct$foo_$anon.6" = linkonce constant %.introspect { i8 10, i64 16, i64 0, i64 4, [0 x i64] zeroinitializer }, align 8 -@"ct$foo_$anon.7" = linkonce constant %.introspect { i8 11, i64 16, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@"ct$foo_Matrix2x2_b" = linkonce constant %.introspect { i8 10, i64 16, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8 -@.__const = private unnamed_addr constant %Matrix2x2 { %.anon { %.anon.0 { float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00 } } }, align 4 -@.__const.8 = private unnamed_addr constant %Matrix2x2_b { %.anon.1 { [4 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00] } }, align 4 -@.str = private unnamed_addr constant [13 x i8] c"%f %f %f %f\0A\00", align 1 - -; Function Attrs: nounwind -define void @foo_main() #0 { -entry: - %m = alloca %Matrix2x2, align 4 - %m2 = alloca %Matrix2x2_b, align 4 - %0 = bitcast %Matrix2x2* %m to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%Matrix2x2* @.__const to i8*), i32 16, i1 false) - %1 = bitcast %Matrix2x2_b* %m2 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 bitcast (%Matrix2x2_b* @.__const.8 to i8*), i32 16, i1 false) - %2 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %m, i32 0, i32 0 - %3 = bitcast %.anon* %2 to %.anon.0* - %4 = getelementptr inbounds %.anon.0, %.anon.0* %3, i32 0, i32 0 - %5 = load float, float* %4, align 4 - %fpfpext = fpext float %5 to double - %6 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %m, i32 0, i32 0 - %7 = bitcast %.anon* %6 to [4 x float]* - %8 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1 - %9 = load float, float* %8, align 4 - %fpfpext1 = fpext float %9 to double - %10 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %m, i32 0, i32 0 - %11 = bitcast %.anon* %10 to %.anon.0* - %12 = getelementptr inbounds %.anon.0, %.anon.0* %11, i32 0, i32 2 - %13 = load float, float* %12, align 4 - %fpfpext2 = fpext float %13 to double - %14 = getelementptr inbounds %Matrix2x2, %Matrix2x2* %m, i32 0, i32 0 - %15 = bitcast %.anon* %14 to [4 x float]* - %16 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 3 - %17 = load float, float* %16, align 4 - %fpfpext3 = fpext float %17 to double - %18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), double %fpfpext, double %fpfpext1, double %fpfpext2, double %fpfpext3) - ret void -} - -; Function Attrs: nounwind -define i32 @main(i32 %0, i8** %1) #0 { -entry: - call void @foo_main() - ret i32 0 -} \ No newline at end of file diff --git a/test/test_suite14/struct/nested_struct_union_init.c3t b/test/test_suite14/struct/nested_struct_union_init.c3t deleted file mode 100644 index 3b78a2e60..000000000 --- a/test/test_suite14/struct/nested_struct_union_init.c3t +++ /dev/null @@ -1,116 +0,0 @@ -// #target: macos-x64 -module foob; -import libc; -struct Matrix2x2 -{ - union - { - float[4] m; - struct { - float m00, m01, m10, m11; - } - } -} - -struct Matrix2x2_b -{ - union - { - struct { - float m00, m01, m10, m11; - } - float[4] m; - } -} -struct Matrix4x4 { - union { - struct { - float m00, m01, m02, m03; - float m10, m11, m12, m13; - float m20, m21, m22, m23; - float m30, m31, m32, m33; - } - float[16] m; - } -} - - -struct Matrix3x3 { - union { - struct { - float m00, m01, m02, m10, m11, m12, m20, m21, m22; - } - float[9] m; - } -} -fn void main() -{ - Matrix3x3 x = { 1, 2, 3, 4, 5, 6, 7,8 ,9}; - Matrix2x2 m = { float[4] { 1, 2, 3, 4 } }; - Matrix2x2_b m2 = { 1, 2, 3, 4 }; - libc::printf("%f %f %f %f\n", x.m00, x.m[1], x.m10, x.m[3]); -} - -/* #expect: foob.ll - -%Matrix2x2 = type { %.anon.1 } -%.anon.1 = type { [4 x float] } -%Matrix2x2_b = type { %.anon.2 } -%.anon.2 = type { %.anon.3 } -%.anon.3 = type { float, float, float, float } -%Matrix3x3 = type { %.anon } -%.anon = type { %.anon.0 } -%.anon.0 = type { float, float, float, float, float, float, float, float, float } - -define void @foob_main() #0 { -entry: - %x = alloca %Matrix3x3, align 4 - %m = alloca %Matrix2x2, align 4 - %m2 = alloca %Matrix2x2_b, align 4 - %0 = getelementptr inbounds %Matrix3x3, %Matrix3x3* %x, i32 0, i32 0 - %1 = bitcast %.anon* %0 to %.anon.0* - %2 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 0 - store float 1.000000e+00, float* %2, align 4 - %3 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 1 - store float 2.000000e+00, float* %3, align 4 - %4 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 2 - store float 3.000000e+00, float* %4, align 4 - %5 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 3 - store float 4.000000e+00, float* %5, align 4 - %6 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 4 - store float 5.000000e+00, float* %6, align 4 - %7 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 5 - store float 6.000000e+00, float* %7, align 4 - %8 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 6 - store float 7.000000e+00, float* %8, align 4 - %9 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 7 - store float 8.000000e+00, float* %9, align 4 - %10 = getelementptr inbounds %.anon.0, %.anon.0* %1, i32 0, i32 8 - store float 9.000000e+00, float* %10, align 4 - %11 = bitcast %Matrix2x2* %m to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %11, i8* align 4 bitcast (%Matrix2x2* @.__const to i8*), i32 16, i1 false) - %12 = bitcast %Matrix2x2_b* %m2 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %12, i8* align 4 bitcast (%Matrix2x2_b* @.__const.16 to i8*), i32 16, i1 false) - %13 = getelementptr inbounds %Matrix3x3, %Matrix3x3* %x, i32 0, i32 0 - %14 = bitcast %.anon* %13 to %.anon.0* - %15 = getelementptr inbounds %.anon.0, %.anon.0* %14, i32 0, i32 0 - %16 = load float, float* %15, align 4 - %fpfpext = fpext float %16 to double - %17 = getelementptr inbounds %Matrix3x3, %Matrix3x3* %x, i32 0, i32 0 - %18 = bitcast %.anon* %17 to [9 x float]* - %19 = getelementptr inbounds [9 x float], [9 x float]* %18, i64 0, i64 1 - %20 = load float, float* %19, align 4 - %fpfpext1 = fpext float %20 to double - %21 = getelementptr inbounds %Matrix3x3, %Matrix3x3* %x, i32 0, i32 0 - %22 = bitcast %.anon* %21 to %.anon.0* - %23 = getelementptr inbounds %.anon.0, %.anon.0* %22, i32 0, i32 3 - %24 = load float, float* %23, align 4 - %fpfpext2 = fpext float %24 to double - %25 = getelementptr inbounds %Matrix3x3, %Matrix3x3* %x, i32 0, i32 0 - %26 = bitcast %.anon* %25 to [9 x float]* - %27 = getelementptr inbounds [9 x float], [9 x float]* %26, i64 0, i64 3 - %28 = load float, float* %27, align 4 - %fpfpext3 = fpext float %28 to double - %29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), double %fpfpext, double %fpfpext1, double %fpfpext2, double %fpfpext3) - ret void -} diff --git a/test/test_suite14/struct/recursive_structs.c3 b/test/test_suite14/struct/recursive_structs.c3 deleted file mode 100644 index 19dbbf06a..000000000 --- a/test/test_suite14/struct/recursive_structs.c3 +++ /dev/null @@ -1,25 +0,0 @@ -struct Test1 -{ - Test1 *x; -} - -struct Test2 -{ - Test2[] y; -} - -struct Test3 // #error: Recursive definition -{ - Test3[4] z; -} - -struct Test4 -{ - Test4[3]* w; -} - - -struct Test5 -{ - Test5[3][] w; -} diff --git a/test/test_suite14/struct/simple_struct.c3t b/test/test_suite14/struct/simple_struct.c3t deleted file mode 100644 index fe64e4641..000000000 --- a/test/test_suite14/struct/simple_struct.c3t +++ /dev/null @@ -1,14 +0,0 @@ -module test; - -private Foo a; - -struct Foo -{ - int x; - double a; -} - -// #expect: test.ll - -%Foo = type { i32, double } -@test_a = protected unnamed_addr global %Foo zeroinitializer, align 8 \ No newline at end of file diff --git a/test/test_suite14/struct/sret.c3t b/test/test_suite14/struct/sret.c3t deleted file mode 100644 index a96701630..000000000 --- a/test/test_suite14/struct/sret.c3t +++ /dev/null @@ -1,26 +0,0 @@ -// #target: macos-x64 -struct Abc -{ - long a; - long b; - long c; - long d; - long e; -} - -extern fn Abc foo1(); -extern fn Abc foo2(); - -fn void bar() -{ - Abc dummy1 = foo1(); - Abc dummy2 = foo2(); -} - - -/* #expect: sret.ll - -sret(%Abc) -sret(%Abc) -sret(%Abc) -sret(%Abc) \ No newline at end of file diff --git a/test/test_suite14/struct/struct_as_value.c3t b/test/test_suite14/struct/struct_as_value.c3t deleted file mode 100644 index c5d19f659..000000000 --- a/test/test_suite14/struct/struct_as_value.c3t +++ /dev/null @@ -1,50 +0,0 @@ -// #target: macos-x64 -module test; - -struct Event -{ - int op; -} - -fn Event test(int x) -{ - Event foo = { 1 }; - Event bar = { 2 }; - return x ? foo : bar; -} - -/* #expect: test.ll - -%Event = type { i32 } - -@"ct$test_Event" = linkonce constant %.introspect { i8 10, i64 4, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8 -@.__const = private unnamed_addr constant %Event { i32 1 }, align 4 -@.__const.1 = private unnamed_addr constant %Event { i32 2 }, align 4 - -define i32 @test_test(i32 %0) #0 { -entry: - %foo = alloca %Event, align 4 - %bar = alloca %Event, align 4 - %taddr = alloca %Event, align 4 - %1 = bitcast %Event* %foo to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 bitcast (%Event* @.__const to i8*), i32 4, i1 false) - %2 = bitcast %Event* %bar to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 4 bitcast (%Event* @.__const.1 to i8*), i32 4, i1 false) - %intbool = icmp ne i32 %0, 0 - br i1 %intbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - %3 = load %Event, %Event* %foo, align 4 - br label %cond.phi - -cond.rhs: ; preds = %entry - %4 = load %Event, %Event* %bar, align 4 - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %cond.lhs - %val = phi %Event [ %3, %cond.lhs ], [ %4, %cond.rhs ] - store %Event %val, %Event* %taddr, align 4 - %5 = getelementptr inbounds %Event, %Event* %taddr, i32 0, i32 0 - %6 = load i32, i32* %5, align 4 - ret i32 %6 -} diff --git a/test/test_suite14/struct/struct_as_value_aarch64.c3t b/test/test_suite14/struct/struct_as_value_aarch64.c3t deleted file mode 100644 index 43ed1c9e9..000000000 --- a/test/test_suite14/struct/struct_as_value_aarch64.c3t +++ /dev/null @@ -1,44 +0,0 @@ -// #target: linux-aarch64 -module test; - -struct Event -{ - int op; -} - -fn Event test(int x) -{ - Event foo = { 1 }; - Event bar = { 2 }; - return x ? foo : bar; -} - -/* #expect: test.ll - -define i32 @test_test(i32 %0) #0 { -entry: - %foo = alloca %Event, align 4 - %bar = alloca %Event, align 4 - %taddr = alloca %Event, align 4 - %1 = bitcast %Event* %foo to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 bitcast (%Event* @.__const to i8*), i32 4, i1 false) - %2 = bitcast %Event* %bar to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 4 bitcast (%Event* @.__const.1 to i8*), i32 4, i1 false) - %intbool = icmp ne i32 %0, 0 - br i1 %intbool, label %cond.lhs, label %cond.rhs - -cond.lhs: ; preds = %entry - %3 = load %Event, %Event* %foo, align 4 - br label %cond.phi - -cond.rhs: ; preds = %entry - %4 = load %Event, %Event* %bar, align 4 - br label %cond.phi - -cond.phi: ; preds = %cond.rhs, %cond.lhs - %val = phi %Event [ %3, %cond.lhs ], [ %4, %cond.rhs ] - store %Event %val, %Event* %taddr, align 4 - %5 = getelementptr inbounds %Event, %Event* %taddr, i32 0, i32 0 - %6 = load i32, i32* %5, align 4 - ret i32 %6 -} \ No newline at end of file diff --git a/test/test_suite14/struct/struct_codegen.c3t b/test/test_suite14/struct/struct_codegen.c3t deleted file mode 100644 index 4b2519125..000000000 --- a/test/test_suite14/struct/struct_codegen.c3t +++ /dev/null @@ -1,28 +0,0 @@ -// #target: macos-x64 -module test; - -struct Point -{ - int x; - int y; -} - -fn void test1() -{ - Point p = { 5, 6 }; -} - -/* #expect: test.ll - -%Point = type { i32, i32 } - -@"ct$test_Point" = linkonce constant %.introspect { i8 10, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@.__const = private unnamed_addr constant %Point { i32 5, i32 6 }, align 4 - -define void @test_test1() #0 { -entry: - %p = alloca %Point, align 4 - %0 = bitcast %Point* %p to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%Point* @.__const to i8*), i32 8, i1 false) - ret void -} diff --git a/test/test_suite14/struct/struct_codegen_empty.c3t b/test/test_suite14/struct/struct_codegen_empty.c3t deleted file mode 100644 index bdcc6c909..000000000 --- a/test/test_suite14/struct/struct_codegen_empty.c3t +++ /dev/null @@ -1,41 +0,0 @@ -// #target: macos-x64 -struct StructA -{ - int a; -} - -struct StructB -{ - struct b - { - int a; - } -} - -fn void test() -{ - StructA a = {}; - StructA a2; - StructB b = {}; - StructB b2; - StructB b3 = { .b = { } }; -} - -/* #expect: struct_codegen_empty.ll - - %a = alloca %StructA, align 4 - %a2 = alloca %StructA, align 4 - %b = alloca %StructB, align 4 - %b2 = alloca %StructB, align 4 - %b3 = alloca %StructB, align 4 - %0 = bitcast %StructA* %a to i32* - store i32 0, i32* %0, align 4 - %1 = bitcast %StructA* %a2 to i32* - store i32 0, i32* %1, align 4 - %2 = bitcast %StructB* %b to i32* - store i32 0, i32* %2, align 4 - %3 = bitcast %StructB* %b2 to i32* - store i32 0, i32* %3, align 4 - %4 = bitcast %StructB* %b3 to i32* - store i32 0, i32* %4, align 4 - ret void \ No newline at end of file diff --git a/test/test_suite14/struct/struct_codegen_fam.c3t b/test/test_suite14/struct/struct_codegen_fam.c3t deleted file mode 100644 index 68b9945a2..000000000 --- a/test/test_suite14/struct/struct_codegen_fam.c3t +++ /dev/null @@ -1,30 +0,0 @@ -// #target: macos-x64 -module foo; - -struct Bar -{ - struct - { - int y; - } - int ufe; - int[*] z; -} - - -fn void test(Bar b) -{ - b.z[1]; -} - -/* #expect: foo.ll - -%Bar = type { %.anon, i32, [0 x i32] } -%.anon = type { i32 } - -define void @foo_test(%Bar* byval(%Bar) align 8 %0) #0 { -entry: - %1 = getelementptr inbounds %Bar, %Bar* %0, i32 0, i32 2 - %2 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 1 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/struct/struct_const_construct_simple.c3t b/test/test_suite14/struct/struct_const_construct_simple.c3t deleted file mode 100644 index badb3449d..000000000 --- a/test/test_suite14/struct/struct_const_construct_simple.c3t +++ /dev/null @@ -1,33 +0,0 @@ -// #target: macos-x64 -module structo; - -struct Foo -{ - int foo; - long bar; -} - -private usz x = Foo.sizeof; - -private Foo foo1 = { 1, 2 }; -private Foo foo2 = { .foo = 2 }; -private Foo foo3 = { .bar = 3 }; -private Foo foo4 = { .bar = 4, .foo = 4, .bar = 1 }; -private Foo foo5 = {}; -private Foo foo6; -private const Foo FOO7 = { 1, 2 }; -private Foo foo8 = FOO7; - -/* #expect: structo.ll -%Foo = type { i32, i64 } - -@"ct$structo_Foo" = linkonce constant %.introspect { i8 10, i64 16, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8 -@structo_x = protected unnamed_addr global i64 16, align 8 -@structo_foo1 = protected unnamed_addr global %Foo { i32 1, i64 2 }, align 8 -@structo_foo2 = protected unnamed_addr global %Foo { i32 2, i64 0 }, align 8 -@structo_foo3 = protected unnamed_addr global %Foo { i32 0, i64 3 }, align 8 -@structo_foo4 = protected unnamed_addr global %Foo { i32 4, i64 1 }, align 8 -@structo_foo5 = protected unnamed_addr global %Foo zeroinitializer, align 8 -@structo_foo6 = protected unnamed_addr global %Foo zeroinitializer, align 8 -@structo_FOO7 = protected unnamed_addr constant %Foo { i32 1, i64 2 }, align 8 -@structo_foo8 = protected unnamed_addr global %Foo { i32 1, i64 2 }, align 8 diff --git a/test/test_suite14/struct/struct_pack_and_align.c3t b/test/test_suite14/struct/struct_pack_and_align.c3t deleted file mode 100644 index 3e868d33e..000000000 --- a/test/test_suite14/struct/struct_pack_and_align.c3t +++ /dev/null @@ -1,101 +0,0 @@ -// #target: macos-x64 - -module struct2; - -// <{ i64, i8, [3 x i8] }> -struct Foo1 @packed @align(4) -{ - long bar; - char foo; -} - -$assert(Foo1.sizeof == 12); -Foo1 foo1 = { 1, 2 }; - -// <{ i8, i64, [3 x i8] }> -struct Foo2 @packed @align(4) -{ - char foo; - long bar; -} - -$assert(Foo2.sizeof == 12); -Foo2 foo2 = { 1, 2 }; - -// <{ i8, i64, [7 x i8] }> -struct Foo3 @packed @align(8) -{ - char foo; - long bar; -} - -Foo3 foo3 = { 1, 2 }; -$assert(Foo3.sizeof == 16); - -// <{ i8, i64 }> -struct Foo4 @packed -{ - char foo; - long bar; -} - -$assert(Foo4.sizeof == 9); -Foo4 foo4 = { 1, 2 }; - -// { i32, [12 x i8], i8, [15 x i8] } -struct Foo5 -{ - int bar @align(16); - ichar foo @align(16); -} - -$assert(Foo5.sizeof == 32); -Foo5 foo5 = { 1, 2 }; - -fn int test5(ichar x) -{ - Foo5 y = { .foo = x }; - return y.foo + y.bar; -} - -// { i32, i16, i16 } -struct Foo6 @packed -{ - int a; - short b; - short c; -} - -$assert(Foo6.sizeof == 8); -Foo6 foo6 = { 1, 2, 3 }; - -/* #expect: struct2.ll - -%Foo1 = type <{ i64, i8, [3 x i8] }> -%Foo2 = type <{ i8, i64, [3 x i8] }> -%Foo3 = type <{ i8, i64, [7 x i8] }> -%Foo4 = type <{ i8, i64 }> -%Foo5 = type { i32, [12 x i8], i8, [15 x i8] } -%Foo6 = type { i32, i16, i16 } - -@struct2_foo1 = local_unnamed_addr global %Foo1 <{ i64 1, i8 2, [3 x i8] undef }>, align 4 -@struct2_foo2 = local_unnamed_addr global %Foo2 <{ i8 1, i64 2, [3 x i8] undef }>, align 4 -@struct2_foo3 = local_unnamed_addr global %Foo3 <{ i8 1, i64 2, [7 x i8] undef }>, align 8 -@struct2_foo4 = local_unnamed_addr global %Foo4 <{ i8 1, i64 2 }>, align 1 -@struct2_foo5 = local_unnamed_addr global %Foo5 { i32 1, [12 x i8] undef, i8 2, [15 x i8] undef }, align 16 -@struct2_foo6 = local_unnamed_addr global %Foo6 { i32 1, i16 2, i16 3 }, align 1 - -define i32 @struct2_test5(i8 signext %0) #0 { -entry: - %y = alloca %Foo5, align 16 - %1 = bitcast %Foo5* %y to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 32, i1 false) - %2 = getelementptr inbounds %Foo5, %Foo5* %y, i32 0, i32 2 - store i8 %0, i8* %2, align 16 - %3 = getelementptr inbounds %Foo5, %Foo5* %y, i32 0, i32 2 - %4 = load i8, i8* %3, align 16 - %sisiext = sext i8 %4 to i32 - %5 = getelementptr inbounds %Foo5, %Foo5* %y, i32 0, i32 0 - %6 = load i32, i32* %5, align 16 - %add = add i32 %sisiext, %6 - ret i32 %add diff --git a/test/test_suite14/struct/struct_params.c3 b/test/test_suite14/struct/struct_params.c3 deleted file mode 100644 index 8a4bd2f69..000000000 --- a/test/test_suite14/struct/struct_params.c3 +++ /dev/null @@ -1,27 +0,0 @@ -module test; - -struct Foo -{ - char p; - short q; - char r; - int x; - short y, z; - int q2; -} - -extern fn int test(Foo, float); -extern fn int testE(char,short,char,int,int,float); - -fn void test3(Foo *x) -{ - x.q = 1; -} - -fn void test2(Foo y) -{ - testE(y.p, y.q, y.r, y.x, y.y, 0.1); - test(y, 0.1); - test2(y); - test3(&y); -} diff --git a/test/test_suite14/struct/zero_member.c3 b/test/test_suite14/struct/zero_member.c3 deleted file mode 100644 index 98496e0d2..000000000 --- a/test/test_suite14/struct/zero_member.c3 +++ /dev/null @@ -1,7 +0,0 @@ -define Foo = int[0]; // #error: An array may not have zero - -struct Bar -{ - Foo x; - int b; -} \ No newline at end of file diff --git a/test/test_suite14/subarrays/slice_comparison.c3t b/test/test_suite14/subarrays/slice_comparison.c3t deleted file mode 100644 index 1d55c5ff6..000000000 --- a/test/test_suite14/subarrays/slice_comparison.c3t +++ /dev/null @@ -1,233 +0,0 @@ -// #target: macos-x64 - -module mymodule; - -extern fn void printf(char *, ...); - -fn void main() -{ - - char[] y = "hodo"; - char[] z = "hodo"; - if (y == "hodo") - { - printf("This works\n"); - } - if (y == z) - { - printf("This works too\n"); - } - switch (y) - { - case "mixx": - printf("Wut\n"); - case "hodot": - printf("Nope\n"); - case "hodo": - printf("Winning!\n"); - default: - printf("Hodohell\n"); - } - -} - -// #expect: mymodule.ll - -define void @mymodule_main() #0 { -entry: - %y = alloca %"char[]", align 8 - %z = alloca %"char[]", align 8 - %cmp.idx = alloca i64, align 8 - %cmp.idx5 = alloca i64, align 8 - %switch = alloca %"char[]", align 8 - %cmp.idx18 = alloca i64, align 8 - %cmp.idx29 = alloca i64, align 8 - %cmp.idx42 = alloca i64, align 8 - store %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i64 4 }, %"char[]"* %y, align 8 - store %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i64 4 }, %"char[]"* %z, align 8 - %0 = load %"char[]", %"char[]"* %y, align 8 - %1 = extractvalue %"char[]" %0, 1 - %2 = extractvalue %"char[]" %0, 0 - %eq = icmp eq i64 %1, 4 - br i1 %eq, label %subarray_cmp_values, label %subarray_cmp_exit - -subarray_cmp_values: ; preds = %entry - store i64 0, i64* %cmp.idx, align 8 - br label %subarray_loop_start - -subarray_loop_start: ; preds = %subarray_loop_comparison, %subarray_cmp_values - %3 = load i64, i64* %cmp.idx, align 8 - %lt = icmp ult i64 %3, %1 - br i1 %lt, label %subarray_loop_comparison, label %subarray_cmp_exit - -subarray_loop_comparison: ; preds = %subarray_loop_start - %ptroffset = getelementptr inbounds i8, i8* %2, i64 %3 - %ptroffset1 = getelementptr inbounds i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i64 %3 - %4 = load i8, i8* %ptroffset, align 1 - %5 = load i8, i8* %ptroffset1, align 1 - %eq2 = icmp eq i8 %4, %5 - %6 = add i64 %3, 1 - store i64 %6, i64* %cmp.idx, align 8 - br i1 %eq2, label %subarray_loop_start, label %subarray_cmp_exit - -subarray_cmp_exit: ; preds = %subarray_loop_comparison, %subarray_loop_start, %entry - %subarray_cmp_phi = phi i1 [ true, %subarray_loop_start ], [ false, %entry ], [ false, %subarray_loop_comparison ] - br i1 %subarray_cmp_phi, label %if.then, label %if.exit - -if.then: ; preds = %subarray_cmp_exit - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0)) - br label %if.exit - -if.exit: ; preds = %if.then, %subarray_cmp_exit - %7 = load %"char[]", %"char[]"* %y, align 8 - %8 = load %"char[]", %"char[]"* %z, align 8 - %9 = extractvalue %"char[]" %7, 1 - %10 = extractvalue %"char[]" %8, 1 - %11 = extractvalue %"char[]" %7, 0 - %12 = extractvalue %"char[]" %8, 0 - %eq3 = icmp eq i64 %9, %10 - br i1 %eq3, label %subarray_cmp_values4, label %subarray_cmp_exit12 - -subarray_cmp_values4: ; preds = %if.exit - store i64 0, i64* %cmp.idx5, align 8 - br label %subarray_loop_start6 - -subarray_loop_start6: ; preds = %subarray_loop_comparison8, %subarray_cmp_values4 - %13 = load i64, i64* %cmp.idx5, align 8 - %lt7 = icmp ult i64 %13, %9 - br i1 %lt7, label %subarray_loop_comparison8, label %subarray_cmp_exit12 - -subarray_loop_comparison8: ; preds = %subarray_loop_start6 - %ptroffset9 = getelementptr inbounds i8, i8* %11, i64 %13 - %ptroffset10 = getelementptr inbounds i8, i8* %12, i64 %13 - %14 = load i8, i8* %ptroffset9, align 1 - %15 = load i8, i8* %ptroffset10, align 1 - %eq11 = icmp eq i8 %14, %15 - %16 = add i64 %13, 1 - store i64 %16, i64* %cmp.idx5, align 8 - br i1 %eq11, label %subarray_loop_start6, label %subarray_cmp_exit12 - -subarray_cmp_exit12: ; preds = %subarray_loop_comparison8, %subarray_loop_start6, %if.exit - %subarray_cmp_phi13 = phi i1 [ true, %subarray_loop_start6 ], [ false, %if.exit ], [ false, %subarray_loop_comparison8 ] - br i1 %subarray_cmp_phi13, label %if.then14, label %if.exit15 - -if.then14: ; preds = %subarray_cmp_exit12 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0)) - br label %if.exit15 - -if.exit15: ; preds = %if.then14, %subarray_cmp_exit12 - %17 = bitcast %"char[]"* %switch to i8* - %18 = bitcast %"char[]"* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %17, i8* align 8 %18, i32 16, i1 false) - br label %switch.entry - -switch.entry: ; preds = %if.exit15 - %19 = load %"char[]", %"char[]"* %switch, align 8 - %20 = extractvalue %"char[]" %19, 1 - %21 = extractvalue %"char[]" %19, 0 - %eq16 = icmp eq i64 4, %20 - br i1 %eq16, label %subarray_cmp_values17, label %subarray_cmp_exit25 - -subarray_cmp_values17: ; preds = %switch.entry - store i64 0, i64* %cmp.idx18, align 8 - br label %subarray_loop_start19 - -subarray_loop_start19: ; preds = %subarray_loop_comparison21, %subarray_cmp_values17 - %22 = load i64, i64* %cmp.idx18, align 8 - %lt20 = icmp ult i64 %22, 4 - br i1 %lt20, label %subarray_loop_comparison21, label %subarray_cmp_exit25 - -subarray_loop_comparison21: ; preds = %subarray_loop_start19 - %ptroffset22 = getelementptr inbounds i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i64 %22 - %ptroffset23 = getelementptr inbounds i8, i8* %21, i64 %22 - %23 = load i8, i8* %ptroffset22, align 1 - %24 = load i8, i8* %ptroffset23, align 1 - %eq24 = icmp eq i8 %23, %24 - %25 = add i64 %22, 1 - store i64 %25, i64* %cmp.idx18, align 8 - br i1 %eq24, label %subarray_loop_start19, label %subarray_cmp_exit25 - -subarray_cmp_exit25: ; preds = %subarray_loop_comparison21, %subarray_loop_start19, %switch.entry - %subarray_cmp_phi26 = phi i1 [ true, %subarray_loop_start19 ], [ false, %switch.entry ], [ false, %subarray_loop_comparison21 ] - br i1 %subarray_cmp_phi26, label %switch.case, label %next_if - -switch.case: ; preds = %subarray_cmp_exit25 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0)) - br label %switch.exit - -next_if: ; preds = %subarray_cmp_exit25 - %26 = extractvalue %"char[]" %19, 1 - %27 = extractvalue %"char[]" %19, 0 - %eq27 = icmp eq i64 5, %26 - br i1 %eq27, label %subarray_cmp_values28, label %subarray_cmp_exit36 - -subarray_cmp_values28: ; preds = %next_if - store i64 0, i64* %cmp.idx29, align 8 - br label %subarray_loop_start30 - -subarray_loop_start30: ; preds = %subarray_loop_comparison32, %subarray_cmp_values28 - %28 = load i64, i64* %cmp.idx29, align 8 - %lt31 = icmp ult i64 %28, 5 - br i1 %lt31, label %subarray_loop_comparison32, label %subarray_cmp_exit36 - -subarray_loop_comparison32: ; preds = %subarray_loop_start30 - %ptroffset33 = getelementptr inbounds i8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i64 %28 - %ptroffset34 = getelementptr inbounds i8, i8* %27, i64 %28 - %29 = load i8, i8* %ptroffset33, align 1 - %30 = load i8, i8* %ptroffset34, align 1 - %eq35 = icmp eq i8 %29, %30 - %31 = add i64 %28, 1 - store i64 %31, i64* %cmp.idx29, align 8 - br i1 %eq35, label %subarray_loop_start30, label %subarray_cmp_exit36 - -subarray_cmp_exit36: ; preds = %subarray_loop_comparison32, %subarray_loop_start30, %next_if - %subarray_cmp_phi37 = phi i1 [ true, %subarray_loop_start30 ], [ false, %next_if ], [ false, %subarray_loop_comparison32 ] - br i1 %subarray_cmp_phi37, label %switch.case38, label %next_if39 - -switch.case38: ; preds = %subarray_cmp_exit36 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0)) - br label %switch.exit - -next_if39: ; preds = %subarray_cmp_exit36 - %32 = extractvalue %"char[]" %19, 1 - %33 = extractvalue %"char[]" %19, 0 - %eq40 = icmp eq i64 4, %32 - br i1 %eq40, label %subarray_cmp_values41, label %subarray_cmp_exit49 - -subarray_cmp_values41: ; preds = %next_if39 - store i64 0, i64* %cmp.idx42, align 8 - br label %subarray_loop_start43 - -subarray_loop_start43: ; preds = %subarray_loop_comparison45, %subarray_cmp_values41 - %34 = load i64, i64* %cmp.idx42, align 8 - %lt44 = icmp ult i64 %34, 4 - br i1 %lt44, label %subarray_loop_comparison45, label %subarray_cmp_exit49 - -subarray_loop_comparison45: ; preds = %subarray_loop_start43 - %ptroffset46 = getelementptr inbounds i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i64 %34 - %ptroffset47 = getelementptr inbounds i8, i8* %33, i64 %34 - %35 = load i8, i8* %ptroffset46, align 1 - %36 = load i8, i8* %ptroffset47, align 1 - %eq48 = icmp eq i8 %35, %36 - %37 = add i64 %34, 1 - store i64 %37, i64* %cmp.idx42, align 8 - br i1 %eq48, label %subarray_loop_start43, label %subarray_cmp_exit49 - -subarray_cmp_exit49: ; preds = %subarray_loop_comparison45, %subarray_loop_start43, %next_if39 - %subarray_cmp_phi50 = phi i1 [ true, %subarray_loop_start43 ], [ false, %next_if39 ], [ false, %subarray_loop_comparison45 ] - br i1 %subarray_cmp_phi50, label %switch.case51, label %next_if52 - -switch.case51: ; preds = %subarray_cmp_exit49 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0)) - br label %switch.exit - -next_if52: ; preds = %subarray_cmp_exit49 - br label %switch.default - -switch.default: ; preds = %next_if52 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.default, %switch.case51, %switch.case38, %switch.case - ret void -} \ No newline at end of file diff --git a/test/test_suite14/subarrays/slice_negative_len.c3 b/test/test_suite14/subarrays/slice_negative_len.c3 deleted file mode 100644 index e9e44f2f7..000000000 --- a/test/test_suite14/subarrays/slice_negative_len.c3 +++ /dev/null @@ -1,72 +0,0 @@ -fn void test() -{ - int[3] x = { 1, 2, 3}; - int[] z = x[2..2]; - z = x[2..1]; // #error: Start index greater than end index. -} - -fn void test2() -{ - int[3] x = { 1, 2, 3}; - int[] z = x[^2..^2]; - z = x[^3..]; - z = x[^1..^2]; // #error: Start index greater than end index. -} - -fn void test3() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[..4]; // #error: End index out of bounds, was 4, exceeding 3. -} - -fn void test4() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[..^1]; - z = x[..^-1]; // #error: Negative numbers are not allowed when indexing from the end. -} - -fn void test5() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[..^4]; // #error: Index out of bounds, using a negative index is only allowed for pointers. -} - -fn void test6() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[3..]; // #error: Index out of bounds, was 3, exceeding maximum (2). -} - -fn void test7() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[-1..]; // #error: Index out of bounds, using a negative index is only allowed for pointers. -} - -fn void test8() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[^4..]; // #error: Index out of bounds, using a negative index is only allowed for pointers. -} - -fn void test9() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[^0..]; // #error: Index out of bounds, was 3, exceeding maximum (2) -} - -fn void test10() -{ - int* x = null; - x[-10..-3]; - int[] w = x[0..]; // #error: Omitting end index is not allowed for pointers. - int[] z = x[^2..]; // #error: Indexing from the end is not allowed for pointers. - int[] y = x[..^2]; // #error: Indexing from the end is not allowed for pointers. -} - -fn void test11() -{ - int[3] x = { 1, 2, 3 }; - int[] z = x[..^0]; // #error: End index out of bounds, was 3, exceeding 3. -} diff --git a/test/test_suite14/subarrays/slice_offset.c3t b/test/test_suite14/subarrays/slice_offset.c3t deleted file mode 100644 index 8b4aeff47..000000000 --- a/test/test_suite14/subarrays/slice_offset.c3t +++ /dev/null @@ -1,16 +0,0 @@ -fn void test() -{ - int[3] x = { 1, 2, 3 }; - int[] y = x[1..2]; -} - -// #expect: slice_offset.ll - - %x = alloca [3 x i32], align 4 - %y = alloca %"int[]", align 8 - %0 = bitcast [3 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - %2 = insertvalue %"int[]" undef, i32* %1, 0 - %3 = insertvalue %"int[]" %2, i64 2, 1 - store %"int[]" %3, %"int[]"* %y, align 8 diff --git a/test/test_suite14/subarrays/slice_offset_neg_end.c3t b/test/test_suite14/subarrays/slice_offset_neg_end.c3t deleted file mode 100644 index 5e33af0f3..000000000 --- a/test/test_suite14/subarrays/slice_offset_neg_end.c3t +++ /dev/null @@ -1,18 +0,0 @@ - -fn void test() -{ - int[3] x = { 1, 2, 3 }; - int[] y = x[1..^1]; -} - -// #expect: slice_offset_neg_end.ll - - %x = alloca [3 x i32], align 4 - %y = alloca %"int[]", align 8 - %0 = bitcast [3 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - %2 = insertvalue %"int[]" undef, i32* %1, 0 - %3 = insertvalue %"int[]" %2, i64 2, 1 - store %"int[]" %3, %"int[]"* %y, align 8 - diff --git a/test/test_suite14/subarrays/slice_offset_neg_start.c3t b/test/test_suite14/subarrays/slice_offset_neg_start.c3t deleted file mode 100644 index 13a406179..000000000 --- a/test/test_suite14/subarrays/slice_offset_neg_start.c3t +++ /dev/null @@ -1,16 +0,0 @@ -fn void test() -{ - int[3] x = { 1, 2, 3 }; - int[] y = x[^2..1]; -} - -// #expect: slice_offset_neg_start.ll - - %x = alloca [3 x i32], align 4 - %y = alloca %"int[]", align 8 - %0 = bitcast [3 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 1 - %2 = insertvalue %"int[]" undef, i32* %1, 0 - %3 = insertvalue %"int[]" %2, i64 1, 1 - store %"int[]" %3, %"int[]"* %y, align 8 diff --git a/test/test_suite14/subarrays/slice_start.c3t b/test/test_suite14/subarrays/slice_start.c3t deleted file mode 100644 index 6f94e5d7c..000000000 --- a/test/test_suite14/subarrays/slice_start.c3t +++ /dev/null @@ -1,16 +0,0 @@ -fn void test() -{ - int[3] x = { 1, 2, 3 }; - int[] y = x[..]; -} - -// #expect: slice_start.ll - - %x = alloca [3 x i32], align 4 - %y = alloca %"int[]", align 8 - %0 = bitcast [3 x i32]* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false) - %1 = getelementptr inbounds [3 x i32], [3 x i32]* %x, i64 0, i64 0 - %2 = insertvalue %"int[]" undef, i32* %1, 0 - %3 = insertvalue %"int[]" %2, i64 3, 1 - store %"int[]" %3, %"int[]"* %y, align 8 diff --git a/test/test_suite14/subarrays/slice_syntax.c3 b/test/test_suite14/subarrays/slice_syntax.c3 deleted file mode 100644 index e4f3f641c..000000000 --- a/test/test_suite14/subarrays/slice_syntax.c3 +++ /dev/null @@ -1,24 +0,0 @@ -fn void test() -{ - int[6] feok2 = { 1, 8, 100, 293, 23982, 34}; - int[] feok = &feok2; - int[] flok = feok2[3..5]; - int[] flak = flok[1..2]; - flok = feok2[..5]; - flok = feok2[..^2]; - flok = feok2[..]; - flok = feok2[^3..]; - flok = feok2[^4..5]; - flok = feok2[2..^2]; - flok = feok2[^3..^1]; - flok = feok2[..]; - flak = flok[..6]; - flak = flok[..^2]; - flak = flok[..]; - flak = flok[^3..]; - flak = flok[^4..5]; - flak = flok[2..^2]; - flak = flok[^3..^1]; - int* p = null; - // TODO p[-1..20]; -} \ No newline at end of file diff --git a/test/test_suite14/subarrays/sub_array_init.c3 b/test/test_suite14/subarrays/sub_array_init.c3 deleted file mode 100644 index 72b6d5698..000000000 --- a/test/test_suite14/subarrays/sub_array_init.c3 +++ /dev/null @@ -1,7 +0,0 @@ -fn void test2() -{ - int[2] a = { 1, 2 }; - - int[2] b = 30; // #error: 'int[2]' - int[2] c = a; -} diff --git a/test/test_suite14/switch/failable_switch.c3 b/test/test_suite14/switch/failable_switch.c3 deleted file mode 100644 index 4bc2d2197..000000000 --- a/test/test_suite14/switch/failable_switch.c3 +++ /dev/null @@ -1,14 +0,0 @@ -fault MyError -{ - FOO -} - -fn void test() -{ - int x = 0; - switch (x) - { - case MyError.FOO!: // #error: cannot be converted - x = x + 1; - } -} \ No newline at end of file diff --git a/test/test_suite14/symbols/allow_local_shadowing.c3 b/test/test_suite14/symbols/allow_local_shadowing.c3 deleted file mode 100644 index 802eaf090..000000000 --- a/test/test_suite14/symbols/allow_local_shadowing.c3 +++ /dev/null @@ -1,10 +0,0 @@ -int foo; - -fn void x() -{ - double foo = 123; -} - -fn void y(int foo) -{ -} \ No newline at end of file diff --git a/test/test_suite14/symbols/shadow_struct.c3 b/test/test_suite14/symbols/shadow_struct.c3 deleted file mode 100644 index 72b36f698..000000000 --- a/test/test_suite14/symbols/shadow_struct.c3 +++ /dev/null @@ -1,15 +0,0 @@ -struct Foo -{ - Foo *x; - int y; -} - -define Foo = float; // #error: shadow a previous declaration - -enum Bar -{ - TEST1, - TEST2 -} - -define Bar = float; // #error: shadow a previous declaration \ No newline at end of file diff --git a/test/test_suite14/symbols/various.c3 b/test/test_suite14/symbols/various.c3 deleted file mode 100644 index 2dd2fe1e9..000000000 --- a/test/test_suite14/symbols/various.c3 +++ /dev/null @@ -1,186 +0,0 @@ -module test; - -fn void test1() -{ - char a = 1; - int b = 2; - char c = b > a ? 1 : 0; -} - -fn void test2() -{ - char a = 1; - char b = 2; - char c = a + b; -} - -fn void test3() -{ - ichar a = 1; - int b = 2; - ichar c = a + b; // #error: 'ichar' -} - -fn void test4() -{ - char a = 1; - char b = 2; - int c = a + b; -} - -fn void test5() -{ - char a = 1; - int b = 2; - int c = a + b; -} - - -fn void test6() -{ - char a = 1; - char b = 2; - char c = (b > a) ? 1 : 0 + a + b; -} - -fn void test7() -{ - int[100] array = { }; - int v = array[1]; -} - -define Number = int; - -fn void test8() -{ - Number a = 10; - ichar c = a; // #error: 'Number' (int) -} - - -fn void test9() -{ - const char A = 1; - char b = A; - A = b; // #error: You cannot assign to a constant -} - -fn void test10() -{ - const char B = 1; - char* c = &B; - const A = 1; - char* b = &A; // #error: either type it or use && to take the reference to a temporary -} - -enum Enum : int -{ - A, - B, -} - -fn void test11() -{ - int a = Enum.A; - ichar b = Enum.B; -} - -fn void test12() -{ - float f = 3.14; - ichar a = f; // #error: 'ichar' -} - -fn void test13() -{ - int a = 1; - ichar b = a; // #error: 'ichar' -} - -fn void test14() -{ - char a = 1; - ichar b = a; -} - -fn void test15() -{ - float f = 3.14; - ichar c = 1; - ichar* a = &f; // #error: 'float*' to 'ichar*' - ichar* b = &c; -} - -fn void test16() -{ - float f = 3.14; - int i = 1; - - ichar c = 1 ? 'c' : 'd'; - ichar d = 1 ? 'c' : i; - ichar e = 1 ? i : 0; // #error: 'ichar' - int g = 1 ? i : f; // #error: 'float' - int a = f ? 1 : 0; -} - -fn void test17() -{ - int a = "test"; // #error: 'char[4]*' to 'int' -} - -fn void test18() -{ - char b = 1; - int a = b; -} - -fn void test19() -{ - uint a = 1; - int b = a; -} - -/* -const i32 Num = 200; - -fn void test1() { - i8 a = test.Num; // @error{constant value 200 out-of-bounds for type 'i8', range [-128, 127]} -}*/ - -fn void test21() -{ - int a = 1; - uint b = a; -} - -fn void foo() {} - -fn void test22() -{ - ichar a = foo(); // #error: 'void' into 'ichar' - short b = foo(); // #error: 'void' into 'short' - int c = foo(); // #error: 'void' into 'int' - long d = foo(); // #error: 'void' into 'long' - char e = foo(); // #error: 'void' into 'char' - ushort f = foo(); // #error: 'void' into 'ushort' - uint g = foo(); // #error: 'void' into 'uint' - ulong h = foo(); // #error: 'void' into 'ulong' - bool i = foo(); // #error: 'void' into 'bool' -} - - -int num = 10; - -fn void test23() -{ - int a = num; - int b = test::num; - char c = test::num; // #error: 'char' -} - -int[2][3] b123; - -fn void test24() -{ - int a = b123; // #error: 'int[2][3]' to 'int' -} diff --git a/test/test_suite14/types/enum_illegal_type.c3 b/test/test_suite14/types/enum_illegal_type.c3 deleted file mode 100644 index 0c2a2610a..000000000 --- a/test/test_suite14/types/enum_illegal_type.c3 +++ /dev/null @@ -1,9 +0,0 @@ -enum EnumTestErrorType : float // #error: must be an integer type not 'float' -{ - VALUE_BOOM -} - -enum EnumWithErrorType2 : int* // #error: must be an integer type not 'int*' -{ - TEST -} \ No newline at end of file diff --git a/test/test_suite14/types/enum_implicit_overflow.c3 b/test/test_suite14/types/enum_implicit_overflow.c3 deleted file mode 100644 index aa64a25ae..000000000 --- a/test/test_suite14/types/enum_implicit_overflow.c3 +++ /dev/null @@ -1,136 +0,0 @@ -enum Foo : ichar -{ - MY_VAL0, - MY_VAL1, - MY_VAL2, - MY_VAL3, - MY_VAL4, - MY_VAL5, - MY_VAL6, - MY_VAL7, - MY_VAL8, - MY_VAL9, - MY_VAL10, - MY_VAL11, - MY_VAL12, - MY_VAL13, - MY_VAL14, - MY_VAL15, - MY_VAL16, - MY_VAL17, - MY_VAL18, - MY_VAL19, - MY_VAL20, - MY_VAL21, - MY_VAL22, - MY_VAL23, - MY_VAL24, - MY_VAL25, - MY_VAL26, - MY_VAL27, - MY_VAL28, - MY_VAL29, - MY_VAL30, - MY_VAL31, - MY_VAL32, - MY_VAL33, - MY_VAL34, - MY_VAL35, - MY_VAL36, - MY_VAL37, - MY_VAL38, - MY_VAL39, - MY_VAL40, - MY_VAL41, - MY_VAL42, - MY_VAL43, - MY_VAL44, - MY_VAL45, - MY_VAL46, - MY_VAL47, - MY_VAL48, - MY_VAL49, - MY_VAL50, - MY_VAL51, - MY_VAL52, - MY_VAL53, - MY_VAL54, - MY_VAL55, - MY_VAL56, - MY_VAL57, - MY_VAL58, - MY_VAL59, - MY_VAL60, - MY_VAL61, - MY_VAL62, - MY_VAL63, - MY_VAL64, - MY_VAL65, - MY_VAL66, - MY_VAL67, - MY_VAL68, - MY_VAL69, - MY_VAL70, - MY_VAL71, - MY_VAL72, - MY_VAL73, - MY_VAL74, - MY_VAL75, - MY_VAL76, - MY_VAL77, - MY_VAL78, - MY_VAL79, - MY_VAL80, - MY_VAL81, - MY_VAL82, - MY_VAL83, - MY_VAL84, - MY_VAL85, - MY_VAL86, - MY_VAL87, - MY_VAL88, - MY_VAL89, - MY_VAL90, - MY_VAL91, - MY_VAL92, - MY_VAL93, - MY_VAL94, - MY_VAL95, - MY_VAL96, - MY_VAL97, - MY_VAL98, - MY_VAL99, - MY_VAL100, - MY_VAL101, - MY_VAL102, - MY_VAL103, - MY_VAL104, - MY_VAL105, - MY_VAL106, - MY_VAL107, - MY_VAL108, - MY_VAL109, - MY_VAL110, - MY_VAL111, - MY_VAL112, - MY_VAL113, - MY_VAL114, - MY_VAL115, - MY_VAL116, - MY_VAL117, - MY_VAL118, - MY_VAL119, - MY_VAL120, - MY_VAL121, - MY_VAL122, - MY_VAL123, - MY_VAL124, - MY_VAL125, - MY_VAL126, - MY_VAL127, - MY_VAL128, // #error: The enum value would implicitly be 128 which does not fit in 'ichar' - MY_VAL129, - - - -} \ No newline at end of file diff --git a/test/test_suite14/types/enum_inference.c3 b/test/test_suite14/types/enum_inference.c3 deleted file mode 100644 index 6899a879e..000000000 --- a/test/test_suite14/types/enum_inference.c3 +++ /dev/null @@ -1,43 +0,0 @@ - -enum Inf -{ - A, - B, - C -} - -enum Inf2 : char -{ - A, - B, - C, -} - -define BooInf = Inf; - - -fn void enumInferenceTest() -{ - Inf x = Inf.A; - x = BooInf.B; - x = A; - int x1 = 0; - bool y = x1 == x1; - Inf2 z = C; - if (z == Inf2.A) return; - if (z == 1) return; - z = (Inf2)(2); - switch (z) - { - case Inf2.A: - x1++; - return; - case B: - return; - case (Inf2)(2): - x1 += 1; - return; - default: - return; - } -} \ No newline at end of file diff --git a/test/test_suite14/types/enum_ok.c3 b/test/test_suite14/types/enum_ok.c3 deleted file mode 100644 index 1374947c8..000000000 --- a/test/test_suite14/types/enum_ok.c3 +++ /dev/null @@ -1,35 +0,0 @@ -enum EnumTest : long -{ - VALUE1, - VALUE2 -} - -define Frob = long; - -enum EnumTestAlias : Frob -{ - VALUE1, - VALUE2 -} - -enum EnumTestDefault -{ - VALUE, - VALUE2 -} - - -enum EnumWithErrorData2 : int (int bar, ) -{ - TEST // #error: Expected associated value -} - -enum EnumTestErrorType4 -{ -} - -enum EnumTest5 -{ - B, - C, -} \ No newline at end of file diff --git a/test/test_suite14/types/enum_param.c3 b/test/test_suite14/types/enum_param.c3 deleted file mode 100644 index f369a64ed..000000000 --- a/test/test_suite14/types/enum_param.c3 +++ /dev/null @@ -1,12 +0,0 @@ -enum Foo -{ - A, B -} - -fn void test(Foo f) -{} - -fn void test2() -{ - test(Foo.A); -} \ No newline at end of file diff --git a/test/test_suite14/types/enum_parse_errors.c3 b/test/test_suite14/types/enum_parse_errors.c3 deleted file mode 100644 index a46e18efa..000000000 --- a/test/test_suite14/types/enum_parse_errors.c3 +++ /dev/null @@ -1,22 +0,0 @@ - -enum EnumWithErrorWithMissingName : int (int) // #error: The parameter must be named -{ - TEST -} - -enum EnumWithErrorData : int (int // #error: end of the parameter list -{ - TEST -} - -enum EnumWithErrorData2 : int (int, int bar) // #error: The parameter must be named -{ - TEST -} - - -enum EnumTestErrorType3 : int -{ - A, - A // #error: This enum constant is declared twice -} \ No newline at end of file diff --git a/test/test_suite14/types/recursive_array.c3 b/test/test_suite14/types/recursive_array.c3 deleted file mode 100644 index 199a6c013..000000000 --- a/test/test_suite14/types/recursive_array.c3 +++ /dev/null @@ -1,4 +0,0 @@ -struct Qq -{ - Qq[3]* a; -} \ No newline at end of file diff --git a/test/test_suite14/types/recursive_typedef.c3 b/test/test_suite14/types/recursive_typedef.c3 deleted file mode 100644 index 7d264a9d7..000000000 --- a/test/test_suite14/types/recursive_typedef.c3 +++ /dev/null @@ -1,9 +0,0 @@ -define Number2 = Number1; // #error: Recursive definition of 'Number2' -define Number1 = Number2; - -define Number = Number; // #error: Recursive definition of 'Number' - - -define Loop2 = Loop; // #error: Recursive definition of 'Loop2' -define Loop3 = Loop2; -define Loop = Loop3; diff --git a/test/test_suite14/types/redefinition.c3 b/test/test_suite14/types/redefinition.c3 deleted file mode 100644 index a2e16bd89..000000000 --- a/test/test_suite14/types/redefinition.c3 +++ /dev/null @@ -1,2 +0,0 @@ -define Number = int; -define Number = uint; // #error: 'Number' would shadow a previous declaration. \ No newline at end of file diff --git a/test/test_suite14/types/typedefs.c3 b/test/test_suite14/types/typedefs.c3 deleted file mode 100644 index 893061592..000000000 --- a/test/test_suite14/types/typedefs.c3 +++ /dev/null @@ -1,11 +0,0 @@ -define Arr = int[4]; - -Arr a = { 3, 4, 5, 6 }; - -fn void test1() -{ - Arr b = { 3, 4, 5, 6 }; - int c = b; // #error: 'Arr' (int[4]) to 'int' - int d = a; // #error: 'Arr' (int[4]) to 'int' -} - diff --git a/test/test_suite14/types/various.c3 b/test/test_suite14/types/various.c3 deleted file mode 100644 index 3a93475fc..000000000 --- a/test/test_suite14/types/various.c3 +++ /dev/null @@ -1,5 +0,0 @@ -func1 a = 1; // #error: A type name was expected - -fn void func1() {} - -uint b = -1; \ No newline at end of file diff --git a/test/test_suite14/unicode/commenting-out.c3 b/test/test_suite14/unicode/commenting-out.c3 deleted file mode 100644 index 2c9a908db..000000000 --- a/test/test_suite14/unicode/commenting-out.c3 +++ /dev/null @@ -1,10 +0,0 @@ -// #error: Invalid encoding - Unbalanced bidirectional markers. -int main() { - bool isAdmin = false; - /*‮ } ⁦if (isAdmin)⁩ ⁦ begin admins only */ - printf("You are an admin.\n"); - /* end admins only ‮ { ⁦*/ - return 0; -} - - diff --git a/test/test_suite14/union/flexible_array_union.c3 b/test/test_suite14/union/flexible_array_union.c3 deleted file mode 100644 index 42bbe8276..000000000 --- a/test/test_suite14/union/flexible_array_union.c3 +++ /dev/null @@ -1,5 +0,0 @@ -union Zee -{ - int z; - int[*] y; // #error: Flexible array members not allowed in unions. -} \ No newline at end of file diff --git a/test/test_suite14/union/test_unions.c3 b/test/test_suite14/union/test_unions.c3 deleted file mode 100644 index 8f465442b..000000000 --- a/test/test_suite14/union/test_unions.c3 +++ /dev/null @@ -1,28 +0,0 @@ -module test; - -union Qu -{ - Qu *x; -} - -union Xe -{ - char c; - int a, z; - long b; - void *b1; - struct qu - { - int a; - long z; - } -} - -fn Xe foo(Xe a) -{ - a.c = 123; - a.a = 39249; - a.b = 12301230123123i64; - a.z = 1; - return a; -} \ No newline at end of file diff --git a/test/test_suite14/union/union_codegen_const.c3t b/test/test_suite14/union/union_codegen_const.c3t deleted file mode 100644 index 60582734b..000000000 --- a/test/test_suite14/union/union_codegen_const.c3t +++ /dev/null @@ -1,20 +0,0 @@ -module test; - -union Foo -{ - int a; - double b; -} - -private Foo f = { .a = 23 }; -private Foo g = { .b = 2.3 }; -private Foo h = { .a = 23, .b = 2.3 }; -Foo i = { .b = 2.3, .a = 23 }; - -// #expect: test.ll - -@test_f = protected unnamed_addr global { i32, [4 x i8] } { i32 23, [4 x i8] undef }, align 8 -@test_g = protected unnamed_addr global %Foo { double 2.300000e+00 }, align 8 -@test_h = protected unnamed_addr global %Foo { double 2.300000e+00 }, align 8 -@test_i = local_unnamed_addr global { i32, [4 x i8] } { i32 23, [4 x i8] undef }, align 8 - diff --git a/test/test_suite14/union/union_codegen_empty.c3t b/test/test_suite14/union/union_codegen_empty.c3t deleted file mode 100644 index f52d5aa4e..000000000 --- a/test/test_suite14/union/union_codegen_empty.c3t +++ /dev/null @@ -1,46 +0,0 @@ -union UnionA -{ - int a; -} - -union UnionB -{ - struct b - { - int a; - } - int c; - double d; -} - -fn void test() -{ - UnionA a = {}; - UnionA a2; - UnionB b = {}; - UnionB b2; - UnionB b3 = { .b = {} }; - UnionB b4 = { .b.a = 23, .c = 4, .d = 0.4, .b = {} }; -} - -// #expect: union_codegen_empty.ll - - %a = alloca %UnionA, align 4 - %a2 = alloca %UnionA, align 4 - %b = alloca %UnionB, align 8 - %b2 = alloca %UnionB, align 8 - %b3 = alloca %UnionB, align 8 - %b4 = alloca %UnionB, align 8 - %0 = bitcast %UnionA* %a to i32* - store i32 0, i32* %0, align 4 - %1 = bitcast %UnionA* %a2 to i32* - store i32 0, i32* %1, align 4 - %2 = bitcast %UnionB* %b to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %2, i8 0, i64 8, i1 false) - %3 = bitcast %UnionB* %b2 to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %3, i8 0, i64 8, i1 false) - %4 = bitcast %UnionB* %b3 to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %4, i8 0, i64 8, i1 false) - %5 = bitcast %UnionB* %b4 to i8* - call void @llvm.memset.p0i8.i64(i8* align 8 %5, i8 0, i64 8, i1 false) - ret void diff --git a/test/test_suite14/union/union_codegen_overwrite_call.c3t b/test/test_suite14/union/union_codegen_overwrite_call.c3t deleted file mode 100644 index 01521672c..000000000 --- a/test/test_suite14/union/union_codegen_overwrite_call.c3t +++ /dev/null @@ -1,31 +0,0 @@ -module test; - -union UnionB -{ - struct b - { - int a; - } - int c; - double d; -} - -extern fn int bar(); - -fn void test() -{ - UnionB b = { .c = bar(), .b = {} }; -} - -// #expect: test.ll - -entry: - %b = alloca %UnionB, align 8 - %0 = bitcast %UnionB* %b to i32* - %1 = call i32 @bar() - store i32 %1, i32* %0, align 8 - %2 = bitcast %UnionB* %b to %b* - %3 = bitcast %b* %2 to i32* - store i32 0, i32* %3, align 8 - ret void - diff --git a/test/test_suite14/union/union_in_struct.c3t b/test/test_suite14/union/union_in_struct.c3t deleted file mode 100644 index 6dee64784..000000000 --- a/test/test_suite14/union/union_in_struct.c3t +++ /dev/null @@ -1,45 +0,0 @@ -// #target: macos-x64 -module test; - -struct Foo -{ - char c; - union { - int a; - double b; - } - int z; -} - -Foo foo1 = { .a = 3, .z = 4 }; -Foo foo2 = { .b = 3, .z = 4 }; - -struct Blend_Map_Entry -{ - union vals { - float[5] colour; - double[2] point_Slope; - } -} - -Blend_Map_Entry a = { .vals = { .colour = { 1, 2, 3, 4, 5 } } }; -Blend_Map_Entry b = { .vals = { .point_Slope = { 6, 7 } } }; -Blend_Map_Entry c = { .vals.colour[2] = 1 }; -Blend_Map_Entry d = { .vals.colour = { 1, 2, 3, 4, 5 } }; - -fn void test(Blend_Map_Entry* foo) -{ -} - -// #expect: test.ll - - -%Blend_Map_Entry = type { %vals } -%vals = type { [2 x double], [8 x i8] } - -@test_foo1 = local_unnamed_addr global { i8, [4 x i8], { i32, [4 x i8] }, i32 } { i8 0, [4 x i8] undef, { i32, [4 x i8] } { i32 3, [4 x i8] undef }, i32 4 }, align 8 -@test_foo2 = local_unnamed_addr global %Foo { i8 0, %.anon { double 3.000000e+00 }, i32 4 }, align 8 -@test_a = local_unnamed_addr global { { [5 x float], [4 x i8] } } { { [5 x float], [4 x i8] } { [5 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00], [4 x i8] undef } }, align 8 -@test_b = local_unnamed_addr global %Blend_Map_Entry { %vals { [2 x double] [double 6.000000e+00, double 7.000000e+00], [8 x i8] undef } }, align 8 -@test_c = local_unnamed_addr global { { { [2 x float], float, [2 x float] }, [4 x i8] } } { { { [2 x float], float, [2 x float] }, [4 x i8] } { { [2 x float], float, [2 x float] } { [2 x float] zeroinitializer, float 1.000000e+00, [2 x float] zeroinitializer }, [4 x i8] undef } }, align 8 -@test_d = local_unnamed_addr global { { [5 x float], [4 x i8] } } { { [5 x float], [4 x i8] } { [5 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00], [4 x i8] undef } }, align 8 diff --git a/test/test_suite14/union/union_member_voidcast.c3 b/test/test_suite14/union/union_member_voidcast.c3 deleted file mode 100644 index aeea25047..000000000 --- a/test/test_suite14/union/union_member_voidcast.c3 +++ /dev/null @@ -1,13 +0,0 @@ -module test; - -union Xu -{ - void *b; -} - -fn Xu foo() -{ - Xu a; - a.b = (void*)(123); - return a; -} \ No newline at end of file diff --git a/test/test_suite14/variables/consts.c3 b/test/test_suite14/variables/consts.c3 deleted file mode 100644 index a571906b7..000000000 --- a/test/test_suite14/variables/consts.c3 +++ /dev/null @@ -1,7 +0,0 @@ -const int foo = 3; // #error: must be all uppercase - -fn void foo(int i) -{ - const int x = i; // #error: must be all uppercase - const int Y = i; -} \ No newline at end of file diff --git a/test/test_suite14/variant/variant_assign.c3t b/test/test_suite14/variant/variant_assign.c3t deleted file mode 100644 index a0e7c71c8..000000000 --- a/test/test_suite14/variant/variant_assign.c3t +++ /dev/null @@ -1,368 +0,0 @@ -// #target: macos-x64 -module foo; - -extern fn void printf(char*, ...); - -fn void test(variant z) -{ - switch (z) - { - case int: - printf("int: %d\n", *z); - case double: - printf("double %f\n", *z); - default: - printf("Unknown type.\n"); - } -} -fn void test2(variant y) -{ - switch (z = y) - { - case int: - y = &&12; - printf("int: %d\n", *z); - case double: - printf("double %f\n", *z); - default: - printf("Unknown type.\n"); - } -} - -fn void test3(variant y) -{ - switch (z = *y) - { - case int: - printf("int: %d\n", z); - case double: - printf("double %f\n", z); - default: - printf("Unknown type.\n"); - } -} - -fn int main() -{ - test(&&123.0); - test(&&1); - test(&&true); - test2(&&123.5); - test2(&&1); - test2(&&true); - test3(&&124.0); - test3(&&2); - test3(&&true); - return 0; -} - -/* #expect: foo.ll - -@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$double" = linkonce constant %.introspect { i8 4, i64 8, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$bool" = linkonce constant %.introspect { i8 1, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 - -define void @foo_test(i64 %0, i8* %1) #0 { -entry: - %z = alloca %variant, align 8 - %switch = alloca i64, align 8 - %z1 = alloca i32*, align 8 - %z4 = alloca double*, align 8 - %pair = bitcast %variant* %z to { i64, i8* }* - %2 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 0 - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 1 - store i8* %1, i8** %3, align 8 - %4 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 1 - %5 = load i64, i64* %4, align 8 - store i64 %5, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %entry - %6 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.introspect* @"ct$int" to i64), %6 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - %7 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 0 - %8 = bitcast i8** %7 to i32** - %9 = load i32*, i32** %8, align 8 - store i32* %9, i32** %z1, align 8 - %10 = load i32*, i32** %z1, align 8 - %11 = load i32, i32* %10, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %11) - br label %switch.exit - -next_if: ; preds = %switch.entry - %eq2 = icmp eq i64 ptrtoint (%.introspect* @"ct$double" to i64), %6 - br i1 %eq2, label %switch.case3, label %next_if5 - -switch.case3: ; preds = %next_if - %12 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 0 - %13 = bitcast i8** %12 to double** - %14 = load double*, double** %13, align 8 - store double* %14, double** %z4, align 8 - %15 = load double*, double** %z4, align 8 - %16 = load double, double* %15, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), double %16) - br label %switch.exit - -next_if5: ; preds = %next_if - br label %switch.default - -switch.default: ; preds = %next_if5 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.default, %switch.case3, %switch.case - ret void -} - -; Function Attrs: nounwind -define void @foo_test2(i64 %0, i8* %1) #0 { -entry: - %y = alloca %variant, align 8 - %.anon = alloca %variant, align 8 - %switch = alloca i64, align 8 - %z = alloca i32*, align 8 - %taddr = alloca i32, align 4 - %z3 = alloca double*, align 8 - %pair = bitcast %variant* %y to { i64, i8* }* - %2 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 0 - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 1 - store i8* %1, i8** %3, align 8 - %4 = bitcast %variant* %.anon to i8* - %5 = bitcast %variant* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 16, i1 false) - %6 = getelementptr inbounds %variant, %variant* %y, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - store i64 %7, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %entry - %8 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.introspect* @"ct$int" to i64), %8 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - %9 = getelementptr inbounds %variant, %variant* %.anon, i32 0, i32 0 - %10 = bitcast i8** %9 to i32** - %11 = load i32*, i32** %10, align 8 - store i32* %11, i32** %z, align 8 - store i32 12, i32* %taddr, align 4 - %12 = bitcast i32* %taddr to i8* - %13 = insertvalue %variant undef, i8* %12, 0 - %14 = insertvalue %variant %13, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %14, %variant* %y, align 8 - %15 = load i32*, i32** %z, align 8 - %16 = load i32, i32* %15, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i32 %16) - br label %switch.exit - -next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (%.introspect* @"ct$double" to i64), %8 - br i1 %eq1, label %switch.case2, label %next_if4 - -switch.case2: ; preds = %next_if - %17 = getelementptr inbounds %variant, %variant* %.anon, i32 0, i32 0 - %18 = bitcast i8** %17 to double** - %19 = load double*, double** %18, align 8 - store double* %19, double** %z3, align 8 - %20 = load double*, double** %z3, align 8 - %21 = load double, double* %20, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), double %21) - br label %switch.exit - -next_if4: ; preds = %next_if - br label %switch.default - -switch.default: ; preds = %next_if4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.default, %switch.case2, %switch.case - ret void -} - -; Function Attrs: nounwind -define void @foo_test3(i64 %0, i8* %1) #0 { -entry: - %y = alloca %variant, align 8 - %.anon = alloca %variant, align 8 - %switch = alloca i64, align 8 - %z = alloca i32, align 4 - %z3 = alloca double, align 8 - %pair = bitcast %variant* %y to { i64, i8* }* - %2 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 0 - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 1 - store i8* %1, i8** %3, align 8 - %4 = bitcast %variant* %.anon to i8* - %5 = bitcast %variant* %y to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %4, i8* align 8 %5, i32 16, i1 false) - %6 = getelementptr inbounds %variant, %variant* %y, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - store i64 %7, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %entry - %8 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.introspect* @"ct$int" to i64), %8 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - %9 = getelementptr inbounds %variant, %variant* %.anon, i32 0, i32 0 - %10 = bitcast i8** %9 to i32** - %11 = load i32*, i32** %10, align 8 - %12 = load i32, i32* %11, align 4 - store i32 %12, i32* %z, align 4 - %13 = load i32, i32* %z, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0), i32 %13) - br label %switch.exit - -next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (%.introspect* @"ct$double" to i64), %8 - br i1 %eq1, label %switch.case2, label %next_if4 - -switch.case2: ; preds = %next_if - %14 = getelementptr inbounds %variant, %variant* %.anon, i32 0, i32 0 - %15 = bitcast i8** %14 to double** - %16 = load double*, double** %15, align 8 - %17 = load double, double* %16, align 8 - store double %17, double* %z3, align 8 - %18 = load double, double* %z3, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0), double %18) - br label %switch.exit - -next_if4: ; preds = %next_if - br label %switch.default - -switch.default: ; preds = %next_if4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.default, %switch.case2, %switch.case - ret void -} - -; Function Attrs: nounwind -define i32 @main() #0 { -entry: - %taddr = alloca double, align 8 - %taddr1 = alloca %variant, align 8 - %taddr2 = alloca i32, align 4 - %taddr3 = alloca %variant, align 8 - %taddr6 = alloca i8, align 1 - %taddr7 = alloca %variant, align 8 - %taddr10 = alloca double, align 8 - %taddr11 = alloca %variant, align 8 - %taddr14 = alloca i32, align 4 - %taddr15 = alloca %variant, align 8 - %taddr18 = alloca i8, align 1 - %taddr19 = alloca %variant, align 8 - %taddr22 = alloca double, align 8 - %taddr23 = alloca %variant, align 8 - %taddr26 = alloca i32, align 4 - %taddr27 = alloca %variant, align 8 - %taddr30 = alloca i8, align 1 - %taddr31 = alloca %variant, align 8 - store double 1.230000e+02, double* %taddr, align 8 - %0 = bitcast double* %taddr to i8* - %1 = insertvalue %variant undef, i8* %0, 0 - %2 = insertvalue %variant %1, i64 ptrtoint (%.introspect* @"ct$double" to i64), 1 - store %variant %2, %variant* %taddr1, align 8 - %3 = bitcast %variant* %taddr1 to { i64, i8* }* - %4 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %3, i32 0, i32 0 - %lo = load i64, i64* %4, align 8 - %5 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %3, i32 0, i32 1 - %hi = load i8*, i8** %5, align 8 - call void @foo_test(i64 %lo, i8* %hi) - store i32 1, i32* %taddr2, align 4 - %6 = bitcast i32* %taddr2 to i8* - %7 = insertvalue %variant undef, i8* %6, 0 - %8 = insertvalue %variant %7, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %8, %variant* %taddr3, align 8 - %9 = bitcast %variant* %taddr3 to { i64, i8* }* - %10 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %9, i32 0, i32 0 - %lo4 = load i64, i64* %10, align 8 - %11 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %9, i32 0, i32 1 - %hi5 = load i8*, i8** %11, align 8 - call void @foo_test(i64 %lo4, i8* %hi5) - store i8 1, i8* %taddr6, align 1 - %12 = insertvalue %variant undef, i8* %taddr6, 0 - %13 = insertvalue %variant %12, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - store %variant %13, %variant* %taddr7, align 8 - %14 = bitcast %variant* %taddr7 to { i64, i8* }* - %15 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %14, i32 0, i32 0 - %lo8 = load i64, i64* %15, align 8 - %16 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %14, i32 0, i32 1 - %hi9 = load i8*, i8** %16, align 8 - call void @foo_test(i64 %lo8, i8* %hi9) - store double 1.235000e+02, double* %taddr10, align 8 - %17 = bitcast double* %taddr10 to i8* - %18 = insertvalue %variant undef, i8* %17, 0 - %19 = insertvalue %variant %18, i64 ptrtoint (%.introspect* @"ct$double" to i64), 1 - store %variant %19, %variant* %taddr11, align 8 - %20 = bitcast %variant* %taddr11 to { i64, i8* }* - %21 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %20, i32 0, i32 0 - %lo12 = load i64, i64* %21, align 8 - %22 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %20, i32 0, i32 1 - %hi13 = load i8*, i8** %22, align 8 - call void @foo_test2(i64 %lo12, i8* %hi13) - store i32 1, i32* %taddr14, align 4 - %23 = bitcast i32* %taddr14 to i8* - %24 = insertvalue %variant undef, i8* %23, 0 - %25 = insertvalue %variant %24, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %25, %variant* %taddr15, align 8 - %26 = bitcast %variant* %taddr15 to { i64, i8* }* - %27 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %26, i32 0, i32 0 - %lo16 = load i64, i64* %27, align 8 - %28 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %26, i32 0, i32 1 - %hi17 = load i8*, i8** %28, align 8 - call void @foo_test2(i64 %lo16, i8* %hi17) - store i8 1, i8* %taddr18, align 1 - %29 = insertvalue %variant undef, i8* %taddr18, 0 - %30 = insertvalue %variant %29, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - store %variant %30, %variant* %taddr19, align 8 - %31 = bitcast %variant* %taddr19 to { i64, i8* }* - %32 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %31, i32 0, i32 0 - %lo20 = load i64, i64* %32, align 8 - %33 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %31, i32 0, i32 1 - %hi21 = load i8*, i8** %33, align 8 - call void @foo_test2(i64 %lo20, i8* %hi21) - store double 1.240000e+02, double* %taddr22, align 8 - %34 = bitcast double* %taddr22 to i8* - %35 = insertvalue %variant undef, i8* %34, 0 - %36 = insertvalue %variant %35, i64 ptrtoint (%.introspect* @"ct$double" to i64), 1 - store %variant %36, %variant* %taddr23, align 8 - %37 = bitcast %variant* %taddr23 to { i64, i8* }* - %38 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %37, i32 0, i32 0 - %lo24 = load i64, i64* %38, align 8 - %39 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %37, i32 0, i32 1 - %hi25 = load i8*, i8** %39, align 8 - call void @foo_test3(i64 %lo24, i8* %hi25) - store i32 2, i32* %taddr26, align 4 - %40 = bitcast i32* %taddr26 to i8* - %41 = insertvalue %variant undef, i8* %40, 0 - %42 = insertvalue %variant %41, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %42, %variant* %taddr27, align 8 - %43 = bitcast %variant* %taddr27 to { i64, i8* }* - %44 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %43, i32 0, i32 0 - %lo28 = load i64, i64* %44, align 8 - %45 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %43, i32 0, i32 1 - %hi29 = load i8*, i8** %45, align 8 - call void @foo_test3(i64 %lo28, i8* %hi29) - store i8 1, i8* %taddr30, align 1 - %46 = insertvalue %variant undef, i8* %taddr30, 0 - %47 = insertvalue %variant %46, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - store %variant %47, %variant* %taddr31, align 8 - %48 = bitcast %variant* %taddr31 to { i64, i8* }* - %49 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %48, i32 0, i32 0 - %lo32 = load i64, i64* %49, align 8 - %50 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %48, i32 0, i32 1 - %hi33 = load i8*, i8** %50, align 8 - call void @foo_test3(i64 %lo32, i8* %hi33) - ret i32 0 -} - diff --git a/test/test_suite14/variant/variant_switch.c3t b/test/test_suite14/variant/variant_switch.c3t deleted file mode 100644 index 1695f95c3..000000000 --- a/test/test_suite14/variant/variant_switch.c3t +++ /dev/null @@ -1,151 +0,0 @@ -// #target: macos-x64 -module foo; - -extern fn void printf(char*, ...); - -fn void test(variant z) -{ - switch (z) - { - case int: - printf("int: %d\n", *z); - *z = 3; - case double: - printf("double %f\n", *z); - default: - printf("Unknown type.\n"); - } - if (z.type == int.typeid) - { - printf("int: %d\n", *(int*)(z)); - } -} -fn int main() -{ - test(&&123.0); - test(&&1); - test(&&true); - return 0; -} - -/* #expect: foo.ll - -@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$double" = linkonce constant %.introspect { i8 4, i64 8, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$bool" = linkonce constant %.introspect { i8 1, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 - -define void @foo_test(i64 %0, i8* %1) #0 { -entry: - %z = alloca %variant, align 8 - %switch = alloca i64, align 8 - %z1 = alloca i32*, align 8 - %z4 = alloca double*, align 8 - %pair = bitcast %variant* %z to { i64, i8* }* - %2 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 0 - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 1 - store i8* %1, i8** %3, align 8 - %4 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 1 - %5 = load i64, i64* %4, align 8 - store i64 %5, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %entry - %6 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.introspect* @"ct$int" to i64), %6 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - %7 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 0 - %8 = bitcast i8** %7 to i32** - %9 = load i32*, i32** %8, align 8 - store i32* %9, i32** %z1, align 8 - %10 = load i32*, i32** %z1, align 8 - %11 = load i32, i32* %10, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %11) - %12 = load i32*, i32** %z1, align 8 - store i32 3, i32* %12, align 4 - br label %switch.exit - -next_if: ; preds = %switch.entry - %eq2 = icmp eq i64 ptrtoint (%.introspect* @"ct$double" to i64), %6 - br i1 %eq2, label %switch.case3, label %next_if5 - -switch.case3: ; preds = %next_if - %13 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 0 - %14 = bitcast i8** %13 to double** - %15 = load double*, double** %14, align 8 - store double* %15, double** %z4, align 8 - %16 = load double*, double** %z4, align 8 - %17 = load double, double* %16, align 8 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), double %17) - br label %switch.exit - -next_if5: ; preds = %next_if - br label %switch.default - -switch.default: ; preds = %next_if5 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.default, %switch.case3, %switch.case - %18 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 1 - %19 = load i64, i64* %18, align 8 - %eq6 = icmp eq i64 %19, ptrtoint (%.introspect* @"ct$int" to i64) - br i1 %eq6, label %if.then, label %if.exit - -if.then: ; preds = %switch.exit - %20 = getelementptr inbounds %variant, %variant* %z, i32 0, i32 0 - %21 = bitcast i8** %20 to i32** - %22 = load i32*, i32** %21, align 8 - %23 = load i32, i32* %22, align 4 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i32 %23) - br label %if.exit - -if.exit: ; preds = %if.then, %switch.exit - ret void -} - -; Function Attrs: nounwind -define i32 @main() #0 { -entry: - %taddr = alloca double, align 8 - %taddr1 = alloca %variant, align 8 - %taddr2 = alloca i32, align 4 - %taddr3 = alloca %variant, align 8 - %taddr6 = alloca i8, align 1 - %taddr7 = alloca %variant, align 8 - store double 1.230000e+02, double* %taddr, align 8 - %0 = bitcast double* %taddr to i8* - %1 = insertvalue %variant undef, i8* %0, 0 - %2 = insertvalue %variant %1, i64 ptrtoint (%.introspect* @"ct$double" to i64), 1 - store %variant %2, %variant* %taddr1, align 8 - %3 = bitcast %variant* %taddr1 to { i64, i8* }* - %4 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %3, i32 0, i32 0 - %lo = load i64, i64* %4, align 8 - %5 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %3, i32 0, i32 1 - %hi = load i8*, i8** %5, align 8 - call void @foo_test(i64 %lo, i8* %hi) - store i32 1, i32* %taddr2, align 4 - %6 = bitcast i32* %taddr2 to i8* - %7 = insertvalue %variant undef, i8* %6, 0 - %8 = insertvalue %variant %7, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %8, %variant* %taddr3, align 8 - %9 = bitcast %variant* %taddr3 to { i64, i8* }* - %10 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %9, i32 0, i32 0 - %lo4 = load i64, i64* %10, align 8 - %11 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %9, i32 0, i32 1 - %hi5 = load i8*, i8** %11, align 8 - call void @foo_test(i64 %lo4, i8* %hi5) - store i8 1, i8* %taddr6, align 1 - %12 = insertvalue %variant undef, i8* %taddr6, 0 - %13 = insertvalue %variant %12, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - store %variant %13, %variant* %taddr7, align 8 - %14 = bitcast %variant* %taddr7 to { i64, i8* }* - %15 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %14, i32 0, i32 0 - %lo8 = load i64, i64* %15, align 8 - %16 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %14, i32 0, i32 1 - %hi9 = load i8*, i8** %16, align 8 - call void @foo_test(i64 %lo8, i8* %hi9) - ret i32 0 -} diff --git a/test/test_suite14/variant/variant_test.c3t b/test/test_suite14/variant/variant_test.c3t deleted file mode 100644 index fcc4464c3..000000000 --- a/test/test_suite14/variant/variant_test.c3t +++ /dev/null @@ -1,340 +0,0 @@ -// #target: macos-x64 -module foo; -extern fn void printf(char*, ...); - -fn void test(variant x) -{ - switch (x.type) - { - case int: - printf("Was int\n"); - case double: - printf("Was double\n"); - case variant: - printf("Was variant\n"); - case int*: - printf("Was int*\n"); - default: - printf("Unknown type\n"); - } -} - -fn void test_all(variant... y) -{ - foreach (element : y) - { - test(element); - } -} - -fn void main() -{ - variant x = &&1; - int z; - variant y = &z; - typeid g = y.type; - typeid h = x.type; - if (y.type == int.typeid) - { - printf("y int match\n"); - } - if (x.type == int.typeid) - { - printf("x int match\n"); - } - y = &&1.0; - x = &x; - if (y.type == int.typeid) - { - printf("y int match\n"); - } - if (x.type == int.typeid) - { - printf("x int match\n"); - } - test(x); - test(&&1.0); - test(&&1); - test(&&true); - printf("----\n"); - int* df = null; - test_all(x, x, &&1.0, &x, &df); -} - -/* #expect: foo.ll - -%variant = type { i8*, i64 } -%"variant[]" = type { %variant*, i64 } - -@"ct$int" = linkonce constant %.introspect { i8 2, i64 4, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$double" = linkonce constant %.introspect { i8 4, i64 8, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$variant" = linkonce constant %.introspect { i8 7, i64 16, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$p$int" = linkonce constant %.introspect { i8 19, i64 8, i64 ptrtoint (%.introspect* @"ct$int" to i64), i64 0, [0 x i64] zeroinitializer }, align 8 -@"ct$bool" = linkonce constant %.introspect { i8 1, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8 - -define void @foo_test(i64 %0, i8* %1) #0 { -entry: - %x = alloca %variant, align 8 - %switch = alloca i64, align 8 - %pair = bitcast %variant* %x to { i64, i8* }* - %2 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 0 - store i64 %0, i64* %2, align 8 - %3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %pair, i32 0, i32 1 - store i8* %1, i8** %3, align 8 - %4 = getelementptr inbounds %variant, %variant* %x, i32 0, i32 1 - %5 = load i64, i64* %4, align 8 - store i64 %5, i64* %switch, align 8 - br label %switch.entry - -switch.entry: ; preds = %entry - %6 = load i64, i64* %switch, align 8 - %eq = icmp eq i64 ptrtoint (%.introspect* @"ct$int" to i64), %6 - br i1 %eq, label %switch.case, label %next_if - -switch.case: ; preds = %switch.entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0)) - br label %switch.exit - -next_if: ; preds = %switch.entry - %eq1 = icmp eq i64 ptrtoint (%.introspect* @"ct$double" to i64), %6 - br i1 %eq1, label %switch.case2, label %next_if3 - -switch.case2: ; preds = %next_if - call void (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0)) - br label %switch.exit - -next_if3: ; preds = %next_if - %eq4 = icmp eq i64 ptrtoint (%.introspect* @"ct$variant" to i64), %6 - br i1 %eq4, label %switch.case5, label %next_if6 - -switch.case5: ; preds = %next_if3 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0)) - br label %switch.exit - -next_if6: ; preds = %next_if3 - %eq7 = icmp eq i64 ptrtoint (%.introspect* @"ct$p$int" to i64), %6 - br i1 %eq7, label %switch.case8, label %next_if9 - -switch.case8: ; preds = %next_if6 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0)) - br label %switch.exit - -next_if9: ; preds = %next_if6 - br label %switch.default - -switch.default: ; preds = %next_if9 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0)) - br label %switch.exit - -switch.exit: ; preds = %switch.default, %switch.case8, %switch.case5, %switch.case2, %switch.case - ret void -} - -; Function Attrs: nounwind -define void @foo_test_all(i8* %0, i64 %1) #0 { -entry: - %y = alloca %"variant[]", align 8 - %.anon = alloca i64, align 8 - %.anon1 = alloca i64, align 8 - %element = alloca %variant, align 8 - %pair = bitcast %"variant[]"* %y to { i8*, i64 }* - %2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0 - store i8* %0, i8** %2, align 8 - %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1 - store i64 %1, i64* %3, align 8 - %4 = getelementptr inbounds %"variant[]", %"variant[]"* %y, i32 0, i32 1 - %5 = load i64, i64* %4, align 8 - store i64 %5, i64* %.anon, align 8 - store i64 0, i64* %.anon1, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %6 = load i64, i64* %.anon1, align 8 - %7 = load i64, i64* %.anon, align 8 - %lt = icmp ult i64 %6, %7 - br i1 %lt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %8 = getelementptr inbounds %"variant[]", %"variant[]"* %y, i32 0, i32 0 - %9 = load %variant*, %variant** %8, align 8 - %10 = load i64, i64* %.anon1, align 8 - %ptroffset = getelementptr inbounds %variant, %variant* %9, i64 %10 - %11 = bitcast %variant* %element to i8* - %12 = bitcast %variant* %ptroffset to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %11, i8* align 8 %12, i32 16, i1 false) - %13 = bitcast %variant* %element to { i64, i8* }* - %14 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %13, i32 0, i32 0 - %lo = load i64, i64* %14, align 8 - %15 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %13, i32 0, i32 1 - %hi = load i8*, i8** %15, align 8 - call void @foo_test(i64 %lo, i8* %hi) - %16 = load i64, i64* %.anon1, align 8 - %add = add i64 %16, 1 - store i64 %add, i64* %.anon1, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - ret void -} - -; Function Attrs: nounwind -define void @foo_main() #0 { -entry: - %x = alloca %variant, align 8 - %taddr = alloca i32, align 4 - %z = alloca i32, align 4 - %y = alloca %variant, align 8 - %g = alloca i64, align 8 - %h = alloca i64, align 8 - %taddr4 = alloca double, align 8 - %taddr11 = alloca double, align 8 - %taddr12 = alloca %variant, align 8 - %taddr15 = alloca i32, align 4 - %taddr16 = alloca %variant, align 8 - %taddr19 = alloca i8, align 1 - %taddr20 = alloca %variant, align 8 - %df = alloca i32*, align 8 - %varargslots = alloca [5 x %variant], align 16 - %taddr23 = alloca double, align 8 - %taddr24 = alloca %"variant[]", align 8 - store i32 1, i32* %taddr, align 4 - %0 = bitcast i32* %taddr to i8* - %1 = insertvalue %variant undef, i8* %0, 0 - %2 = insertvalue %variant %1, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %2, %variant* %x, align 8 - store i32 0, i32* %z, align 4 - %3 = bitcast i32* %z to i8* - %4 = insertvalue %variant undef, i8* %3, 0 - %5 = insertvalue %variant %4, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %5, %variant* %y, align 8 - %6 = getelementptr inbounds %variant, %variant* %y, i32 0, i32 1 - %7 = load i64, i64* %6, align 8 - store i64 %7, i64* %g, align 8 - %8 = getelementptr inbounds %variant, %variant* %x, i32 0, i32 1 - %9 = load i64, i64* %8, align 8 - store i64 %9, i64* %h, align 8 - %10 = getelementptr inbounds %variant, %variant* %y, i32 0, i32 1 - %11 = load i64, i64* %10, align 8 - %eq = icmp eq i64 %11, ptrtoint (%.introspect* @"ct$int" to i64) - br i1 %eq, label %if.then, label %if.exit - -if.then: ; preds = %entry - call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i32 0, i32 0)) - br label %if.exit - -if.exit: ; preds = %if.then, %entry - %12 = getelementptr inbounds %variant, %variant* %x, i32 0, i32 1 - %13 = load i64, i64* %12, align 8 - %eq1 = icmp eq i64 %13, ptrtoint (%.introspect* @"ct$int" to i64) - br i1 %eq1, label %if.then2, label %if.exit3 - -if.then2: ; preds = %if.exit - call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i32 0, i32 0)) - br label %if.exit3 - -if.exit3: ; preds = %if.then2, %if.exit - store double 1.000000e+00, double* %taddr4, align 8 - %14 = bitcast double* %taddr4 to i8* - %15 = insertvalue %variant undef, i8* %14, 0 - %16 = insertvalue %variant %15, i64 ptrtoint (%.introspect* @"ct$double" to i64), 1 - store %variant %16, %variant* %y, align 8 - %17 = bitcast %variant* %x to i8* - %18 = insertvalue %variant undef, i8* %17, 0 - %19 = insertvalue %variant %18, i64 ptrtoint (%.introspect* @"ct$variant" to i64), 1 - store %variant %19, %variant* %x, align 8 - %20 = getelementptr inbounds %variant, %variant* %y, i32 0, i32 1 - %21 = load i64, i64* %20, align 8 - %eq5 = icmp eq i64 %21, ptrtoint (%.introspect* @"ct$int" to i64) - br i1 %eq5, label %if.then6, label %if.exit7 - -if.then6: ; preds = %if.exit3 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i32 0, i32 0)) - br label %if.exit7 - -if.exit7: ; preds = %if.then6, %if.exit3 - %22 = getelementptr inbounds %variant, %variant* %x, i32 0, i32 1 - %23 = load i64, i64* %22, align 8 - %eq8 = icmp eq i64 %23, ptrtoint (%.introspect* @"ct$int" to i64) - br i1 %eq8, label %if.then9, label %if.exit10 - -if.then9: ; preds = %if.exit7 - call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i32 0, i32 0)) - br label %if.exit10 - -if.exit10: ; preds = %if.then9, %if.exit7 - %24 = bitcast %variant* %x to { i64, i8* }* - %25 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %24, i32 0, i32 0 - %lo = load i64, i64* %25, align 8 - %26 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %24, i32 0, i32 1 - %hi = load i8*, i8** %26, align 8 - call void @foo_test(i64 %lo, i8* %hi) - store double 1.000000e+00, double* %taddr11, align 8 - %27 = bitcast double* %taddr11 to i8* - %28 = insertvalue %variant undef, i8* %27, 0 - %29 = insertvalue %variant %28, i64 ptrtoint (%.introspect* @"ct$double" to i64), 1 - store %variant %29, %variant* %taddr12, align 8 - %30 = bitcast %variant* %taddr12 to { i64, i8* }* - %31 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %30, i32 0, i32 0 - %lo13 = load i64, i64* %31, align 8 - %32 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %30, i32 0, i32 1 - %hi14 = load i8*, i8** %32, align 8 - call void @foo_test(i64 %lo13, i8* %hi14) - store i32 1, i32* %taddr15, align 4 - %33 = bitcast i32* %taddr15 to i8* - %34 = insertvalue %variant undef, i8* %33, 0 - %35 = insertvalue %variant %34, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 - store %variant %35, %variant* %taddr16, align 8 - %36 = bitcast %variant* %taddr16 to { i64, i8* }* - %37 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %36, i32 0, i32 0 - %lo17 = load i64, i64* %37, align 8 - %38 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %36, i32 0, i32 1 - %hi18 = load i8*, i8** %38, align 8 - call void @foo_test(i64 %lo17, i8* %hi18) - store i8 1, i8* %taddr19, align 1 - %39 = insertvalue %variant undef, i8* %taddr19, 0 - %40 = insertvalue %variant %39, i64 ptrtoint (%.introspect* @"ct$bool" to i64), 1 - store %variant %40, %variant* %taddr20, align 8 - %41 = bitcast %variant* %taddr20 to { i64, i8* }* - %42 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %41, i32 0, i32 0 - %lo21 = load i64, i64* %42, align 8 - %43 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %41, i32 0, i32 1 - %hi22 = load i8*, i8** %43, align 8 - call void @foo_test(i64 %lo21, i8* %hi22) - call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0)) - store i32* null, i32** %df, align 8 - %44 = getelementptr inbounds [5 x %variant], [5 x %variant]* %varargslots, i64 0, i64 0 - %45 = bitcast %variant* %44 to i8* - %46 = bitcast %variant* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %45, i8* align 8 %46, i32 16, i1 false) - %47 = getelementptr inbounds [5 x %variant], [5 x %variant]* %varargslots, i64 0, i64 1 - %48 = bitcast %variant* %47 to i8* - %49 = bitcast %variant* %x to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %48, i8* align 8 %49, i32 16, i1 false) - store double 1.000000e+00, double* %taddr23, align 8 - %50 = bitcast double* %taddr23 to i8* - %51 = insertvalue %variant undef, i8* %50, 0 - %52 = insertvalue %variant %51, i64 ptrtoint (%.introspect* @"ct$double" to i64), 1 - %53 = getelementptr inbounds [5 x %variant], [5 x %variant]* %varargslots, i64 0, i64 2 - store %variant %52, %variant* %53, align 16 - %54 = bitcast %variant* %x to i8* - %55 = insertvalue %variant undef, i8* %54, 0 - %56 = insertvalue %variant %55, i64 ptrtoint (%.introspect* @"ct$variant" to i64), 1 - %57 = getelementptr inbounds [5 x %variant], [5 x %variant]* %varargslots, i64 0, i64 3 - store %variant %56, %variant* %57, align 16 - %58 = bitcast i32** %df to i8* - %59 = insertvalue %variant undef, i8* %58, 0 - %60 = insertvalue %variant %59, i64 ptrtoint (%.introspect* @"ct$p$int" to i64), 1 - %61 = getelementptr inbounds [5 x %variant], [5 x %variant]* %varargslots, i64 0, i64 4 - store %variant %60, %variant* %61, align 16 - %62 = bitcast [5 x %variant]* %varargslots to %variant* - %63 = insertvalue %"variant[]" undef, %variant* %62, 0 - %64 = insertvalue %"variant[]" %63, i64 5, 1 - store %"variant[]" %64, %"variant[]"* %taddr24, align 8 - %65 = bitcast %"variant[]"* %taddr24 to { i8*, i64 }* - %66 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %65, i32 0, i32 0 - %lo25 = load i8*, i8** %66, align 8 - %67 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %65, i32 0, i32 1 - %hi26 = load i64, i64* %67, align 8 - call void @foo_test_all(i8* %lo25, i64 %hi26) - ret void -} diff --git a/test/test_suite14/vector/vector_bit.c3t b/test/test_suite14/vector/vector_bit.c3t deleted file mode 100644 index a415568da..000000000 --- a/test/test_suite14/vector/vector_bit.c3t +++ /dev/null @@ -1,155 +0,0 @@ -// #target: macos-x64 - -import libc; - -fn void testf() -{ - float[<4>] y = { 0, 2, 3, 0 }; - int[<4>] w = !y; - libc::printf("Notf %d %d %d %d\n", w[0], w[1], w[2], w[3]); -} - -fn void testi() -{ - int[<4>] y = { 1, 2, 3, 4 }; - int[<4>] z = { 2, 3, 13, -100 }; - int[<4>] w; - w = y & z; - libc::printf("And %d %d %d %d\n", w[0], w[1], w[2], w[3]); - w = y | z; - libc::printf("Or %d %d %d %d\n", w[0], w[1], w[2], w[3]); - w = y ^ z; - libc::printf("Xor %d %d %d %d\n", w[0], w[1], w[2], w[3]); - w = ~y; - libc::printf("BitNeg %d %d %d %d\n", w[0], w[1], w[2], w[3]); - w = -y; - libc::printf("Neg %d %d %d %d\n", w[0], w[1], w[2], w[3]); - w = !y; - w = { -1, 13, 0, 0 }; - w = !w; - libc::printf("Not %d %d %d %d\n", w[0], w[1], w[2], w[3]); -} - -fn void main() -{ - testf(); - testi(); -} - -/* #expect: vector_bit.ll - -; Function Attrs: nounwind -define void @vector_bit_testf() #0 { -entry: - %y = alloca <4 x float>, align 16 - %w = alloca <4 x i32>, align 16 - store <4 x float> , <4 x float>* %y, align 16 - %0 = load <4 x float>, <4 x float>* %y, align 16 - %not = fcmp une <4 x float> %0, zeroinitializer - %1 = sext <4 x i1> %not to <4 x i32> - store <4 x i32> %1, <4 x i32>* %w, align 16 - %2 = load <4 x i32>, <4 x i32>* %w, align 16 - %3 = extractelement <4 x i32> %2, i64 0 - %4 = load <4 x i32>, <4 x i32>* %w, align 16 - %5 = extractelement <4 x i32> %4, i64 1 - %6 = load <4 x i32>, <4 x i32>* %w, align 16 - %7 = extractelement <4 x i32> %6, i64 2 - %8 = load <4 x i32>, <4 x i32>* %w, align 16 - %9 = extractelement <4 x i32> %8, i64 3 - %10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i32 0, i32 0), i32 %3, i32 %5, i32 %7, i32 %9) - ret void -} - -; Function Attrs: nounwind -define void @vector_bit_testi() #0 { -entry: - %y = alloca <4 x i32>, align 16 - %z = alloca <4 x i32>, align 16 - %w = alloca <4 x i32>, align 16 - store <4 x i32> , <4 x i32>* %y, align 16 - store <4 x i32> , <4 x i32>* %z, align 16 - store <4 x i32> zeroinitializer, <4 x i32>* %w, align 16 - %0 = load <4 x i32>, <4 x i32>* %y, align 16 - %1 = load <4 x i32>, <4 x i32>* %z, align 16 - %and = and <4 x i32> %0, %1 - store <4 x i32> %and, <4 x i32>* %w, align 16 - %2 = load <4 x i32>, <4 x i32>* %w, align 16 - %3 = extractelement <4 x i32> %2, i64 0 - %4 = load <4 x i32>, <4 x i32>* %w, align 16 - %5 = extractelement <4 x i32> %4, i64 1 - %6 = load <4 x i32>, <4 x i32>* %w, align 16 - %7 = extractelement <4 x i32> %6, i64 2 - %8 = load <4 x i32>, <4 x i32>* %w, align 16 - %9 = extractelement <4 x i32> %8, i64 3 - %10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i32 0, i32 0), i32 %3, i32 %5, i32 %7, i32 %9) - %11 = load <4 x i32>, <4 x i32>* %y, align 16 - %12 = load <4 x i32>, <4 x i32>* %z, align 16 - %or = or <4 x i32> %11, %12 - store <4 x i32> %or, <4 x i32>* %w, align 16 - %13 = load <4 x i32>, <4 x i32>* %w, align 16 - %14 = extractelement <4 x i32> %13, i64 0 - %15 = load <4 x i32>, <4 x i32>* %w, align 16 - %16 = extractelement <4 x i32> %15, i64 1 - %17 = load <4 x i32>, <4 x i32>* %w, align 16 - %18 = extractelement <4 x i32> %17, i64 2 - %19 = load <4 x i32>, <4 x i32>* %w, align 16 - %20 = extractelement <4 x i32> %19, i64 3 - %21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0), i32 %14, i32 %16, i32 %18, i32 %20) - %22 = load <4 x i32>, <4 x i32>* %y, align 16 - %23 = load <4 x i32>, <4 x i32>* %z, align 16 - %xor = xor <4 x i32> %22, %23 - store <4 x i32> %xor, <4 x i32>* %w, align 16 - %24 = load <4 x i32>, <4 x i32>* %w, align 16 - %25 = extractelement <4 x i32> %24, i64 0 - %26 = load <4 x i32>, <4 x i32>* %w, align 16 - %27 = extractelement <4 x i32> %26, i64 1 - %28 = load <4 x i32>, <4 x i32>* %w, align 16 - %29 = extractelement <4 x i32> %28, i64 2 - %30 = load <4 x i32>, <4 x i32>* %w, align 16 - %31 = extractelement <4 x i32> %30, i64 3 - %32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i32 %25, i32 %27, i32 %29, i32 %31) - %33 = load <4 x i32>, <4 x i32>* %y, align 16 - %bnot = xor <4 x i32> %33, - store <4 x i32> %bnot, <4 x i32>* %w, align 16 - %34 = load <4 x i32>, <4 x i32>* %w, align 16 - %35 = extractelement <4 x i32> %34, i64 0 - %36 = load <4 x i32>, <4 x i32>* %w, align 16 - %37 = extractelement <4 x i32> %36, i64 1 - %38 = load <4 x i32>, <4 x i32>* %w, align 16 - %39 = extractelement <4 x i32> %38, i64 2 - %40 = load <4 x i32>, <4 x i32>* %w, align 16 - %41 = extractelement <4 x i32> %40, i64 3 - %42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i32 0, i32 0), i32 %35, i32 %37, i32 %39, i32 %41) - %43 = load <4 x i32>, <4 x i32>* %y, align 16 - %44 = load <4 x i32>, <4 x i32>* %y, align 16 - %neg = sub <4 x i32> zeroinitializer, %44 - store <4 x i32> %neg, <4 x i32>* %w, align 16 - %45 = load <4 x i32>, <4 x i32>* %w, align 16 - %46 = extractelement <4 x i32> %45, i64 0 - %47 = load <4 x i32>, <4 x i32>* %w, align 16 - %48 = extractelement <4 x i32> %47, i64 1 - %49 = load <4 x i32>, <4 x i32>* %w, align 16 - %50 = extractelement <4 x i32> %49, i64 2 - %51 = load <4 x i32>, <4 x i32>* %w, align 16 - %52 = extractelement <4 x i32> %51, i64 3 - %53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i32 0, i32 0), i32 %46, i32 %48, i32 %50, i32 %52) - %54 = load <4 x i32>, <4 x i32>* %y, align 16 - %not = icmp eq <4 x i32> %54, zeroinitializer - %55 = sext <4 x i1> %not to <4 x i32> - store <4 x i32> %55, <4 x i32>* %w, align 16 - store <4 x i32> , <4 x i32>* %w, align 16 - %56 = load <4 x i32>, <4 x i32>* %w, align 16 - %not1 = icmp eq <4 x i32> %56, zeroinitializer - %57 = sext <4 x i1> %not1 to <4 x i32> - store <4 x i32> %57, <4 x i32>* %w, align 16 - %58 = load <4 x i32>, <4 x i32>* %w, align 16 - %59 = extractelement <4 x i32> %58, i64 0 - %60 = load <4 x i32>, <4 x i32>* %w, align 16 - %61 = extractelement <4 x i32> %60, i64 1 - %62 = load <4 x i32>, <4 x i32>* %w, align 16 - %63 = extractelement <4 x i32> %62, i64 2 - %64 = load <4 x i32>, <4 x i32>* %w, align 16 - %65 = extractelement <4 x i32> %64, i64 3 - %66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i32 0, i32 0), i32 %59, i32 %61, i32 %63, i32 %65) - ret void -} diff --git a/test/test_suite14/vector/vector_incdec.c3t b/test/test_suite14/vector/vector_incdec.c3t deleted file mode 100644 index 75c1132b6..000000000 --- a/test/test_suite14/vector/vector_incdec.c3t +++ /dev/null @@ -1,190 +0,0 @@ -// #target: macos-x64 -import libc; - -fn void testf() -{ - float[<4>] y = { 1, 2, 3, 4 }; - float[<4>] z = { 2, 2, 2, -100 }; - y += z; - libc::printf("Add %f %f %f %f\n", y[0], y[1], y[2], y[3]); - y++; - libc::printf("Inc %f %f %f %f\n", y[0], y[1], y[2], y[3]); - ++y; - libc::printf("Inc %f %f %f %f\n", y[0], y[1], y[2], y[3]); - y--; - libc::printf("Dec %f %f %f %f\n", y[0], y[1], y[2], y[3]); -} - -fn void testi() -{ - int[<4>] y = { 1, 2, 3, 4 }; - int[<4>] z = { 2, 2, 2, -100 }; - y += z; - libc::printf("Add %d %d %d %d\n", y[0], y[1], y[2], y[3]); - y++; - libc::printf("Inc %d %d %d %d\n", y[0], y[1], y[2], y[3]); - ++y; - libc::printf("Inc %d %d %d %d\n", y[0], y[1], y[2], y[3]); - int[<4>]w = y--; - libc::printf("Dec %d %d %d %d\n", y[0], y[1], y[2], y[3]); - libc::printf("Original %d %d %d %d\n", w[0], w[1], w[2], w[3]); -} - -fn void main() -{ - testf(); - testi(); -} - -/* #expect: vector_incdec.ll - -define void @vector_incdec_testf() #0 { -entry: - %y = alloca <4 x float>, align 16 - %z = alloca <4 x float>, align 16 - store <4 x float> , <4 x float>* %y, align 16 - store <4 x float> , <4 x float>* %z, align 16 - %0 = load <4 x float>, <4 x float>* %y, align 16 - %1 = load <4 x float>, <4 x float>* %z, align 16 - %fadd = fadd <4 x float> %0, %1 - store <4 x float> %fadd, <4 x float>* %y, align 16 - %2 = load <4 x float>, <4 x float>* %y, align 16 - %3 = extractelement <4 x float> %2, i64 0 - %fpfpext = fpext float %3 to double - %4 = load <4 x float>, <4 x float>* %y, align 16 - %5 = extractelement <4 x float> %4, i64 1 - %fpfpext1 = fpext float %5 to double - %6 = load <4 x float>, <4 x float>* %y, align 16 - %7 = extractelement <4 x float> %6, i64 2 - %fpfpext2 = fpext float %7 to double - %8 = load <4 x float>, <4 x float>* %y, align 16 - %9 = extractelement <4 x float> %8, i64 3 - %fpfpext3 = fpext float %9 to double - %10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), double %fpfpext, double %fpfpext1, double %fpfpext2, double %fpfpext3) - %11 = load <4 x float>, <4 x float>* %y, align 16 - %fincdec = fadd <4 x float> %11, - store <4 x float> %fincdec, <4 x float>* %y, align 16 - %12 = load <4 x float>, <4 x float>* %y, align 16 - %13 = extractelement <4 x float> %12, i64 0 - %fpfpext4 = fpext float %13 to double - %14 = load <4 x float>, <4 x float>* %y, align 16 - %15 = extractelement <4 x float> %14, i64 1 - %fpfpext5 = fpext float %15 to double - %16 = load <4 x float>, <4 x float>* %y, align 16 - %17 = extractelement <4 x float> %16, i64 2 - %fpfpext6 = fpext float %17 to double - %18 = load <4 x float>, <4 x float>* %y, align 16 - %19 = extractelement <4 x float> %18, i64 3 - %fpfpext7 = fpext float %19 to double - %20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i32 0, i32 0), double %fpfpext4, double %fpfpext5, double %fpfpext6, double %fpfpext7) - %21 = load <4 x float>, <4 x float>* %y, align 16 - %fincdec8 = fadd <4 x float> %21, - store <4 x float> %fincdec8, <4 x float>* %y, align 16 - %22 = load <4 x float>, <4 x float>* %y, align 16 - %23 = extractelement <4 x float> %22, i64 0 - %fpfpext9 = fpext float %23 to double - %24 = load <4 x float>, <4 x float>* %y, align 16 - %25 = extractelement <4 x float> %24, i64 1 - %fpfpext10 = fpext float %25 to double - %26 = load <4 x float>, <4 x float>* %y, align 16 - %27 = extractelement <4 x float> %26, i64 2 - %fpfpext11 = fpext float %27 to double - %28 = load <4 x float>, <4 x float>* %y, align 16 - %29 = extractelement <4 x float> %28, i64 3 - %fpfpext12 = fpext float %29 to double - %30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i32 0, i32 0), double %fpfpext9, double %fpfpext10, double %fpfpext11, double %fpfpext12) - %31 = load <4 x float>, <4 x float>* %y, align 16 - %fincdec13 = fadd <4 x float> %31, - store <4 x float> %fincdec13, <4 x float>* %y, align 16 - %32 = load <4 x float>, <4 x float>* %y, align 16 - %33 = extractelement <4 x float> %32, i64 0 - %fpfpext14 = fpext float %33 to double - %34 = load <4 x float>, <4 x float>* %y, align 16 - %35 = extractelement <4 x float> %34, i64 1 - %fpfpext15 = fpext float %35 to double - %36 = load <4 x float>, <4 x float>* %y, align 16 - %37 = extractelement <4 x float> %36, i64 2 - %fpfpext16 = fpext float %37 to double - %38 = load <4 x float>, <4 x float>* %y, align 16 - %39 = extractelement <4 x float> %38, i64 3 - %fpfpext17 = fpext float %39 to double - %40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), double %fpfpext14, double %fpfpext15, double %fpfpext16, double %fpfpext17) - ret void -} - -; Function Attrs: nounwind -define void @vector_incdec_testi() #0 { -entry: - %y = alloca <4 x i32>, align 16 - %z = alloca <4 x i32>, align 16 - %w = alloca <4 x i32>, align 16 - store <4 x i32> , <4 x i32>* %y, align 16 - store <4 x i32> , <4 x i32>* %z, align 16 - %0 = load <4 x i32>, <4 x i32>* %y, align 16 - %1 = load <4 x i32>, <4 x i32>* %z, align 16 - %add = add <4 x i32> %0, %1 - store <4 x i32> %add, <4 x i32>* %y, align 16 - %2 = load <4 x i32>, <4 x i32>* %y, align 16 - %3 = extractelement <4 x i32> %2, i64 0 - %4 = load <4 x i32>, <4 x i32>* %y, align 16 - %5 = extractelement <4 x i32> %4, i64 1 - %6 = load <4 x i32>, <4 x i32>* %y, align 16 - %7 = extractelement <4 x i32> %6, i64 2 - %8 = load <4 x i32>, <4 x i32>* %y, align 16 - %9 = extractelement <4 x i32> %8, i64 3 - %10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i32 0, i32 0), i32 %3, i32 %5, i32 %7, i32 %9) - %11 = load <4 x i32>, <4 x i32>* %y, align 16 - %add1 = add <4 x i32> %11, - store <4 x i32> %add1, <4 x i32>* %y, align 16 - %12 = load <4 x i32>, <4 x i32>* %y, align 16 - %13 = extractelement <4 x i32> %12, i64 0 - %14 = load <4 x i32>, <4 x i32>* %y, align 16 - %15 = extractelement <4 x i32> %14, i64 1 - %16 = load <4 x i32>, <4 x i32>* %y, align 16 - %17 = extractelement <4 x i32> %16, i64 2 - %18 = load <4 x i32>, <4 x i32>* %y, align 16 - %19 = extractelement <4 x i32> %18, i64 3 - %20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i32 0, i32 0), i32 %13, i32 %15, i32 %17, i32 %19) - %21 = load <4 x i32>, <4 x i32>* %y, align 16 - %add2 = add <4 x i32> %21, - store <4 x i32> %add2, <4 x i32>* %y, align 16 - %22 = load <4 x i32>, <4 x i32>* %y, align 16 - %23 = extractelement <4 x i32> %22, i64 0 - %24 = load <4 x i32>, <4 x i32>* %y, align 16 - %25 = extractelement <4 x i32> %24, i64 1 - %26 = load <4 x i32>, <4 x i32>* %y, align 16 - %27 = extractelement <4 x i32> %26, i64 2 - %28 = load <4 x i32>, <4 x i32>* %y, align 16 - %29 = extractelement <4 x i32> %28, i64 3 - %30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i32 0, i32 0), i32 %23, i32 %25, i32 %27, i32 %29) - %31 = load <4 x i32>, <4 x i32>* %y, align 16 - %sub = sub <4 x i32> %31, - store <4 x i32> %sub, <4 x i32>* %y, align 16 - store <4 x i32> %31, <4 x i32>* %w, align 16 - %32 = load <4 x i32>, <4 x i32>* %y, align 16 - %33 = extractelement <4 x i32> %32, i64 0 - %34 = load <4 x i32>, <4 x i32>* %y, align 16 - %35 = extractelement <4 x i32> %34, i64 1 - %36 = load <4 x i32>, <4 x i32>* %y, align 16 - %37 = extractelement <4 x i32> %36, i64 2 - %38 = load <4 x i32>, <4 x i32>* %y, align 16 - %39 = extractelement <4 x i32> %38, i64 3 - %40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i32 0, i32 0), i32 %33, i32 %35, i32 %37, i32 %39) - %41 = load <4 x i32>, <4 x i32>* %w, align 16 - %42 = extractelement <4 x i32> %41, i64 0 - %43 = load <4 x i32>, <4 x i32>* %w, align 16 - %44 = extractelement <4 x i32> %43, i64 1 - %45 = load <4 x i32>, <4 x i32>* %w, align 16 - %46 = extractelement <4 x i32> %45, i64 2 - %47 = load <4 x i32>, <4 x i32>* %w, align 16 - %48 = extractelement <4 x i32> %47, i64 3 - %49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i32 0, i32 0), i32 %42, i32 %44, i32 %46, i32 %48) - ret void -} - -define void @vector_incdec_main() #0 { -entry: - call void @vector_incdec_testf() - call void @vector_incdec_testi() - ret void -} diff --git a/test/test_suite14/vector/vector_init.c3t b/test/test_suite14/vector/vector_init.c3t deleted file mode 100644 index e1ed717de..000000000 --- a/test/test_suite14/vector/vector_init.c3t +++ /dev/null @@ -1,53 +0,0 @@ -// #target: macos-x64 -int[<4>] baz = { 1, 4, 5, 7 }; - -fn void main() -{ - int[<4>] foo = { 1, 2, 3, 4 }; - int z = foo[0]; - foo[2] = z + 1; - int[<4>] bar = {}; - int[<4>] bar2 = { 1, z, 3, 4 }; - int[<4>] bar3 = { [1] = z }; - int[<4>] bar4 = { [0..3] = z }; -} - -/* #expect: vector_init.ll - -@vector_init_baz = local_unnamed_addr global <4 x i32> , align 16 - -; Function Attrs: nounwind -define void @vector_init_main() #0 { -entry: - %foo = alloca <4 x i32>, align 16 - %z = alloca i32, align 4 - %bar = alloca <4 x i32>, align 16 - %bar2 = alloca <4 x i32>, align 16 - %bar3 = alloca <4 x i32>, align 16 - %bar4 = alloca <4 x i32>, align 16 - store <4 x i32> , <4 x i32>* %foo, align 16 - %0 = load <4 x i32>, <4 x i32>* %foo, align 16 - %1 = extractelement <4 x i32> %0, i64 0 - store i32 %1, i32* %z, align 4 - %2 = load <4 x i32>, <4 x i32>* %foo, align 16 - %3 = load i32, i32* %z, align 4 - %add = add i32 %3, 1 - %elemset = insertelement <4 x i32> %2, i32 %add, i64 2 - store <4 x i32> %elemset, <4 x i32>* %foo, align 16 - store <4 x i32> zeroinitializer, <4 x i32>* %bar, align 16 - %4 = load i32, i32* %z, align 4 - %5 = insertelement <4 x i32> , i32 %4, i64 1 - %6 = insertelement <4 x i32> %5, i32 3, i64 2 - %7 = insertelement <4 x i32> %6, i32 4, i64 3 - store <4 x i32> %7, <4 x i32>* %bar2, align 16 - %8 = load i32, i32* %z, align 4 - %9 = insertelement <4 x i32> zeroinitializer, i32 %8, i64 1 - store <4 x i32> %9, <4 x i32>* %bar3, align 16 - %10 = load i32, i32* %z, align 4 - %11 = insertelement <4 x i32> zeroinitializer, i32 %10, i64 0 - %12 = insertelement <4 x i32> %11, i32 %10, i64 1 - %13 = insertelement <4 x i32> %12, i32 %10, i64 2 - %14 = insertelement <4 x i32> %13, i32 %10, i64 3 - store <4 x i32> %14, <4 x i32>* %bar4, align 16 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/vector/vector_init_regression.c3t b/test/test_suite14/vector/vector_init_regression.c3t deleted file mode 100644 index 55b243b35..000000000 --- a/test/test_suite14/vector/vector_init_regression.c3t +++ /dev/null @@ -1,416 +0,0 @@ -// #target: macos-x64 -module test; -extern fn int printf(char* format, ...); - -fn void main() { - float radians = 3.1415 / 4; - float[<3>] axis = {0.0, 0.0, 1.0}; - - float cosr = (float) $$cos(radians); - float sinr = (float) $$sin(radians); - float x = axis[0]; - float y = axis[1]; - float z = axis[2]; - - float[<4>][4] a = {}; - a[0] = { - cosr + (x * x) * (float) (1.0 - cosr), - (x * y) * (float) (1.0 - cosr) - (z * sinr), - (x * z) * (float) (1.0 - cosr) + (y * sinr), - 0.0 - }; - - a[1] = { - (y * x) * (float) (1.0 - cosr) + (z * sinr), - cosr + (y * y) * (float) (1.0 - cosr), - (y * z) * (float) (1.0 - cosr) - (x * sinr), - 0.0 - }; - - a[2] = { - (z * x) * (float) (1.0 - cosr) - (y * sinr), - (z * y) * (float) (1.0 - cosr) + (x * sinr), - cosr + (z * z) * (float) (1.0 - cosr), - 0.0 - }; - - a[3] = { - 0.0, - 0.0, - 0.0, - 1.0 - }; - - float[<4>][4] b = { - { - cosr + (x * x) * (float) (1.0 - cosr), - (x * y) * (float) (1.0 - cosr) - (z * sinr), - (x * z) * (float) (1.0 - cosr) + (y * sinr), - 0.0 - }, - { - (y * x) * (float) (1.0 - cosr) + (z * sinr), - cosr + (y * y) * (float) (1.0 - cosr), - (y * z) * (float) (1.0 - cosr) - (x * sinr), - 0.0 - }, - { - (z * x) * (float) (1.0 - cosr) - (y * sinr), - (z * y) * (float) (1.0 - cosr) + (x * sinr), - cosr + (z * z) * (float) (1.0 - cosr), - 0.0 - }, - { - 0.0, - 0.0, - 0.0, - 1.0 - } - }; - - foreach(v : a) { - printf("A: %f %f %f %f\n", v[0], v[1], v[2], v[3]); - } - - printf("\n"); - - foreach(v : b) { - printf("B: %f %f %f %f\n", v[0], v[1], v[2], v[3]); - } -} - -/* #expect: test.ll - -define void @test_main() #0 { -entry: - %radians = alloca float, align 4 - %axis = alloca <3 x float>, align 16 - %cosr = alloca float, align 4 - %sinr = alloca float, align 4 - %x = alloca float, align 4 - %y = alloca float, align 4 - %z = alloca float, align 4 - %a = alloca [4 x <4 x float>], align 16 - %b = alloca [4 x <4 x float>], align 16 - %.anon = alloca i64, align 8 - %v = alloca <4 x float>, align 16 - %.anon85 = alloca i64, align 8 - %v89 = alloca <4 x float>, align 16 - store float 0x3FE921CAC0000000, float* %radians, align 4 - store <3 x float> , <3 x float>* %axis, align 16 - %0 = load float, float* %radians, align 4 - %1 = call float @llvm.cos.f32(float %0) - store float %1, float* %cosr, align 4 - %2 = load float, float* %radians, align 4 - %3 = call float @llvm.sin.f32(float %2) - store float %3, float* %sinr, align 4 - %4 = load <3 x float>, <3 x float>* %axis, align 16 - %5 = extractelement <3 x float> %4, i64 0 - store float %5, float* %x, align 4 - %6 = load <3 x float>, <3 x float>* %axis, align 16 - %7 = extractelement <3 x float> %6, i64 1 - store float %7, float* %y, align 4 - %8 = load <3 x float>, <3 x float>* %axis, align 16 - %9 = extractelement <3 x float> %8, i64 2 - store float %9, float* %z, align 4 - %10 = bitcast [4 x <4 x float>]* %a to i8* - call void @llvm.memset.p0i8.i64(i8* align 16 %10, i8 0, i64 64, i1 false) - %11 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %a, i64 0, i64 0 - %12 = load float, float* %cosr, align 4 - %13 = load float, float* %x, align 4 - %14 = load float, float* %x, align 4 - %fmul = fmul float %13, %14 - %15 = load float, float* %cosr, align 4 - %fpfpext = fpext float %15 to double - %fsub = fsub double 1.000000e+00, %fpfpext - %fpfptrunc = fptrunc double %fsub to float - %16 = call float @llvm.fmuladd.f32(float %fmul, float %fpfptrunc, float %12) - %17 = insertelement <4 x float> undef, float %16, i64 0 - %18 = load float, float* %x, align 4 - %19 = load float, float* %y, align 4 - %fmul1 = fmul float %18, %19 - %20 = load float, float* %cosr, align 4 - %fpfpext2 = fpext float %20 to double - %fsub3 = fsub double 1.000000e+00, %fpfpext2 - %fpfptrunc4 = fptrunc double %fsub3 to float - %21 = load float, float* %z, align 4 - %22 = load float, float* %sinr, align 4 - %fmul5 = fmul float %21, %22 - %23 = fneg float %fmul5 - %24 = call float @llvm.fmuladd.f32(float %fmul1, float %fpfptrunc4, float %23) - %25 = insertelement <4 x float> %17, float %24, i64 1 - %26 = load float, float* %x, align 4 - %27 = load float, float* %z, align 4 - %fmul6 = fmul float %26, %27 - %28 = load float, float* %cosr, align 4 - %fpfpext7 = fpext float %28 to double - %fsub8 = fsub double 1.000000e+00, %fpfpext7 - %fpfptrunc9 = fptrunc double %fsub8 to float - %29 = load float, float* %y, align 4 - %30 = load float, float* %sinr, align 4 - %fmul10 = fmul float %29, %30 - %31 = call float @llvm.fmuladd.f32(float %fmul6, float %fpfptrunc9, float %fmul10) - %32 = insertelement <4 x float> %25, float %31, i64 2 - %33 = insertelement <4 x float> %32, float 0.000000e+00, i64 3 - store <4 x float> %33, <4 x float>* %11, align 16 - %34 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %a, i64 0, i64 1 - %35 = load float, float* %y, align 4 - %36 = load float, float* %x, align 4 - %fmul11 = fmul float %35, %36 - %37 = load float, float* %cosr, align 4 - %fpfpext12 = fpext float %37 to double - %fsub13 = fsub double 1.000000e+00, %fpfpext12 - %fpfptrunc14 = fptrunc double %fsub13 to float - %38 = load float, float* %z, align 4 - %39 = load float, float* %sinr, align 4 - %fmul15 = fmul float %38, %39 - %40 = call float @llvm.fmuladd.f32(float %fmul11, float %fpfptrunc14, float %fmul15) - %41 = insertelement <4 x float> undef, float %40, i64 0 - %42 = load float, float* %cosr, align 4 - %43 = load float, float* %y, align 4 - %44 = load float, float* %y, align 4 - %fmul16 = fmul float %43, %44 - %45 = load float, float* %cosr, align 4 - %fpfpext17 = fpext float %45 to double - %fsub18 = fsub double 1.000000e+00, %fpfpext17 - %fpfptrunc19 = fptrunc double %fsub18 to float - %46 = call float @llvm.fmuladd.f32(float %fmul16, float %fpfptrunc19, float %42) - %47 = insertelement <4 x float> %41, float %46, i64 1 - %48 = load float, float* %y, align 4 - %49 = load float, float* %z, align 4 - %fmul20 = fmul float %48, %49 - %50 = load float, float* %cosr, align 4 - %fpfpext21 = fpext float %50 to double - %fsub22 = fsub double 1.000000e+00, %fpfpext21 - %fpfptrunc23 = fptrunc double %fsub22 to float - %51 = load float, float* %x, align 4 - %52 = load float, float* %sinr, align 4 - %fmul24 = fmul float %51, %52 - %53 = fneg float %fmul24 - %54 = call float @llvm.fmuladd.f32(float %fmul20, float %fpfptrunc23, float %53) - %55 = insertelement <4 x float> %47, float %54, i64 2 - %56 = insertelement <4 x float> %55, float 0.000000e+00, i64 3 - store <4 x float> %56, <4 x float>* %34, align 16 - %57 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %a, i64 0, i64 2 - %58 = load float, float* %z, align 4 - %59 = load float, float* %x, align 4 - %fmul25 = fmul float %58, %59 - %60 = load float, float* %cosr, align 4 - %fpfpext26 = fpext float %60 to double - %fsub27 = fsub double 1.000000e+00, %fpfpext26 - %fpfptrunc28 = fptrunc double %fsub27 to float - %61 = load float, float* %y, align 4 - %62 = load float, float* %sinr, align 4 - %fmul29 = fmul float %61, %62 - %63 = fneg float %fmul29 - %64 = call float @llvm.fmuladd.f32(float %fmul25, float %fpfptrunc28, float %63) - %65 = insertelement <4 x float> undef, float %64, i64 0 - %66 = load float, float* %z, align 4 - %67 = load float, float* %y, align 4 - %fmul30 = fmul float %66, %67 - %68 = load float, float* %cosr, align 4 - %fpfpext31 = fpext float %68 to double - %fsub32 = fsub double 1.000000e+00, %fpfpext31 - %fpfptrunc33 = fptrunc double %fsub32 to float - %69 = load float, float* %x, align 4 - %70 = load float, float* %sinr, align 4 - %fmul34 = fmul float %69, %70 - %71 = call float @llvm.fmuladd.f32(float %fmul30, float %fpfptrunc33, float %fmul34) - %72 = insertelement <4 x float> %65, float %71, i64 1 - %73 = load float, float* %cosr, align 4 - %74 = load float, float* %z, align 4 - %75 = load float, float* %z, align 4 - %fmul35 = fmul float %74, %75 - %76 = load float, float* %cosr, align 4 - %fpfpext36 = fpext float %76 to double - %fsub37 = fsub double 1.000000e+00, %fpfpext36 - %fpfptrunc38 = fptrunc double %fsub37 to float - %77 = call float @llvm.fmuladd.f32(float %fmul35, float %fpfptrunc38, float %73) - %78 = insertelement <4 x float> %72, float %77, i64 2 - %79 = insertelement <4 x float> %78, float 0.000000e+00, i64 3 - store <4 x float> %79, <4 x float>* %57, align 16 - %80 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %a, i64 0, i64 3 - store <4 x float> , <4 x float>* %80, align 16 - %81 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %b, i64 0, i64 0 - %82 = load float, float* %cosr, align 4 - %83 = load float, float* %x, align 4 - %84 = load float, float* %x, align 4 - %fmul39 = fmul float %83, %84 - %85 = load float, float* %cosr, align 4 - %fpfpext40 = fpext float %85 to double - %fsub41 = fsub double 1.000000e+00, %fpfpext40 - %fpfptrunc42 = fptrunc double %fsub41 to float - %86 = call float @llvm.fmuladd.f32(float %fmul39, float %fpfptrunc42, float %82) - %87 = insertelement <4 x float> undef, float %86, i64 0 - %88 = load float, float* %x, align 4 - %89 = load float, float* %y, align 4 - %fmul43 = fmul float %88, %89 - %90 = load float, float* %cosr, align 4 - %fpfpext44 = fpext float %90 to double - %fsub45 = fsub double 1.000000e+00, %fpfpext44 - %fpfptrunc46 = fptrunc double %fsub45 to float - %91 = load float, float* %z, align 4 - %92 = load float, float* %sinr, align 4 - %fmul47 = fmul float %91, %92 - %93 = fneg float %fmul47 - %94 = call float @llvm.fmuladd.f32(float %fmul43, float %fpfptrunc46, float %93) - %95 = insertelement <4 x float> %87, float %94, i64 1 - %96 = load float, float* %x, align 4 - %97 = load float, float* %z, align 4 - %fmul48 = fmul float %96, %97 - %98 = load float, float* %cosr, align 4 - %fpfpext49 = fpext float %98 to double - %fsub50 = fsub double 1.000000e+00, %fpfpext49 - %fpfptrunc51 = fptrunc double %fsub50 to float - %99 = load float, float* %y, align 4 - %100 = load float, float* %sinr, align 4 - %fmul52 = fmul float %99, %100 - %101 = call float @llvm.fmuladd.f32(float %fmul48, float %fpfptrunc51, float %fmul52) - %102 = insertelement <4 x float> %95, float %101, i64 2 - %103 = insertelement <4 x float> %102, float 0.000000e+00, i64 3 - store <4 x float> %103, <4 x float>* %81, align 16 - %104 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %b, i64 0, i64 1 - %105 = load float, float* %y, align 4 - %106 = load float, float* %x, align 4 - %fmul53 = fmul float %105, %106 - %107 = load float, float* %cosr, align 4 - %fpfpext54 = fpext float %107 to double - %fsub55 = fsub double 1.000000e+00, %fpfpext54 - %fpfptrunc56 = fptrunc double %fsub55 to float - %108 = load float, float* %z, align 4 - %109 = load float, float* %sinr, align 4 - %fmul57 = fmul float %108, %109 - %110 = call float @llvm.fmuladd.f32(float %fmul53, float %fpfptrunc56, float %fmul57) - %111 = insertelement <4 x float> undef, float %110, i64 0 - %112 = load float, float* %cosr, align 4 - %113 = load float, float* %y, align 4 - %114 = load float, float* %y, align 4 - %fmul58 = fmul float %113, %114 - %115 = load float, float* %cosr, align 4 - %fpfpext59 = fpext float %115 to double - %fsub60 = fsub double 1.000000e+00, %fpfpext59 - %fpfptrunc61 = fptrunc double %fsub60 to float - %116 = call float @llvm.fmuladd.f32(float %fmul58, float %fpfptrunc61, float %112) - %117 = insertelement <4 x float> %111, float %116, i64 1 - %118 = load float, float* %y, align 4 - %119 = load float, float* %z, align 4 - %fmul62 = fmul float %118, %119 - %120 = load float, float* %cosr, align 4 - %fpfpext63 = fpext float %120 to double - %fsub64 = fsub double 1.000000e+00, %fpfpext63 - %fpfptrunc65 = fptrunc double %fsub64 to float - %121 = load float, float* %x, align 4 - %122 = load float, float* %sinr, align 4 - %fmul66 = fmul float %121, %122 - %123 = fneg float %fmul66 - %124 = call float @llvm.fmuladd.f32(float %fmul62, float %fpfptrunc65, float %123) - %125 = insertelement <4 x float> %117, float %124, i64 2 - %126 = insertelement <4 x float> %125, float 0.000000e+00, i64 3 - store <4 x float> %126, <4 x float>* %104, align 16 - %127 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %b, i64 0, i64 2 - %128 = load float, float* %z, align 4 - %129 = load float, float* %x, align 4 - %fmul67 = fmul float %128, %129 - %130 = load float, float* %cosr, align 4 - %fpfpext68 = fpext float %130 to double - %fsub69 = fsub double 1.000000e+00, %fpfpext68 - %fpfptrunc70 = fptrunc double %fsub69 to float - %131 = load float, float* %y, align 4 - %132 = load float, float* %sinr, align 4 - %fmul71 = fmul float %131, %132 - %133 = fneg float %fmul71 - %134 = call float @llvm.fmuladd.f32(float %fmul67, float %fpfptrunc70, float %133) - %135 = insertelement <4 x float> undef, float %134, i64 0 - %136 = load float, float* %z, align 4 - %137 = load float, float* %y, align 4 - %fmul72 = fmul float %136, %137 - %138 = load float, float* %cosr, align 4 - %fpfpext73 = fpext float %138 to double - %fsub74 = fsub double 1.000000e+00, %fpfpext73 - %fpfptrunc75 = fptrunc double %fsub74 to float - %139 = load float, float* %x, align 4 - %140 = load float, float* %sinr, align 4 - %fmul76 = fmul float %139, %140 - %141 = call float @llvm.fmuladd.f32(float %fmul72, float %fpfptrunc75, float %fmul76) - %142 = insertelement <4 x float> %135, float %141, i64 1 - %143 = load float, float* %cosr, align 4 - %144 = load float, float* %z, align 4 - %145 = load float, float* %z, align 4 - %fmul77 = fmul float %144, %145 - %146 = load float, float* %cosr, align 4 - %fpfpext78 = fpext float %146 to double - %fsub79 = fsub double 1.000000e+00, %fpfpext78 - %fpfptrunc80 = fptrunc double %fsub79 to float - %147 = call float @llvm.fmuladd.f32(float %fmul77, float %fpfptrunc80, float %143) - %148 = insertelement <4 x float> %142, float %147, i64 2 - %149 = insertelement <4 x float> %148, float 0.000000e+00, i64 3 - store <4 x float> %149, <4 x float>* %127, align 16 - %150 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %b, i64 0, i64 3 - store <4 x float> , <4 x float>* %150, align 16 - store i64 0, i64* %.anon, align 8 - br label %loop.cond - -loop.cond: ; preds = %loop.body, %entry - %151 = load i64, i64* %.anon, align 8 - %gt = icmp ugt i64 4, %151 - br i1 %gt, label %loop.body, label %loop.exit - -loop.body: ; preds = %loop.cond - %152 = load i64, i64* %.anon, align 8 - %153 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %a, i64 0, i64 %152 - %154 = load <4 x float>, <4 x float>* %153, align 16 - store <4 x float> %154, <4 x float>* %v, align 16 - %155 = load <4 x float>, <4 x float>* %v, align 16 - %156 = extractelement <4 x float> %155, i64 0 - %fpfpext81 = fpext float %156 to double - %157 = load <4 x float>, <4 x float>* %v, align 16 - %158 = extractelement <4 x float> %157, i64 1 - %fpfpext82 = fpext float %158 to double - %159 = load <4 x float>, <4 x float>* %v, align 16 - %160 = extractelement <4 x float> %159, i64 2 - %fpfpext83 = fpext float %160 to double - %161 = load <4 x float>, <4 x float>* %v, align 16 - %162 = extractelement <4 x float> %161, i64 3 - %fpfpext84 = fpext float %162 to double - %163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i32 0, i32 0), double %fpfpext81, double %fpfpext82, double %fpfpext83, double %fpfpext84) - %164 = load i64, i64* %.anon, align 8 - %add = add i64 %164, 1 - store i64 %add, i64* %.anon, align 8 - br label %loop.cond - -loop.exit: ; preds = %loop.cond - %165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)) - store i64 0, i64* %.anon85, align 8 - br label %loop.cond86 - -loop.cond86: ; preds = %loop.body88, %loop.exit - %166 = load i64, i64* %.anon85, align 8 - %gt87 = icmp ugt i64 4, %166 - br i1 %gt87, label %loop.body88, label %loop.exit95 - -loop.body88: ; preds = %loop.cond86 - %167 = load i64, i64* %.anon85, align 8 - %168 = getelementptr inbounds [4 x <4 x float>], [4 x <4 x float>]* %b, i64 0, i64 %167 - %169 = load <4 x float>, <4 x float>* %168, align 16 - store <4 x float> %169, <4 x float>* %v89, align 16 - %170 = load <4 x float>, <4 x float>* %v89, align 16 - %171 = extractelement <4 x float> %170, i64 0 - %fpfpext90 = fpext float %171 to double - %172 = load <4 x float>, <4 x float>* %v89, align 16 - %173 = extractelement <4 x float> %172, i64 1 - %fpfpext91 = fpext float %173 to double - %174 = load <4 x float>, <4 x float>* %v89, align 16 - %175 = extractelement <4 x float> %174, i64 2 - %fpfpext92 = fpext float %175 to double - %176 = load <4 x float>, <4 x float>* %v89, align 16 - %177 = extractelement <4 x float> %176, i64 3 - %fpfpext93 = fpext float %177 to double - %178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0), double %fpfpext90, double %fpfpext91, double %fpfpext92, double %fpfpext93) - %179 = load i64, i64* %.anon85, align 8 - %add94 = add i64 %179, 1 - store i64 %add94, i64* %.anon85, align 8 - br label %loop.cond86 - -loop.exit95: ; preds = %loop.cond86 - ret void -} \ No newline at end of file diff --git a/test/test_suite14/vector/vector_ops2.c3t b/test/test_suite14/vector/vector_ops2.c3t deleted file mode 100644 index f895878df..000000000 --- a/test/test_suite14/vector/vector_ops2.c3t +++ /dev/null @@ -1,104 +0,0 @@ -// #target: macos-x64 -// #safe: yes -module test; -import libc; - -fn void testf() -{ - float[<4>] y = { 1, 2, 3, 4 }; - float[<4>] z = { 2, 2, 2, -100 }; - float[<4>] w = y + z; - w = y / z; -} - - -fn void testi() -{ - int[<4>] y = { 1, 2, 3, 4 }; - int[<4>] z = { 2, 2, 2, -100 }; - int[<4>] w = y / z; - w = z >> y; - w = z << y; -} - -/* #expect: test.ll - - %4 = call <4 x float> @llvm.fabs.v4f32(<4 x float> %3) - %5 = call float @llvm.vector.reduce.fmin.v4f32(<4 x float> %4) - %zero = fcmp ueq float %5, 0.000000e+00 - br i1 %zero, label %panic, label %checkok - -panic: ; preds = %entry - %6 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %6(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.panic_msg, i64 0, i64 0), i64 17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.file, i64 0, i64 0), i64 14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.func, i64 0, i64 0), i64 5, i32 9) - br label %checkok - -checkok: ; preds = %panic, %entry - %fdiv = fdiv <4 x float> %2, %3 - store <4 x float> %fdiv, <4 x float>* %w, align 16 - - %2 = call i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> %1) - %zero = icmp eq i32 %2, 0 - br i1 %zero, label %panic, label %checkok - -panic: ; preds = %entry - %3 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %3(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.panic_msg.1, i64 0, i64 0), i64 17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.file.2, i64 0, i64 0), i64 14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.func.3, i64 0, i64 0), i64 5, i32 17) - br label %checkok - -checkok: ; preds = %panic, %entry - %sdiv = sdiv <4 x i32> %0, %1 - store <4 x i32> %sdiv, <4 x i32>* %w, align 16 - %4 = load <4 x i32>, <4 x i32>* %z, align 16 - %5 = load <4 x i32>, <4 x i32>* %y, align 16 - %6 = call i32 @llvm.vector.reduce.smin.v4i32(<4 x i32> %5) - %shift_underflow = icmp slt i32 %6, 0 - br i1 %shift_underflow, label %panic1, label %checkok2 - -panic1: ; preds = %checkok - %7 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %7(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.panic_msg.4, i64 0, i64 0), i64 26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.file.5, i64 0, i64 0), i64 14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.func.6, i64 0, i64 0), i64 5, i32 18) - br label %checkok2 - -checkok2: ; preds = %panic1, %checkok - %8 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %5) - %shift_exceeds = icmp sge i32 %8, 32 - br i1 %shift_exceeds, label %panic3, label %checkok4 - -panic3: ; preds = %checkok2 - %9 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %9(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.panic_msg.7, i64 0, i64 0), i64 26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.file.8, i64 0, i64 0), i64 14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.func.9, i64 0, i64 0), i64 5, i32 18) - br label %checkok4 - -checkok4: ; preds = %panic3, %checkok2 - %ashr = ashr <4 x i32> %4, %5 - %10 = freeze <4 x i32> %ashr - store <4 x i32> %10, <4 x i32>* %w, align 16 - %11 = load <4 x i32>, <4 x i32>* %z, align 16 - %12 = load <4 x i32>, <4 x i32>* %y, align 16 - %13 = call i32 @llvm.vector.reduce.smin.v4i32(<4 x i32> %12) - %shift_underflow5 = icmp slt i32 %13, 0 - br i1 %shift_underflow5, label %panic6, label %checkok7 - -panic6: ; preds = %checkok4 - %14 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %14(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.panic_msg.10, i64 0, i64 0), i64 26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.file.11, i64 0, i64 0), i64 14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.func.12, i64 0, i64 0), i64 5, i32 19) - br label %checkok7 - -checkok7: ; preds = %panic6, %checkok4 - %15 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %12) - %shift_exceeds8 = icmp sge i32 %15, 32 - br i1 %shift_exceeds8, label %panic9, label %checkok10 - -panic9: ; preds = %checkok7 - %16 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8 - call void %16(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.panic_msg.13, i64 0, i64 0), i64 26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.file.14, i64 0, i64 0), i64 14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.func.15, i64 0, i64 0), i64 5, i32 19) - br label %checkok10 - -checkok10: ; preds = %panic9, %checkok7 - %shl = shl <4 x i32> %11, %12 - %17 = freeze <4 x i32> %shl - store <4 x i32> %17, <4 x i32>* %w, align 16 - ret void -} - diff --git a/test/test_suite14/vector/vector_to_array_cast.c3t b/test/test_suite14/vector/vector_to_array_cast.c3t deleted file mode 100644 index 50410c149..000000000 --- a/test/test_suite14/vector/vector_to_array_cast.c3t +++ /dev/null @@ -1,38 +0,0 @@ -// #target: macos-x64 - -module test; - -int[<2>] b = (int[<2>])(int[2] { 1, 2 }); -int[2] c = (int[2])(int[<2>] { 1, 2 }); - -fn void tester() -{ - int[<2>] x = { 1, 2 }; - int[2] y = (int[2])(x); - x = (int[<2>])(y); -} - -/* #expect: test.ll - -@test_b = local_unnamed_addr global <2 x i32> , align 8 -@test_c = local_unnamed_addr global [2 x i32] [i32 1, i32 2], align 4 - -define void @test_tester() #0 { -entry: - %x = alloca <2 x i32>, align 8 - %y = alloca [2 x i32], align 4 - store <2 x i32> , <2 x i32>* %x, align 8 - %0 = load <2 x i32>, <2 x i32>* %x, align 8 - %1 = extractelement <2 x i32> %0, i64 0 - %2 = insertvalue [2 x i32] undef, i32 %1, 0 - %3 = extractelement <2 x i32> %0, i64 1 - %4 = insertvalue [2 x i32] %2, i32 %3, 1 - store [2 x i32] %4, [2 x i32]* %y, align 4 - %5 = load [2 x i32], [2 x i32]* %y, align 4 - %6 = extractvalue [2 x i32] %5, 0 - %7 = insertelement <2 x i32> undef, i32 %6, i64 0 - %8 = extractvalue [2 x i32] %5, 1 - %9 = insertelement <2 x i32> %7, i32 %8, i64 1 - store <2 x i32> %9, <2 x i32>* %x, align 8 - ret void -} diff --git a/test/test_suite14/vector/vector_to_array_fail.c3 b/test/test_suite14/vector/vector_to_array_fail.c3 deleted file mode 100644 index e35b9a947..000000000 --- a/test/test_suite14/vector/vector_to_array_fail.c3 +++ /dev/null @@ -1,13 +0,0 @@ -module test; -import std::io; -fn void main() -{ - int[<2>] x = { 4, 7 }; - int[2] y = x; - int[*] y1 = y; - int[*] y2 = x; - int[<*>] z = x; - int[<*>] w = y; - double[<2>] ww = x; - double[<2>] www = y; // #error: 'int[2]' to 'double[<2>]' -} \ No newline at end of file diff --git a/test/test_suite14/visibility/ambiguous_var.c3t b/test/test_suite14/visibility/ambiguous_var.c3t deleted file mode 100644 index dfad51ace..000000000 --- a/test/test_suite14/visibility/ambiguous_var.c3t +++ /dev/null @@ -1,27 +0,0 @@ -// #file: file1.c3 -module foo; - -int a; -int b; - -// #file: file2.c3 -module bar; -int a; -int b; - -// #file: file3.c3 - -module baz; -import foo; -import bar; - -int a; - -private fn void test2() -{ - int c = a; // This is fine. - c = foo::b; - c = bar::b; - c = foo::a; - c = b; // #error: global variable 'b' is defined in both 'foo' and 'bar', please use either foo::b or bar::b to resolve the ambiguity -} diff --git a/test/test_suite14/visibility/no_shared_imports.c3t b/test/test_suite14/visibility/no_shared_imports.c3t deleted file mode 100644 index 420d4410c..000000000 --- a/test/test_suite14/visibility/no_shared_imports.c3t +++ /dev/null @@ -1,23 +0,0 @@ -// #file: file1.c3 -module baz; - -fn void runBar() -{ - visible(); - bar::barFunc(); // #error: 'bar::barFunc' could not be found, did you spell it right? -} - -// #file: file2.c3 -module baz; -import private bar; - -private fn void visible() -{ - bar::barFunc(); -} - -// #file: file3.c3 -module bar; - -private fn void barFunc() -{} \ No newline at end of file diff --git a/test/test_suite14/visibility/not_visible.c3t b/test/test_suite14/visibility/not_visible.c3t deleted file mode 100644 index 30aa271fa..000000000 --- a/test/test_suite14/visibility/not_visible.c3t +++ /dev/null @@ -1,16 +0,0 @@ -// #file: file1.c3 -module baz; -import bar; - -fn void runBar() -{ - bar::notVisible(); // #error: 'bar::notVisible' is not visible from this module. -} - -// #file: file2.c3 -module bar; - -private fn void notVisible() -{ - -} \ No newline at end of file diff --git a/test/test_suite14/visibility/private_import.c3 b/test/test_suite14/visibility/private_import.c3 deleted file mode 100644 index 32360a4c6..000000000 --- a/test/test_suite14/visibility/private_import.c3 +++ /dev/null @@ -1,21 +0,0 @@ -module foo; - -private fn void hidden() -{ -} - -module bar; -import foo; - -fn void test() -{ - foo::hidden(); // #error: The function 'foo::hidden' is not visible from this module. -} - -module baz; -import private foo; - -fn void test() -{ - foo::hidden(); -} \ No newline at end of file diff --git a/test/test_suite14/visibility/private_module.c3 b/test/test_suite14/visibility/private_module.c3 deleted file mode 100644 index 5faba9b0b..000000000 --- a/test/test_suite14/visibility/private_module.c3 +++ /dev/null @@ -1,17 +0,0 @@ -module private foo; - -fn void hidden() -{ -} - -module bar; -import foo; // #error: Importing a private module is not allowed (unless 'import private' is used). - - -module baz; -import private foo; - -fn void test() -{ - foo::hidden(); -} \ No newline at end of file diff --git a/test/test_suite14/visibility/shared_module.c3t b/test/test_suite14/visibility/shared_module.c3t deleted file mode 100644 index 3895bec2a..000000000 --- a/test/test_suite14/visibility/shared_module.c3t +++ /dev/null @@ -1,15 +0,0 @@ -// #file: file1.c3 -module baz; - -fn void runBar() -{ - visible(); -} - -// #file: file2.c3 -module baz; - -private fn void visible() -{ - -} \ No newline at end of file diff --git a/test/test_suite14/visibility/simple_visibility.c3t b/test/test_suite14/visibility/simple_visibility.c3t deleted file mode 100644 index a88afec45..000000000 --- a/test/test_suite14/visibility/simple_visibility.c3t +++ /dev/null @@ -1,16 +0,0 @@ -// #file: file1.c3 -module baz; -import bar; - -fn void runBar() -{ - bar::visible(); -} - -// #file: file2.c3 -module bar; - -fn void visible() -{ - -}