Merge branch 'master' into const_array_broadcast

This commit is contained in:
gingerBill
2026-08-26 08:42:51 +01:00
committed by GitHub
14 changed files with 183 additions and 20 deletions

View File

@@ -5230,6 +5230,12 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
operand->type = t_invalid;
return false;
}
convert_to_typed(c, &x, t_int);
if (x.mode == Addressing_Invalid) {
operand->mode = Addressing_Type;
operand->type = t_invalid;
return false;
}
i64 count = big_int_to_i64(&x.value.value_integer);
check_expr_or_type(c, &y, ce->args[1]);
@@ -7710,6 +7716,12 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
return false;
}
convert_to_typed(c, &x, t_int);
if (x.mode == Addressing_Invalid) {
operand->mode = Addressing_Type;
operand->type = t_invalid;
return false;
}
i64 index = big_int_to_i64(&x.value.value_integer);
if (index < 0 || index >= u->Union.variants.count) {
error(call, "Variant tag out of bounds index for '%.*s", LIT(builtin_name));

View File

@@ -954,14 +954,17 @@ gb_internal void check_unroll_range_stmt(CheckerContext *ctx, Ast *node, u32 mod
error(x.expr, "Expected a constant integer for #unroll, got '%s'", s);
gb_string_free(s);
} else {
ExactValue value = exact_value_to_integer(x.value);
i64 v = exact_value_to_i64(value);
if (v < 1) {
error(x.expr, "Expected a constant integer >= 1 for #unroll, got %lld", cast(long long)v);
} else {
unroll_count = v;
if (v > 1024) {
error(x.expr, "Too large of a value for #unroll, got %lld, expected <= 1024", cast(long long)v);
convert_to_typed(ctx, &x, t_int);
if (x.mode != Addressing_Invalid) {
ExactValue value = exact_value_to_integer(x.value);
i64 v = exact_value_to_i64(value);
if (v < 1) {
error(x.expr, "Expected a constant integer >= 1 for #unroll, got %lld", cast(long long)v);
} else {
unroll_count = v;
if (v > 1024) {
error(x.expr, "Too large of a value for #unroll, got %lld, expected <= 1024", cast(long long)v);
}
}
}

View File

@@ -1120,6 +1120,13 @@ gb_internal void check_bit_field_type(CheckerContext *ctx, Type *bit_field_type,
gb_string_free(s);
}
if (o.mode == Addressing_Constant) {
convert_to_typed(ctx, &o, t_int);
if (o.mode == Addressing_Invalid) {
o.value = exact_value_i64(1);
}
}
ExactValue bit_size = o.value;
if (bit_size.kind != ExactValue_Integer) {

View File

@@ -1,6 +1,6 @@
// Generates Documentation
gb_global int print_entity_kind_ordering[Entity_Count] = {
gb_global int print_entity_kind_ordering[] = {
/*Invalid*/ -1,
/*Constant*/ 0,
/*Variable*/ 1,
@@ -12,8 +12,10 @@ gb_global int print_entity_kind_ordering[Entity_Count] = {
/*LibraryName*/ -1,
/*Nil*/ -1,
/*Label*/ -1,
/*AsmTemplate*/ 5,
};
gb_global char const *print_entity_names[Entity_Count] = {
GB_STATIC_ASSERT(gb_count_of(print_entity_kind_ordering) == Entity_Count);
gb_global char const *print_entity_names[] = {
/*Invalid*/ "",
/*Constant*/ "constants",
/*Variable*/ "variables",
@@ -25,7 +27,9 @@ gb_global char const *print_entity_names[Entity_Count] = {
/*LibraryName*/ "library names",
/*Nil*/ "",
/*Label*/ "",
/*AsmTemplate*/ "asm templates",
};
GB_STATIC_ASSERT(gb_count_of(print_entity_names) == Entity_Count);
gb_internal GB_COMPARE_PROC(cmp_entities_for_printing) {
@@ -257,6 +261,7 @@ gb_internal void print_doc_package(CheckerInfo *info, AstPackage *pkg) {
case Entity_ProcGroup:
case Entity_ImportName:
case Entity_LibraryName:
case Entity_AsmTemplate:
// Fine
break;
}

View File

@@ -994,7 +994,7 @@ gb_internal lbAddr lb_find_or_generate_context_ptr(lbProcedure *p) {
}
gb_internal lbValue lb_address_from_load_or_generate_local(lbProcedure *p, lbValue value) {
if (LLVMIsALoadInst(value.value)) {
if (!p->in_multi_assignment && LLVMIsALoadInst(value.value)) {
lbValue res = {};
res.value = LLVMGetOperand(value.value, 0);
res.type = alloc_type_pointer(value.type);

View File

@@ -3455,6 +3455,7 @@ gb_internal void print_show_unused(Checker *c) {
case Entity_ProcGroup:
case Entity_ImportName:
case Entity_LibraryName:
case Entity_AsmTemplate:
// Fine
break;
}

View File

@@ -2156,6 +2156,7 @@ gb_internal bool is_type_endian_specific(Type *t) {
case Basic_u32le:
case Basic_i64le:
case Basic_u64le:
case Basic_i128le:
case Basic_u128le:
return true;
@@ -2165,6 +2166,7 @@ gb_internal bool is_type_endian_specific(Type *t) {
case Basic_u32be:
case Basic_i64be:
case Basic_u64be:
case Basic_i128be:
case Basic_u128be:
return true;
@@ -3721,14 +3723,6 @@ gb_internal ProcTypeOverloadKind are_proc_types_overload_safe(Type *x, Type *y)
return ProcOverload_TargetFeatures;
}
if (px.params != nullptr && py.params != nullptr) {
Entity *ex = px.params->Tuple.variables[0];
Entity *ey = py.params->Tuple.variables[0];
bool ok = are_types_identical(ex->type, ey->type);
if (ok) {
}
}
return ProcOverload_Identical;
}