summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkugwa <kugwa2000@gmail.com>2016-01-03 15:30:23 +0800
committerkugwa <kugwa2000@gmail.com>2016-01-03 15:30:23 +0800
commit5547071a152f14999ac0087bc9b712877fa220e5 (patch)
treef808caeb958d7275ffa741c77311d0f442319af1
parent46df3a9fc34f5a6bf9ee73fc384179ad7bfefaec (diff)
downloadcompiler2015-5547071a152f14999ac0087bc9b712877fa220e5.tar
compiler2015-5547071a152f14999ac0087bc9b712877fa220e5.tar.gz
compiler2015-5547071a152f14999ac0087bc9b712877fa220e5.tar.bz2
compiler2015-5547071a152f14999ac0087bc9b712877fa220e5.tar.lz
compiler2015-5547071a152f14999ac0087bc9b712877fa220e5.tar.xz
compiler2015-5547071a152f14999ac0087bc9b712877fa220e5.tar.zst
compiler2015-5547071a152f14999ac0087bc9b712877fa220e5.zip
Comment and indent code generated by register.c
-rw-r--r--src/register.c20
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;