10 #ifndef LLVM_SUPPORT_CHRONO_H 11 #define LLVM_SUPPORT_CHRONO_H 33 template <
typename D = std::chrono::nanoseconds>
34 using 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));
52 raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP);
93 template <
typename Period>
struct unit {
static const char value[]; };
96 template <>
struct unit<
std::ratio<3600>> {
static const char value[]; };
97 template <>
struct unit<
std::ratio<60>> {
static const char value[]; };
98 template <>
struct unit<
std::ratio<1>> {
static const char value[]; };
99 template <>
struct unit<
std::milli> {
static const char value[]; };
100 template <>
struct unit<
std::micro> {
static const char value[]; };
101 template <>
struct unit<
std::nano> {
static const char value[]; };
104 template <
typename Rep,
typename Period>
107 typedef std::chrono::duration<Rep, Period> Dur;
108 typedef typename std::conditional<
109 std::chrono::treat_as_floating_point<Rep>::value, double, intmax_t>
::type 112 template <
typename AsPeriod>
static InternalRep getAs(
const Dur &
D) {
113 using namespace std::chrono;
114 return duration_cast<duration<InternalRep, AsPeriod>>(
D).
count();
117 static std::pair<InternalRep, StringRef> consumeUnit(
StringRef &
Style,
119 using namespace std::chrono;
121 return {getAs<std::nano>(
D),
"ns"};
123 return {getAs<std::micro>(
D),
"us"};
125 return {getAs<std::milli>(
D),
"ms"};
127 return {getAs<std::ratio<1>>(
D),
"s"};
129 return {getAs<std::ratio<60>>(
D),
"m"};
131 return {getAs<std::ratio<3600>>(
D),
"h"};
135 static bool consumeShowUnit(
StringRef &Style) {
142 assert(0 &&
"Unrecognised duration format");
150 std::tie(count, unit) = consumeUnit(Style, D);
151 bool show_unit = consumeShowUnit(Style);
157 Stream <<
" " << unit;
164 #endif // LLVM_SUPPORT_CHRONO_H LLVM_ATTRIBUTE_ALWAYS_INLINE std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
Compute iterated dominance frontiers using a linear time algorithm.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
LLVM_ATTRIBUTE_ALWAYS_INLINE TimePoint< std::chrono::seconds > toTimePoint(std::time_t T)
Convert a std::time_t to a TimePoint.
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.