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