diff --git a/src/qiree/Module.cc b/src/qiree/Module.cc index 346e311..d771eb0 100644 --- a/src/qiree/Module.cc +++ b/src/qiree/Module.cc @@ -113,6 +113,22 @@ Module::Module(UPModule&& module) : module_{std::move(module)} << module_->getSourceFileName() << "'"); } +//---------------------------------------------------------------------------// +/*! + * Construct with an LLVM module and an entry point. + * Useful when there are multiple entry points. + */ +Module::Module(UPModule&& module, std::string const& entrypoint) + : module_{std::move(module)} +{ + QIREE_EXPECT(module_); + + // Search for explicitly named entry point + entrypoint_ = module_->getFunction(entrypoint); + QIREE_VALIDATE(entrypoint_, + << "no entrypoint function '" << entrypoint << "' exists"); +} + //---------------------------------------------------------------------------// /*! * Construct with an LLVM IR file (bitcode or disassembled). @@ -125,6 +141,7 @@ Module::Module(std::string const& filename) //---------------------------------------------------------------------------// /*! * Construct with an LLVM IR file (bitcode or disassembled) and entry point. + * Useful when there are multiple entry points. */ Module::Module(std::string const& filename, std::string const& entrypoint) : module_{load_llvm_module(filename)} diff --git a/src/qiree/Module.hh b/src/qiree/Module.hh index c6ceaed..21ed2df 100644 --- a/src/qiree/Module.hh +++ b/src/qiree/Module.hh @@ -45,6 +45,9 @@ class Module // Construct from an externally created LLVM module explicit Module(UPModule&& module); + // Construct from an externally created LLVM module and an entry point + Module(UPModule&& module, std::string const& entrypoint); + // Construct with an LLVM IR file (bitcode or disassembled) explicit Module(std::string const& filename);