Breaking up the PowerPC target into 32- and 64-bit subparts, Part III: the rest.
[oota-llvm.git] / lib / Target / PowerPC / PowerPCInstrInfo.h
1 //===- PowerPCInstrInfo.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 POWERPC_INSTRUCTIONINFO_H
15 #define POWERPC_INSTRUCTIONINFO_H
16
17 #include "PowerPC.h"
18 #include "PowerPCRegisterInfo.h"
19 #include "llvm/Target/TargetInstrInfo.h"
20
21 namespace llvm {
22
23 namespace PPCII {
24         enum {
25                 ArgCountShift = 0,
26                 ArgCountMask = 7,
27                 
28                 Arg0TypeShift = 3,
29                 Arg1TypeShift = 8,
30                 Arg2TypeShift = 13,
31                 Arg3TypeShift = 18,
32                 Arg4TypeShift = 23,
33                 VMX = 1<<28,
34                 PPC64 = 1<<29,
35                 ArgTypeMask = 31
36         };
37         
38         enum {
39                 None = 0,
40                 Gpr = 1,
41                 Gpr0 = 2,
42                 Simm16 = 3,
43                 Zimm16 = 4,
44                 PCRelimm24 = 5,
45                 Imm24 = 6,
46                 Imm5 = 7,
47                 PCRelimm14 = 8,
48                 Imm14 = 9,
49                 Imm2 = 10,
50                 Crf = 11,
51                 Imm3 = 12,
52                 Imm1 = 13,
53                 Fpr = 14,
54                 Imm4 = 15,
55                 Imm8 = 16,
56                 Disimm16 = 17,
57                 Disimm14 = 18,
58                 Spr = 19,
59                 Sgr = 20,
60                 Imm15 = 21,
61                 Vpr = 22
62         };
63 }
64
65 class PowerPCInstrInfo : public TargetInstrInfo {
66   const PowerPCRegisterInfo RI;
67 public:
68   PowerPCInstrInfo();
69
70   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
71   /// such, whenever a client has an instance of instruction info, it should
72   /// always be able to get register info as well (through this method).
73   ///
74   virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
75
76   //
77   // Return true if the instruction is a register to register move and
78   // leave the source and dest operands in the passed parameters.
79   //
80   virtual bool isMoveInstr(const MachineInstr& MI,
81                            unsigned& sourceReg,
82                            unsigned& destReg) const;
83
84   static unsigned invertPPCBranchOpcode(unsigned Opcode) {
85     switch (Opcode) {
86     default: assert(0 && "Unknown PPC branch opcode!");
87     case PPC::BEQ: return PPC::BNE;
88     case PPC::BNE: return PPC::BEQ;
89     case PPC::BLT: return PPC::BGE;
90     case PPC::BGE: return PPC::BLT;
91     case PPC::BGT: return PPC::BLE;
92     case PPC::BLE: return PPC::BGT;
93     } 
94   }
95 };
96
97 }
98
99 #endif