1 //===- Use.cpp ------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/SandboxIR/Use.h"
10 #include "llvm/SandboxIR/Context.h"
11 #include "llvm/SandboxIR/User.h"
13 namespace llvm::sandboxir
{
15 Value
*Use::get() const { return Ctx
->getValue(LLVMUse
->get()); }
17 void Use::set(Value
*V
) {
18 Ctx
->getTracker().emplaceIfTracking
<UseSet
>(*this);
22 unsigned Use::getOperandNo() const { return Usr
->getUseOperandNo(*this); }
24 void Use::swap(Use
&OtherUse
) {
25 Ctx
->getTracker().emplaceIfTracking
<UseSwap
>(*this, OtherUse
);
26 LLVMUse
->swap(*OtherUse
.LLVMUse
);
30 void Use::dumpOS(raw_ostream
&OS
) const {
32 if (LLVMUse
== nullptr)
33 OS
<< "<null> LLVM Use! ";
35 Def
= Ctx
->getValue(LLVMUse
->get());
58 void Use::dump() const { dumpOS(dbgs()); }
61 } // namespace llvm::sandboxir