131d157ae1ac2cd9c787dc3c1d28e64c682803844Jia Liu//===- HexagonInstrInfo.h - Hexagon Instruction Information -----*- C++ -*-===// 2b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// 3b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// The LLVM Compiler Infrastructure 4b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// 5b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// This file is distributed under the University of Illinois Open Source 6b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// License. See LICENSE.TXT for details. 7b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// 8b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//===----------------------------------------------------------------------===// 9b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// 10b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// This file contains the Hexagon implementation of the TargetInstrInfo class. 11b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// 12b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//===----------------------------------------------------------------------===// 13b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 14b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#ifndef HexagonINSTRUCTIONINFO_H 15b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#define HexagonINSTRUCTIONINFO_H 16b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 1779aa3417eb6f58d668aadfedf075240a41d35a26Craig Topper#include "HexagonRegisterInfo.h" 18c635ebdb1a366060fe71ef3028ae888fa5e4130dBrendon Cahoon#include "MCTargetDesc/HexagonBaseInfo.h" 19b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/Target/TargetInstrInfo.h" 20b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/Target/TargetFrameLowering.h" 21b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 22b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 23b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#define GET_INSTRINFO_HEADER 24b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "HexagonGenInstrInfo.inc" 25b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 26b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumnamespace llvm { 27b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 28b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumclass HexagonInstrInfo : public HexagonGenInstrInfo { 29b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const HexagonRegisterInfo RI; 30b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const HexagonSubtarget& Subtarget; 31b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumpublic: 32b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum explicit HexagonInstrInfo(HexagonSubtarget &ST); 33b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 34b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As 35b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// such, whenever a client has an instance of instruction info, it should 36b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// always be able to get register info as well (through this method). 37b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// 38b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual const HexagonRegisterInfo &getRegisterInfo() const { return RI; } 39b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 40b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// isLoadFromStackSlot - If the specified machine instruction is a direct 41b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// load from a stack slot, return the virtual or physical register number of 42b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// the destination along with the FrameIndex of the loaded stack slot. If 43b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// not, return 0. This predicate must return 0 if the instruction has 44b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// any side effects other than loading from the stack slot. 45b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual unsigned isLoadFromStackSlot(const MachineInstr *MI, 46b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum int &FrameIndex) const; 47b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 48b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// isStoreToStackSlot - If the specified machine instruction is a direct 49b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// store to a stack slot, return the virtual or physical register number of 50b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// the source reg along with the FrameIndex of the loaded stack slot. If 51b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// not, return 0. This predicate must return 0 if the instruction has 52b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum /// any side effects other than storing to the stack slot. 53b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual unsigned isStoreToStackSlot(const MachineInstr *MI, 54b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum int &FrameIndex) const; 55b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 56b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 57b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB, 58b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineBasicBlock *&FBB, 59b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum SmallVectorImpl<MachineOperand> &Cond, 60b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool AllowModify) const; 61b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 62b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; 63b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 64b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, 65b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineBasicBlock *FBB, 66b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const SmallVectorImpl<MachineOperand> &Cond, 67b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum DebugLoc DL) const; 68b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 69b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual void copyPhysReg(MachineBasicBlock &MBB, 70b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineBasicBlock::iterator I, DebugLoc DL, 71b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum unsigned DestReg, unsigned SrcReg, 72b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool KillSrc) const; 73b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 74b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual void storeRegToStackSlot(MachineBasicBlock &MBB, 75b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineBasicBlock::iterator MBBI, 76b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum unsigned SrcReg, bool isKill, int FrameIndex, 77b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const TargetRegisterClass *RC, 78b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const TargetRegisterInfo *TRI) const; 79b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 80b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill, 81b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum SmallVectorImpl<MachineOperand> &Addr, 82b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const TargetRegisterClass *RC, 83b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum SmallVectorImpl<MachineInstr*> &NewMIs) const; 84b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 85b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, 86b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineBasicBlock::iterator MBBI, 87b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum unsigned DestReg, int FrameIndex, 88b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const TargetRegisterClass *RC, 89b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const TargetRegisterInfo *TRI) const; 90b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 91b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg, 92b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum SmallVectorImpl<MachineOperand> &Addr, 93b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const TargetRegisterClass *RC, 94b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum SmallVectorImpl<MachineInstr*> &NewMIs) const; 95b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 96b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, 97b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineInstr* MI, 98b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const SmallVectorImpl<unsigned> &Ops, 99b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum int FrameIndex) const; 100b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 101b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, 102b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineInstr* MI, 103b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const SmallVectorImpl<unsigned> &Ops, 104b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineInstr* LoadMI) const { 105b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum return 0; 106b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum } 107b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 108b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum unsigned createVR(MachineFunction* MF, MVT VT) const; 109b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 110b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool isPredicable(MachineInstr *MI) const; 111b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool 112b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum PredicateInstruction(MachineInstr *MI, 113b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const SmallVectorImpl<MachineOperand> &Cond) const; 114b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 115b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCyles, 116b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum unsigned ExtraPredCycles, 117b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const BranchProbability &Probability) const; 118b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 119b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool isProfitableToIfCvt(MachineBasicBlock &TMBB, 120b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum unsigned NumTCycles, unsigned ExtraTCycles, 121b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum MachineBasicBlock &FMBB, 122b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum unsigned NumFCycles, unsigned ExtraFCycles, 123b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const BranchProbability &Probability) const; 124b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 125b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool isPredicated(const MachineInstr *MI) const; 126b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool DefinesPredicate(MachineInstr *MI, 127b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum std::vector<MachineOperand> &Pred) const; 128b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool 129b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1, 130b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const SmallVectorImpl<MachineOperand> &Pred2) const; 131b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 132b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool 133b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; 134b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 135b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum virtual bool 136b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum isProfitableToDupForIfCvt(MachineBasicBlock &MBB,unsigned NumCycles, 137b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum const BranchProbability &Probability) const; 138b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 139ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick virtual DFAPacketizer* 140ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick CreateTargetScheduleState(const TargetMachine *TM, 141ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick const ScheduleDAG *DAG) const; 142ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick 143ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick virtual bool isSchedulingBoundary(const MachineInstr *MI, 144ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick const MachineBasicBlock *MBB, 145ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick const MachineFunction &MF) const; 146b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isValidOffset(const int Opcode, const int Offset) const; 147b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isValidAutoIncImm(const EVT VT, const int Offset) const; 148b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isMemOp(const MachineInstr *MI) const; 149b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isSpillPredRegOp(const MachineInstr *MI) const; 150b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isU6_3Immediate(const int value) const; 151b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isU6_2Immediate(const int value) const; 152b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isU6_1Immediate(const int value) const; 153b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isU6_0Immediate(const int value) const; 154b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isS4_3Immediate(const int value) const; 155b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isS4_2Immediate(const int value) const; 156b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isS4_1Immediate(const int value) const; 157b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isS4_0Immediate(const int value) const; 158b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isS12_Immediate(const int value) const; 159b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isU6_Immediate(const int value) const; 160b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isS8_Immediate(const int value) const; 161b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isS6_Immediate(const int value) const; 162b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 163b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isConditionalALU32 (const MachineInstr* MI) const; 164b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isConditionalLoad (const MachineInstr* MI) const; 165b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum bool isDeallocRet(const MachineInstr *MI) const; 166ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande unsigned getInvertedPredicatedOpcode(const int Opc) const; 167b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 168b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumprivate: 169b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum int getMatchingCondBranchOpcode(int Opc, bool sense) const; 170b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 171b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}; 172b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 173b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum} 174b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum 175b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#endif 176