2012-02-28 15:46:26 +08:00
|
|
|
//===-- MipsInstrInfo.h - Mips Instruction Information ----------*- C++ -*-===//
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
|
|
|
// This file contains the Mips implementation of the TargetInstrInfo class.
|
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
|
|
|
|
#ifndef MIPSINSTRUCTIONINFO_H
|
|
|
|
#define MIPSINSTRUCTIONINFO_H
|
|
|
|
|
|
|
|
#include "Mips.h"
|
2012-06-14 09:16:45 +08:00
|
|
|
#include "MipsAnalyzeImmediate.h"
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "MipsRegisterInfo.h"
|
2009-07-12 04:10:48 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2007-06-06 15:42:06 +08:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
|
|
|
|
2011-07-02 01:57:27 +08:00
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "MipsGenInstrInfo.inc"
|
|
|
|
|
2007-06-06 15:42:06 +08:00
|
|
|
namespace llvm {
|
|
|
|
|
2011-07-02 01:57:27 +08:00
|
|
|
class MipsInstrInfo : public MipsGenInstrInfo {
|
2012-08-01 05:49:49 +08:00
|
|
|
protected:
|
2007-06-06 15:42:06 +08:00
|
|
|
MipsTargetMachine &TM;
|
2011-12-13 06:39:35 +08:00
|
|
|
unsigned UncondBrOpc;
|
2007-06-06 15:42:06 +08:00
|
|
|
|
2012-08-01 05:49:49 +08:00
|
|
|
public:
|
2013-03-01 09:10:17 +08:00
|
|
|
enum BranchType {
|
|
|
|
BT_None, // Couldn't analyze branch.
|
|
|
|
BT_NoBranch, // No branches found.
|
|
|
|
BT_Uncond, // One unconditional branch.
|
|
|
|
BT_Cond, // One conditional branch.
|
|
|
|
BT_CondUncond, // A conditional branch followed by an unconditional branch.
|
|
|
|
BT_Indirect // One indirct branch.
|
|
|
|
};
|
|
|
|
|
2012-08-01 05:49:49 +08:00
|
|
|
explicit MipsInstrInfo(MipsTargetMachine &TM, unsigned UncondBrOpc);
|
2011-03-05 01:51:39 +08:00
|
|
|
|
2012-08-03 02:21:47 +08:00
|
|
|
static const MipsInstrInfo *create(MipsTargetMachine &TM);
|
|
|
|
|
2007-08-18 09:59:45 +08:00
|
|
|
/// Branch Analysis
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2009-02-09 15:14:22 +08:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const;
|
2011-04-02 01:39:08 +08:00
|
|
|
|
2012-08-01 05:49:49 +08:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
2011-04-02 01:39:08 +08:00
|
|
|
|
2007-06-06 15:42:06 +08:00
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2007-08-18 09:59:45 +08:00
|
|
|
MachineBasicBlock *FBB,
|
2010-06-18 06:43:56 +08:00
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
DebugLoc DL) const;
|
2012-08-01 05:49:49 +08:00
|
|
|
|
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
|
2012-05-26 04:52:52 +08:00
|
|
|
|
2013-03-01 09:10:17 +08:00
|
|
|
BranchType AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify,
|
|
|
|
SmallVectorImpl<MachineInstr*> &BranchInstrs) const;
|
|
|
|
|
2011-07-01 09:04:43 +08:00
|
|
|
virtual MachineInstr* emitFrameIndexDebugValue(MachineFunction &MF,
|
|
|
|
int FrameIx, uint64_t Offset,
|
|
|
|
const MDNode *MDPtr,
|
|
|
|
DebugLoc DL) const;
|
|
|
|
|
2007-08-18 09:59:45 +08:00
|
|
|
/// Insert nop instruction when hazard condition is found
|
2011-03-05 01:51:39 +08:00
|
|
|
virtual void insertNoop(MachineBasicBlock &MBB,
|
2007-08-18 09:59:45 +08:00
|
|
|
MachineBasicBlock::iterator MI) const;
|
2012-06-14 09:16:45 +08:00
|
|
|
|
2012-08-01 05:49:49 +08: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-08-01 07:41:32 +08:00
|
|
|
virtual const MipsRegisterInfo &getRegisterInfo() const = 0;
|
2012-08-01 05:49:49 +08:00
|
|
|
|
|
|
|
virtual unsigned GetOppositeBranchOpc(unsigned Opc) const = 0;
|
|
|
|
|
2012-06-14 09:16:45 +08:00
|
|
|
/// Return the number of bytes of code the specified instruction may be.
|
|
|
|
unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
|
2012-08-01 05:49:49 +08: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 15:42:06 +08:00
|
|
|
};
|
|
|
|
|
2012-08-03 02:21:47 +08:00
|
|
|
/// Create MipsInstrInfo objects.
|
|
|
|
const MipsInstrInfo *createMips16InstrInfo(MipsTargetMachine &TM);
|
|
|
|
const MipsInstrInfo *createMipsSEInstrInfo(MipsTargetMachine &TM);
|
|
|
|
|
2007-06-06 15:42:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|