Line 78... |
Line 78... |
t = insn[i];
|
t = insn[i];
|
insn[i] = insn[j];
|
insn[i] = insn[j];
|
insn[j] = t;
|
insn[j] = t;
|
}
|
}
|
|
|
|
/* Negates conditional instruction */
|
|
void negate_conditional (cuc_insn *ii)
|
|
{
|
|
assert (ii->type & IT_COND);
|
|
|
|
if (ii->index == II_SFEQ) change_insn_type (ii, II_SFNE);
|
|
else if (ii->index == II_SFNE) change_insn_type (ii, II_SFEQ);
|
|
else if (ii->index == II_SFLT) change_insn_type (ii, II_SFGE);
|
|
else if (ii->index == II_SFGT) change_insn_type (ii, II_SFLE);
|
|
else if (ii->index == II_SFLE) change_insn_type (ii, II_SFGT);
|
|
else if (ii->index == II_SFGE) change_insn_type (ii, II_SFLT);
|
|
else assert (0);
|
|
}
|
|
|
/* Remove delay slots */
|
/* Remove delay slots */
|
void remove_dslots ()
|
void remove_dslots ()
|
{
|
{
|
int i;
|
int i;
|
int in_delay = 0;
|
int in_delay = 0;
|
Line 267... |
Line 281... |
insn[--d] = insn[i];
|
insn[--d] = insn[i];
|
change_insn_type (&insn[d], II_ADD);
|
change_insn_type (&insn[d], II_ADD);
|
insn[d].type = 0;
|
insn[d].type = 0;
|
insn[d].op[0] = -1; insn[d].opt[0] = OPT_REGISTER | OPT_DEST;
|
insn[d].op[0] = -1; insn[d].opt[0] = OPT_REGISTER | OPT_DEST;
|
insn[d].op[1] = insn[d].op[2]; insn[d].opt[1] = insn[d].opt[2];
|
insn[d].op[1] = insn[d].op[2]; insn[d].opt[1] = insn[d].opt[2];
|
insn[d].op[2] = 0x20000000; insn[d].opt[2] = OPT_CONST;
|
insn[d].op[2] = 0x80000000; insn[d].opt[2] = OPT_CONST;
|
insn[d].opt[3] = OPT_NONE;
|
insn[d].opt[3] = OPT_NONE;
|
|
|
insn[--d] = insn[i];
|
insn[--d] = insn[i];
|
change_insn_type (&insn[d], II_ADD);
|
change_insn_type (&insn[d], II_ADD);
|
insn[d].type = 0;
|
insn[d].type = 0;
|
insn[d].op[0] = -1; insn[d].opt[0] = OPT_REGISTER | OPT_DEST;
|
insn[d].op[0] = -1; insn[d].opt[0] = OPT_REGISTER | OPT_DEST;
|
insn[d].op[1] = insn[d].op[1]; insn[d].opt[1] = insn[d].opt[1];
|
insn[d].op[1] = insn[d].op[1]; insn[d].opt[1] = insn[d].opt[1];
|
insn[d].op[2] = 0x20000000; insn[d].opt[2] = OPT_CONST;
|
insn[d].op[2] = 0x80000000; insn[d].opt[2] = OPT_CONST;
|
insn[d].opt[3] = OPT_NONE;
|
insn[d].opt[3] = OPT_NONE;
|
|
|
reloc[i] = d;
|
reloc[i] = d;
|
} else {
|
} else {
|
insn[--d] = insn[i];
|
insn[--d] = insn[i];
|
Line 341... |
Line 355... |
insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
|
insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
|
insn[i].op[1] = 1; insn[i].opt[1] = OPT_CONST;
|
insn[i].op[1] = 1; insn[i].opt[1] = OPT_CONST;
|
insn[i].type |= IT_BRANCH | IT_VOLATILE;
|
insn[i].type |= IT_BRANCH | IT_VOLATILE;
|
} else {
|
} else {
|
i--;
|
i--;
|
if (f) {
|
|
//printf ("%s\n", cuc_insn_name (&insn[i]));
|
|
if (insn[i].index == II_SFEQ) change_insn_type (&insn[i], II_SFNE);
|
|
else if (insn[i].index == II_SFNE) change_insn_type (&insn[i], II_SFEQ);
|
|
else if (insn[i].index == II_SFLT) change_insn_type (&insn[i], II_SFGE);
|
|
else if (insn[i].index == II_SFGT) change_insn_type (&insn[i], II_SFLE);
|
|
else if (insn[i].index == II_SFLE) change_insn_type (&insn[i], II_SFGT);
|
|
else if (insn[i].index == II_SFGE) change_insn_type (&insn[i], II_SFLT);
|
|
else assert (0);
|
|
}
|
|
/* repair params */
|
/* repair params */
|
insn[i].op[2] = insn[i].op[1]; insn[i].opt[2] = insn[i].opt[1] & ~OPT_DEST;
|
insn[i].op[2] = insn[i].op[1]; insn[i].opt[2] = insn[i].opt[1] & ~OPT_DEST;
|
insn[i].op[1] = insn[i].op[0]; insn[i].opt[1] = insn[i].opt[0] & ~OPT_DEST;
|
insn[i].op[1] = insn[i].op[0]; insn[i].opt[1] = insn[i].opt[0] & ~OPT_DEST;
|
insn[i].op[0] = FLAG_REG; insn[i].opt[0] = OPT_DEST | OPT_REGISTER;
|
insn[i].op[0] = FLAG_REG; insn[i].opt[0] = OPT_DEST | OPT_REGISTER;
|
insn[i].opt[3] = OPT_NONE;
|
insn[i].opt[3] = OPT_NONE;
|
insn[i].type |= IT_COND;
|
insn[i].type |= IT_COND;
|
|
if (f) negate_conditional (&insn[i]);
|
i++;
|
i++;
|
change_insn_type (&insn[i], II_BF);
|
change_insn_type (&insn[i], II_BF);
|
insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
|
insn[i].op[0] = i + insn[i].op[0]; insn[i].opt[0] = OPT_JUMP;
|
insn[i].op[1] = FLAG_REG; insn[i].opt[1] = OPT_REGISTER;
|
insn[i].op[1] = FLAG_REG; insn[i].opt[1] = OPT_REGISTER;
|
insn[i].type |= IT_BRANCH | IT_VOLATILE;
|
insn[i].type |= IT_BRANCH | IT_VOLATILE;
|