1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

56 Commits

Author SHA1 Message Date
Daniel Dunbar
5aa51a83c7 Revert r78924, disabling buffering defeats all the fast paths in raw_ostream.
llvm-svn: 79361
2009-08-18 20:07:36 +00:00
Dan Gohman
82430f54ec Mingw also doesn't have st_blksize.
llvm-svn: 79142
2009-08-15 21:41:03 +00:00
Dan Gohman
d0419623b1 Always check to see if raw_fd_ostream's file descriptor is attached to
a terminal, not just when it's STDOUT_FILENO.

llvm-svn: 79066
2009-08-15 02:05:19 +00:00
Dan Gohman
0c10b8864a When standard output is a terminal, set outs() to be unbuffered, to
mimic the behavior of stdtout, which is line-buffered when the output
is a terminal. This fixes some issues with bugpoint output appearing
being printed out of order.

llvm-svn: 78953
2009-08-13 23:18:56 +00:00
Dan Gohman
fa45862247 Fix a compiler warning about comparing signed with unsigned.
llvm-svn: 78933
2009-08-13 20:32:03 +00:00
Dan Gohman
c91e786fa1 Add an assert to check copy_to_buffer's precondition.
llvm-svn: 78926
2009-08-13 18:38:15 +00:00
Dan Gohman
c692477e5e Set raw_os_ostream, raw_string_ostream, and raw_svector_ostream to be
unbuffered. std::ostream does its own buffering, and std::string and
SmallVector both have allocation strategies intended to handle frequent
appending.

llvm-svn: 78924
2009-08-13 17:41:40 +00:00
Dan Gohman
4ac7200d66 Add support to raw_ostream for sizing the buffer according to the
needs of the underlying output mechanism. raw_fd_ostream now uses
st_blksize from fstat to determine a buffer size.

llvm-svn: 78923
2009-08-13 17:27:29 +00:00
Dan Gohman
fb52ff3ba7 Move SetBufferSize and SetUnbuffered out of line.
llvm-svn: 78909
2009-08-13 15:58:55 +00:00
Dan Gohman
3469d2e1a9 Fix the buffer handling logic so that write_impl is always called with
a full buffer, rather than often being called with a
slightly-less-than-full buffer.

llvm-svn: 78907
2009-08-13 15:44:52 +00:00
Daniel Dunbar
79e9ed1d26 Add raw_ostream::write_hex
llvm-svn: 77614
2009-07-30 18:21:23 +00:00
Daniel Dunbar
d2bf575100 Perform simplification noticed by Reid.
llvm-svn: 77477
2009-07-29 17:29:36 +00:00
Daniel Dunbar
1589195975 raw_ostream: Follow the 32-bit path when printing "small" decimal numbers.
llvm-svn: 77444
2009-07-29 06:45:14 +00:00
Dan Gohman
40bd748448 Make raw_null_ostream flush its buffer in its destructor, so that
it conforms to the assertion added in r77245. This fixes a failure
in qa_override.c in clang's testsuite.

llvm-svn: 77255
2009-07-27 21:46:02 +00:00
Dan Gohman
982c2fe893 Add an assertion check to raw_ostream's destructor to verify
that the subclass hasn't left any pending data in the buffer.

llvm-svn: 77245
2009-07-27 20:49:44 +00:00
Daniel Dunbar
276e4a7a7d Add raw_null_ostream and llvm::nulls(), a raw_ostream that discards output.
- No functionality change.

llvm-svn: 76103
2009-07-16 21:17:53 +00:00
Dan Gohman
0bcfcaa96c Use size_t.
llvm-svn: 76069
2009-07-16 15:24:40 +00:00
Dan Gohman
f01e53a482 Change raw_ostream so that it doesn't call llvm_report_error
immediately on every output error. Instead, add a flag to
raw_ostream, and set the flag whenever an error is detected.

The flag can be queried and cleared from the public API. This
gives applications more flexibility to handling errors in
application-specific ways.

If the flag is not cleared when the raw_ostream is destructed,
llvm_report_error is called from the destructor. This ensures
that errors are not implicitly silenced, and provides
convenient default behavior for tools like llc and opt.
Clients wishing to avoid llvm_report_error calls from
raw_ostream should check for errors and clear the error flag.

llvm-svn: 75857
2009-07-15 23:25:33 +00:00
Dan Gohman
9ced780576 Add a Force option to raw_fd_ostream to specify whether opening
an existing file is considered an error. Convert several tools
to use raw_fd_ostream instead of std::ostream, and to use this
new option instead of doing a manual check.

llvm-svn: 75801
2009-07-15 17:29:42 +00:00
Dan Gohman
d9404ff779 Check for errors on close(2) too. And lseek(2).
llvm-svn: 75793
2009-07-15 16:43:01 +00:00
Dan Gohman
60616fdb0b Use 0664 instead of 0644 for the default open mode. This is
consistent with common std::ostream implmentations, and it gives
the user the option of using the umask group write bit.

llvm-svn: 75792
2009-07-15 16:39:40 +00:00
Daniel Dunbar
2b6a680bf6 Detect write failures on raw_fd_ostream.
llvm-svn: 75758
2009-07-15 08:11:46 +00:00
David Greene
9c8a1b9b90 Have asm printers use formatted_raw_ostream directly to avoid a
dynamic_cast<>.

llvm-svn: 75670
2009-07-14 20:18:05 +00:00
David Greene
a60479705b Make changes suggested by Chris and eliminate newly-added raw_ostream
hooks as they're no longer needed.

The major change with this patch is to make formatted_raw_ostream usable
by any client of raw_ostream.

llvm-svn: 75283
2009-07-10 21:14:44 +00:00
David Greene
98610d5cfd Add some hooks that a redesigned AsmStream needs to do its job. These
allow derived classes to examine the stream buffer before it's flushed.

llvm-svn: 75199
2009-07-09 23:43:41 +00:00
Torok Edwin
5da9f51d1e Add support for outputting ANSI colors to raw_fd_ostream.
llvm-svn: 72854
2009-06-04 07:09:50 +00:00
Douglas Gregor
bdeba00c46 Make all raw_ostreams support the tell() function.
llvm-svn: 69583
2009-04-20 07:34:17 +00:00
Daniel Dunbar
7c9dba0950 Add BUILTIN_EXPECT Support/Compiler macro.
- Use for exceptional buffer conditions in raw_ostream:write to shave
   off a cycle or two.

 - Please rename if you have a better one.

llvm-svn: 67103
2009-03-17 21:15:18 +00:00
Daniel Dunbar
2cc1ec75e1 raw_ostream: Put all exceptional conditions in raw_ostream::write
under a single branch.

Also, add a FIXME for formatted output.

llvm-svn: 67069
2009-03-17 01:36:56 +00:00
Daniel Dunbar
b04be1838d raw_ostream: Rework implementation of unbuffered streams so outputting
a single character requires only one branch to follow slow path.
 - Never use a buffer when writing on an unbuffered stream.

 - Move default buffer size to header.

llvm-svn: 67066
2009-03-17 01:13:35 +00:00
Daniel Dunbar
2062a58347 raw_ostream: Replace flush_impl with write_impl, which takes data to
write as arguments.
 - Add raw_ostream::GetNumBytesInBuffer.
 - Privatize buffer pointers.
 - Get rid of slow and unnecessary code for writing out large strings.

llvm-svn: 67060
2009-03-16 23:29:31 +00:00
Daniel Dunbar
c2d554fe0b raw_ostream: Lift out flush_nonempty.
- Flush a known non-empty buffers; enforces the interface to
   flush_impl and kills off HandleFlush (which I saw no reason to be
   an inline method, Chris?).

 - Clarify invariant that flush_impl is only called with OutBufCur >
   OutBufStart.

 - This also cleary collects all places where we have to deal with the
   buffer possibly not existing.

 - A few more comments and fixing the unbuffered behavior remain in
   this commit sequence.

llvm-svn: 67057
2009-03-16 22:55:06 +00:00
Daniel Dunbar
5ef319c7d7 Make raw_ostream::operator<<(const void *) fast; it doesn't matter but
it is easy.

llvm-svn: 67054
2009-03-16 22:08:44 +00:00
Daniel Dunbar
c64fdabf4f Add slow path for single character write, and use exclusively for
single characters writes outside of the fast path in raw_ostream.h

llvm-svn: 67053
2009-03-16 22:00:17 +00:00
Daniel Dunbar
b60a074565 PR3478: raw_ostream should not buffer stderr
- Add unbuffered flag to raw_ostream, forwarded by raw_fd_ostream and
   used by raw_stderr_ostream.

llvm-svn: 66545
2009-03-10 16:21:55 +00:00
Ted Kremenek
d8045c9154 Add method raw_fd_ostream::seek() for random access within a file.
llvm-svn: 63044
2009-01-26 21:42:04 +00:00
Ted Kremenek
a851e459e1 Have raw_fd_ostream keep track of the position in the file to make tell() go faster by not requiring a flush().
llvm-svn: 60560
2008-12-04 22:51:11 +00:00
Ted Kremenek
b31e49cd47 Add 'tell' method to raw_fd_ostream that clients can use to query the current location in the file the stream is writing to.
llvm-svn: 60085
2008-11-26 03:33:13 +00:00
Daniel Dunbar
a830cb14f3 Add Binary flag to raw_fd_ostream constructor.
Document raw_fd_ostream's treatment of "-".

llvm-svn: 59219
2008-11-13 05:01:07 +00:00
Chris Lattner
3fed68158c fix PR2953, an off-by-one error handling formatted i/o.
Thanks to Török Edwin for the awesome reduced testcase.

llvm-svn: 58199
2008-10-26 19:20:47 +00:00
Ted Kremenek
b04b85f615 Added raw_fd_ostream::close().
llvm-svn: 58052
2008-10-23 23:49:09 +00:00
Daniel Dunbar
aa7a7ae8d5 Clear raw_fd_ostream error string on success and explain behavior in
documentation.

Add C++ header marker.

llvm-svn: 57923
2008-10-21 19:53:10 +00:00
Cedric Venet
d1b22a76d2 Updating VC++ project.
Adding one include file and correct one declaration from class to struct in order to make llvm compile on VC2005.

llvm-svn: 55279
2008-08-24 11:56:40 +00:00
Chris Lattner
3ad9fe55e5 Add raw_stream adaptors that write into an std::string and SmallVector/SmallString.
llvm-svn: 55265
2008-08-23 22:43:04 +00:00
Chris Lattner
fe3155fc62 Switch the asmprinter (.ll) and all the stuff it requires over to
use raw_ostream instead of std::ostream.  Among other goodness,
this speeds up llvm-dis of kc++ with a release build from 0.85s
to 0.49s (88% faster).

Other interesting changes:
 1) This makes Value::print be non-virtual.
 2) AP[S]Int and ConstantRange can no longer print to ostream directly, 
    use raw_ostream instead.
 3) This fixes a bug in raw_os_ostream where it didn't flush itself 
    when destroyed.
 4) This adds a new SDNode::print method, instead of only allowing "dump".


A lot of APIs have both std::ostream and raw_ostream versions, it would
be useful to go through and systematically anihilate the std::ostream 
versions.

This passes dejagnu, but there may be minor fallout, plz let me know if
so and I'll fix it.

llvm-svn: 55263
2008-08-23 22:23:09 +00:00
Chris Lattner
4623abf761 add #include
llvm-svn: 55252
2008-08-23 20:34:06 +00:00
Chris Lattner
b7914ec04e add a simple mechanism for formatted output. This gives raw_ostream's
all the power and risk of fprintf format strings.  Use them like this:

  OS << format("%10.4f", 42.0) << "\n" << format("%x", 42) << '\n';

llvm-svn: 55246
2008-08-23 19:23:10 +00:00
Chris Lattner
39ea1a575a improve support for systems that need unistd.h to get STDOUT_FILENO.
Patch contributed by Bjorn Reese!

llvm-svn: 55179
2008-08-22 15:45:00 +00:00
Owen Anderson
0b0215d531 Fix write() when the string being written is larger than the buffer. This broke various ObjC testcases
with very long symbol names.

llvm-svn: 55148
2008-08-21 22:39:33 +00:00
Owen Anderson
5a542e7eda Move non-trivial methods out of line to avoid code-size bloat.
llvm-svn: 55138
2008-08-21 20:58:52 +00:00