ad5a9d71da49ff7b5693ca7c005e9c6354461b1f
[oota-llvm.git] / lib / Target / TargetInstrInfo.cpp
1 //===-- TargetInstrInfo.cpp - Target Instruction Information --------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/TargetInstrInfo.h"
15 #include "llvm/Target/TargetRegisterInfo.h"
16 #include "llvm/Support/ErrorHandling.h"
17 using namespace llvm;
18
19 TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc,
20                                  unsigned numOpcodes)
21   : Descriptors(Desc), NumOpcodes(numOpcodes) {
22 }
23
24 TargetInstrInfo::~TargetInstrInfo() {
25 }
26
27 /// insertNoop - Insert a noop into the instruction stream at the specified
28 /// point.
29 void TargetInstrInfo::insertNoop(MachineBasicBlock &MBB, 
30                                  MachineBasicBlock::iterator MI) const {
31   llvm_unreachable("Target didn't implement insertNoop!");
32 }
33
34
35 bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
36   const TargetInstrDesc &TID = MI->getDesc();
37   if (!TID.isTerminator()) return false;
38   
39   // Conditional branch is a special case.
40   if (TID.isBranch() && !TID.isBarrier())
41     return true;
42   if (!TID.isPredicable())
43     return true;
44   return !isPredicated(MI);
45 }
46
47 /// getRegClass - Get the register class for the operand, handling resolution
48 /// of "symbolic" pointer register classes etc.  If this is not a register
49 /// operand, this returns null.
50 const TargetRegisterClass *
51 TargetOperandInfo::getRegClass(const TargetRegisterInfo *TRI) const {
52   if (isLookupPtrRegClass())
53     return TRI->getPointerRegClass(RegClass);
54   return TRI->getRegClass(RegClass);
55 }
56