Add bunch of 32-bit patterns... Uffff :)
[oota-llvm.git] / lib / Target / SystemZ / SystemZInstrInfo.cpp
1 //===- SystemZInstrInfo.cpp - SystemZ 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 SystemZ implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "SystemZ.h"
15 #include "SystemZInstrInfo.h"
16 #include "SystemZMachineFunctionInfo.h"
17 #include "SystemZTargetMachine.h"
18 #include "SystemZGenInstrInfo.inc"
19 #include "llvm/Function.h"
20 #include "llvm/CodeGen/MachineFrameInfo.h"
21 #include "llvm/CodeGen/MachineInstrBuilder.h"
22 #include "llvm/CodeGen/MachineRegisterInfo.h"
23 #include "llvm/CodeGen/PseudoSourceValue.h"
24
25 using namespace llvm;
26
27 SystemZInstrInfo::SystemZInstrInfo(SystemZTargetMachine &tm)
28   : TargetInstrInfoImpl(SystemZInsts, array_lengthof(SystemZInsts)),
29     RI(tm, *this), TM(tm) {}
30
31 void SystemZInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
32                                           MachineBasicBlock::iterator MI,
33                                     unsigned SrcReg, bool isKill, int FrameIdx,
34                                     const TargetRegisterClass *RC) const {
35   assert(0 && "Cannot store this register to stack slot!");
36 }
37
38 void SystemZInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
39                                            MachineBasicBlock::iterator MI,
40                                            unsigned DestReg, int FrameIdx,
41                                            const TargetRegisterClass *RC) const{
42   assert(0 && "Cannot store this register to stack slot!");
43 }
44
45 bool SystemZInstrInfo::copyRegToReg(MachineBasicBlock &MBB,
46                                     MachineBasicBlock::iterator I,
47                                     unsigned DestReg, unsigned SrcReg,
48                                     const TargetRegisterClass *DestRC,
49                                     const TargetRegisterClass *SrcRC) const {
50   DebugLoc DL = DebugLoc::getUnknownLoc();
51   if (I != MBB.end()) DL = I->getDebugLoc();
52
53   // Determine if DstRC and SrcRC have a common superclass.
54   const TargetRegisterClass *CommonRC = DestRC;
55   if (DestRC == SrcRC)
56     /* Same regclass for source and dest */;
57   else if (CommonRC->hasSuperClass(SrcRC))
58     CommonRC = SrcRC;
59   else if (!CommonRC->hasSubClass(SrcRC))
60     CommonRC = 0;
61
62   if (CommonRC) {
63     unsigned Opc;
64     if (CommonRC == &SystemZ::GR64RegClass) {
65       Opc = SystemZ::MOV64rr;
66     } else if (CommonRC == &SystemZ::GR32RegClass) {
67       Opc = SystemZ::MOV32rr;
68     } else {
69       return false;
70     }
71
72     BuildMI(MBB, I, DL, get(Opc), DestReg).addReg(SrcReg);
73     return true;
74   }
75
76   return false;
77 }
78
79 bool
80 SystemZInstrInfo::isMoveInstr(const MachineInstr& MI,
81                               unsigned &SrcReg, unsigned &DstReg,
82                               unsigned &SrcSubIdx, unsigned &DstSubIdx) const {
83   SrcSubIdx = DstSubIdx = 0; // No sub-registers yet.
84
85   switch (MI.getOpcode()) {
86   default:
87     return false;
88   case SystemZ::MOV32rr:
89   case SystemZ::MOV64rr:
90     assert(MI.getNumOperands() >= 2 &&
91            MI.getOperand(0).isReg() &&
92            MI.getOperand(1).isReg() &&
93            "invalid register-register move instruction");
94     SrcReg = MI.getOperand(1).getReg();
95     DstReg = MI.getOperand(0).getReg();
96     return true;
97   }
98 }
99
100 bool
101 SystemZInstrInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB,
102                                            MachineBasicBlock::iterator MI,
103                                 const std::vector<CalleeSavedInfo> &CSI) const {
104   return false;
105 }
106
107 bool
108 SystemZInstrInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
109                                              MachineBasicBlock::iterator MI,
110                                 const std::vector<CalleeSavedInfo> &CSI) const {
111   return false;
112 }
113
114 unsigned
115 SystemZInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
116                               MachineBasicBlock *FBB,
117                             const SmallVectorImpl<MachineOperand> &Cond) const {
118   assert(0 && "Implement branches!");
119
120   return 0;
121 }