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