Пример #1
0
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()
}
Пример #2
0
STATIC
void GenPrintInstr1Operand(int instr, int instrval, int operand, int operandval)
{
  GenPrintInstr(instr, instrval);
  GenPrintOperand(operand, operandval);
  GenPrintNewLine();
}
Пример #3
0
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();
}
Пример #4
0
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
}
Пример #5
0
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();
}
Пример #6
0
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();
}
Пример #7
0
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
}
Пример #8
0
void GenPrintInstrNoOperand(int instr)
{
  GenPrintInstr(instr, 0);
  GenPrintNewLine();
}
Пример #9
0
STATIC
void GenPrintInstrNoOperand(int instr, int instrval)
{
  GenPrintInstr(instr, instrval);
  GenPrintNewLine();
}