blob: d8d1578c72def0ce2e21f7e5461fe46ace0c3cc8 [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 {
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
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 {
41 const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
42 if (TID->Flags & M_TERMINATOR_FLAG) {
43 // Conditional branch is a special case.
44 if ((TID->Flags & M_BRANCH_FLAG) != 0 && (TID->Flags & M_BARRIER_FLAG) == 0)
45 return true;
46 if ((TID->Flags & M_PREDICABLE) == 0)
47 return true;
48 return !isPredicated(MI);
49 }
50 return false;
51}