LLVM 22.0.0git
VirtualOutputConfig.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/// \file
10/// This file contains the declarations of the OutputConfig class.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_SUPPORT_VIRTUALOUTPUTCONFIG_H
15#define LLVM_SUPPORT_VIRTUALOUTPUTCONFIG_H
16
18
19namespace llvm {
20
21class raw_ostream;
22
23namespace sys::fs {
24enum OpenFlags : unsigned;
25} // end namespace sys::fs
26
27namespace vfs {
28
29namespace detail {
30/// Unused and empty base class to allow OutputConfig constructor to be
31/// constexpr, with commas before every field's initializer.
33} // namespace detail
34
35/// Full configuration for an output for use by the \a OutputBackend. Each
36/// configuration flag is either \c true or \c false.
38public:
39 LLVM_ABI_FOR_TEST void print(raw_ostream &OS) const;
40 void dump() const;
41
42#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) \
43 constexpr bool get##NAME() const { return NAME; } \
44 constexpr bool getNo##NAME() const { return !NAME; } \
45 constexpr OutputConfig &set##NAME(bool Value) { \
46 NAME = Value; \
47 return *this; \
48 } \
49 constexpr OutputConfig &set##NAME() { return set##NAME(true); } \
50 constexpr OutputConfig &setNo##NAME() { return set##NAME(false); }
51#include "llvm/Support/VirtualOutputConfig.def"
52
53 constexpr OutputConfig &setBinary() { return setNoText().setNoCRLF(); }
54 constexpr OutputConfig &setTextWithCRLF() { return setText().setCRLF(); }
56 return Value ? setText().setCRLF() : setBinary();
57 }
58 constexpr bool getTextWithCRLF() const { return getText() && getCRLF(); }
59 constexpr bool getBinary() const { return !getText(); }
60
61 /// Updates Text and CRLF flags based on \a sys::fs::OF_Text and \a
62 /// sys::fs::OF_CRLF in \p Flags. Rejects CRLF without Text (calling
63 /// \a setBinary()).
65
66 constexpr OutputConfig()
67 : EmptyBaseClass()
68#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) , NAME(DEFAULT)
69#include "llvm/Support/VirtualOutputConfig.def"
70 {
71 }
72
74#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) \
75 if (NAME != RHS.NAME) \
76 return false;
77#include "llvm/Support/VirtualOutputConfig.def"
78 return true;
79 }
80 bool operator!=(OutputConfig RHS) const { return !operator==(RHS); }
81
82private:
83#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT) bool NAME : 1;
84#include "llvm/Support/VirtualOutputConfig.def"
85};
86
87} // namespace vfs
88
89LLVM_ABI_FOR_TEST raw_ostream &operator<<(raw_ostream &OS,
90 vfs::OutputConfig Config);
91
92} // namespace llvm
93
94#endif // LLVM_SUPPORT_VIRTUALOUTPUTCONFIG_H
@ DEFAULT
Default weight is used in cases when there is no dedicated execution weight set.
#define LLVM_ABI_FOR_TEST
Definition Compiler.h:218
#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT)
Value * RHS
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Full configuration for an output for use by the OutputBackend.
bool operator==(OutputConfig RHS) const
constexpr bool getTextWithCRLF() const
constexpr OutputConfig & setBinary()
LLVM_ABI_FOR_TEST void print(raw_ostream &OS) const
constexpr OutputConfig & setTextWithCRLF(bool Value)
LLVM_ABI_FOR_TEST OutputConfig & setOpenFlags(const sys::fs::OpenFlags &Flags)
Updates Text and CRLF flags based on sys::fs::OF_Text and sys::fs::OF_CRLF in Flags.
constexpr bool getBinary() const
constexpr OutputConfig & setTextWithCRLF()
bool operator!=(OutputConfig RHS) const
Unused and empty base class to allow OutputConfig constructor to be constexpr, with commas before eve...