2015-04-27 14:16:43 +00:00
|
|
|
|
2012-02-18 12:03:15 +00:00
|
|
|
//===- HexagonInstrInfo.h - Hexagon Instruction Information -----*- C++ -*-===//
|
2011-12-12 21:14:40 +00: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-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
|
2011-12-12 21:14:40 +00:00
|
|
|
|
2012-03-17 18:46:09 +00:00
|
|
|
#include "HexagonRegisterInfo.h"
|
2012-02-08 18:25:47 +00:00
|
|
|
#include "MCTargetDesc/HexagonBaseInfo.h"
|
2013-05-02 15:39:30 +00:00
|
|
|
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
|
2014-01-07 11:48:04 +00:00
|
|
|
#include "llvm/Target/TargetFrameLowering.h"
|
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2011-12-12 21:14:40 +00:00
|
|
|
|
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "HexagonGenInstrInfo.inc"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-03-15 09:11:41 +00:00
|
|
|
struct EVT;
|
2015-03-12 06:07:16 +00:00
|
|
|
class HexagonSubtarget;
|
2011-12-12 21:14:40 +00:00
|
|
|
class HexagonInstrInfo : public HexagonGenInstrInfo {
|
2013-11-19 00:57:56 +00:00
|
|
|
virtual void anchor();
|
2011-12-12 21:14:40 +00:00
|
|
|
const HexagonRegisterInfo RI;
|
2013-06-07 06:19:56 +00:00
|
|
|
const HexagonSubtarget &Subtarget;
|
2013-05-01 21:37:34 +00:00
|
|
|
|
2011-12-12 21:14:40 +00:00
|
|
|
public:
|
2015-05-08 16:16:29 +00:00
|
|
|
typedef unsigned Opcode_t;
|
|
|
|
|
2011-12-12 21:14:40 +00: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 07:58:16 +00:00
|
|
|
const HexagonRegisterInfo &getRegisterInfo() const { return RI; }
|
2011-12-12 21:14:40 +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.
|
2014-04-29 07:58:16 +00:00
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const override;
|
2011-12-12 21:14:40 +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.
|
2014-04-29 07:58:16 +00: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,
|
2015-06-11 19:30:37 +00:00
|
|
|
MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
|
2014-04-29 07:58:16 +00:00
|
|
|
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-09 22:05:21 +00: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 12:04:00 +00:00
|
|
|
MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI,
|
|
|
|
ArrayRef<unsigned> Ops,
|
2015-06-08 20:09:58 +00:00
|
|
|
MachineBasicBlock::iterator InsertPt,
|
2014-04-29 07:58:16 +00:00
|
|
|
int FrameIndex) const override;
|
|
|
|
|
2015-02-28 12:04:00 +00:00
|
|
|
MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI,
|
|
|
|
ArrayRef<unsigned> Ops,
|
2015-06-08 20:09:58 +00:00
|
|
|
MachineBasicBlock::iterator InsertPt,
|
2015-02-28 12:04:00 +00:00
|
|
|
MachineInstr *LoadMI) const override {
|
2014-04-28 04:05:08 +00:00
|
|
|
return nullptr;
|
2011-12-12 21:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned createVR(MachineFunction* MF, MVT VT) const;
|
|
|
|
|
2014-04-29 07:58:16 +00:00
|
|
|
bool isBranch(const MachineInstr *MI) const;
|
|
|
|
bool isPredicable(MachineInstr *MI) const override;
|
|
|
|
bool PredicateInstruction(MachineInstr *MI,
|
2015-06-11 19:30:37 +00:00
|
|
|
ArrayRef<MachineOperand> Cond) const override;
|
2014-04-29 07:58:16 +00:00
|
|
|
|
|
|
|
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;
|
2015-06-11 19:30:37 +00:00
|
|
|
bool SubsumesPredicate(ArrayRef<MachineOperand> Pred1,
|
|
|
|
ArrayRef<MachineOperand> Pred2) const override;
|
2014-04-29 07:58:16 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
|
|
|
|
|
|
|
|
bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
|
|
|
|
const BranchProbability &Probability) const override;
|
|
|
|
|
2014-10-09 01:59:35 +00:00
|
|
|
DFAPacketizer *
|
|
|
|
CreateTargetScheduleState(const TargetSubtargetInfo &STI) const override;
|
2012-02-01 22:13:57 +00:00
|
|
|
|
2014-04-29 07:58:16 +00:00
|
|
|
bool isSchedulingBoundary(const MachineInstr *MI,
|
|
|
|
const MachineBasicBlock *MBB,
|
|
|
|
const MachineFunction &MF) const override;
|
2015-04-22 17:51:26 +00:00
|
|
|
bool isValidOffset(unsigned Opcode, int Offset, bool Extend = true) const;
|
2011-12-12 21:14:40 +00: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-03 21:52:53 +00:00
|
|
|
bool isSaveCalleeSavedRegsCall(const MachineInstr* MI) const;
|
|
|
|
bool isConditionalTransfer(const MachineInstr* MI) const;
|
2012-04-23 18:25:57 +00:00
|
|
|
bool isConditionalALU32 (const MachineInstr* MI) const;
|
|
|
|
bool isConditionalLoad (const MachineInstr* MI) const;
|
2012-05-03 21:52:53 +00:00
|
|
|
bool isConditionalStore(const MachineInstr* MI) const;
|
2013-03-05 18:51:42 +00:00
|
|
|
bool isNewValueInst(const MachineInstr* MI) const;
|
2013-05-06 18:49:23 +00:00
|
|
|
bool isNewValue(const MachineInstr* MI) const;
|
2015-05-08 16:16:29 +00:00
|
|
|
bool isNewValue(Opcode_t Opcode) const;
|
2013-03-28 19:44:04 +00:00
|
|
|
bool isDotNewInst(const MachineInstr* MI) const;
|
2013-05-10 20:58:11 +00:00
|
|
|
int GetDotOldOp(const int opc) const;
|
2013-05-10 20:27:34 +00:00
|
|
|
int GetDotNewOp(const MachineInstr* MI) const;
|
2013-05-09 19:16:07 +00:00
|
|
|
int GetDotNewPredOp(MachineInstr *MI,
|
|
|
|
const MachineBranchProbabilityInfo
|
|
|
|
*MBPI) const;
|
2013-05-10 20:58:11 +00:00
|
|
|
bool mayBeNewStore(const MachineInstr* MI) const;
|
2011-12-12 21:14:40 +00:00
|
|
|
bool isDeallocRet(const MachineInstr *MI) const;
|
2012-04-23 18:25:57 +00:00
|
|
|
unsigned getInvertedPredicatedOpcode(const int Opc) const;
|
2012-05-03 21:52:53 +00: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-10 20:27:34 +00:00
|
|
|
bool isNewValueStore(unsigned Opcode) const;
|
2012-05-03 21:52:53 +00:00
|
|
|
bool isNewValueJump(const MachineInstr* MI) const;
|
2015-05-08 16:16:29 +00:00
|
|
|
bool isNewValueJump(Opcode_t Opcode) const;
|
2012-05-12 05:10:30 +00:00
|
|
|
bool isNewValueJumpCandidate(const MachineInstr *MI) const;
|
2011-12-12 21:14:40 +00:00
|
|
|
|
2013-03-01 17:37:13 +00:00
|
|
|
|
|
|
|
void immediateExtend(MachineInstr *MI) const;
|
2015-04-27 14:16:43 +00:00
|
|
|
bool isConstExtended(const MachineInstr *MI) const;
|
|
|
|
unsigned getSize(const MachineInstr *MI) const;
|
2013-05-02 15:39:30 +00:00
|
|
|
int getDotNewPredJumpOp(MachineInstr *MI,
|
|
|
|
const MachineBranchProbabilityInfo *MBPI) const;
|
2013-03-01 17:37:13 +00: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-01 21:37:34 +00:00
|
|
|
bool PredOpcodeHasJMP_c(Opcode_t Opcode) const;
|
2015-06-11 19:30:37 +00:00
|
|
|
bool predOpcodeHasNot(ArrayRef<MachineOperand> Cond) const;
|
2015-05-08 16:16:29 +00:00
|
|
|
bool isEndLoopN(Opcode_t Opcode) const;
|
2015-06-11 19:30:37 +00:00
|
|
|
bool getPredReg(ArrayRef<MachineOperand> Cond, unsigned &PredReg,
|
|
|
|
unsigned &PredRegPos, unsigned &PredRegFlags) const;
|
2015-03-31 13:35:12 +00:00
|
|
|
int getCondOpcode(int Opc, bool sense) const;
|
2011-12-12 21:14:40 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-06-23 09:49:53 +00:00
|
|
|
}
|
2011-12-12 21:14:40 +00:00
|
|
|
|
|
|
|
#endif
|