40#ifndef LLVM_SANDBOXIR_TRACKER_H
41#define LLVM_SANDBOXIR_TRACKER_H
90 Value *OrigV =
nullptr;
139 : ThisUse(ThisUse), OtherUse(OtherUse) {
153 struct InstrAndOperands {
166 std::unique_ptr<sandboxir::Value> ErasedIPtr;
211template <auto GetterFn, auto SetterFn>
214 template <
typename>
struct GetClassTypeFromGetter;
215 template <
typename RetT,
typename ClassT>
216 struct GetClassTypeFromGetter<RetT (ClassT::*)()
const> {
217 using ClassType = ClassT;
219 using InstrT =
typename GetClassTypeFromGetter<
decltype(GetterFn)>::ClassType;
220 using SavedValT = std::invoke_result_t<
decltype(GetterFn), InstrT>;
239template <auto GetterFn, auto SetterFn>
242 template <
typename ClassT,
typename RetT>
243 static ClassT getClassTypeFromGetter(RetT (ClassT::*Fn)(
unsigned)
const);
244 template <
typename ClassT,
typename RetT>
245 static ClassT getClassTypeFromGetter(RetT (ClassT::*Fn)(
unsigned));
247 using InstrT =
decltype(getClassTypeFromGetter(GetterFn));
248 using SavedValT = std::invoke_result_t<
decltype(GetterFn), InstrT,
unsigned>;
290 : Switch(Switch), Val(Val) {}
306 : Switch(Switch), Val(Val), Dest(Dest) {}
386 void track(std::unique_ptr<IRChangeBase> &&Change) {
390 "We are in the middle of creating another change!");
402 template <
typename ChangeT,
typename... ArgsT>
406 track(std::make_unique<ChangeT>(Args...));
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
mir Rename Register Operands
Module.h This file contains the declarations for the Module class.
This file defines the PointerUnion class, which is a discriminated union of pointer types.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements an extremely fast bulk output stream that can only output to a stream.
Contains a list of sandboxir::Instruction's.
LLVM_DUMP_METHOD void dump() const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void accept() final
This runs when changes get accepted.
void dump(raw_ostream &OS) const final
LLVM_DUMP_METHOD void dump() const final
void accept() final
This runs when changes get accepted.
CreateAndInsertInst(Instruction *NewI)
void dump(raw_ostream &OS) const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void dump(raw_ostream &OS) const final
void accept() final
This runs when changes get accepted.
LLVM_DUMP_METHOD void dump() const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
Similar to GenericSetter but the setters/getters have an index as their first argument.
void revert(Tracker &Tracker) final
This runs when changes get reverted.
LLVM_DUMP_METHOD void dump() const final
void dump(raw_ostream &OS) const final
GenericSetterWithIdx(InstrT *I, unsigned Idx)
void accept() final
This runs when changes get accepted.
This class can be used for tracking most instruction setters.
void dump(raw_ostream &OS) const final
void accept() final
This runs when changes get accepted.
void revert(Tracker &Tracker) final
This runs when changes get reverted.
LLVM_DUMP_METHOD void dump() const final
The base class for IR Change classes.
virtual LLVM_DUMP_METHOD void dump() const =0
virtual void revert(Tracker &Tracker)=0
This runs when changes get reverted.
friend raw_ostream & operator<<(raw_ostream &OS, const IRChangeBase &C)
virtual ~IRChangeBase()=default
virtual void accept()=0
This runs when changes get accepted.
virtual void dump(raw_ostream &OS) const =0
void dump(raw_ostream &OS) const final
LLVM_DUMP_METHOD void dump() const final
void accept() final
This runs when changes get accepted.
void revert(Tracker &Tracker) final
This runs when changes get reverted.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
LLVM_DUMP_METHOD void dump() const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void accept() final
This runs when changes get accepted.
void dump(raw_ostream &OS) const final
void dump(raw_ostream &OS) const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void accept() final
This runs when changes get accepted.
LLVM_DUMP_METHOD void dump() const final
void accept() final
This runs when changes get accepted.
LLVM_DUMP_METHOD void dump() const final
void dump(raw_ostream &OS) const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void dump(raw_ostream &OS) const final
Instruction * getInstruction() const
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void accept() final
This runs when changes get accepted.
LLVM_DUMP_METHOD void dump() const final
SwitchAddCase(SwitchInst *Switch, ConstantInt *Val)
void dump(raw_ostream &OS) const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
LLVM_DUMP_METHOD void dump() const final
void accept() final
This runs when changes get accepted.
void dump(raw_ostream &OS) const final
LLVM_DUMP_METHOD void dump() const final
SwitchRemoveCase(SwitchInst *Switch, ConstantInt *Val, BasicBlock *Dest)
void accept() final
This runs when changes get accepted.
void revert(Tracker &Tracker) final
This runs when changes get reverted.
The tracker collects all the change objects and implements the main API for saving / reverting / acce...
@ Record
ā€¨Tracking is disabled
void revert()
Stops tracking and reverts to saved state.
TrackerState getState() const
\Returns the current state of the tracker.
friend raw_ostream & operator<<(raw_ostream &OS, const Tracker &Tracker)
void dump(raw_ostream &OS) const
bool isTracking() const
\Returns true if the tracker is recording changes.
void save()
Turns on IR tracking.
void track(std::unique_ptr< IRChangeBase > &&Change)
Record Change and take ownership.
bool InMiddleOfCreatingChange
Helps catch bugs where we are creating new change objects while in the middle of creating other chang...
Context & getContext() const
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
void accept()
Stops tracking and accept changes.
LLVM_DUMP_METHOD void dump() const
Tracks the change of the source Value of a sandboxir::Use.
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void dump(raw_ostream &OS) const final
void accept() final
This runs when changes get accepted.
LLVM_DUMP_METHOD void dump() const final
Tracks swapping a Use with another Use.
void revert(Tracker &Tracker) final
This runs when changes get reverted.
LLVM_DUMP_METHOD void dump() const final
void accept() final
This runs when changes get accepted.
void dump(raw_ostream &OS) const final
UseSwap(const Use &ThisUse, const Use &OtherUse)
Represents a Def-use/Use-def edge in SandboxIR.
class User * getUser() const
A SandboxIR Value has users. This is the base class.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.