Remove unused member functions.
[oota-llvm.git] / lib / Target / ARM / Thumb2InstrInfo.cpp
1 //===- Thumb2InstrInfo.cpp - Thumb-2 Instruction Information --------*- C++ -*-===//
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 contains the Thumb-2 implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "ARMInstrInfo.h"
15 #include "ARM.h"
16 #include "ARMGenInstrInfo.inc"
17 #include "ARMMachineFunctionInfo.h"
18 #include "llvm/CodeGen/MachineFrameInfo.h"
19 #include "llvm/CodeGen/MachineInstrBuilder.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "Thumb2InstrInfo.h"
22
23 using namespace llvm;
24
25 Thumb2InstrInfo::Thumb2InstrInfo(const ARMSubtarget &STI)
26   : ARMBaseInstrInfo(STI), RI(*this, STI) {
27 }
28
29 unsigned Thumb2InstrInfo::getUnindexedOpcode(unsigned Opc) const {
30   // FIXME
31   return 0;
32 }
33
34 unsigned Thumb2InstrInfo::getOpcode(ARMII::Op Op) const {
35   switch (Op) {
36   case ARMII::ADDri: return ARM::t2ADDri;
37   case ARMII::ADDrs: return ARM::t2ADDrs;
38   case ARMII::ADDrr: return ARM::t2ADDrr;
39   case ARMII::B: return ARM::t2B;
40   case ARMII::Bcc: return ARM::t2Bcc;
41   case ARMII::BR_JTr: return ARM::t2BR_JTr;
42   case ARMII::BR_JTm: return ARM::t2BR_JTm;
43   case ARMII::BR_JTadd: return ARM::t2BR_JTadd;
44   case ARMII::BX_RET: return ARM::tBX_RET;
45   case ARMII::LDRrr: return ARM::t2LDRs;
46   case ARMII::LDRri: return ARM::t2LDRi12;
47   case ARMII::MOVr: return ARM::t2MOVr;
48   case ARMII::STRrr: return ARM::t2STRs;
49   case ARMII::STRri: return ARM::t2STRi12;
50   case ARMII::SUBri: return ARM::t2SUBri;
51   case ARMII::SUBrs: return ARM::t2SUBrs;
52   case ARMII::SUBrr: return ARM::t2SUBrr;
53   default:
54     break;
55   }
56
57   return 0;
58 }
59
60 bool
61 Thumb2InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
62   if (MBB.empty()) return false;
63
64   // FIXME
65   switch (MBB.back().getOpcode()) {
66   case ARM::t2LDM_RET:
67   case ARM::t2B:        // Uncond branch.
68   case ARM::t2BR_JTr:   // Jumptable branch.
69   case ARM::t2BR_JTm:   // Jumptable branch through mem.
70   case ARM::t2BR_JTadd: // Jumptable branch add to pc.
71     return true;
72   case ARM::tBX_RET:
73   case ARM::tBX_RET_vararg:
74   case ARM::tPOP_RET:
75   case ARM::tB:
76   case ARM::tBR_JTr:
77     return true;
78   default:
79     break;
80   }
81
82   return false;
83 }
84
85 bool
86 Thumb2InstrInfo::copyRegToReg(MachineBasicBlock &MBB,
87                               MachineBasicBlock::iterator I,
88                               unsigned DestReg, unsigned SrcReg,
89                               const TargetRegisterClass *DestRC,
90                               const TargetRegisterClass *SrcRC) const {
91   DebugLoc DL = DebugLoc::getUnknownLoc();
92   if (I != MBB.end()) DL = I->getDebugLoc();
93
94   if ((DestRC == ARM::GPRRegisterClass &&
95        SrcRC == ARM::tGPRRegisterClass) ||
96       (DestRC == ARM::tGPRRegisterClass &&
97        SrcRC == ARM::GPRRegisterClass)) {
98     AddDefaultCC(AddDefaultPred(BuildMI(MBB, I, DL, get(getOpcode(ARMII::MOVr)),
99                                         DestReg).addReg(SrcReg)));
100     return true;
101   }
102
103   return ARMBaseInstrInfo::copyRegToReg(MBB, I, DestReg, SrcReg, DestRC, SrcRC);
104 }