| Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===- HexagonInstrInfo.h - Hexagon Instruction Information -----*- C++ -*-===// |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains the Hexagon implementation of the TargetInstrInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H |
| 15 | #define LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 16 | |
| Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 17 | #include "HexagonRegisterInfo.h" |
| Brendon Cahoon | 6f35837 | 2012-02-08 18:25:47 +0000 | [diff] [blame] | 18 | #include "MCTargetDesc/HexagonBaseInfo.h" |
| Jyotsna Verma | 1d29750 | 2013-05-02 15:39:30 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" |
| Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetFrameLowering.h" |
| 21 | #include "llvm/Target/TargetInstrInfo.h" |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 22 | |
| 23 | #define GET_INSTRINFO_HEADER |
| 24 | #include "HexagonGenInstrInfo.inc" |
| 25 | |
| 26 | namespace llvm { |
| 27 | |
| Patrik Hagglund | 8d09a6c | 2014-03-15 09:11:41 +0000 | [diff] [blame] | 28 | struct EVT; |
| Eric Christopher | 234a1ec | 2015-03-12 06:07:16 +0000 | [diff] [blame] | 29 | class HexagonSubtarget; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 30 | |
| 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; |
| Jyotsna Verma | 5ed5181 | 2013-05-01 21:37:34 +0000 | [diff] [blame] | 34 | |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 35 | public: |
| 36 | explicit HexagonInstrInfo(HexagonSubtarget &ST); |
| 37 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 38 | /// TargetInstrInfo overrides. |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 39 | /// |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 40 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 41 | /// If the specified machine instruction is a direct |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 42 | /// load from a stack slot, return the virtual or physical register number of |
| 43 | /// the destination along with the FrameIndex of the loaded stack slot. If |
| 44 | /// not, return 0. This predicate must return 0 if the instruction has |
| 45 | /// any side effects other than loading from the stack slot. |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 46 | unsigned isLoadFromStackSlot(const MachineInstr &MI, |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 47 | int &FrameIndex) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 48 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 49 | /// If the specified machine instruction is a direct |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 50 | /// store to a stack slot, return the virtual or physical register number of |
| 51 | /// the source reg along with the FrameIndex of the loaded stack slot. If |
| 52 | /// not, return 0. This predicate must return 0 if the instruction has |
| 53 | /// any side effects other than storing to the stack slot. |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 54 | unsigned isStoreToStackSlot(const MachineInstr &MI, |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 55 | int &FrameIndex) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 56 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 57 | /// Analyze the branching code at the end of MBB, returning |
| 58 | /// true if it cannot be understood (e.g. it's a switch dispatch or isn't |
| 59 | /// implemented for a target). Upon success, this returns false and returns |
| 60 | /// with the following information in various cases: |
| 61 | /// |
| 62 | /// 1. If this block ends with no branches (it just falls through to its succ) |
| 63 | /// just return false, leaving TBB/FBB null. |
| 64 | /// 2. If this block ends with only an unconditional branch, it sets TBB to be |
| 65 | /// the destination block. |
| 66 | /// 3. If this block ends with a conditional branch and it falls through to a |
| 67 | /// successor block, it sets TBB to be the branch destination block and a |
| 68 | /// list of operands that evaluate the condition. These operands can be |
| 69 | /// passed to other TargetInstrInfo methods to create new branches. |
| 70 | /// 4. If this block ends with a conditional branch followed by an |
| 71 | /// unconditional branch, it returns the 'true' destination in TBB, the |
| 72 | /// 'false' destination in FBB, and a list of operands that evaluate the |
| 73 | /// condition. These operands can be passed to other TargetInstrInfo |
| 74 | /// methods to create new branches. |
| 75 | /// |
| 76 | /// Note that RemoveBranch and InsertBranch must be implemented to support |
| 77 | /// cases where this method returns success. |
| 78 | /// |
| 79 | /// If AllowModify is true, then this routine is allowed to modify the basic |
| 80 | /// block (e.g. delete instructions after the unconditional branch). |
| 81 | /// |
| Jacques Pienaar | 71c30a1 | 2016-07-15 14:41:04 +0000 | [diff] [blame] | 82 | bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, |
| 83 | MachineBasicBlock *&FBB, |
| 84 | SmallVectorImpl<MachineOperand> &Cond, |
| 85 | bool AllowModify) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 86 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 87 | /// Remove the branching code at the end of the specific MBB. |
| 88 | /// This is only invoked in cases where AnalyzeBranch returns success. It |
| 89 | /// returns the number of instructions that were removed. |
| Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame^] | 90 | unsigned RemoveBranch(MachineBasicBlock &MBB, |
| 91 | int *BytesRemoved = nullptr) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 92 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 93 | /// Insert branch code into the end of the specified MachineBasicBlock. |
| 94 | /// The operands to this method are the same as those |
| 95 | /// returned by AnalyzeBranch. This is only invoked in cases where |
| 96 | /// AnalyzeBranch returns success. It returns the number of instructions |
| 97 | /// inserted. |
| 98 | /// |
| 99 | /// It is also invoked by tail merging to add unconditional branches in |
| 100 | /// cases where AnalyzeBranch doesn't apply because there was no original |
| 101 | /// branch to analyze. At least this much must be implemented, else tail |
| 102 | /// merging needs to be disabled. |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 103 | unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
| Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 104 | MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, |
| Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame^] | 105 | const DebugLoc &DL, |
| 106 | int *BytesAdded = nullptr) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 107 | |
| Brendon Cahoon | 254f889 | 2016-07-29 16:44:44 +0000 | [diff] [blame] | 108 | /// Analyze the loop code, return true if it cannot be understood. Upon |
| 109 | /// success, this function returns false and returns information about the |
| 110 | /// induction variable and compare instruction used at the end. |
| 111 | bool analyzeLoop(MachineLoop &L, MachineInstr *&IndVarInst, |
| 112 | MachineInstr *&CmpInst) const override; |
| 113 | |
| 114 | /// Generate code to reduce the loop iteration by one and check if the loop is |
| 115 | /// finished. Return the value/register of the the new loop count. We need |
| 116 | /// this function when peeling off one or more iterations of a loop. This |
| 117 | /// function assumes the nth iteration is peeled first. |
| 118 | unsigned reduceLoopCount(MachineBasicBlock &MBB, |
| Krzysztof Parzyszek | 8fb181c | 2016-08-01 17:55:48 +0000 | [diff] [blame] | 119 | MachineInstr *IndVar, MachineInstr &Cmp, |
| Brendon Cahoon | 254f889 | 2016-07-29 16:44:44 +0000 | [diff] [blame] | 120 | SmallVectorImpl<MachineOperand> &Cond, |
| 121 | SmallVectorImpl<MachineInstr *> &PrevInsts, |
| 122 | unsigned Iter, unsigned MaxIter) const override; |
| 123 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 124 | /// Return true if it's profitable to predicate |
| 125 | /// instructions with accumulated instruction latency of "NumCycles" |
| 126 | /// of the specified basic block, where the probability of the instructions |
| 127 | /// being executed is given by Probability, and Confidence is a measure |
| 128 | /// of our confidence that it will be properly predicted. |
| 129 | bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, |
| 130 | unsigned ExtraPredCycles, |
| 131 | BranchProbability Probability) const override; |
| Krzysztof Parzyszek | cfe285e | 2013-02-11 20:04:29 +0000 | [diff] [blame] | 132 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 133 | /// Second variant of isProfitableToIfCvt. This one |
| 134 | /// checks for the case where two basic blocks from true and false path |
| 135 | /// of a if-then-else (diamond) are predicated on mutally exclusive |
| 136 | /// predicates, where the probability of the true path being taken is given |
| 137 | /// by Probability, and Confidence is a measure of our confidence that it |
| 138 | /// will be properly predicted. |
| 139 | bool isProfitableToIfCvt(MachineBasicBlock &TMBB, |
| 140 | unsigned NumTCycles, unsigned ExtraTCycles, |
| 141 | MachineBasicBlock &FMBB, |
| 142 | unsigned NumFCycles, unsigned ExtraFCycles, |
| 143 | BranchProbability Probability) const override; |
| 144 | |
| 145 | /// Return true if it's profitable for if-converter to duplicate instructions |
| 146 | /// of specified accumulated instruction latencies in the specified MBB to |
| 147 | /// enable if-conversion. |
| 148 | /// The probability of the instructions being executed is given by |
| 149 | /// Probability, and Confidence is a measure of our confidence that it |
| 150 | /// will be properly predicted. |
| 151 | bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, |
| 152 | BranchProbability Probability) const override; |
| 153 | |
| 154 | /// Emit instructions to copy a pair of physical registers. |
| 155 | /// |
| 156 | /// This function should support copies within any legal register class as |
| 157 | /// well as any cross-class copies created during instruction selection. |
| 158 | /// |
| 159 | /// The source and destination registers may overlap, which may require a |
| 160 | /// careful implementation when multiple copy instructions are required for |
| 161 | /// large registers. See for example the ARM target. |
| Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 162 | void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, |
| 163 | const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 164 | bool KillSrc) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 165 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 166 | /// Store the specified register of the given register class to the specified |
| 167 | /// stack frame index. The store instruction is to be added to the given |
| 168 | /// machine basic block before the specified machine instruction. If isKill |
| 169 | /// is true, the register operand is the last use and must be marked kill. |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 170 | void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 171 | MachineBasicBlock::iterator MBBI, |
| 172 | unsigned SrcReg, bool isKill, int FrameIndex, |
| 173 | const TargetRegisterClass *RC, |
| 174 | const TargetRegisterInfo *TRI) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 175 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 176 | /// Load the specified register of the given register class from the specified |
| 177 | /// stack frame index. The load instruction is to be added to the given |
| 178 | /// machine basic block before the specified machine instruction. |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 179 | void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 180 | MachineBasicBlock::iterator MBBI, |
| 181 | unsigned DestReg, int FrameIndex, |
| 182 | const TargetRegisterClass *RC, |
| 183 | const TargetRegisterInfo *TRI) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 184 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 185 | /// This function is called for all pseudo instructions |
| Colin LeMahieu | 7b1799c | 2015-03-09 22:05:21 +0000 | [diff] [blame] | 186 | /// that remain after register allocation. Many pseudo instructions are |
| 187 | /// created to help register allocation. This is the place to convert them |
| 188 | /// into real instructions. The target can edit MI in place, or it can insert |
| 189 | /// new instructions and erase MI. The function should return true if |
| 190 | /// anything was changed. |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 191 | bool expandPostRAPseudo(MachineInstr &MI) const override; |
| Colin LeMahieu | 7b1799c | 2015-03-09 22:05:21 +0000 | [diff] [blame] | 192 | |
| Brendon Cahoon | 254f889 | 2016-07-29 16:44:44 +0000 | [diff] [blame] | 193 | /// \brief Get the base register and byte offset of a load/store instr. |
| 194 | bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, |
| 195 | int64_t &Offset, |
| 196 | const TargetRegisterInfo *TRI) const override; |
| 197 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 198 | /// Reverses the branch condition of the specified condition list, |
| 199 | /// returning false on success and true if it cannot be reversed. |
| 200 | bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) |
| 201 | const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 202 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 203 | /// Insert a noop into the instruction stream at the specified point. |
| 204 | void insertNoop(MachineBasicBlock &MBB, |
| 205 | MachineBasicBlock::iterator MI) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 206 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 207 | /// Returns true if the instruction is already predicated. |
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 208 | bool isPredicated(const MachineInstr &MI) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 209 | |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 210 | /// Return true for post-incremented instructions. |
| Krzysztof Parzyszek | 8fb181c | 2016-08-01 17:55:48 +0000 | [diff] [blame] | 211 | bool isPostIncrement(const MachineInstr &MI) const override; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 212 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 213 | /// Convert the instruction into a predicated instruction. |
| 214 | /// It returns true if the operation was successful. |
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 215 | bool PredicateInstruction(MachineInstr &MI, |
| Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 216 | ArrayRef<MachineOperand> Cond) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 217 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 218 | /// Returns true if the first specified predicate |
| 219 | /// subsumes the second, e.g. GE subsumes GT. |
| Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 220 | bool SubsumesPredicate(ArrayRef<MachineOperand> Pred1, |
| 221 | ArrayRef<MachineOperand> Pred2) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 222 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 223 | /// If the specified instruction defines any predicate |
| 224 | /// or condition code register(s) used for predication, returns true as well |
| 225 | /// as the definition predicate(s) by reference. |
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 226 | bool DefinesPredicate(MachineInstr &MI, |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 227 | std::vector<MachineOperand> &Pred) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 228 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 229 | /// Return true if the specified instruction can be predicated. |
| 230 | /// By default, this returns true for every instruction with a |
| 231 | /// PredicateOperand. |
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 232 | bool isPredicable(MachineInstr &MI) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 233 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 234 | /// Test if the given instruction should be considered a scheduling boundary. |
| 235 | /// This primarily includes labels and terminators. |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 236 | bool isSchedulingBoundary(const MachineInstr &MI, |
| Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 237 | const MachineBasicBlock *MBB, |
| 238 | const MachineFunction &MF) const override; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 239 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 240 | /// Measure the specified inline asm to determine an approximation of its |
| 241 | /// length. |
| 242 | unsigned getInlineAsmLength(const char *Str, |
| 243 | const MCAsmInfo &MAI) const override; |
| 244 | |
| 245 | /// Allocate and return a hazard recognizer to use for this target when |
| 246 | /// scheduling the machine instructions after register allocation. |
| 247 | ScheduleHazardRecognizer* |
| 248 | CreateTargetPostRAHazardRecognizer(const InstrItineraryData*, |
| 249 | const ScheduleDAG *DAG) const override; |
| 250 | |
| 251 | /// For a comparison instruction, return the source registers |
| 252 | /// in SrcReg and SrcReg2 if having two register operands, and the value it |
| 253 | /// compares against in CmpValue. Return true if the comparison instruction |
| 254 | /// can be analyzed. |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 255 | bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, |
| 256 | unsigned &SrcReg2, int &Mask, int &Value) const override; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 257 | |
| 258 | /// Compute the instruction latency of a given instruction. |
| 259 | /// If the instruction has higher cost when predicated, it's returned via |
| 260 | /// PredCost. |
| 261 | unsigned getInstrLatency(const InstrItineraryData *ItinData, |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 262 | const MachineInstr &MI, |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 263 | unsigned *PredCost = 0) const override; |
| 264 | |
| 265 | /// Create machine specific model for scheduling. |
| 266 | DFAPacketizer * |
| 267 | CreateTargetScheduleState(const TargetSubtargetInfo &STI) const override; |
| 268 | |
| 269 | // Sometimes, it is possible for the target |
| 270 | // to tell, even without aliasing information, that two MIs access different |
| 271 | // memory addresses. This function returns true if two MIs access different |
| 272 | // memory addresses and false otherwise. |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 273 | bool |
| 274 | areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, |
| 275 | AliasAnalysis *AA = nullptr) const override; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 276 | |
| Brendon Cahoon | 254f889 | 2016-07-29 16:44:44 +0000 | [diff] [blame] | 277 | /// For instructions with a base and offset, return the position of the |
| 278 | /// base register and offset operands. |
| Krzysztof Parzyszek | 8fb181c | 2016-08-01 17:55:48 +0000 | [diff] [blame] | 279 | bool getBaseAndOffsetPosition(const MachineInstr &MI, unsigned &BasePos, |
| Brendon Cahoon | 254f889 | 2016-07-29 16:44:44 +0000 | [diff] [blame] | 280 | unsigned &OffsetPos) const override; |
| 281 | |
| 282 | /// If the instruction is an increment of a constant value, return the amount. |
| Krzysztof Parzyszek | 8fb181c | 2016-08-01 17:55:48 +0000 | [diff] [blame] | 283 | bool getIncrementValue(const MachineInstr &MI, int &Value) const override; |
| Brendon Cahoon | 254f889 | 2016-07-29 16:44:44 +0000 | [diff] [blame] | 284 | |
| Dean Michael Berris | 6d6addb | 2016-09-01 01:58:24 +0000 | [diff] [blame] | 285 | bool isTailCall(const MachineInstr &MI) const override; |
| 286 | |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 287 | /// HexagonInstrInfo specifics. |
| 288 | /// |
| 289 | |
| 290 | const HexagonRegisterInfo &getRegisterInfo() const { return RI; } |
| 291 | |
| 292 | unsigned createVR(MachineFunction* MF, MVT VT) const; |
| 293 | |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 294 | bool isAbsoluteSet(const MachineInstr &MI) const; |
| 295 | bool isAccumulator(const MachineInstr &MI) const; |
| 296 | bool isComplex(const MachineInstr &MI) const; |
| 297 | bool isCompoundBranchInstr(const MachineInstr &MI) const; |
| 298 | bool isCondInst(const MachineInstr &MI) const; |
| 299 | bool isConditionalALU32 (const MachineInstr &MI) const; |
| 300 | bool isConditionalLoad(const MachineInstr &MI) const; |
| 301 | bool isConditionalStore(const MachineInstr &MI) const; |
| 302 | bool isConditionalTransfer(const MachineInstr &MI) const; |
| 303 | bool isConstExtended(const MachineInstr &MI) const; |
| 304 | bool isDeallocRet(const MachineInstr &MI) const; |
| 305 | bool isDependent(const MachineInstr &ProdMI, |
| 306 | const MachineInstr &ConsMI) const; |
| 307 | bool isDotCurInst(const MachineInstr &MI) const; |
| 308 | bool isDotNewInst(const MachineInstr &MI) const; |
| 309 | bool isDuplexPair(const MachineInstr &MIa, const MachineInstr &MIb) const; |
| 310 | bool isEarlySourceInstr(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 311 | bool isEndLoopN(unsigned Opcode) const; |
| 312 | bool isExpr(unsigned OpType) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 313 | bool isExtendable(const MachineInstr &MI) const; |
| 314 | bool isExtended(const MachineInstr &MI) const; |
| 315 | bool isFloat(const MachineInstr &MI) const; |
| 316 | bool isHVXMemWithAIndirect(const MachineInstr &I, |
| 317 | const MachineInstr &J) const; |
| 318 | bool isIndirectCall(const MachineInstr &MI) const; |
| 319 | bool isIndirectL4Return(const MachineInstr &MI) const; |
| 320 | bool isJumpR(const MachineInstr &MI) const; |
| 321 | bool isJumpWithinBranchRange(const MachineInstr &MI, unsigned offset) const; |
| 322 | bool isLateInstrFeedsEarlyInstr(const MachineInstr &LRMI, |
| 323 | const MachineInstr &ESMI) const; |
| 324 | bool isLateResultInstr(const MachineInstr &MI) const; |
| 325 | bool isLateSourceInstr(const MachineInstr &MI) const; |
| 326 | bool isLoopN(const MachineInstr &MI) const; |
| 327 | bool isMemOp(const MachineInstr &MI) const; |
| 328 | bool isNewValue(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 329 | bool isNewValue(unsigned Opcode) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 330 | bool isNewValueInst(const MachineInstr &MI) const; |
| 331 | bool isNewValueJump(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 332 | bool isNewValueJump(unsigned Opcode) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 333 | bool isNewValueStore(const MachineInstr &MI) const; |
| Jyotsna Verma | 300f0b9 | 2013-05-10 20:27:34 +0000 | [diff] [blame] | 334 | bool isNewValueStore(unsigned Opcode) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 335 | bool isOperandExtended(const MachineInstr &MI, unsigned OperandNum) const; |
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 336 | bool isPredicatedNew(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 337 | bool isPredicatedNew(unsigned Opcode) const; |
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 338 | bool isPredicatedTrue(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 339 | bool isPredicatedTrue(unsigned Opcode) const; |
| 340 | bool isPredicated(unsigned Opcode) const; |
| 341 | bool isPredicateLate(unsigned Opcode) const; |
| 342 | bool isPredictedTaken(unsigned Opcode) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 343 | bool isSaveCalleeSavedRegsCall(const MachineInstr &MI) const; |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 344 | bool isSignExtendingLoad(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 345 | bool isSolo(const MachineInstr &MI) const; |
| 346 | bool isSpillPredRegOp(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 347 | bool isTC1(const MachineInstr &MI) const; |
| 348 | bool isTC2(const MachineInstr &MI) const; |
| 349 | bool isTC2Early(const MachineInstr &MI) const; |
| 350 | bool isTC4x(const MachineInstr &MI) const; |
| 351 | bool isToBeScheduledASAP(const MachineInstr &MI1, |
| 352 | const MachineInstr &MI2) const; |
| 353 | bool isV60VectorInstruction(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 354 | bool isValidAutoIncImm(const EVT VT, const int Offset) const; |
| 355 | bool isValidOffset(unsigned Opcode, int Offset, bool Extend = true) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 356 | bool isVecAcc(const MachineInstr &MI) const; |
| 357 | bool isVecALU(const MachineInstr &MI) const; |
| 358 | bool isVecUsableNextPacket(const MachineInstr &ProdMI, |
| 359 | const MachineInstr &ConsMI) const; |
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 360 | bool isZeroExtendingLoad(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 361 | |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 362 | bool addLatencyToSchedule(const MachineInstr &MI1, |
| 363 | const MachineInstr &MI2) const; |
| 364 | bool canExecuteInBundle(const MachineInstr &First, |
| 365 | const MachineInstr &Second) const; |
| Krzysztof Parzyszek | 1b689da | 2016-08-11 21:14:25 +0000 | [diff] [blame] | 366 | bool doesNotReturn(const MachineInstr &CallMI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 367 | bool hasEHLabel(const MachineBasicBlock *B) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 368 | bool hasNonExtEquivalent(const MachineInstr &MI) const; |
| 369 | bool hasPseudoInstrPair(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 370 | bool hasUncondBranch(const MachineBasicBlock *B) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 371 | bool mayBeCurLoad(const MachineInstr &MI) const; |
| 372 | bool mayBeNewStore(const MachineInstr &MI) const; |
| 373 | bool producesStall(const MachineInstr &ProdMI, |
| 374 | const MachineInstr &ConsMI) const; |
| 375 | bool producesStall(const MachineInstr &MI, |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 376 | MachineBasicBlock::const_instr_iterator MII) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 377 | bool predCanBeUsedAsDotNew(const MachineInstr &MI, unsigned PredReg) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 378 | bool PredOpcodeHasJMP_c(unsigned Opcode) const; |
| 379 | bool predOpcodeHasNot(ArrayRef<MachineOperand> Cond) const; |
| 380 | |
| 381 | |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 382 | short getAbsoluteForm(const MachineInstr &MI) const; |
| 383 | unsigned getAddrMode(const MachineInstr &MI) const; |
| 384 | unsigned getBaseAndOffset(const MachineInstr &MI, int &Offset, |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 385 | unsigned &AccessSize) const; |
| Krzysztof Parzyszek | f5cbac9 | 2016-04-29 15:49:13 +0000 | [diff] [blame] | 386 | short getBaseWithLongOffset(short Opcode) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 387 | short getBaseWithLongOffset(const MachineInstr &MI) const; |
| 388 | short getBaseWithRegOffset(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 389 | SmallVector<MachineInstr*,2> getBranchingInstrs(MachineBasicBlock& MBB) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 390 | unsigned getCExtOpNum(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 391 | HexagonII::CompoundGroup |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 392 | getCompoundCandidateGroup(const MachineInstr &MI) const; |
| 393 | unsigned getCompoundOpcode(const MachineInstr &GA, |
| 394 | const MachineInstr &GB) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 395 | int getCondOpcode(int Opc, bool sense) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 396 | int getDotCurOp(const MachineInstr &MI) const; |
| 397 | int getDotNewOp(const MachineInstr &MI) const; |
| 398 | int getDotNewPredJumpOp(const MachineInstr &MI, |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 399 | const MachineBranchProbabilityInfo *MBPI) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 400 | int getDotNewPredOp(const MachineInstr &MI, |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 401 | const MachineBranchProbabilityInfo *MBPI) const; |
| 402 | int getDotOldOp(const int opc) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 403 | HexagonII::SubInstructionGroup getDuplexCandidateGroup(const MachineInstr &MI) |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 404 | const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 405 | short getEquivalentHWInstr(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 406 | MachineInstr *getFirstNonDbgInst(MachineBasicBlock *BB) const; |
| 407 | unsigned getInstrTimingClassLatency(const InstrItineraryData *ItinData, |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 408 | const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 409 | bool getInvertedPredSense(SmallVectorImpl<MachineOperand> &Cond) const; |
| 410 | unsigned getInvertedPredicatedOpcode(const int Opc) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 411 | int getMaxValue(const MachineInstr &MI) const; |
| 412 | unsigned getMemAccessSize(const MachineInstr &MI) const; |
| 413 | int getMinValue(const MachineInstr &MI) const; |
| 414 | short getNonExtOpcode(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 415 | bool getPredReg(ArrayRef<MachineOperand> Cond, unsigned &PredReg, |
| 416 | unsigned &PredRegPos, unsigned &PredRegFlags) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 417 | short getPseudoInstrPair(const MachineInstr &MI) const; |
| 418 | short getRegForm(const MachineInstr &MI) const; |
| 419 | unsigned getSize(const MachineInstr &MI) const; |
| 420 | uint64_t getType(const MachineInstr &MI) const; |
| 421 | unsigned getUnits(const MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 422 | unsigned getValidSubTargets(const unsigned Opcode) const; |
| 423 | |
| 424 | |
| 425 | /// getInstrTimingClassLatency - Compute the instruction latency of a given |
| 426 | /// instruction using Timing Class information, if available. |
| 427 | unsigned nonDbgBBSize(const MachineBasicBlock *BB) const; |
| 428 | unsigned nonDbgBundleSize(MachineBasicBlock::const_iterator BundleHead) const; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 429 | |
| Jyotsna Verma | 8425643 | 2013-03-01 17:37:13 +0000 | [diff] [blame] | 430 | |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 431 | void immediateExtend(MachineInstr &MI) const; |
| 432 | bool invertAndChangeJumpTarget(MachineInstr &MI, |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 433 | MachineBasicBlock* NewTarget) const; |
| 434 | void genAllInsnTimingClasses(MachineFunction &MF) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 435 | bool reversePredSense(MachineInstr &MI) const; |
| Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 436 | unsigned reversePrediction(unsigned Opcode) const; |
| 437 | bool validateBranchCond(const ArrayRef<MachineOperand> &Cond) const; |
| Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 438 | short xformRegToImmOffset(const MachineInstr &MI) const; |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 439 | }; |
| 440 | |
| Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 441 | } |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 442 | |
| 443 | #endif |