[llvm] ee0f43a - [SandboxIR][NFC] Move BasicBlock class definition up (#101422)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 15:39:54 PDT 2024
Author: Arthur Eubanks
Date: 2024-07-31T15:39:52-07:00
New Revision: ee0f43af2b344a7cd603a8564871c357d8fb108a
URL: https://github.com/llvm/llvm-project/commit/ee0f43af2b344a7cd603a8564871c357d8fb108a
DIFF: https://github.com/llvm/llvm-project/commit/ee0f43af2b344a7cd603a8564871c357d8fb108a.diff
LOG: [SandboxIR][NFC] Move BasicBlock class definition up (#101422)
To make future PRs smaller.
Added:
Modified:
llvm/include/llvm/SandboxIR/SandboxIR.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/SandboxIR/SandboxIR.h b/llvm/include/llvm/SandboxIR/SandboxIR.h
index 3a23eb761f5cf..38c2586f9d73c 100644
--- a/llvm/include/llvm/SandboxIR/SandboxIR.h
+++ b/llvm/include/llvm/SandboxIR/SandboxIR.h
@@ -536,6 +536,57 @@ class BBIterator {
pointer get() const { return getInstr(It); }
};
+/// Contains a list of sandboxir::Instruction's.
+class BasicBlock : public Value {
+ /// Builds a graph that contains all values in \p BB in their original form
+ /// i.e., no vectorization is taking place here.
+ void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB);
+ friend class Context; // For `buildBasicBlockFromIR`
+ friend class Instruction; // For LLVM Val.
+
+ BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
+ : Value(ClassID::Block, BB, SBCtx) {
+ buildBasicBlockFromLLVMIR(BB);
+ }
+
+public:
+ ~BasicBlock() = default;
+ /// For isa/dyn_cast.
+ static bool classof(const Value *From) {
+ return From->getSubclassID() == Value::ClassID::Block;
+ }
+ Function *getParent() const;
+ using iterator = BBIterator;
+ iterator begin() const;
+ iterator end() const {
+ auto *BB = cast<llvm::BasicBlock>(Val);
+ return iterator(BB, BB->end(), &Ctx);
+ }
+ std::reverse_iterator<iterator> rbegin() const {
+ return std::make_reverse_iterator(end());
+ }
+ std::reverse_iterator<iterator> rend() const {
+ return std::make_reverse_iterator(begin());
+ }
+ Context &getContext() const { return Ctx; }
+ Instruction *getTerminator() const;
+ bool empty() const { return begin() == end(); }
+ Instruction &front() const;
+ Instruction &back() const;
+
+#ifndef NDEBUG
+ void verify() const final {
+ assert(isa<llvm::BasicBlock>(Val) && "Expected BasicBlock!");
+ }
+ friend raw_ostream &operator<<(raw_ostream &OS, const BasicBlock &SBBB) {
+ SBBB.dump(OS);
+ return OS;
+ }
+ void dump(raw_ostream &OS) const final;
+ LLVM_DUMP_METHOD void dump() const final;
+#endif
+};
+
/// A sandboxir::User with operands, opcode and linked with previous/next
/// instructions in an instruction list.
class Instruction : public sandboxir::User {
@@ -1579,57 +1630,6 @@ class OpaqueInst : public sandboxir::Instruction {
#endif
};
-/// Contains a list of sandboxir::Instruction's.
-class BasicBlock : public Value {
- /// Builds a graph that contains all values in \p BB in their original form
- /// i.e., no vectorization is taking place here.
- void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB);
- friend class Context; // For `buildBasicBlockFromIR`
- friend class Instruction; // For LLVM Val.
-
- BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
- : Value(ClassID::Block, BB, SBCtx) {
- buildBasicBlockFromLLVMIR(BB);
- }
-
-public:
- ~BasicBlock() = default;
- /// For isa/dyn_cast.
- static bool classof(const Value *From) {
- return From->getSubclassID() == Value::ClassID::Block;
- }
- Function *getParent() const;
- using iterator = BBIterator;
- iterator begin() const;
- iterator end() const {
- auto *BB = cast<llvm::BasicBlock>(Val);
- return iterator(BB, BB->end(), &Ctx);
- }
- std::reverse_iterator<iterator> rbegin() const {
- return std::make_reverse_iterator(end());
- }
- std::reverse_iterator<iterator> rend() const {
- return std::make_reverse_iterator(begin());
- }
- Context &getContext() const { return Ctx; }
- Instruction *getTerminator() const;
- bool empty() const { return begin() == end(); }
- Instruction &front() const;
- Instruction &back() const;
-
-#ifndef NDEBUG
- void verify() const final {
- assert(isa<llvm::BasicBlock>(Val) && "Expected BasicBlock!");
- }
- friend raw_ostream &operator<<(raw_ostream &OS, const BasicBlock &SBBB) {
- SBBB.dump(OS);
- return OS;
- }
- void dump(raw_ostream &OS) const final;
- LLVM_DUMP_METHOD void dump() const final;
-#endif
-};
-
class Context {
protected:
LLVMContext &LLVMCtx;
More information about the llvm-commits
mailing list