blob: d8d1578c72def0ce2e21f7e5461fe46ace0c3cc8 [file] [log] [blame]
Chris Lattner08084142003-01-13 00:26:36 +00001//===-- TargetInstrInfo.cpp - Target Instruction Information --------------===//
Misha Brukmanf976c852005-04-21 22:55:34 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-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 Brukmanf976c852005-04-21 22:55:34 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattner93fa7052002-10-28 23:55:33 +00009//
Chris Lattner167b10c2005-01-19 06:53:34 +000010// This file implements the TargetInstrInfo class.
Chris Lattner93fa7052002-10-28 23:55:33 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattner3501fea2003-01-14 22:00:31 +000014#include "llvm/Target/TargetInstrInfo.h"
Chris Lattner93fa7052002-10-28 23:55:33 +000015#include "llvm/Constant.h"
16#include "llvm/DerivedTypes.h"
Chris Lattner167b10c2005-01-19 06:53:34 +000017using namespace llvm;
Chris Lattner93fa7052002-10-28 23:55:33 +000018
Evan Chengcc22a7a2006-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 Lattner08084142003-01-13 00:26:36 +000032TargetInstrInfo::TargetInstrInfo(const TargetInstrDescriptor* Desc,
Misha Brukman7847fca2005-04-22 17:54:37 +000033 unsigned numOpcodes)
Chris Lattnerdce363d2004-02-29 06:31:44 +000034 : desc(Desc), NumOpcodes(numOpcodes) {
Chris Lattner93fa7052002-10-28 23:55:33 +000035}
36
Chris Lattner08084142003-01-13 00:26:36 +000037TargetInstrInfo::~TargetInstrInfo() {
Chris Lattner93fa7052002-10-28 23:55:33 +000038}
39
Evan Chengbfd2ec42007-06-08 21:59:56 +000040bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
41 const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
Evan Cheng0e4a2762007-07-05 07:06:46 +000042 if (TID->Flags & M_TERMINATOR_FLAG) {
Evan Cheng14c46552007-07-06 23:22:03 +000043 // Conditional branch is a special case.
44 if ((TID->Flags & M_BRANCH_FLAG) != 0 && (TID->Flags & M_BARRIER_FLAG) == 0)
45 return true;
Evan Cheng0e4a2762007-07-05 07:06:46 +000046 if ((TID->Flags & M_PREDICABLE) == 0)
47 return true;
Evan Chengbfd2ec42007-06-08 21:59:56 +000048 return !isPredicated(MI);
Evan Cheng14c46552007-07-06 23:22:03 +000049 }
Evan Chengbfd2ec42007-06-08 21:59:56 +000050 return false;
51}