Skip to content

Commit ee0f43a

Browse files
authored
[SandboxIR][NFC] Move BasicBlock class definition up (llvm#101422)
To make future PRs smaller.
1 parent 6f318d4 commit ee0f43a

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

llvm/include/llvm/SandboxIR/SandboxIR.h

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,57 @@ class BBIterator {
536536
pointer get() const { return getInstr(It); }
537537
};
538538

539+
/// Contains a list of sandboxir::Instruction's.
540+
class BasicBlock : public Value {
541+
/// Builds a graph that contains all values in \p BB in their original form
542+
/// i.e., no vectorization is taking place here.
543+
void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB);
544+
friend class Context; // For `buildBasicBlockFromIR`
545+
friend class Instruction; // For LLVM Val.
546+
547+
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
548+
: Value(ClassID::Block, BB, SBCtx) {
549+
buildBasicBlockFromLLVMIR(BB);
550+
}
551+
552+
public:
553+
~BasicBlock() = default;
554+
/// For isa/dyn_cast.
555+
static bool classof(const Value *From) {
556+
return From->getSubclassID() == Value::ClassID::Block;
557+
}
558+
Function *getParent() const;
559+
using iterator = BBIterator;
560+
iterator begin() const;
561+
iterator end() const {
562+
auto *BB = cast<llvm::BasicBlock>(Val);
563+
return iterator(BB, BB->end(), &Ctx);
564+
}
565+
std::reverse_iterator<iterator> rbegin() const {
566+
return std::make_reverse_iterator(end());
567+
}
568+
std::reverse_iterator<iterator> rend() const {
569+
return std::make_reverse_iterator(begin());
570+
}
571+
Context &getContext() const { return Ctx; }
572+
Instruction *getTerminator() const;
573+
bool empty() const { return begin() == end(); }
574+
Instruction &front() const;
575+
Instruction &back() const;
576+
577+
#ifndef NDEBUG
578+
void verify() const final {
579+
assert(isa<llvm::BasicBlock>(Val) && "Expected BasicBlock!");
580+
}
581+
friend raw_ostream &operator<<(raw_ostream &OS, const BasicBlock &SBBB) {
582+
SBBB.dump(OS);
583+
return OS;
584+
}
585+
void dump(raw_ostream &OS) const final;
586+
LLVM_DUMP_METHOD void dump() const final;
587+
#endif
588+
};
589+
539590
/// A sandboxir::User with operands, opcode and linked with previous/next
540591
/// instructions in an instruction list.
541592
class Instruction : public sandboxir::User {
@@ -1579,57 +1630,6 @@ class OpaqueInst : public sandboxir::Instruction {
15791630
#endif
15801631
};
15811632

1582-
/// Contains a list of sandboxir::Instruction's.
1583-
class BasicBlock : public Value {
1584-
/// Builds a graph that contains all values in \p BB in their original form
1585-
/// i.e., no vectorization is taking place here.
1586-
void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB);
1587-
friend class Context; // For `buildBasicBlockFromIR`
1588-
friend class Instruction; // For LLVM Val.
1589-
1590-
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
1591-
: Value(ClassID::Block, BB, SBCtx) {
1592-
buildBasicBlockFromLLVMIR(BB);
1593-
}
1594-
1595-
public:
1596-
~BasicBlock() = default;
1597-
/// For isa/dyn_cast.
1598-
static bool classof(const Value *From) {
1599-
return From->getSubclassID() == Value::ClassID::Block;
1600-
}
1601-
Function *getParent() const;
1602-
using iterator = BBIterator;
1603-
iterator begin() const;
1604-
iterator end() const {
1605-
auto *BB = cast<llvm::BasicBlock>(Val);
1606-
return iterator(BB, BB->end(), &Ctx);
1607-
}
1608-
std::reverse_iterator<iterator> rbegin() const {
1609-
return std::make_reverse_iterator(end());
1610-
}
1611-
std::reverse_iterator<iterator> rend() const {
1612-
return std::make_reverse_iterator(begin());
1613-
}
1614-
Context &getContext() const { return Ctx; }
1615-
Instruction *getTerminator() const;
1616-
bool empty() const { return begin() == end(); }
1617-
Instruction &front() const;
1618-
Instruction &back() const;
1619-
1620-
#ifndef NDEBUG
1621-
void verify() const final {
1622-
assert(isa<llvm::BasicBlock>(Val) && "Expected BasicBlock!");
1623-
}
1624-
friend raw_ostream &operator<<(raw_ostream &OS, const BasicBlock &SBBB) {
1625-
SBBB.dump(OS);
1626-
return OS;
1627-
}
1628-
void dump(raw_ostream &OS) const final;
1629-
LLVM_DUMP_METHOD void dump() const final;
1630-
#endif
1631-
};
1632-
16331633
class Context {
16341634
protected:
16351635
LLVMContext &LLVMCtx;

0 commit comments

Comments
 (0)