2003-01-13 00:26:36 +00:00
|
|
|
//===-- TargetInstrInfo.cpp - Target Instruction Information --------------===//
|
2005-04-21 22:55:34 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:55:34 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-10-28 23:55:33 +00:00
|
|
|
//
|
2005-01-19 06:53:34 +00:00
|
|
|
// This file implements the TargetInstrInfo class.
|
2002-10-28 23:55:33 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-01-14 22:00:31 +00:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2002-10-28 23:55:33 +00:00
|
|
|
#include "llvm/Constant.h"
|
|
|
|
#include "llvm/DerivedTypes.h"
|
2005-01-19 06:53:34 +00:00
|
|
|
using namespace llvm;
|
2002-10-28 23:55:33 +00:00
|
|
|
|
2006-11-01 23:18:32 +00:00
|
|
|
/// findTiedToSrcOperand - Returns the operand that is tied to the specified
|
|
|
|
/// dest operand. Returns -1 if there isn't one.
|
2006-12-08 18:45:48 +00:00
|
|
|
int TargetInstrDescriptor::findTiedToSrcOperand(unsigned OpNum) const {
|
|
|
|
for (unsigned i = 0, e = numOperands; i != e; ++i) {
|
2006-11-01 23:00:31 +00:00
|
|
|
if (i == OpNum)
|
|
|
|
continue;
|
2006-12-08 18:45:48 +00:00
|
|
|
if (getOperandConstraint(i, TOI::TIED_TO) == (int)OpNum)
|
2006-11-01 23:00:31 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-10-28 23:55:33 +00:00
|
|
|
|
2006-12-08 18:45:48 +00:00
|
|
|
TargetInstrInfo::TargetInstrInfo(const TargetInstrDescriptor* Desc,
|
|
|
|
unsigned numOpcodes)
|
|
|
|
: desc(Desc), NumOpcodes(numOpcodes) {
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetInstrInfo::~TargetInstrInfo() {
|
|
|
|
}
|
|
|
|
|
2007-06-08 21:59:56 +00:00
|
|
|
bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
|
|
|
|
const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
|
2007-07-05 07:06:46 +00:00
|
|
|
if (TID->Flags & M_TERMINATOR_FLAG) {
|
2007-07-06 23:22:03 +00:00
|
|
|
// Conditional branch is a special case.
|
|
|
|
if ((TID->Flags & M_BRANCH_FLAG) != 0 && (TID->Flags & M_BARRIER_FLAG) == 0)
|
|
|
|
return true;
|
2007-07-05 07:06:46 +00:00
|
|
|
if ((TID->Flags & M_PREDICABLE) == 0)
|
|
|
|
return true;
|
2007-06-08 21:59:56 +00:00
|
|
|
return !isPredicated(MI);
|
2007-07-06 23:22:03 +00:00
|
|
|
}
|
2007-06-08 21:59:56 +00:00
|
|
|
return false;
|
|
|
|
}
|