예제 #1
0
파일: cgtr3k2.c 프로젝트: gdos/SmallerC
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();
}
예제 #2
0
파일: cgmips.c 프로젝트: Benderx2/SmallerC
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();
}
예제 #3
0
파일: cgtr3k2.c 프로젝트: gdos/SmallerC
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()
}
예제 #4
0
파일: cgtr3k2.c 프로젝트: gdos/SmallerC
STATIC
void GenPrintInstr1Operand(int instr, int instrval, int operand, int operandval)
{
  GenPrintInstr(instr, instrval);
  GenPrintOperand(operand, operandval);
  GenPrintNewLine();
}
예제 #5
0
파일: cgtr3k2.c 프로젝트: gdos/SmallerC
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();
}
예제 #6
0
파일: cgmips.c 프로젝트: Benderx2/SmallerC
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
}
예제 #7
0
파일: cgmips.c 프로젝트: Benderx2/SmallerC
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
파일: cgtr3k2.c 프로젝트: gdos/SmallerC
STATIC
void GenPrintOperand(int op, int val)
{
  if (op >= Tr32OpReg0 && op <= Tr32OpRegFlags)
  {
    GenRegsUsed |= 1 << op;
    switch (op)
    {
    case Tr32OpRegBp:    printf2("%%bp");    break;
    case Tr32OpRegSp:    printf2("%%sp");    break;
    case Tr32OpRegY:     printf2("%%y");     break;
    case Tr32OpRegFlags: printf2("%%flags"); break;
    default:             printf2("%%r%d", op);
    }
  }
  else if (op >= Tr32OpIndReg0 && op <= Tr32OpIndRegFlags)
  {
    GenPrintOperand(op - Tr32OpIndReg0, 0);
    val = truncInt(val);
    if (val)
      printf2(", %d", val);
  }
  else
  {
    switch (op)
    {
    case Tr32OpConst: printf2("%d", truncInt(val)); break;
    case Tr32OpLabel: GenPrintLabel(IdentTable + val); break;
    case Tr32OpNumLabel: GenPrintNumLabel(val); break;

    default:
      //error("WTF!\n");
      errorInternal(100);
      break;
    }
  }
}