10b57cec5SDimitry Andric //===-- Use.cpp - Implement the Use class ---------------------------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #include "llvm/IR/Use.h" 100b57cec5SDimitry Andric #include "llvm/IR/User.h" 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric namespace llvm { 130b57cec5SDimitry Andric swap(Use & RHS)140b57cec5SDimitry Andricvoid Use::swap(Use &RHS) { 150b57cec5SDimitry Andric if (Val == RHS.Val) 160b57cec5SDimitry Andric return; 170b57cec5SDimitry Andric 18*e8d8bef9SDimitry Andric std::swap(Val, RHS.Val); 19*e8d8bef9SDimitry Andric std::swap(Next, RHS.Next); 20*e8d8bef9SDimitry Andric std::swap(Prev, RHS.Prev); 210b57cec5SDimitry Andric 22*e8d8bef9SDimitry Andric *Prev = this; 23*e8d8bef9SDimitry Andric if (Next) 24*e8d8bef9SDimitry Andric Next->Prev = &Next; 250b57cec5SDimitry Andric 26*e8d8bef9SDimitry Andric *RHS.Prev = &RHS; 27*e8d8bef9SDimitry Andric if (RHS.Next) 28*e8d8bef9SDimitry Andric RHS.Next->Prev = &RHS.Next; 290b57cec5SDimitry Andric } 300b57cec5SDimitry Andric getOperandNo() const310b57cec5SDimitry Andricunsigned Use::getOperandNo() const { 320b57cec5SDimitry Andric return this - getUser()->op_begin(); 330b57cec5SDimitry Andric } 340b57cec5SDimitry Andric zap(Use * Start,const Use * Stop,bool del)350b57cec5SDimitry Andricvoid Use::zap(Use *Start, const Use *Stop, bool del) { 360b57cec5SDimitry Andric while (Start != Stop) 370b57cec5SDimitry Andric (--Stop)->~Use(); 380b57cec5SDimitry Andric if (del) 390b57cec5SDimitry Andric ::operator delete(Start); 400b57cec5SDimitry Andric } 410b57cec5SDimitry Andric 425ffd83dbSDimitry Andric } // namespace llvm 43