2008-05-15 18:04:30 +08:00
|
|
|
//===-- Use.cpp - Implement the Use class ---------------------------------===//
|
2008-05-10 16:32:32 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2008-05-10 16:32:32 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-03-04 16:51:00 +08:00
|
|
|
#include "llvm/IR/Use.h"
|
2014-03-04 17:19:43 +08:00
|
|
|
#include "llvm/IR/User.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Value.h"
|
2012-03-26 22:04:17 +08:00
|
|
|
#include <new>
|
2008-05-10 16:32:32 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2008-05-14 06:51:52 +08:00
|
|
|
void Use::swap(Use &RHS) {
|
2014-03-04 17:00:15 +08:00
|
|
|
if (Val == RHS.Val)
|
|
|
|
return;
|
2008-05-14 06:51:52 +08:00
|
|
|
|
2020-05-18 18:08:57 +08:00
|
|
|
std::swap(Val, RHS.Val);
|
|
|
|
std::swap(Next, RHS.Next);
|
|
|
|
std::swap(Prev, RHS.Prev);
|
|
|
|
|
|
|
|
*Prev = this;
|
|
|
|
if (Next)
|
|
|
|
Next->Prev = &Next;
|
|
|
|
|
|
|
|
*RHS.Prev = &RHS;
|
|
|
|
if (RHS.Next)
|
|
|
|
RHS.Next->Prev = &RHS.Next;
|
2008-05-14 06:51:52 +08:00
|
|
|
}
|
|
|
|
|
2014-03-04 17:19:43 +08:00
|
|
|
unsigned Use::getOperandNo() const {
|
|
|
|
return this - getUser()->op_begin();
|
|
|
|
}
|
|
|
|
|
2008-05-10 16:32:32 +08:00
|
|
|
void Use::zap(Use *Start, const Use *Stop, bool del) {
|
2011-01-16 23:30:52 +08:00
|
|
|
while (Start != Stop)
|
|
|
|
(--Stop)->~Use();
|
|
|
|
if (del)
|
2008-05-10 16:32:32 +08:00
|
|
|
::operator delete(Start);
|
|
|
|
}
|
|
|
|
|
2020-06-26 00:48:29 +08:00
|
|
|
} // namespace llvm
|