blob: 10a5cdb6247a9fb44aa02a660203960c72d6f2e1 [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.
Chris Lattner5b930372008-01-07 07:27:27 +000021int TargetInstrDesc::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
Chris Lattner5b930372008-01-07 07:27:27 +000032TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033 unsigned numOpcodes)
Chris Lattner5b930372008-01-07 07:27:27 +000034 : Descriptors(Desc), NumOpcodes(numOpcodes) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035}
36
37TargetInstrInfo::~TargetInstrInfo() {
38}
39
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
Chris Lattner5b930372008-01-07 07:27:27 +000041 const TargetInstrDesc &TID = MI->getDesc();
42 if (!TID.isTerminator()) return false;
Chris Lattner62327602008-01-07 01:56:04 +000043
44 // Conditional branch is a special case.
Chris Lattner5b930372008-01-07 07:27:27 +000045 if (TID.isBranch() && !TID.isBarrier())
Chris Lattner62327602008-01-07 01:56:04 +000046 return true;
Chris Lattner5b930372008-01-07 07:27:27 +000047 if (!TID.isPredicable())
Chris Lattner62327602008-01-07 01:56:04 +000048 return true;
49 return !isPredicated(MI);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050}