#pragma once #include "dsl.h" #include #include #include #include namespace seq { /// Plugin metadata struct Plugin { /// the associated DSL std::unique_ptr dsl; /// plugin load path std::string path; /// plugin dlopen handle void *handle; }; /// Manager for loading, applying and unloading plugins. class PluginManager { private: /// pass manager with which to register plugin IR passes ir::transform::PassManager *pm; /// vector of loaded plugins std::vector plugins; /// true if compiling in debug mode bool debug; public: using LoadFunc = std::function()>; /// Error codes when loading plugins enum Error { NONE = 0, NOT_FOUND, NO_ENTRYPOINT, UNSUPPORTED_VERSION }; /// Constructs a plugin manager from a given IR pass manager /// @param pm the IR pass manager to register IR passes with explicit PluginManager(ir::transform::PassManager *pm, bool debug = false) : pm(pm), plugins(), debug(debug) {} ~PluginManager(); /// Loads the plugin at the given load path. Error load(const std::string &path); /// Loads the given DSL Error load(DSL *dsl); }; } // namespace seq