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 {
|
2007-06-06 07:42:06 +00:00
|
|
|
MipsTargetMachine &TM;
|
2011-10-11 00:37:28 +00:00
|
|
|
bool IsN64;
|
2007-06-06 07:42:06 +00:00
|
|
|
const MipsRegisterInfo RI;
|
2011-12-12 22:39:35 +00:00
|
|
|
unsigned UncondBrOpc;
|
2007-06-06 07:42:06 +00:00
|
|
|
public:
|
2008-03-25 22:06:05 +00:00
|
|
|
explicit MipsInstrInfo(MipsTargetMachine &TM);
|
2007-06-06 07:42:06 +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).
|
|
|
|
///
|
2011-07-07 23:56:50 +00:00
|
|
|
virtual const MipsRegisterInfo &getRegisterInfo() const;
|
2007-06-06 07:42:06 +00:00
|
|
|
|
|
|
|
/// isLoadFromStackSlot - If the specified machine instruction is a direct
|
|
|
|
/// load from a stack slot, return the virtual or physical register number of
|
|
|
|
/// the destination along with the FrameIndex of the loaded stack slot. If
|
|
|
|
/// not, return 0. This predicate must return 0 if the instruction has
|
|
|
|
/// any side effects other than loading from the stack slot.
|
2008-11-18 19:49:32 +00:00
|
|
|
virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
2011-03-04 17:51:39 +00:00
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
/// isStoreToStackSlot - If the specified machine instruction is a direct
|
|
|
|
/// store to a stack slot, return the virtual or physical register number of
|
|
|
|
/// the source reg along with the FrameIndex of the loaded stack slot. If
|
|
|
|
/// not, return 0. This predicate must return 0 if the instruction has
|
|
|
|
/// any side effects other than storing to the stack slot.
|
2008-11-18 19:49:32 +00:00
|
|
|
virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
2011-03-04 17:51:39 +00:00
|
|
|
|
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;
|
2007-08-18 01:59:45 +00:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
2011-04-01 17:39:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void BuildCondBr(MachineBasicBlock &MBB, MachineBasicBlock *TBB, DebugLoc DL,
|
|
|
|
const SmallVectorImpl<MachineOperand>& Cond) const;
|
2012-05-25 20:52:52 +00:00
|
|
|
void ExpandExtractElementF64(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I) const;
|
|
|
|
void ExpandBuildPairF64(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I) const;
|
2011-04-01 17:39:08 +00:00
|
|
|
|
|
|
|
public:
|
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;
|
2010-07-11 01:08:31 +00:00
|
|
|
virtual void copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
bool KillSrc) const;
|
2008-01-01 21:11:32 +00:00
|
|
|
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
2011-04-15 21:51:11 +00:00
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
2010-05-06 19:06:44 +00:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const;
|
2008-01-01 21:11:32 +00:00
|
|
|
|
|
|
|
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
2010-05-06 19:06:44 +00:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const;
|
2008-01-01 21:11:32 +00:00
|
|
|
|
2012-05-25 20:52:52 +00:00
|
|
|
virtual bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const;
|
|
|
|
|
2011-07-01 01:04:43 +00:00
|
|
|
virtual MachineInstr* emitFrameIndexDebugValue(MachineFunction &MF,
|
|
|
|
int FrameIx, uint64_t Offset,
|
|
|
|
const MDNode *MDPtr,
|
|
|
|
DebugLoc DL) const;
|
|
|
|
|
2008-08-14 22:49:33 +00:00
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) 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
|
|
|
|
|
|
|
/// Return the number of bytes of code the specified instruction may be.
|
|
|
|
unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
|
2007-06-06 07:42:06 +00:00
|
|
|
};
|
|
|
|
|
2012-06-14 01:16:45 +00:00
|
|
|
namespace Mips {
|
|
|
|
/// GetOppositeBranchOpc - Return the inverse of the specified
|
|
|
|
/// opcode, e.g. turning BEQ to BNE.
|
|
|
|
unsigned GetOppositeBranchOpc(unsigned Opc);
|
|
|
|
|
|
|
|
/// Emit a series of instructions to load an immediate. All instructions
|
|
|
|
/// except for the last one are emitted. The function returns the number of
|
|
|
|
/// MachineInstrs generated. The opcode-immediate pair of the last
|
|
|
|
/// instruction is returned in LastInst, if it is not 0.
|
|
|
|
unsigned
|
|
|
|
loadImmediate(int64_t Imm, bool IsN64, const TargetInstrInfo &TII,
|
|
|
|
MachineBasicBlock& MBB, MachineBasicBlock::iterator II,
|
|
|
|
DebugLoc DL, bool LastInstrIsADDiu,
|
|
|
|
MipsAnalyzeImmediate::Inst *LastInst);
|
|
|
|
}
|
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|