blob: ad5a9d71da49ff7b5693ca7c005e9c6354461b1f [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"
Chris Lattner1a6ef242009-08-02 04:58:19 +000016#include "llvm/Support/ErrorHandling.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017using namespace llvm;
18
Chris Lattner5b930372008-01-07 07:27:27 +000019TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020 unsigned numOpcodes)
Chris Lattner5b930372008-01-07 07:27:27 +000021 : Descriptors(Desc), NumOpcodes(numOpcodes) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000022}
23
24TargetInstrInfo::~TargetInstrInfo() {
25}
26
Chris Lattner1a6ef242009-08-02 04:58:19 +000027/// insertNoop - Insert a noop into the instruction stream at the specified
28/// point.
29void TargetInstrInfo::insertNoop(MachineBasicBlock &MBB,
30 MachineBasicBlock::iterator MI) const {
31 llvm_unreachable("Target didn't implement insertNoop!");
32}
33
34
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035bool TargetInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
Chris Lattner5b930372008-01-07 07:27:27 +000036 const TargetInstrDesc &TID = MI->getDesc();
37 if (!TID.isTerminator()) return false;
Chris Lattner62327602008-01-07 01:56:04 +000038
39 // Conditional branch is a special case.
Chris Lattner5b930372008-01-07 07:27:27 +000040 if (TID.isBranch() && !TID.isBarrier())
Chris Lattner62327602008-01-07 01:56:04 +000041 return true;
Chris Lattner5b930372008-01-07 07:27:27 +000042 if (!TID.isPredicable())
Chris Lattner62327602008-01-07 01:56:04 +000043 return true;
44 return !isPredicated(MI);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045}
Evan Cheng8058d702009-05-05 00:30:09 +000046
Chris Lattner6a66b292009-07-29 21:10:12 +000047/// 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.
50const TargetRegisterClass *
51TargetOperandInfo::getRegClass(const TargetRegisterInfo *TRI) const {
52 if (isLookupPtrRegClass())
53 return TRI->getPointerRegClass(RegClass);
54 return TRI->getRegClass(RegClass);
55}
56