Merge pull request #7239 from catermujo/push-oyzvqkzwnlzz

llvm: handle #soa fixed compound literals for vars
This commit is contained in:
gingerBill
2026-08-07 19:58:11 +02:00
committed by GitHub
4 changed files with 70 additions and 24 deletions

View File

@@ -4924,6 +4924,11 @@ gb_internal void lb_build_addr_compound_lit_populate(lbProcedure *p, Slice<Ast *
case Type_SimdVector: et = bt->SimdVector.elem; break;
case Type_Matrix: et = bt->Matrix.elem; break;
case Type_FixedCapacityDynamicArray: et = bt->FixedCapacityDynamicArray.elem; break;
case Type_Struct:
if (bt->Struct.soa_kind == StructSoa_Fixed) {
et = bt->Struct.soa_elem;
}
break;
}
GB_ASSERT(et != nullptr);
@@ -5038,18 +5043,17 @@ gb_internal void lb_build_addr_compound_lit_populate(lbProcedure *p, Slice<Ast *
}
gb_internal void lb_build_addr_compound_lit_assign_array(lbProcedure *p, Array<lbCompoundLitElemTempData> const &temp_data) {
for (auto const &td : temp_data) {
if (td.value.value != nullptr) {
if (td.elem_length > 0) {
auto loop_data = lb_loop_start(p, cast(isize)td.elem_length, t_i32);
{
lbValue dst = td.gep;
dst = lb_emit_ptr_offset(p, dst, loop_data.idx);
lb_emit_store(p, dst, td.value);
}
lb_loop_end(p, loop_data);
} else {
lb_emit_store(p, td.gep, td.value);
GB_ASSERT(td.value.value != nullptr);
if (td.elem_length > 0) {
auto loop_data = lb_loop_start(p, cast(isize)td.elem_length, t_i32);
{
lbValue dst = td.gep;
dst = lb_emit_ptr_offset(p, dst, loop_data.idx);
lb_emit_store(p, dst, td.value);
}
lb_loop_end(p, loop_data);
} else {
lb_emit_store(p, td.gep, td.value);
}
}
}
@@ -6120,7 +6124,35 @@ gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) {
}
case Type_Struct:
lb_build_addr_struct_compound_lit_populate(p, expr, type, v);
if (is_type_soa_struct(type)) {
GB_ASSERT(bt->Struct.soa_kind == StructSoa_Fixed);
if (cl->elems.count == 0) {
break;
}
lb_addr_store(p, v, lb_const_value(p->module, type, exact_value_compound(expr)));
auto temp_data = array_make<lbCompoundLitElemTempData>(temporary_allocator(), 0, cl->elems.count);
lb_build_addr_compound_lit_populate(p, cl->elems, &temp_data, type);
for (auto const &td : temp_data) {
GB_ASSERT(td.value.value != nullptr);
lbValue offset = lb_const_int(p->module, t_i32, td.elem_index);
if (td.elem_length > 0) {
auto loop_data = lb_loop_start(p, cast(isize)td.elem_length, t_i32);
{
lbValue index = lb_emit_arith(p, Token_Add, offset, loop_data.idx, t_i32);
lbAddr dst = lb_addr_soa_variable(v.addr, index, td.expr);
lb_addr_store(p, dst, td.value);
}
lb_loop_end(p, loop_data);
} else {
lbValue index = offset;
lbAddr dst = lb_addr_soa_variable(v.addr, index, td.expr);
lb_addr_store(p, dst, td.value);
}
}
} else {
lb_build_addr_struct_compound_lit_populate(p, expr, type, v);
}
break;
case Type_Map: {

View File

@@ -42,6 +42,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
..\..\..\odin check ..\test_issue_6874.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b
..\..\..\odin check ..\test_issue_6979.odin -no-entry-point %COMMON% || exit /b
..\..\..\odin build ..\test_issue_7037.odin %COMMON% -o:none || exit /b
..\..\..\odin build ..\test_issue_7188.odin %COMMON% || exit /b
..\..\..\odin build ..\test_issue_7073-1.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "2" || exit /b
@echo off

View File

@@ -7,10 +7,9 @@ ODIN=../../../odin
COMMON="-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused-defineables -microarch:native"
COMMON_CHECK="-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused-defineables"
set -x
$ODIN test ../test_issue_829.odin $COMMON
$ODIN test ../test_issue_829.odin $COMMON
$ODIN test ../test_issue_1592.odin $COMMON
$ODIN test ../test_issue_1730.odin $COMMON
$ODIN test ../test_issue_2056.odin $COMMON
@@ -24,7 +23,7 @@ $ODIN test ../test_issue_3435.odin $COMMON
$ODIN test ../test_issue_4210.odin $COMMON
$ODIN test ../test_issue_4364.odin $COMMON
$ODIN test ../test_issue_4584.odin $COMMON
if [[ $($ODIN build ../test_issue_2395.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then
if [[ $($ODIN build ../test_issue_2395.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
@@ -34,7 +33,7 @@ $ODIN build ../test_issue_5043.odin $COMMON
$ODIN build ../test_issue_5097.odin $COMMON
$ODIN build ../test_issue_5097-2.odin $COMMON
$ODIN build ../test_issue_5265.odin $COMMON
if [[ $($ODIN build ../test_issue_5573.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then
if [[ $($ODIN build ../test_issue_5573.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
@@ -49,25 +48,25 @@ $ODIN test ../test_issue_6344.odin $COMMON -o:speed
$ODIN test ../test_issue_6396.odin $COMMON
$ODIN test ../test_pr_6476.odin $COMMON
if [[ $($ODIN build ../test_issue_6240.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 3 ]] ; then
if [[ $($ODIN build ../test_issue_6240.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 3 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
exit 1
fi
if [[ $($ODIN build ../test_issue_6401.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 3 ]] ; then
if [[ $($ODIN build ../test_issue_6401.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 3 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
exit 1
fi
if [[ $($ODIN build ../test_issue_6594.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]] ; then
if [[ $($ODIN build ../test_issue_6594.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
exit 1
fi
if [[ $($ODIN build ../test_issue_6621.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]] ; then
if [[ $($ODIN build ../test_issue_6621.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
@@ -75,7 +74,7 @@ else
fi
$ODIN test ../test_issue_6419.odin $COMMON
$ODIN test ../test_pr_6470.odin $COMMON
if [[ $($ODIN test ../test_pr_6470.odin -define:TEST_EXPECT_FAILURE=true $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]] ; then
if [[ $($ODIN test ../test_pr_6470.odin -define:TEST_EXPECT_FAILURE=true $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
@@ -83,7 +82,7 @@ else
fi
$ODIN check ../test_issue_6484.odin -no-entry-point $COMMON_CHECK
$ODIN test ../test_issue_6753.odin $COMMON
if [[ $($ODIN check ../test_issue_6874.odin $COMMON_CHECK 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]] ; then
if [[ $($ODIN check ../test_issue_6874.odin $COMMON_CHECK 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
@@ -92,15 +91,16 @@ fi
$ODIN check ../test_issue_6979.odin -no-entry-point $COMMON_CHECK
$ODIN build ../test_issue_7037.odin $COMMON -o:none
$ODIN build ../test_issue_7167.odin $COMMON
$ODIN build ../test_issue_7188.odin $COMMON
if [[ $($ODIN build ../test_issue_7108.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then
if [[ $($ODIN build ../test_issue_7108.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
exit 1
fi
if [[ $($ODIN build ../test_issue_7073-1.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then
if [[ $($ODIN build ../test_issue_7073-1.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]]; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"

View File

@@ -0,0 +1,13 @@
package test_issues
main :: proc() {
val: f32 = 42.0
// unable to broadcast like ([4][4]f32)(1) or (#soa[4][4]f32)(([4]f32)(1))
_ = #soa[2][2]f32 {
0..<2 = val
}
vtxs := #soa[33][2]f32 {
0..<33 = val
}
_ = vtxs.x[32]
}