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