Path: blob/main/contrib/llvm-project/llvm/lib/SandboxIR/Use.cpp
213766 views
//===- Use.cpp ------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/SandboxIR/Use.h"9#include "llvm/SandboxIR/Context.h"10#include "llvm/SandboxIR/User.h"1112namespace llvm::sandboxir {1314Value *Use::get() const { return Ctx->getValue(LLVMUse->get()); }1516void Use::set(Value *V) {17Ctx->getTracker().emplaceIfTracking<UseSet>(*this);18LLVMUse->set(V->Val);19}2021unsigned Use::getOperandNo() const { return Usr->getUseOperandNo(*this); }2223void Use::swap(Use &OtherUse) {24Ctx->getTracker().emplaceIfTracking<UseSwap>(*this, OtherUse);25LLVMUse->swap(*OtherUse.LLVMUse);26}2728#ifndef NDEBUG29void Use::dumpOS(raw_ostream &OS) const {30Value *Def = nullptr;31if (LLVMUse == nullptr)32OS << "<null> LLVM Use! ";33else34Def = Ctx->getValue(LLVMUse->get());35OS << "Def: ";36if (Def == nullptr)37OS << "NULL";38else39OS << *Def;40OS << "\n";4142OS << "User: ";43if (Usr == nullptr)44OS << "NULL";45else46OS << *Usr;47OS << "\n";4849OS << "OperandNo: ";50if (Usr == nullptr)51OS << "N/A";52else53OS << getOperandNo();54OS << "\n";55}5657void Use::dump() const { dumpOS(dbgs()); }58#endif // NDEBUG5960} // namespace llvm::sandboxir616263