Rename BPFTable to TableDesc
authorBrenden Blanco <bblanco@plumgrid.com>
Fri, 7 Aug 2015 16:59:48 +0000 (09:59 -0700)
committerBrenden Blanco <bblanco@plumgrid.com>
Fri, 7 Aug 2015 16:59:48 +0000 (09:59 -0700)
This whole project is about bpf, prefixing everything with the same
acronym is redundant.

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
src/cc/bpf_module.h
src/cc/frontends/b/codegen_llvm.cc
src/cc/frontends/b/codegen_llvm.h
src/cc/frontends/b/loader.cc
src/cc/frontends/b/loader.h
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.h
src/cc/frontends/clang/loader.cc
src/cc/frontends/clang/loader.h
src/cc/table_desc.h

index 5d79dff..8f0c5e4 100644 (file)
@@ -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_;
 };
index 4b1c734..e6a7102 100644 (file)
@@ -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,
index f256e28..d63375f 100644 (file)
@@ -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;
 
index 75d3d53..20840cf 100644 (file)
@@ -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);
index 82a89ae..e57d266 100644 (file)
@@ -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_;
index 396207d..8c3330a 100644 (file)
@@ -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() {
index 61bccee..6491326 100644 (file)
@@ -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
index 1c68fb7..eea2ff2 100644 (file)
@@ -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;
 
index 44e634a..d8b72fc 100644 (file)
@@ -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_;
index 795b61f..ca067f6 100644 (file)
@@ -19,7 +19,7 @@
 
 namespace ebpf {
 
-struct BPFTable {
+struct TableDesc {
   int fd;
   size_t key_size;  // sizes are in bytes
   size_t leaf_size;