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"
|
2013-05-13 17:57:42 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.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 {
|
2013-11-19 00:57:56 +00:00
|
|
|
virtual void anchor();
|
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:
|
2013-03-01 01:10:17 +00: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-07-31 21:49:49 +00:00
|
|
|
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
|
|
|
|
2013-03-01 01:10:17 +00:00
|
|
|
BranchType AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify,
|
|
|
|
SmallVectorImpl<MachineInstr*> &BranchInstrs) 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
|
|
|
|
2013-05-13 17:43:19 +00:00
|
|
|
virtual unsigned getOppositeBranchOpc(unsigned Opc) const = 0;
|
2012-07-31 21:49:49 +00:00
|
|
|
|
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
|
|
|
|
2013-03-29 02:14:12 +00:00
|
|
|
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
|
|
|
storeRegToStack(MBB, MBBI, SrcReg, isKill, FrameIndex, RC, TRI, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
|
|
|
loadRegFromStack(MBB, MBBI, DestReg, FrameIndex, RC, TRI, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void storeRegToStack(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI,
|
|
|
|
int64_t Offset) const = 0;
|
|
|
|
|
|
|
|
virtual void loadRegFromStack(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI,
|
|
|
|
int64_t Offset) const = 0;
|
|
|
|
|
2013-05-13 17:57:42 +00:00
|
|
|
/// Create an instruction which has the same operands and memory operands
|
|
|
|
/// as MI but has a new opcode.
|
|
|
|
MachineInstrBuilder genInstrWithNewOpc(unsigned NewOpc,
|
|
|
|
MachineBasicBlock::iterator I) 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:
|
2013-05-13 17:43:19 +00:00
|
|
|
virtual unsigned getAnalyzableBrOpc(unsigned Opc) const = 0;
|
2012-07-31 21:49:49 +00:00
|
|
|
|
|
|
|
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
|