Commit 8c5661e8 authored by Brenden Blanco's avatar Brenden Blanco

Rename BPFTable to TableDesc

This whole project is about bpf, prefixing everything with the same
acronym is redundant.
Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent 5a19f90a
......@@ -29,7 +29,7 @@ class Module;
}
namespace ebpf {
class BPFTable;
class TableDesc;
class BLoader;
class ClangLoader;
......@@ -83,7 +83,7 @@ class BPFModule {
std::unique_ptr<BLoader> b_loader_;
std::unique_ptr<ClangLoader> clang_loader_;
std::map<std::string, std::tuple<uint8_t *, uintptr_t>> sections_;
std::unique_ptr<std::map<std::string, BPFTable>> tables_;
std::unique_ptr<std::map<std::string, TableDesc>> tables_;
std::vector<std::string> table_names_;
std::vector<std::string> function_names_;
};
......
......@@ -1221,7 +1221,7 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) {
return mkstatus(0);
}
StatusTuple CodegenLLVM::visit(Node* root, map<string, BPFTable> &tables) {
StatusTuple CodegenLLVM::visit(Node* root, map<string, TableDesc> &tables) {
scopes_->set_current(scopes_->top_state());
scopes_->set_current(scopes_->top_var());
......@@ -1235,7 +1235,7 @@ StatusTuple CodegenLLVM::visit(Node* root, map<string, BPFTable> &tables) {
//TRY2(print_parser());
for (auto table : tables_) {
BPFTable desc = {
TableDesc desc = {
table_fds_[table.first],
table.first->key_type_->bit_width_ >> 3,
table.first->leaf_type_->bit_width_ >> 3,
......
......@@ -41,7 +41,7 @@ class GlobalVariable;
}
namespace ebpf {
class BPFTable;
class TableDesc;
namespace cc {
......@@ -63,7 +63,7 @@ class CodegenLLVM : public Visitor {
EXPAND_NODES(VISIT)
#undef VISIT
virtual STATUS_RETURN visit(Node* n, std::map<string, BPFTable> &tables);
virtual STATUS_RETURN visit(Node* n, std::map<string, TableDesc> &tables);
int get_table_fd(const std::string &name) const;
......
......@@ -34,7 +34,7 @@ BLoader::~BLoader() {
}
int BLoader::parse(llvm::Module *mod, const string &filename, const string &proto_filename,
unique_ptr<map<string, BPFTable>> *tables) {
unique_ptr<map<string, TableDesc>> *tables) {
int rc;
proto_parser_ = make_unique<ebpf::cc::Parser>(proto_filename);
......@@ -61,7 +61,7 @@ int BLoader::parse(llvm::Module *mod, const string &filename, const string &prot
return -1;
}
*tables = make_unique<map<string, BPFTable>>();
*tables = make_unique<map<string, TableDesc>>();
codegen_ = ebpf::make_unique<ebpf::cc::CodegenLLVM>(mod, parser_->scopes_.get(), proto_parser_->scopes_.get());
ret = codegen_->visit(parser_->root_node_, **tables);
......
......@@ -26,7 +26,7 @@ class Module;
namespace ebpf {
class BPFTable;
class TableDesc;
namespace cc {
class Parser;
......@@ -38,7 +38,7 @@ class BLoader {
BLoader();
~BLoader();
int parse(llvm::Module *mod, const std::string &filename, const std::string &proto_filename,
std::unique_ptr<std::map<std::string, BPFTable>> *tables);
std::unique_ptr<std::map<std::string, TableDesc>> *tables);
int get_table_fd(const std::string &name) const;
private:
std::unique_ptr<cc::Parser> parser_;
......
......@@ -145,7 +145,7 @@ void BScanfVisitor::finalize(string &result) {
result += "}\n";
}
BTypeVisitor::BTypeVisitor(ASTContext &C, Rewriter &rewriter, map<string, BPFTable> &tables)
BTypeVisitor::BTypeVisitor(ASTContext &C, Rewriter &rewriter, map<string, TableDesc> &tables)
: C(C), rewriter_(rewriter), out_(llvm::errs()), tables_(tables) {
}
......@@ -419,7 +419,7 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
return false;
}
const RecordDecl *RD = R->getDecl()->getDefinition();
BPFTable table;
TableDesc table;
unsigned i = 0;
for (auto F : RD->fields()) {
size_t sz = C.getTypeSize(F->getType()) >> 3;
......@@ -489,7 +489,7 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
return true;
}
BTypeConsumer::BTypeConsumer(ASTContext &C, Rewriter &rewriter, map<string, BPFTable> &tables)
BTypeConsumer::BTypeConsumer(ASTContext &C, Rewriter &rewriter, map<string, TableDesc> &tables)
: visitor_(C, rewriter, tables) {
}
......@@ -500,7 +500,7 @@ bool BTypeConsumer::HandleTopLevelDecl(DeclGroupRef D) {
}
BFrontendAction::BFrontendAction(llvm::raw_ostream &os)
: rewriter_(new Rewriter), os_(os), tables_(new map<string, BPFTable>) {
: rewriter_(new Rewriter), os_(os), tables_(new map<string, TableDesc>) {
}
void BFrontendAction::EndSourceFileAction() {
......
......@@ -79,7 +79,7 @@ class BScanfVisitor : public clang::RecursiveASTVisitor<BScanfVisitor> {
class BTypeVisitor : public clang::RecursiveASTVisitor<BTypeVisitor> {
public:
explicit BTypeVisitor(clang::ASTContext &C, clang::Rewriter &rewriter,
std::map<std::string, BPFTable> &tables);
std::map<std::string, TableDesc> &tables);
bool TraverseCallExpr(clang::CallExpr *Call);
bool TraverseMemberExpr(clang::MemberExpr *E);
bool VisitFunctionDecl(clang::FunctionDecl *D);
......@@ -94,7 +94,7 @@ class BTypeVisitor : public clang::RecursiveASTVisitor<BTypeVisitor> {
clang::ASTContext &C;
clang::Rewriter &rewriter_; /// modifications to the source go into this class
llvm::raw_ostream &out_; /// for debugging
std::map<std::string, BPFTable> &tables_; /// store the open FDs
std::map<std::string, TableDesc> &tables_; /// store the open FDs
std::vector<clang::ParmVarDecl *> fn_args_;
};
......@@ -102,7 +102,7 @@ class BTypeVisitor : public clang::RecursiveASTVisitor<BTypeVisitor> {
class BTypeConsumer : public clang::ASTConsumer {
public:
explicit BTypeConsumer(clang::ASTContext &C, clang::Rewriter &rewriter,
std::map<std::string, BPFTable> &tables);
std::map<std::string, TableDesc> &tables);
bool HandleTopLevelDecl(clang::DeclGroupRef D) override;
private:
BTypeVisitor visitor_;
......@@ -125,11 +125,11 @@ class BFrontendAction : public clang::ASTFrontendAction {
CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef InFile) override;
// take ownership of the table-to-fd mapping data structure
std::unique_ptr<std::map<std::string, BPFTable>> take_tables() { return move(tables_); }
std::unique_ptr<std::map<std::string, TableDesc>> take_tables() { return move(tables_); }
private:
std::unique_ptr<clang::Rewriter> rewriter_;
llvm::raw_ostream &os_;
std::unique_ptr<std::map<std::string, BPFTable>> tables_;
std::unique_ptr<std::map<std::string, TableDesc>> tables_;
};
} // namespace visitor
......@@ -65,7 +65,7 @@ ClangLoader::ClangLoader(llvm::LLVMContext *ctx)
ClangLoader::~ClangLoader() {}
int ClangLoader::parse(unique_ptr<llvm::Module> *mod,
unique_ptr<map<string, BPFTable>> *tables,
unique_ptr<map<string, TableDesc>> *tables,
const string &file, bool in_memory) {
using namespace clang;
......
......@@ -27,7 +27,7 @@ class LLVMContext;
namespace ebpf {
class BPFTable;
class TableDesc;
namespace cc {
class Parser;
......@@ -39,7 +39,7 @@ class ClangLoader {
explicit ClangLoader(llvm::LLVMContext *ctx);
~ClangLoader();
int parse(std::unique_ptr<llvm::Module> *mod,
std::unique_ptr<std::map<std::string, BPFTable>> *tables,
std::unique_ptr<std::map<std::string, TableDesc>> *tables,
const std::string &file, bool in_memory);
private:
llvm::LLVMContext *ctx_;
......
......@@ -19,7 +19,7 @@
namespace ebpf {
struct BPFTable {
struct TableDesc {
int fd;
size_t key_size; // sizes are in bytes
size_t leaf_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment