1 //===- RemarkSerializer.cpp -----------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file provides tools for serializing remarks.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Remarks/RemarkSerializer.h"
14 #include "llvm/Remarks/BitstreamRemarkSerializer.h"
15 #include "llvm/Remarks/YAMLRemarkSerializer.h"
18 using namespace llvm::remarks
;
20 Expected
<std::unique_ptr
<RemarkSerializer
>>
21 remarks::createRemarkSerializer(Format RemarksFormat
, SerializerMode Mode
,
23 switch (RemarksFormat
) {
25 return createStringError(std::errc::invalid_argument
,
26 "Unknown remark serializer format.");
28 return std::make_unique
<YAMLRemarkSerializer
>(OS
, Mode
);
29 case Format::YAMLStrTab
:
30 return std::make_unique
<YAMLStrTabRemarkSerializer
>(OS
, Mode
);
31 case Format::Bitstream
:
32 return std::make_unique
<BitstreamRemarkSerializer
>(OS
, Mode
);
34 llvm_unreachable("Unknown remarks::Format enum");
37 Expected
<std::unique_ptr
<RemarkSerializer
>>
38 remarks::createRemarkSerializer(Format RemarksFormat
, SerializerMode Mode
,
39 raw_ostream
&OS
, remarks::StringTable StrTab
) {
40 switch (RemarksFormat
) {
42 return createStringError(std::errc::invalid_argument
,
43 "Unknown remark serializer format.");
45 return std::make_unique
<YAMLRemarkSerializer
>(OS
, Mode
, std::move(StrTab
));
46 case Format::YAMLStrTab
:
47 return std::make_unique
<YAMLStrTabRemarkSerializer
>(OS
, Mode
,
49 case Format::Bitstream
:
50 return std::make_unique
<BitstreamRemarkSerializer
>(OS
, Mode
,
53 llvm_unreachable("Unknown remarks::Format enum");