aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mips.c7
-rw-r--r--ssa.c8
2 files changed, 9 insertions, 6 deletions
diff --git a/mips.c b/mips.c
index ba81456..9605377 100644
--- a/mips.c
+++ b/mips.c
@@ -68,9 +68,10 @@ void mips_prologue(void) {
void mips_load(int reg, COpr_t opr) {
CVar_t var = opr->spill->info.var;
CType_t type = opr->type;
- if (type->type == CSTRUCT ||
+ if (opr->kind == VAR &&
+ (type->type == CSTRUCT ||
type->type == CUNION ||
- type->type == CARR)
+ type->type == CARR))
{
if (var->loc > 0)
printf("\tla $%d, _%s\n", reg, var->name);
@@ -214,7 +215,7 @@ void mips_space_alloc(void) {
int i;
for (i = 0; i < MAX_AVAIL_REGS; i++)
save_pos[avail_regs[i]] = prev + i * INT_SIZE;
- save_pos[30] = save_size;
+ save_pos[30] = prev + save_size;
save_size += INT_SIZE;
}
prev += save_size;
diff --git a/ssa.c b/ssa.c
index 82c865d..79d7b1a 100644
--- a/ssa.c
+++ b/ssa.c
@@ -1959,7 +1959,7 @@ int copr_comp(const void *a, const void *b) {
return (*(COpr_t *)a)->range->l - (*(COpr_t *)b)->range->l;
}
-const int avail_regs[] = {8, 9, 10, 11, 12, 13, 14, 15, 24, 25};
+const int avail_regs[] = {8, 9, 10, 11, 12, 13, 14, 15, 16, 24, 25};
const int MAX_AVAIL_REGS = sizeof(avail_regs) / sizeof(avail_regs[0]);
void register_alloc(void) {
@@ -2383,7 +2383,9 @@ void cexpmap_destroy(CExpMap_t cem) {
void copr_shortcut(COpr_t *opr) {
COpr_t t = *opr;
if (!t) return;
- *opr = t->same;
+ t = t->same;
+ if (t->kind == TMP)
+ *opr = t->same;
}
void subexp_elimination(void) {
@@ -2510,7 +2512,7 @@ void ssa_func(CType_t func) {
renaming_vars(oprs);
/* optimization on SSA */
const_propagation();
-/* subexp_elimination(); */
+ subexp_elimination();
strength_reduction();
/* out of SSA */
mark_insts();