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))
103template <
typename Period>
struct unit {
static const char value[]; };
150template <
typename Rep,
typename Period>
153 typedef std::chrono::duration<Rep, Period> Dur;
154 typedef std::conditional_t<std::chrono::treat_as_floating_point<Rep>::value,
158 template <
typename AsPeriod>
static InternalRep getAs(
const Dur &
D) {
159 using namespace std::chrono;
160 return duration_cast<duration<InternalRep, AsPeriod>>(
D).
count();
163 static std::pair<InternalRep, StringRef> consumeUnit(
StringRef &Style,
165 using namespace std::chrono;
166 if (Style.consume_front(
"ns"))
167 return {getAs<std::nano>(
D),
"ns"};
168 if (Style.consume_front(
"us"))
169 return {getAs<std::micro>(
D),
"us"};
170 if (Style.consume_front(
"ms"))
171 return {getAs<std::milli>(
D),
"ms"};
172 if (Style.consume_front(
"s"))
173 return {getAs<std::ratio<1>>(
D),
"s"};
174 if (Style.consume_front(
"m"))
175 return {getAs<std::ratio<60>>(
D),
"m"};
176 if (Style.consume_front(
"h"))
177 return {getAs<std::ratio<3600>>(
D),
"h"};
181 static bool consumeShowUnit(
StringRef &Style) {
184 if (Style.consume_front(
"-"))
186 if (Style.consume_front(
"+"))
188 assert(0 &&
"Unrecognised duration format");
196 std::tie(
count, unit) = consumeUnit(Style,
D);
197 bool show_unit = consumeShowUnit(Style);
203 Stream <<
" " << unit;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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[]