Commit 3f215a06 authored by Robert Kimball's avatar Robert Kimball

generating pch

parent 3bb93eb3
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <clang/Basic/TargetInfo.h> #include <clang/Basic/TargetInfo.h>
#include <clang/CodeGen/CodeGenAction.h> #include <clang/CodeGen/CodeGenAction.h>
#include <clang/Frontend/CompilerInstance.h> #include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendActions.h>
#include <clang/Frontend/TextDiagnosticPrinter.h> #include <clang/Frontend/TextDiagnosticPrinter.h>
#include <llvm/Support/TargetSelect.h> #include <llvm/Support/TargetSelect.h>
...@@ -214,7 +215,10 @@ StaticCompiler::StaticCompiler() ...@@ -214,7 +215,10 @@ StaticCompiler::StaticCompiler()
CGO.setDebugInfo(codegenoptions::FullDebugInfo); CGO.setDebugInfo(codegenoptions::FullDebugInfo);
} }
if (m_precompiled_headers_enabled) // if (!m_precompiled_header_valid)
// {
// }
if (m_precompiled_header_valid)
{ {
// Preprocessor options // Preprocessor options
auto& PPO = m_compiler->getInvocation().getPreprocessorOpts(); auto& PPO = m_compiler->getInvocation().getPreprocessorOpts();
...@@ -313,6 +317,8 @@ void StaticCompiler::use_cached_files() ...@@ -313,6 +317,8 @@ void StaticCompiler::use_cached_files()
std::unique_ptr<llvm::Module> StaticCompiler::compile(const string& source) std::unique_ptr<llvm::Module> StaticCompiler::compile(const string& source)
{ {
generate_pch(source);
// Map code filename to a memoryBuffer // Map code filename to a memoryBuffer
StringRef source_ref(source); StringRef source_ref(source);
unique_ptr<MemoryBuffer> buffer = MemoryBuffer::getMemBufferCopy(source_ref); unique_ptr<MemoryBuffer> buffer = MemoryBuffer::getMemBufferCopy(source_ref);
...@@ -333,24 +339,25 @@ std::unique_ptr<llvm::Module> StaticCompiler::compile(const string& source) ...@@ -333,24 +339,25 @@ std::unique_ptr<llvm::Module> StaticCompiler::compile(const string& source)
return rc; return rc;
} }
// std::unique_ptr<llvm::Module> StaticCompiler::generate_pch(const string& source) void StaticCompiler::generate_pch(const string& source)
// { {
// // Map code filename to a memoryBuffer NGRAPH_INFO;
// StringRef source_ref(source); string pch_path = file_util::path_join(file_util::get_temp_directory(), "ngraph.pch");
// unique_ptr<MemoryBuffer> buffer = MemoryBuffer::getMemBufferCopy(source_ref); m_compiler->getFrontendOpts().OutputFile = pch_path;
// m_compiler->getInvocation().getPreprocessorOpts().addRemappedFile(m_source_name, buffer.get());
// // Create and execute action // Map code filename to a memoryBuffer
// CodeGenAction* compilerAction = new GeneratePCHAction(); StringRef source_ref(source);
// std::unique_ptr<llvm::Module> rc; unique_ptr<MemoryBuffer> buffer = MemoryBuffer::getMemBufferCopy(source_ref);
// if (m_compiler->ExecuteAction(*compilerAction) == true) m_compiler->getInvocation().getPreprocessorOpts().addRemappedFile(m_source_name, buffer.get());
// {
// rc = compilerAction->takeModule();
// }
// buffer.release(); // Create and execute action
clang::GeneratePCHAction* compilerAction = new clang::GeneratePCHAction();
if (m_compiler->ExecuteAction(*compilerAction) == true)
{
NGRAPH_INFO;
}
// m_compiler->getInvocation().getPreprocessorOpts().clearRemappedFiles(); buffer.release();
// return rc; m_compiler->getInvocation().getPreprocessorOpts().clearRemappedFiles();
// } }
...@@ -68,6 +68,7 @@ public: ...@@ -68,6 +68,7 @@ public:
bool is_debuginfo_enabled() { return m_debuginfo_enabled; } bool is_debuginfo_enabled() { return m_debuginfo_enabled; }
void add_header_search_path(const std::string& path); void add_header_search_path(const std::string& path);
std::unique_ptr<llvm::Module> compile(const std::string& source); std::unique_ptr<llvm::Module> compile(const std::string& source);
void generate_pch(const std::string& source);
private: private:
std::unique_ptr<clang::CompilerInstance> m_compiler; std::unique_ptr<clang::CompilerInstance> m_compiler;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment