9#ifndef LLVM_SUPPORT_CHRONO_H
10#define LLVM_SUPPORT_CHRONO_H
33template <
typename D = std::chrono::nanoseconds>
34using TimePoint = std::chrono::time_point<std::chrono::system_clock, D>;
38 using namespace std::chrono;
39 return system_clock::to_time_t(
40 time_point_cast<system_clock::time_point::duration>(TP));
46 using namespace std::chrono;
47 return time_point_cast<seconds>(system_clock::from_time_t(
T));
53 using namespace std::chrono;
54 return time_point_cast<nanoseconds>(system_clock::from_time_t(
T))
60raw_ostream &
operator<<(raw_ostream &
OS, sys::TimePoint<> TP);
77template <
typename Period>
struct unit {
static const char value[]; };
80template <>
struct unit<
std::ratio<3600>> {
static const char value[]; };
81template <>
struct unit<
std::ratio<60>> {
static const char value[]; };
82template <>
struct unit<
std::ratio<1>> {
static const char value[]; };
112template <
typename Rep,
typename Period>
115 typedef std::chrono::duration<Rep, Period> Dur;
116 typedef std::conditional_t<std::chrono::treat_as_floating_point<Rep>::value,
120 template <
typename AsPeriod>
static InternalRep getAs(
const Dur &
D) {
121 using namespace std::chrono;
122 return duration_cast<duration<InternalRep, AsPeriod>>(
D).
count();
125 static std::pair<InternalRep, StringRef> consumeUnit(
StringRef &Style,
127 using namespace std::chrono;
128 if (Style.consume_front(
"ns"))
129 return {getAs<std::nano>(
D),
"ns"};
130 if (Style.consume_front(
"us"))
131 return {getAs<std::micro>(
D),
"us"};
132 if (Style.consume_front(
"ms"))
133 return {getAs<std::milli>(
D),
"ms"};
134 if (Style.consume_front(
"s"))
135 return {getAs<std::ratio<1>>(
D),
"s"};
136 if (Style.consume_front(
"m"))
137 return {getAs<std::ratio<60>>(
D),
"m"};
138 if (Style.consume_front(
"h"))
139 return {getAs<std::ratio<3600>>(
D),
"h"};
143 static bool consumeShowUnit(
StringRef &Style) {
146 if (Style.consume_front(
"-"))
148 if (Style.consume_front(
"+"))
150 assert(0 &&
"Unrecognised duration format");
158 std::tie(
count, unit) = consumeUnit(Style,
D);
159 bool show_unit = consumeShowUnit(Style);
165 Stream <<
" " << unit;
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
This class implements an extremely fast bulk output stream that can only output to a stream.
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
TimePoint< std::chrono::seconds > toTimePoint(std::time_t T)
Convert a std::time_t to a TimePoint.
std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
This is an optimization pass for GlobalISel generic memory operations.
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
static const char value[]