blob: ceaea0c2027ce20b6605eb68a9689292752dd6d2 [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"
Evan Cheng8058d702009-05-05 00:30:09 +000015#include "llvm/Target/TargetRegisterInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000016#include "llvm/Constant.h"
17#include "llvm/DerivedTypes.h"
18using namespace llvm;
19
Chris Lattner5b930372008-01-07 07:27:27 +000020TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021 unsigned numOpcodes)
Chris Lattner5b930372008-01-07 07:27:27 +000022 : Descriptors(Desc), NumOpcodes(numOpcodes) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023}
24
25TargetInstrInfo::~TargetInstrInfo() {
26}
27
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
Chris Lattner5b930372008-01-07 07:27:27 +000029 const TargetInstrDesc &TID = MI->getDesc();
30 if (!TID.isTerminator()) return false;
Chris Lattner62327602008-01-07 01:56:04 +000031
32 // Conditional branch is a special case.
Chris Lattner5b930372008-01-07 07:27:27 +000033 if (TID.isBranch() && !TID.isBarrier())
Chris Lattner62327602008-01-07 01:56:04 +000034 return true;
Chris Lattner5b930372008-01-07 07:27:27 +000035 if (!TID.isPredicable())
Chris Lattner62327602008-01-07 01:56:04 +000036 return true;
37 return !isPredicated(MI);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038}
Evan Cheng8058d702009-05-05 00:30:09 +000039
40/// getInstrOperandRegClass - Return register class of the operand of an
41/// instruction of the specified TargetInstrDesc.
42const TargetRegisterClass*
43llvm::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);
50}