mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
speedups for compilation of initializers in -O gen-C++ generated code
This commit is contained in:
parent
6daf9d5b88
commit
0ca2f9a8b2
6 changed files with 139 additions and 50 deletions
|
@ -133,10 +133,10 @@ public:
|
|||
// Sets the associated C++ type.
|
||||
virtual void SetCPPType(std::string ct) { CPP_type = std::move(ct); }
|
||||
|
||||
// Whether this initializer is in terms of compound objects. Used
|
||||
// Whether this initializer is in terms of compound vectors. Used
|
||||
// for avoiding compiler warnings about singleton initializations in
|
||||
// braces.
|
||||
virtual bool IsCompound() const { return false; }
|
||||
virtual bool UsesCompoundVectors() const { return false; }
|
||||
|
||||
// Returns the type associated with the table used for initialization
|
||||
// (i.e., this is the type of the global returned by InitializersName()).
|
||||
|
@ -146,9 +146,11 @@ public:
|
|||
void AddInstance(std::shared_ptr<CPP_InitInfo> g);
|
||||
|
||||
// Emit code to populate the table used to initialize this collection.
|
||||
void GenerateInitializers(CPPCompile* c);
|
||||
virtual void GenerateInitializers(CPPCompile* c);
|
||||
|
||||
protected:
|
||||
virtual void GenerateCohorts(CPPCompile* c);
|
||||
|
||||
// Computes offset_set - see below.
|
||||
void BuildOffsetSet(CPPCompile* c);
|
||||
|
||||
|
@ -214,7 +216,7 @@ public:
|
|||
BuildInitType();
|
||||
}
|
||||
|
||||
bool IsCompound() const override { return true; }
|
||||
bool UsesCompoundVectors() const override { return true; }
|
||||
|
||||
private:
|
||||
void BuildInitType() { inits_type = std::string("CPP_CustomInits<") + CPPType() + ">"; }
|
||||
|
@ -236,7 +238,7 @@ public:
|
|||
inits_type = std::string("CPP_BasicConsts<") + CPP_type + ", " + c_type + ", " + tag + "Val>";
|
||||
}
|
||||
|
||||
bool IsCompound() const override { return false; }
|
||||
bool UsesCompoundVectors() const override { return false; }
|
||||
|
||||
void BuildCohortElement(CPPCompile* c, std::string init_type, std::vector<std::string>& ivs) override;
|
||||
};
|
||||
|
@ -254,7 +256,12 @@ public:
|
|||
inits_type = std::string("CPP_IndexedInits<") + CPPType() + ">";
|
||||
}
|
||||
|
||||
bool IsCompound() const override { return true; }
|
||||
// This isn't true (anymore) because we separately build up the compound
|
||||
// vectors needed for the initialization.
|
||||
bool UsesCompoundVectors() const override { return false; }
|
||||
|
||||
void GenerateInitializers(CPPCompile* c) override;
|
||||
void GenerateCohorts(CPPCompile* c) override;
|
||||
|
||||
void BuildCohortElement(CPPCompile* c, std::string init_type, std::vector<std::string>& ivs) override;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue