Merge branch 'master' into msp430
[llvm/msp430.git] / lib / Target / TargetInstrInfo.cpp
blobceaea0c2027ce20b6605eb68a9689292752dd6d2
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.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/TargetInstrInfo.h"
15 #include "llvm/Target/TargetRegisterInfo.h"
16 #include "llvm/Constant.h"
17 #include "llvm/DerivedTypes.h"
18 using namespace llvm;
20 TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc,
21 unsigned numOpcodes)
22 : Descriptors(Desc), NumOpcodes(numOpcodes) {
25 TargetInstrInfo::~TargetInstrInfo() {
28 bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
29 const TargetInstrDesc &TID = MI->getDesc();
30 if (!TID.isTerminator()) return false;
32 // Conditional branch is a special case.
33 if (TID.isBranch() && !TID.isBarrier())
34 return true;
35 if (!TID.isPredicable())
36 return true;
37 return !isPredicated(MI);
40 /// getInstrOperandRegClass - Return register class of the operand of an
41 /// instruction of the specified TargetInstrDesc.
42 const TargetRegisterClass*
43 llvm::getInstrOperandRegClass(const TargetRegisterInfo *TRI,
44 const TargetInstrDesc &II, unsigned Op) {
45 if (Op >= II.getNumOperands())
46 return NULL;
47 if (II.OpInfo[Op].isLookupPtrRegClass())
48 return TRI->getPointerRegClass();
49 return TRI->getRegClass(II.OpInfo[Op].RegClass);