diff options
| author | Ginger Bill <bill@gingerbill.org> | 2016-09-18 21:44:22 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2016-09-18 21:44:22 +0100 |
| commit | 828095afd1351b218cae6b60033200a92894921c (patch) | |
| tree | eca72ccef9a122f809cc824d47989ad03077b833 /src/common.cpp | |
| parent | 2d6171f3e573c06dc9eb1c8fc3ada720998b24fa (diff) | |
Better name mangler for SSA generation
TODO: Define better name mangling rules and allow for explicit name overload
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp index 890c82373..db0a6ebdb 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -4,6 +4,21 @@ #include "string.cpp" + +struct BlockTimer { + u64 start; + u64 finish; + char *msg; + BlockTimer(char *msg) : msg(msg) { + start = gb_utc_time_now(); + } + ~BlockTimer() { + finish = gb_utc_time_now(); + gb_printf_err("%s - %llu us\n", finish-start); + } +}; + + // Hasing struct HashKey { @@ -45,6 +60,9 @@ b32 hash_key_equal(HashKey a, HashKey b) { } i64 next_pow2(i64 n) { + if (n <= 0) { + return 0; + } n--; n |= n >> 1; n |= n >> 2; @@ -56,6 +74,19 @@ i64 next_pow2(i64 n) { return n; } +i64 prev_pow2(i64 n) { + if (n <= 0) { + return 0; + } + n |= n >> 1; + n |= n >> 2; + n |= n >> 4; + n |= n >> 8; + n |= n >> 16; + n |= n >> 32; + return n - (n >> 1); +} + #define gb_for_array(index_, array_) for (isize index_ = 0; (array_) != NULL && index_ < gb_array_count(array_); index_++) |