2008-05-15 12:04:30 +02:00
|
|
|
//===-- Use.cpp - Implement the Use class ---------------------------------===//
|
2008-05-10 10:32:32 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01: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 10:32:32 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-03-04 09:51:00 +01:00
|
|
|
#include "llvm/IR/Use.h"
|
2014-03-04 10:19:43 +01:00
|
|
|
#include "llvm/IR/User.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/Value.h"
|
2012-03-26 16:04:17 +02:00
|
|
|
#include <new>
|
2008-05-10 10:32:32 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2008-05-14 00:51:52 +02:00
|
|
|
void Use::swap(Use &RHS) {
|
2014-03-04 10:00:15 +01:00
|
|
|
if (Val == RHS.Val)
|
|
|
|
return;
|
2008-05-14 00:51:52 +02:00
|
|
|
|
2020-05-18 12:08:57 +02: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 00:51:52 +02:00
|
|
|
}
|
|
|
|
|
2014-03-04 10:19:43 +01:00
|
|
|
unsigned Use::getOperandNo() const {
|
|
|
|
return this - getUser()->op_begin();
|
|
|
|
}
|
|
|
|
|
2008-05-10 10:32:32 +02:00
|
|
|
void Use::zap(Use *Start, const Use *Stop, bool del) {
|
2011-01-16 16:30:52 +01:00
|
|
|
while (Start != Stop)
|
|
|
|
(--Stop)->~Use();
|
|
|
|
if (del)
|
2008-05-10 10:32:32 +02:00
|
|
|
::operator delete(Start);
|
|
|
|
}
|
|
|
|
|
2020-06-25 18:48:29 +02:00
|
|
|
} // namespace llvm
|