File: Status.cpp

package info (click to toggle)
intel-graphics-compiler2 2.20.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 107,552 kB
  • sloc: cpp: 807,012; lisp: 287,936; ansic: 16,397; python: 4,010; yacc: 2,588; lex: 1,666; pascal: 313; sh: 186; makefile: 37
file content (151 lines) | stat: -rw-r--r-- 4,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*========================== begin_copyright_notice ============================

Copyright (C) 2020-2024 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

#include "vc/Support/Status.h"
#include "vc/Support/StatusCode.h"
#include "vc/Support/StatusTraits.h"
#include <string>
#include <system_error>
#include "Probe/Assertion.h"

namespace {
class vc_error_category : public std::error_category {
public:
  const char *name() const noexcept override;
  std::string message(int condition) const override;
};
} // namespace

const char *vc_error_category::name() const noexcept {
  return "vector compiler";
}

std::string vc_error_category::message(int condition) const {
  using namespace vc;

  switch (static_cast<errc>(condition)) {
  case errc::dynamic_load_fail:
    return std::string(ErrorTraits<errc::dynamic_load_fail>::getMessage());
  case errc::symbol_not_found:
    return std::string(ErrorTraits<errc::symbol_not_found>::getMessage());
  case errc::bad_spirv:
    return std::string(ErrorTraits<errc::bad_spirv>::getMessage());
  case errc::bad_bitcode:
    return std::string(ErrorTraits<errc::bad_bitcode>::getMessage());
  case errc::invalid_module:
    return std::string(ErrorTraits<errc::invalid_module>::getMessage());
  case errc::target_machine_not_created:
    return std::string(
        ErrorTraits<errc::target_machine_not_created>::getMessage());
  case errc::not_vc_codegen:
    return std::string(ErrorTraits<errc::not_vc_codegen>::getMessage());
  case errc::invalid_api_option:
    return std::string(ErrorTraits<errc::invalid_api_option>::getMessage());
  case errc::invalid_internal_option:
    return std::string(
        ErrorTraits<errc::invalid_internal_option>::getMessage());
  case errc::bif_load_fail:
    return std::string(ErrorTraits<errc::bif_load_fail>::getMessage());
  case errc::output_not_created:
    return std::string(ErrorTraits<errc::output_not_created>::getMessage());
  }
  IGC_ASSERT_UNREACHABLE(); // Unknown error code
}

static const vc_error_category vc_err_category;

namespace vc {

const std::error_category &err_category() noexcept { return vc_err_category; }

// DynLoadError {{
char DynLoadError::ID = 0;

void DynLoadError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::dynamic_load_fail>::getMessage() << ": " << Message;
}
// }}

// SymbolLookupError {{
char SymbolLookupError::ID = 0;

void SymbolLookupError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::symbol_not_found>::getMessage() << ": symbol '"
     << Symbol << "' was not found in '" << Library << "'";
}
// }}

// BadSpirvError {{
char BadSpirvError::ID = 0;

void BadSpirvError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::bad_spirv>::getMessage() << ": " << Message;
}
// }}

// BadBitcodeError {{
char BadBitcodeError::ID = 0;

void BadBitcodeError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::bad_bitcode>::getMessage() << ": " << Message;
}
// }}

// InvalidModuleError {{
char InvalidModuleError::ID = 0;

void InvalidModuleError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::invalid_module>::getMessage();
}
// }}

// BifLoadingError {{
char BifLoadingError::ID = 0;

void BifLoadingError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::bif_load_fail>::getMessage();
}
// }}

// TargetMachineError {{
char TargetMachineError::ID = 0;

void TargetMachineError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::target_machine_not_created>::getMessage();
}
// }}

// NotVCError {{
char NotVCError::ID = 0;

void NotVCError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::not_vc_codegen>::getMessage();
}
// }}

// OptionErrorCommon {{
char OptionError::ID = 0;

void OptionError::log(llvm::raw_ostream &OS) const {
  if (IsInternal)
    OS << ErrorTraits<errc::invalid_internal_option>::getMessage();
  else
    OS << ErrorTraits<errc::invalid_api_option>::getMessage();
  OS << ": " << BadOption;
}
// }}

// OutputBinaryCreationError {{
char OutputBinaryCreationError::ID = 0;
void OutputBinaryCreationError::log(llvm::raw_ostream &OS) const {
  OS << ErrorTraits<errc::output_not_created>::getMessage();
  OS << ": " << Message;
}
// }}

} // namespace vc