diff --git a/src/qiree/Module.cc b/src/qiree/Module.cc index 346e311..83d9703 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. + */ +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). diff --git a/src/qiree/Module.hh b/src/qiree/Module.hh index c6ceaed..fc7247c 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 + explicit Module(UPModule&& module, std::string const& entrypoint); + // Construct with an LLVM IR file (bitcode or disassembled) explicit Module(std::string const& filename);