Set the is64bit flag and propagate it to PowerPCRegisterInfo
[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   bool is64bit;
68 public:
69   PowerPCInstrInfo(bool is64b);
70
71   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
72   /// such, whenever a client has an instance of instruction info, it should
73   /// always be able to get register info as well (through this method).
74   ///
75   virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
76
77   //
78   // Return true if the instruction is a register to register move and
79   // leave the source and dest operands in the passed parameters.
80   //
81   virtual bool isMoveInstr(const MachineInstr& MI,
82                            unsigned& sourceReg,
83                            unsigned& destReg) const;
84
85   static unsigned invertPPCBranchOpcode(unsigned Opcode) {
86     switch (Opcode) {
87     default: assert(0 && "Unknown PPC branch opcode!");
88     case PPC::BEQ: return PPC::BNE;
89     case PPC::BNE: return PPC::BEQ;
90     case PPC::BLT: return PPC::BGE;
91     case PPC::BGE: return PPC::BLT;
92     case PPC::BGT: return PPC::BLE;
93     case PPC::BLE: return PPC::BGT;
94     } 
95   }
96 };
97
98 }
99
100 #endif