diff --git a/backends/p4tools/common/compiler/compiler_target.h b/backends/p4tools/common/compiler/compiler_target.h index 7d88f2cb7d4..d69422b5fcf 100644 --- a/backends/p4tools/common/compiler/compiler_target.h +++ b/backends/p4tools/common/compiler/compiler_target.h @@ -29,6 +29,8 @@ class CompilerResult : public ICastable { /// @returns the reference to the input P4 program, after it has been transformed by the /// compiler. [[nodiscard]] const IR::P4Program &getProgram() const; + + DECLARE_TYPEINFO(CompilerResult); }; /// P4Tools compilers may return an error instead of a compiler result. diff --git a/backends/p4tools/common/core/z3_solver.h b/backends/p4tools/common/core/z3_solver.h index 96bbdbf77c9..b406d82b266 100644 --- a/backends/p4tools/common/core/z3_solver.h +++ b/backends/p4tools/common/core/z3_solver.h @@ -14,6 +14,7 @@ #include "ir/solver.h" #include "lib/cstring.h" #include "lib/ordered_map.h" +#include "lib/rtti.h" #include "lib/safe_vector.h" namespace P4Tools { @@ -127,6 +128,8 @@ class Z3Solver : public AbstractSolver { /// Stores the timeout, as last set by @ref timeout. std::optional timeout_; + + DECLARE_TYPEINFO(Z3Solver, AbstractSolver); }; } // namespace P4Tools diff --git a/backends/p4tools/common/lib/formulae.h b/backends/p4tools/common/lib/formulae.h index 03d3cbf4961..1483d86dc6c 100644 --- a/backends/p4tools/common/lib/formulae.h +++ b/backends/p4tools/common/lib/formulae.h @@ -28,6 +28,8 @@ class AbstractRepCheckedNode : public ICastable { explicit AbstractRepCheckedNode(const Node *node, std::string classDesc) : node(*node) { BUG_CHECK(Self::repOk(node), "%1%: Not a valid %2%.", node, classDesc); } + + DECLARE_TYPEINFO(AbstractRepCheckedNode); }; } // namespace P4Tools diff --git a/backends/p4tools/common/lib/trace_event.h b/backends/p4tools/common/lib/trace_event.h index c44eed17434..3ce8cb5bb7a 100644 --- a/backends/p4tools/common/lib/trace_event.h +++ b/backends/p4tools/common/lib/trace_event.h @@ -34,6 +34,8 @@ class TraceEvent : public ICastable { protected: /// Prints this trace event to the given ostream. virtual void print(std::ostream &) const = 0; + + DECLARE_TYPEINFO(TraceEvent); }; } // namespace P4Tools diff --git a/backends/p4tools/common/lib/trace_event_types.h b/backends/p4tools/common/lib/trace_event_types.h index dd2426e0085..1ab86dd4bc5 100644 --- a/backends/p4tools/common/lib/trace_event_types.h +++ b/backends/p4tools/common/lib/trace_event_types.h @@ -34,6 +34,8 @@ class Generic : public TraceEvent { Generic(Generic &&) = default; Generic &operator=(const Generic &) = default; Generic &operator=(Generic &&) = default; + + DECLARE_TYPEINFO(Generic, TraceEvent); }; /* ============================================================================================= @@ -50,6 +52,8 @@ class GenericDescription : public Generic { public: explicit GenericDescription(cstring label, cstring description); + + DECLARE_TYPEINFO(GenericDescription, Generic); }; /* ============================================================================================= @@ -75,6 +79,8 @@ class Expression : public Generic { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(Expression, Generic); }; /* ============================================================================================= @@ -96,6 +102,8 @@ class MethodCall : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(MethodCall, TraceEvent); }; /* ============================================================================================= @@ -120,6 +128,8 @@ class IfStatementCondition : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(IfStatementCondition, TraceEvent); }; /* ============================================================================================= @@ -141,6 +151,8 @@ class AssignmentStatement : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(AssignmentStatement, TraceEvent); }; /* ============================================================================================= @@ -187,6 +199,8 @@ class ExtractSuccess : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(ExtractSuccess, TraceEvent); }; /* ============================================================================================= @@ -219,6 +233,8 @@ class ExtractFailure : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(ExtractFailure, TraceEvent); }; /* ============================================================================================= @@ -245,6 +261,8 @@ class Emit : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(Emit, TraceEvent); }; /* ============================================================================================= @@ -281,6 +299,8 @@ class Packet : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(Packet, TraceEvent); }; std::ostream &operator<<(std::ostream &os, const Packet::Direction &direction); @@ -304,6 +324,8 @@ class ParserStart : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(ParserStart, TraceEvent); }; /* ============================================================================================= @@ -328,6 +350,8 @@ class ParserState : public TraceEvent { protected: void print(std::ostream &os) const override; + + DECLARE_TYPEINFO(ParserState, TraceEvent); }; } // namespace P4Tools::TraceEvents diff --git a/backends/p4tools/modules/testgen/core/compiler_target.h b/backends/p4tools/modules/testgen/core/compiler_target.h index caa939eed36..ca634b40af5 100644 --- a/backends/p4tools/modules/testgen/core/compiler_target.h +++ b/backends/p4tools/modules/testgen/core/compiler_target.h @@ -28,6 +28,8 @@ class TestgenCompilerResult : public CompilerResult { /// @returns the coverable nodes in the analyzed P4 program. [[nodiscard]] const P4::Coverage::CoverageSet &getCoverableNodes() const; + + DECLARE_TYPEINFO(TestgenCompilerResult, CompilerResult); }; class TestgenCompilerTarget : public CompilerTarget { diff --git a/backends/p4tools/modules/testgen/core/program_info.h b/backends/p4tools/modules/testgen/core/program_info.h index 1c612406214..7355f05d34c 100644 --- a/backends/p4tools/modules/testgen/core/program_info.h +++ b/backends/p4tools/modules/testgen/core/program_info.h @@ -9,6 +9,7 @@ #include "backends/p4tools/common/lib/arch_spec.h" #include "ir/ir.h" #include "lib/castable.h" +#include "lib/rtti.h" #include "midend/coverage.h" #include "backends/p4tools/modules/testgen/core/compiler_target.h" @@ -114,6 +115,8 @@ class ProgramInfo : public ICastable { const ArchSpec::ArchMember *archMember, std::vector *copyIns, std::vector *copyOuts) const; + + DECLARE_TYPEINFO(ProgramInfo); }; } // namespace P4Tools::P4Testgen diff --git a/backends/p4tools/modules/testgen/lib/test_object.h b/backends/p4tools/modules/testgen/lib/test_object.h index 63b9c72b3f7..6752634b46f 100644 --- a/backends/p4tools/modules/testgen/lib/test_object.h +++ b/backends/p4tools/modules/testgen/lib/test_object.h @@ -27,6 +27,8 @@ class TestObject : public ICastable { /// @returns a version of the test object where all expressions are resolved and symbolic /// variables are substituted according to the mapping present in the @param model. [[nodiscard]] virtual const TestObject *evaluate(const Model &model, bool doComplete) const = 0; + + DECLARE_TYPEINFO(TestObject); }; /// A map of test objects. diff --git a/backends/p4tools/modules/testgen/lib/test_spec.h b/backends/p4tools/modules/testgen/lib/test_spec.h index ef299585e23..207fbb7678f 100644 --- a/backends/p4tools/modules/testgen/lib/test_spec.h +++ b/backends/p4tools/modules/testgen/lib/test_spec.h @@ -54,6 +54,8 @@ class Packet : public TestObject { /// is ignored. /// A BUG is thrown otherwise. [[nodiscard]] const IR::Constant *getEvaluatedPayloadMask() const; + + DECLARE_TYPEINFO(Packet, TestObject); }; /* ========================================================================================= @@ -84,6 +86,8 @@ class ActionArg : public TestObject { /// If the value is a bool, it is converted into a constant. /// A BUG is thrown otherwise. [[nodiscard]] const IR::Constant *getEvaluatedValue() const; + + DECLARE_TYPEINFO(ActionArg, TestObject); }; class ActionCall : public TestObject { @@ -115,6 +119,8 @@ class ActionCall : public TestObject { /// @returns the arguments of this particular call. [[nodiscard]] const std::vector *getArgs() const; + + DECLARE_TYPEINFO(ActionCall, TestObject); }; class TableMatch : public TestObject { @@ -127,6 +133,8 @@ class TableMatch : public TestObject { /// @returns the key associated with this object. [[nodiscard]] const IR::KeyElement *getKey() const; + + DECLARE_TYPEINFO(TableMatch, TestObject); }; using TableMatchMap = std::map; @@ -156,6 +164,8 @@ class Ternary : public TableMatch { /// value needs to be a constant. /// A BUG is thrown otherwise. [[nodiscard]] const IR::Constant *getEvaluatedMask() const; + + DECLARE_TYPEINFO(Ternary, TableMatch); }; class LPM : public TableMatch { @@ -183,6 +193,8 @@ class LPM : public TableMatch { /// point the prefix is expected to be a constant. /// A BUG is thrown otherwise. [[nodiscard]] const IR::Constant *getEvaluatedPrefixLength() const; + + DECLARE_TYPEINFO(LPM, TableMatch); }; class Exact : public TableMatch { @@ -200,6 +212,8 @@ class Exact : public TableMatch { /// @returns the match value. It is expected to be a constant at this point. /// A BUG is thrown otherwise. [[nodiscard]] const IR::Constant *getEvaluatedValue() const; + + DECLARE_TYPEINFO(Exact, TableMatch); }; class TableRule : public TestObject { @@ -232,6 +246,8 @@ class TableRule : public TestObject { /// @returns the time-to-live of this particular entry. [[nodiscard]] int getTTL() const; + + DECLARE_TYPEINFO(TableRule, TestObject); }; class TableConfig : public TestObject { @@ -269,6 +285,8 @@ class TableConfig : public TestObject { /// Add a table property to the table. void addTableProperty(cstring propertyName, const TestObject *property); + + DECLARE_TYPEINFO(TableConfig, TestObject); }; /* ========================================================================================= diff --git a/backends/p4tools/modules/testgen/targets/bmv2/bmv2.h b/backends/p4tools/modules/testgen/targets/bmv2/bmv2.h index 2db89d47391..4f59a4cfe46 100644 --- a/backends/p4tools/modules/testgen/targets/bmv2/bmv2.h +++ b/backends/p4tools/modules/testgen/targets/bmv2/bmv2.h @@ -39,6 +39,8 @@ class BMv2V1ModelCompilerResult : public TestgenCompilerResult { /// @returns the map of direct extern declarations which are attached to a table. [[nodiscard]] const DirectExternMap &getDirectExternMap() const; + + DECLARE_TYPEINFO(BMv2V1ModelCompilerResult, TestgenCompilerResult); }; class Bmv2V1ModelCompilerTarget : public TestgenCompilerTarget { diff --git a/backends/p4tools/modules/testgen/targets/bmv2/program_info.h b/backends/p4tools/modules/testgen/targets/bmv2/program_info.h index 73df87b5276..3a53f342005 100644 --- a/backends/p4tools/modules/testgen/targets/bmv2/program_info.h +++ b/backends/p4tools/modules/testgen/targets/bmv2/program_info.h @@ -80,6 +80,8 @@ class Bmv2V1ModelProgramInfo : public ProgramInfo { /// @see ProgramInfo::getArchSpec static const ArchSpec ARCH_SPEC; + + DECLARE_TYPEINFO(Bmv2V1ModelProgramInfo, ProgramInfo); }; } // namespace P4Tools::P4Testgen::Bmv2 diff --git a/backends/p4tools/modules/testgen/targets/bmv2/test_spec.h b/backends/p4tools/modules/testgen/targets/bmv2/test_spec.h index a57c295db01..f228e417c09 100644 --- a/backends/p4tools/modules/testgen/targets/bmv2/test_spec.h +++ b/backends/p4tools/modules/testgen/targets/bmv2/test_spec.h @@ -12,6 +12,7 @@ #include "ir/declaration.h" #include "ir/ir.h" #include "lib/cstring.h" +#include "lib/rtti.h" #include "backends/p4tools/modules/testgen/lib/execution_state.h" #include "backends/p4tools/modules/testgen/lib/test_object.h" @@ -55,6 +56,8 @@ class IndexExpression : public TestObject { bool doComplete) const override; [[nodiscard]] cstring getObjectName() const override; + + DECLARE_TYPEINFO(IndexExpression, TestObject); }; /* ========================================================================================= @@ -88,6 +91,8 @@ class IndexMap : public TestObject { /// Return the "writes" to this index map as a [[nodiscard]] std::map> unravelMap() const; + + DECLARE_TYPEINFO(IndexMap, TestObject); }; /* ========================================================================================= @@ -109,6 +114,8 @@ class Bmv2V1ModelRegisterValue : public IndexMap { [[nodiscard]] const Bmv2V1ModelRegisterValue *evaluate(const Model &model, bool doComplete) const override; + + DECLARE_TYPEINFO(Bmv2V1ModelRegisterValue, IndexMap); }; /* ========================================================================================= @@ -130,6 +137,8 @@ class Bmv2V1ModelMeterValue : public IndexMap { /// @returns whether the meter associated with this meter value object is a direct meter. [[nodiscard]] bool isDirectMeter() const; + + DECLARE_TYPEINFO(Bmv2V1ModelMeterValue, IndexMap); }; /* ========================================================================================= @@ -162,6 +171,8 @@ class Bmv2V1ModelActionProfile : public TestObject { [[nodiscard]] const Bmv2V1ModelActionProfile *evaluate(const Model &model, bool doComplete) const override; + + DECLARE_TYPEINFO(Bmv2V1ModelActionProfile, TestObject); }; /* ========================================================================================= @@ -189,6 +200,8 @@ class Bmv2V1ModelActionSelector : public TestObject { [[nodiscard]] const Bmv2V1ModelActionSelector *evaluate(const Model &model, bool doComplete) const override; + + DECLARE_TYPEINFO(Bmv2V1ModelActionSelector, TestObject); }; /* ========================================================================================= @@ -230,6 +243,8 @@ class Bmv2V1ModelCloneInfo : public TestObject { /// @returns the state that was cloned at the time of generation of this object. [[nodiscard]] const ExecutionState &getClonedState() const; + + DECLARE_TYPEINFO(Bmv2V1ModelCloneInfo, TestObject); }; /* ========================================================================================= @@ -273,6 +288,8 @@ class Bmv2V1ModelCloneSpec : public TestObject { /// @returns the evaluated session id. This means it must be a constant. /// The function will throw a bug if this is not the case. [[nodiscard]] const IR::Constant *getEvaluatedSessionId() const; + + DECLARE_TYPEINFO(Bmv2V1ModelCloneSpec, TestObject); }; /* ========================================================================================= @@ -299,6 +316,8 @@ class MetadataCollection : public TestObject { /// @returns a metadata field from the collection. const IR::Literal *getMetadataField(cstring name); + + DECLARE_TYPEINFO(MetadataCollection, TestObject); }; /* ========================================================================================= @@ -326,6 +345,8 @@ class Optional : public TableMatch { /// @returns whether to add this optional match as an exact match. [[nodiscard]] bool addAsExactMatch() const; + + DECLARE_TYPEINFO(Optional, TableMatch); }; class Range : public TableMatch { @@ -351,6 +372,8 @@ class Range : public TableMatch { /// @returns the inclusive end of the range. It is expected to be a constant at this point. /// A BUG is thrown otherwise. [[nodiscard]] const IR::Constant *getEvaluatedHigh() const; + + DECLARE_TYPEINFO(Range, TableMatch); }; } // namespace P4Tools::P4Testgen::Bmv2 diff --git a/backends/p4tools/modules/testgen/targets/ebpf/program_info.h b/backends/p4tools/modules/testgen/targets/ebpf/program_info.h index c6f50f734f9..70d1edb7235 100644 --- a/backends/p4tools/modules/testgen/targets/ebpf/program_info.h +++ b/backends/p4tools/modules/testgen/targets/ebpf/program_info.h @@ -47,6 +47,8 @@ class EBPFProgramInfo : public ProgramInfo { /// @see ProgramInfo::getArchSpec static const ArchSpec ARCH_SPEC; + + DECLARE_TYPEINFO(EBPFProgramInfo, ProgramInfo); }; } // namespace P4Tools::P4Testgen::EBPF diff --git a/backends/p4tools/modules/testgen/targets/pna/dpdk/program_info.h b/backends/p4tools/modules/testgen/targets/pna/dpdk/program_info.h index ed9ef1d215e..5be5cd66ac5 100644 --- a/backends/p4tools/modules/testgen/targets/pna/dpdk/program_info.h +++ b/backends/p4tools/modules/testgen/targets/pna/dpdk/program_info.h @@ -29,6 +29,8 @@ class PnaDpdkProgramInfo : public SharedPnaProgramInfo { /// @see ProgramInfo::getArchSpec static const ArchSpec ARCH_SPEC; + + DECLARE_TYPEINFO(PnaDpdkProgramInfo, SharedPnaProgramInfo); }; } // namespace P4Tools::P4Testgen::Pna diff --git a/backends/p4tools/modules/testgen/targets/pna/shared_program_info.h b/backends/p4tools/modules/testgen/targets/pna/shared_program_info.h index 70602d41d52..6c60bdc95fb 100644 --- a/backends/p4tools/modules/testgen/targets/pna/shared_program_info.h +++ b/backends/p4tools/modules/testgen/targets/pna/shared_program_info.h @@ -39,6 +39,8 @@ class SharedPnaProgramInfo : public ProgramInfo { /// index. This is the name of the parameter that is used in the P4 program. [[nodiscard]] const IR::PathExpression *getBlockParam(cstring blockLabel, size_t paramIndex) const; + + DECLARE_TYPEINFO(SharedPnaProgramInfo, ProgramInfo); }; } // namespace P4Tools::P4Testgen::Pna diff --git a/backends/p4tools/modules/testgen/targets/pna/test_spec.h b/backends/p4tools/modules/testgen/targets/pna/test_spec.h index 871951b3376..9be0f8efd26 100644 --- a/backends/p4tools/modules/testgen/targets/pna/test_spec.h +++ b/backends/p4tools/modules/testgen/targets/pna/test_spec.h @@ -42,6 +42,8 @@ class PnaDpdkRegisterCondition : public TestObject { bool doComplete) const override; [[nodiscard]] cstring getObjectName() const override; + + DECLARE_TYPEINFO(PnaDpdkRegisterCondition, TestObject); }; /// This object tracks the list of writes that have been performed to a particular register. The @@ -82,6 +84,8 @@ class PnaDpdkRegisterValue : public TestObject { [[nodiscard]] const PnaDpdkRegisterValue *evaluate(const Model &model, bool doComplete) const override; + + DECLARE_TYPEINFO(PnaDpdkRegisterValue, TestObject); }; /* ========================================================================================= @@ -114,6 +118,8 @@ class PnaDpdkActionProfile : public TestObject { [[nodiscard]] const PnaDpdkActionProfile *evaluate(const Model &model, bool doComplete) const override; + + DECLARE_TYPEINFO(PnaDpdkActionProfile, TestObject); }; /* ========================================================================================= @@ -141,6 +147,8 @@ class PnaDpdkActionSelector : public TestObject { [[nodiscard]] const PnaDpdkActionSelector *evaluate(const Model &model, bool doComplete) const override; + + DECLARE_TYPEINFO(PnaDpdkActionSelector, TestObject); }; /* ========================================================================================= @@ -164,6 +172,8 @@ class MetadataCollection : public TestObject { void addMetaDataField(cstring name, const IR::Literal *metadataField); const IR::Literal *getMetadataField(cstring name); + + DECLARE_TYPEINFO(MetadataCollection, TestObject); }; /* ========================================================================================= @@ -191,6 +201,8 @@ class Optional : public TableMatch { /// @returns whether to add this optional match as an exact match. bool addAsExactMatch() const; + + DECLARE_TYPEINFO(Optional, TableMatch); }; class Range : public TableMatch { @@ -216,6 +228,8 @@ class Range : public TableMatch { /// @returns the inclusive end of the range. It is expected to be a constant at this point. /// A BUG is thrown otherwise. const IR::Constant *getEvaluatedHigh() const; + + DECLARE_TYPEINFO(Range, TableMatch); }; } // namespace P4Tools::P4Testgen::Pna diff --git a/ir/solver.h b/ir/solver.h index dd406a36b2b..459be62fa28 100644 --- a/ir/solver.h +++ b/ir/solver.h @@ -62,6 +62,8 @@ class AbstractSolver : public ICastable { /// @returns whether this solver is incremental. [[nodiscard]] virtual bool isInIncrementalMode() const = 0; + + DECLARE_TYPEINFO(AbstractSolver); }; #endif /* IR_SOLVER_H_ */