LLVM 20.0.0git
Use.h
Go to the documentation of this file.
1//===- Use.h ----------------------------------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// Sandbox IR Use.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SANDBOXIR_USE_H
14#define LLVM_SANDBOXIR_USE_H
15
16#include "llvm/IR/Use.h"
18
19namespace llvm::sandboxir {
20
21class Context;
22class Value;
23class User;
24class CallBase;
25class CallBrInst;
26class PHINode;
27
28/// Represents a Def-use/Use-def edge in SandboxIR.
29/// NOTE: Unlike llvm::Use, this is not an integral part of the use-def chains.
30/// It is also not uniqued and is currently passed by value, so you can have
31/// more than one sandboxir::Use objects for the same use-def edge.
32class Use {
33 llvm::Use *LLVMUse;
34 User *Usr;
35 Context *Ctx;
36
37 /// Don't allow the user to create a sandboxir::Use directly.
38 Use(llvm::Use *LLVMUse, User *Usr, Context &Ctx)
39 : LLVMUse(LLVMUse), Usr(Usr), Ctx(&Ctx) {}
40 Use() : LLVMUse(nullptr), Ctx(nullptr) {}
41
42 friend class Value; // For constructor
43 friend class User; // For constructor
44 friend class OperandUseIterator; // For constructor
45 friend class UserUseIterator; // For accessing members
46 friend class CallBase; // For LLVMUse
47 friend class CallBrInst; // For constructor
48 friend class PHINode; // For LLVMUse
49
50public:
51 operator Value *() const { return get(); }
52 Value *get() const;
53 void set(Value *V);
54 class User *getUser() const { return Usr; }
55 unsigned getOperandNo() const;
56 void swap(Use &OtherUse);
57 Context *getContext() const { return Ctx; }
58 bool operator==(const Use &Other) const {
59 assert(Ctx == Other.Ctx && "Contexts differ!");
60 return LLVMUse == Other.LLVMUse && Usr == Other.Usr;
61 }
62 bool operator!=(const Use &Other) const { return !(*this == Other); }
63#ifndef NDEBUG
64 void dumpOS(raw_ostream &OS) const;
65 void dump() const;
66#endif // NDEBUG
67};
68
69} // namespace llvm::sandboxir
70
71#endif // LLVM_SANDBOXIR_USE_H
This defines the Use class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
Iterator for the Use edges of a User's operands.
Definition: SandboxIR.h:142
Represents a Def-use/Use-def edge in SandboxIR.
Definition: Use.h:32
void dumpOS(raw_ostream &OS) const
Definition: SandboxIR.cpp:33
unsigned getOperandNo() const
Definition: SandboxIR.cpp:25
Value * get() const
Definition: SandboxIR.cpp:18
void set(Value *V)
Definition: SandboxIR.cpp:20
bool operator==(const Use &Other) const
Definition: Use.h:58
bool operator!=(const Use &Other) const
Definition: Use.h:62
Context * getContext() const
Definition: Use.h:57
class User * getUser() const
Definition: Use.h:54
void dump() const
Definition: SandboxIR.cpp:61
Iterator for the Use edges of a Value's users.
Definition: SandboxIR.h:178
A sandboxir::User has operands.
Definition: SandboxIR.h:400
A SandboxIR Value has users. This is the base class.
Definition: SandboxIR.h:204
@ User
could "use" a pointer
@ Other
Any other memory.