diff options
-rw-r--r-- | src/register.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/register.c b/src/register.c index 43eb00f..0cf8a18 100644 --- a/src/register.c +++ b/src/register.c @@ -51,7 +51,10 @@ CcmmcTmp *ccmmc_register_alloc(CcmmcRegPool *pool, uint64_t *offset) } else { // gen code to alloc space on the stack - fprintf(pool->asm_output, "\tsub\tsp, sp, #%d\n", REG_SIZE); + fprintf(pool->asm_output, + "\t\t/* ccmmc_register_alloc(): */\n" + "\t\tsub\tsp, sp, #%d\n", + REG_SIZE); // tmp and offset *offset += REG_SIZE; @@ -88,11 +91,15 @@ const char *ccmmc_register_lock(CcmmcRegPool *pool, CcmmcTmp *tmp) assert(i < pool->num); //must found // gen code to swap the tmp in the register and the tmp on the stack - fprintf(pool->asm_output, "\tmov\t%s, %s\n", REG_RESERVED, + fprintf(pool->asm_output, + "\t\t/* ccmmc_register_lock(): swap %s, [fp, #-%" PRIu64 "] */\n", + pool->list[i]->name, + tmp->addr); + fprintf(pool->asm_output, "\t\tmov\t%s, %s\n", REG_RESERVED, pool->list[i]->name); - fprintf(pool->asm_output, "\tldr\t%s, [fp, #-%" PRIu64 "]\n", + fprintf(pool->asm_output, "\t\tldr\t%s, [fp, #-%" PRIu64 "]\n", pool->list[i]->name, tmp->addr); - fprintf(pool->asm_output, "\tstr\t%s, [fp, #-%" PRIu64 "]\n", + fprintf(pool->asm_output, "\t\tstr\t%s, [fp, #-%" PRIu64 "]\n", REG_RESERVED, tmp->addr); // find the index of tmp in pool->spill @@ -158,9 +165,10 @@ void ccmmc_register_free(CcmmcRegPool *pool, CcmmcTmp *tmp, uint64_t *offset) pool->top--; // gen code to move the last tmp to this register - fprintf(pool->asm_output, "\tldr\t%s, [fp, #-%" PRIu64 "]\n", + fprintf(pool->asm_output, "\t\t/* ccmmc_register_free(): */\n"); + fprintf(pool->asm_output, "\t\tldr\t%s, [fp, #-%" PRIu64 "]\n", tmp->reg->name, pool->spill[pool->top - pool->num]->addr); - fprintf(pool->asm_output, "\tadd\tsp, sp, #%d\n", REG_SIZE); + fprintf(pool->asm_output, "\t\tadd\tsp, sp, #%d\n", REG_SIZE); // offset *offset -= REG_SIZE; |