Frank Winter via llvm-dev
2016-Feb-19 21:16 UTC
[llvm-dev] raw_pwrite_stream to string or stdout?
TargetMachine::addPassesToEmitFile(..) requires as its 2nd argument an raw_pwrite_stream. Is it possible to create such a thing which either writes into a standard string or streams to outs() ? Thanks,
Yaron Keren via llvm-dev
2016-Feb-20 07:14 UTC
[llvm-dev] raw_pwrite_stream to string or stdout?
raw_string_ostream is an adaptor for std::string. raw_svector_ostream is more efficient adaptor for llvm::SmallString. outs() will not work as it can't seek. 2016-02-19 23:16 GMT+02:00 Frank Winter via llvm-dev < llvm-dev at lists.llvm.org>:> TargetMachine::addPassesToEmitFile(..) > requires as its 2nd argument an raw_pwrite_stream. > > Is it possible to create such a thing which either writes into a standard > string or streams to outs() ? > > Thanks, > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160220/868fa24a/attachment.html>
Rafael EspĂndola via llvm-dev
2016-Feb-22 16:06 UTC
[llvm-dev] raw_pwrite_stream to string or stdout?
On 19 February 2016 at 16:16, Frank Winter via llvm-dev <llvm-dev at lists.llvm.org> wrote:> TargetMachine::addPassesToEmitFile(..) > requires as its 2nd argument an raw_pwrite_stream. > > Is it possible to create such a thing which either writes into a standard > string or streams to outs() ?I would suggest doing what llc does: if ((FileType != TargetMachine::CGFT_AssemblyFile && !Out->os().supportsSeeking()) || CompileTwice) { BOS = make_unique<raw_svector_ostream>(Buffer); OS = BOS.get(); } That will work even with redirects. Cheers, Rafael
Frank Winter via llvm-dev
2016-Feb-22 16:16 UTC
[llvm-dev] raw_pwrite_stream to string or stdout?
TargetMachine::CGFT_AssemblyFile is exactly what I am trying to write out. Frank On 02/22/2016 11:06 AM, Rafael EspĂndola wrote:> On 19 February 2016 at 16:16, Frank Winter via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> TargetMachine::addPassesToEmitFile(..) >> requires as its 2nd argument an raw_pwrite_stream. >> >> Is it possible to create such a thing which either writes into a standard >> string or streams to outs() ? > > > I would suggest doing what llc does: > > if ((FileType != TargetMachine::CGFT_AssemblyFile && > !Out->os().supportsSeeking()) || > CompileTwice) { > BOS = make_unique<raw_svector_ostream>(Buffer); > OS = BOS.get(); > } > > That will work even with redirects. > > Cheers, > Rafael >