2015-04-27 22:16:43 +08:00
|
|
|
|
2012-02-18 20:03:15 +08:00
|
|
|
//===- HexagonInstrInfo.h - Hexagon Instruction Information -----*- C++ -*-===//
|
2011-12-13 05:14:40 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the Hexagon implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "HexagonRegisterInfo.h"
|
2012-02-09 02:25:47 +08:00
|
|
|
#include "MCTargetDesc/HexagonBaseInfo.h"
|
2013-05-02 23:39:30 +08:00
|
|
|
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
|
2014-01-07 19:48:04 +08:00
|
|
|
#include "llvm/Target/TargetFrameLowering.h"
|
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "HexagonGenInstrInfo.inc"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-03-15 17:11:41 +08:00
|
|
|
struct EVT;
|
2015-03-12 14:07:16 +08:00
|
|
|
class HexagonSubtarget;
|
2011-12-13 05:14:40 +08:00
|
|
|
class HexagonInstrInfo : public HexagonGenInstrInfo {
|
2013-11-19 08:57:56 +08:00
|
|
|
virtual void anchor();
|
2011-12-13 05:14:40 +08:00
|
|
|
const HexagonRegisterInfo RI;
|
2013-06-07 14:19:56 +08:00
|
|
|
const HexagonSubtarget &Subtarget;
|
2013-05-02 05:37:34 +08:00
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
public:
|
2015-05-09 00:16:29 +08:00
|
|
|
typedef unsigned Opcode_t;
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
explicit HexagonInstrInfo(HexagonSubtarget &ST);
|
|
|
|
|
|
|
|
/// 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).
|
|
|
|
///
|
2014-04-29 15:58:16 +08:00
|
|
|
const HexagonRegisterInfo &getRegisterInfo() const { return RI; }
|
2011-12-13 05:14:40 +08: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.
|
2014-04-29 15:58:16 +08:00
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const override;
|
2011-12-13 05:14:40 +08: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.
|
2014-04-29 15:58:16 +08:00
|
|
|
unsigned isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const override;
|
|
|
|
|
|
|
|
|
|
|
|
bool AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const override;
|
|
|
|
|
|
|
|
unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
|
|
|
|
|
|
|
|
unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
|
|
|
MachineBasicBlock *FBB,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
DebugLoc DL) const override;
|
|
|
|
|
|
|
|
bool analyzeCompare(const MachineInstr *MI,
|
|
|
|
unsigned &SrcReg, unsigned &SrcReg2,
|
|
|
|
int &Mask, int &Value) const override;
|
|
|
|
|
|
|
|
void copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
bool KillSrc) const override;
|
|
|
|
|
|
|
|
void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override;
|
|
|
|
|
|
|
|
void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
|
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const;
|
|
|
|
|
|
|
|
void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override;
|
|
|
|
|
|
|
|
void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
|
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const;
|
|
|
|
|
2015-03-10 06:05:21 +08:00
|
|
|
/// expandPostRAPseudo - This function is called for all pseudo instructions
|
|
|
|
/// that remain after register allocation. Many pseudo instructions are
|
|
|
|
/// created to help register allocation. This is the place to convert them
|
|
|
|
/// into real instructions. The target can edit MI in place, or it can insert
|
|
|
|
/// new instructions and erase MI. The function should return true if
|
|
|
|
/// anything was changed.
|
|
|
|
bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override;
|
|
|
|
|
2015-02-28 20:04:00 +08:00
|
|
|
MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI,
|
|
|
|
ArrayRef<unsigned> Ops,
|
2014-04-29 15:58:16 +08:00
|
|
|
int FrameIndex) const override;
|
|
|
|
|
2015-02-28 20:04:00 +08:00
|
|
|
MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI,
|
|
|
|
ArrayRef<unsigned> Ops,
|
|
|
|
MachineInstr *LoadMI) const override {
|
2014-04-28 12:05:08 +08:00
|
|
|
return nullptr;
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned createVR(MachineFunction* MF, MVT VT) const;
|
|
|
|
|
2014-04-29 15:58:16 +08:00
|
|
|
bool isBranch(const MachineInstr *MI) const;
|
|
|
|
bool isPredicable(MachineInstr *MI) const override;
|
|
|
|
bool PredicateInstruction(MachineInstr *MI,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond) const override;
|
|
|
|
|
|
|
|
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
|
|
|
|
unsigned ExtraPredCycles,
|
|
|
|
const BranchProbability &Probability) const override;
|
|
|
|
|
|
|
|
bool isProfitableToIfCvt(MachineBasicBlock &TMBB,
|
|
|
|
unsigned NumTCycles, unsigned ExtraTCycles,
|
|
|
|
MachineBasicBlock &FMBB,
|
|
|
|
unsigned NumFCycles, unsigned ExtraFCycles,
|
|
|
|
const BranchProbability &Probability) const override;
|
|
|
|
|
|
|
|
bool isPredicated(const MachineInstr *MI) const override;
|
|
|
|
bool isPredicated(unsigned Opcode) const;
|
|
|
|
bool isPredicatedTrue(const MachineInstr *MI) const;
|
|
|
|
bool isPredicatedTrue(unsigned Opcode) const;
|
|
|
|
bool isPredicatedNew(const MachineInstr *MI) const;
|
|
|
|
bool isPredicatedNew(unsigned Opcode) const;
|
|
|
|
bool DefinesPredicate(MachineInstr *MI,
|
|
|
|
std::vector<MachineOperand> &Pred) const override;
|
|
|
|
bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Pred2) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
|
|
|
|
|
|
|
|
bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
|
|
|
|
const BranchProbability &Probability) const override;
|
|
|
|
|
2014-10-09 09:59:35 +08:00
|
|
|
DFAPacketizer *
|
|
|
|
CreateTargetScheduleState(const TargetSubtargetInfo &STI) const override;
|
2012-02-02 06:13:57 +08:00
|
|
|
|
2014-04-29 15:58:16 +08:00
|
|
|
bool isSchedulingBoundary(const MachineInstr *MI,
|
|
|
|
const MachineBasicBlock *MBB,
|
|
|
|
const MachineFunction &MF) const override;
|
2015-04-23 01:51:26 +08:00
|
|
|
bool isValidOffset(unsigned Opcode, int Offset, bool Extend = true) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
bool isValidAutoIncImm(const EVT VT, const int Offset) const;
|
|
|
|
bool isMemOp(const MachineInstr *MI) const;
|
|
|
|
bool isSpillPredRegOp(const MachineInstr *MI) const;
|
|
|
|
bool isU6_3Immediate(const int value) const;
|
|
|
|
bool isU6_2Immediate(const int value) const;
|
|
|
|
bool isU6_1Immediate(const int value) const;
|
|
|
|
bool isU6_0Immediate(const int value) const;
|
|
|
|
bool isS4_3Immediate(const int value) const;
|
|
|
|
bool isS4_2Immediate(const int value) const;
|
|
|
|
bool isS4_1Immediate(const int value) const;
|
|
|
|
bool isS4_0Immediate(const int value) const;
|
|
|
|
bool isS12_Immediate(const int value) const;
|
|
|
|
bool isU6_Immediate(const int value) const;
|
|
|
|
bool isS8_Immediate(const int value) const;
|
|
|
|
bool isS6_Immediate(const int value) const;
|
|
|
|
|
2012-05-04 05:52:53 +08:00
|
|
|
bool isSaveCalleeSavedRegsCall(const MachineInstr* MI) const;
|
|
|
|
bool isConditionalTransfer(const MachineInstr* MI) const;
|
2012-04-24 02:25:57 +08:00
|
|
|
bool isConditionalALU32 (const MachineInstr* MI) const;
|
|
|
|
bool isConditionalLoad (const MachineInstr* MI) const;
|
2012-05-04 05:52:53 +08:00
|
|
|
bool isConditionalStore(const MachineInstr* MI) const;
|
2013-03-06 02:51:42 +08:00
|
|
|
bool isNewValueInst(const MachineInstr* MI) const;
|
2013-05-07 02:49:23 +08:00
|
|
|
bool isNewValue(const MachineInstr* MI) const;
|
2015-05-09 00:16:29 +08:00
|
|
|
bool isNewValue(Opcode_t Opcode) const;
|
2013-03-29 03:44:04 +08:00
|
|
|
bool isDotNewInst(const MachineInstr* MI) const;
|
2013-05-11 04:58:11 +08:00
|
|
|
int GetDotOldOp(const int opc) const;
|
2013-05-11 04:27:34 +08:00
|
|
|
int GetDotNewOp(const MachineInstr* MI) const;
|
2013-05-10 03:16:07 +08:00
|
|
|
int GetDotNewPredOp(MachineInstr *MI,
|
|
|
|
const MachineBranchProbabilityInfo
|
|
|
|
*MBPI) const;
|
2013-05-11 04:58:11 +08:00
|
|
|
bool mayBeNewStore(const MachineInstr* MI) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
bool isDeallocRet(const MachineInstr *MI) const;
|
2012-04-24 02:25:57 +08:00
|
|
|
unsigned getInvertedPredicatedOpcode(const int Opc) const;
|
2012-05-04 05:52:53 +08:00
|
|
|
bool isExtendable(const MachineInstr* MI) const;
|
|
|
|
bool isExtended(const MachineInstr* MI) const;
|
|
|
|
bool isPostIncrement(const MachineInstr* MI) const;
|
|
|
|
bool isNewValueStore(const MachineInstr* MI) const;
|
2013-05-11 04:27:34 +08:00
|
|
|
bool isNewValueStore(unsigned Opcode) const;
|
2012-05-04 05:52:53 +08:00
|
|
|
bool isNewValueJump(const MachineInstr* MI) const;
|
2015-05-09 00:16:29 +08:00
|
|
|
bool isNewValueJump(Opcode_t Opcode) const;
|
2012-05-12 13:10:30 +08:00
|
|
|
bool isNewValueJumpCandidate(const MachineInstr *MI) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2013-03-02 01:37:13 +08:00
|
|
|
|
|
|
|
void immediateExtend(MachineInstr *MI) const;
|
2015-04-27 22:16:43 +08:00
|
|
|
bool isConstExtended(const MachineInstr *MI) const;
|
|
|
|
unsigned getSize(const MachineInstr *MI) const;
|
2013-05-02 23:39:30 +08:00
|
|
|
int getDotNewPredJumpOp(MachineInstr *MI,
|
|
|
|
const MachineBranchProbabilityInfo *MBPI) const;
|
2013-03-02 01:37:13 +08:00
|
|
|
unsigned getAddrMode(const MachineInstr* MI) const;
|
|
|
|
bool isOperandExtended(const MachineInstr *MI,
|
|
|
|
unsigned short OperandNum) const;
|
|
|
|
unsigned short getCExtOpNum(const MachineInstr *MI) const;
|
|
|
|
int getMinValue(const MachineInstr *MI) const;
|
|
|
|
int getMaxValue(const MachineInstr *MI) const;
|
|
|
|
bool NonExtEquivalentExists (const MachineInstr *MI) const;
|
|
|
|
short getNonExtOpcode(const MachineInstr *MI) const;
|
2013-05-02 05:37:34 +08:00
|
|
|
bool PredOpcodeHasJMP_c(Opcode_t Opcode) const;
|
2015-05-09 00:16:29 +08:00
|
|
|
bool predOpcodeHasNot(const SmallVectorImpl<MachineOperand> &Cond) const;
|
|
|
|
bool isEndLoopN(Opcode_t Opcode) const;
|
|
|
|
bool getPredReg(const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
unsigned &PredReg, unsigned &PredRegPos,
|
|
|
|
unsigned &PredRegFlags) const;
|
2015-03-31 21:35:12 +08:00
|
|
|
int getCondOpcode(int Opc, bool sense) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|