Brendon Cahoon | 55bdeb7 | 2015-04-27 14:16:43 +0000 | [diff] [blame^] | 1 | |
Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 2 | //===- HexagonInstrInfo.h - Hexagon Instruction Information -----*- C++ -*-===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | // |
| 11 | // This file contains the Hexagon implementation of the TargetInstrInfo class. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H |
| 16 | #define LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 17 | |
Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 18 | #include "HexagonRegisterInfo.h" |
Brendon Cahoon | 6f35837 | 2012-02-08 18:25:47 +0000 | [diff] [blame] | 19 | #include "MCTargetDesc/HexagonBaseInfo.h" |
Jyotsna Verma | 1d29750 | 2013-05-02 15:39:30 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 21 | #include "llvm/Target/TargetFrameLowering.h" |
| 22 | #include "llvm/Target/TargetInstrInfo.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 23 | |
| 24 | #define GET_INSTRINFO_HEADER |
| 25 | #include "HexagonGenInstrInfo.inc" |
| 26 | |
| 27 | namespace llvm { |
| 28 | |
Patrik Hagglund | 8d09a6c | 2014-03-15 09:11:41 +0000 | [diff] [blame] | 29 | struct EVT; |
Eric Christopher | 234a1ec | 2015-03-12 06:07:16 +0000 | [diff] [blame] | 30 | class HexagonSubtarget; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 31 | class HexagonInstrInfo : public HexagonGenInstrInfo { |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 32 | virtual void anchor(); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 33 | const HexagonRegisterInfo RI; |
Bill Wendling | 4a7a408 | 2013-06-07 06:19:56 +0000 | [diff] [blame] | 34 | const HexagonSubtarget &Subtarget; |
Jyotsna Verma | 5ed5181 | 2013-05-01 21:37:34 +0000 | [diff] [blame] | 35 | typedef unsigned Opcode_t; |
| 36 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 37 | public: |
| 38 | explicit HexagonInstrInfo(HexagonSubtarget &ST); |
| 39 | |
| 40 | /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As |
| 41 | /// such, whenever a client has an instance of instruction info, it should |
| 42 | /// always be able to get register info as well (through this method). |
| 43 | /// |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 44 | const HexagonRegisterInfo &getRegisterInfo() const { return RI; } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 45 | |
| 46 | /// isLoadFromStackSlot - If the specified machine instruction is a direct |
| 47 | /// load from a stack slot, return the virtual or physical register number of |
| 48 | /// the destination along with the FrameIndex of the loaded stack slot. If |
| 49 | /// not, return 0. This predicate must return 0 if the instruction has |
| 50 | /// any side effects other than loading from the stack slot. |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 51 | unsigned isLoadFromStackSlot(const MachineInstr *MI, |
| 52 | int &FrameIndex) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 53 | |
| 54 | /// isStoreToStackSlot - If the specified machine instruction is a direct |
| 55 | /// store to a stack slot, return the virtual or physical register number of |
| 56 | /// the source reg along with the FrameIndex of the loaded stack slot. If |
| 57 | /// not, return 0. This predicate must return 0 if the instruction has |
| 58 | /// any side effects other than storing to the stack slot. |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 59 | unsigned isStoreToStackSlot(const MachineInstr *MI, |
| 60 | int &FrameIndex) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 61 | |
| 62 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 63 | bool AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB, |
| 64 | MachineBasicBlock *&FBB, |
| 65 | SmallVectorImpl<MachineOperand> &Cond, |
| 66 | bool AllowModify) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 67 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 68 | unsigned RemoveBranch(MachineBasicBlock &MBB) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 69 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 70 | unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
| 71 | MachineBasicBlock *FBB, |
| 72 | const SmallVectorImpl<MachineOperand> &Cond, |
| 73 | DebugLoc DL) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 74 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 75 | bool analyzeCompare(const MachineInstr *MI, |
| 76 | unsigned &SrcReg, unsigned &SrcReg2, |
| 77 | int &Mask, int &Value) const override; |
Krzysztof Parzyszek | cfe285e | 2013-02-11 20:04:29 +0000 | [diff] [blame] | 78 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 79 | void copyPhysReg(MachineBasicBlock &MBB, |
| 80 | MachineBasicBlock::iterator I, DebugLoc DL, |
| 81 | unsigned DestReg, unsigned SrcReg, |
| 82 | bool KillSrc) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 83 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 84 | void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 85 | MachineBasicBlock::iterator MBBI, |
| 86 | unsigned SrcReg, bool isKill, int FrameIndex, |
| 87 | const TargetRegisterClass *RC, |
| 88 | const TargetRegisterInfo *TRI) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 89 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 90 | void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill, |
| 91 | SmallVectorImpl<MachineOperand> &Addr, |
| 92 | const TargetRegisterClass *RC, |
| 93 | SmallVectorImpl<MachineInstr*> &NewMIs) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 94 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 95 | void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 96 | MachineBasicBlock::iterator MBBI, |
| 97 | unsigned DestReg, int FrameIndex, |
| 98 | const TargetRegisterClass *RC, |
| 99 | const TargetRegisterInfo *TRI) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 100 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 101 | void loadRegFromAddr(MachineFunction &MF, unsigned DestReg, |
| 102 | SmallVectorImpl<MachineOperand> &Addr, |
| 103 | const TargetRegisterClass *RC, |
| 104 | SmallVectorImpl<MachineInstr*> &NewMIs) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 105 | |
Colin LeMahieu | 7b1799c | 2015-03-09 22:05:21 +0000 | [diff] [blame] | 106 | /// expandPostRAPseudo - This function is called for all pseudo instructions |
| 107 | /// that remain after register allocation. Many pseudo instructions are |
| 108 | /// created to help register allocation. This is the place to convert them |
| 109 | /// into real instructions. The target can edit MI in place, or it can insert |
| 110 | /// new instructions and erase MI. The function should return true if |
| 111 | /// anything was changed. |
| 112 | bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override; |
| 113 | |
Benjamin Kramer | f1362f6 | 2015-02-28 12:04:00 +0000 | [diff] [blame] | 114 | MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI, |
| 115 | ArrayRef<unsigned> Ops, |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 116 | int FrameIndex) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 117 | |
Benjamin Kramer | f1362f6 | 2015-02-28 12:04:00 +0000 | [diff] [blame] | 118 | MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI, |
| 119 | ArrayRef<unsigned> Ops, |
| 120 | MachineInstr *LoadMI) const override { |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 121 | return nullptr; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | unsigned createVR(MachineFunction* MF, MVT VT) const; |
| 125 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 126 | bool isBranch(const MachineInstr *MI) const; |
| 127 | bool isPredicable(MachineInstr *MI) const override; |
| 128 | bool PredicateInstruction(MachineInstr *MI, |
| 129 | const SmallVectorImpl<MachineOperand> &Cond) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 130 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 131 | bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, |
| 132 | unsigned ExtraPredCycles, |
| 133 | const BranchProbability &Probability) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 134 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 135 | bool isProfitableToIfCvt(MachineBasicBlock &TMBB, |
| 136 | unsigned NumTCycles, unsigned ExtraTCycles, |
| 137 | MachineBasicBlock &FMBB, |
| 138 | unsigned NumFCycles, unsigned ExtraFCycles, |
| 139 | const BranchProbability &Probability) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 140 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 141 | bool isPredicated(const MachineInstr *MI) const override; |
| 142 | bool isPredicated(unsigned Opcode) const; |
| 143 | bool isPredicatedTrue(const MachineInstr *MI) const; |
| 144 | bool isPredicatedTrue(unsigned Opcode) const; |
| 145 | bool isPredicatedNew(const MachineInstr *MI) const; |
| 146 | bool isPredicatedNew(unsigned Opcode) const; |
| 147 | bool DefinesPredicate(MachineInstr *MI, |
| 148 | std::vector<MachineOperand> &Pred) const override; |
| 149 | bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1, |
| 150 | const SmallVectorImpl<MachineOperand> &Pred2) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 151 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 152 | bool |
| 153 | ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 154 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 155 | bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, |
| 156 | const BranchProbability &Probability) const override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 157 | |
Eric Christopher | 143f02c | 2014-10-09 01:59:35 +0000 | [diff] [blame] | 158 | DFAPacketizer * |
| 159 | CreateTargetScheduleState(const TargetSubtargetInfo &STI) const override; |
Andrew Trick | d06df96 | 2012-02-01 22:13:57 +0000 | [diff] [blame] | 160 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 161 | bool isSchedulingBoundary(const MachineInstr *MI, |
| 162 | const MachineBasicBlock *MBB, |
| 163 | const MachineFunction &MF) const override; |
Krzysztof Parzyszek | 0590216 | 2015-04-22 17:51:26 +0000 | [diff] [blame] | 164 | bool isValidOffset(unsigned Opcode, int Offset, bool Extend = true) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 165 | bool isValidAutoIncImm(const EVT VT, const int Offset) const; |
| 166 | bool isMemOp(const MachineInstr *MI) const; |
| 167 | bool isSpillPredRegOp(const MachineInstr *MI) const; |
| 168 | bool isU6_3Immediate(const int value) const; |
| 169 | bool isU6_2Immediate(const int value) const; |
| 170 | bool isU6_1Immediate(const int value) const; |
| 171 | bool isU6_0Immediate(const int value) const; |
| 172 | bool isS4_3Immediate(const int value) const; |
| 173 | bool isS4_2Immediate(const int value) const; |
| 174 | bool isS4_1Immediate(const int value) const; |
| 175 | bool isS4_0Immediate(const int value) const; |
| 176 | bool isS12_Immediate(const int value) const; |
| 177 | bool isU6_Immediate(const int value) const; |
| 178 | bool isS8_Immediate(const int value) const; |
| 179 | bool isS6_Immediate(const int value) const; |
| 180 | |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 181 | bool isSaveCalleeSavedRegsCall(const MachineInstr* MI) const; |
| 182 | bool isConditionalTransfer(const MachineInstr* MI) const; |
Chandler Carruth | 3c3bb55 | 2012-04-23 18:25:57 +0000 | [diff] [blame] | 183 | bool isConditionalALU32 (const MachineInstr* MI) const; |
| 184 | bool isConditionalLoad (const MachineInstr* MI) const; |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 185 | bool isConditionalStore(const MachineInstr* MI) const; |
Jyotsna Verma | f1214a8 | 2013-03-05 18:51:42 +0000 | [diff] [blame] | 186 | bool isNewValueInst(const MachineInstr* MI) const; |
Jyotsna Verma | 84c4710 | 2013-05-06 18:49:23 +0000 | [diff] [blame] | 187 | bool isNewValue(const MachineInstr* MI) const; |
Jyotsna Verma | a46059b | 2013-03-28 19:44:04 +0000 | [diff] [blame] | 188 | bool isDotNewInst(const MachineInstr* MI) const; |
Jyotsna Verma | 438cec5 | 2013-05-10 20:58:11 +0000 | [diff] [blame] | 189 | int GetDotOldOp(const int opc) const; |
Jyotsna Verma | 300f0b9 | 2013-05-10 20:27:34 +0000 | [diff] [blame] | 190 | int GetDotNewOp(const MachineInstr* MI) const; |
Jyotsna Verma | 00681dc | 2013-05-09 19:16:07 +0000 | [diff] [blame] | 191 | int GetDotNewPredOp(MachineInstr *MI, |
| 192 | const MachineBranchProbabilityInfo |
| 193 | *MBPI) const; |
Jyotsna Verma | 438cec5 | 2013-05-10 20:58:11 +0000 | [diff] [blame] | 194 | bool mayBeNewStore(const MachineInstr* MI) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 195 | bool isDeallocRet(const MachineInstr *MI) const; |
Chandler Carruth | 3c3bb55 | 2012-04-23 18:25:57 +0000 | [diff] [blame] | 196 | unsigned getInvertedPredicatedOpcode(const int Opc) const; |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 197 | bool isExtendable(const MachineInstr* MI) const; |
| 198 | bool isExtended(const MachineInstr* MI) const; |
| 199 | bool isPostIncrement(const MachineInstr* MI) const; |
| 200 | bool isNewValueStore(const MachineInstr* MI) const; |
Jyotsna Verma | 300f0b9 | 2013-05-10 20:27:34 +0000 | [diff] [blame] | 201 | bool isNewValueStore(unsigned Opcode) const; |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 202 | bool isNewValueJump(const MachineInstr* MI) const; |
Sirish Pande | 4bd20c5 | 2012-05-12 05:10:30 +0000 | [diff] [blame] | 203 | bool isNewValueJumpCandidate(const MachineInstr *MI) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 204 | |
Jyotsna Verma | 8425643 | 2013-03-01 17:37:13 +0000 | [diff] [blame] | 205 | |
| 206 | void immediateExtend(MachineInstr *MI) const; |
Brendon Cahoon | 55bdeb7 | 2015-04-27 14:16:43 +0000 | [diff] [blame^] | 207 | bool isConstExtended(const MachineInstr *MI) const; |
| 208 | unsigned getSize(const MachineInstr *MI) const; |
Jyotsna Verma | 1d29750 | 2013-05-02 15:39:30 +0000 | [diff] [blame] | 209 | int getDotNewPredJumpOp(MachineInstr *MI, |
| 210 | const MachineBranchProbabilityInfo *MBPI) const; |
Jyotsna Verma | 8425643 | 2013-03-01 17:37:13 +0000 | [diff] [blame] | 211 | unsigned getAddrMode(const MachineInstr* MI) const; |
| 212 | bool isOperandExtended(const MachineInstr *MI, |
| 213 | unsigned short OperandNum) const; |
| 214 | unsigned short getCExtOpNum(const MachineInstr *MI) const; |
| 215 | int getMinValue(const MachineInstr *MI) const; |
| 216 | int getMaxValue(const MachineInstr *MI) const; |
| 217 | bool NonExtEquivalentExists (const MachineInstr *MI) const; |
| 218 | short getNonExtOpcode(const MachineInstr *MI) const; |
Jyotsna Verma | 5ed5181 | 2013-05-01 21:37:34 +0000 | [diff] [blame] | 219 | bool PredOpcodeHasJMP_c(Opcode_t Opcode) const; |
| 220 | bool PredOpcodeHasNot(Opcode_t Opcode) const; |
Krzysztof Parzyszek | c05dff1 | 2015-03-31 13:35:12 +0000 | [diff] [blame] | 221 | int getCondOpcode(int Opc, bool sense) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 222 | |
| 223 | }; |
| 224 | |
| 225 | } |
| 226 | |
| 227 | #endif |