diff options
Diffstat (limited to 'src/core/cpu/program.h')
-rw-r--r-- | src/core/cpu/program.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/core/cpu/program.h b/src/core/cpu/program.h index 34668f2..350d248 100644 --- a/src/core/cpu/program.h +++ b/src/core/cpu/program.h @@ -25,6 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/** + * \file cpu/program.h + * \brief CPU program + */ + #ifndef __CPU_PROGRAM_H__ #define __CPU_PROGRAM_H__ @@ -42,9 +47,23 @@ namespace Coal class CPUDevice; class Program; +/** + * \brief CPU program + * + * This class implements the \c Coal::DeviceProgram interface for CPU + * acceleration. + * + * It's main purpose is to initialize a \c llvm::JIT object to run LLVM bitcode, + * in \c initJIT(). + */ class CPUProgram : public DeviceProgram { public: + /** + * \brief Constructor + * \param device CPU device to which this program is attached + * \param program \c Coal::Program that will be run + */ CPUProgram(CPUDevice *device, Program *program); ~CPUProgram(); @@ -52,8 +71,22 @@ class CPUProgram : public DeviceProgram void createOptimizationPasses(llvm::PassManager *manager, bool optimize); bool build(llvm::Module *module); + /** + * \brief Initialize an LLVM JIT + * + * This function creates a \c llvm::JIT object to run this program on + * the CPU. A few implementation details : + * + * - The JIT is set not to resolve unknown symbols using \c dlsym(). + * This way, a malicious kernel cannot execute arbitrary code on + * the host by declaring \c libc functions and calling them. + * - All the unknown function names are passed to \c getBuiltin() to + * get native built-in implementations. + * + * \return true if success, false otherwise + */ bool initJIT(); - llvm::ExecutionEngine *jit() const; + llvm::ExecutionEngine *jit() const; /*!< \brief Current LLVM execution engine */ private: CPUDevice *p_device; |