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));
53 using namespace std::chrono;
54 return time_point_cast<nanoseconds>(system_clock::from_time_t(T))
60 raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP);
101 template <
typename Period>
struct unit {
static const char value[]; };
104 template <>
struct unit<
std::ratio<3600>> {
static const char value[]; };
105 template <>
struct unit<
std::ratio<60>> {
static const char value[]; };
106 template <>
struct unit<
std::ratio<1>> {
static const char value[]; };
107 template <>
struct unit<
std::milli> {
static const char value[]; };
108 template <>
struct unit<
std::micro> {
static const char value[]; };
109 template <>
struct unit<
std::nano> {
static const char value[]; };
112 template <
typename Rep,
typename Period>
115 typedef std::chrono::duration<Rep, Period> Dur;
116 typedef typename std::conditional<
117 std::chrono::treat_as_floating_point<Rep>::value, double, intmax_t>
::type 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;
129 return {getAs<std::nano>(
D),
"ns"};
131 return {getAs<std::micro>(
D),
"us"};
133 return {getAs<std::milli>(
D),
"ms"};
135 return {getAs<std::ratio<1>>(
D),
"s"};
137 return {getAs<std::ratio<60>>(
D),
"m"};
139 return {getAs<std::ratio<3600>>(
D),
"h"};
143 static bool consumeShowUnit(
StringRef &Style) {
150 assert(0 &&
"Unrecognised duration format");
158 std::tie(count, unit) = consumeUnit(Style, D);
159 bool show_unit = consumeShowUnit(Style);
165 Stream <<
" " << unit;
172 #endif // LLVM_SUPPORT_CHRONO_H LLVM_ATTRIBUTE_ALWAYS_INLINE std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
This class represents lattice values for constants.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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.
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
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.