LLVM  13.0.0git
Use.cpp
Go to the documentation of this file.
1 //===-- Use.cpp - Implement the Use class ---------------------------------===//
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 #include "llvm/IR/Use.h"
10 #include "llvm/IR/User.h"
11 #include "llvm/IR/Value.h"
12 #include <new>
13 
14 namespace llvm {
15 
16 void Use::swap(Use &RHS) {
17  if (Val == RHS.Val)
18  return;
19 
20  std::swap(Val, RHS.Val);
21  std::swap(Next, RHS.Next);
22  std::swap(Prev, RHS.Prev);
23 
24  *Prev = this;
25  if (Next)
26  Next->Prev = &Next;
27 
28  *RHS.Prev = &RHS;
29  if (RHS.Next)
30  RHS.Next->Prev = &RHS.Next;
31 }
32 
33 unsigned Use::getOperandNo() const {
34  return this - getUser()->op_begin();
35 }
36 
37 void Use::zap(Use *Start, const Use *Stop, bool del) {
38  while (Start != Stop)
39  (--Stop)->~Use();
40  if (del)
41  ::operator delete(Start);
42 }
43 
44 } // namespace llvm
llvm
Definition: AllocatorList.h:23
llvm::Use::zap
static void zap(Use *Start, const Use *Stop, bool del=false)
Destroys Use operands when the number of operands of a User changes.
Definition: Use.cpp:37
llvm::Use::getOperandNo
unsigned getOperandNo() const
Return the operand # of this use in its User.
Definition: Use.cpp:33
Use.h
llvm::Use::getUser
User * getUser() const
Returns the User that contains this Use.
Definition: Use.h:73
llvm::Use::Use
Use(const Use &U)=delete
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:840
llvm::Use::swap
void swap(Use &RHS)
Provide a fast substitute to std::swap<Use> that also works with less standard-compliant compilers.
Definition: Use.cpp:16
User.h
llvm::User::op_begin
op_iterator op_begin()
Definition: User.h:234
Value.h
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:44