aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Support/Error.cpp
blob: da4299f0af24890f53768a96e5e1e0b25c35b582 (plain)
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
// SPDX-License-Identifier: GPL-3.0-or-later

#include "rcc/Support/Error.h"

namespace rcc {

std::string_view getErrorCodeName(ErrorCode Code) noexcept {
  switch (Code) {
  case ErrorCode::InvalidArgument:
    return "invalid argument";
  case ErrorCode::ParseError:
    return "parse error";
  case ErrorCode::VerificationError:
    return "verification error";
  case ErrorCode::Unsupported:
    return "unsupported";
  case ErrorCode::RegisterAllocationFailed:
    return "register allocation failed";
  case ErrorCode::FrameLayoutFailed:
    return "frame layout failed";
  case ErrorCode::SchedulingFailed:
    return "scheduling failed";
  case ErrorCode::BranchRelaxationFailed:
    return "branch relaxation failed";
  case ErrorCode::PseudoExpansionFailed:
    return "pseudo expansion failed";
  case ErrorCode::FinalEncodabilityFailed:
    return "final encodability failed";
  case ErrorCode::CFGOptimizationFailed:
    return "CFG optimization failed";
  case ErrorCode::AssemblyLoweringFailed:
    return "assembly lowering failed";
  case ErrorCode::InstructionEncodingFailed:
    return "instruction encoding failed";
  case ErrorCode::FixupApplicationFailed:
    return "fixup application failed";
  case ErrorCode::RelocationFailed:
    return "relocation failed";
  case ErrorCode::ObjectWritingFailed:
    return "object writing failed";
  case ErrorCode::IoError:
    return "I/O error";
  case ErrorCode::InternalError:
    return "internal error";
  }

  return "unknown error";
}

Error::Error(ErrorCode Code, std::string Message) : Code(Code), Message(std::move(Message)) {}

} // namespace rcc