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. |
Chris Lattner | 5b93037 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 21 | int TargetInstrDesc::findTiedToSrcOperand(unsigned OpNum) const { |
Chris Lattner | 0c2a4f3 | 2008-01-07 03:13:06 +0000 | [diff] [blame] | 22 | for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 5b93037 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 32 | TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 33 | unsigned numOpcodes) |
Chris Lattner | 5b93037 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 34 | : Descriptors(Desc), NumOpcodes(numOpcodes) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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 | 5b93037 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 41 | const TargetInstrDesc &TID = MI->getDesc(); |
| 42 | if (!TID.isTerminator()) return false; |
Chris Lattner | 6232760 | 2008-01-07 01:56:04 +0000 | [diff] [blame] | 43 | |
| 44 | // Conditional branch is a special case. |
Chris Lattner | 5b93037 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 45 | if (TID.isBranch() && !TID.isBarrier()) |
Chris Lattner | 6232760 | 2008-01-07 01:56:04 +0000 | [diff] [blame] | 46 | return true; |
Chris Lattner | 5b93037 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 47 | if (!TID.isPredicable()) |
Chris Lattner | 6232760 | 2008-01-07 01:56:04 +0000 | [diff] [blame] | 48 | return true; |
| 49 | return !isPredicated(MI); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 50 | } |