diff options
author | kugwa <kugwa2000@gmail.com> | 2016-01-21 19:22:39 +0800 |
---|---|---|
committer | kugwa <kugwa2000@gmail.com> | 2016-01-21 19:22:39 +0800 |
commit | c5de372c67e3c2d84ff17e0914bdcb5f4dad886b (patch) | |
tree | 4296097cf08a832874fa841c4365421a9133a210 | |
parent | 0b2af19e14053a2d02447a3fec93b2cf24a799aa (diff) | |
download | compiler2015-c5de372c67e3c2d84ff17e0914bdcb5f4dad886b.tar compiler2015-c5de372c67e3c2d84ff17e0914bdcb5f4dad886b.tar.gz compiler2015-c5de372c67e3c2d84ff17e0914bdcb5f4dad886b.tar.bz2 compiler2015-c5de372c67e3c2d84ff17e0914bdcb5f4dad886b.tar.lz compiler2015-c5de372c67e3c2d84ff17e0914bdcb5f4dad886b.tar.xz compiler2015-c5de372c67e3c2d84ff17e0914bdcb5f4dad886b.tar.zst compiler2015-c5de372c67e3c2d84ff17e0914bdcb5f4dad886b.zip |
Dynamically adjust the size of pool->spill
-rw-r--r-- | src/register.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/register.c b/src/register.c index 01a6fe2..77423e0 100644 --- a/src/register.c +++ b/src/register.c @@ -8,15 +8,19 @@ #include <string.h> #define REG_NUM 16 +// #define REG_NUM 5 #define REG_ADDR "x9" #define REG_SWAP "w10" #define REG_LOCK_MAX 3 #define REG_SIZE 4 -#define SPILL_MAX 64 -char print_buf[(REG_NUM + 1) * 25]; static const char *reg_name[REG_NUM] = { "w11", "w12", "w13", "w14", "w15", "w19", "w20", "w21", "w22", "w23", "w24", "w25", "w26", "w27", "w28", "w29"}; + // "w11", "w12", "w13", "w14", "w15"}; + +int spill_max = 32; + +char print_buf[(REG_NUM + 1) * 25]; CcmmcRegPool *ccmmc_register_init(FILE *asm_output) { @@ -29,7 +33,7 @@ CcmmcRegPool *ccmmc_register_init(FILE *asm_output) pool->list[i]->lock = false; pool->list[i]->name = reg_name[i]; } - pool->spill = malloc(sizeof(CcmmcTmp*) * SPILL_MAX); + pool->spill = malloc(sizeof(CcmmcTmp*) * spill_max); pool->top = 0; pool->lock_max = REG_LOCK_MAX; pool->lock_cnt = 0; @@ -65,6 +69,10 @@ CcmmcTmp *ccmmc_register_alloc(CcmmcRegPool *pool, uint64_t *offset) tmp->reg = NULL; // spill + if (pool->top - pool->num >= spill_max) { + spill_max *= 2; + pool->spill = realloc(pool->spill, sizeof(CcmmcTmp*) * spill_max); + } pool->spill[pool->top - pool->num] = tmp; // pool |