LLVM 20.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 DataLayout;
33class DbgMarker;
34class FastMathFlags;
35class MDNode;
36class Module;
37struct AAMDNodes;
38class DbgMarker;
39class DbgRecord;
40
41template <> struct ilist_alloc_traits<Instruction> {
42 static inline void deleteNode(Instruction *V);
43};
44
47
52
53public:
54 InsertPosition(std::nullptr_t) : InsertAt() {}
55 LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead",
56 "BasicBlock::iterator")
57 InsertPosition(Instruction *InsertBefore);
58 InsertPosition(BasicBlock *InsertAtEnd);
59 InsertPosition(InstListType::iterator InsertAt) : InsertAt(InsertAt) {}
60 operator InstListType::iterator() const { return InsertAt; }
61 bool isValid() const { return InsertAt.isValid(); }
62 BasicBlock *getBasicBlock() { return InsertAt.getNodeParent(); }
63};
64
65class Instruction : public User,
66 public ilist_node_with_parent<Instruction, BasicBlock,
67 ilist_iterator_bits<true>,
68 ilist_parent<BasicBlock>> {
69public:
72
73private:
74 DebugLoc DbgLoc; // 'dbg' Metadata cache.
75
76 /// Relative order of this instruction in its parent basic block. Used for
77 /// O(1) local dominance checks between instructions.
78 mutable unsigned Order = 0;
79
80public:
81 /// Optional marker recording the position for debugging information that
82 /// takes effect immediately before this instruction. Null unless there is
83 /// debugging information present.
84 DbgMarker *DebugMarker = nullptr;
85
86 /// Clone any debug-info attached to \p From onto this instruction. Used to
87 /// copy debugging information from one block to another, when copying entire
88 /// blocks. \see DebugProgramInstruction.h , because the ordering of
89 /// DbgRecords is still important, fine grain control of which instructions
90 /// are moved and where they go is necessary.
91 /// \p From The instruction to clone debug-info from.
92 /// \p from_here Optional iterator to limit DbgRecords cloned to be a range
93 /// from
94 /// from_here to end().
95 /// \p InsertAtHead Whether the cloned DbgRecords should be placed at the end
96 /// or the beginning of existing DbgRecords attached to this.
97 /// \returns A range over the newly cloned DbgRecords.
99 const Instruction *From,
100 std::optional<simple_ilist<DbgRecord>::iterator> FromHere = std::nullopt,
101 bool InsertAtHead = false);
102
103 /// Return a range over the DbgRecords attached to this instruction.
105 return llvm::getDbgRecordRange(DebugMarker);
106 }
107
108 /// Return an iterator to the position of the "Next" DbgRecord after this
109 /// instruction, or std::nullopt. This is the position to pass to
110 /// BasicBlock::reinsertInstInDbgRecords when re-inserting an instruction.
111 std::optional<simple_ilist<DbgRecord>::iterator> getDbgReinsertionPosition();
112
113 /// Returns true if any DbgRecords are attached to this instruction.
114 bool hasDbgRecords() const;
115
116 /// Transfer any DbgRecords on the position \p It onto this instruction,
117 /// by simply adopting the sequence of DbgRecords (which is efficient) if
118 /// possible, by merging two sequences otherwise.
119 void adoptDbgRecords(BasicBlock *BB, InstListType::iterator It,
120 bool InsertAtHead);
121
122 /// Erase any DbgRecords attached to this instruction.
123 void dropDbgRecords();
124
125 /// Erase a single DbgRecord \p I that is attached to this instruction.
126 void dropOneDbgRecord(DbgRecord *I);
127
128 /// Handle the debug-info implications of this instruction being removed. Any
129 /// attached DbgRecords need to "fall" down onto the next instruction.
130 void handleMarkerRemoval();
131
132protected:
133 // The 15 first bits of `Value::SubclassData` are available for subclasses of
134 // `Instruction` to use.
136
137 // Template alias so that all Instruction storing alignment use the same
138 // definiton.
139 // Valid alignments are powers of two from 2^0 to 2^MaxAlignmentExponent =
140 // 2^32. We store them as Log2(Alignment), so we need 6 bits to encode the 33
141 // possible values.
142 template <unsigned Offset>
144 typename Bitfield::Element<unsigned, Offset, 6,
145 Value::MaxAlignmentExponent>;
146
147 template <unsigned Offset>
149
150 template <unsigned Offset>
153 AtomicOrdering::LAST>;
154
155private:
156 // The last bit is used to store whether the instruction has metadata attached
157 // or not.
159
160protected:
161 ~Instruction(); // Use deleteValue() to delete a generic Instruction.
162
163public:
164 Instruction(const Instruction &) = delete;
166
167 /// Specialize the methods defined in Value, as we know that an instruction
168 /// can only be used by other instructions.
169 Instruction *user_back() { return cast<Instruction>(*user_begin());}
170 const Instruction *user_back() const { return cast<Instruction>(*user_begin());}
171
172 /// Return the module owning the function this instruction belongs to
173 /// or nullptr it the function does not have a module.
174 ///
175 /// Note: this is undefined behavior if the instruction does not have a
176 /// parent, or the parent basic block does not have a parent function.
177 const Module *getModule() const;
179 return const_cast<Module *>(
180 static_cast<const Instruction *>(this)->getModule());
181 }
182
183 /// Return the function this instruction belongs to.
184 ///
185 /// Note: it is undefined behavior to call this on an instruction not
186 /// currently inserted into a function.
187 const Function *getFunction() const;
189 return const_cast<Function *>(
190 static_cast<const Instruction *>(this)->getFunction());
191 }
192
193 /// Get the data layout of the module this instruction belongs to.
194 ///
195 /// Requires the instruction to have a parent module.
196 const DataLayout &getDataLayout() const;
197
198 /// This method unlinks 'this' from the containing basic block, but does not
199 /// delete it.
200 void removeFromParent();
201
202 /// This method unlinks 'this' from the containing basic block and deletes it.
203 ///
204 /// \returns an iterator pointing to the element after the erased one
205 InstListType::iterator eraseFromParent();
206
207 /// Insert an unlinked instruction into a basic block immediately before
208 /// the specified instruction.
209 void insertBefore(Instruction *InsertPos);
210
211 /// Insert an unlinked instruction into a basic block immediately before
212 /// the specified position.
213 void insertBefore(InstListType::iterator InsertPos);
214
215 /// Insert an unlinked instruction into a basic block immediately after the
216 /// specified instruction.
217 void insertAfter(Instruction *InsertPos);
218
219 /// Insert an unlinked instruction into a basic block immediately after the
220 /// specified position.
221 void insertAfter(InstListType::iterator InsertPos);
222
223 /// Inserts an unlinked instruction into \p ParentBB at position \p It and
224 /// returns the iterator of the inserted instruction.
225 InstListType::iterator insertInto(BasicBlock *ParentBB,
226 InstListType::iterator It);
227
228 void insertBefore(BasicBlock &BB, InstListType::iterator InsertPos);
229
230 /// Unlink this instruction from its current basic block and insert it into
231 /// the basic block that MovePos lives in, right before MovePos.
232 void moveBefore(Instruction *MovePos);
233
234 /// Unlink this instruction from its current basic block and insert it into
235 /// the basic block that MovePos lives in, right before MovePos.
236 void moveBefore(InstListType::iterator InsertPos);
237
238 /// Perform a \ref moveBefore operation, while signalling that the caller
239 /// intends to preserve the original ordering of instructions. This implicitly
240 /// means that any adjacent debug-info should move with this instruction.
241 /// This method is currently a no-op placeholder, but it will become
242 /// meaningful when the "RemoveDIs" project is enabled.
243 void moveBeforePreserving(Instruction *MovePos);
244
245private:
246 /// RemoveDIs project: all other moves implemented with this method,
247 /// centralising debug-info updates into one place.
248 void moveBeforeImpl(BasicBlock &BB, InstListType::iterator I, bool Preserve);
249
250public:
251 /// Unlink this instruction and insert into BB before I.
252 ///
253 /// \pre I is a valid iterator into BB.
254 void moveBefore(BasicBlock &BB, InstListType::iterator I);
255
256 void moveBeforePreserving(BasicBlock &BB, InstListType::iterator I);
257 /// Unlink this instruction from its current basic block and insert it into
258 /// the basic block that MovePos lives in, right before MovePos.
259 void moveBeforePreserving(InstListType::iterator I);
260
261 /// Unlink this instruction from its current basic block and insert it into
262 /// the basic block that MovePos lives in, right after MovePos.
263 void moveAfter(Instruction *MovePos);
264
265 /// Unlink this instruction from its current basic block and insert it into
266 /// the basic block that MovePos lives in, right after MovePos.
268
269 /// See \ref moveBeforePreserving .
270 void moveAfterPreserving(Instruction *MovePos);
271
272 /// Given an instruction Other in the same basic block as this instruction,
273 /// return true if this instruction comes before Other. In this worst case,
274 /// this takes linear time in the number of instructions in the block. The
275 /// results are cached, so in common cases when the block remains unmodified,
276 /// it takes constant time.
277 bool comesBefore(const Instruction *Other) const;
278
279 /// Get the first insertion point at which the result of this instruction
280 /// is defined. This is *not* the directly following instruction in a number
281 /// of cases, e.g. phi nodes or terminators that return values. This function
282 /// may return null if the insertion after the definition is not possible,
283 /// e.g. due to a catchswitch terminator.
284 std::optional<InstListType::iterator> getInsertionPointAfterDef();
285
286 //===--------------------------------------------------------------------===//
287 // Subclass classification.
288 //===--------------------------------------------------------------------===//
289
290 /// Returns a member of one of the enums like Instruction::Add.
291 unsigned getOpcode() const { return getValueID() - InstructionVal; }
292
293 const char *getOpcodeName() const { return getOpcodeName(getOpcode()); }
294 bool isTerminator() const { return isTerminator(getOpcode()); }
295 bool isUnaryOp() const { return isUnaryOp(getOpcode()); }
296 bool isBinaryOp() const { return isBinaryOp(getOpcode()); }
297 bool isIntDivRem() const { return isIntDivRem(getOpcode()); }
298 bool isFPDivRem() const { return isFPDivRem(getOpcode()); }
299 bool isShift() const { return isShift(getOpcode()); }
300 bool isCast() const { return isCast(getOpcode()); }
301 bool isFuncletPad() const { return isFuncletPad(getOpcode()); }
303
304 /// It checks if this instruction is the only user of at least one of
305 /// its operands.
306 bool isOnlyUserOfAnyOperand();
307
308 static const char *getOpcodeName(unsigned Opcode);
309
310 static inline bool isTerminator(unsigned Opcode) {
311 return Opcode >= TermOpsBegin && Opcode < TermOpsEnd;
312 }
313
314 static inline bool isUnaryOp(unsigned Opcode) {
315 return Opcode >= UnaryOpsBegin && Opcode < UnaryOpsEnd;
316 }
317 static inline bool isBinaryOp(unsigned Opcode) {
318 return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd;
319 }
320
321 static inline bool isIntDivRem(unsigned Opcode) {
322 return Opcode == UDiv || Opcode == SDiv || Opcode == URem || Opcode == SRem;
323 }
324
325 static inline bool isFPDivRem(unsigned Opcode) {
326 return Opcode == FDiv || Opcode == FRem;
327 }
328
329 /// Determine if the Opcode is one of the shift instructions.
330 static inline bool isShift(unsigned Opcode) {
331 return Opcode >= Shl && Opcode <= AShr;
332 }
333
334 /// Return true if this is a logical shift left or a logical shift right.
335 inline bool isLogicalShift() const {
336 return getOpcode() == Shl || getOpcode() == LShr;
337 }
338
339 /// Return true if this is an arithmetic shift right.
340 inline bool isArithmeticShift() const {
341 return getOpcode() == AShr;
342 }
343
344 /// Determine if the Opcode is and/or/xor.
345 static inline bool isBitwiseLogicOp(unsigned Opcode) {
346 return Opcode == And || Opcode == Or || Opcode == Xor;
347 }
348
349 /// Return true if this is and/or/xor.
350 inline bool isBitwiseLogicOp() const {
351 return isBitwiseLogicOp(getOpcode());
352 }
353
354 /// Determine if the Opcode is one of the CastInst instructions.
355 static inline bool isCast(unsigned Opcode) {
356 return Opcode >= CastOpsBegin && Opcode < CastOpsEnd;
357 }
358
359 /// Determine if the Opcode is one of the FuncletPadInst instructions.
360 static inline bool isFuncletPad(unsigned Opcode) {
361 return Opcode >= FuncletPadOpsBegin && Opcode < FuncletPadOpsEnd;
362 }
363
364 /// Returns true if the Opcode is a "special" terminator that does more than
365 /// branch to a successor (e.g. have a side effect or return a value).
366 static inline bool isSpecialTerminator(unsigned Opcode) {
367 switch (Opcode) {
368 case Instruction::CatchSwitch:
369 case Instruction::CatchRet:
370 case Instruction::CleanupRet:
371 case Instruction::Invoke:
372 case Instruction::Resume:
373 case Instruction::CallBr:
374 return true;
375 default:
376 return false;
377 }
378 }
379
380 //===--------------------------------------------------------------------===//
381 // Metadata manipulation.
382 //===--------------------------------------------------------------------===//
383
384 /// Return true if this instruction has any metadata attached to it.
385 bool hasMetadata() const { return DbgLoc || Value::hasMetadata(); }
386
387 // Return true if this instruction contains loop metadata other than
388 // a debug location
389 bool hasNonDebugLocLoopMetadata() const;
390
391 /// Return true if this instruction has metadata attached to it other than a
392 /// debug location.
393 bool hasMetadataOtherThanDebugLoc() const { return Value::hasMetadata(); }
394
395 /// Return true if this instruction has the given type of metadata attached.
396 bool hasMetadata(unsigned KindID) const {
397 return getMetadata(KindID) != nullptr;
398 }
399
400 /// Return true if this instruction has the given type of metadata attached.
401 bool hasMetadata(StringRef Kind) const {
402 return getMetadata(Kind) != nullptr;
403 }
404
405 /// Get the metadata of given kind attached to this Instruction.
406 /// If the metadata is not found then return null.
407 MDNode *getMetadata(unsigned KindID) const {
408 // Handle 'dbg' as a special case since it is not stored in the hash table.
409 if (KindID == LLVMContext::MD_dbg)
410 return DbgLoc.getAsMDNode();
411 return Value::getMetadata(KindID);
412 }
413
414 /// Get the metadata of given kind attached to this Instruction.
415 /// If the metadata is not found then return null.
417 if (!hasMetadata()) return nullptr;
418 return getMetadataImpl(Kind);
419 }
420
421 /// Get all metadata attached to this Instruction. The first element of each
422 /// pair returned is the KindID, the second element is the metadata value.
423 /// This list is returned sorted by the KindID.
424 void
425 getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
426 if (hasMetadata())
427 getAllMetadataImpl(MDs);
428 }
429
430 /// This does the same thing as getAllMetadata, except that it filters out the
431 /// debug location.
433 SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
434 Value::getAllMetadata(MDs);
435 }
436
437 /// Set the metadata of the specified kind to the specified node. This updates
438 /// or replaces metadata if already present, or removes it if Node is null.
439 void setMetadata(unsigned KindID, MDNode *Node);
440 void setMetadata(StringRef Kind, MDNode *Node);
441
442 /// Copy metadata from \p SrcInst to this instruction. \p WL, if not empty,
443 /// specifies the list of meta data that needs to be copied. If \p WL is
444 /// empty, all meta data will be copied.
445 void copyMetadata(const Instruction &SrcInst,
447
448 /// Erase all metadata that matches the predicate.
449 void eraseMetadataIf(function_ref<bool(unsigned, MDNode *)> Pred);
450
451 /// If the instruction has "branch_weights" MD_prof metadata and the MDNode
452 /// has three operands (including name string), swap the order of the
453 /// metadata.
454 void swapProfMetadata();
455
456 /// Drop all unknown metadata except for debug locations.
457 /// @{
458 /// Passes are required to drop metadata they don't understand. This is a
459 /// convenience method for passes to do so.
460 /// dropUBImplyingAttrsAndUnknownMetadata should be used instead of
461 /// this API if the Instruction being modified is a call.
462 void dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs = {});
463 /// @}
464
465 /// Adds an !annotation metadata node with \p Annotation to this instruction.
466 /// If this instruction already has !annotation metadata, append \p Annotation
467 /// to the existing node.
468 void addAnnotationMetadata(StringRef Annotation);
469 /// Adds an !annotation metadata node with an array of \p Annotations
470 /// as a tuple to this instruction. If this instruction already has
471 /// !annotation metadata, append the tuple to
472 /// the existing node.
473 void addAnnotationMetadata(SmallVector<StringRef> Annotations);
474 /// Returns the AA metadata for this instruction.
475 AAMDNodes getAAMetadata() const;
476
477 /// Sets the AA metadata on this instruction from the AAMDNodes structure.
478 void setAAMetadata(const AAMDNodes &N);
479
480 /// Sets the nosanitize metadata on this instruction.
481 void setNoSanitizeMetadata();
482
483 /// Retrieve total raw weight values of a branch.
484 /// Returns true on success with profile total weights filled in.
485 /// Returns false if no metadata was found.
486 bool extractProfTotalWeight(uint64_t &TotalVal) const;
487
488 /// Set the debug location information for this instruction.
489 void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
490
491 /// Return the debug location for this node as a DebugLoc.
492 const DebugLoc &getDebugLoc() const { return DbgLoc; }
493
494 /// Fetch the debug location for this node, unless this is a debug intrinsic,
495 /// in which case fetch the debug location of the next non-debug node.
496 const DebugLoc &getStableDebugLoc() const;
497
498 /// Set or clear the nuw flag on this instruction, which must be an operator
499 /// which supports this flag. See LangRef.html for the meaning of this flag.
500 void setHasNoUnsignedWrap(bool b = true);
501
502 /// Set or clear the nsw flag on this instruction, which must be an operator
503 /// which supports this flag. See LangRef.html for the meaning of this flag.
504 void setHasNoSignedWrap(bool b = true);
505
506 /// Set or clear the exact flag on this instruction, which must be an operator
507 /// which supports this flag. See LangRef.html for the meaning of this flag.
508 void setIsExact(bool b = true);
509
510 /// Set or clear the nneg flag on this instruction, which must be a zext
511 /// instruction.
512 void setNonNeg(bool b = true);
513
514 /// Determine whether the no unsigned wrap flag is set.
516
517 /// Determine whether the no signed wrap flag is set.
519
520 /// Determine whether the the nneg flag is set.
521 bool hasNonNeg() const LLVM_READONLY;
522
523 /// Return true if this operator has flags which may cause this instruction
524 /// to evaluate to poison despite having non-poison inputs.
525 bool hasPoisonGeneratingFlags() const LLVM_READONLY;
526
527 /// Drops flags that may cause this instruction to evaluate to poison despite
528 /// having non-poison inputs.
529 void dropPoisonGeneratingFlags();
530
531 /// Return true if this instruction has poison-generating metadata.
532 bool hasPoisonGeneratingMetadata() const LLVM_READONLY;
533
534 /// Drops metadata that may generate poison.
535 void dropPoisonGeneratingMetadata();
536
537 /// Return true if this instruction has poison-generating attribute.
538 bool hasPoisonGeneratingReturnAttributes() const LLVM_READONLY;
539
540 /// Drops return attributes that may generate poison.
541 void dropPoisonGeneratingReturnAttributes();
542
543 /// Return true if this instruction has poison-generating flags,
544 /// return attributes or metadata.
545 bool hasPoisonGeneratingAnnotations() const {
546 return hasPoisonGeneratingFlags() ||
547 hasPoisonGeneratingReturnAttributes() ||
548 hasPoisonGeneratingMetadata();
549 }
550
551 /// Drops flags, return attributes and metadata that may generate poison.
553 dropPoisonGeneratingFlags();
554 dropPoisonGeneratingReturnAttributes();
555 dropPoisonGeneratingMetadata();
556 }
557
558 /// This function drops non-debug unknown metadata (through
559 /// dropUnknownNonDebugMetadata). For calls, it also drops parameter and
560 /// return attributes that can cause undefined behaviour. Both of these should
561 /// be done by passes which move instructions in IR.
562 void dropUBImplyingAttrsAndUnknownMetadata(ArrayRef<unsigned> KnownIDs = {});
563
564 /// Drop any attributes or metadata that can cause immediate undefined
565 /// behavior. Retain other attributes/metadata on a best-effort basis.
566 /// This should be used when speculating instructions.
567 void dropUBImplyingAttrsAndMetadata();
568
569 /// Determine whether the exact flag is set.
570 bool isExact() const LLVM_READONLY;
571
572 /// Set or clear all fast-math-flags on this instruction, which must be an
573 /// operator which supports this flag. See LangRef.html for the meaning of
574 /// this flag.
575 void setFast(bool B);
576
577 /// Set or clear the reassociation flag on this instruction, which must be
578 /// an operator which supports this flag. See LangRef.html for the meaning of
579 /// this flag.
580 void setHasAllowReassoc(bool B);
581
582 /// Set or clear the no-nans flag on this instruction, which must be an
583 /// operator which supports this flag. See LangRef.html for the meaning of
584 /// this flag.
585 void setHasNoNaNs(bool B);
586
587 /// Set or clear the no-infs flag on this instruction, which must be an
588 /// operator which supports this flag. See LangRef.html for the meaning of
589 /// this flag.
590 void setHasNoInfs(bool B);
591
592 /// Set or clear the no-signed-zeros flag on this instruction, which must be
593 /// an operator which supports this flag. See LangRef.html for the meaning of
594 /// this flag.
595 void setHasNoSignedZeros(bool B);
596
597 /// Set or clear the allow-reciprocal flag on this instruction, which must be
598 /// an operator which supports this flag. See LangRef.html for the meaning of
599 /// this flag.
600 void setHasAllowReciprocal(bool B);
601
602 /// Set or clear the allow-contract flag on this instruction, which must be
603 /// an operator which supports this flag. See LangRef.html for the meaning of
604 /// this flag.
605 void setHasAllowContract(bool B);
606
607 /// Set or clear the approximate-math-functions flag on this instruction,
608 /// which must be an operator which supports this flag. See LangRef.html for
609 /// the meaning of this flag.
610 void setHasApproxFunc(bool B);
611
612 /// Convenience function for setting multiple fast-math flags on this
613 /// instruction, which must be an operator which supports these flags. See
614 /// LangRef.html for the meaning of these flags.
615 void setFastMathFlags(FastMathFlags FMF);
616
617 /// Convenience function for transferring all fast-math flag values to this
618 /// instruction, which must be an operator which supports these flags. See
619 /// LangRef.html for the meaning of these flags.
620 void copyFastMathFlags(FastMathFlags FMF);
621
622 /// Determine whether all fast-math-flags are set.
623 bool isFast() const LLVM_READONLY;
624
625 /// Determine whether the allow-reassociation flag is set.
626 bool hasAllowReassoc() const LLVM_READONLY;
627
628 /// Determine whether the no-NaNs flag is set.
629 bool hasNoNaNs() const LLVM_READONLY;
630
631 /// Determine whether the no-infs flag is set.
633
634 /// Determine whether the no-signed-zeros flag is set.
635 bool hasNoSignedZeros() const LLVM_READONLY;
636
637 /// Determine whether the allow-reciprocal flag is set.
638 bool hasAllowReciprocal() const LLVM_READONLY;
639
640 /// Determine whether the allow-contract flag is set.
641 bool hasAllowContract() const LLVM_READONLY;
642
643 /// Determine whether the approximate-math-functions flag is set.
644 bool hasApproxFunc() const LLVM_READONLY;
645
646 /// Convenience function for getting all the fast-math flags, which must be an
647 /// operator which supports these flags. See LangRef.html for the meaning of
648 /// these flags.
649 FastMathFlags getFastMathFlags() const LLVM_READONLY;
650
651 /// Copy I's fast-math flags
652 void copyFastMathFlags(const Instruction *I);
653
654 /// Convenience method to copy supported exact, fast-math, and (optionally)
655 /// wrapping flags from V to this instruction.
656 void copyIRFlags(const Value *V, bool IncludeWrapFlags = true);
657
658 /// Logical 'and' of any supported wrapping, exact, and fast-math flags of
659 /// V and this instruction.
660 void andIRFlags(const Value *V);
661
662 /// Merge 2 debug locations and apply it to the Instruction. If the
663 /// instruction is a CallIns, we need to traverse the inline chain to find
664 /// the common scope. This is not efficient for N-way merging as each time
665 /// you merge 2 iterations, you need to rebuild the hashmap to find the
666 /// common scope. However, we still choose this API because:
667 /// 1) Simplicity: it takes 2 locations instead of a list of locations.
668 /// 2) In worst case, it increases the complexity from O(N*I) to
669 /// O(2*N*I), where N is # of Instructions to merge, and I is the
670 /// maximum level of inline stack. So it is still linear.
671 /// 3) Merging of call instructions should be extremely rare in real
672 /// applications, thus the N-way merging should be in code path.
673 /// The DebugLoc attached to this instruction will be overwritten by the
674 /// merged DebugLoc.
675 void applyMergedLocation(DILocation *LocA, DILocation *LocB);
676
677 /// Updates the debug location given that the instruction has been hoisted
678 /// from a block to a predecessor of that block.
679 /// Note: it is undefined behavior to call this on an instruction not
680 /// currently inserted into a function.
681 void updateLocationAfterHoist();
682
683 /// Drop the instruction's debug location. This does not guarantee removal
684 /// of the !dbg source location attachment, as it must set a line 0 location
685 /// with scope information attached on call instructions. To guarantee
686 /// removal of the !dbg attachment, use the \ref setDebugLoc() API.
687 /// Note: it is undefined behavior to call this on an instruction not
688 /// currently inserted into a function.
689 void dropLocation();
690
691 /// Merge the DIAssignID metadata from this instruction and those attached to
692 /// instructions in \p SourceInstructions. This process performs a RAUW on
693 /// the MetadataAsValue uses of the merged DIAssignID nodes. Not every
694 /// instruction in \p SourceInstructions needs to have DIAssignID
695 /// metadata. If none of them do then nothing happens. If this instruction
696 /// does not have a DIAssignID attachment but at least one in \p
697 /// SourceInstructions does then the merged one will be attached to
698 /// it. However, instructions without attachments in \p SourceInstructions
699 /// are not modified.
700 void mergeDIAssignID(ArrayRef<const Instruction *> SourceInstructions);
701
702private:
703 // These are all implemented in Metadata.cpp.
704 MDNode *getMetadataImpl(StringRef Kind) const;
705 void
706 getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const;
707
708 /// Update the LLVMContext ID-to-Instruction(s) mapping. If \p ID is nullptr
709 /// then clear the mapping for this instruction.
710 void updateDIAssignIDMapping(DIAssignID *ID);
711
712public:
713 //===--------------------------------------------------------------------===//
714 // Predicates and helper methods.
715 //===--------------------------------------------------------------------===//
716
717 /// Return true if the instruction is associative:
718 ///
719 /// Associative operators satisfy: x op (y op z) === (x op y) op z
720 ///
721 /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
722 ///
724 static bool isAssociative(unsigned Opcode) {
725 return Opcode == And || Opcode == Or || Opcode == Xor ||
726 Opcode == Add || Opcode == Mul;
727 }
728
729 /// Return true if the instruction is commutative:
730 ///
731 /// Commutative operators satisfy: (x op y) === (y op x)
732 ///
733 /// In LLVM, these are the commutative operators, plus SetEQ and SetNE, when
734 /// applied to any type.
735 ///
737 static bool isCommutative(unsigned Opcode) {
738 switch (Opcode) {
739 case Add: case FAdd:
740 case Mul: case FMul:
741 case And: case Or: case Xor:
742 return true;
743 default:
744 return false;
745 }
746 }
747
748 /// Return true if the instruction is idempotent:
749 ///
750 /// Idempotent operators satisfy: x op x === x
751 ///
752 /// In LLVM, the And and Or operators are idempotent.
753 ///
754 bool isIdempotent() const { return isIdempotent(getOpcode()); }
755 static bool isIdempotent(unsigned Opcode) {
756 return Opcode == And || Opcode == Or;
757 }
758
759 /// Return true if the instruction is nilpotent:
760 ///
761 /// Nilpotent operators satisfy: x op x === Id,
762 ///
763 /// where Id is the identity for the operator, i.e. a constant such that
764 /// x op Id === x and Id op x === x for all x.
765 ///
766 /// In LLVM, the Xor operator is nilpotent.
767 ///
768 bool isNilpotent() const { return isNilpotent(getOpcode()); }
769 static bool isNilpotent(unsigned Opcode) {
770 return Opcode == Xor;
771 }
772
773 /// Return true if this instruction may modify memory.
774 bool mayWriteToMemory() const LLVM_READONLY;
775
776 /// Return true if this instruction may read memory.
777 bool mayReadFromMemory() const LLVM_READONLY;
778
779 /// Return true if this instruction may read or write memory.
780 bool mayReadOrWriteMemory() const {
781 return mayReadFromMemory() || mayWriteToMemory();
782 }
783
784 /// Return true if this instruction has an AtomicOrdering of unordered or
785 /// higher.
786 bool isAtomic() const LLVM_READONLY;
787
788 /// Return true if this atomic instruction loads from memory.
789 bool hasAtomicLoad() const LLVM_READONLY;
790
791 /// Return true if this atomic instruction stores to memory.
792 bool hasAtomicStore() const LLVM_READONLY;
793
794 /// Return true if this instruction has a volatile memory access.
795 bool isVolatile() const LLVM_READONLY;
796
797 /// Return the type this instruction accesses in memory, if any.
799
800 /// Return true if this instruction may throw an exception.
801 ///
802 /// If IncludePhaseOneUnwind is set, this will also include cases where
803 /// phase one unwinding may unwind past this frame due to skipping of
804 /// cleanup landingpads.
805 bool mayThrow(bool IncludePhaseOneUnwind = false) const LLVM_READONLY;
806
807 /// Return true if this instruction behaves like a memory fence: it can load
808 /// or store to memory location without being given a memory location.
809 bool isFenceLike() const {
810 switch (getOpcode()) {
811 default:
812 return false;
813 // This list should be kept in sync with the list in mayWriteToMemory for
814 // all opcodes which don't have a memory location.
815 case Instruction::Fence:
816 case Instruction::CatchPad:
817 case Instruction::CatchRet:
818 case Instruction::Call:
819 case Instruction::Invoke:
820 return true;
821 }
822 }
823
824 /// Return true if the instruction may have side effects.
825 ///
826 /// Side effects are:
827 /// * Writing to memory.
828 /// * Unwinding.
829 /// * Not returning (e.g. an infinite loop).
830 ///
831 /// Note that this does not consider malloc and alloca to have side
832 /// effects because the newly allocated memory is completely invisible to
833 /// instructions which don't use the returned value. For cases where this
834 /// matters, isSafeToSpeculativelyExecute may be more appropriate.
836
837 /// Return true if the instruction can be removed if the result is unused.
838 ///
839 /// When constant folding some instructions cannot be removed even if their
840 /// results are unused. Specifically terminator instructions and calls that
841 /// may have side effects cannot be removed without semantically changing the
842 /// generated program.
843 bool isSafeToRemove() const LLVM_READONLY;
844
845 /// Return true if the instruction will return (unwinding is considered as
846 /// a form of returning control flow here).
847 bool willReturn() const LLVM_READONLY;
848
849 /// Return true if the instruction is a variety of EH-block.
850 bool isEHPad() const {
851 switch (getOpcode()) {
852 case Instruction::CatchSwitch:
853 case Instruction::CatchPad:
854 case Instruction::CleanupPad:
855 case Instruction::LandingPad:
856 return true;
857 default:
858 return false;
859 }
860 }
861
862 /// Return true if the instruction is a llvm.lifetime.start or
863 /// llvm.lifetime.end marker.
864 bool isLifetimeStartOrEnd() const LLVM_READONLY;
865
866 /// Return true if the instruction is a llvm.launder.invariant.group or
867 /// llvm.strip.invariant.group.
868 bool isLaunderOrStripInvariantGroup() const LLVM_READONLY;
869
870 /// Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst.
871 bool isDebugOrPseudoInst() const LLVM_READONLY;
872
873 /// Return a pointer to the next non-debug instruction in the same basic
874 /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo
875 /// operations if \c SkipPseudoOp is true.
877 getNextNonDebugInstruction(bool SkipPseudoOp = false) const;
878 Instruction *getNextNonDebugInstruction(bool SkipPseudoOp = false) {
879 return const_cast<Instruction *>(
880 static_cast<const Instruction *>(this)->getNextNonDebugInstruction(
881 SkipPseudoOp));
882 }
883
884 /// Return a pointer to the previous non-debug instruction in the same basic
885 /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo
886 /// operations if \c SkipPseudoOp is true.
887 const Instruction *
888 getPrevNonDebugInstruction(bool SkipPseudoOp = false) const;
889 Instruction *getPrevNonDebugInstruction(bool SkipPseudoOp = false) {
890 return const_cast<Instruction *>(
891 static_cast<const Instruction *>(this)->getPrevNonDebugInstruction(
892 SkipPseudoOp));
893 }
894
895 /// Create a copy of 'this' instruction that is identical in all ways except
896 /// the following:
897 /// * The instruction has no parent
898 /// * The instruction has no name
899 ///
900 Instruction *clone() const;
901
902 /// Return true if the specified instruction is exactly identical to the
903 /// current one. This means that all operands match and any extra information
904 /// (e.g. load is volatile) agree.
905 bool isIdenticalTo(const Instruction *I) const LLVM_READONLY;
906
907 /// This is like isIdenticalTo, except that it ignores the
908 /// SubclassOptionalData flags, which may specify conditions under which the
909 /// instruction's result is undefined.
910 bool
911 isIdenticalToWhenDefined(const Instruction *I,
912 bool IntersectAttrs = false) const LLVM_READONLY;
913
914 /// When checking for operation equivalence (using isSameOperationAs) it is
915 /// sometimes useful to ignore certain attributes.
917 /// Check for equivalence ignoring load/store alignment.
918 CompareIgnoringAlignment = 1 << 0,
919 /// Check for equivalence treating a type and a vector of that type
920 /// as equivalent.
921 CompareUsingScalarTypes = 1 << 1,
922 /// Check for equivalence with intersected callbase attrs.
923 CompareUsingIntersectedAttrs = 1 << 2,
924 };
925
926 /// This function determines if the specified instruction executes the same
927 /// operation as the current one. This means that the opcodes, type, operand
928 /// types and any other factors affecting the operation must be the same. This
929 /// is similar to isIdenticalTo except the operands themselves don't have to
930 /// be identical.
931 /// @returns true if the specified instruction is the same operation as
932 /// the current one.
933 /// Determine if one instruction is the same operation as another.
934 bool isSameOperationAs(const Instruction *I, unsigned flags = 0) const LLVM_READONLY;
935
936 /// This function determines if the speficied instruction has the same
937 /// "special" characteristics as the current one. This means that opcode
938 /// specific details are the same. As a common example, if we are comparing
939 /// loads, then hasSameSpecialState would compare the alignments (among
940 /// other things).
941 /// @returns true if the specific instruction has the same opcde specific
942 /// characteristics as the current one. Determine if one instruction has the
943 /// same state as another.
944 bool hasSameSpecialState(const Instruction *I2, bool IgnoreAlignment = false,
945 bool IntersectAttrs = false) const LLVM_READONLY;
946
947 /// Return true if there are any uses of this instruction in blocks other than
948 /// the specified block. Note that PHI nodes are considered to evaluate their
949 /// operands in the corresponding predecessor block.
950 bool isUsedOutsideOfBlock(const BasicBlock *BB) const LLVM_READONLY;
951
952 /// Return the number of successors that this instruction has. The instruction
953 /// must be a terminator.
954 unsigned getNumSuccessors() const LLVM_READONLY;
955
956 /// Return the specified successor. This instruction must be a terminator.
957 BasicBlock *getSuccessor(unsigned Idx) const LLVM_READONLY;
958
959 /// Update the specified successor to point at the provided block. This
960 /// instruction must be a terminator.
961 void setSuccessor(unsigned Idx, BasicBlock *BB);
962
963 /// Replace specified successor OldBB to point at the provided block.
964 /// This instruction must be a terminator.
965 void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB);
966
967 /// Methods for support type inquiry through isa, cast, and dyn_cast:
968 static bool classof(const Value *V) {
969 return V->getValueID() >= Value::InstructionVal;
970 }
971
972 //----------------------------------------------------------------------
973 // Exported enumerations.
974 //
975 enum TermOps { // These terminate basic blocks
976#define FIRST_TERM_INST(N) TermOpsBegin = N,
977#define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N,
978#define LAST_TERM_INST(N) TermOpsEnd = N+1
979#include "llvm/IR/Instruction.def"
980 };
981
982 enum UnaryOps {
983#define FIRST_UNARY_INST(N) UnaryOpsBegin = N,
984#define HANDLE_UNARY_INST(N, OPC, CLASS) OPC = N,
985#define LAST_UNARY_INST(N) UnaryOpsEnd = N+1
986#include "llvm/IR/Instruction.def"
987 };
988
990#define FIRST_BINARY_INST(N) BinaryOpsBegin = N,
991#define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N,
992#define LAST_BINARY_INST(N) BinaryOpsEnd = N+1
993#include "llvm/IR/Instruction.def"
994 };
995
997#define FIRST_MEMORY_INST(N) MemoryOpsBegin = N,
998#define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N,
999#define LAST_MEMORY_INST(N) MemoryOpsEnd = N+1
1000#include "llvm/IR/Instruction.def"
1001 };
1002
1003 enum CastOps {
1004#define FIRST_CAST_INST(N) CastOpsBegin = N,
1005#define HANDLE_CAST_INST(N, OPC, CLASS) OPC = N,
1006#define LAST_CAST_INST(N) CastOpsEnd = N+1
1007#include "llvm/IR/Instruction.def"
1008 };
1009
1011#define FIRST_FUNCLETPAD_INST(N) FuncletPadOpsBegin = N,
1012#define HANDLE_FUNCLETPAD_INST(N, OPC, CLASS) OPC = N,
1013#define LAST_FUNCLETPAD_INST(N) FuncletPadOpsEnd = N+1
1014#include "llvm/IR/Instruction.def"
1015 };
1016
1018#define FIRST_OTHER_INST(N) OtherOpsBegin = N,
1019#define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N,
1020#define LAST_OTHER_INST(N) OtherOpsEnd = N+1
1021#include "llvm/IR/Instruction.def"
1022 };
1023
1024private:
1025 friend class SymbolTableListTraits<Instruction, ilist_iterator_bits<true>,
1026 ilist_parent<BasicBlock>>;
1027 friend class BasicBlock; // For renumbering.
1028
1029 // Shadow Value::setValueSubclassData with a private forwarding method so that
1030 // subclasses cannot accidentally use it.
1031 void setValueSubclassData(unsigned short D) {
1032 Value::setValueSubclassData(D);
1033 }
1034
1035 unsigned short getSubclassDataFromValue() const {
1036 return Value::getSubclassDataFromValue();
1037 }
1038
1039protected:
1040 // Instruction subclasses can stick up to 15 bits of stuff into the
1041 // SubclassData field of instruction with these members.
1042
1043 template <typename BitfieldElement>
1044 typename BitfieldElement::Type getSubclassData() const {
1045 static_assert(
1046 std::is_same<BitfieldElement, HasMetadataField>::value ||
1047 !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
1048 "Must not overlap with the metadata bit");
1049 return Bitfield::get<BitfieldElement>(getSubclassDataFromValue());
1050 }
1051
1052 template <typename BitfieldElement>
1053 void setSubclassData(typename BitfieldElement::Type Value) {
1054 static_assert(
1055 std::is_same<BitfieldElement, HasMetadataField>::value ||
1056 !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
1057 "Must not overlap with the metadata bit");
1058 auto Storage = getSubclassDataFromValue();
1059 Bitfield::set<BitfieldElement>(Storage, Value);
1060 setValueSubclassData(Storage);
1061 }
1062
1063 Instruction(Type *Ty, unsigned iType, AllocInfo AllocInfo,
1064 InsertPosition InsertBefore = nullptr);
1065
1066private:
1067 /// Create a copy of this instruction.
1068 Instruction *cloneImpl() const;
1069};
1070
1072 V->deleteValue();
1073}
1074
1075} // end namespace llvm
1076
1077#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.
BlockVerifier::State From
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:306
static bool hasNoInfs(const TargetOptions &Options, SDValue N)
static StringRef getOpcodeName(uint8_t Opcode, uint8_t OpcodeBase)
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
std::optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1315
uint64_t Offset
Definition: ELF_riscv.cpp:478
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:235
static bool hasNoSignedWrap(BinaryOperator &I)
static bool hasNoUnsignedWrap(BinaryOperator &I)
static MemAccessTy getAccessType(const TargetTransformInfo &TTI, Instruction *Inst, Value *OperandVal)
Return the type of the memory being accessed.
#define I(x, y, z)
Definition: MD5.cpp:58
Machine Check Debug Module
static bool mayHaveSideEffects(MachineInstr &MI)
static bool isCommutative(Instruction *I)
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition: VPlanSLP.cpp:191
static bool isAssociative(const COFFSection &Section)
BinaryOperator * Mul
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:61
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
Per-instruction record of debug-info.
Base class for non-instruction debug metadata records that have positions within IR.
A debug info location.
Definition: DebugLoc.h:33
MDNode * getAsMDNode() const
Return this as a bar MDNode.
Definition: DebugLoc.h:106
bool isValid() const
Definition: Instruction.h:61
BasicBlock * getBasicBlock()
Definition: Instruction.h:62
InsertPosition(std::nullptr_t)
Definition: Instruction.h:54
LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead", "BasicBlock::iterator") InsertPosition(Instruction *InsertBefore)
operator InstListType::iterator() const
Definition: Instruction.h:60
BitfieldElement::Type getSubclassData() const
Definition: Instruction.h:1044
bool hasMetadata(unsigned KindID) const
Return true if this instruction has the given type of metadata attached.
Definition: Instruction.h:396
static bool isBinaryOp(unsigned Opcode)
Definition: Instruction.h:317
bool isArithmeticShift() const
Return true if this is an arithmetic shift right.
Definition: Instruction.h:340
bool hasMetadata(StringRef Kind) const
Return true if this instruction has the given type of metadata attached.
Definition: Instruction.h:401
static bool isFPDivRem(unsigned Opcode)
Definition: Instruction.h:325
bool isCast() const
Definition: Instruction.h:300
static bool isBitwiseLogicOp(unsigned Opcode)
Determine if the Opcode is and/or/xor.
Definition: Instruction.h:345
static bool isShift(unsigned Opcode)
Determine if the Opcode is one of the shift instructions.
Definition: Instruction.h:330
Function * getFunction()
Definition: Instruction.h:188
static bool isSpecialTerminator(unsigned Opcode)
Returns true if the Opcode is a "special" terminator that does more than branch to a successor (e....
Definition: Instruction.h:366
typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT
Definition: Instruction.h:153
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange() const
Return a range over the DbgRecords attached to this instruction.
Definition: Instruction.h:104
static bool isCast(unsigned Opcode)
Determine if the Opcode is one of the CastInst instructions.
Definition: Instruction.h:355
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:492
Instruction & operator=(const Instruction &)=delete
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
Definition: Instruction.h:393
typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT
Definition: Instruction.h:148
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
Definition: Instruction.h:385
Module * getModule()
Definition: Instruction.h:178
bool isBinaryOp() const
Definition: Instruction.h:296
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:169
static bool isIdempotent(unsigned Opcode)
Definition: Instruction.h:755
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:407
bool isFuncletPad() const
Definition: Instruction.h:301
bool isTerminator() const
Definition: Instruction.h:294
typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT
Definition: Instruction.h:145
Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false)
Definition: Instruction.h:889
bool isNilpotent() const
Return true if the instruction is nilpotent:
Definition: Instruction.h:768
void dropPoisonGeneratingAnnotations()
Drops flags, return attributes and metadata that may generate poison.
Definition: Instruction.h:552
const char * getOpcodeName() const
Definition: Instruction.h:293
const Instruction * user_back() const
Definition: Instruction.h:170
bool isFPDivRem() const
Definition: Instruction.h:298
OperationEquivalenceFlags
When checking for operation equivalence (using isSameOperationAs) it is sometimes useful to ignore ce...
Definition: Instruction.h:916
MDNode * getMetadata(StringRef Kind) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:416
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Get all metadata attached to this Instruction.
Definition: Instruction.h:425
bool isLogicalShift() const
Return true if this is a logical shift left or a logical shift right.
Definition: Instruction.h:335
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:432
static bool isFuncletPad(unsigned Opcode)
Determine if the Opcode is one of the FuncletPadInst instructions.
Definition: Instruction.h:360
static bool isUnaryOp(unsigned Opcode)
Definition: Instruction.h:314
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:291
static bool isNilpotent(unsigned Opcode)
Definition: Instruction.h:769
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
Definition: Instruction.h:350
bool isShift() const
Definition: Instruction.h:299
static bool isTerminator(unsigned Opcode)
Definition: Instruction.h:310
void moveAfter(InstListType::iterator MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
bool isUnaryOp() const
Definition: Instruction.h:295
Instruction(const Instruction &)=delete
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:489
static bool isIntDivRem(unsigned Opcode)
Definition: Instruction.h:321
bool isIdempotent() const
Return true if the instruction is idempotent:
Definition: Instruction.h:754
bool isIntDivRem() const
Definition: Instruction.h:297
void setSubclassData(typename BitfieldElement::Type Value)
Definition: Instruction.h:1053
bool isSpecialTerminator() const
Definition: Instruction.h:302
Metadata node.
Definition: Metadata.h:1073
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:573
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
An efficient, type-erasing, non-owning reference to a callable.
An ilist node that can access its parent list.
Definition: ilist_node.h:321
base_list_type::iterator iterator
Definition: ilist.h:121
A range adaptor for a pair of iterators.
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, false >::type iterator
Definition: simple_ilist.h:97
This file defines the ilist_node class template, which is a convenient base class for creating classe...
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange(DbgMarker *DebugMarker)
Inline helper to return a range of DbgRecords attached to a marker.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Xor
Bitwise or logical XOR of integers.
@ FMul
Product of floats.
@ And
Bitwise or logical AND of integers.
@ FAdd
Sum of floats.
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
#define N
Summary of memprof metadata on allocations.
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
Option to add a pointer to this list's owner in every node.