mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-26 07:25:00 -07:00
Merge pull request #4012 from laytan/posix
core:sys/posix and core:os/os2 based on it (for darwin, netbsd, freebsd and openbsd)
This commit is contained in:
@@ -621,3 +621,7 @@ gb_internal String big_int_to_string(gbAllocator allocator, BigInt const *x, u64
|
||||
}
|
||||
return make_string(cast(u8 *)buf.data, buf.count);
|
||||
}
|
||||
|
||||
gb_internal int big_int_log2(BigInt const *x) {
|
||||
return mp_count_bits(x) - 1;
|
||||
}
|
||||
|
||||
@@ -3979,6 +3979,23 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
||||
break;
|
||||
}
|
||||
|
||||
case BuiltinProc_constant_log2: {
|
||||
Operand o = {};
|
||||
check_expr(c, &o, ce->args[0]);
|
||||
|
||||
if (!is_type_integer(o.type) && (o.mode != Addressing_Constant)) {
|
||||
error(ce->args[0], "Expected a constant integer for '%.*s'", LIT(builtin_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
int log2 = big_int_log2(&o.value.value_integer);
|
||||
|
||||
operand->mode = Addressing_Constant;
|
||||
operand->value = exact_value_i64(cast(i64)log2);
|
||||
operand->type = t_untyped_integer;
|
||||
break;
|
||||
}
|
||||
|
||||
case BuiltinProc_soa_struct: {
|
||||
Operand x = {};
|
||||
Operand y = {};
|
||||
|
||||
+18
-2
@@ -756,13 +756,29 @@ gb_internal bool are_signatures_similar_enough(Type *a_, Type *b_) {
|
||||
for (isize i = 0; i < a->param_count; i++) {
|
||||
Type *x = core_type(a->params->Tuple.variables[i]->type);
|
||||
Type *y = core_type(b->params->Tuple.variables[i]->type);
|
||||
|
||||
if (x->kind == Type_BitSet && x->BitSet.underlying) {
|
||||
x = core_type(x->BitSet.underlying);
|
||||
}
|
||||
if (y->kind == Type_BitSet && y->BitSet.underlying) {
|
||||
y = core_type(y->BitSet.underlying);
|
||||
}
|
||||
|
||||
if (!signature_parameter_similar_enough(x, y)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (isize i = 0; i < a->result_count; i++) {
|
||||
Type *x = base_type(a->results->Tuple.variables[i]->type);
|
||||
Type *y = base_type(b->results->Tuple.variables[i]->type);
|
||||
Type *x = core_type(a->results->Tuple.variables[i]->type);
|
||||
Type *y = core_type(b->results->Tuple.variables[i]->type);
|
||||
|
||||
if (x->kind == Type_BitSet && x->BitSet.underlying) {
|
||||
x = core_type(x->BitSet.underlying);
|
||||
}
|
||||
if (y->kind == Type_BitSet && y->BitSet.underlying) {
|
||||
y = core_type(y->BitSet.underlying);
|
||||
}
|
||||
|
||||
if (!signature_parameter_similar_enough(x, y)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ enum BuiltinProcId {
|
||||
|
||||
BuiltinProc_has_target_feature,
|
||||
|
||||
BuiltinProc_constant_log2,
|
||||
|
||||
BuiltinProc_transpose,
|
||||
BuiltinProc_outer_product,
|
||||
BuiltinProc_hadamard_product,
|
||||
@@ -380,6 +382,8 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = {
|
||||
|
||||
{STR_LIT("has_target_feature"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||
|
||||
{STR_LIT("constant_log2"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||
|
||||
{STR_LIT("transpose"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||
{STR_LIT("outer_product"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||
{STR_LIT("hadamard_product"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||
|
||||
Reference in New Issue
Block a user