mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-25 23:14:59 -07:00
Better name mangler for SSA generation
TODO: Define better name mangling rules and allow for explicit name overload
This commit is contained in:
@@ -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_++)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user