MLIR
24.0.0git
include
mlir
Remark
RemarkStreamer.h
Go to the documentation of this file.
1
//===- RemarkStreamer.h - MLIR Optimization Remark ---------------*-===//
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 defines LLVMRemarkStreamer plugging class that uses LLVM's
10
// streamer.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "
mlir/IR/Remarks.h
"
15
16
#include "llvm/Remarks/RemarkStreamer.h"
17
#include "llvm/Support/Error.h"
18
#include "llvm/Support/ToolOutputFile.h"
19
20
namespace
mlir::remark::detail
{
21
22
/// Concrete streamer that writes LLVM optimization remarks to a file
23
/// (YAML or Bitstream). Lives outside core.
24
class
LLVMRemarkStreamer final :
public
MLIRRemarkStreamerBase
{
25
public
:
26
/// Open \p path and create the serializer for \p fmt.
27
static
llvm::Expected<std::unique_ptr<MLIRRemarkStreamerBase>
>
28
createToFile
(llvm::StringRef path, llvm::remarks::Format fmt);
29
30
void
streamOptimizationRemark
(
const
Remark
&
remark
)
override
;
31
void
finalize
()
override
;
32
~LLVMRemarkStreamer
()
override
;
33
34
private
:
35
LLVMRemarkStreamer() =
default
;
36
37
std::unique_ptr<class llvm::ToolOutputFile> file;
38
// RemarkStreamer must be destructed before file is destroyed!
39
std::unique_ptr<class llvm::remarks::RemarkStreamer> remarkStreamer;
40
};
41
}
// namespace mlir::remark::detail
42
43
namespace
mlir::remark
{
44
/// Enable optimization remarks to a file with the given path and format.
45
/// The remark categories are used to filter the remarks that are emitted.
46
/// If the printAsEmitRemarks flag is set, remarks will also be printed using
47
/// mlir::emitRemarks. If the file cannot be opened or the serializer cannot be
48
/// created, an error is emitted on the context.
49
LogicalResult
enableOptimizationRemarksWithLLVMStreamer
(
50
MLIRContext
&ctx, StringRef filePath, llvm::remarks::Format fmt,
51
std::unique_ptr<detail::RemarkEmittingPolicyBase> remarkEmittingPolicy,
52
const
RemarkCategories
&cat,
bool
printAsEmitRemarks =
false
);
53
54
}
// namespace mlir::remark
llvm::Expected
Definition
ExecutionEngine.h:29
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition
MLIRContext.h:64
mlir::remark::detail::LLVMRemarkStreamer::streamOptimizationRemark
void streamOptimizationRemark(const Remark &remark) override
Stream an optimization remark to the underlying remark streamer.
Definition
RemarkStreamer.cpp:35
mlir::remark::detail::LLVMRemarkStreamer::createToFile
static llvm::Expected< std::unique_ptr< MLIRRemarkStreamerBase > > createToFile(llvm::StringRef path, llvm::remarks::Format fmt)
Open path and create the serializer for fmt.
Definition
RemarkStreamer.cpp:15
mlir::remark::detail::LLVMRemarkStreamer::~LLVMRemarkStreamer
~LLVMRemarkStreamer() override
Definition
RemarkStreamer.cpp:45
mlir::remark::detail::LLVMRemarkStreamer::finalize
void finalize() override
Definition
RemarkStreamer.cpp:50
mlir::remark::detail::MLIRRemarkStreamerBase
Base class for MLIR remark streamers that is used to stream optimization remarks to the underlying re...
Definition
Remarks.h:452
mlir::remark::detail::Remark
Definition
Remarks.h:148
Remarks.h
mlir::remark::detail
Definition
MLIRContext.h:38
mlir::remark
Definition
MLIRContext.h:38
mlir::remark::enableOptimizationRemarksWithLLVMStreamer
LogicalResult enableOptimizationRemarksWithLLVMStreamer(MLIRContext &ctx, StringRef filePath, llvm::remarks::Format fmt, std::unique_ptr< detail::RemarkEmittingPolicyBase > remarkEmittingPolicy, const RemarkCategories &cat, bool printAsEmitRemarks=false)
Enable optimization remarks to a file with the given path and format.
Definition
RemarkStreamer.cpp:58
mlir::remark::RemarkCategories
Define an the set of categories to accept.
Definition
Remarks.h:64
Generated on
for MLIR by
1.14.0