LLVM  14.0.0git
Instruction.h
Go to the documentation of this file.
1 //===-- llvm/Instruction.h - Instruction class definition -------*- 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 declaration of the Instruction class, which is the
10 // base class for all of the LLVM instructions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_IR_INSTRUCTION_H
15 #define LLVM_IR_INSTRUCTION_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/Bitfields.h"
19 #include "llvm/ADT/None.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/ilist_node.h"
22 #include "llvm/IR/DebugLoc.h"
24 #include "llvm/IR/User.h"
25 #include "llvm/IR/Value.h"
27 #include "llvm/Support/Casting.h"
28 #include <algorithm>
29 #include <cassert>
30 #include <cstdint>
31 #include <utility>
32 
33 namespace llvm {
34 
35 class BasicBlock;
36 class FastMathFlags;
37 class MDNode;
38 class Module;
39 struct AAMDNodes;
40 
41 template <> struct ilist_alloc_traits<Instruction> {
42  static inline void deleteNode(Instruction *V);
43 };
44 
45 class Instruction : public User,
46  public ilist_node_with_parent<Instruction, BasicBlock> {
47  BasicBlock *Parent;
48  DebugLoc DbgLoc; // 'dbg' Metadata cache.
49 
50  /// Relative order of this instruction in its parent basic block. Used for
51  /// O(1) local dominance checks between instructions.
52  mutable unsigned Order = 0;
53 
54 protected:
55  // The 15 first bits of `Value::SubclassData` are available for subclasses of
56  // `Instruction` to use.
58 
59  // Template alias so that all Instruction storing alignment use the same
60  // definiton.
61  // Valid alignments are powers of two from 2^0 to 2^MaxAlignmentExponent =
62  // 2^32. We store them as Log2(Alignment), so we need 6 bits to encode the 33
63  // possible values.
64  template <unsigned Offset>
66  typename Bitfield::Element<unsigned, Offset, 6,
68 
69  template <unsigned Offset>
71 
72  template <unsigned Offset>
76 
77 private:
78  // The last bit is used to store whether the instruction has metadata attached
79  // or not.
81 
82 protected:
83  ~Instruction(); // Use deleteValue() to delete a generic Instruction.
84 
85 public:
86  Instruction(const Instruction &) = delete;
87  Instruction &operator=(const Instruction &) = delete;
88 
89  /// Specialize the methods defined in Value, as we know that an instruction
90  /// can only be used by other instructions.
91  Instruction *user_back() { return cast<Instruction>(*user_begin());}
92  const Instruction *user_back() const { return cast<Instruction>(*user_begin());}
93 
94  inline const BasicBlock *getParent() const { return Parent; }
95  inline BasicBlock *getParent() { return Parent; }
96 
97  /// Return the module owning the function this instruction belongs to
98  /// or nullptr it the function does not have a module.
99  ///
100  /// Note: this is undefined behavior if the instruction does not have a
101  /// parent, or the parent basic block does not have a parent function.
102  const Module *getModule() const;
104  return const_cast<Module *>(
105  static_cast<const Instruction *>(this)->getModule());
106  }
107 
108  /// Return the function this instruction belongs to.
109  ///
110  /// Note: it is undefined behavior to call this on an instruction not
111  /// currently inserted into a function.
112  const Function *getFunction() const;
114  return const_cast<Function *>(
115  static_cast<const Instruction *>(this)->getFunction());
116  }
117 
118  /// This method unlinks 'this' from the containing basic block, but does not
119  /// delete it.
120  void removeFromParent();
121 
122  /// This method unlinks 'this' from the containing basic block and deletes it.
123  ///
124  /// \returns an iterator pointing to the element after the erased one
126 
127  /// Insert an unlinked instruction into a basic block immediately before
128  /// the specified instruction.
129  void insertBefore(Instruction *InsertPos);
130 
131  /// Insert an unlinked instruction into a basic block immediately after the
132  /// specified instruction.
133  void insertAfter(Instruction *InsertPos);
134 
135  /// Unlink this instruction from its current basic block and insert it into
136  /// the basic block that MovePos lives in, right before MovePos.
137  void moveBefore(Instruction *MovePos);
138 
139  /// Unlink this instruction and insert into BB before I.
140  ///
141  /// \pre I is a valid iterator into BB.
143 
144  /// Unlink this instruction from its current basic block and insert it into
145  /// the basic block that MovePos lives in, right after MovePos.
146  void moveAfter(Instruction *MovePos);
147 
148  /// Given an instruction Other in the same basic block as this instruction,
149  /// return true if this instruction comes before Other. In this worst case,
150  /// this takes linear time in the number of instructions in the block. The
151  /// results are cached, so in common cases when the block remains unmodified,
152  /// it takes constant time.
153  bool comesBefore(const Instruction *Other) const;
154 
155  //===--------------------------------------------------------------------===//
156  // Subclass classification.
157  //===--------------------------------------------------------------------===//
158 
159  /// Returns a member of one of the enums like Instruction::Add.
160  unsigned getOpcode() const { return getValueID() - InstructionVal; }
161 
162  const char *getOpcodeName() const { return getOpcodeName(getOpcode()); }
163  bool isTerminator() const { return isTerminator(getOpcode()); }
164  bool isUnaryOp() const { return isUnaryOp(getOpcode()); }
165  bool isBinaryOp() const { return isBinaryOp(getOpcode()); }
166  bool isIntDivRem() const { return isIntDivRem(getOpcode()); }
167  bool isShift() const { return isShift(getOpcode()); }
168  bool isCast() const { return isCast(getOpcode()); }
169  bool isFuncletPad() const { return isFuncletPad(getOpcode()); }
170  bool isExceptionalTerminator() const {
172  }
173 
174  /// It checks if this instruction is the only user of at least one of
175  /// its operands.
176  bool isOnlyUserOfAnyOperand();
177 
178  bool isIndirectTerminator() const {
180  }
181 
182  static const char* getOpcodeName(unsigned OpCode);
183 
184  static inline bool isTerminator(unsigned OpCode) {
185  return OpCode >= TermOpsBegin && OpCode < TermOpsEnd;
186  }
187 
188  static inline bool isUnaryOp(unsigned Opcode) {
189  return Opcode >= UnaryOpsBegin && Opcode < UnaryOpsEnd;
190  }
191  static inline bool isBinaryOp(unsigned Opcode) {
192  return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd;
193  }
194 
195  static inline bool isIntDivRem(unsigned Opcode) {
196  return Opcode == UDiv || Opcode == SDiv || Opcode == URem || Opcode == SRem;
197  }
198 
199  /// Determine if the Opcode is one of the shift instructions.
200  static inline bool isShift(unsigned Opcode) {
201  return Opcode >= Shl && Opcode <= AShr;
202  }
203 
204  /// Return true if this is a logical shift left or a logical shift right.
205  inline bool isLogicalShift() const {
206  return getOpcode() == Shl || getOpcode() == LShr;
207  }
208 
209  /// Return true if this is an arithmetic shift right.
210  inline bool isArithmeticShift() const {
211  return getOpcode() == AShr;
212  }
213 
214  /// Determine if the Opcode is and/or/xor.
215  static inline bool isBitwiseLogicOp(unsigned Opcode) {
216  return Opcode == And || Opcode == Or || Opcode == Xor;
217  }
218 
219  /// Return true if this is and/or/xor.
220  inline bool isBitwiseLogicOp() const {
221  return isBitwiseLogicOp(getOpcode());
222  }
223 
224  /// Determine if the OpCode is one of the CastInst instructions.
225  static inline bool isCast(unsigned OpCode) {
226  return OpCode >= CastOpsBegin && OpCode < CastOpsEnd;
227  }
228 
229  /// Determine if the OpCode is one of the FuncletPadInst instructions.
230  static inline bool isFuncletPad(unsigned OpCode) {
231  return OpCode >= FuncletPadOpsBegin && OpCode < FuncletPadOpsEnd;
232  }
233 
234  /// Returns true if the OpCode is a terminator related to exception handling.
235  static inline bool isExceptionalTerminator(unsigned OpCode) {
236  switch (OpCode) {
237  case Instruction::CatchSwitch:
238  case Instruction::CatchRet:
239  case Instruction::CleanupRet:
240  case Instruction::Invoke:
241  case Instruction::Resume:
242  return true;
243  default:
244  return false;
245  }
246  }
247 
248  /// Returns true if the OpCode is a terminator with indirect targets.
249  static inline bool isIndirectTerminator(unsigned OpCode) {
250  switch (OpCode) {
251  case Instruction::IndirectBr:
252  case Instruction::CallBr:
253  return true;
254  default:
255  return false;
256  }
257  }
258 
259  //===--------------------------------------------------------------------===//
260  // Metadata manipulation.
261  //===--------------------------------------------------------------------===//
262 
263  /// Return true if this instruction has any metadata attached to it.
264  bool hasMetadata() const { return DbgLoc || Value::hasMetadata(); }
265 
266  /// Return true if this instruction has metadata attached to it other than a
267  /// debug location.
269 
270  /// Return true if this instruction has the given type of metadata attached.
271  bool hasMetadata(unsigned KindID) const {
272  return getMetadata(KindID) != nullptr;
273  }
274 
275  /// Return true if this instruction has the given type of metadata attached.
276  bool hasMetadata(StringRef Kind) const {
277  return getMetadata(Kind) != nullptr;
278  }
279 
280  /// Get the metadata of given kind attached to this Instruction.
281  /// If the metadata is not found then return null.
282  MDNode *getMetadata(unsigned KindID) const {
283  if (!hasMetadata()) return nullptr;
284  return getMetadataImpl(KindID);
285  }
286 
287  /// Get the metadata of given kind attached to this Instruction.
288  /// If the metadata is not found then return null.
290  if (!hasMetadata()) return nullptr;
291  return getMetadataImpl(Kind);
292  }
293 
294  /// Get all metadata attached to this Instruction. The first element of each
295  /// pair returned is the KindID, the second element is the metadata value.
296  /// This list is returned sorted by the KindID.
297  void
298  getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
299  if (hasMetadata())
300  getAllMetadataImpl(MDs);
301  }
302 
303  /// This does the same thing as getAllMetadata, except that it filters out the
304  /// debug location.
306  SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
308  }
309 
310  /// Set the metadata of the specified kind to the specified node. This updates
311  /// or replaces metadata if already present, or removes it if Node is null.
312  void setMetadata(unsigned KindID, MDNode *Node);
314 
315  /// Copy metadata from \p SrcInst to this instruction. \p WL, if not empty,
316  /// specifies the list of meta data that needs to be copied. If \p WL is
317  /// empty, all meta data will be copied.
318  void copyMetadata(const Instruction &SrcInst,
320 
321  /// If the instruction has "branch_weights" MD_prof metadata and the MDNode
322  /// has three operands (including name string), swap the order of the
323  /// metadata.
324  void swapProfMetadata();
325 
326  /// Drop all unknown metadata except for debug locations.
327  /// @{
328  /// Passes are required to drop metadata they don't understand. This is a
329  /// convenience method for passes to do so.
330  /// dropUndefImplyingAttrsAndUnknownMetadata should be used instead of
331  /// this API if the Instruction being modified is a call.
335  }
336  void dropUnknownNonDebugMetadata(unsigned ID1) {
338  }
339  void dropUnknownNonDebugMetadata(unsigned ID1, unsigned ID2) {
340  unsigned IDs[] = {ID1, ID2};
341  return dropUnknownNonDebugMetadata(IDs);
342  }
343  /// @}
344 
345  /// Adds an !annotation metadata node with \p Annotation to this instruction.
346  /// If this instruction already has !annotation metadata, append \p Annotation
347  /// to the existing node.
348  void addAnnotationMetadata(StringRef Annotation);
349 
350  /// Returns the AA metadata for this instruction.
351  AAMDNodes getAAMetadata() const;
352 
353  /// Sets the AA metadata on this instruction from the AAMDNodes structure.
354  void setAAMetadata(const AAMDNodes &N);
355 
356  /// Retrieve the raw weight values of a conditional branch or select.
357  /// Returns true on success with profile weights filled in.
358  /// Returns false if no metadata or invalid metadata was found.
360 
361  /// Retrieve total raw weight values of a branch.
362  /// Returns true on success with profile total weights filled in.
363  /// Returns false if no metadata was found.
364  bool extractProfTotalWeight(uint64_t &TotalVal) const;
365 
366  /// Set the debug location information for this instruction.
367  void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
368 
369  /// Return the debug location for this node as a DebugLoc.
370  const DebugLoc &getDebugLoc() const { return DbgLoc; }
371 
372  /// Set or clear the nuw flag on this instruction, which must be an operator
373  /// which supports this flag. See LangRef.html for the meaning of this flag.
374  void setHasNoUnsignedWrap(bool b = true);
375 
376  /// Set or clear the nsw flag on this instruction, which must be an operator
377  /// which supports this flag. See LangRef.html for the meaning of this flag.
378  void setHasNoSignedWrap(bool b = true);
379 
380  /// Set or clear the exact flag on this instruction, which must be an operator
381  /// which supports this flag. See LangRef.html for the meaning of this flag.
382  void setIsExact(bool b = true);
383 
384  /// Determine whether the no unsigned wrap flag is set.
385  bool hasNoUnsignedWrap() const;
386 
387  /// Determine whether the no signed wrap flag is set.
388  bool hasNoSignedWrap() const;
389 
390  /// Drops flags that may cause this instruction to evaluate to poison despite
391  /// having non-poison inputs.
393 
394  /// This function drops non-debug unknown metadata (through
395  /// dropUnknownNonDebugMetadata). For calls, it also drops parameter and
396  /// return attributes that can cause undefined behaviour. Both of these should
397  /// be done by passes which move instructions in IR.
398  void
400 
401  /// Determine whether the exact flag is set.
402  bool isExact() const;
403 
404  /// Set or clear all fast-math-flags on this instruction, which must be an
405  /// operator which supports this flag. See LangRef.html for the meaning of
406  /// this flag.
407  void setFast(bool B);
408 
409  /// Set or clear the reassociation flag on this instruction, which must be
410  /// an operator which supports this flag. See LangRef.html for the meaning of
411  /// this flag.
412  void setHasAllowReassoc(bool B);
413 
414  /// Set or clear the no-nans flag on this instruction, which must be an
415  /// operator which supports this flag. See LangRef.html for the meaning of
416  /// this flag.
417  void setHasNoNaNs(bool B);
418 
419  /// Set or clear the no-infs flag on this instruction, which must be an
420  /// operator which supports this flag. See LangRef.html for the meaning of
421  /// this flag.
422  void setHasNoInfs(bool B);
423 
424  /// Set or clear the no-signed-zeros flag on this instruction, which must be
425  /// an operator which supports this flag. See LangRef.html for the meaning of
426  /// this flag.
427  void setHasNoSignedZeros(bool B);
428 
429  /// Set or clear the allow-reciprocal flag on this instruction, which must be
430  /// an operator which supports this flag. See LangRef.html for the meaning of
431  /// this flag.
432  void setHasAllowReciprocal(bool B);
433 
434  /// Set or clear the allow-contract flag on this instruction, which must be
435  /// an operator which supports this flag. See LangRef.html for the meaning of
436  /// this flag.
437  void setHasAllowContract(bool B);
438 
439  /// Set or clear the approximate-math-functions flag on this instruction,
440  /// which must be an operator which supports this flag. See LangRef.html for
441  /// the meaning of this flag.
442  void setHasApproxFunc(bool B);
443 
444  /// Convenience function for setting multiple fast-math flags on this
445  /// instruction, which must be an operator which supports these flags. See
446  /// LangRef.html for the meaning of these flags.
447  void setFastMathFlags(FastMathFlags FMF);
448 
449  /// Convenience function for transferring all fast-math flag values to this
450  /// instruction, which must be an operator which supports these flags. See
451  /// LangRef.html for the meaning of these flags.
452  void copyFastMathFlags(FastMathFlags FMF);
453 
454  /// Determine whether all fast-math-flags are set.
455  bool isFast() const;
456 
457  /// Determine whether the allow-reassociation flag is set.
458  bool hasAllowReassoc() const;
459 
460  /// Determine whether the no-NaNs flag is set.
461  bool hasNoNaNs() const;
462 
463  /// Determine whether the no-infs flag is set.
464  bool hasNoInfs() const;
465 
466  /// Determine whether the no-signed-zeros flag is set.
467  bool hasNoSignedZeros() const;
468 
469  /// Determine whether the allow-reciprocal flag is set.
470  bool hasAllowReciprocal() const;
471 
472  /// Determine whether the allow-contract flag is set.
473  bool hasAllowContract() const;
474 
475  /// Determine whether the approximate-math-functions flag is set.
476  bool hasApproxFunc() const;
477 
478  /// Convenience function for getting all the fast-math flags, which must be an
479  /// operator which supports these flags. See LangRef.html for the meaning of
480  /// these flags.
481  FastMathFlags getFastMathFlags() const;
482 
483  /// Copy I's fast-math flags
484  void copyFastMathFlags(const Instruction *I);
485 
486  /// Convenience method to copy supported exact, fast-math, and (optionally)
487  /// wrapping flags from V to this instruction.
488  void copyIRFlags(const Value *V, bool IncludeWrapFlags = true);
489 
490  /// Logical 'and' of any supported wrapping, exact, and fast-math flags of
491  /// V and this instruction.
492  void andIRFlags(const Value *V);
493 
494  /// Merge 2 debug locations and apply it to the Instruction. If the
495  /// instruction is a CallIns, we need to traverse the inline chain to find
496  /// the common scope. This is not efficient for N-way merging as each time
497  /// you merge 2 iterations, you need to rebuild the hashmap to find the
498  /// common scope. However, we still choose this API because:
499  /// 1) Simplicity: it takes 2 locations instead of a list of locations.
500  /// 2) In worst case, it increases the complexity from O(N*I) to
501  /// O(2*N*I), where N is # of Instructions to merge, and I is the
502  /// maximum level of inline stack. So it is still linear.
503  /// 3) Merging of call instructions should be extremely rare in real
504  /// applications, thus the N-way merging should be in code path.
505  /// The DebugLoc attached to this instruction will be overwritten by the
506  /// merged DebugLoc.
507  void applyMergedLocation(const DILocation *LocA, const DILocation *LocB);
508 
509  /// Updates the debug location given that the instruction has been hoisted
510  /// from a block to a predecessor of that block.
511  /// Note: it is undefined behavior to call this on an instruction not
512  /// currently inserted into a function.
514 
515  /// Drop the instruction's debug location. This does not guarantee removal
516  /// of the !dbg source location attachment, as it must set a line 0 location
517  /// with scope information attached on call instructions. To guarantee
518  /// removal of the !dbg attachment, use the \ref setDebugLoc() API.
519  /// Note: it is undefined behavior to call this on an instruction not
520  /// currently inserted into a function.
521  void dropLocation();
522 
523 private:
524  // These are all implemented in Metadata.cpp.
525  MDNode *getMetadataImpl(unsigned KindID) const;
526  MDNode *getMetadataImpl(StringRef Kind) const;
527  void
528  getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const;
529 
530 public:
531  //===--------------------------------------------------------------------===//
532  // Predicates and helper methods.
533  //===--------------------------------------------------------------------===//
534 
535  /// Return true if the instruction is associative:
536  ///
537  /// Associative operators satisfy: x op (y op z) === (x op y) op z
538  ///
539  /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
540  ///
542  static bool isAssociative(unsigned Opcode) {
543  return Opcode == And || Opcode == Or || Opcode == Xor ||
544  Opcode == Add || Opcode == Mul;
545  }
546 
547  /// Return true if the instruction is commutative:
548  ///
549  /// Commutative operators satisfy: (x op y) === (y op x)
550  ///
551  /// In LLVM, these are the commutative operators, plus SetEQ and SetNE, when
552  /// applied to any type.
553  ///
555  static bool isCommutative(unsigned Opcode) {
556  switch (Opcode) {
557  case Add: case FAdd:
558  case Mul: case FMul:
559  case And: case Or: case Xor:
560  return true;
561  default:
562  return false;
563  }
564  }
565 
566  /// Return true if the instruction is idempotent:
567  ///
568  /// Idempotent operators satisfy: x op x === x
569  ///
570  /// In LLVM, the And and Or operators are idempotent.
571  ///
572  bool isIdempotent() const { return isIdempotent(getOpcode()); }
573  static bool isIdempotent(unsigned Opcode) {
574  return Opcode == And || Opcode == Or;
575  }
576 
577  /// Return true if the instruction is nilpotent:
578  ///
579  /// Nilpotent operators satisfy: x op x === Id,
580  ///
581  /// where Id is the identity for the operator, i.e. a constant such that
582  /// x op Id === x and Id op x === x for all x.
583  ///
584  /// In LLVM, the Xor operator is nilpotent.
585  ///
586  bool isNilpotent() const { return isNilpotent(getOpcode()); }
587  static bool isNilpotent(unsigned Opcode) {
588  return Opcode == Xor;
589  }
590 
591  /// Return true if this instruction may modify memory.
592  bool mayWriteToMemory() const;
593 
594  /// Return true if this instruction may read memory.
595  bool mayReadFromMemory() const;
596 
597  /// Return true if this instruction may read or write memory.
598  bool mayReadOrWriteMemory() const {
599  return mayReadFromMemory() || mayWriteToMemory();
600  }
601 
602  /// Return true if this instruction has an AtomicOrdering of unordered or
603  /// higher.
604  bool isAtomic() const;
605 
606  /// Return true if this atomic instruction loads from memory.
607  bool hasAtomicLoad() const;
608 
609  /// Return true if this atomic instruction stores to memory.
610  bool hasAtomicStore() const;
611 
612  /// Return true if this instruction has a volatile memory access.
613  bool isVolatile() const;
614 
615  /// Return true if this instruction may throw an exception.
616  bool mayThrow() const;
617 
618  /// Return true if this instruction behaves like a memory fence: it can load
619  /// or store to memory location without being given a memory location.
620  bool isFenceLike() const {
621  switch (getOpcode()) {
622  default:
623  return false;
624  // This list should be kept in sync with the list in mayWriteToMemory for
625  // all opcodes which don't have a memory location.
626  case Instruction::Fence:
627  case Instruction::CatchPad:
628  case Instruction::CatchRet:
629  case Instruction::Call:
630  case Instruction::Invoke:
631  return true;
632  }
633  }
634 
635  /// Return true if the instruction may have side effects.
636  ///
637  /// Side effects are:
638  /// * Writing to memory.
639  /// * Unwinding.
640  /// * Not returning (e.g. an infinite loop).
641  ///
642  /// Note that this does not consider malloc and alloca to have side
643  /// effects because the newly allocated memory is completely invisible to
644  /// instructions which don't use the returned value. For cases where this
645  /// matters, isSafeToSpeculativelyExecute may be more appropriate.
646  bool mayHaveSideEffects() const;
647 
648  /// Return true if the instruction can be removed if the result is unused.
649  ///
650  /// When constant folding some instructions cannot be removed even if their
651  /// results are unused. Specifically terminator instructions and calls that
652  /// may have side effects cannot be removed without semantically changing the
653  /// generated program.
654  bool isSafeToRemove() const;
655 
656  /// Return true if the instruction will return (unwinding is considered as
657  /// a form of returning control flow here).
658  bool willReturn() const;
659 
660  /// Return true if the instruction is a variety of EH-block.
661  bool isEHPad() const {
662  switch (getOpcode()) {
663  case Instruction::CatchSwitch:
664  case Instruction::CatchPad:
665  case Instruction::CleanupPad:
666  case Instruction::LandingPad:
667  return true;
668  default:
669  return false;
670  }
671  }
672 
673  /// Return true if the instruction is a llvm.lifetime.start or
674  /// llvm.lifetime.end marker.
675  bool isLifetimeStartOrEnd() const;
676 
677  /// Return true if the instruction is a llvm.launder.invariant.group or
678  /// llvm.strip.invariant.group.
679  bool isLaunderOrStripInvariantGroup() const;
680 
681  /// Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst.
682  bool isDebugOrPseudoInst() const;
683 
684  /// Return a pointer to the next non-debug instruction in the same basic
685  /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo
686  /// operations if \c SkipPseudoOp is true.
687  const Instruction *
688  getNextNonDebugInstruction(bool SkipPseudoOp = false) const;
689  Instruction *getNextNonDebugInstruction(bool SkipPseudoOp = false) {
690  return const_cast<Instruction *>(
691  static_cast<const Instruction *>(this)->getNextNonDebugInstruction(
692  SkipPseudoOp));
693  }
694 
695  /// Return a pointer to the previous non-debug instruction in the same basic
696  /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo
697  /// operations if \c SkipPseudoOp is true.
698  const Instruction *
699  getPrevNonDebugInstruction(bool SkipPseudoOp = false) const;
700  Instruction *getPrevNonDebugInstruction(bool SkipPseudoOp = false) {
701  return const_cast<Instruction *>(
702  static_cast<const Instruction *>(this)->getPrevNonDebugInstruction(
703  SkipPseudoOp));
704  }
705 
706  /// Create a copy of 'this' instruction that is identical in all ways except
707  /// the following:
708  /// * The instruction has no parent
709  /// * The instruction has no name
710  ///
711  Instruction *clone() const;
712 
713  /// Return true if the specified instruction is exactly identical to the
714  /// current one. This means that all operands match and any extra information
715  /// (e.g. load is volatile) agree.
716  bool isIdenticalTo(const Instruction *I) const;
717 
718  /// This is like isIdenticalTo, except that it ignores the
719  /// SubclassOptionalData flags, which may specify conditions under which the
720  /// instruction's result is undefined.
721  bool isIdenticalToWhenDefined(const Instruction *I) const;
722 
723  /// When checking for operation equivalence (using isSameOperationAs) it is
724  /// sometimes useful to ignore certain attributes.
726  /// Check for equivalence ignoring load/store alignment.
728  /// Check for equivalence treating a type and a vector of that type
729  /// as equivalent.
731  };
732 
733  /// This function determines if the specified instruction executes the same
734  /// operation as the current one. This means that the opcodes, type, operand
735  /// types and any other factors affecting the operation must be the same. This
736  /// is similar to isIdenticalTo except the operands themselves don't have to
737  /// be identical.
738  /// @returns true if the specified instruction is the same operation as
739  /// the current one.
740  /// Determine if one instruction is the same operation as another.
741  bool isSameOperationAs(const Instruction *I, unsigned flags = 0) const;
742 
743  /// Return true if there are any uses of this instruction in blocks other than
744  /// the specified block. Note that PHI nodes are considered to evaluate their
745  /// operands in the corresponding predecessor block.
746  bool isUsedOutsideOfBlock(const BasicBlock *BB) const;
747 
748  /// Return the number of successors that this instruction has. The instruction
749  /// must be a terminator.
750  unsigned getNumSuccessors() const;
751 
752  /// Return the specified successor. This instruction must be a terminator.
753  BasicBlock *getSuccessor(unsigned Idx) const;
754 
755  /// Update the specified successor to point at the provided block. This
756  /// instruction must be a terminator.
757  void setSuccessor(unsigned Idx, BasicBlock *BB);
758 
759  /// Replace specified successor OldBB to point at the provided block.
760  /// This instruction must be a terminator.
761  void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB);
762 
763  /// Methods for support type inquiry through isa, cast, and dyn_cast:
764  static bool classof(const Value *V) {
765  return V->getValueID() >= Value::InstructionVal;
766  }
767 
768  //----------------------------------------------------------------------
769  // Exported enumerations.
770  //
771  enum TermOps { // These terminate basic blocks
772 #define FIRST_TERM_INST(N) TermOpsBegin = N,
773 #define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N,
774 #define LAST_TERM_INST(N) TermOpsEnd = N+1
775 #include "llvm/IR/Instruction.def"
776  };
777 
778  enum UnaryOps {
779 #define FIRST_UNARY_INST(N) UnaryOpsBegin = N,
780 #define HANDLE_UNARY_INST(N, OPC, CLASS) OPC = N,
781 #define LAST_UNARY_INST(N) UnaryOpsEnd = N+1
782 #include "llvm/IR/Instruction.def"
783  };
784 
785  enum BinaryOps {
786 #define FIRST_BINARY_INST(N) BinaryOpsBegin = N,
787 #define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N,
788 #define LAST_BINARY_INST(N) BinaryOpsEnd = N+1
789 #include "llvm/IR/Instruction.def"
790  };
791 
792  enum MemoryOps {
793 #define FIRST_MEMORY_INST(N) MemoryOpsBegin = N,
794 #define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N,
795 #define LAST_MEMORY_INST(N) MemoryOpsEnd = N+1
796 #include "llvm/IR/Instruction.def"
797  };
798 
799  enum CastOps {
800 #define FIRST_CAST_INST(N) CastOpsBegin = N,
801 #define HANDLE_CAST_INST(N, OPC, CLASS) OPC = N,
802 #define LAST_CAST_INST(N) CastOpsEnd = N+1
803 #include "llvm/IR/Instruction.def"
804  };
805 
807 #define FIRST_FUNCLETPAD_INST(N) FuncletPadOpsBegin = N,
808 #define HANDLE_FUNCLETPAD_INST(N, OPC, CLASS) OPC = N,
809 #define LAST_FUNCLETPAD_INST(N) FuncletPadOpsEnd = N+1
810 #include "llvm/IR/Instruction.def"
811  };
812 
813  enum OtherOps {
814 #define FIRST_OTHER_INST(N) OtherOpsBegin = N,
815 #define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N,
816 #define LAST_OTHER_INST(N) OtherOpsEnd = N+1
817 #include "llvm/IR/Instruction.def"
818  };
819 
820 private:
822  friend class BasicBlock; // For renumbering.
823 
824  // Shadow Value::setValueSubclassData with a private forwarding method so that
825  // subclasses cannot accidentally use it.
826  void setValueSubclassData(unsigned short D) {
828  }
829 
830  unsigned short getSubclassDataFromValue() const {
832  }
833 
834  void setParent(BasicBlock *P);
835 
836 protected:
837  // Instruction subclasses can stick up to 15 bits of stuff into the
838  // SubclassData field of instruction with these members.
839 
840  template <typename BitfieldElement>
842  static_assert(
843  std::is_same<BitfieldElement, HasMetadataField>::value ||
844  !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
845  "Must not overlap with the metadata bit");
846  return Bitfield::get<BitfieldElement>(getSubclassDataFromValue());
847  }
848 
849  template <typename BitfieldElement>
851  static_assert(
852  std::is_same<BitfieldElement, HasMetadataField>::value ||
853  !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
854  "Must not overlap with the metadata bit");
855  auto Storage = getSubclassDataFromValue();
856  Bitfield::set<BitfieldElement>(Storage, Value);
857  setValueSubclassData(Storage);
858  }
859 
860  Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
861  Instruction *InsertBefore = nullptr);
862  Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
863  BasicBlock *InsertAtEnd);
864 
865 private:
866  /// Create a copy of this instruction.
867  Instruction *cloneImpl() const;
868 };
869 
871  V->deleteValue();
872 }
873 
874 } // end namespace llvm
875 
876 #endif // LLVM_IR_INSTRUCTION_H
llvm::Instruction::getPrevNonDebugInstruction
const Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the previous non-debug instruction in the same basic block as 'this',...
Definition: Instruction.cpp:736
llvm::Instruction::isTerminator
bool isTerminator() const
Definition: Instruction.h:163
llvm::Instruction::isAssociative
bool isAssociative() const LLVM_READONLY
Return true if the instruction is associative:
Definition: Instruction.cpp:743
llvm::Instruction::getNextNonDebugInstruction
Instruction * getNextNonDebugInstruction(bool SkipPseudoOp=false)
Definition: Instruction.h:689
LLVM_READONLY
#define LLVM_READONLY
Definition: Compiler.h:212
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::Instruction::replaceSuccessorWith
void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB)
Replace specified successor OldBB to point at the provided block.
Definition: Instruction.cpp:801
llvm::Instruction::getModule
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:66
llvm::RecurKind::Or
@ Or
Bitwise or logical OR of integers.
llvm::Instruction::UnaryOps
UnaryOps
Definition: Instruction.h:778
llvm::Instruction::isBitwiseLogicOp
static bool isBitwiseLogicOp(unsigned Opcode)
Determine if the Opcode is and/or/xor.
Definition: Instruction.h:215
llvm::RecurKind::FMul
@ FMul
Product of floats.
llvm::Instruction::isExceptionalTerminator
static bool isExceptionalTerminator(unsigned OpCode)
Returns true if the OpCode is a terminator related to exception handling.
Definition: Instruction.h:235
AtomicOrdering.h
llvm::Instruction::getNextNonDebugInstruction
const Instruction * getNextNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the next non-debug instruction in the same basic block as 'this',...
Definition: Instruction.cpp:728
llvm::Function
Definition: Function.h:62
llvm::Instruction::isCast
bool isCast() const
Definition: Instruction.h:168
StringRef.h
llvm::Value::getSubclassDataFromValue
unsigned short getSubclassDataFromValue() const
Definition: Value.h:852
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::Instruction::isVolatile
bool isVolatile() const
Return true if this instruction has a volatile memory access.
Definition: Instruction.cpp:643
llvm::Instruction::isNilpotent
static bool isNilpotent(unsigned Opcode)
Definition: Instruction.h:587
llvm::Instruction::getAllMetadataOtherThanDebugLoc
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
Definition: Instruction.h:305
llvm::Instruction::getParent
BasicBlock * getParent()
Definition: Instruction.h:95
llvm::Instruction::setHasAllowContract
void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
Definition: Instruction.cpp:220
llvm::ilist_node_with_parent
An ilist node that can access its parent list.
Definition: ilist_node.h:256
llvm::Instruction::getSubclassData
BitfieldElement::Type getSubclassData() const
Definition: Instruction.h:841
llvm::Instruction::hasNoUnsignedWrap
bool hasNoUnsignedWrap() const
Determine whether the no unsigned wrap flag is set.
Definition: Instruction.cpp:136
llvm::Instruction::AlignmentBitfieldElementT
typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT
Definition: Instruction.h:67
llvm::Instruction::insertBefore
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
Definition: Instruction.cpp:84
llvm::Instruction::hasAllowReciprocal
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
Definition: Instruction.cpp:265
llvm::Instruction::isIndirectTerminator
static bool isIndirectTerminator(unsigned OpCode)
Returns true if the OpCode is a terminator with indirect targets.
Definition: Instruction.h:249
llvm::AAMDNodes
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:651
llvm::Instruction::dropUnknownNonDebugMetadata
void dropUnknownNonDebugMetadata(unsigned ID1)
Definition: Instruction.h:336
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Instruction::getPrevNonDebugInstruction
Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false)
Definition: Instruction.h:700
llvm::Instruction::isShift
bool isShift() const
Definition: Instruction.h:167
llvm::Instruction::setSubclassData
void setSubclassData(typename BitfieldElement::Type Value)
Definition: Instruction.h:850
llvm::Instruction::hasApproxFunc
bool hasApproxFunc() const
Determine whether the approximate-math-functions flag is set.
Definition: Instruction.cpp:275
llvm::Instruction::comesBefore
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
Definition: Instruction.cpp:111
llvm::Instruction::setHasNoUnsignedWrap
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:124
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::tgtok::FalseVal
@ FalseVal
Definition: TGLexer.h:61
llvm::Instruction::mayThrow
bool mayThrow() const
Return true if this instruction may throw an exception.
Definition: Instruction.cpp:673
llvm::Value::user_begin
user_iterator user_begin()
Definition: Value.h:397
llvm::Instruction::copyMetadata
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
Definition: Instruction.cpp:829
llvm::Value::setValueSubclassData
void setValueSubclassData(unsigned short D)
Definition: Value.h:853
llvm::Instruction::~Instruction
~Instruction()
Definition: Instruction.cpp:45
llvm::Instruction::setIsExact
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:132
llvm::Instruction::dropUnknownNonDebugMetadata
void dropUnknownNonDebugMetadata()
Definition: Instruction.h:333
llvm::Instruction::isExceptionalTerminator
bool isExceptionalTerminator() const
Definition: Instruction.h:170
llvm::Instruction::mayHaveSideEffects
bool mayHaveSideEffects() const
Return true if the instruction may have side effects.
Definition: Instruction.cpp:683
llvm::Instruction::hasMetadata
bool hasMetadata(StringRef Kind) const
Return true if this instruction has the given type of metadata attached.
Definition: Instruction.h:276
llvm::Instruction::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1336
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::Instruction::getNumSuccessors
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
Definition: Instruction.cpp:765
llvm::Instruction::insertAfter
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
Definition: Instruction.cpp:90
llvm::Instruction::getOpcode
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:160
llvm::Instruction::willReturn
bool willReturn() const
Return true if the instruction will return (unwinding is considered as a form of returning control fl...
Definition: Instruction.cpp:692
llvm::Instruction::extractProfTotalWeight
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
Definition: Metadata.cpp:1430
llvm::Instruction::isArithmeticShift
bool isArithmeticShift() const
Return true if this is an arithmetic shift right.
Definition: Instruction.h:210
llvm::RecurKind::And
@ And
Bitwise or logical AND of integers.
llvm::Instruction::mayReadOrWriteMemory
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.
Definition: Instruction.h:598
llvm::Instruction::setHasNoSignedWrap
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:128
llvm::User
Definition: User.h:44
llvm::Instruction::BoolBitfieldElementT
typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT
Definition: Instruction.h:70
llvm::Instruction::isIdenticalToWhenDefined
bool isIdenticalToWhenDefined(const Instruction *I) const
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags,...
Definition: Instruction.cpp:495
b
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int b
Definition: README.txt:418
llvm::Instruction::applyMergedLocation
void applyMergedLocation(const DILocation *LocA, const DILocation *LocB)
Merge 2 debug locations and apply it to the Instruction.
Definition: DebugInfo.cpp:815
llvm::Instruction::OtherOps
OtherOps
Definition: Instruction.h:813
llvm::Instruction::isShift
static bool isShift(unsigned Opcode)
Determine if the Opcode is one of the shift instructions.
Definition: Instruction.h:200
llvm::Instruction::isNilpotent
bool isNilpotent() const
Return true if the instruction is nilpotent:
Definition: Instruction.h:586
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:532
llvm::Instruction::CastOps
CastOps
Definition: Instruction.h:799
llvm::Instruction::getOpcodeName
const char * getOpcodeName() const
Definition: Instruction.h:162
llvm::Instruction::classof
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: Instruction.h:764
llvm::Instruction
Definition: Instruction.h:45
llvm::Instruction::getAllMetadata
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
Get all metadata attached to this Instruction.
Definition: Instruction.h:298
llvm::Instruction::hasMetadata
bool hasMetadata(unsigned KindID) const
Return true if this instruction has the given type of metadata attached.
Definition: Instruction.h:271
DebugLoc.h
llvm::Instruction::getAAMetadata
AAMDNodes getAAMetadata() const
Returns the AA metadata for this instruction.
Definition: Metadata.cpp:1370
llvm::Instruction::getSuccessor
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
Definition: Instruction.cpp:777
llvm::Instruction::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
Definition: Instruction.cpp:74
llvm::Instruction::isSafeToRemove
bool isSafeToRemove() const
Return true if the instruction can be removed if the result is unused.
Definition: Instruction.cpp:687
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:153
llvm::Instruction::mayWriteToMemory
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
Definition: Instruction.cpp:584
llvm::Instruction::isLifetimeStartOrEnd
bool isLifetimeStartOrEnd() const
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
Definition: Instruction.cpp:706
llvm::Instruction::isIntDivRem
bool isIntDivRem() const
Definition: Instruction.h:166
llvm::Value::MaxAlignmentExponent
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
Definition: Value.h:792
llvm::Instruction::extractProfMetadata
bool extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) const
Retrieve the raw weight values of a conditional branch or select.
Definition: Metadata.cpp:1405
llvm::None
const NoneType None
Definition: None.h:23
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Instruction::isLaunderOrStripInvariantGroup
bool isLaunderOrStripInvariantGroup() const
Return true if the instruction is a llvm.launder.invariant.group or llvm.strip.invariant....
Definition: Instruction.cpp:714
llvm::Instruction::OperationEquivalenceFlags
OperationEquivalenceFlags
When checking for operation equivalence (using isSameOperationAs) it is sometimes useful to ignore ce...
Definition: Instruction.h:725
llvm::Instruction::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:282
llvm::Instruction::isCommutative
bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
Definition: Instruction.cpp:758
llvm::Instruction::setHasNoNaNs
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
Definition: Instruction.cpp:200
llvm::Instruction::hasAtomicLoad
bool hasAtomicLoad() const
Return true if this atomic instruction loads from memory.
Definition: Instruction.cpp:619
llvm::Instruction::AtomicOrderingBitfieldElementT
typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT
Definition: Instruction.h:75
llvm::Instruction::andIRFlags
void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction.
Definition: Instruction.cpp:313
llvm::Value::Value
Value(Type *Ty, unsigned scid)
Definition: Value.cpp:53
llvm::AtomicOrdering
AtomicOrdering
Atomic ordering for LLVM's memory model.
Definition: AtomicOrdering.h:56
llvm::Instruction::isTerminator
static bool isTerminator(unsigned OpCode)
Definition: Instruction.h:184
llvm::Instruction::addAnnotationMetadata
void addAnnotationMetadata(StringRef Annotation)
Adds an !annotation metadata node with Annotation to this instruction.
Definition: Metadata.cpp:1349
llvm::Instruction::eraseFromParent
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition: Instruction.cpp:78
llvm::Instruction::isLogicalShift
bool isLogicalShift() const
Return true if this is a logical shift left or a logical shift right.
Definition: Instruction.h:205
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:26
uint64_t
llvm::Instruction::setFast
void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
Definition: Instruction.cpp:190
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::AtomicOrdering::LAST
@ LAST
llvm::Instruction::hasAllowContract
bool hasAllowContract() const
Determine whether the allow-contract flag is set.
Definition: Instruction.cpp:270
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::Instruction::user_back
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
Definition: Instruction.h:91
llvm::Instruction::MemoryOps
MemoryOps
Definition: Instruction.h:792
llvm::Instruction::isIdenticalTo
bool isIdenticalTo(const Instruction *I) const
Return true if the specified instruction is exactly identical to the current one.
Definition: Instruction.cpp:490
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::Instruction::moveAfter
void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
Definition: Instruction.cpp:101
llvm::Instruction::isFenceLike
bool isFenceLike() const
Return true if this instruction behaves like a memory fence: it can load or store to memory location ...
Definition: Instruction.h:620
llvm::Instruction::isOnlyUserOfAnyOperand
bool isOnlyUserOfAnyOperand()
It checks if this instruction is the only user of at least one of its operands.
Definition: Instruction.cpp:120
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::Instruction::hasAtomicStore
bool hasAtomicStore() const
Return true if this atomic instruction stores to memory.
Definition: Instruction.cpp:631
llvm::ilist_alloc_traits
Use delete by default for iplist and ilist.
Definition: ilist.h:40
ArrayRef.h
llvm::Instruction::updateLocationAfterHoist
void updateLocationAfterHoist()
Updates the debug location given that the instruction has been hoisted from a block to a predecessor ...
Definition: DebugInfo.cpp:820
llvm::Instruction::setDebugLoc
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:367
llvm::Instruction::isIdempotent
bool isIdempotent() const
Return true if the instruction is idempotent:
Definition: Instruction.h:572
llvm::Instruction::dropLocation
void dropLocation()
Drop the instruction's debug location.
Definition: DebugInfo.cpp:822
llvm::Instruction::hasMetadata
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
Definition: Instruction.h:264
llvm::Instruction::isFast
bool isFast() const
Determine whether all fast-math-flags are set.
Definition: Instruction.cpp:240
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::Instruction::isBinaryOp
bool isBinaryOp() const
Definition: Instruction.h:165
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::Instruction::FuncletPadOps
FuncletPadOps
Definition: Instruction.h:806
llvm::Instruction::clone
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition: Instruction.cpp:850
llvm::Instruction::dropUndefImplyingAttrsAndUnknownMetadata
void dropUndefImplyingAttrsAndUnknownMetadata(ArrayRef< unsigned > KnownIDs={})
This function drops non-debug unknown metadata (through dropUnknownNonDebugMetadata).
Definition: Instruction.cpp:168
llvm::ArrayRef< unsigned >
llvm::Instruction::getFastMathFlags
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Definition: Instruction.cpp:280
None.h
llvm::SymbolTableList
List that automatically updates parent links and symbol tables.
Definition: SymbolTableListTraits.h:60
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::Instruction::setSuccessor
void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
Definition: Instruction.cpp:789
llvm::Instruction::getFunction
const Function * getFunction() const
Return the function this instruction belongs to.
Definition: Instruction.cpp:70
llvm::Instruction::isExact
bool isExact() const
Determine whether the exact flag is set.
Definition: Instruction.cpp:186
llvm::RecurKind::Mul
@ Mul
Product of integers.
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::Instruction::copyFastMathFlags
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
Definition: Instruction.cpp:235
llvm::Instruction::TermOps
TermOps
Definition: Instruction.h:771
llvm::Instruction::user_back
const Instruction * user_back() const
Definition: Instruction.h:92
Node
Definition: ItaniumDemangle.h:235
llvm::Instruction::mayReadFromMemory
bool mayReadFromMemory() const
Return true if this instruction may read memory.
Definition: Instruction.cpp:564
llvm::Instruction::operator=
Instruction & operator=(const Instruction &)=delete
llvm::Instruction::isBinaryOp
static bool isBinaryOp(unsigned Opcode)
Definition: Instruction.h:191
llvm::Instruction::setFastMathFlags
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
Definition: Instruction.cpp:230
llvm::Instruction::isAtomic
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
Definition: Instruction.cpp:604
llvm::Instruction::isFuncletPad
static bool isFuncletPad(unsigned OpCode)
Determine if the OpCode is one of the FuncletPadInst instructions.
Definition: Instruction.h:230
llvm::Instruction::setHasApproxFunc
void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
Definition: Instruction.cpp:225
llvm::Instruction::CompareIgnoringAlignment
@ CompareIgnoringAlignment
Check for equivalence ignoring load/store alignment.
Definition: Instruction.h:727
llvm::Instruction::Instruction
Instruction(const Instruction &)=delete
llvm::Instruction::isUsedOutsideOfBlock
bool isUsedOutsideOfBlock(const BasicBlock *BB) const
Return true if there are any uses of this instruction in blocks other than the specified block.
Definition: Instruction.cpp:546
llvm::Instruction::isFuncletPad
bool isFuncletPad() const
Definition: Instruction.h:169
llvm::Instruction::dropUnknownNonDebugMetadata
void dropUnknownNonDebugMetadata(unsigned ID1, unsigned ID2)
Definition: Instruction.h:339
llvm::Instruction::getModule
Module * getModule()
Definition: Instruction.h:103
Casting.h
llvm::Instruction::setAAMetadata
void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
Definition: Metadata.cpp:1379
Bitfields.h
llvm::Instruction::isIntDivRem
static bool isIntDivRem(unsigned Opcode)
Definition: Instruction.h:195
llvm::Instruction::isEHPad
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Definition: Instruction.h:661
llvm::Bitfield::Element
Describes an element of a Bitfield.
Definition: Bitfields.h:223
llvm::Instruction::isUnaryOp
static bool isUnaryOp(unsigned Opcode)
Definition: Instruction.h:188
llvm::Instruction::isBitwiseLogicOp
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
Definition: Instruction.h:220
llvm::Instruction::hasAllowReassoc
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
Definition: Instruction.cpp:245
llvm::Instruction::isDebugOrPseudoInst
bool isDebugOrPseudoInst() const
Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst.
Definition: Instruction.cpp:723
llvm::Instruction::hasNoNaNs
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
Definition: Instruction.cpp:250
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:476
llvm::Instruction::setHasAllowReciprocal
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
Definition: Instruction.cpp:215
llvm::Instruction::getMetadata
MDNode * getMetadata(StringRef Kind) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:289
llvm::Instruction::BinaryOps
BinaryOps
Definition: Instruction.h:785
llvm::RecurKind::FAdd
@ FAdd
Sum of floats.
llvm::Instruction::isIdempotent
static bool isIdempotent(unsigned Opcode)
Definition: Instruction.h:573
llvm::Instruction::setHasNoInfs
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
Definition: Instruction.cpp:205
llvm::Instruction::getDebugLoc
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:370
User.h
llvm::ilist_alloc_traits::deleteNode
static void deleteNode(NodeTy *V)
Definition: ilist.h:41
llvm::Instruction::setHasNoSignedZeros
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
Definition: Instruction.cpp:210
llvm::Instruction::hasNoSignedWrap
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
Definition: Instruction.cpp:140
N
#define N
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:94
llvm::Value::deleteValue
void deleteValue()
Delete a pointer to a generic Value.
Definition: Value.cpp:110
llvm::Instruction::CompareUsingScalarTypes
@ CompareUsingScalarTypes
Check for equivalence treating a type and a vector of that type as equivalent.
Definition: Instruction.h:730
llvm::Instruction::isUnaryOp
bool isUnaryOp() const
Definition: Instruction.h:164
llvm::Instruction::swapProfMetadata
void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
Definition: Instruction.cpp:812
ilist_node.h
llvm::Instruction::copyIRFlags
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
Definition: Instruction.cpp:289
llvm::Value::getAllMetadata
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
Definition: Metadata.cpp:1223
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::msgpack::Type
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:49
llvm::Instruction::hasNoInfs
bool hasNoInfs() const
Determine whether the no-infs flag is set.
Definition: Instruction.cpp:255
llvm::Instruction::hasNoSignedZeros
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
Definition: Instruction.cpp:260
llvm::Instruction::getFunction
Function * getFunction()
Definition: Instruction.h:113
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::Instruction::isSameOperationAs
bool isSameOperationAs(const Instruction *I, unsigned flags=0) const
This function determines if the specified instruction executes the same operation as the current one.
Definition: Instruction.cpp:522
SymbolTableListTraits.h
llvm::tgtok::TrueVal
@ TrueVal
Definition: TGLexer.h:61
Value.h
llvm::Value::hasMetadata
bool hasMetadata() const
Return true if this value has any metadata attached to it.
Definition: Value.h:588
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Instruction::setHasAllowReassoc
void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
Definition: Instruction.cpp:195
llvm::Instruction::dropPoisonGeneratingFlags
void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs.
Definition: Instruction.cpp:144
llvm::Instruction::isIndirectTerminator
bool isIndirectTerminator() const
Definition: Instruction.h:178
llvm::Instruction::BasicBlock
friend class BasicBlock
Various leaf nodes.
Definition: Instruction.h:822
llvm::RecurKind::Xor
@ Xor
Bitwise or logical XOR of integers.
llvm::Instruction::moveBefore
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
Definition: Instruction.cpp:97
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:44
llvm::Instruction::hasMetadataOtherThanDebugLoc
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
Definition: Instruction.h:268
llvm::Instruction::isCast
static bool isCast(unsigned OpCode)
Determine if the OpCode is one of the CastInst instructions.
Definition: Instruction.h:225