From 483a72ac61f6e67ac7077a9b5d715ea23e933d22 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Wed, 3 Aug 2022 12:34:03 -0400 Subject: fixed debug symbols for range interval --- src/llvm_backend_stmt.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/llvm_backend_stmt.cpp') diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index f131bb3db..8f5120946 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -458,15 +458,6 @@ void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node, val1_type = type_of_expr(rs->vals[1]); } - if (val0_type != nullptr) { - Entity *e = entity_of_node(rs->vals[0]); - lb_add_local(p, e->type, e, true); - } - if (val1_type != nullptr) { - Entity *e = entity_of_node(rs->vals[1]); - lb_add_local(p, e->type, e, true); - } - TokenKind op = Token_Lt; switch (node->op.kind) { case Token_Ellipsis: op = Token_LtEq; break; @@ -478,10 +469,22 @@ void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node, lbValue lower = lb_build_expr(p, node->left); lbValue upper = {}; // initialized each time in the loop - lbAddr value = lb_add_local_generated(p, val0_type ? val0_type : lower.type, false); + lbAddr value; + if (val0_type != nullptr) { + Entity *e = entity_of_node(rs->vals[0]); + value = lb_add_local(p, val0_type ? val0_type : lower.type, e, false); + } else { + value = lb_add_local_generated(p, val0_type ? val0_type : lower.type, false); + } lb_addr_store(p, value, lower); - lbAddr index = lb_add_local_generated(p, t_int, false); + lbAddr index; + if (val1_type != nullptr) { + Entity *e = entity_of_node(rs->vals[1]); + index = lb_add_local(p, t_int, e, false); + } else { + index = lb_add_local_generated(p, t_int, false); + } lb_addr_store(p, index, lb_const_int(m, t_int, 0)); lbBlock *loop = lb_create_block(p, "for.interval.loop"); -- cgit v1.2.3 From 595efba747f791634f3dee67a7cbf466f86af988 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Thu, 11 Aug 2022 11:43:19 -0400 Subject: removed unnecessary ternary --- src/llvm_backend_stmt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/llvm_backend_stmt.cpp') diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index 8f5120946..2aa9ba802 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -472,9 +472,9 @@ void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node, lbAddr value; if (val0_type != nullptr) { Entity *e = entity_of_node(rs->vals[0]); - value = lb_add_local(p, val0_type ? val0_type : lower.type, e, false); + value = lb_add_local(p, val0_type, e, false); } else { - value = lb_add_local_generated(p, val0_type ? val0_type : lower.type, false); + value = lb_add_local_generated(p, lower.type, false); } lb_addr_store(p, value, lower); -- cgit v1.2.3 From f5431a046decd81ddb6eed7165368a44913eaca1 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Mon, 15 Aug 2022 08:08:49 -0400 Subject: using correct type for val1 --- src/llvm_backend_stmt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/llvm_backend_stmt.cpp') diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index 2aa9ba802..e55fae3a7 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -481,7 +481,7 @@ void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node, lbAddr index; if (val1_type != nullptr) { Entity *e = entity_of_node(rs->vals[1]); - index = lb_add_local(p, t_int, e, false); + index = lb_add_local(p, val1_type, e, false); } else { index = lb_add_local_generated(p, t_int, false); } -- cgit v1.2.3 From aeacf3a9d8a1f6aa36d5c1315e1d8529bb985847 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 24 Aug 2022 13:07:41 +0100 Subject: Correct max alignment handling throughout the llvm backend --- src/build_settings.cpp | 22 ++++++++++++---------- src/llvm_abi.cpp | 2 +- src/llvm_backend_expr.cpp | 6 +++--- src/llvm_backend_general.cpp | 5 ++++- src/llvm_backend_stmt.cpp | 2 +- src/types.cpp | 2 +- 6 files changed, 22 insertions(+), 17 deletions(-) (limited to 'src/llvm_backend_stmt.cpp') diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 3ad4dd3e3..3f6be3c48 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -428,12 +428,13 @@ gb_global TargetMetrics target_essence_amd64 = { str_lit("x86_64-pc-none-elf"), }; + gb_global TargetMetrics target_freestanding_wasm32 = { TargetOs_freestanding, TargetArch_wasm32, 4, 8, 16, str_lit("wasm32-freestanding-js"), - str_lit(""), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; gb_global TargetMetrics target_js_wasm32 = { @@ -441,15 +442,7 @@ gb_global TargetMetrics target_js_wasm32 = { TargetArch_wasm32, 4, 8, 16, str_lit("wasm32-js-js"), - str_lit(""), -}; - -gb_global TargetMetrics target_js_wasm64 = { - TargetOs_js, - TargetArch_wasm64, - 8, 8, 16, - str_lit("wasm64-js-js"), - str_lit(""), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; gb_global TargetMetrics target_wasi_wasm32 = { @@ -457,6 +450,15 @@ gb_global TargetMetrics target_wasi_wasm32 = { TargetArch_wasm32, 4, 8, 16, str_lit("wasm32-wasi-js"), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), +}; + + +gb_global TargetMetrics target_js_wasm64 = { + TargetOs_js, + TargetArch_wasm64, + 8, 8, 16, + str_lit("wasm64-js-js"), str_lit(""), }; diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 2ee8dc673..4bdc31077 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -294,7 +294,7 @@ i64 lb_alignof(LLVMTypeRef type) { i64 elem_size = lb_sizeof(elem); i64 count = LLVMGetVectorSize(type); i64 size = count * elem_size; - return gb_clamp(next_pow2(size), 1, build_context.max_align); + return gb_clamp(next_pow2(size), 1, build_context.max_simd_align); } } diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index dd66943d7..7d81d1407 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -137,7 +137,7 @@ lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x, Type *type) lbAddr res_addr = lb_add_local(p, type, nullptr, false, 0, true); lbValue res = lb_addr_get_ptr(p, res_addr); - bool inline_array_arith = type_size_of(type) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(type); i32 count = cast(i32)get_array_type_count(tl); @@ -436,7 +436,7 @@ lbValue lb_emit_arith_array(lbProcedure *p, TokenKind op, lbValue lhs, lbValue r return direct_vector_res; } - bool inline_array_arith = type_size_of(type) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(type); if (inline_array_arith) { auto dst_ptrs = slice_make(temporary_allocator(), n); @@ -2303,7 +2303,7 @@ lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue ri cmp_op = Token_And; } - bool inline_array_arith = type_size_of(tl) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(tl); i32 count = 0; switch (tl->kind) { case Type_Array: count = cast(i32)tl->Array.count; break; diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 071986458..6f98458fa 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -591,6 +591,9 @@ bool lb_try_update_alignment(lbValue ptr, unsigned alignment) { return lb_try_update_alignment(ptr.value, alignment); } +bool lb_can_try_to_inline_array_arith(Type *t) { + return type_size_of(t) <= build_context.max_simd_align; +} bool lb_try_vector_cast(lbModule *m, lbValue ptr, LLVMTypeRef *vector_type_) { Type *array_type = base_type(type_deref(ptr.type)); @@ -599,7 +602,7 @@ bool lb_try_vector_cast(lbModule *m, lbValue ptr, LLVMTypeRef *vector_type_) { Type *elem_type = base_array_type(array_type); // TODO(bill): Determine what is the correct limit for doing vector arithmetic - if (type_size_of(array_type) <= build_context.max_align && + if (lb_can_try_to_inline_array_arith(array_type) && is_type_valid_vector_elem(elem_type)) { // Try to treat it like a vector if possible bool possible = false; diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index e55fae3a7..175c4c537 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -1796,7 +1796,7 @@ void lb_build_assign_stmt_array(lbProcedure *p, TokenKind op, lbAddr const &lhs, lbValue rhs = lb_emit_conv(p, value, lhs_type); - bool inline_array_arith = type_size_of(array_type) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(array_type); if (lhs.kind == lbAddr_Swizzle) { diff --git a/src/types.cpp b/src/types.cpp index aa4a3c4a1..b7cb4dd2c 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1428,7 +1428,7 @@ i64 matrix_align_of(Type *t, struct TypePath *tp) { } GB_ASSERT(min_alignment >= elem_align); - i64 align = gb_min(min_alignment, build_context.max_align); + i64 align = gb_min(min_alignment, build_context.max_simd_align); return align; } -- cgit v1.2.3