mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 13:19:18 -08:00
Create a src and include directory for libomptarget and libompaccsupport following the same structure as liboffload. Move headers from the base include directory to the directories that use them. Just a few utility headers remain in the share base include/Shared directory. Of those, Environment.h and RPCOpcodes.h seem questionable but seem in used in both the plugins and libomptarget (which seems to point to further refactoring needed). Changes in source files are basically due to directory changes, leftover headers, and in a few cases, changing headers that were only used transitively for their own dependence. Headers in libompaccsupport seem like they could be further refined as they contain both shared and things only neeeded by libomptarget, but that's a larger refactoring to be done later. Mechanical work done by Claude.
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
//===- OmpAccError.h - Error class for the OpenMP offload RTL -------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef OMPTARGET_OMPACCERROR_H
|
|
#define OMPTARGET_OMPACCERROR_H
|
|
|
|
#include "llvm/Support/Error.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
namespace llvm::omp::target::error {
|
|
|
|
enum class ErrorCode {
|
|
Unknown,
|
|
InvalidBinary,
|
|
InvalidValue,
|
|
BackendFailure,
|
|
};
|
|
|
|
} // namespace llvm::omp::target::error
|
|
|
|
namespace std {
|
|
template <>
|
|
struct is_error_code_enum<llvm::omp::target::error::ErrorCode>
|
|
: std::true_type {};
|
|
} // namespace std
|
|
|
|
namespace llvm::omp::target::error {
|
|
|
|
const std::error_category &OmpAccErrCategory();
|
|
|
|
inline std::error_code make_error_code(ErrorCode E) {
|
|
return std::error_code(static_cast<int>(E), OmpAccErrCategory());
|
|
}
|
|
|
|
/// Error class used by the OpenMP offload runtime (libomptarget).
|
|
class OmpAccError : public llvm::ErrorInfo<OmpAccError, llvm::StringError> {
|
|
public:
|
|
using ErrorInfo<OmpAccError, StringError>::ErrorInfo;
|
|
|
|
OmpAccError(const llvm::Twine &S) : ErrorInfo(S, ErrorCode::Unknown) {}
|
|
|
|
static char ID;
|
|
};
|
|
|
|
/// Create an offload runtime error.
|
|
template <typename... ArgsTy>
|
|
[[maybe_unused]] static llvm::Error
|
|
createError(ErrorCode Code, const char *ErrFmt, ArgsTy... Args) {
|
|
std::string Buffer;
|
|
llvm::raw_string_ostream(Buffer) << llvm::format(ErrFmt, Args...);
|
|
return llvm::make_error<OmpAccError>(Code, Buffer);
|
|
}
|
|
|
|
inline llvm::Error createError(ErrorCode Code, const char *S) {
|
|
return llvm::make_error<OmpAccError>(Code, S);
|
|
}
|
|
|
|
} // namespace llvm::omp::target::error
|
|
|
|
#endif
|