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 26namespace llvm { 27 28class MipsInstrInfo : public MipsGenInstrInfo { 29protected: 30 MipsTargetMachine &TM; 31 unsigned UncondBrOpc; 32 33public: 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 74protected: 75 bool isZeroImm(const MachineOperand &op) const; 76 77 MachineMemOperand *GetMemOperand(MachineBasicBlock &MBB, int FI, 78 unsigned Flag) const; 79 80private: 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/// Create MipsInstrInfo objects. 92const MipsInstrInfo *createMips16InstrInfo(MipsTargetMachine &TM); 93const MipsInstrInfo *createMipsSEInstrInfo(MipsTargetMachine &TM); 94 95} 96 97#endif 98