OSDN Git Service

Replace copyRegToReg with copyPhysReg for SystemZ.
[android-x86/external-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 "SystemZInstrBuilder.h"
16 #include "SystemZInstrInfo.h"
17 #include "SystemZMachineFunctionInfo.h"
18 #include "SystemZTargetMachine.h"
19 #include "SystemZGenInstrInfo.inc"
20 #include "llvm/Function.h"
21 #include "llvm/CodeGen/MachineFrameInfo.h"
22 #include "llvm/CodeGen/MachineInstrBuilder.h"
23 #include "llvm/CodeGen/MachineRegisterInfo.h"
24 #include "llvm/CodeGen/PseudoSourceValue.h"
25 #include "llvm/Support/ErrorHandling.h"
26 using namespace llvm;
27
28 SystemZInstrInfo::SystemZInstrInfo(SystemZTargetMachine &tm)
29   : TargetInstrInfoImpl(SystemZInsts, array_lengthof(SystemZInsts)),
30     RI(tm, *this), TM(tm) {
31   // Fill the spill offsets map
32   static const unsigned SpillOffsTab[][2] = {
33     { SystemZ::R2D,  0x10 },
34     { SystemZ::R3D,  0x18 },
35     { SystemZ::R4D,  0x20 },
36     { SystemZ::R5D,  0x28 },
37     { SystemZ::R6D,  0x30 },
38     { SystemZ::R7D,  0x38 },
39     { SystemZ::R8D,  0x40 },
40     { SystemZ::R9D,  0x48 },
41     { SystemZ::R10D, 0x50 },
42     { SystemZ::R11D, 0x58 },
43     { SystemZ::R12D, 0x60 },
44     { SystemZ::R13D, 0x68 },
45     { SystemZ::R14D, 0x70 },
46     { SystemZ::R15D, 0x78 }
47   };
48
49   RegSpillOffsets.grow(SystemZ::NUM_TARGET_REGS);
50
51   for (unsigned i = 0, e = array_lengthof(SpillOffsTab); i != e; ++i)
52     RegSpillOffsets[SpillOffsTab[i][0]] = SpillOffsTab[i][1];
53 }
54
55 /// isGVStub - Return true if the GV requires an extra load to get the
56 /// real address.
57 static inline bool isGVStub(GlobalValue *GV, SystemZTargetMachine &TM) {
58   return TM.getSubtarget<SystemZSubtarget>().GVRequiresExtraLoad(GV, TM, false);
59 }
60
61 void SystemZInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
62                                           MachineBasicBlock::iterator MI,
63                                     unsigned SrcReg, bool isKill, int FrameIdx,
64                                            const TargetRegisterClass *RC,
65                                            const TargetRegisterInfo *TRI) const {
66   DebugLoc DL;
67   if (MI != MBB.end()) DL = MI->getDebugLoc();
68
69   unsigned Opc = 0;
70   if (RC == &SystemZ::GR32RegClass ||
71       RC == &SystemZ::ADDR32RegClass)
72     Opc = SystemZ::MOV32mr;
73   else if (RC == &SystemZ::GR64RegClass ||
74            RC == &SystemZ::ADDR64RegClass) {
75     Opc = SystemZ::MOV64mr;
76   } else if (RC == &SystemZ::FP32RegClass) {
77     Opc = SystemZ::FMOV32mr;
78   } else if (RC == &SystemZ::FP64RegClass) {
79     Opc = SystemZ::FMOV64mr;
80   } else if (RC == &SystemZ::GR64PRegClass) {
81     Opc = SystemZ::MOV64Pmr;
82   } else if (RC == &SystemZ::GR128RegClass) {
83     Opc = SystemZ::MOV128mr;
84   } else
85     llvm_unreachable("Unsupported regclass to store");
86
87   addFrameReference(BuildMI(MBB, MI, DL, get(Opc)), FrameIdx)
88     .addReg(SrcReg, getKillRegState(isKill));
89 }
90
91 void SystemZInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
92                                            MachineBasicBlock::iterator MI,
93                                            unsigned DestReg, int FrameIdx,
94                                             const TargetRegisterClass *RC,
95                                             const TargetRegisterInfo *TRI) const{
96   DebugLoc DL;
97   if (MI != MBB.end()) DL = MI->getDebugLoc();
98
99   unsigned Opc = 0;
100   if (RC == &SystemZ::GR32RegClass ||
101       RC == &SystemZ::ADDR32RegClass)
102     Opc = SystemZ::MOV32rm;
103   else if (RC == &SystemZ::GR64RegClass ||
104            RC == &SystemZ::ADDR64RegClass) {
105     Opc = SystemZ::MOV64rm;
106   } else if (RC == &SystemZ::FP32RegClass) {
107     Opc = SystemZ::FMOV32rm;
108   } else if (RC == &SystemZ::FP64RegClass) {
109     Opc = SystemZ::FMOV64rm;
110   } else if (RC == &SystemZ::GR64PRegClass) {
111     Opc = SystemZ::MOV64Prm;
112   } else if (RC == &SystemZ::GR128RegClass) {
113     Opc = SystemZ::MOV128rm;
114   } else
115     llvm_unreachable("Unsupported regclass to load");
116
117   addFrameReference(BuildMI(MBB, MI, DL, get(Opc), DestReg), FrameIdx);
118 }
119
120 void SystemZInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
121                                    MachineBasicBlock::iterator I, DebugLoc DL,
122                                    unsigned DestReg, unsigned SrcReg,
123                                    bool KillSrc) const {
124   unsigned Opc;
125   if (SystemZ::GR64RegClass.contains(DestReg, SrcReg))
126     Opc = SystemZ::MOV64rr;
127   else if (SystemZ::GR32RegClass.contains(DestReg, SrcReg))
128     Opc = SystemZ::MOV32rr;
129   else if (SystemZ::GR64PRegClass.contains(DestReg, SrcReg))
130     Opc = SystemZ::MOV64rrP;
131   else if (SystemZ::GR128RegClass.contains(DestReg, SrcReg))
132     Opc = SystemZ::MOV128rr;
133   else if (SystemZ::GR32RegClass.contains(DestReg, SrcReg))
134     Opc = SystemZ::MOV32rr;
135   else if (SystemZ::FP32RegClass.contains(DestReg, SrcReg))
136     Opc = SystemZ::FMOV32rr;
137   else if (SystemZ::FP64RegClass.contains(DestReg, SrcReg))
138     Opc = SystemZ::FMOV64rr;
139   else
140     llvm_unreachable("Impossible reg-to-reg copy");
141
142   BuildMI(MBB, I, DL, get(Opc), DestReg)
143     .addReg(SrcReg, getKillRegState(KillSrc));
144 }
145
146 bool
147 SystemZInstrInfo::isMoveInstr(const MachineInstr& MI,
148                               unsigned &SrcReg, unsigned &DstReg,
149                               unsigned &SrcSubIdx, unsigned &DstSubIdx) const {
150   switch (MI.getOpcode()) {
151   default:
152     return false;
153   case SystemZ::MOV32rr:
154   case SystemZ::MOV64rr:
155   case SystemZ::MOV64rrP:
156   case SystemZ::MOV128rr:
157   case SystemZ::FMOV32rr:
158   case SystemZ::FMOV64rr:
159     assert(MI.getNumOperands() >= 2 &&
160            MI.getOperand(0).isReg() &&
161            MI.getOperand(1).isReg() &&
162            "invalid register-register move instruction");
163     SrcReg = MI.getOperand(1).getReg();
164     DstReg = MI.getOperand(0).getReg();
165     SrcSubIdx = MI.getOperand(1).getSubReg();
166     DstSubIdx = MI.getOperand(0).getSubReg();
167     return true;
168   }
169 }
170
171 unsigned SystemZInstrInfo::isLoadFromStackSlot(const MachineInstr *MI,
172                                                int &FrameIndex) const {
173   switch (MI->getOpcode()) {
174   default: break;
175   case SystemZ::MOV32rm:
176   case SystemZ::MOV32rmy:
177   case SystemZ::MOV64rm:
178   case SystemZ::MOVSX32rm8:
179   case SystemZ::MOVSX32rm16y:
180   case SystemZ::MOVSX64rm8:
181   case SystemZ::MOVSX64rm16:
182   case SystemZ::MOVSX64rm32:
183   case SystemZ::MOVZX32rm8:
184   case SystemZ::MOVZX32rm16:
185   case SystemZ::MOVZX64rm8:
186   case SystemZ::MOVZX64rm16:
187   case SystemZ::MOVZX64rm32:
188   case SystemZ::FMOV32rm:
189   case SystemZ::FMOV32rmy:
190   case SystemZ::FMOV64rm:
191   case SystemZ::FMOV64rmy:
192   case SystemZ::MOV64Prm:
193   case SystemZ::MOV64Prmy:
194   case SystemZ::MOV128rm:
195     if (MI->getOperand(1).isFI() &&
196         MI->getOperand(2).isImm() && MI->getOperand(3).isReg() &&
197         MI->getOperand(2).getImm() == 0 && MI->getOperand(3).getReg() == 0) {
198       FrameIndex = MI->getOperand(1).getIndex();
199       return MI->getOperand(0).getReg();
200     }
201     break;
202   }
203   return 0;
204 }
205
206 unsigned SystemZInstrInfo::isStoreToStackSlot(const MachineInstr *MI,
207                                               int &FrameIndex) const {
208   switch (MI->getOpcode()) {
209   default: break;
210   case SystemZ::MOV32mr:
211   case SystemZ::MOV32mry:
212   case SystemZ::MOV64mr:
213   case SystemZ::MOV32m8r:
214   case SystemZ::MOV32m8ry:
215   case SystemZ::MOV32m16r:
216   case SystemZ::MOV32m16ry:
217   case SystemZ::MOV64m8r:
218   case SystemZ::MOV64m8ry:
219   case SystemZ::MOV64m16r:
220   case SystemZ::MOV64m16ry:
221   case SystemZ::MOV64m32r:
222   case SystemZ::MOV64m32ry:
223   case SystemZ::FMOV32mr:
224   case SystemZ::FMOV32mry:
225   case SystemZ::FMOV64mr:
226   case SystemZ::FMOV64mry:
227   case SystemZ::MOV64Pmr:
228   case SystemZ::MOV64Pmry:
229   case SystemZ::MOV128mr:
230     if (MI->getOperand(0).isFI() &&
231         MI->getOperand(1).isImm() && MI->getOperand(2).isReg() &&
232         MI->getOperand(1).getImm() == 0 && MI->getOperand(2).getReg() == 0) {
233       FrameIndex = MI->getOperand(0).getIndex();
234       return MI->getOperand(3).getReg();
235     }
236     break;
237   }
238   return 0;
239 }
240
241 bool
242 SystemZInstrInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB,
243                                            MachineBasicBlock::iterator MI,
244                                         const std::vector<CalleeSavedInfo> &CSI,
245                                           const TargetRegisterInfo *TRI) const {
246   if (CSI.empty())
247     return false;
248
249   DebugLoc DL;
250   if (MI != MBB.end()) DL = MI->getDebugLoc();
251
252   MachineFunction &MF = *MBB.getParent();
253   SystemZMachineFunctionInfo *MFI = MF.getInfo<SystemZMachineFunctionInfo>();
254   unsigned CalleeFrameSize = 0;
255
256   // Scan the callee-saved and find the bounds of register spill area.
257   unsigned LowReg = 0, HighReg = 0, StartOffset = -1U, EndOffset = 0;
258   for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
259     unsigned Reg = CSI[i].getReg();
260     if (!SystemZ::FP64RegClass.contains(Reg)) {
261       unsigned Offset = RegSpillOffsets[Reg];
262       CalleeFrameSize += 8;
263       if (StartOffset > Offset) {
264         LowReg = Reg; StartOffset = Offset;
265       }
266       if (EndOffset < Offset) {
267         HighReg = Reg; EndOffset = RegSpillOffsets[Reg];
268       }
269     }
270   }
271
272   // Save information for epilogue inserter.
273   MFI->setCalleeSavedFrameSize(CalleeFrameSize);
274   MFI->setLowReg(LowReg); MFI->setHighReg(HighReg);
275
276   // Save GPRs
277   if (StartOffset) {
278     // Build a store instruction. Use STORE MULTIPLE instruction if there are many
279     // registers to store, otherwise - just STORE.
280     MachineInstrBuilder MIB =
281       BuildMI(MBB, MI, DL, get((LowReg == HighReg ?
282                                 SystemZ::MOV64mr : SystemZ::MOV64mrm)));
283
284     // Add store operands.
285     MIB.addReg(SystemZ::R15D).addImm(StartOffset);
286     if (LowReg == HighReg)
287       MIB.addReg(0);
288     MIB.addReg(LowReg, RegState::Kill);
289     if (LowReg != HighReg)
290       MIB.addReg(HighReg, RegState::Kill);
291
292     // Do a second scan adding regs as being killed by instruction
293     for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
294       unsigned Reg = CSI[i].getReg();
295       // Add the callee-saved register as live-in. It's killed at the spill.
296       MBB.addLiveIn(Reg);
297       if (Reg != LowReg && Reg != HighReg)
298         MIB.addReg(Reg, RegState::ImplicitKill);
299     }
300   }
301
302   // Save FPRs
303   for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
304     unsigned Reg = CSI[i].getReg();
305     if (SystemZ::FP64RegClass.contains(Reg)) {
306       MBB.addLiveIn(Reg);
307       storeRegToStackSlot(MBB, MI, Reg, true, CSI[i].getFrameIdx(),
308                           &SystemZ::FP64RegClass, &RI);
309     }
310   }
311
312   return true;
313 }
314
315 bool
316 SystemZInstrInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
317                                              MachineBasicBlock::iterator MI,
318                                         const std::vector<CalleeSavedInfo> &CSI,
319                                           const TargetRegisterInfo *TRI) const {
320   if (CSI.empty())
321     return false;
322
323   DebugLoc DL;
324   if (MI != MBB.end()) DL = MI->getDebugLoc();
325
326   MachineFunction &MF = *MBB.getParent();
327   const TargetRegisterInfo *RegInfo= MF.getTarget().getRegisterInfo();
328   SystemZMachineFunctionInfo *MFI = MF.getInfo<SystemZMachineFunctionInfo>();
329
330   // Restore FP registers
331   for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
332     unsigned Reg = CSI[i].getReg();
333     if (SystemZ::FP64RegClass.contains(Reg))
334       loadRegFromStackSlot(MBB, MI, Reg, CSI[i].getFrameIdx(),
335                            &SystemZ::FP64RegClass, &RI);
336   }
337
338   // Restore GP registers
339   unsigned LowReg = MFI->getLowReg(), HighReg = MFI->getHighReg();
340   unsigned StartOffset = RegSpillOffsets[LowReg];
341
342   if (StartOffset) {
343     // Build a load instruction. Use LOAD MULTIPLE instruction if there are many
344     // registers to load, otherwise - just LOAD.
345     MachineInstrBuilder MIB =
346       BuildMI(MBB, MI, DL, get((LowReg == HighReg ?
347                                 SystemZ::MOV64rm : SystemZ::MOV64rmm)));
348     // Add store operands.
349     MIB.addReg(LowReg, RegState::Define);
350     if (LowReg != HighReg)
351       MIB.addReg(HighReg, RegState::Define);
352
353     MIB.addReg((RegInfo->hasFP(MF) ? SystemZ::R11D : SystemZ::R15D));
354     MIB.addImm(StartOffset);
355     if (LowReg == HighReg)
356       MIB.addReg(0);
357
358     // Do a second scan adding regs as being defined by instruction
359     for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
360       unsigned Reg = CSI[i].getReg();
361       if (Reg != LowReg && Reg != HighReg)
362         MIB.addReg(Reg, RegState::ImplicitDefine);
363     }
364   }
365
366   return true;
367 }
368
369 bool SystemZInstrInfo::
370 ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
371   assert(Cond.size() == 1 && "Invalid Xbranch condition!");
372
373   SystemZCC::CondCodes CC = static_cast<SystemZCC::CondCodes>(Cond[0].getImm());
374   Cond[0].setImm(getOppositeCondition(CC));
375   return false;
376 }
377
378 bool SystemZInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
379   const TargetInstrDesc &TID = MI->getDesc();
380   if (!TID.isTerminator()) return false;
381
382   // Conditional branch is a special case.
383   if (TID.isBranch() && !TID.isBarrier())
384     return true;
385   if (!TID.isPredicable())
386     return true;
387   return !isPredicated(MI);
388 }
389
390 bool SystemZInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
391                                      MachineBasicBlock *&TBB,
392                                      MachineBasicBlock *&FBB,
393                                      SmallVectorImpl<MachineOperand> &Cond,
394                                      bool AllowModify) const {
395   // Start from the bottom of the block and work up, examining the
396   // terminator instructions.
397   MachineBasicBlock::iterator I = MBB.end();
398   while (I != MBB.begin()) {
399     --I;
400     if (I->isDebugValue())
401       continue;
402     // Working from the bottom, when we see a non-terminator
403     // instruction, we're done.
404     if (!isUnpredicatedTerminator(I))
405       break;
406
407     // A terminator that isn't a branch can't easily be handled
408     // by this analysis.
409     if (!I->getDesc().isBranch())
410       return true;
411
412     // Handle unconditional branches.
413     if (I->getOpcode() == SystemZ::JMP) {
414       if (!AllowModify) {
415         TBB = I->getOperand(0).getMBB();
416         continue;
417       }
418
419       // If the block has any instructions after a JMP, delete them.
420       while (llvm::next(I) != MBB.end())
421         llvm::next(I)->eraseFromParent();
422       Cond.clear();
423       FBB = 0;
424
425       // Delete the JMP if it's equivalent to a fall-through.
426       if (MBB.isLayoutSuccessor(I->getOperand(0).getMBB())) {
427         TBB = 0;
428         I->eraseFromParent();
429         I = MBB.end();
430         continue;
431       }
432
433       // TBB is used to indicate the unconditinal destination.
434       TBB = I->getOperand(0).getMBB();
435       continue;
436     }
437
438     // Handle conditional branches.
439     SystemZCC::CondCodes BranchCode = getCondFromBranchOpc(I->getOpcode());
440     if (BranchCode == SystemZCC::INVALID)
441       return true;  // Can't handle indirect branch.
442
443     // Working from the bottom, handle the first conditional branch.
444     if (Cond.empty()) {
445       FBB = TBB;
446       TBB = I->getOperand(0).getMBB();
447       Cond.push_back(MachineOperand::CreateImm(BranchCode));
448       continue;
449     }
450
451     // Handle subsequent conditional branches. Only handle the case where all
452     // conditional branches branch to the same destination.
453     assert(Cond.size() == 1);
454     assert(TBB);
455
456     // Only handle the case where all conditional branches branch to
457     // the same destination.
458     if (TBB != I->getOperand(0).getMBB())
459       return true;
460
461     SystemZCC::CondCodes OldBranchCode = (SystemZCC::CondCodes)Cond[0].getImm();
462     // If the conditions are the same, we can leave them alone.
463     if (OldBranchCode == BranchCode)
464       continue;
465
466     return true;
467   }
468
469   return false;
470 }
471
472 unsigned SystemZInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
473   MachineBasicBlock::iterator I = MBB.end();
474   unsigned Count = 0;
475
476   while (I != MBB.begin()) {
477     --I;
478     if (I->isDebugValue())
479       continue;
480     if (I->getOpcode() != SystemZ::JMP &&
481         getCondFromBranchOpc(I->getOpcode()) == SystemZCC::INVALID)
482       break;
483     // Remove the branch.
484     I->eraseFromParent();
485     I = MBB.end();
486     ++Count;
487   }
488
489   return Count;
490 }
491
492 unsigned
493 SystemZInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
494                                MachineBasicBlock *FBB,
495                                const SmallVectorImpl<MachineOperand> &Cond,
496                                DebugLoc DL) const {
497   // Shouldn't be a fall through.
498   assert(TBB && "InsertBranch must not be told to insert a fallthrough");
499   assert((Cond.size() == 1 || Cond.size() == 0) &&
500          "SystemZ branch conditions have one component!");
501
502   if (Cond.empty()) {
503     // Unconditional branch?
504     assert(!FBB && "Unconditional branch with multiple successors!");
505     BuildMI(&MBB, DL, get(SystemZ::JMP)).addMBB(TBB);
506     return 1;
507   }
508
509   // Conditional branch.
510   unsigned Count = 0;
511   SystemZCC::CondCodes CC = (SystemZCC::CondCodes)Cond[0].getImm();
512   BuildMI(&MBB, DL, getBrCond(CC)).addMBB(TBB);
513   ++Count;
514
515   if (FBB) {
516     // Two-way Conditional branch. Insert the second branch.
517     BuildMI(&MBB, DL, get(SystemZ::JMP)).addMBB(FBB);
518     ++Count;
519   }
520   return Count;
521 }
522
523 const TargetInstrDesc&
524 SystemZInstrInfo::getBrCond(SystemZCC::CondCodes CC) const {
525   switch (CC) {
526   default:
527    llvm_unreachable("Unknown condition code!");
528   case SystemZCC::O:   return get(SystemZ::JO);
529   case SystemZCC::H:   return get(SystemZ::JH);
530   case SystemZCC::NLE: return get(SystemZ::JNLE);
531   case SystemZCC::L:   return get(SystemZ::JL);
532   case SystemZCC::NHE: return get(SystemZ::JNHE);
533   case SystemZCC::LH:  return get(SystemZ::JLH);
534   case SystemZCC::NE:  return get(SystemZ::JNE);
535   case SystemZCC::E:   return get(SystemZ::JE);
536   case SystemZCC::NLH: return get(SystemZ::JNLH);
537   case SystemZCC::HE:  return get(SystemZ::JHE);
538   case SystemZCC::NL:  return get(SystemZ::JNL);
539   case SystemZCC::LE:  return get(SystemZ::JLE);
540   case SystemZCC::NH:  return get(SystemZ::JNH);
541   case SystemZCC::NO:  return get(SystemZ::JNO);
542   }
543 }
544
545 SystemZCC::CondCodes
546 SystemZInstrInfo::getCondFromBranchOpc(unsigned Opc) const {
547   switch (Opc) {
548   default:            return SystemZCC::INVALID;
549   case SystemZ::JO:   return SystemZCC::O;
550   case SystemZ::JH:   return SystemZCC::H;
551   case SystemZ::JNLE: return SystemZCC::NLE;
552   case SystemZ::JL:   return SystemZCC::L;
553   case SystemZ::JNHE: return SystemZCC::NHE;
554   case SystemZ::JLH:  return SystemZCC::LH;
555   case SystemZ::JNE:  return SystemZCC::NE;
556   case SystemZ::JE:   return SystemZCC::E;
557   case SystemZ::JNLH: return SystemZCC::NLH;
558   case SystemZ::JHE:  return SystemZCC::HE;
559   case SystemZ::JNL:  return SystemZCC::NL;
560   case SystemZ::JLE:  return SystemZCC::LE;
561   case SystemZ::JNH:  return SystemZCC::NH;
562   case SystemZ::JNO:  return SystemZCC::NO;
563   }
564 }
565
566 SystemZCC::CondCodes
567 SystemZInstrInfo::getOppositeCondition(SystemZCC::CondCodes CC) const {
568   switch (CC) {
569   default:
570     llvm_unreachable("Invalid condition!");
571   case SystemZCC::O:   return SystemZCC::NO;
572   case SystemZCC::H:   return SystemZCC::NH;
573   case SystemZCC::NLE: return SystemZCC::LE;
574   case SystemZCC::L:   return SystemZCC::NL;
575   case SystemZCC::NHE: return SystemZCC::HE;
576   case SystemZCC::LH:  return SystemZCC::NLH;
577   case SystemZCC::NE:  return SystemZCC::E;
578   case SystemZCC::E:   return SystemZCC::NE;
579   case SystemZCC::NLH: return SystemZCC::LH;
580   case SystemZCC::HE:  return SystemZCC::NHE;
581   case SystemZCC::NL:  return SystemZCC::L;
582   case SystemZCC::LE:  return SystemZCC::NLE;
583   case SystemZCC::NH:  return SystemZCC::H;
584   case SystemZCC::NO:  return SystemZCC::O;
585   }
586 }
587
588 const TargetInstrDesc&
589 SystemZInstrInfo::getLongDispOpc(unsigned Opc) const {
590   switch (Opc) {
591   default:
592     llvm_unreachable("Don't have long disp version of this instruction");
593   case SystemZ::MOV32mr:   return get(SystemZ::MOV32mry);
594   case SystemZ::MOV32rm:   return get(SystemZ::MOV32rmy);
595   case SystemZ::MOVSX32rm16: return get(SystemZ::MOVSX32rm16y);
596   case SystemZ::MOV32m8r:  return get(SystemZ::MOV32m8ry);
597   case SystemZ::MOV32m16r: return get(SystemZ::MOV32m16ry);
598   case SystemZ::MOV64m8r:  return get(SystemZ::MOV64m8ry);
599   case SystemZ::MOV64m16r: return get(SystemZ::MOV64m16ry);
600   case SystemZ::MOV64m32r: return get(SystemZ::MOV64m32ry);
601   case SystemZ::MOV8mi:    return get(SystemZ::MOV8miy);
602   case SystemZ::MUL32rm:   return get(SystemZ::MUL32rmy);
603   case SystemZ::CMP32rm:   return get(SystemZ::CMP32rmy);
604   case SystemZ::UCMP32rm:  return get(SystemZ::UCMP32rmy);
605   case SystemZ::FMOV32mr:  return get(SystemZ::FMOV32mry);
606   case SystemZ::FMOV64mr:  return get(SystemZ::FMOV64mry);
607   case SystemZ::FMOV32rm:  return get(SystemZ::FMOV32rmy);
608   case SystemZ::FMOV64rm:  return get(SystemZ::FMOV64rmy);
609   case SystemZ::MOV64Pmr:  return get(SystemZ::MOV64Pmry);
610   case SystemZ::MOV64Prm:  return get(SystemZ::MOV64Prmy);
611   }
612 }