LLVM  15.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 
12 namespace llvm {
13 
14 void Use::swap(Use &RHS) {
15  if (Val == RHS.Val)
16  return;
17 
18  std::swap(Val, RHS.Val);
19  std::swap(Next, RHS.Next);
20  std::swap(Prev, RHS.Prev);
21 
22  *Prev = this;
23  if (Next)
24  Next->Prev = &Next;
25 
26  *RHS.Prev = &RHS;
27  if (RHS.Next)
28  RHS.Next->Prev = &RHS.Next;
29 }
30 
31 unsigned Use::getOperandNo() const {
32  return this - getUser()->op_begin();
33 }
34 
35 void Use::zap(Use *Start, const Use *Stop, bool del) {
36  while (Start != Stop)
37  (--Stop)->~Use();
38  if (del)
39  ::operator delete(Start);
40 }
41 
42 } // namespace llvm
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
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:35
llvm::Use::getOperandNo
unsigned getOperandNo() const
Return the operand # of this use in its User.
Definition: Use.cpp:31
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
Use.h
llvm::Use::getUser
User * getUser() const
Returns the User that contains this Use.
Definition: Use.h:72
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:853
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:14
User.h
llvm::User::op_begin
op_iterator op_begin()
Definition: User.h:234
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43