LLVM 24.0.0git
HexagonInstrInfo.h
Go to the documentation of this file.
1//===- HexagonInstrInfo.h - Hexagon Instruction Information -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the Hexagon implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
14#define LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
15
17#include "llvm/ADT/ArrayRef.h"
23#include <cstdint>
24#include <vector>
25
26#include "HexagonRegisterInfo.h"
27
28#define GET_INSTRINFO_HEADER
29#include "HexagonGenInstrInfo.inc"
30
31namespace llvm {
32
33class AAResults;
34class HexagonSubtarget;
35class MachineBranchProbabilityInfo;
36class MachineFunction;
37class MachineInstr;
38class MachineOperand;
39class TargetRegisterInfo;
40
42 const HexagonRegisterInfo RegInfo;
43 const HexagonSubtarget &Subtarget;
44
45 enum BundleAttribute {
46 memShufDisabledMask = 0x4
47 };
48
49 virtual void anchor();
50
51public:
52 explicit HexagonInstrInfo(const HexagonSubtarget &ST);
53
54 const HexagonRegisterInfo &getRegisterInfo() const { return RegInfo; }
55
57 InlineAsm::ConstraintCode C) const override {
58 return &Hexagon::IntRegsRegClass;
59 }
60
61 bool isMIBefore(const MachineInstr *A, const MachineInstr *B) const;
62
63 /// Copies the debug values of the variables that read the register First and
64 /// Second define to just after \p Second, in their original order, and sets
65 /// each dependent original undef. If a copy would read a value that changes
66 /// in between, nothing is copied and only the originals are set undef.
67 ///
68 /// Call this before the replacement for First and Second is created, and
69 /// insert the replacement before \p Second. The replacement must not write a
70 /// register the copies read, unless First or Second writes it too.
72 MachineInstr &Second) const;
73
74 bool hasQFPInstrs(const MachineFunction &MF) const;
75
76 /// TargetInstrInfo overrides.
77
78 /// If the specified machine instruction is a direct
79 /// load from a stack slot, return the virtual or physical register number of
80 /// the destination along with the FrameIndex of the loaded stack slot. If
81 /// not, return 0. This predicate must return 0 if the instruction has
82 /// any side effects other than loading from the stack slot.
84 int &FrameIndex) const override;
85
86 /// If the specified machine instruction is a direct
87 /// store to a stack slot, return the virtual or physical register number of
88 /// the source reg along with the FrameIndex of the loaded stack slot. If
89 /// not, return 0. This predicate must return 0 if the instruction has
90 /// any side effects other than storing to the stack slot.
92 int &FrameIndex) const override;
93
94 /// Check if the instruction or the bundle of instructions has
95 /// load from stack slots. Return the frameindex and machine memory operand
96 /// if true.
98 const MachineInstr &MI,
100
101 /// Check if the instruction or the bundle of instructions has
102 /// store to stack slots. Return the frameindex and machine memory operand
103 /// if true.
105 const MachineInstr &MI,
107
109
110 /// Analyze the branching code at the end of MBB, returning
111 /// true if it cannot be understood (e.g. it's a switch dispatch or isn't
112 /// implemented for a target). Upon success, this returns false and returns
113 /// with the following information in various cases:
114 ///
115 /// 1. If this block ends with no branches (it just falls through to its succ)
116 /// just return false, leaving TBB/FBB null.
117 /// 2. If this block ends with only an unconditional branch, it sets TBB to be
118 /// the destination block.
119 /// 3. If this block ends with a conditional branch and it falls through to a
120 /// successor block, it sets TBB to be the branch destination block and a
121 /// list of operands that evaluate the condition. These operands can be
122 /// passed to other TargetInstrInfo methods to create new branches.
123 /// 4. If this block ends with a conditional branch followed by an
124 /// unconditional branch, it returns the 'true' destination in TBB, the
125 /// 'false' destination in FBB, and a list of operands that evaluate the
126 /// condition. These operands can be passed to other TargetInstrInfo
127 /// methods to create new branches.
128 ///
129 /// Note that removeBranch and insertBranch must be implemented to support
130 /// cases where this method returns success.
131 ///
132 /// If AllowModify is true, then this routine is allowed to modify the basic
133 /// block (e.g. delete instructions after the unconditional branch).
135 MachineBasicBlock *&FBB,
137 bool AllowModify) const override;
138
139 /// Remove the branching code at the end of the specific MBB.
140 /// This is only invoked in cases where analyzeBranch returns success. It
141 /// returns the number of instructions that were removed.
143 int *BytesRemoved = nullptr) const override;
144
145 /// Insert branch code into the end of the specified MachineBasicBlock.
146 /// The operands to this method are the same as those
147 /// returned by analyzeBranch. This is only invoked in cases where
148 /// analyzeBranch returns success. It returns the number of instructions
149 /// inserted.
150 ///
151 /// It is also invoked by tail merging to add unconditional branches in
152 /// cases where analyzeBranch doesn't apply because there was no original
153 /// branch to analyze. At least this much must be implemented, else tail
154 /// merging needs to be disabled.
157 const DebugLoc &DL,
158 int *BytesAdded = nullptr) const override;
159
160 /// Analyze loop L, which must be a single-basic-block loop, and if the
161 /// conditions can be understood enough produce a PipelinerLoopInfo object.
162 std::unique_ptr<PipelinerLoopInfo>
163 analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override;
164
165 /// Return true if it's profitable to predicate
166 /// instructions with accumulated instruction latency of "NumCycles"
167 /// of the specified basic block, where the probability of the instructions
168 /// being executed is given by Probability, and Confidence is a measure
169 /// of our confidence that it will be properly predicted.
170 bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
171 unsigned ExtraPredCycles,
172 BranchProbability Probability) const override;
173
174 /// Second variant of isProfitableToIfCvt. This one
175 /// checks for the case where two basic blocks from true and false path
176 /// of a if-then-else (diamond) are predicated on mutually exclusive
177 /// predicates, where the probability of the true path being taken is given
178 /// by Probability, and Confidence is a measure of our confidence that it
179 /// will be properly predicted.
181 unsigned NumTCycles, unsigned ExtraTCycles,
182 MachineBasicBlock &FMBB,
183 unsigned NumFCycles, unsigned ExtraFCycles,
184 BranchProbability Probability) const override;
185
186 /// Return true if it's profitable for if-converter to duplicate instructions
187 /// of specified accumulated instruction latencies in the specified MBB to
188 /// enable if-conversion.
189 /// The probability of the instructions being executed is given by
190 /// Probability, and Confidence is a measure of our confidence that it
191 /// will be properly predicted.
192 bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
193 BranchProbability Probability) const override;
194
195 /// Emit instructions to copy a pair of physical registers.
196 ///
197 /// This function should support copies within any legal register class as
198 /// well as any cross-class copies created during instruction selection.
199 ///
200 /// The source and destination registers may overlap, which may require a
201 /// careful implementation when multiple copy instructions are required for
202 /// large registers. See for example the ARM target.
204 const DebugLoc &DL, Register DestReg, Register SrcReg,
205 bool KillSrc, bool RenamableDest = false,
206 bool RenamableSrc = false) const override;
207
208 /// Store the specified register of the given register class to the specified
209 /// stack frame index. The store instruction is to be added to the given
210 /// machine basic block before the specified machine instruction. If isKill
211 /// is true, the register operand is the last use and must be marked kill.
214 bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg,
215 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
216
217 /// Load the specified register of the given register class from the specified
218 /// stack frame index. The load instruction is to be added to the given
219 /// machine basic block before the specified machine instruction.
222 Register DestReg, int FrameIndex, const TargetRegisterClass *RC,
223 Register VReg, unsigned SubReg = 0,
224 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
225
226 /// This function is called for all pseudo instructions
227 /// that remain after register allocation. Many pseudo instructions are
228 /// created to help register allocation. This is the place to convert them
229 /// into real instructions. The target can edit MI in place, or it can insert
230 /// new instructions and erase MI. The function should return true if
231 /// anything was changed.
232 bool expandPostRAPseudo(MachineInstr &MI) const override;
233
234 /// Get the base register and byte offset of a load/store instr.
236 const MachineInstr &LdSt,
238 bool &OffsetIsScalable, LocationSize &Width) const override;
239
240 /// Reverses the branch condition of the specified condition list,
241 /// returning false on success and true if it cannot be reversed.
243 const override;
244
245 /// Insert a noop into the instruction stream at the specified point.
247 MachineBasicBlock::iterator MI) const override;
248
249 /// Returns true if the instruction is already predicated.
250 bool isPredicated(const MachineInstr &MI) const override;
251
252 /// Return true for post-incremented instructions.
253 bool isPostIncrement(const MachineInstr &MI) const override;
254 bool isPostIncWithImmOffset(const MachineInstr &MI) const;
255
256 /// Convert the instruction into a predicated instruction.
257 /// It returns true if the operation was successful.
259 ArrayRef<MachineOperand> Cond) const override;
260
261 /// Returns true if the first specified predicate
262 /// subsumes the second, e.g. GE subsumes GT.
264 ArrayRef<MachineOperand> Pred2) const override;
265
266 /// If the specified instruction defines any predicate
267 /// or condition code register(s) used for predication, returns true as well
268 /// as the definition predicate(s) by reference.
269 bool ClobbersPredicate(MachineInstr &MI, std::vector<MachineOperand> &Pred,
270 bool SkipDead) const override;
271
272 /// Return true if the specified instruction can be predicated.
273 /// By default, this returns true for every instruction with a
274 /// PredicateOperand.
275 bool isPredicable(const MachineInstr &MI) const override;
276
277 /// Test if the given instruction should be considered a scheduling boundary.
278 /// This primarily includes labels and terminators.
280 const MachineBasicBlock *MBB,
281 const MachineFunction &MF) const override;
282
283 /// Measure the specified inline asm to determine an approximation of its
284 /// length.
285 unsigned getInlineAsmLength(
286 const char *Str,
287 const MCAsmInfo &MAI,
288 const TargetSubtargetInfo *STI = nullptr) const override;
289
290 /// Allocate and return a hazard recognizer to use for this target when
291 /// scheduling the machine instructions after register allocation.
294 const ScheduleDAG *DAG) const override;
295
296 /// For a comparison instruction, return the source registers
297 /// in SrcReg and SrcReg2 if having two register operands, and the value it
298 /// compares against in CmpValue. Return true if the comparison instruction
299 /// can be analyzed.
300 bool analyzeCompare(const MachineInstr &MI, Register &SrcReg,
301 Register &SrcReg2, int64_t &Mask,
302 int64_t &Value) const override;
303
304 /// Compute the instruction latency of a given instruction.
305 /// If the instruction has higher cost when predicated, it's returned via
306 /// PredCost.
307 unsigned getInstrLatency(const InstrItineraryData *ItinData,
308 const MachineInstr &MI,
309 unsigned *PredCost = nullptr) const override;
310
311 /// Create machine specific model for scheduling.
313 CreateTargetScheduleState(const TargetSubtargetInfo &STI) const override;
314
315 // Sometimes, it is possible for the target
316 // to tell, even without aliasing information, that two MIs access different
317 // memory addresses. This function returns true if two MIs access different
318 // memory addresses and false otherwise.
319 bool
321 const MachineInstr &MIb) const override;
322
323 /// Return true if the memory accesses of \p MIa and \p MIb may depend on
324 /// each other. Uses \p AA, if not null, for accesses that are not
325 /// trivially disjoint.
327 const MachineInstr *MIb) const;
328
329 /// For instructions with a base and offset, return the position of the
330 /// base register and offset operands.
331 bool getBaseAndOffsetPosition(const MachineInstr &MI, unsigned &BasePos,
332 unsigned &OffsetPos) const override;
333
334 /// If the instruction is an increment of a constant value, return the amount.
335 bool getIncrementValue(const MachineInstr &MI, int &Value) const override;
336
337 /// getOperandLatency - Compute and return the use operand latency of a given
338 /// pair of def and use.
339 /// In most cases, the static scheduling itinerary was enough to determine the
340 /// operand latency. But it may not be possible for instructions with variable
341 /// number of defs / uses.
342 ///
343 /// This is a raw interface to the itinerary that may be directly overridden
344 /// by a target. Use computeOperandLatency to get the best estimate of
345 /// latency.
346 std::optional<unsigned> getOperandLatency(const InstrItineraryData *ItinData,
347 const MachineInstr &DefMI,
348 unsigned DefIdx,
349 const MachineInstr &UseMI,
350 unsigned UseIdx) const override;
351
352 /// Decompose the machine operand's target flags into two values - the direct
353 /// target flag value and any of bit flags that are applied.
354 std::pair<unsigned, unsigned>
355 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
356
357 /// Return an array that contains the direct target flag values and their
358 /// names.
359 ///
360 /// MIR Serialization is able to serialize only the target flags that are
361 /// defined by this method.
364
365 /// Return an array that contains the bitmask target flag values and their
366 /// names.
367 ///
368 /// MIR Serialization is able to serialize only the target flags that are
369 /// defined by this method.
372
373 bool isTailCall(const MachineInstr &MI) const override;
374 bool isAsCheapAsAMove(const MachineInstr &MI) const override;
375
376 // Return true if the instruction should be sunk by MachineSink.
377 // MachineSink determines on its own whether the instruction is safe to sink;
378 // this gives the target a hook to override the default behavior with regards
379 // to which instructions should be sunk.
380 bool shouldSink(const MachineInstr &MI) const override;
381
382 /// HexagonInstrInfo specifics.
383
384 Register createVR(MachineFunction *MF, MVT VT) const;
385 MachineInstr *findLoopInstr(MachineBasicBlock *BB, unsigned EndLoopOp,
386 MachineBasicBlock *TargetBB,
388
389 bool isAbsoluteSet(const MachineInstr &MI) const;
390 bool isAccumulator(const MachineInstr &MI) const;
391 bool isAddrModeWithOffset(const MachineInstr &MI) const;
392 bool isBaseImmOffset(const MachineInstr &MI) const;
393 bool isComplex(const MachineInstr &MI) const;
394 bool isCompoundBranchInstr(const MachineInstr &MI) const;
395 bool isConstExtended(const MachineInstr &MI) const;
396 bool isDeallocRet(const MachineInstr &MI) const;
397 bool isDependent(const MachineInstr &ProdMI,
398 const MachineInstr &ConsMI) const;
399 bool isDotCurInst(const MachineInstr &MI) const;
400 bool isDotCurOperand(const MachineInstr &MI, unsigned OpIndex) const;
401 bool isDotNewOperand(const MachineInstr &MI, unsigned OpIndex) const;
402 bool isDotTmpInst(const MachineInstr &MI) const;
403 bool isDotTmpOperand(const MachineInstr &MI, unsigned OpIndex) const;
404 /// A use (\p UseMI) can share a bundle with an instruction that redefines the
405 /// same register (\p DefMI), the use still sees the old value (WAR).
406 /// Returns true when that holds: no operand forwarding (.new/.tmp/.cur)
407 /// exposes the new value. Caller ensures same-bundle intent. \p IsPullDown
408 /// (push-down) is not yet supported and always returns false.
409 /// \p DefViaRegMask = true when the def is a regmask clobber (no operand):
410 /// such a def never forwards, so the def-side operand checks are skipped.
411 bool isSafeInBundleWAR(const MachineInstr &DefMI, unsigned DefOpIdx,
412 const MachineInstr &UseMI, unsigned UseOpIdx,
413 bool IsPullDown = false,
414 bool DefViaRegMask = false) const;
415 bool isDotNewInst(const MachineInstr &MI) const;
416 bool isDuplexPair(const MachineInstr &MIa, const MachineInstr &MIb) const;
417 bool isHMXActivateInstr(const MachineInstr &MI) const;
418 bool isHMXWeightInstr(const MachineInstr &MI) const;
419 bool isActivateWeightPair(const MachineInstr &MIa,
420 const MachineInstr &MIb) const;
421 bool isEndLoopN(unsigned Opcode) const;
422 bool isExpr(unsigned OpType) const;
423 bool isExtendable(const MachineInstr &MI) const;
424 bool isExtended(const MachineInstr &MI) const;
425 bool isFloat(const MachineInstr &MI) const;
427 const MachineInstr &J) const;
428 bool isIndirectCall(const MachineInstr &MI) const;
429 bool isIndirectL4Return(const MachineInstr &MI) const;
430 bool isJumpR(const MachineInstr &MI) const;
431 bool isJumpWithinBranchRange(const MachineInstr &MI, unsigned offset) const;
432 bool isLateSourceInstr(const MachineInstr &MI) const;
433 bool isLoopN(const MachineInstr &MI) const;
434 bool isMemOp(const MachineInstr &MI) const;
435 bool isNewValue(const MachineInstr &MI) const;
436 bool isNewValue(unsigned Opcode) const;
437 bool isNewValueInst(const MachineInstr &MI) const;
438 bool isNewValueJump(const MachineInstr &MI) const;
439 bool isNewValueJump(unsigned Opcode) const;
440 bool isNewValueStore(const MachineInstr &MI) const;
441 bool isNewValueStore(unsigned Opcode) const;
442 bool isOperandExtended(const MachineInstr &MI, unsigned OperandNum) const;
443 bool isPredicatedNew(const MachineInstr &MI) const;
444 bool isPredicatedNew(unsigned Opcode) const;
445 bool isPredicatedTrue(const MachineInstr &MI) const;
446 bool isPredicatedTrue(unsigned Opcode) const;
447 bool isPredicated(unsigned Opcode) const;
448 bool isPredicateLate(unsigned Opcode) const;
449 bool isPredictedTaken(unsigned Opcode) const;
450 bool isPureSlot0(const MachineInstr &MI) const;
451 bool isRestrictNoSlot1Store(const MachineInstr &MI) const;
452 bool isSaveCalleeSavedRegsCall(const MachineInstr &MI) const;
453 bool isSignExtendingLoad(const MachineInstr &MI) const;
454 bool isSolo(const MachineInstr &MI) const;
455 bool isSpillPredRegOp(const MachineInstr &MI) const;
456 bool isTC1(const MachineInstr &MI) const;
457 bool isTC2(const MachineInstr &MI) const;
458 bool isTC2Early(const MachineInstr &MI) const;
459 bool isTC4x(const MachineInstr &MI) const;
460 bool isToBeScheduledASAP(const MachineInstr &MI1,
461 const MachineInstr &MI2) const;
462 bool isHVXVec(const MachineInstr &MI) const;
463 bool isHLXVec(const MachineInstr &MI) const;
464 bool isValidAutoIncImm(const EVT VT, const int Offset) const;
465 bool isValidOffset(unsigned Opcode, int Offset, bool Extend = true) const;
466 bool isVecAcc(const MachineInstr &MI) const;
467 bool isVecALU(const MachineInstr &MI) const;
468 bool isVecUsableNextPacket(const MachineInstr &ProdMI,
469 const MachineInstr &ConsMI) const;
470 bool isZeroExtendingLoad(const MachineInstr &MI) const;
471
472 bool addLatencyToSchedule(const MachineInstr &MI1,
473 const MachineInstr &MI2) const;
475 const MachineInstr &Second) const;
476 bool doesNotReturn(const MachineInstr &CallMI) const;
477 bool hasEHLabel(const MachineBasicBlock *B) const;
478 bool hasNonExtEquivalent(const MachineInstr &MI) const;
479 bool hasUncondBranch(const MachineBasicBlock *B) const;
480 bool mayBeCurLoad(const MachineInstr &MI) const;
481 bool mayBeNewStore(const MachineInstr &MI) const;
482 // Identify HLX pseudos that expand to a tmp load or new store and a copy.
483 bool isTmpLoadPseudo(const MachineInstr &MI) const;
484 bool isNewStorePseudo(const MachineInstr &MI) const;
485 bool producesStall(const MachineInstr &ProdMI,
486 const MachineInstr &ConsMI) const;
487 bool producesStall(const MachineInstr &MI,
489 bool predCanBeUsedAsDotNew(const MachineInstr &MI, Register PredReg) const;
490 bool PredOpcodeHasJMP_c(unsigned Opcode) const;
492
493 unsigned getAddrMode(const MachineInstr &MI) const;
495 LocationSize &AccessSize) const;
497 unsigned getCExtOpNum(const MachineInstr &MI) const;
500 unsigned getCompoundOpcode(const MachineInstr &GA,
501 const MachineInstr &GB) const;
502 int getDuplexOpcode(const MachineInstr &MI, bool ForBigCore = true) const;
503 int getCondOpcode(int Opc, bool sense) const;
504 int getDotCurOp(const MachineInstr &MI) const;
505 int getNonDotCurOp(const MachineInstr &MI) const;
506 int getDotNewOp(const MachineInstr &MI) const;
508 const MachineBranchProbabilityInfo *MBPI) const;
510 const MachineBranchProbabilityInfo *MBPI) const;
511 int getDotOldOp(const MachineInstr &MI) const;
514 unsigned getInstrTimingClassLatency(const InstrItineraryData *ItinData,
515 const MachineInstr &MI) const;
517 unsigned getInvertedPredicatedOpcode(const int Opc) const;
518 int getMaxValue(const MachineInstr &MI) const;
519 unsigned getMemAccessSize(const MachineInstr &MI) const;
520 int getMinValue(const MachineInstr &MI) const;
521 short getNonExtOpcode(const MachineInstr &MI) const;
523 unsigned &PredRegPos, RegState &PredRegFlags) const;
524 short getRegForm(const MachineInstr &MI) const;
525 unsigned getSize(const MachineInstr &MI) const;
526 uint64_t getType(const MachineInstr &MI) const;
528
530
531 /// getInstrTimingClassLatency - Compute the instruction latency of a given
532 /// instruction using Timing Class information, if available.
533 unsigned nonDbgBBSize(const MachineBasicBlock *BB) const;
534 unsigned nonDbgBundleSize(MachineBasicBlock::const_iterator BundleHead) const;
535
536 void immediateExtend(MachineInstr &MI) const;
538 MachineBasicBlock *NewTarget) const;
540 bool reversePredSense(MachineInstr &MI) const;
541 unsigned reversePrediction(unsigned Opcode) const;
543
545 bool getBundleNoShuf(const MachineInstr &MIB) const;
546
547 // When TinyCore with Duplexes is enabled, this function is used to translate
548 // tiny-instructions to big-instructions and vice versa to get the slot
549 // consumption.
551 bool ToBigInstrs) const;
553 bool ToBigInstrs = true) const;
555 bool ToBigInstrs) const;
556 bool useMachineCombiner() const override { return true; }
558 bool Invert) const override;
559
560 // Addressing mode relations.
561 short changeAddrMode_abs_io(short Opc) const;
562 short changeAddrMode_io_abs(short Opc) const;
563 short changeAddrMode_io_pi(short Opc) const;
564 short changeAddrMode_io_rr(short Opc) const;
565 short changeAddrMode_pi_io(short Opc) const;
566 short changeAddrMode_rr_io(short Opc) const;
567 short changeAddrMode_rr_ur(short Opc) const;
568 short changeAddrMode_ur_rr(short Opc) const;
569
571 return changeAddrMode_abs_io(MI.getOpcode());
572 }
574 return changeAddrMode_io_abs(MI.getOpcode());
575 }
577 return changeAddrMode_io_rr(MI.getOpcode());
578 }
580 return changeAddrMode_rr_io(MI.getOpcode());
581 }
583 return changeAddrMode_rr_ur(MI.getOpcode());
584 }
586 return changeAddrMode_ur_rr(MI.getOpcode());
587 }
588
589 MCInst getNop() const override;
590 bool isQFPMul(const MachineInstr *MF) const;
591
592 // Check if the instruction uses a qf32/qf16 operand.
593 // 'Index' specifies the input operand number (1..3). If 0, check any.
594 bool usesQF32Operand(MachineInstr *MI, unsigned Index = 0) const;
595 bool usesQF16Operand(MachineInstr *MI, unsigned Index = 0) const;
596 bool usesQFOperand(MachineInstr *MI, unsigned Index = 0) const;
597
598 // Check if the instruction has a qf32/qf16 output.
599 bool isQFP32Instr(MachineInstr *MI) const;
600 bool isQFP16Instr(MachineInstr *MI) const;
601 bool isQFPInstr(MachineInstr *MI) const;
602};
603
604/// \brief Create RegSubRegPair from a register MachineOperand
605inline TargetInstrInfo::RegSubRegPair
606getRegSubRegPair(const MachineOperand &O) {
607 assert(O.isReg());
608 return TargetInstrInfo::RegSubRegPair(O.getReg(), O.getSubReg());
609}
610
611} // end namespace llvm
612
613#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONINSTRINFO_H
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
SDValue Pred
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DXIL Forward Handle Accesses
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
uint64_t IntrinsicInst * II
SmallVector< MachineOperand, 4 > Cond
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A debug info location.
Definition DebugLoc.h:127
bool isTmpLoadPseudo(const MachineInstr &MI) const
int getDuplexOpcode(const MachineInstr &MI, bool ForBigCore=true) const
bool isHLXVec(const MachineInstr &MI) const
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Remove the branching code at the end of the specific MBB.
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
bool isHVXMemWithAIndirect(const MachineInstr &I, const MachineInstr &J) const
short changeAddrMode_abs_io(short Opc) const
bool isRestrictNoSlot1Store(const MachineInstr &MI) const
short getRegForm(const MachineInstr &MI) const
bool isVecALU(const MachineInstr &MI) const
bool isCompoundBranchInstr(const MachineInstr &MI) const
bool isDuplexPair(const MachineInstr &MIa, const MachineInstr &MIb) const
Symmetrical. See if these two instructions are fit for duplex pair.
bool isJumpR(const MachineInstr &MI) const
ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, const ScheduleDAG *DAG) const override
Allocate and return a hazard recognizer to use for this target when scheduling the machine instructio...
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
Decompose the machine operand's target flags into two values - the direct target flag value and any o...
bool getMemOperandsWithOffsetWidth(const MachineInstr &LdSt, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width) const override
Get the base register and byte offset of a load/store instr.
bool producesStall(const MachineInstr &ProdMI, const MachineInstr &ConsMI) const
bool invertAndChangeJumpTarget(MachineInstr &MI, MachineBasicBlock *NewTarget) const
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
Store the specified register of the given register class to the specified stack frame index.
bool isDotTmpInst(const MachineInstr &MI) const
bool isPredictedTaken(unsigned Opcode) const
bool isSaveCalleeSavedRegsCall(const MachineInstr &MI) const
bool hasQFPInstrs(const MachineFunction &MF) const
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
TargetInstrInfo overrides.
unsigned nonDbgBundleSize(MachineBasicBlock::const_iterator BundleHead) const
int getDotNewPredOp(const MachineInstr &MI, const MachineBranchProbabilityInfo *MBPI) const
bool isQFP32Instr(MachineInstr *MI) const
bool ClobbersPredicate(MachineInstr &MI, std::vector< MachineOperand > &Pred, bool SkipDead) const override
If the specified instruction defines any predicate or condition code register(s) used for predication...
unsigned getInvertedPredicatedOpcode(const int Opc) const
bool isPureSlot0(const MachineInstr &MI) const
bool doesNotReturn(const MachineInstr &CallMI) const
HexagonII::SubInstructionGroup getDuplexCandidateGroup(const MachineInstr &MI) const
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
bool usesQF16Operand(MachineInstr *MI, unsigned Index=0) const
bool isPredicatedNew(const MachineInstr &MI) const
bool isSignExtendingLoad(const MachineInstr &MI) const
bool isVecAcc(const MachineInstr &MI) const
bool reversePredSense(MachineInstr &MI) const
bool isPostIncWithImmOffset(const MachineInstr &MI) const
bool isQFPMul(const MachineInstr *MF) const
unsigned getAddrMode(const MachineInstr &MI) const
MCInst getNop() const override
bool isJumpWithinBranchRange(const MachineInstr &MI, unsigned offset) const
bool mayBeNewStore(const MachineInstr &MI) const
short changeAddrMode_rr_ur(const MachineInstr &MI) const
bool isOperandExtended(const MachineInstr &MI, unsigned OperandNum) const
bool canExecuteInBundle(const MachineInstr &First, const MachineInstr &Second) const
Can these instructions execute at the same time in a bundle.
bool isQFP16Instr(MachineInstr *MI) const
std::optional< unsigned > getOperandLatency(const InstrItineraryData *ItinData, const MachineInstr &DefMI, unsigned DefIdx, const MachineInstr &UseMI, unsigned UseIdx) const override
getOperandLatency - Compute and return the use operand latency of a given pair of def and use.
bool isAddrModeWithOffset(const MachineInstr &MI) const
bool isBaseImmOffset(const MachineInstr &MI) const
bool isAbsoluteSet(const MachineInstr &MI) const
short changeAddrMode_io_pi(short Opc) const
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
Emit instructions to copy a pair of physical registers.
const HexagonRegisterInfo & getRegisterInfo() const
short changeAddrMode_pi_io(short Opc) const
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg, Register &SrcReg2, int64_t &Mask, int64_t &Value) const override
For a comparison instruction, return the source registers in SrcReg and SrcReg2 if having two registe...
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
Reverses the branch condition of the specified condition list, returning false on success and true if...
std::unique_ptr< PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
Analyze loop L, which must be a single-basic-block loop, and if the conditions can be understood enou...
bool isLoopN(const MachineInstr &MI) const
bool isSpillPredRegOp(const MachineInstr &MI) const
bool hasStoreToStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand * > &Accesses) const override
Check if the instruction or the bundle of instructions has store to stack slots.
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
Return an array that contains the direct target flag values and their names.
bool useMachineCombiner() const override
bool isIndirectCall(const MachineInstr &MI) const
short changeAddrMode_ur_rr(short Opc) const
bool isValidAutoIncImm(const EVT VT, const int Offset) const
bool hasNonExtEquivalent(const MachineInstr &MI) const
bool isConstExtended(const MachineInstr &MI) const
bool getIncrementValue(const MachineInstr &MI, int &Value) const override
If the instruction is an increment of a constant value, return the amount.
int getCondOpcode(int Opc, bool sense) const
void moveDependentDebugValues(MachineInstr &First, MachineInstr &Second) const
Copies the debug values of the variables that read the register First and Second define to just after...
MachineInstr * findLoopInstr(MachineBasicBlock *BB, unsigned EndLoopOp, MachineBasicBlock *TargetBB, SmallPtrSet< MachineBasicBlock *, 8 > &Visited) const
Find the hardware loop instruction used to set-up the specified loop.
unsigned getInstrTimingClassLatency(const InstrItineraryData *ItinData, const MachineInstr &MI) const
bool usesQF32Operand(MachineInstr *MI, unsigned Index=0) const
bool isAccumulator(const MachineInstr &MI) const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
Insert branch code into the end of the specified MachineBasicBlock.
unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const override
Compute the instruction latency of a given instruction.
bool PredOpcodeHasJMP_c(unsigned Opcode) const
bool isNewValue(const MachineInstr &MI) const
Register createVR(MachineFunction *MF, MVT VT) const
HexagonInstrInfo specifics.
bool isDotCurInst(const MachineInstr &MI) const
bool validateBranchCond(const ArrayRef< MachineOperand > &Cond) const
bool areMemAccessesDependent(AAResults *AA, const MachineInstr *MIa, const MachineInstr *MIb) const
Return true if the memory accesses of MIa and MIb may depend on each other.
bool isExtended(const MachineInstr &MI) const
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
Return true if it's profitable to predicate instructions with accumulated instruction latency of "Num...
bool isAsCheapAsAMove(const MachineInstr &MI) const override
int getMaxValue(const MachineInstr &MI) const
bool isPredicateLate(unsigned Opcode) const
short changeAddrMode_rr_ur(short Opc) const
bool isNewValueInst(const MachineInstr &MI) const
bool isHMXWeightInstr(const MachineInstr &MI) const
unsigned getInlineAsmLength(const char *Str, const MCAsmInfo &MAI, const TargetSubtargetInfo *STI=nullptr) const override
Measure the specified inline asm to determine an approximation of its length.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
int getNonDotCurOp(const MachineInstr &MI) const
bool isIndirectL4Return(const MachineInstr &MI) const
unsigned reversePrediction(unsigned Opcode) const
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
Return an array that contains the bitmask target flag values and their names.
bool isAssociativeAndCommutative(const MachineInstr &Inst, bool Invert) const override
short changeAddrMode_rr_io(const MachineInstr &MI) const
InstrStage::FuncUnits getUnits(const MachineInstr &MI) const
short changeAddrMode_ur_rr(const MachineInstr &MI) const
unsigned getMemAccessSize(const MachineInstr &MI) const
bool predOpcodeHasNot(ArrayRef< MachineOperand > Cond) const
bool isComplex(const MachineInstr &MI) const
bool isPostIncrement(const MachineInstr &MI) const override
Return true for post-incremented instructions.
void setBundleNoShuf(MachineBasicBlock::instr_iterator MIB) const
short changeAddrMode_io_abs(const MachineInstr &MI) const
MachineBasicBlock::instr_iterator expandVGatherPseudo(MachineInstr &MI) const
bool isDotCurOperand(const MachineInstr &MI, unsigned OpIndex) const
Returns true if the specified operand is a .cur (current) operand.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
Load the specified register of the given register class from the specified stack frame index.
int getDotNewOp(const MachineInstr &MI) const
void changeDuplexOpcode(MachineBasicBlock::instr_iterator MII, bool ToBigInstrs) const
bool isMemOp(const MachineInstr &MI) const
int getDotOldOp(const MachineInstr &MI) const
bool hasUncondBranch(const MachineBasicBlock *B) const
short getNonExtOpcode(const MachineInstr &MI) const
bool isNewStorePseudo(const MachineInstr &MI) const
bool isTailCall(const MachineInstr &MI) const override
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
Insert a noop into the instruction stream at the specified point.
bool isDeallocRet(const MachineInstr &MI) const
HexagonInstrInfo(const HexagonSubtarget &ST)
unsigned getCExtOpNum(const MachineInstr &MI) const
bool isSolo(const MachineInstr &MI) const
DFAPacketizer * CreateTargetScheduleState(const TargetSubtargetInfo &STI) const override
Create machine specific model for scheduling.
bool isLateSourceInstr(const MachineInstr &MI) const
bool isDotNewInst(const MachineInstr &MI) const
void translateInstrsForDup(MachineFunction &MF, bool ToBigInstrs=true) const
bool isTC1(const MachineInstr &MI) const
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
Test if the given instruction should be considered a scheduling boundary.
bool predCanBeUsedAsDotNew(const MachineInstr &MI, Register PredReg) const
unsigned getSize(const MachineInstr &MI) const
bool isDotNewOperand(const MachineInstr &MI, unsigned OpIndex) const
Should be able to tell if the operand in question is .new.
bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, BranchProbability Probability) const override
Return true if it's profitable for if-converter to duplicate instructions of specified accumulated in...
short changeAddrMode_io_abs(short Opc) const
int getDotCurOp(const MachineInstr &MI) const
bool expandPostRAPseudo(MachineInstr &MI) const override
This function is called for all pseudo instructions that remain after register allocation.
bool isMIBefore(const MachineInstr *A, const MachineInstr *B) const
bool isExpr(unsigned OpType) const
bool isSafeInBundleWAR(const MachineInstr &DefMI, unsigned DefOpIdx, const MachineInstr &UseMI, unsigned UseOpIdx, bool IsPullDown=false, bool DefViaRegMask=false) const
A use (UseMI) can share a bundle with an instruction that redefines the same register (DefMI),...
void genAllInsnTimingClasses(MachineFunction &MF) const
bool isTC2Early(const MachineInstr &MI) const
bool hasEHLabel(const MachineBasicBlock *B) const
bool shouldSink(const MachineInstr &MI) const override
bool isZeroExtendingLoad(const MachineInstr &MI) const
short changeAddrMode_rr_io(short Opc) const
bool isHVXVec(const MachineInstr &MI) const
bool isDotTmpOperand(const MachineInstr &MI, unsigned OpIndex) const
Returns true if the specified operand is a .tmp (temporary) operand.
bool isDependent(const MachineInstr &ProdMI, const MachineInstr &ConsMI) const
short changeAddrMode_io_rr(short Opc) const
bool SubsumesPredicate(ArrayRef< MachineOperand > Pred1, ArrayRef< MachineOperand > Pred2) const override
Returns true if the first specified predicate subsumes the second, e.g.
bool mayBeCurLoad(const MachineInstr &MI) const
bool getBundleNoShuf(const MachineInstr &MIB) const
bool isNewValueJump(const MachineInstr &MI) const
bool isTC4x(const MachineInstr &MI) const
bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Cond) const override
Convert the instruction into a predicated instruction.
bool getPredReg(ArrayRef< MachineOperand > Cond, Register &PredReg, unsigned &PredRegPos, RegState &PredRegFlags) const
bool isFloat(const MachineInstr &MI) const
bool isQFPInstr(MachineInstr *MI) const
bool isToBeScheduledASAP(const MachineInstr &MI1, const MachineInstr &MI2) const
MachineOperand * getBaseAndOffset(const MachineInstr &MI, int64_t &Offset, LocationSize &AccessSize) const
bool getInvertedPredSense(SmallVectorImpl< MachineOperand > &Cond) const
unsigned nonDbgBBSize(const MachineBasicBlock *BB) const
getInstrTimingClassLatency - Compute the instruction latency of a given instruction using Timing Clas...
uint64_t getType(const MachineInstr &MI) const
bool isEndLoopN(unsigned Opcode) const
bool getBaseAndOffsetPosition(const MachineInstr &MI, unsigned &BasePos, unsigned &OffsetPos) const override
For instructions with a base and offset, return the position of the base register and offset operands...
bool isPredicable(const MachineInstr &MI) const override
Return true if the specified instruction can be predicated.
bool isHMXActivateInstr(const MachineInstr &MI) const
bool isExtendable(const MachineInstr &MI) const
short changeAddrMode_abs_io(const MachineInstr &MI) const
void immediateExtend(MachineInstr &MI) const
immediateExtend - Changes the instruction in place to one using an immediate extender.
short changeAddrMode_io_rr(const MachineInstr &MI) const
bool isValidOffset(unsigned Opcode, int Offset, bool Extend=true) const
bool isActivateWeightPair(const MachineInstr &MIa, const MachineInstr &MIb) const
HexagonII::CompoundGroup getCompoundCandidateGroup(const MachineInstr &MI) const
bool hasLoadFromStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand * > &Accesses) const override
Check if the instruction or the bundle of instructions has load from stack slots.
SmallVector< MachineInstr *, 2 > getBranchingInstrs(MachineBasicBlock &MBB) const
const TargetRegisterClass * getInlineAsmMemoryOperandRegClass(InlineAsm::ConstraintCode C) const override
bool isPredicatedTrue(const MachineInstr &MI) const
bool isNewValueStore(const MachineInstr &MI) const
int getMinValue(const MachineInstr &MI) const
bool isVecUsableNextPacket(const MachineInstr &ProdMI, const MachineInstr &ConsMI) const
unsigned getCompoundOpcode(const MachineInstr &GA, const MachineInstr &GB) const
bool addLatencyToSchedule(const MachineInstr &MI1, const MachineInstr &MI2) const
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
If the specified machine instruction is a direct store to a stack slot, return the virtual or physica...
int getDotNewPredJumpOp(const MachineInstr &MI, const MachineBranchProbabilityInfo *MBPI) const
bool usesQFOperand(MachineInstr *MI, unsigned Index=0) const
bool isTC2(const MachineInstr &MI) const
Itinerary data supplied by a subtarget to be used by a target.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:67
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Machine Value Type.
MachineInstrBundleIterator< const MachineInstr > const_iterator
Instructions::iterator instr_iterator
Instructions::const_iterator const_instr_iterator
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
HazardRecognizer - This determines whether or not an instruction can be issued this cycle,...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
virtual bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
TargetSubtargetInfo - Generic base class for all target subtargets.
LLVM Value Representation.
Definition Value.h:75
Abstract Attribute helper functions.
Definition Attributor.h:166
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
TargetInstrInfo::RegSubRegPair getRegSubRegPair(const MachineOperand &O)
Create RegSubRegPair from a register MachineOperand.
RegState
Flags to represent properties of register accesses.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Definition ModRef.h:74
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
Extended Value Type.
Definition ValueTypes.h:35
uint64_t FuncUnits
Bitmask representing a set of functional units.