diff options
author | Alexey Bader <alexey.bader@intel.com> | 2015-12-14 16:41:05 +0300 |
---|---|---|
committer | Alexey Bader <alexey.bader@intel.com> | 2015-12-14 17:33:55 +0300 |
commit | e35f69c4c53ccaad4812c7ba66b7691a9c10a09c (patch) | |
tree | e6ceb3ac620def1dffe0f6c98e70341b564dd808 /tools | |
parent | 5de3a72d0d7d95b4fa8e869096fb4493bc157eb1 (diff) |
Clang integration.
- Added SPIRVWriterPass.
- Switched from std::ostream to llvm::raw_ostream.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-spirv/llvm-spirv.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/llvm-spirv/llvm-spirv.cpp b/tools/llvm-spirv/llvm-spirv.cpp index c6c597b..906f718 100644 --- a/tools/llvm-spirv/llvm-spirv.cpp +++ b/tools/llvm-spirv/llvm-spirv.cpp @@ -142,10 +142,10 @@ convertLLVMToSPIRV() { OutputFile = removeExt(InputFile) + kExt::SpirvBinary;
}
- std::ofstream OFS;
- std::ostream *OS = OutputFile == "-" ? &std::cout :
- (OFS.open(OutputFile, std::ios::binary), &OFS);
- if (!WriteSPIRV(M.get(), *OS, Err)) {
+ llvm::StringRef outFile(OutputFile);
+ std::error_code EC;
+ llvm::raw_fd_ostream OFS(outFile, EC, llvm::sys::fs::F_None);
+ if (!WriteSPIRV(M.get(), OFS, Err)) {
errs() << "Fails to save LLVM as SPIRV: " << Err << '\n';
return -1;
}
@@ -211,7 +211,7 @@ convertSPIRV() { }
}
- auto Action = [&](std::ostream &OFS) {
+ auto Action = [&](llvm::raw_ostream &OFS) {
std::string Err;
if (!SPIRV::ConvertSPIRV(IFS, OFS, Err, ToBinary, ToText)) {
errs() << "Fails to convert SPIR-V : " << Err << '\n';
@@ -220,10 +220,11 @@ convertSPIRV() { return 0;
};
if (OutputFile != "-") {
- std::ofstream OFS(OutputFile, std::ios::binary);
+ std::error_code EC;
+ llvm::raw_fd_ostream OFS(llvm::StringRef(OutputFile), EC, llvm::sys::fs::F_None);
return Action(OFS);
} else
- return Action(std::cout);
+ return Action(outs());
}
#endif
|