rename TargetInstrDescriptor -> TargetInstrDesc.
[oota-llvm.git] / lib / Target / TargetInstrInfo.cpp
1 //===-- TargetInstrInfo.cpp - Target Instruction Information --------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/TargetInstrInfo.h"
15 #include "llvm/Constant.h"
16 #include "llvm/DerivedTypes.h"
17 using namespace llvm;
18
19 /// findTiedToSrcOperand - Returns the operand that is tied to the specified
20 /// dest operand. Returns -1 if there isn't one.
21 int TargetInstrDesc::findTiedToSrcOperand(unsigned OpNum) const {
22   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
23     if (i == OpNum)
24       continue;
25     if (getOperandConstraint(i, TOI::TIED_TO) == (int)OpNum)
26       return i;
27   }
28   return -1;
29 }
30
31
32 TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc,
33                                  unsigned numOpcodes)
34   : Descriptors(Desc), NumOpcodes(numOpcodes) {
35 }
36
37 TargetInstrInfo::~TargetInstrInfo() {
38 }
39
40 bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
41   const TargetInstrDesc &TID = MI->getDesc();
42   if (!TID.isTerminator()) return false;
43   
44   // Conditional branch is a special case.
45   if (TID.isBranch() && !TID.isBarrier())
46     return true;
47   if (!TID.isPredicable())
48     return true;
49   return !isPredicated(MI);
50 }