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