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>;
40template <
typename D = std::chrono::nanoseconds>
41using UtcTime = std::chrono::time_point<UtcClock, D>;
45 using namespace std::chrono;
51 using namespace std::chrono;
52 return system_clock::to_time_t(
53 time_point_cast<system_clock::time_point::duration>(TP));
58 using namespace std::chrono;
59 return system_clock::to_time_t(time_point<system_clock, seconds>(
60 duration_cast<seconds>(TP.time_since_epoch())));
66 using namespace std::chrono;
67 return time_point_cast<seconds>(system_clock::from_time_t(
T));
73 using namespace std::chrono;
74 return time_point_cast<nanoseconds>(system_clock::from_time_t(
T))
80raw_ostream &
operator<<(raw_ostream &
OS, sys::TimePoint<> TP);
103template <
typename Period>
struct unit {
static const char value[]; };
106template <>
struct unit<
std::ratio<3600>> {
static const char value[]; };
138template <
typename Rep,
typename Period>
141 typedef std::chrono::duration<Rep, Period> Dur;
142 typedef std::conditional_t<std::chrono::treat_as_floating_point<Rep>::value,
146 template <
typename AsPeriod>
static InternalRep getAs(
const Dur &
D) {
147 using namespace std::chrono;
148 return duration_cast<duration<InternalRep, AsPeriod>>(
D).
count();
151 static std::pair<InternalRep, StringRef> consumeUnit(
StringRef &Style,
153 using namespace std::chrono;
154 if (Style.consume_front(
"ns"))
155 return {getAs<std::nano>(
D),
"ns"};
156 if (Style.consume_front(
"us"))
157 return {getAs<std::micro>(
D),
"us"};
158 if (Style.consume_front(
"ms"))
159 return {getAs<std::milli>(
D),
"ms"};
160 if (Style.consume_front(
"s"))
161 return {getAs<std::ratio<1>>(
D),
"s"};
162 if (Style.consume_front(
"m"))
163 return {getAs<std::ratio<60>>(
D),
"m"};
164 if (Style.consume_front(
"h"))
165 return {getAs<std::ratio<3600>>(
D),
"h"};
169 static bool consumeShowUnit(
StringRef &Style) {
172 if (Style.consume_front(
"-"))
174 if (Style.consume_front(
"+"))
176 assert(0 &&
"Unrecognised duration format");
184 std::tie(
count, unit) = consumeUnit(Style,
D);
185 bool show_unit = consumeShowUnit(Style);
191 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::chrono::time_point< UtcClock, D > UtcTime
UtcTime< std::chrono::seconds > toUtcTime(std::time_t T)
Convert a std::time_t to a UtcTime.
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)
Implement std::hash so that hash_code can be used in STL containers.
static const char value[]