From: Brenden Blanco Date: Fri, 7 Aug 2015 16:59:48 +0000 (-0700) Subject: Rename BPFTable to TableDesc X-Git-Tag: v0.1.4~5^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c5661e88b0bda92878cdab97fd0912d257d47f9;p=platform%2Fupstream%2Fbcc.git Rename BPFTable to TableDesc This whole project is about bpf, prefixing everything with the same acronym is redundant. Signed-off-by: Brenden Blanco --- diff --git a/src/cc/bpf_module.h b/src/cc/bpf_module.h index 5d79dff..8f0c5e4 100644 --- a/src/cc/bpf_module.h +++ b/src/cc/bpf_module.h @@ -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 b_loader_; std::unique_ptr clang_loader_; std::map> sections_; - std::unique_ptr> tables_; + std::unique_ptr> tables_; std::vector table_names_; std::vector function_names_; }; diff --git a/src/cc/frontends/b/codegen_llvm.cc b/src/cc/frontends/b/codegen_llvm.cc index 4b1c734..e6a7102 100644 --- a/src/cc/frontends/b/codegen_llvm.cc +++ b/src/cc/frontends/b/codegen_llvm.cc @@ -1221,7 +1221,7 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) { return mkstatus(0); } -StatusTuple CodegenLLVM::visit(Node* root, map &tables) { +StatusTuple CodegenLLVM::visit(Node* root, map &tables) { scopes_->set_current(scopes_->top_state()); scopes_->set_current(scopes_->top_var()); @@ -1235,7 +1235,7 @@ StatusTuple CodegenLLVM::visit(Node* root, map &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, diff --git a/src/cc/frontends/b/codegen_llvm.h b/src/cc/frontends/b/codegen_llvm.h index f256e28..d63375f 100644 --- a/src/cc/frontends/b/codegen_llvm.h +++ b/src/cc/frontends/b/codegen_llvm.h @@ -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 &tables); + virtual STATUS_RETURN visit(Node* n, std::map &tables); int get_table_fd(const std::string &name) const; diff --git a/src/cc/frontends/b/loader.cc b/src/cc/frontends/b/loader.cc index 75d3d53..20840cf 100644 --- a/src/cc/frontends/b/loader.cc +++ b/src/cc/frontends/b/loader.cc @@ -34,7 +34,7 @@ BLoader::~BLoader() { } int BLoader::parse(llvm::Module *mod, const string &filename, const string &proto_filename, - unique_ptr> *tables) { + unique_ptr> *tables) { int rc; proto_parser_ = make_unique(proto_filename); @@ -61,7 +61,7 @@ int BLoader::parse(llvm::Module *mod, const string &filename, const string &prot return -1; } - *tables = make_unique>(); + *tables = make_unique>(); codegen_ = ebpf::make_unique(mod, parser_->scopes_.get(), proto_parser_->scopes_.get()); ret = codegen_->visit(parser_->root_node_, **tables); diff --git a/src/cc/frontends/b/loader.h b/src/cc/frontends/b/loader.h index 82a89ae..e57d266 100644 --- a/src/cc/frontends/b/loader.h +++ b/src/cc/frontends/b/loader.h @@ -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> *tables); + std::unique_ptr> *tables); int get_table_fd(const std::string &name) const; private: std::unique_ptr parser_; diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc index 396207d..8c3330a 100644 --- a/src/cc/frontends/clang/b_frontend_action.cc +++ b/src/cc/frontends/clang/b_frontend_action.cc @@ -145,7 +145,7 @@ void BScanfVisitor::finalize(string &result) { result += "}\n"; } -BTypeVisitor::BTypeVisitor(ASTContext &C, Rewriter &rewriter, map &tables) +BTypeVisitor::BTypeVisitor(ASTContext &C, Rewriter &rewriter, map &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 &tables) +BTypeConsumer::BTypeConsumer(ASTContext &C, Rewriter &rewriter, map &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) { + : rewriter_(new Rewriter), os_(os), tables_(new map) { } void BFrontendAction::EndSourceFileAction() { diff --git a/src/cc/frontends/clang/b_frontend_action.h b/src/cc/frontends/clang/b_frontend_action.h index 61bccee..6491326 100644 --- a/src/cc/frontends/clang/b_frontend_action.h +++ b/src/cc/frontends/clang/b_frontend_action.h @@ -79,7 +79,7 @@ class BScanfVisitor : public clang::RecursiveASTVisitor { class BTypeVisitor : public clang::RecursiveASTVisitor { public: explicit BTypeVisitor(clang::ASTContext &C, clang::Rewriter &rewriter, - std::map &tables); + std::map &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 { clang::ASTContext &C; clang::Rewriter &rewriter_; /// modifications to the source go into this class llvm::raw_ostream &out_; /// for debugging - std::map &tables_; /// store the open FDs + std::map &tables_; /// store the open FDs std::vector fn_args_; }; @@ -102,7 +102,7 @@ class BTypeVisitor : public clang::RecursiveASTVisitor { class BTypeConsumer : public clang::ASTConsumer { public: explicit BTypeConsumer(clang::ASTContext &C, clang::Rewriter &rewriter, - std::map &tables); + std::map &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> take_tables() { return move(tables_); } + std::unique_ptr> take_tables() { return move(tables_); } private: std::unique_ptr rewriter_; llvm::raw_ostream &os_; - std::unique_ptr> tables_; + std::unique_ptr> tables_; }; } // namespace visitor diff --git a/src/cc/frontends/clang/loader.cc b/src/cc/frontends/clang/loader.cc index 1c68fb7..eea2ff2 100644 --- a/src/cc/frontends/clang/loader.cc +++ b/src/cc/frontends/clang/loader.cc @@ -65,7 +65,7 @@ ClangLoader::ClangLoader(llvm::LLVMContext *ctx) ClangLoader::~ClangLoader() {} int ClangLoader::parse(unique_ptr *mod, - unique_ptr> *tables, + unique_ptr> *tables, const string &file, bool in_memory) { using namespace clang; diff --git a/src/cc/frontends/clang/loader.h b/src/cc/frontends/clang/loader.h index 44e634a..d8b72fc 100644 --- a/src/cc/frontends/clang/loader.h +++ b/src/cc/frontends/clang/loader.h @@ -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 *mod, - std::unique_ptr> *tables, + std::unique_ptr> *tables, const std::string &file, bool in_memory); private: llvm::LLVMContext *ctx_; diff --git a/src/cc/table_desc.h b/src/cc/table_desc.h index 795b61f..ca067f6 100644 --- a/src/cc/table_desc.h +++ b/src/cc/table_desc.h @@ -19,7 +19,7 @@ namespace ebpf { -struct BPFTable { +struct TableDesc { int fd; size_t key_size; // sizes are in bytes size_t leaf_size;