blob: 637327d8a0a2985581b7f6d4542ff4f5aabd920c [file] [log] [blame]
Akira Hatanaka0bc1adb2012-07-31 21:49:49 +00001//===-- Mips16InstrInfo.cpp - Mips16 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 contains the Mips16 implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "Mips16InstrInfo.h"
15#include "MipsTargetMachine.h"
16#include "MipsMachineFunction.h"
17#include "InstPrinter/MipsInstPrinter.h"
18#include "llvm/CodeGen/MachineInstrBuilder.h"
19#include "llvm/CodeGen/MachineRegisterInfo.h"
20#include "llvm/Support/ErrorHandling.h"
21#include "llvm/Support/TargetRegistry.h"
22#include "llvm/ADT/STLExtras.h"
23#include "llvm/ADT/StringRef.h"
24
25using namespace llvm;
26
27Mips16InstrInfo::Mips16InstrInfo(MipsTargetMachine &tm)
28 : MipsInstrInfo(tm, /* FIXME: set mips16 unconditional br */ 0) {}
29
30/// isLoadFromStackSlot - If the specified machine instruction is a direct
31/// load from a stack slot, return the virtual or physical register number of
32/// the destination along with the FrameIndex of the loaded stack slot. If
33/// not, return 0. This predicate must return 0 if the instruction has
34/// any side effects other than loading from the stack slot.
35unsigned Mips16InstrInfo::
36isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const
37{
38 return 0;
39}
40
41/// isStoreToStackSlot - If the specified machine instruction is a direct
42/// store to a stack slot, return the virtual or physical register number of
43/// the source reg along with the FrameIndex of the loaded stack slot. If
44/// not, return 0. This predicate must return 0 if the instruction has
45/// any side effects other than storing to the stack slot.
46unsigned Mips16InstrInfo::
47isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const
48{
49 return 0;
50}
51
52void Mips16InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
53 MachineBasicBlock::iterator I, DebugLoc DL,
54 unsigned DestReg, unsigned SrcReg,
55 bool KillSrc) const {
56 unsigned Opc = 0, ZeroReg = 0;
57
58 if (Mips::CPURegsRegClass.contains(DestReg)) { // Copy to CPU Reg.
59 if (Mips::CPURegsRegClass.contains(SrcReg))
60 Opc = Mips::Mov32R16;
61 }
62
63 assert(Opc && "Cannot copy registers");
64
65 MachineInstrBuilder MIB = BuildMI(MBB, I, DL, get(Opc));
66
67 if (DestReg)
68 MIB.addReg(DestReg, RegState::Define);
69
70 if (ZeroReg)
71 MIB.addReg(ZeroReg);
72
73 if (SrcReg)
74 MIB.addReg(SrcReg, getKillRegState(KillSrc));
75}
76
77void Mips16InstrInfo::
78storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
79 unsigned SrcReg, bool isKill, int FI,
80 const TargetRegisterClass *RC,
81 const TargetRegisterInfo *TRI) const {
82 assert(false && "Implement this function.");
83}
84
85void Mips16InstrInfo::
86loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
87 unsigned DestReg, int FI,
88 const TargetRegisterClass *RC,
89 const TargetRegisterInfo *TRI) const {
90 assert(false && "Implement this function.");
91}
92
93bool Mips16InstrInfo::expandPostRAPseudo(MachineBasicBlock::iterator MI) const {
94 MachineBasicBlock &MBB = *MI->getParent();
95
96 switch(MI->getDesc().getOpcode()) {
97 default:
98 return false;
99 case Mips::RetRA16:
100 ExpandRetRA16(MBB, MI, Mips::JrRa16);
101 break;
102 }
103
104 MBB.erase(MI);
105 return true;
106}
107
108/// GetOppositeBranchOpc - Return the inverse of the specified
109/// opcode, e.g. turning BEQ to BNE.
110unsigned Mips16InstrInfo::GetOppositeBranchOpc(unsigned Opc) const {
111 assert(false && "Implement this function.");
112 return 0;
113}
114
115unsigned Mips16InstrInfo::GetAnalyzableBrOpc(unsigned Opc) const {
116 return 0;
117}
118
119void Mips16InstrInfo::ExpandRetRA16(MachineBasicBlock &MBB,
120 MachineBasicBlock::iterator I,
121 unsigned Opc) const {
122 BuildMI(MBB, I, I->getDebugLoc(), get(Opc));
123}