2012-02-28 08:46:26 +01:00
|
|
|
//===-- MipsInstrInfo.h - Mips Instruction Information ----------*- C++ -*-===//
|
2007-06-06 09:42:06 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-06-06 09:42:06 +02:00
|
|
|
//
|
2011-04-15 23:51:11 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 09:42:06 +02:00
|
|
|
//
|
|
|
|
// This file contains the Mips implementation of the TargetInstrInfo class.
|
|
|
|
//
|
2014-04-30 17:06:25 +02:00
|
|
|
// FIXME: We need to override TargetInstrInfo::getInlineAsmLength method in
|
|
|
|
// order for MipsLongBranch pass to work correctly when the code has inline
|
|
|
|
// assembly. The returned value doesn't have to be the asm instruction's exact
|
|
|
|
// size in bytes; MipsLongBranch only expects it to be the correct upper bound.
|
2011-04-15 23:51:11 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 09:42:06 +02:00
|
|
|
|
2014-08-13 18:26:38 +02:00
|
|
|
#ifndef LLVM_LIB_TARGET_MIPS_MIPSINSTRINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_MIPS_MIPSINSTRINFO_H
|
2007-06-06 09:42:06 +02:00
|
|
|
|
|
|
|
#include "Mips.h"
|
2012-06-14 03:16:45 +02:00
|
|
|
#include "MipsAnalyzeImmediate.h"
|
2012-03-17 19:46:09 +01:00
|
|
|
#include "MipsRegisterInfo.h"
|
2013-05-13 19:57:42 +02:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2009-07-11 22:10:48 +02:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2007-06-06 09:42:06 +02:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
|
|
|
|
2011-07-01 19:57:27 +02:00
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "MipsGenInstrInfo.inc"
|
|
|
|
|
2007-06-06 09:42:06 +02:00
|
|
|
namespace llvm {
|
2015-03-12 06:43:57 +01:00
|
|
|
class MipsSubtarget;
|
2011-07-01 19:57:27 +02:00
|
|
|
class MipsInstrInfo : public MipsGenInstrInfo {
|
2013-11-19 01:57:56 +01:00
|
|
|
virtual void anchor();
|
2012-07-31 23:49:49 +02:00
|
|
|
protected:
|
2014-07-19 01:25:00 +02:00
|
|
|
const MipsSubtarget &Subtarget;
|
2011-12-12 23:39:35 +01:00
|
|
|
unsigned UncondBrOpc;
|
2007-06-06 09:42:06 +02:00
|
|
|
|
2012-07-31 23:49:49 +02:00
|
|
|
public:
|
2013-03-01 02:10:17 +01: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.
|
|
|
|
};
|
|
|
|
|
2014-07-19 01:25:00 +02:00
|
|
|
explicit MipsInstrInfo(const MipsSubtarget &STI, unsigned UncondBrOpc);
|
2011-03-04 18:51:39 +01:00
|
|
|
|
2014-07-19 01:25:00 +02:00
|
|
|
static const MipsInstrInfo *create(MipsSubtarget &STI);
|
2012-08-02 20:21:47 +02:00
|
|
|
|
2007-08-18 03:59:45 +02:00
|
|
|
/// Branch Analysis
|
2014-04-29 09:58:02 +02:00
|
|
|
bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const override;
|
2011-04-01 19:39:08 +02:00
|
|
|
|
2014-04-29 09:58:02 +02:00
|
|
|
unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
|
2011-04-01 19:39:08 +02:00
|
|
|
|
2014-04-29 09:58:02 +02:00
|
|
|
unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2015-06-11 21:30:37 +02:00
|
|
|
MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
|
2014-04-29 09:58:02 +02:00
|
|
|
DebugLoc DL) const override;
|
2012-07-31 23:49:49 +02:00
|
|
|
|
2014-04-29 09:58:02 +02:00
|
|
|
bool
|
|
|
|
ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
|
2012-05-25 22:52:52 +02:00
|
|
|
|
2013-03-01 02:10:17 +01:00
|
|
|
BranchType AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify,
|
|
|
|
SmallVectorImpl<MachineInstr*> &BranchInstrs) const;
|
|
|
|
|
2007-08-18 03:59:45 +02:00
|
|
|
/// Insert nop instruction when hazard condition is found
|
2014-04-29 09:58:02 +02:00
|
|
|
void insertNoop(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI) const override;
|
2012-06-14 03:16:45 +02:00
|
|
|
|
2012-07-31 23:49:49 +02: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 01:41:32 +02:00
|
|
|
virtual const MipsRegisterInfo &getRegisterInfo() const = 0;
|
2012-07-31 23:49:49 +02:00
|
|
|
|
2013-05-13 19:43:19 +02:00
|
|
|
virtual unsigned getOppositeBranchOpc(unsigned Opc) const = 0;
|
2012-07-31 23:49:49 +02:00
|
|
|
|
2012-06-14 03:16:45 +02:00
|
|
|
/// Return the number of bytes of code the specified instruction may be.
|
|
|
|
unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
|
2012-07-31 23:49:49 +02:00
|
|
|
|
2014-04-29 09:58:02 +02:00
|
|
|
void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override {
|
2013-03-29 03:14:12 +01:00
|
|
|
storeRegToStack(MBB, MBBI, SrcReg, isKill, FrameIndex, RC, TRI, 0);
|
|
|
|
}
|
|
|
|
|
2014-04-29 09:58:02 +02:00
|
|
|
void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override {
|
2013-03-29 03:14:12 +01:00
|
|
|
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;
|
2015-04-02 12:42:44 +02:00
|
|
|
|
|
|
|
virtual void adjustStackPtr(unsigned SP, int64_t Amount,
|
|
|
|
MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I) const = 0;
|
2013-03-29 03:14:12 +01:00
|
|
|
|
2013-05-13 19:57:42 +02: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 23:49:49 +02:00
|
|
|
protected:
|
|
|
|
bool isZeroImm(const MachineOperand &op) const;
|
|
|
|
|
|
|
|
MachineMemOperand *GetMemOperand(MachineBasicBlock &MBB, int FI,
|
|
|
|
unsigned Flag) const;
|
|
|
|
|
|
|
|
private:
|
2013-05-13 19:43:19 +02:00
|
|
|
virtual unsigned getAnalyzableBrOpc(unsigned Opc) const = 0;
|
2012-07-31 23:49:49 +02:00
|
|
|
|
|
|
|
void AnalyzeCondBr(const MachineInstr *Inst, unsigned Opc,
|
|
|
|
MachineBasicBlock *&BB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond) const;
|
|
|
|
|
|
|
|
void BuildCondBr(MachineBasicBlock &MBB, MachineBasicBlock *TBB, DebugLoc DL,
|
2015-06-11 21:30:37 +02:00
|
|
|
ArrayRef<MachineOperand> Cond) const;
|
2007-06-06 09:42:06 +02:00
|
|
|
};
|
|
|
|
|
2012-08-02 20:21:47 +02:00
|
|
|
/// Create MipsInstrInfo objects.
|
2014-07-19 01:25:00 +02:00
|
|
|
const MipsInstrInfo *createMips16InstrInfo(const MipsSubtarget &STI);
|
|
|
|
const MipsInstrInfo *createMipsSEInstrInfo(const MipsSubtarget &STI);
|
2012-08-02 20:21:47 +02:00
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
}
|
2007-06-06 09:42:06 +02:00
|
|
|
|
|
|
|
#endif
|