Better name mangler for SSA generation

TODO: Define better name mangling rules and allow for explicit name overload
This commit is contained in:
Ginger Bill
2016-09-18 21:44:22 +01:00
parent 2d6171f3e5
commit 828095afd1
14 changed files with 195 additions and 547 deletions
+31
View File
@@ -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_++)