[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / IR / Use.cpp
blob99a89386d75f92be9539b49af95aa24230b33f83
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"
12 namespace llvm {
14 void Use::swap(Use &RHS) {
15 if (Val == RHS.Val)
16 return;
18 std::swap(Val, RHS.Val);
19 std::swap(Next, RHS.Next);
20 std::swap(Prev, RHS.Prev);
22 *Prev = this;
23 if (Next)
24 Next->Prev = &Next;
26 *RHS.Prev = &RHS;
27 if (RHS.Next)
28 RHS.Next->Prev = &RHS.Next;
31 unsigned Use::getOperandNo() const {
32 return this - getUser()->op_begin();
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);
42 } // namespace llvm