blob: 5342dd187277f9549de4b23422bb2d49f176c4cd [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- TargetInstrInfo.cpp - Target Instruction Information --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Target/TargetInstrInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015#include "llvm/Constant.h"
16#include "llvm/DerivedTypes.h"
17using namespace llvm;
18
19/// findTiedToSrcOperand - Returns the operand that is tied to the specified
20/// dest operand. Returns -1 if there isn't one.
21int TargetInstrDescriptor::findTiedToSrcOperand(unsigned OpNum) const {
Chris Lattner0c2a4f32008-01-07 03:13:06 +000022 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023 if (i == OpNum)
24 continue;
25 if (getOperandConstraint(i, TOI::TIED_TO) == (int)OpNum)
26 return i;
27 }
28 return -1;
29}
30
31
32TargetInstrInfo::TargetInstrInfo(const TargetInstrDescriptor* Desc,
33 unsigned numOpcodes)
34 : desc(Desc), NumOpcodes(numOpcodes) {
35}
36
37TargetInstrInfo::~TargetInstrInfo() {
38}
39
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
Chris Lattner62327602008-01-07 01:56:04 +000041 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 Gohmanf17a25c2007-07-18 16:29:46 +000050}