blob: d45e895276bb77aabad2f365a0b4bdeb0f5b905b [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===- HexagonInstrInfo.h - Hexagon Instruction Information -----*- C++ -*-===//
Tony Linthicum1213a7a2011-12-12 21:14:40 +00002//
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 Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
15#define LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
Tony Linthicum1213a7a2011-12-12 21:14:40 +000016
Brendon Cahoon6f358372012-02-08 18:25:47 +000017#include "MCTargetDesc/HexagonBaseInfo.h"
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000018#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/SmallVector.h"
20#include "llvm/CodeGen/MachineBasicBlock.h"
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000021#include "llvm/CodeGen/MachineValueType.h"
Eugene Zelenko3b873362017-09-28 22:27:31 +000022#include "llvm/CodeGen/ValueTypes.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000023#include "llvm/Target/TargetInstrInfo.h"
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000024#include <cstdint>
25#include <vector>
Tony Linthicum1213a7a2011-12-12 21:14:40 +000026
27#define GET_INSTRINFO_HEADER
28#include "HexagonGenInstrInfo.inc"
29
30namespace llvm {
31
Eric Christopher234a1ec2015-03-12 06:07:16 +000032class HexagonSubtarget;
Eugene Zelenko3b873362017-09-28 22:27:31 +000033class MachineBranchProbabilityInfo;
34class MachineFunction;
35class MachineInstr;
36class MachineOperand;
37class TargetRegisterInfo;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000038
Tony Linthicum1213a7a2011-12-12 21:14:40 +000039class HexagonInstrInfo : public HexagonGenInstrInfo {
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000040 virtual void anchor();
41
Tony Linthicum1213a7a2011-12-12 21:14:40 +000042public:
43 explicit HexagonInstrInfo(HexagonSubtarget &ST);
44
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000045 /// TargetInstrInfo overrides.
Tony Linthicum1213a7a2011-12-12 21:14:40 +000046
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000047 /// If the specified machine instruction is a direct
Tony Linthicum1213a7a2011-12-12 21:14:40 +000048 /// load from a stack slot, return the virtual or physical register number of
49 /// the destination along with the FrameIndex of the loaded stack slot. If
50 /// not, return 0. This predicate must return 0 if the instruction has
51 /// any side effects other than loading from the stack slot.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000052 unsigned isLoadFromStackSlot(const MachineInstr &MI,
Craig Topper906c2cd2014-04-29 07:58:16 +000053 int &FrameIndex) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000054
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000055 /// If the specified machine instruction is a direct
Tony Linthicum1213a7a2011-12-12 21:14:40 +000056 /// store to a stack slot, return the virtual or physical register number of
57 /// the source reg along with the FrameIndex of the loaded stack slot. If
58 /// not, return 0. This predicate must return 0 if the instruction has
59 /// any side effects other than storing to the stack slot.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000060 unsigned isStoreToStackSlot(const MachineInstr &MI,
Craig Topper906c2cd2014-04-29 07:58:16 +000061 int &FrameIndex) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000062
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000063 /// Analyze the branching code at the end of MBB, returning
64 /// true if it cannot be understood (e.g. it's a switch dispatch or isn't
65 /// implemented for a target). Upon success, this returns false and returns
66 /// with the following information in various cases:
67 ///
68 /// 1. If this block ends with no branches (it just falls through to its succ)
69 /// just return false, leaving TBB/FBB null.
70 /// 2. If this block ends with only an unconditional branch, it sets TBB to be
71 /// the destination block.
72 /// 3. If this block ends with a conditional branch and it falls through to a
73 /// successor block, it sets TBB to be the branch destination block and a
74 /// list of operands that evaluate the condition. These operands can be
75 /// passed to other TargetInstrInfo methods to create new branches.
76 /// 4. If this block ends with a conditional branch followed by an
77 /// unconditional branch, it returns the 'true' destination in TBB, the
78 /// 'false' destination in FBB, and a list of operands that evaluate the
79 /// condition. These operands can be passed to other TargetInstrInfo
80 /// methods to create new branches.
81 ///
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +000082 /// Note that removeBranch and insertBranch must be implemented to support
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000083 /// cases where this method returns success.
84 ///
85 /// If AllowModify is true, then this routine is allowed to modify the basic
86 /// block (e.g. delete instructions after the unconditional branch).
Jacques Pienaar71c30a12016-07-15 14:41:04 +000087 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
88 MachineBasicBlock *&FBB,
89 SmallVectorImpl<MachineOperand> &Cond,
90 bool AllowModify) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000091
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000092 /// Remove the branching code at the end of the specific MBB.
93 /// This is only invoked in cases where AnalyzeBranch returns success. It
94 /// returns the number of instructions that were removed.
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +000095 unsigned removeBranch(MachineBasicBlock &MBB,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +000096 int *BytesRemoved = nullptr) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000097
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000098 /// Insert branch code into the end of the specified MachineBasicBlock.
99 /// The operands to this method are the same as those
100 /// returned by AnalyzeBranch. This is only invoked in cases where
101 /// AnalyzeBranch returns success. It returns the number of instructions
102 /// inserted.
103 ///
104 /// It is also invoked by tail merging to add unconditional branches in
105 /// cases where AnalyzeBranch doesn't apply because there was no original
106 /// branch to analyze. At least this much must be implemented, else tail
107 /// merging needs to be disabled.
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +0000108 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000109 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000110 const DebugLoc &DL,
111 int *BytesAdded = nullptr) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000112
Brendon Cahoon254f8892016-07-29 16:44:44 +0000113 /// Analyze the loop code, return true if it cannot be understood. Upon
114 /// success, this function returns false and returns information about the
115 /// induction variable and compare instruction used at the end.
116 bool analyzeLoop(MachineLoop &L, MachineInstr *&IndVarInst,
117 MachineInstr *&CmpInst) const override;
118
119 /// Generate code to reduce the loop iteration by one and check if the loop is
120 /// finished. Return the value/register of the the new loop count. We need
121 /// this function when peeling off one or more iterations of a loop. This
122 /// function assumes the nth iteration is peeled first.
123 unsigned reduceLoopCount(MachineBasicBlock &MBB,
Krzysztof Parzyszek8fb181c2016-08-01 17:55:48 +0000124 MachineInstr *IndVar, MachineInstr &Cmp,
Brendon Cahoon254f8892016-07-29 16:44:44 +0000125 SmallVectorImpl<MachineOperand> &Cond,
126 SmallVectorImpl<MachineInstr *> &PrevInsts,
127 unsigned Iter, unsigned MaxIter) const override;
128
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000129 /// Return true if it's profitable to predicate
130 /// instructions with accumulated instruction latency of "NumCycles"
131 /// of the specified basic block, where the probability of the instructions
132 /// being executed is given by Probability, and Confidence is a measure
133 /// of our confidence that it will be properly predicted.
134 bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
135 unsigned ExtraPredCycles,
136 BranchProbability Probability) const override;
Krzysztof Parzyszekcfe285e2013-02-11 20:04:29 +0000137
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000138 /// Second variant of isProfitableToIfCvt. This one
139 /// checks for the case where two basic blocks from true and false path
140 /// of a if-then-else (diamond) are predicated on mutally exclusive
141 /// predicates, where the probability of the true path being taken is given
142 /// by Probability, and Confidence is a measure of our confidence that it
143 /// will be properly predicted.
144 bool isProfitableToIfCvt(MachineBasicBlock &TMBB,
145 unsigned NumTCycles, unsigned ExtraTCycles,
146 MachineBasicBlock &FMBB,
147 unsigned NumFCycles, unsigned ExtraFCycles,
148 BranchProbability Probability) const override;
149
150 /// Return true if it's profitable for if-converter to duplicate instructions
151 /// of specified accumulated instruction latencies in the specified MBB to
152 /// enable if-conversion.
153 /// The probability of the instructions being executed is given by
154 /// Probability, and Confidence is a measure of our confidence that it
155 /// will be properly predicted.
156 bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
157 BranchProbability Probability) const override;
158
159 /// Emit instructions to copy a pair of physical registers.
160 ///
161 /// This function should support copies within any legal register class as
162 /// well as any cross-class copies created during instruction selection.
163 ///
164 /// The source and destination registers may overlap, which may require a
165 /// careful implementation when multiple copy instructions are required for
166 /// large registers. See for example the ARM target.
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000167 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
168 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
Craig Topper906c2cd2014-04-29 07:58:16 +0000169 bool KillSrc) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000170
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000171 /// Store the specified register of the given register class to the specified
172 /// stack frame index. The store instruction is to be added to the given
173 /// machine basic block before the specified machine instruction. If isKill
174 /// is true, the register operand is the last use and must be marked kill.
Craig Topper906c2cd2014-04-29 07:58:16 +0000175 void storeRegToStackSlot(MachineBasicBlock &MBB,
176 MachineBasicBlock::iterator MBBI,
177 unsigned SrcReg, bool isKill, int FrameIndex,
178 const TargetRegisterClass *RC,
179 const TargetRegisterInfo *TRI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000180
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000181 /// Load the specified register of the given register class from the specified
182 /// stack frame index. The load instruction is to be added to the given
183 /// machine basic block before the specified machine instruction.
Craig Topper906c2cd2014-04-29 07:58:16 +0000184 void loadRegFromStackSlot(MachineBasicBlock &MBB,
185 MachineBasicBlock::iterator MBBI,
186 unsigned DestReg, int FrameIndex,
187 const TargetRegisterClass *RC,
188 const TargetRegisterInfo *TRI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000189
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000190 /// This function is called for all pseudo instructions
Colin LeMahieu7b1799c2015-03-09 22:05:21 +0000191 /// that remain after register allocation. Many pseudo instructions are
192 /// created to help register allocation. This is the place to convert them
193 /// into real instructions. The target can edit MI in place, or it can insert
194 /// new instructions and erase MI. The function should return true if
195 /// anything was changed.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000196 bool expandPostRAPseudo(MachineInstr &MI) const override;
Colin LeMahieu7b1799c2015-03-09 22:05:21 +0000197
Brendon Cahoon254f8892016-07-29 16:44:44 +0000198 /// \brief Get the base register and byte offset of a load/store instr.
199 bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg,
200 int64_t &Offset,
201 const TargetRegisterInfo *TRI) const override;
202
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000203 /// Reverses the branch condition of the specified condition list,
204 /// returning false on success and true if it cannot be reversed.
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000205 bool reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond)
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000206 const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000207
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000208 /// Insert a noop into the instruction stream at the specified point.
209 void insertNoop(MachineBasicBlock &MBB,
210 MachineBasicBlock::iterator MI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000211
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000212 /// Returns true if the instruction is already predicated.
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000213 bool isPredicated(const MachineInstr &MI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000214
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000215 /// Return true for post-incremented instructions.
Krzysztof Parzyszek8fb181c2016-08-01 17:55:48 +0000216 bool isPostIncrement(const MachineInstr &MI) const override;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000217
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000218 /// Convert the instruction into a predicated instruction.
219 /// It returns true if the operation was successful.
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000220 bool PredicateInstruction(MachineInstr &MI,
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000221 ArrayRef<MachineOperand> Cond) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000222
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000223 /// Returns true if the first specified predicate
224 /// subsumes the second, e.g. GE subsumes GT.
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000225 bool SubsumesPredicate(ArrayRef<MachineOperand> Pred1,
226 ArrayRef<MachineOperand> Pred2) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000227
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000228 /// If the specified instruction defines any predicate
229 /// or condition code register(s) used for predication, returns true as well
230 /// as the definition predicate(s) by reference.
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000231 bool DefinesPredicate(MachineInstr &MI,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000232 std::vector<MachineOperand> &Pred) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000233
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000234 /// Return true if the specified instruction can be predicated.
235 /// By default, this returns true for every instruction with a
236 /// PredicateOperand.
Krzysztof Parzyszekcc318712017-03-03 18:30:54 +0000237 bool isPredicable(const MachineInstr &MI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000238
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000239 /// Test if the given instruction should be considered a scheduling boundary.
240 /// This primarily includes labels and terminators.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000241 bool isSchedulingBoundary(const MachineInstr &MI,
Craig Topper906c2cd2014-04-29 07:58:16 +0000242 const MachineBasicBlock *MBB,
243 const MachineFunction &MF) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000244
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000245 /// Measure the specified inline asm to determine an approximation of its
246 /// length.
247 unsigned getInlineAsmLength(const char *Str,
248 const MCAsmInfo &MAI) const override;
249
250 /// Allocate and return a hazard recognizer to use for this target when
251 /// scheduling the machine instructions after register allocation.
252 ScheduleHazardRecognizer*
Eugene Zelenko3b873362017-09-28 22:27:31 +0000253 CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000254 const ScheduleDAG *DAG) const override;
255
256 /// For a comparison instruction, return the source registers
257 /// in SrcReg and SrcReg2 if having two register operands, and the value it
258 /// compares against in CmpValue. Return true if the comparison instruction
259 /// can be analyzed.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000260 bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg,
261 unsigned &SrcReg2, int &Mask, int &Value) const override;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000262
263 /// Compute the instruction latency of a given instruction.
264 /// If the instruction has higher cost when predicated, it's returned via
265 /// PredCost.
266 unsigned getInstrLatency(const InstrItineraryData *ItinData,
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000267 const MachineInstr &MI,
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +0000268 unsigned *PredCost = nullptr) const override;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000269
270 /// Create machine specific model for scheduling.
271 DFAPacketizer *
272 CreateTargetScheduleState(const TargetSubtargetInfo &STI) const override;
273
274 // Sometimes, it is possible for the target
275 // to tell, even without aliasing information, that two MIs access different
276 // memory addresses. This function returns true if two MIs access different
277 // memory addresses and false otherwise.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000278 bool
279 areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb,
280 AliasAnalysis *AA = nullptr) const override;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000281
Brendon Cahoon254f8892016-07-29 16:44:44 +0000282 /// For instructions with a base and offset, return the position of the
283 /// base register and offset operands.
Krzysztof Parzyszek8fb181c2016-08-01 17:55:48 +0000284 bool getBaseAndOffsetPosition(const MachineInstr &MI, unsigned &BasePos,
Brendon Cahoon254f8892016-07-29 16:44:44 +0000285 unsigned &OffsetPos) const override;
286
287 /// If the instruction is an increment of a constant value, return the amount.
Krzysztof Parzyszek8fb181c2016-08-01 17:55:48 +0000288 bool getIncrementValue(const MachineInstr &MI, int &Value) const override;
Brendon Cahoon254f8892016-07-29 16:44:44 +0000289
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000290 /// getOperandLatency - Compute and return the use operand latency of a given
291 /// pair of def and use.
292 /// In most cases, the static scheduling itinerary was enough to determine the
293 /// operand latency. But it may not be possible for instructions with variable
294 /// number of defs / uses.
295 ///
296 /// This is a raw interface to the itinerary that may be directly overriden by
297 /// a target. Use computeOperandLatency to get the best estimate of latency.
298 int getOperandLatency(const InstrItineraryData *ItinData,
299 const MachineInstr &DefMI, unsigned DefIdx,
300 const MachineInstr &UseMI,
301 unsigned UseIdx) const override;
302
Krzysztof Parzyszek0ac065f2017-07-10 18:31:02 +0000303 /// Decompose the machine operand's target flags into two values - the direct
304 /// target flag value and any of bit flags that are applied.
305 std::pair<unsigned, unsigned>
306 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
307
308 /// Return an array that contains the direct target flag values and their
309 /// names.
310 ///
311 /// MIR Serialization is able to serialize only the target flags that are
312 /// defined by this method.
313 ArrayRef<std::pair<unsigned, const char *>>
314 getSerializableDirectMachineOperandTargetFlags() const override;
315
316 /// Return an array that contains the bitmask target flag values and their
317 /// names.
318 ///
319 /// MIR Serialization is able to serialize only the target flags that are
320 /// defined by this method.
321 ArrayRef<std::pair<unsigned, const char *>>
322 getSerializableBitmaskMachineOperandTargetFlags() const override;
323
Dean Michael Berris6d6addb2016-09-01 01:58:24 +0000324 bool isTailCall(const MachineInstr &MI) const override;
325
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000326 /// HexagonInstrInfo specifics.
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000327
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000328 unsigned createVR(MachineFunction* MF, MVT VT) const;
329
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000330 bool isAbsoluteSet(const MachineInstr &MI) const;
331 bool isAccumulator(const MachineInstr &MI) const;
332 bool isComplex(const MachineInstr &MI) const;
333 bool isCompoundBranchInstr(const MachineInstr &MI) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000334 bool isConstExtended(const MachineInstr &MI) const;
335 bool isDeallocRet(const MachineInstr &MI) const;
336 bool isDependent(const MachineInstr &ProdMI,
337 const MachineInstr &ConsMI) const;
338 bool isDotCurInst(const MachineInstr &MI) const;
339 bool isDotNewInst(const MachineInstr &MI) const;
340 bool isDuplexPair(const MachineInstr &MIa, const MachineInstr &MIb) const;
341 bool isEarlySourceInstr(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000342 bool isEndLoopN(unsigned Opcode) const;
343 bool isExpr(unsigned OpType) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000344 bool isExtendable(const MachineInstr &MI) const;
345 bool isExtended(const MachineInstr &MI) const;
346 bool isFloat(const MachineInstr &MI) const;
347 bool isHVXMemWithAIndirect(const MachineInstr &I,
348 const MachineInstr &J) const;
349 bool isIndirectCall(const MachineInstr &MI) const;
350 bool isIndirectL4Return(const MachineInstr &MI) const;
351 bool isJumpR(const MachineInstr &MI) const;
352 bool isJumpWithinBranchRange(const MachineInstr &MI, unsigned offset) const;
353 bool isLateInstrFeedsEarlyInstr(const MachineInstr &LRMI,
354 const MachineInstr &ESMI) const;
355 bool isLateResultInstr(const MachineInstr &MI) const;
356 bool isLateSourceInstr(const MachineInstr &MI) const;
357 bool isLoopN(const MachineInstr &MI) const;
358 bool isMemOp(const MachineInstr &MI) const;
359 bool isNewValue(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000360 bool isNewValue(unsigned Opcode) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000361 bool isNewValueInst(const MachineInstr &MI) const;
362 bool isNewValueJump(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000363 bool isNewValueJump(unsigned Opcode) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000364 bool isNewValueStore(const MachineInstr &MI) const;
Jyotsna Verma300f0b92013-05-10 20:27:34 +0000365 bool isNewValueStore(unsigned Opcode) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000366 bool isOperandExtended(const MachineInstr &MI, unsigned OperandNum) const;
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000367 bool isPredicatedNew(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000368 bool isPredicatedNew(unsigned Opcode) const;
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000369 bool isPredicatedTrue(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000370 bool isPredicatedTrue(unsigned Opcode) const;
371 bool isPredicated(unsigned Opcode) const;
372 bool isPredicateLate(unsigned Opcode) const;
373 bool isPredictedTaken(unsigned Opcode) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000374 bool isSaveCalleeSavedRegsCall(const MachineInstr &MI) const;
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000375 bool isSignExtendingLoad(const MachineInstr &MI) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000376 bool isSolo(const MachineInstr &MI) const;
377 bool isSpillPredRegOp(const MachineInstr &MI) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000378 bool isTC1(const MachineInstr &MI) const;
379 bool isTC2(const MachineInstr &MI) const;
380 bool isTC2Early(const MachineInstr &MI) const;
381 bool isTC4x(const MachineInstr &MI) const;
382 bool isToBeScheduledASAP(const MachineInstr &MI1,
383 const MachineInstr &MI2) const;
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000384 bool isHVXVec(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000385 bool isValidAutoIncImm(const EVT VT, const int Offset) const;
Krzysztof Parzyszek55772972017-09-15 15:46:05 +0000386 bool isValidOffset(unsigned Opcode, int Offset,
387 const TargetRegisterInfo *TRI, bool Extend = true) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000388 bool isVecAcc(const MachineInstr &MI) const;
389 bool isVecALU(const MachineInstr &MI) const;
390 bool isVecUsableNextPacket(const MachineInstr &ProdMI,
391 const MachineInstr &ConsMI) const;
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000392 bool isZeroExtendingLoad(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000393
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000394 bool addLatencyToSchedule(const MachineInstr &MI1,
395 const MachineInstr &MI2) const;
396 bool canExecuteInBundle(const MachineInstr &First,
397 const MachineInstr &Second) const;
Krzysztof Parzyszek1b689da2016-08-11 21:14:25 +0000398 bool doesNotReturn(const MachineInstr &CallMI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000399 bool hasEHLabel(const MachineBasicBlock *B) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000400 bool hasNonExtEquivalent(const MachineInstr &MI) const;
401 bool hasPseudoInstrPair(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000402 bool hasUncondBranch(const MachineBasicBlock *B) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000403 bool mayBeCurLoad(const MachineInstr &MI) const;
404 bool mayBeNewStore(const MachineInstr &MI) const;
405 bool producesStall(const MachineInstr &ProdMI,
406 const MachineInstr &ConsMI) const;
407 bool producesStall(const MachineInstr &MI,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000408 MachineBasicBlock::const_instr_iterator MII) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000409 bool predCanBeUsedAsDotNew(const MachineInstr &MI, unsigned PredReg) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000410 bool PredOpcodeHasJMP_c(unsigned Opcode) const;
411 bool predOpcodeHasNot(ArrayRef<MachineOperand> Cond) const;
412
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000413 short getAbsoluteForm(const MachineInstr &MI) const;
414 unsigned getAddrMode(const MachineInstr &MI) const;
415 unsigned getBaseAndOffset(const MachineInstr &MI, int &Offset,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000416 unsigned &AccessSize) const;
Krzysztof Parzyszekf5cbac92016-04-29 15:49:13 +0000417 short getBaseWithLongOffset(short Opcode) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000418 short getBaseWithLongOffset(const MachineInstr &MI) const;
419 short getBaseWithRegOffset(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000420 SmallVector<MachineInstr*,2> getBranchingInstrs(MachineBasicBlock& MBB) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000421 unsigned getCExtOpNum(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000422 HexagonII::CompoundGroup
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000423 getCompoundCandidateGroup(const MachineInstr &MI) const;
424 unsigned getCompoundOpcode(const MachineInstr &GA,
425 const MachineInstr &GB) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000426 int getCondOpcode(int Opc, bool sense) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000427 int getDotCurOp(const MachineInstr &MI) const;
Krzysztof Parzyszek0a8043e2017-05-03 15:28:56 +0000428 int getNonDotCurOp(const MachineInstr &MI) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000429 int getDotNewOp(const MachineInstr &MI) const;
430 int getDotNewPredJumpOp(const MachineInstr &MI,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000431 const MachineBranchProbabilityInfo *MBPI) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000432 int getDotNewPredOp(const MachineInstr &MI,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000433 const MachineBranchProbabilityInfo *MBPI) const;
Krzysztof Parzyszek143158b2017-03-06 17:03:16 +0000434 int getDotOldOp(const MachineInstr &MI) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000435 HexagonII::SubInstructionGroup getDuplexCandidateGroup(const MachineInstr &MI)
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000436 const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000437 short getEquivalentHWInstr(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000438 MachineInstr *getFirstNonDbgInst(MachineBasicBlock *BB) const;
439 unsigned getInstrTimingClassLatency(const InstrItineraryData *ItinData,
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000440 const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000441 bool getInvertedPredSense(SmallVectorImpl<MachineOperand> &Cond) const;
442 unsigned getInvertedPredicatedOpcode(const int Opc) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000443 int getMaxValue(const MachineInstr &MI) const;
444 unsigned getMemAccessSize(const MachineInstr &MI) const;
445 int getMinValue(const MachineInstr &MI) const;
446 short getNonExtOpcode(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000447 bool getPredReg(ArrayRef<MachineOperand> Cond, unsigned &PredReg,
448 unsigned &PredRegPos, unsigned &PredRegFlags) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000449 short getPseudoInstrPair(const MachineInstr &MI) const;
450 short getRegForm(const MachineInstr &MI) const;
451 unsigned getSize(const MachineInstr &MI) const;
452 uint64_t getType(const MachineInstr &MI) const;
453 unsigned getUnits(const MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000454
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000455 /// getInstrTimingClassLatency - Compute the instruction latency of a given
456 /// instruction using Timing Class information, if available.
457 unsigned nonDbgBBSize(const MachineBasicBlock *BB) const;
458 unsigned nonDbgBundleSize(MachineBasicBlock::const_iterator BundleHead) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000459
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000460 void immediateExtend(MachineInstr &MI) const;
461 bool invertAndChangeJumpTarget(MachineInstr &MI,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000462 MachineBasicBlock* NewTarget) const;
463 void genAllInsnTimingClasses(MachineFunction &MF) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000464 bool reversePredSense(MachineInstr &MI) const;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000465 unsigned reversePrediction(unsigned Opcode) const;
466 bool validateBranchCond(const ArrayRef<MachineOperand> &Cond) const;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000467 short xformRegToImmOffset(const MachineInstr &MI) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000468};
469
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +0000470} // end namespace llvm
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000471
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +0000472#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H