21cc1700652135be811466906383eda7e26a76d4
[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     unsupported_version,
31     too_large,
32     truncated,
33     malformed,
34     unknown_function
35   };
36   ErrorType V;
37
38   instrprof_error(ErrorType V) : V(V) {}
39   operator ErrorType() const { return V; }
40 };
41
42 inline error_code make_error_code(instrprof_error E) {
43   return error_code(static_cast<int>(E), instrprof_category());
44 }
45
46 template <> struct is_error_code_enum<instrprof_error> : std::true_type {};
47 template <> struct is_error_code_enum<instrprof_error::ErrorType>
48   : std::true_type {};
49
50 } // end namespace llvm
51
52 #endif // LLVM_PROFILEDATA_INSTRPROF_H__