llvm.org GIT mirror llvm / 95db93c
Revert r77397, it causes significant regressions in llc performance. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77425 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
2 changed file(s) with 13 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
4848 ///
4949 bool DeleteStream;
5050
51 /// ColumnFlushed - The current output column of the data that's
52 /// been flushed. The column scheme is zero-based.
51 /// Column - The current output column of the stream. The column
52 /// scheme is zero-based.
5353 ///
54 unsigned ColumnFlushed;
54 unsigned Column;
5555
5656 virtual void write_impl(const char *Ptr, size_t Size) {
57 ComputeColumn(ColumnFlushed);
57 ComputeColumn(Ptr, Size);
5858 TheStream->write(Ptr, Size);
5959 }
6060
6666 return TheStream->tell() - TheStream->GetNumBytesInBuffer();
6767 }
6868
69 /// ComputeColumn - Examine the current buffer and figure out
70 /// which column we're in.
69 /// ComputeColumn - Examine the current output and figure out
70 /// which column we end up in after output.
7171 ///
72 void ComputeColumn(unsigned &Column);
72 void ComputeColumn(const char *Ptr, size_t Size);
7373
7474 public:
7575 /// formatted_raw_ostream - Open the specified file for
8383 /// underneath it.
8484 ///
8585 formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
86 : raw_ostream(), TheStream(0), DeleteStream(false), ColumnFlushed(0) {
86 : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {
8787 setStream(Stream, Delete);
8888 }
8989 explicit formatted_raw_ostream()
90 : raw_ostream(), TheStream(0), DeleteStream(false), ColumnFlushed(0) {}
90 : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
9191
9292 ~formatted_raw_ostream() {
9393 if (DeleteStream)
1818 /// ComputeColumn - Examine the current output and figure out which
1919 /// column we end up in after output.
2020 ///
21 void formatted_raw_ostream::ComputeColumn(unsigned &Column) {
21 void formatted_raw_ostream::ComputeColumn(const char *Ptr, size_t Size) {
2222 // Keep track of the current column by scanning the string for
2323 // special characters
2424
25 for (const char *Ptr = begin(); Ptr != end(); ++Ptr) {
25 for (const char *epos = Ptr + Size; Ptr != epos; ++Ptr) {
2626 ++Column;
2727 if (*Ptr == '\n' || *Ptr == '\r')
2828 Column = 0;
3737 /// \param MinPad - The minimum space to give after the most recent
3838 /// I/O, even if the current column + minpad > newcol.
3939 ///
40 void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) {
41 // Start out from the last flush position.
42 unsigned Column = ColumnFlushed;
43
44 // Now figure out what's in the buffer and add it to the column
45 // count.
46 ComputeColumn(Column);
40 void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) {
41 flush();
4742
4843 // Output spaces until we reach the desired column.
4944 unsigned num = NewCol - Column;