MLIR  19.0.0git
ToolUtilities.h
Go to the documentation of this file.
1 //===- ToolUtilities.h - MLIR Tool Utilities --------------------*- C++ -*-===//
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 file declares common utilities for implementing MLIR tools.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_SUPPORT_TOOLUTILITIES_H
14 #define MLIR_SUPPORT_TOOLUTILITIES_H
15 
16 #include "mlir/Support/LLVM.h"
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/ADT/StringRef.h"
19 
20 #include <memory>
21 
22 namespace llvm {
23 class MemoryBuffer;
24 } // namespace llvm
25 
26 namespace mlir {
27 struct LogicalResult;
28 
30  std::unique_ptr<llvm::MemoryBuffer> chunkBuffer, raw_ostream &os)>;
31 
32 extern inline const char *const kDefaultSplitMarker = "// -----";
33 
34 /// Splits the specified buffer on a marker (`// -----` by default), processes
35 /// each chunk independently according to the normal `processChunkBuffer` logic,
36 /// and writes all results to `os`.
37 ///
38 /// This is used to allow a large number of small independent tests to be put
39 /// into a single file. The input split marker is configurable. If it is empty,
40 /// merging is disabled, which allows for merging split and non-split code
41 /// paths. Output split markers (`//-----` by default) followed by a new line
42 /// character, respectively, are placed between each of the processed output
43 /// chunks. (The new line character is inserted even if the split marker is
44 /// empty.)
46 splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer> originalBuffer,
47  ChunkBufferHandler processChunkBuffer, raw_ostream &os,
48  llvm::StringRef inputSplitMarker = kDefaultSplitMarker,
49  llvm::StringRef outputSplitMarker = "");
50 } // namespace mlir
51 
52 #endif // MLIR_SUPPORT_TOOLUTILITIES_H
Include the generated interface declarations.
Definition: CallGraph.h:229
Include the generated interface declarations.
const char *const kDefaultSplitMarker
LogicalResult splitAndProcessBuffer(std::unique_ptr< llvm::MemoryBuffer > originalBuffer, ChunkBufferHandler processChunkBuffer, raw_ostream &os, llvm::StringRef inputSplitMarker=kDefaultSplitMarker, llvm::StringRef outputSplitMarker="")
Splits the specified buffer on a marker (// ----- by default), processes each chunk independently acc...
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26