LLVM 19.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;
24
25/// Represents a Def-use/Use-def edge in SandboxIR.
26/// NOTE: Unlike llvm::Use, this is not an integral part of the use-def chains.
27/// It is also not uniqued and is currently passed by value, so you can have
28/// more than one sandboxir::Use objects for the same use-def edge.
29class Use {
30 llvm::Use *LLVMUse;
31 User *Usr;
32 Context *Ctx;
33
34 /// Don't allow the user to create a sandboxir::Use directly.
35 Use(llvm::Use *LLVMUse, User *Usr, Context &Ctx)
36 : LLVMUse(LLVMUse), Usr(Usr), Ctx(&Ctx) {}
37 Use() : LLVMUse(nullptr), Ctx(nullptr) {}
38
39 friend class Value; // For constructor
40 friend class User; // For constructor
41 friend class OperandUseIterator; // For constructor
42 friend class UserUseIterator; // For accessing members
43
44public:
45 operator Value *() const { return get(); }
46 Value *get() const;
47 void set(Value *V);
48 class User *getUser() const { return Usr; }
49 unsigned getOperandNo() const;
50 Context *getContext() const { return Ctx; }
51 bool operator==(const Use &Other) const {
52 assert(Ctx == Other.Ctx && "Contexts differ!");
53 return LLVMUse == Other.LLVMUse && Usr == Other.Usr;
54 }
55 bool operator!=(const Use &Other) const { return !(*this == Other); }
56#ifndef NDEBUG
57 void dump(raw_ostream &OS) const;
58 void dump() const;
59#endif // NDEBUG
60};
61
62} // namespace llvm::sandboxir
63
64#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:84
Represents a Def-use/Use-def edge in SandboxIR.
Definition: Use.h:29
unsigned getOperandNo() const
Definition: SandboxIR.cpp:21
Value * get() const
Definition: SandboxIR.cpp:17
void set(Value *V)
Definition: SandboxIR.cpp:19
bool operator==(const Use &Other) const
Definition: Use.h:51
bool operator!=(const Use &Other) const
Definition: Use.h:55
Context * getContext() const
Definition: Use.h:50
class User * getUser() const
Definition: Use.h:48
void dump() const
Definition: SandboxIR.cpp:52
Iterator for the Use edges of a Value's users.
Definition: SandboxIR.h:112
A sandboxir::User has operands.
Definition: SandboxIR.h:316
A SandboxIR Value has users. This is the base class.
Definition: SandboxIR.h:137
@ User
could "use" a pointer
@ Other
Any other memory.