STATIC void GenSaveRestoreRegs(int save) { int rstart, rstop, rinc, r; int mask = GenRegsUsed; mask &= ~(1 << Tr32OpReg0); // not preserved // mask &= ~(1 << Tr32OpRegY); // TBD??? Y is preserved, right??? mask &= ~(1 << Tr32OpRegBp); // taken care of mask &= ~(1 << Tr32OpRegSp); // taken care of mask &= ~(1 << Tr32OpRegFlags); // TBD??? flags aren't preserved, right??? if (save) rstart = Tr32OpReg0, rstop = Tr32OpRegFlags, rinc = 1; else rstart = Tr32OpRegFlags, rstop = Tr32OpReg0, rinc = -1; for (r = rstart; r != rstop; r += rinc) { int used = (mask & (1 << r)) != 0; if (save || used) { int pfx = used ? ' ' : ';'; printf2(save ? "\t%cpush\t" : "\t%cpop\t", pfx); GenPrintOperand(r, 0); GenPrintNewLine(); } } GenRegsUsed = mask; // undo changes in GenRegsUsed by GenPrintOperand() }
STATIC void GenPrintInstr1Operand(int instr, int instrval, int operand, int operandval) { GenPrintInstr(instr, instrval); GenPrintOperand(operand, operandval); GenPrintNewLine(); }
STATIC void GenPrintInstr2Operands(int instr, int instrval, int operand1, int operand1val, int operand2, int operand2val) { GenPrintInstr(instr, instrval); GenPrintOperand(operand1, operand1val); GenPrintOperandSeparator(); GenPrintOperand(operand2, operand2val); GenPrintNewLine(); }
void GenPrintInstr1Operand(int instr, int instrval, int operand, int operandval) { GenPrintInstr(instr, instrval); GenPrintOperand(operand, operandval); GenPrintNewLine(); #ifndef NO_REORDER_WORKAROUND if (instr == MipsInstrJ || instr == MipsInstrJAL) GenNop(); #endif }
void GenPrintInstr2Operands(int instr, int instrval, int operand1, int operand1val, int operand2, int operand2val) { if (operand2 == MipsOpConst && operand2val == 0 && (instr == MipsInstrAddU || instr == MipsInstrSubU)) return; GenPrintInstr(instr, instrval); GenPrintOperand(operand1, operand1val); GenPrintOperandSeparator(); GenPrintOperand(operand2, operand2val); GenPrintNewLine(); }
STATIC void GenPrintInstr3Operands(int instr, int instrval, int operand1, int operand1val, int operand2, int operand2val, int operand3, int operand3val) { if (operand3 == Tr32OpConst && operand3val == 0 && (instr == Tr32InstrAdd || instr == Tr32InstrSub) && operand1 == operand2) return; GenPrintInstr(instr, instrval); GenPrintOperand(operand1, operand1val); GenPrintOperandSeparator(); GenPrintOperand(operand2, operand2val); GenPrintOperandSeparator(); GenPrintOperand(operand3, operand3val); GenPrintNewLine(); }
void GenPrintInstr3Operands(int instr, int instrval, int operand1, int operand1val, int operand2, int operand2val, int operand3, int operand3val) { if (operand3 == MipsOpConst && operand3val == 0 && (instr == MipsInstrAddU || instr == MipsInstrSubU)) return; GenPrintInstr(instr, instrval); GenPrintOperand(operand1, operand1val); GenPrintOperandSeparator(); GenPrintOperand(operand2, operand2val); GenPrintOperandSeparator(); GenPrintOperand(operand3, operand3val); GenPrintNewLine(); #ifndef NO_REORDER_WORKAROUND if (instr == MipsInstrBEQ || instr == MipsInstrBNE) GenNop(); #endif }
void GenPrintInstrNoOperand(int instr) { GenPrintInstr(instr, 0); GenPrintNewLine(); }
STATIC void GenPrintInstrNoOperand(int instr, int instrval) { GenPrintInstr(instr, instrval); GenPrintNewLine(); }