LLVM 23.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"
11#include "llvm/IR/User.h"
12
13using namespace llvm;
14
15void Use::swap(Use &RHS) {
16 if (Val == RHS.Val)
17 return;
18
19 std::swap(Val, RHS.Val);
20 std::swap(Next, RHS.Next);
21 std::swap(Prev, RHS.Prev);
22
23 if (Prev)
24 *Prev = this;
25
26 if (Next)
27 Next->Prev = &Next;
28
29 if (RHS.Prev)
30 *RHS.Prev = &RHS;
31
32 if (RHS.Next)
33 RHS.Next->Prev = &RHS.Next;
34}
35
36unsigned Use::getOperandNo() const {
37 return this - getUser()->op_begin();
38}
39
40void Use::zap(Use *Start, const Use *Stop, bool del) {
41 while (Start != Stop)
42 (--Stop)->~Use();
43 if (del)
44 ::operator delete(Start);
45}
This defines the Use class.
Value * RHS
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM_ABI unsigned getOperandNo() const
Return the operand # of this use in its User.
Definition Use.cpp:36
static LLVM_ABI 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:40
LLVM_ABI void swap(Use &RHS)
Provide a fast substitute to std::swap<Use> that also works with less standard-compliant compilers.
Definition Use.cpp:15
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Next
Definition InstrProf.h:141
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:863