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;
31 const MipsRegisterInfo RI;
35 explicit MipsInstrInfo(MipsTargetMachine &TM, unsigned UncondBrOpc);
38 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
39 MachineBasicBlock *&FBB,
40 SmallVectorImpl<MachineOperand> &Cond,
41 bool AllowModify) const;
43 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
45 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
46 MachineBasicBlock *FBB,
47 const SmallVectorImpl<MachineOperand> &Cond,
51 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
53 virtual MachineInstr* emitFrameIndexDebugValue(MachineFunction &MF,
54 int FrameIx, uint64_t Offset,
58 /// Insert nop instruction when hazard condition is found
59 virtual void insertNoop(MachineBasicBlock &MBB,
60 MachineBasicBlock::iterator MI) const;
62 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
63 /// such, whenever a client has an instance of instruction info, it should
64 /// always be able to get register info as well (through this method).
66 virtual const MipsRegisterInfo &getRegisterInfo() const;
68 virtual unsigned GetOppositeBranchOpc(unsigned Opc) const = 0;
70 /// Return the number of bytes of code the specified instruction may be.
71 unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
74 bool isZeroImm(const MachineOperand &op) const;
76 MachineMemOperand *GetMemOperand(MachineBasicBlock &MBB, int FI,
80 virtual unsigned GetAnalyzableBrOpc(unsigned Opc) const = 0;
82 void AnalyzeCondBr(const MachineInstr *Inst, unsigned Opc,
83 MachineBasicBlock *&BB,
84 SmallVectorImpl<MachineOperand> &Cond) const;
86 void BuildCondBr(MachineBasicBlock &MBB, MachineBasicBlock *TBB, DebugLoc DL,
87 const SmallVectorImpl<MachineOperand>& Cond) const;
91 /// Emit a series of instructions to load an immediate. All instructions
92 /// except for the last one are emitted. The function returns the number of
93 /// MachineInstrs generated. The opcode-immediate pair of the last
94 /// instruction is returned in LastInst, if it is not 0.
96 loadImmediate(int64_t Imm, bool IsN64, const TargetInstrInfo &TII,
97 MachineBasicBlock& MBB, MachineBasicBlock::iterator II,
98 DebugLoc DL, bool LastInstrIsADDiu,
99 MipsAnalyzeImmediate::Inst *LastInst);