31 :
PHI(
PHI), RemovedIdx(RemovedIdx) {
32 RemovedV =
PHI->getIncomingValue(RemovedIdx);
33 RemovedBB =
PHI->getIncomingBlock(RemovedIdx);
40 if (NumIncoming == 0) {
46 unsigned LastIdx = NumIncoming - 1;
49 for (
unsigned Idx = LastIdx;
Idx > RemovedIdx; --
Idx) {
79 assert(Changes.empty() &&
"You must accept or revert changes!");
83 : ErasedIPtr(
std::
move(ErasedIPtr)) {
84 auto *
I = cast<Instruction>(this->ErasedIPtr.get());
85 auto LLVMInstrs =
I->getLLVMInstrs();
87 for (
auto *LLVMI :
reverse(LLVMInstrs)) {
89 Operands.reserve(LLVMI->getNumOperands());
95 [](
const auto &D0,
const auto &D1) {
96 return D0.LLVMI->comesBefore(D1.LLVMI);
98 "Expected reverse program order!");
99 auto *BotLLVMI = cast<llvm::Instruction>(
I->Val);
100 if (BotLLVMI->getNextNode() !=
nullptr)
101 NextLLVMIOrBB = BotLLVMI->getNextNode();
103 NextLLVMIOrBB = BotLLVMI->getParent();
107 for (
const auto &IData : InstrData)
108 IData.LLVMI->deleteValue();
113 auto [
Operands, BotLLVMI] = InstrData[0];
115 BotLLVMI->insertBefore(NextLLVMI);
121 BotLLVMI->setOperand(OpNum,
Op);
125 LLVMI->insertBefore(BotLLVMI);
127 LLVMI->setOperand(OpNum,
Op);
142 NextInstrOrBB = NextI;
148 if (
auto *NextI = NextInstrOrBB.dyn_cast<
Instruction *>()) {
186 NextInstrOrBB = NextI;
192 if (
auto *NextI = NextInstrOrBB.dyn_cast<
Instruction *>()) {
232 for (
auto &Change :
reverse(Changes))
233 Change->revert(*
this);
240 for (
auto &Change : Changes)
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Basic Block Representation.
void insertInto(Function *Parent, BasicBlock *InsertBefore=nullptr)
Insert unlinked basic block into a function.
This class represents an Operation in the Expression.
T get() const
Returns the value of the specified pointer type.
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwise returns null.
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.
Value * registerValue(std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
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.
LLVM_DUMP_METHOD void dump() const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
EraseFromParent(std::unique_ptr< sandboxir::Value > &&IPtr)
LLVM_DUMP_METHOD void dump() const final
InsertIntoBB(Instruction *InsertedI)
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 ...
void removeFromParent()
Detach this from its parent BasicBlock without deleting it.
void insertInto(BasicBlock *BB, const BBIterator &WhereIt)
Insert this detached instruction into BB at WhereIt.
void eraseFromParent()
Detach this Value from its parent and delete it.
Instruction * getNextNode() const
\Returns the next sandboxir::Instruction in the block, or nullptr if at the end of the block.
void moveBefore(BasicBlock &BB, const BBIterator &WhereIt)
Move this instruction to WhereIt.
void insertBefore(Instruction *BeforeI)
Insert this detached instruction before BeforeI.
BasicBlock * getParent() const
\Returns the BasicBlock containing this Instruction, or null if it is detached.
LLVM_DUMP_METHOD void dump() const final
MoveInstr(sandboxir::Instruction *I)
void revert(Tracker &Tracker) final
This runs when changes get reverted.
PHIAddIncoming(PHINode *PHI)
void revert(Tracker &Tracker) final
This runs when changes get reverted.
LLVM_DUMP_METHOD void dump() const final
void setIncomingBlock(unsigned Idx, BasicBlock *BB)
void setIncomingValue(unsigned Idx, Value *V)
unsigned getNumIncomingValues() const
void addIncoming(Value *V, BasicBlock *BB)
Value * removeIncomingValue(unsigned Idx)
BasicBlock * getIncomingBlock(unsigned Idx) const
Value * getIncomingValue(unsigned Idx) const
LLVM_DUMP_METHOD void dump() const final
PHIRemoveIncoming(PHINode *PHI, unsigned RemovedIdx)
void revert(Tracker &Tracker) final
This runs when changes get reverted.
void revert(Tracker &Tracker) final
This runs when changes get reverted.
RemoveFromParent(Instruction *RemovedI)
LLVM_DUMP_METHOD void dump() const final
void revert(Tracker &Tracker) final
This runs when changes get reverted.
LLVM_DUMP_METHOD void dump() const final
CaseIt findCaseValue(const ConstantInt *C)
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
CaseIt removeCase(CaseIt It)
This method removes the specified case and its successor from the switch instruction.
LLVM_DUMP_METHOD void dump() const final
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.
void save()
Turns on IR tracking.
Context & getContext() const
void accept()
Stops tracking and accept changes.
LLVM_DUMP_METHOD void dump() const
LLVM_DUMP_METHOD void dump() const final
LLVM_DUMP_METHOD void dump() const final
Represents a Def-use/Use-def edge in SandboxIR.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
auto reverse(ContainerTy &&C)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.