The define for 64 bit sign extension neglected to
[oota-llvm.git] / lib / Target / Mips / MipsInstrInfo.h
1 //===-- MipsInstrInfo.h - Mips Instruction Information ----------*- C++ -*-===//
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 Mips implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef MIPSINSTRUCTIONINFO_H
15 #define MIPSINSTRUCTIONINFO_H
16
17 #include "Mips.h"
18 #include "MipsAnalyzeImmediate.h"
19 #include "MipsRegisterInfo.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include "llvm/Target/TargetInstrInfo.h"
22
23 #define GET_INSTRINFO_HEADER
24 #include "MipsGenInstrInfo.inc"
25
26 namespace llvm {
27
28 class MipsInstrInfo : public MipsGenInstrInfo {
29 protected:
30   MipsTargetMachine &TM;
31   unsigned UncondBrOpc;
32
33 public:
34   explicit MipsInstrInfo(MipsTargetMachine &TM, unsigned UncondBrOpc);
35
36   static const MipsInstrInfo *create(MipsTargetMachine &TM);
37
38   /// Branch Analysis
39   virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
40                              MachineBasicBlock *&FBB,
41                              SmallVectorImpl<MachineOperand> &Cond,
42                              bool AllowModify) const;
43
44   virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
45
46   virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
47                                 MachineBasicBlock *FBB,
48                                 const SmallVectorImpl<MachineOperand> &Cond,
49                                 DebugLoc DL) const;
50
51   virtual
52   bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
53
54   virtual MachineInstr* emitFrameIndexDebugValue(MachineFunction &MF,
55                                                  int FrameIx, uint64_t Offset,
56                                                  const MDNode *MDPtr,
57                                                  DebugLoc DL) const;
58
59   /// Insert nop instruction when hazard condition is found
60   virtual void insertNoop(MachineBasicBlock &MBB,
61                           MachineBasicBlock::iterator MI) const;
62
63   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
64   /// such, whenever a client has an instance of instruction info, it should
65   /// always be able to get register info as well (through this method).
66   ///
67   virtual const MipsRegisterInfo &getRegisterInfo() const = 0;
68
69   virtual unsigned GetOppositeBranchOpc(unsigned Opc) const = 0;
70
71   /// Return the number of bytes of code the specified instruction may be.
72   unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
73
74 protected:
75   bool isZeroImm(const MachineOperand &op) const;
76
77   MachineMemOperand *GetMemOperand(MachineBasicBlock &MBB, int FI,
78                                    unsigned Flag) const;
79
80 private:
81   virtual unsigned GetAnalyzableBrOpc(unsigned Opc) const = 0;
82
83   void AnalyzeCondBr(const MachineInstr *Inst, unsigned Opc,
84                      MachineBasicBlock *&BB,
85                      SmallVectorImpl<MachineOperand> &Cond) const;
86
87   void BuildCondBr(MachineBasicBlock &MBB, MachineBasicBlock *TBB, DebugLoc DL,
88                    const SmallVectorImpl<MachineOperand>& Cond) const;
89 };
90
91 namespace Mips {
92   /// Emit a series of instructions to load an immediate. All instructions
93   /// except for the last one are emitted. The function returns the number of
94   /// MachineInstrs generated. The opcode-immediate pair of the last
95   /// instruction is returned in LastInst, if it is not 0.
96   unsigned
97   loadImmediate(int64_t Imm, bool IsN64, const TargetInstrInfo &TII,
98                 MachineBasicBlock& MBB, MachineBasicBlock::iterator II,
99                 DebugLoc DL, bool LastInstrIsADDiu,
100                 MipsAnalyzeImmediate::Inst *LastInst);
101 }
102
103 /// Create MipsInstrInfo objects.
104 const MipsInstrInfo *createMips16InstrInfo(MipsTargetMachine &TM);
105 const MipsInstrInfo *createMipsSEInstrInfo(MipsTargetMachine &TM);
106
107 }
108
109 #endif