From c5de372c67e3c2d84ff17e0914bdcb5f4dad886b Mon Sep 17 00:00:00 2001 From: kugwa Date: Thu, 21 Jan 2016 19:22:39 +0800 Subject: Dynamically adjust the size of pool->spill --- src/register.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') 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 #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 -- cgit v1.2.3