Lib/Target/Pretty.cpp
/**
 * Pretty printer for Target instructions
 *
 * Returns a string representation of an instruction.
 */
Pretty printer for Target instructions
Returns a string representation of an instruction.
Pretty printer for Target instructions Returns a string representation of an instruction .
std::string pretty_instr(Instr const &instr) {
  std::string buf;
  switch (instr.tag) {
    case LI: {
      buf << instr.assign_cond().to_string()
          << "LI " << instr.dest().dump()
          << " <-" << instr.set_cond().pretty() << " "
          << instr.LI.imm.pretty();
    }
    break;
    case ALU: {
      buf << instr.assign_cond().to_string()
          << instr.dest().dump()
          << " <-" << instr.set_cond().pretty() << " "
          << instr.ALU.op.pretty();
      if (instr.ALU.noOperands()) {
        buf << "()";
      } else if (instr.ALU.oneOperand()) {
        buf << "(" << instr.ALU.srcA.disp() << ")";
      } else {
        buf << "(" << instr.ALU.srcA.disp() << ", " << instr.ALU.srcB.disp() << ")";
      }
    }
    break;
    case BR:   buf << "if " << instr.branch_cond().to_string()
                   << " goto " << instr.branch_target().to_string();
    break;
    case BRL:  buf << "if " << instr.branch_cond().to_string() << " goto L" << instr.branch_label(); break;
    case LAB:  buf << "L" << instr.label();                                                          break;
    case RECV: buf << "RECV(" <<  instr.dest().dump() << ")";                                        break;
    case SINC: buf << "SINC " << instr.semaId;                                                       break;
    case SDEC: buf << "SDEC " << instr.semaId;                                                       break;
    case INIT_BEGIN:
    case INIT_END:
    case END:         
    case NO_OP:
    case SKIP:
    case IRQ:
    case VPM_STALL:
      buf << V3DLib::pretty_instr_tag(instr.tag);
      break;
    default:
      assert(false);
      buf << "<<UNKNOWN: " << instr.tag << ">>";
      break;
  }
  assert(!buf.empty());
  return buf;
}
std :: string pretty_instr ( Instr const & instr ) { std :: string buf ; switch ( instr . tag ) { case LI : { buf << instr . assign_cond ( ) . to_string ( ) << " " << instr . dest ( ) . dump ( ) << " " << instr . set_cond ( ) . pretty ( ) << " " << instr . LI . imm . pretty ( ) ; } break ; case ALU : { buf << instr . assign_cond ( ) . to_string ( ) << instr . dest ( ) . dump ( ) << " " << instr . set_cond ( ) . pretty ( ) << " " << instr . ALU . op . pretty ( ) ; if ( instr . ALU . noOperands ( ) ) { buf << " " ; } else if ( instr . ALU . oneOperand ( ) ) { buf << " " << instr . ALU . srcA . disp ( ) << " " ; } else { buf << " " << instr . ALU . srcA . disp ( ) << " " << instr . ALU . srcB . disp ( ) << " " ; } } break ; case BR : buf << " " << instr . branch_cond ( ) . to_string ( ) << " " << instr . branch_target ( ) . to_string ( ) ; break ; case BRL : buf << " " << instr . branch_cond ( ) . to_string ( ) << " " << instr . branch_label ( ) ; break ; case LAB : buf << " " << instr . label ( ) ; break ; case RECV : buf << " " << instr . dest ( ) . dump ( ) << " " ; break ; case SINC : buf << " " << instr . semaId ; break ; case SDEC : buf << " " << instr . semaId ; break ; case INIT_BEGIN : case INIT_END : case END : case NO_OP : case SKIP : case IRQ : case VPM_STALL : buf << V3DLib :: pretty_instr_tag ( instr . tag ) ; break ; default : assert ( false ) ; buf << " " << instr . tag << " " ; break ; } assert ( ! buf . empty ( ) ) ; return buf ; }
Pretty printer for Target instructions
 Returns a string representation of an instruction.
Pretty printer for Target instructions Returns a string representation of an instruction .
// vc4