[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / IR / Use.cpp
blob99049c0232aa3668d58d720ccdca67a036ad00af
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 //===----------------------------------------------------------------------===//
9 #include "llvm/IR/Use.h"
10 #include "llvm/IR/User.h"
11 #include "llvm/IR/Value.h"
12 #include <new>
14 namespace llvm {
16 void Use::swap(Use &RHS) {
17 if (Val == RHS.Val)
18 return;
20 std::swap(Val, RHS.Val);
21 std::swap(Next, RHS.Next);
22 std::swap(Prev, RHS.Prev);
24 *Prev = this;
25 if (Next)
26 Next->Prev = &Next;
28 *RHS.Prev = &RHS;
29 if (RHS.Next)
30 RHS.Next->Prev = &RHS.Next;
33 unsigned Use::getOperandNo() const {
34 return this - getUser()->op_begin();
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);
44 } // namespace llvm