Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
3f215a06
Commit
3f215a06
authored
Nov 20, 2017
by
Robert Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generating pch
parent
3bb93eb3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
compiler.cpp
src/ngraph/codegen/compiler.cpp
+25
-18
compiler.hpp
src/ngraph/codegen/compiler.hpp
+1
-0
No files found.
src/ngraph/codegen/compiler.cpp
View file @
3f215a06
...
...
@@ -42,6 +42,7 @@
#include <clang/Basic/TargetInfo.h>
#include <clang/CodeGen/CodeGenAction.h>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendActions.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <llvm/Support/TargetSelect.h>
...
...
@@ -214,7 +215,10 @@ StaticCompiler::StaticCompiler()
CGO
.
setDebugInfo
(
codegenoptions
::
FullDebugInfo
);
}
if
(
m_precompiled_headers_enabled
)
// if (!m_precompiled_header_valid)
// {
// }
if
(
m_precompiled_header_valid
)
{
// Preprocessor options
auto
&
PPO
=
m_compiler
->
getInvocation
().
getPreprocessorOpts
();
...
...
@@ -313,6 +317,8 @@ void StaticCompiler::use_cached_files()
std
::
unique_ptr
<
llvm
::
Module
>
StaticCompiler
::
compile
(
const
string
&
source
)
{
generate_pch
(
source
);
// Map code filename to a memoryBuffer
StringRef
source_ref
(
source
);
unique_ptr
<
MemoryBuffer
>
buffer
=
MemoryBuffer
::
getMemBufferCopy
(
source_ref
);
...
...
@@ -333,24 +339,25 @@ std::unique_ptr<llvm::Module> StaticCompiler::compile(const string& source)
return
rc
;
}
// std::unique_ptr<llvm::Module> StaticCompiler::generate_pch(const string& source)
// {
// // Map code filename to a memoryBuffer
// StringRef source_ref(source);
// unique_ptr<MemoryBuffer> buffer = MemoryBuffer::getMemBufferCopy(source_ref);
// m_compiler->getInvocation().getPreprocessorOpts().addRemappedFile(m_source_name, buffer.get());
void
StaticCompiler
::
generate_pch
(
const
string
&
source
)
{
NGRAPH_INFO
;
string
pch_path
=
file_util
::
path_join
(
file_util
::
get_temp_directory
(),
"ngraph.pch"
);
m_compiler
->
getFrontendOpts
().
OutputFile
=
pch_path
;
// // Create and execute action
// CodeGenAction* compilerAction = new GeneratePCHAction();
// std::unique_ptr<llvm::Module> rc;
// if (m_compiler->ExecuteAction(*compilerAction) == true)
// {
// rc = compilerAction->takeModule();
// }
// Map code filename to a memoryBuffer
StringRef
source_ref
(
source
);
unique_ptr
<
MemoryBuffer
>
buffer
=
MemoryBuffer
::
getMemBufferCopy
(
source_ref
);
m_compiler
->
getInvocation
().
getPreprocessorOpts
().
addRemappedFile
(
m_source_name
,
buffer
.
get
());
// 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
()
;
}
src/ngraph/codegen/compiler.hpp
View file @
3f215a06
...
...
@@ -68,6 +68,7 @@ public:
bool
is_debuginfo_enabled
()
{
return
m_debuginfo_enabled
;
}
void
add_header_search_path
(
const
std
::
string
&
path
);
std
::
unique_ptr
<
llvm
::
Module
>
compile
(
const
std
::
string
&
source
);
void
generate_pch
(
const
std
::
string
&
source
);
private
:
std
::
unique_ptr
<
clang
::
CompilerInstance
>
m_compiler
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment