1 //===-- MipsInstrInfo.h - Mips Instruction Information ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the Mips implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef MIPSINSTRUCTIONINFO_H
15 #define MIPSINSTRUCTIONINFO_H
18 #include "MipsAnalyzeImmediate.h"
19 #include "MipsRegisterInfo.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include "llvm/Target/TargetInstrInfo.h"
23 #define GET_INSTRINFO_HEADER
24 #include "MipsGenInstrInfo.inc"
28 class MipsInstrInfo : public MipsGenInstrInfo {
30 MipsTargetMachine &TM;
34 explicit MipsInstrInfo(MipsTargetMachine &TM, unsigned UncondBrOpc);
36 static const MipsInstrInfo *create(MipsTargetMachine &TM);
39 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
40 MachineBasicBlock *&FBB,
41 SmallVectorImpl<MachineOperand> &Cond,
42 bool AllowModify) const;
44 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
46 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
47 MachineBasicBlock *FBB,
48 const SmallVectorImpl<MachineOperand> &Cond,
52 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
54 virtual MachineInstr* emitFrameIndexDebugValue(MachineFunction &MF,
55 int FrameIx, uint64_t Offset,
59 /// Insert nop instruction when hazard condition is found
60 virtual void insertNoop(MachineBasicBlock &MBB,
61 MachineBasicBlock::iterator MI) const;
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).
67 virtual const MipsRegisterInfo &getRegisterInfo() const = 0;
69 virtual unsigned GetOppositeBranchOpc(unsigned Opc) const = 0;
71 /// Return the number of bytes of code the specified instruction may be.
72 unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
75 bool isZeroImm(const MachineOperand &op) const;
77 MachineMemOperand *GetMemOperand(MachineBasicBlock &MBB, int FI,
81 virtual unsigned GetAnalyzableBrOpc(unsigned Opc) const = 0;
83 void AnalyzeCondBr(const MachineInstr *Inst, unsigned Opc,
84 MachineBasicBlock *&BB,
85 SmallVectorImpl<MachineOperand> &Cond) const;
87 void BuildCondBr(MachineBasicBlock &MBB, MachineBasicBlock *TBB, DebugLoc DL,
88 const SmallVectorImpl<MachineOperand>& Cond) const;
91 /// Create MipsInstrInfo objects.
92 const MipsInstrInfo *createMips16InstrInfo(MipsTargetMachine &TM);
93 const MipsInstrInfo *createMipsSEInstrInfo(MipsTargetMachine &TM);