2012-02-28 07:46:26 +00:00
|
|
|
//===-- MipsInstrInfo.h - Mips Instruction Information ----------*- C++ -*-===//
|
2007-06-06 07:42:06 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-06-06 07:42:06 +00:00
|
|
|
//
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
//
|
|
|
|
// This file contains the Mips implementation of the TargetInstrInfo class.
|
|
|
|
//
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
|
|
|
|
#ifndef MIPSINSTRUCTIONINFO_H
|
|
|
|
#define MIPSINSTRUCTIONINFO_H
|
|
|
|
|
|
|
|
#include "Mips.h"
|
2012-06-14 01:16:45 +00:00
|
|
|
#include "MipsAnalyzeImmediate.h"
|
2012-03-17 18:46:09 +00:00
|
|
|
#include "MipsRegisterInfo.h"
|
2009-07-11 20:10:48 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2007-06-06 07:42:06 +00:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
|
|
|
|
2011-07-01 17:57:27 +00:00
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "MipsGenInstrInfo.inc"
|
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2011-07-01 17:57:27 +00:00
|
|
|
class MipsInstrInfo : public MipsGenInstrInfo {
|
2012-07-31 21:49:49 +00:00
|
|
|
protected:
|
2007-06-06 07:42:06 +00:00
|
|
|
MipsTargetMachine &TM;
|
2011-12-12 22:39:35 +00:00
|
|
|
unsigned UncondBrOpc;
|
2007-06-06 07:42:06 +00:00
|
|
|
|
2012-07-31 21:49:49 +00:00
|
|
|
public:
|
|
|
|
explicit MipsInstrInfo(MipsTargetMachine &TM, unsigned UncondBrOpc);
|
2011-03-04 17:51:39 +00:00
|
|
|
|
2012-08-02 18:21:47 +00:00
|
|
|
static const MipsInstrInfo *create(MipsTargetMachine &TM);
|
|
|
|
|
2007-08-18 01:59:45 +00:00
|
|
|
/// Branch Analysis
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2009-02-09 07:14:22 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const;
|
2011-04-01 17:39:08 +00:00
|
|
|
|
2012-07-31 21:49:49 +00:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
2011-04-01 17:39:08 +00:00
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2007-08-18 01:59:45 +00:00
|
|
|
MachineBasicBlock *FBB,
|
2010-06-17 22:43:56 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
DebugLoc DL) const;
|
2012-07-31 21:49:49 +00:00
|
|
|
|
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
|
2012-05-25 20:52:52 +00:00
|
|
|
|
2011-07-01 01:04:43 +00:00
|
|
|
virtual MachineInstr* emitFrameIndexDebugValue(MachineFunction &MF,
|
|
|
|
int FrameIx, uint64_t Offset,
|
|
|
|
const MDNode *MDPtr,
|
|
|
|
DebugLoc DL) const;
|
|
|
|
|
2007-08-18 01:59:45 +00:00
|
|
|
/// Insert nop instruction when hazard condition is found
|
2011-03-04 17:51:39 +00:00
|
|
|
virtual void insertNoop(MachineBasicBlock &MBB,
|
2007-08-18 01:59:45 +00:00
|
|
|
MachineBasicBlock::iterator MI) const;
|
2012-06-14 01:16:45 +00:00
|
|
|
|
2012-07-31 21:49:49 +00:00
|
|
|
/// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
|
|
|
|
/// such, whenever a client has an instance of instruction info, it should
|
|
|
|
/// always be able to get register info as well (through this method).
|
|
|
|
///
|
2012-07-31 23:41:32 +00:00
|
|
|
virtual const MipsRegisterInfo &getRegisterInfo() const = 0;
|
2012-07-31 21:49:49 +00:00
|
|
|
|
|
|
|
virtual unsigned GetOppositeBranchOpc(unsigned Opc) const = 0;
|
|
|
|
|
2012-06-14 01:16:45 +00:00
|
|
|
/// Return the number of bytes of code the specified instruction may be.
|
|
|
|
unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
|
2012-07-31 21:49:49 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool isZeroImm(const MachineOperand &op) const;
|
|
|
|
|
|
|
|
MachineMemOperand *GetMemOperand(MachineBasicBlock &MBB, int FI,
|
|
|
|
unsigned Flag) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual unsigned GetAnalyzableBrOpc(unsigned Opc) const = 0;
|
|
|
|
|
|
|
|
void AnalyzeCondBr(const MachineInstr *Inst, unsigned Opc,
|
|
|
|
MachineBasicBlock *&BB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond) const;
|
|
|
|
|
|
|
|
void BuildCondBr(MachineBasicBlock &MBB, MachineBasicBlock *TBB, DebugLoc DL,
|
|
|
|
const SmallVectorImpl<MachineOperand>& Cond) const;
|
2007-06-06 07:42:06 +00:00
|
|
|
};
|
|
|
|
|
2012-08-02 18:21:47 +00:00
|
|
|
/// Create MipsInstrInfo objects.
|
|
|
|
const MipsInstrInfo *createMips16InstrInfo(MipsTargetMachine &TM);
|
|
|
|
const MipsInstrInfo *createMipsSEInstrInfo(MipsTargetMachine &TM);
|
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|