blob: ba56caa68e8d933a33fd460e924ed305892bdb40 [file] [log] [blame]
Chris Lattner0d5644b2003-01-13 00:26:36 +00001//===-- TargetInstrInfo.cpp - Target Instruction Information --------------===//
Misha Brukman10468d82005-04-21 22:55:34 +00002//
John Criswell482202a2003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman10468d82005-04-21 22:55:34 +00007//
John Criswell482202a2003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattner910b82f2002-10-28 23:55:33 +00009//
Chris Lattnerf6932b72005-01-19 06:53:34 +000010// This file implements the TargetInstrInfo class.
Chris Lattner910b82f2002-10-28 23:55:33 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattnerb4d58d72003-01-14 22:00:31 +000014#include "llvm/Target/TargetInstrInfo.h"
Chris Lattner910b82f2002-10-28 23:55:33 +000015#include "llvm/Constant.h"
16#include "llvm/DerivedTypes.h"
Chris Lattnerf6932b72005-01-19 06:53:34 +000017using namespace llvm;
Chris Lattner910b82f2002-10-28 23:55:33 +000018
Evan Cheng78cb08d2006-12-08 18:45:48 +000019/// 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
Chris Lattner0d5644b2003-01-13 00:26:36 +000032TargetInstrInfo::TargetInstrInfo(const TargetInstrDescriptor* Desc,
Misha Brukmane73e76d2005-04-22 17:54:37 +000033 unsigned numOpcodes)
Chris Lattnered01da82004-02-29 06:31:44 +000034 : desc(Desc), NumOpcodes(numOpcodes) {
Chris Lattner910b82f2002-10-28 23:55:33 +000035}
36
Chris Lattner0d5644b2003-01-13 00:26:36 +000037TargetInstrInfo::~TargetInstrInfo() {
Chris Lattner910b82f2002-10-28 23:55:33 +000038}
39
Evan Cheng5514bbe2007-06-08 21:59:56 +000040bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
Chris Lattnera98c6792008-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);
Evan Cheng5514bbe2007-06-08 21:59:56 +000050}