LLVM
15.0.0git
include
llvm
Remarks
HotnessThresholdParser.h
Go to the documentation of this file.
1
//===- HotnessThresholdParser.h - Parser for hotness threshold --*- 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
/// \file
10
/// This file implements a simple parser to decode commandline option for
11
/// remarks hotness threshold that supports both int and a special 'auto' value.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_REMARKS_HOTNESSTHRESHOLDPARSER_H
16
#define LLVM_REMARKS_HOTNESSTHRESHOLDPARSER_H
17
18
#include "
llvm/ADT/Optional.h
"
19
#include "
llvm/Support/CommandLine.h
"
20
21
namespace
llvm
{
22
namespace
remarks
{
23
24
// Parse remarks hotness threshold argument value.
25
// Valid option values are
26
// 1. integer: manually specified threshold; or
27
// 2. string 'auto': automatically get threshold from profile summary.
28
//
29
// Return None Optional if 'auto' is specified, indicating the value will
30
// be filled later during PSI.
31
inline
Expected<Optional<uint64_t>
>
parseHotnessThresholdOption
(
StringRef
Arg
) {
32
if
(
Arg
==
"auto"
)
33
return
None
;
34
35
int64_t Val;
36
if
(
Arg
.getAsInteger(10, Val))
37
return
createStringError
(
llvm::inconvertibleErrorCode
(),
38
"Not an integer: %s"
,
Arg
.data());
39
40
// Negative integer effectively means no threshold
41
return
Val < 0 ? 0 : Val;
42
}
43
44
// A simple CL parser for '*-remarks-hotness-threshold='
45
class
HotnessThresholdParser
:
public
cl::parser
<Optional<uint64_t>> {
46
public
:
47
HotnessThresholdParser
(
cl::Option
&
O
) :
cl
::
parser
<
Optional
<
uint64_t
>>(
O
) {}
48
49
bool
parse
(
cl::Option
&
O
,
StringRef
ArgName,
StringRef
Arg
,
50
Optional<uint64_t>
&V) {
51
auto
ResultOrErr =
parseHotnessThresholdOption
(
Arg
);
52
if
(!ResultOrErr)
53
return
O
.error(
"Invalid argument '"
+
Arg
+
54
"', only integer or 'auto' is supported."
);
55
56
V = *ResultOrErr;
57
return
false
;
58
}
59
};
60
61
}
// namespace remarks
62
}
// namespace llvm
63
#endif // LLVM_REMARKS_HOTNESSTHRESHOLDPARSER_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:17
Optional.h
llvm::cl::parser< Optional< uint64_t > >::parser
parser(Option &O)
Definition:
CommandLine.h:809
llvm::Optional
Definition:
APInt.h:33
llvm::Expected
Tagged union holding either a T or a Error.
Definition:
APFloat.h:41
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition:
AMDGPULibCalls.cpp:186
CommandLine.h
llvm::remarks::HotnessThresholdParser::HotnessThresholdParser
HotnessThresholdParser(cl::Option &O)
Definition:
HotnessThresholdParser.h:47
remarks
annotation remarks
Definition:
AnnotationRemarks.cpp:114
llvm::cl::parser
Definition:
CommandLine.h:797
llvm::None
const NoneType None
Definition:
None.h:24
llvm::RISCVFenceField::O
@ O
Definition:
RISCVBaseInfo.h:239
llvm::cl::Option
Definition:
CommandLine.h:242
uint64_t
llvm::remarks::HotnessThresholdParser
Definition:
HotnessThresholdParser.h:45
llvm::remarks::parseHotnessThresholdOption
Expected< Optional< uint64_t > > parseHotnessThresholdOption(StringRef Arg)
Definition:
HotnessThresholdParser.h:31
llvm::remarks::HotnessThresholdParser::parse
bool parse(cl::Option &O, StringRef ArgName, StringRef Arg, Optional< uint64_t > &V)
Definition:
HotnessThresholdParser.h:49
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:58
cl
http eax xorl edx cl sete al setne dl sall cl
Definition:
README.txt:25
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition:
Error.h:1239
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition:
Error.cpp:77
Generated on Thu May 19 2022 02:52:01 for LLVM by
1.8.17