Document opt::Instruction::InsertBefore methods (#2751)

This commit is contained in:
David Neto 2019-07-18 11:37:28 -04:00 committed by Steven Perron
parent aa9e8f5380
commit 76b75c40a1
2 changed files with 11 additions and 6 deletions

View File

@ -372,6 +372,11 @@ uint32_t Instruction::GetTypeComponent(uint32_t element) const {
return subtype;
}
Instruction* Instruction::InsertBefore(std::unique_ptr<Instruction>&& i) {
i.get()->InsertBefore(this);
return i.release();
}
Instruction* Instruction::InsertBefore(
std::vector<std::unique_ptr<Instruction>>&& list) {
Instruction* first_node = list.front().get();
@ -382,11 +387,6 @@ Instruction* Instruction::InsertBefore(
return first_node;
}
Instruction* Instruction::InsertBefore(std::unique_ptr<Instruction>&& i) {
i.get()->InsertBefore(this);
return i.release();
}
bool Instruction::IsValidBasePointer() const {
uint32_t tid = type_id();
if (tid == 0) {

View File

@ -398,8 +398,13 @@ class Instruction : public utils::IntrusiveNodeBase<Instruction> {
inline bool operator!=(const Instruction&) const;
inline bool operator<(const Instruction&) const;
Instruction* InsertBefore(std::vector<std::unique_ptr<Instruction>>&& list);
// Takes ownership of the instruction owned by |i| and inserts it immediately
// before |this|. Returns the insterted instruction.
Instruction* InsertBefore(std::unique_ptr<Instruction>&& i);
// Takes ownership of the instructions in |list| and inserts them in order
// immediately before |this|. Returns the first inserted instruction.
// Assumes the list is non-empty.
Instruction* InsertBefore(std::vector<std::unique_ptr<Instruction>>&& list);
using utils::IntrusiveNodeBase<Instruction>::InsertBefore;
// Returns true if |this| is an instruction defining a constant, but not a