Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- TargetInstrInfo.cpp - Target Instruction Information --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the TargetInstrInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/Target/TargetInstrInfo.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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 TargetInstrDescriptor::findTiedToSrcOperand(unsigned OpNum) const { |
| 22 | for (unsigned i = 0, e = numOperands; 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 TargetInstrDescriptor* Desc, |
| 33 | unsigned numOpcodes) |
| 34 | : desc(Desc), NumOpcodes(numOpcodes) { |
| 35 | } |
| 36 | |
| 37 | TargetInstrInfo::~TargetInstrInfo() { |
| 38 | } |
| 39 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 40 | bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const { |
Chris Lattner | 6232760 | 2008-01-07 01:56:04 +0000 | [diff] [blame^] | 41 | const TargetInstrDescriptor *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); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 50 | } |