Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:26

0001 //===- Use.h ----------------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Sandbox IR Use.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_SANDBOXIR_USE_H
0014 #define LLVM_SANDBOXIR_USE_H
0015 
0016 #include "llvm/IR/Use.h"
0017 #include "llvm/Support/raw_ostream.h"
0018 
0019 namespace llvm::sandboxir {
0020 
0021 class Context;
0022 class Value;
0023 class User;
0024 class CallBase;
0025 class CallBrInst;
0026 class PHINode;
0027 
0028 /// Represents a Def-use/Use-def edge in SandboxIR.
0029 /// NOTE: Unlike llvm::Use, this is not an integral part of the use-def chains.
0030 /// It is also not uniqued and is currently passed by value, so you can have
0031 /// more than one sandboxir::Use objects for the same use-def edge.
0032 class Use {
0033   llvm::Use *LLVMUse;
0034   User *Usr;
0035   Context *Ctx;
0036 
0037   /// Don't allow the user to create a sandboxir::Use directly.
0038   Use(llvm::Use *LLVMUse, User *Usr, Context &Ctx)
0039       : LLVMUse(LLVMUse), Usr(Usr), Ctx(&Ctx) {}
0040   Use() : LLVMUse(nullptr), Ctx(nullptr) {}
0041 
0042   friend class Value;              // For constructor
0043   friend class User;               // For constructor
0044   friend class OperandUseIterator; // For constructor
0045   friend class UserUseIterator;    // For accessing members
0046   friend class CallBase;           // For LLVMUse
0047   friend class CallBrInst;         // For constructor
0048   friend class PHINode;            // For LLVMUse
0049 
0050 public:
0051   operator Value *() const { return get(); }
0052   Value *get() const;
0053   void set(Value *V);
0054   class User *getUser() const { return Usr; }
0055   unsigned getOperandNo() const;
0056   void swap(Use &OtherUse);
0057   Context *getContext() const { return Ctx; }
0058   bool operator==(const Use &Other) const {
0059     assert(Ctx == Other.Ctx && "Contexts differ!");
0060     return LLVMUse == Other.LLVMUse && Usr == Other.Usr;
0061   }
0062   bool operator!=(const Use &Other) const { return !(*this == Other); }
0063 #ifndef NDEBUG
0064   void dumpOS(raw_ostream &OS) const;
0065   void dump() const;
0066 #endif // NDEBUG
0067 };
0068 
0069 } // namespace llvm::sandboxir
0070 
0071 #endif // LLVM_SANDBOXIR_USE_H