Move isLoadFrom/StoreToStackSlot from MRegisterInfo to TargetInstrInfo,a far more...
[oota-llvm.git] / lib / Target / PowerPC / PPCInstrInfo.h
1 //===- PPCInstrInfo.h - PowerPC Instruction Information ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the PowerPC implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef POWERPC32_INSTRUCTIONINFO_H
15 #define POWERPC32_INSTRUCTIONINFO_H
16
17 #include "PPC.h"
18 #include "llvm/Target/TargetInstrInfo.h"
19 #include "PPCRegisterInfo.h"
20
21 namespace llvm {
22   
23 class PPCInstrInfo : public TargetInstrInfo {
24   const PPCRegisterInfo RI;
25 public:
26   PPCInstrInfo();
27
28   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
29   /// such, whenever a client has an instance of instruction info, it should
30   /// always be able to get register info as well (through this method).
31   ///
32   virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
33
34   //
35   // Return true if the instruction is a register to register move and
36   // leave the source and dest operands in the passed parameters.
37   //
38   virtual bool isMoveInstr(const MachineInstr& MI,
39                            unsigned& sourceReg,
40                            unsigned& destReg) const;
41
42   unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
43
44   // commuteInstruction - We can commute rlwimi instructions, but only if the
45   // rotate amt is zero.  We also have to munge the immediates a bit.
46   virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
47   
48   static unsigned invertPPCBranchOpcode(unsigned Opcode) {
49     switch (Opcode) {
50     default: assert(0 && "Unknown PPC branch opcode!");
51     case PPC::BEQ: return PPC::BNE;
52     case PPC::BNE: return PPC::BEQ;
53     case PPC::BLT: return PPC::BGE;
54     case PPC::BGE: return PPC::BLT;
55     case PPC::BGT: return PPC::BLE;
56     case PPC::BLE: return PPC::BGT;
57     case PPC::BNU: return PPC::BUN;
58     case PPC::BUN: return PPC::BNU;
59     }
60   }
61 };
62
63 }
64
65 #endif