Skip to content

[llvm] annotate interfaces in llvm/SandboxIR for DLL export #142863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions llvm/include/llvm/SandboxIR/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "llvm/IR/BasicBlock.h"
#include "llvm/SandboxIR/Value.h"
#include "llvm/Support/Compiler.h"

namespace llvm::sandboxir {

Expand All @@ -32,20 +33,20 @@ class BBIterator {
llvm::BasicBlock *BB;
llvm::BasicBlock::iterator It;
Context *Ctx;
pointer getInstr(llvm::BasicBlock::iterator It) const;
LLVM_ABI pointer getInstr(llvm::BasicBlock::iterator It) const;

public:
BBIterator() : BB(nullptr), Ctx(nullptr) {}
BBIterator(llvm::BasicBlock *BB, llvm::BasicBlock::iterator It, Context *Ctx)
: BB(BB), It(It), Ctx(Ctx) {}
reference operator*() const { return *getInstr(It); }
BBIterator &operator++();
LLVM_ABI BBIterator &operator++();
BBIterator operator++(int) {
auto Copy = *this;
++*this;
return Copy;
}
BBIterator &operator--();
LLVM_ABI BBIterator &operator--();
BBIterator operator--(int) {
auto Copy = *this;
--*this;
Expand All @@ -60,14 +61,14 @@ class BBIterator {
/// the instruction is not found in the IR-to-SandboxIR tables.
pointer get() const { return getInstr(It); }
/// \Returns the parent BB.
BasicBlock *getNodeParent() const;
LLVM_ABI BasicBlock *getNodeParent() const;
};

/// 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);
LLVM_ABI void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB);
friend class Context; // For `buildBasicBlockFromIR`
friend class Instruction; // For LLVM Val.

Expand All @@ -82,9 +83,9 @@ class BasicBlock : public Value {
static bool classof(const Value *From) {
return From->getSubclassID() == Value::ClassID::Block;
}
Function *getParent() const;
LLVM_ABI Function *getParent() const;
using iterator = BBIterator;
iterator begin() const;
LLVM_ABI iterator begin() const;
iterator end() const {
auto *BB = cast<llvm::BasicBlock>(Val);
return iterator(BB, BB->end(), &Ctx);
Expand All @@ -96,10 +97,10 @@ class BasicBlock : public Value {
return std::make_reverse_iterator(begin());
}
Context &getContext() const { return Ctx; }
Instruction *getTerminator() const;
LLVM_ABI Instruction *getTerminator() const;
bool empty() const { return begin() == end(); }
Instruction &front() const;
Instruction &back() const;
LLVM_ABI Instruction &front() const;
LLVM_ABI Instruction &back() const;

#ifndef NDEBUG
void verify() const final;
Expand Down
Loading
Loading