bool PatmosInstrInfo::isPredicated(const MachineInstr *MI) const {
  if (MI->isBundle()) {
    MachineBasicBlock::const_instr_iterator II = MI;
    while (II->isBundledWithSucc()) {
      ++II;
      if (isPredicated(&*II)) return true;
    }
    return false;
  }

  int i = MI->findFirstPredOperandIdx();
  if (i != -1) {
    unsigned preg = MI->getOperand(i).getReg();
    int      flag = MI->getOperand(++i).getImm();
    return (preg!=Patmos::NoRegister && preg!=Patmos::P0) || flag;
  }
  // no predicates at all
  return false;
}
示例#2
0
MachineInstr &MachineFunction::CloneMachineInstrBundle(MachineBasicBlock &MBB,
    MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) {
  MachineInstr *FirstClone = nullptr;
  MachineBasicBlock::const_instr_iterator I = Orig.getIterator();
  for (;;) {
    MachineInstr *Cloned = CloneMachineInstr(&*I);
    MBB.insert(InsertBefore, Cloned);
    if (FirstClone == nullptr) {
      FirstClone = Cloned;
    } else {
      Cloned->bundleWithPred();
    }

    if (!I->isBundledWithSucc())
      break;
    ++I;
  }
  return *FirstClone;
}
bool PatmosInstrInfo::getPredicateOperands(const MachineInstr* MI,
                                   SmallVectorImpl<MachineOperand> &Pred) const
{
  if (!isPredicated(MI)) return false;

  if (MI->isBundle()) {
    MachineBasicBlock::const_instr_iterator II = MI;
    while (II->isBundledWithSucc()) {
      ++II;
      getPredicateOperands(&*II, Pred);
    }
    return true;
  }

  if (!MI->getDesc().isPredicable()) return false;

  unsigned Pos = MI->getDesc().getNumDefs();
  Pred.push_back(MI->getOperand(Pos));
  Pred.push_back(MI->getOperand(Pos+1));

  return true;
}