8457678c4ec6d4c5440898b4aefe2fd33c241392
[oota-llvm.git] / include / llvm / ProfileData / InstrProf.h
1 //=-- InstrProf.h - Instrumented profiling format support ---------*- C++ -*-=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Instrumentation-based profiling data is generated by instrumented
11 // binaries through library functions in compiler-rt, and read by the clang
12 // frontend to feed PGO.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_PROFILEDATA_INSTRPROF_H_
17 #define LLVM_PROFILEDATA_INSTRPROF_H_
18
19 #include "llvm/Support/system_error.h"
20
21 namespace llvm {
22
23 const error_category &instrprof_category();
24
25 struct instrprof_error {
26   enum ErrorType {
27     success = 0,
28     eof,
29     bad_magic,
30     bad_header,
31     unsupported_version,
32     unsupported_hash_type,
33     too_large,
34     truncated,
35     malformed,
36     unknown_function,
37     hash_mismatch,
38     count_mismatch,
39     counter_overflow
40   };
41   ErrorType V;
42
43   instrprof_error(ErrorType V) : V(V) {}
44   operator ErrorType() const { return V; }
45 };
46
47 inline error_code make_error_code(instrprof_error E) {
48   return error_code(static_cast<int>(E), instrprof_category());
49 }
50
51 template <> struct is_error_code_enum<instrprof_error> : std::true_type {};
52 template <> struct is_error_code_enum<instrprof_error::ErrorType>
53   : std::true_type {};
54
55 } // end namespace llvm
56
57 #endif // LLVM_PROFILEDATA_INSTRPROF_H_