LLVM  14.0.0git
circular_raw_ostream.cpp
Go to the documentation of this file.
1 //===- circular_raw_ostream.cpp - Implement circular_raw_ostream ----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This implements support for circular buffered streams.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include <algorithm>
15 using namespace llvm;
16 
17 void circular_raw_ostream::write_impl(const char *Ptr, size_t Size) {
18  if (BufferSize == 0) {
19  TheStream->write(Ptr, Size);
20  return;
21  }
22 
23  // Write into the buffer, wrapping if necessary.
24  while (Size != 0) {
25  unsigned Bytes =
26  std::min(unsigned(Size), unsigned(BufferSize - (Cur - BufferArray)));
27  memcpy(Cur, Ptr, Bytes);
28  Size -= Bytes;
29  Cur += Bytes;
30  if (Cur == BufferArray + BufferSize) {
31  // Reset the output pointer to the start of the buffer.
32  Cur = BufferArray;
33  Filled = true;
34  }
35  }
36 }
37 
39  if (BufferSize != 0) {
40  // Write out the buffer
41  TheStream->write(Banner, std::strlen(Banner));
42  flushBuffer();
43  }
44 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::raw_ostream::write
raw_ostream & write(unsigned char C)
Definition: raw_ostream.cpp:220
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::circular_raw_ostream::flushBufferWithBanner
void flushBufferWithBanner()
flushBufferWithBanner - Force output of the buffer along with a small header.
Definition: circular_raw_ostream.cpp:38
circular_raw_ostream.h