diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-08-14 15:10:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-14 15:10:31 +0100 |
| commit | e810c3eacec9cae74a369c747bbc5bd2a386d20d (patch) | |
| tree | f6ddfebe971d21ae6dc3ecf4c86c862c1c3ee96c /src/check_builtin.cpp | |
| parent | 18b6af185881b7ad413157af5c21bf9d77712632 (diff) | |
| parent | e29f0a0f40019d9a235e617759a24032a9688f85 (diff) | |
Merge pull request #4012 from laytan/posix
core:sys/posix and core:os/os2 based on it (for darwin, netbsd, freebsd and openbsd)
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index bde102a8d..e5282f63e 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -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 = {}; |