[llvm] [SYCL] Add platform enumeration and info query using liboffload (PR #166927)

Alexey Bader via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 18:22:33 PST 2025


================
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the definition of the SYCL 2020 exception class interface
+/// (4.13.2.)
+///
+//===----------------------------------------------------------------------===//
+
+// 4.9.2 Exception Class Interface
+#include <sycl/__impl/detail/config.hpp>
+#include <sycl/__impl/exception.hpp>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+
+namespace detail {
+class SYCLCategory : public std::error_category {
+public:
+  const char *name() const noexcept override { return "sycl"; }
+  std::string message(int) const override { return "SYCL Error"; }
+};
+} // namespace detail
+
+// Free functions
+const std::error_category &sycl_category() noexcept {
+  static const detail::SYCLCategory SYCLCategoryObj;
+  return SYCLCategoryObj;
+}
+
+std::error_code make_error_code(sycl::errc Err) noexcept {
+  return std::error_code(static_cast<int>(Err), sycl_category());
+}
+
+// Exception methods implementation
+exception::exception(std::error_code EC, const char *Msg)
+    : MMessage(std::make_shared<std::string>(Msg)), MErrC(EC) {}
+
+exception::~exception() {}
+
+const std::error_code &exception::code() const noexcept { return MErrC; }
+
+const std::error_category &exception::category() const noexcept {
+  return code().category();
+}
+
+const char *exception::what() const noexcept { return MMessage->c_str(); }
+
+bool exception::has_context() const noexcept { /*return (MContext != nullptr);*/
----------------
bader wrote:

```suggestion
bool exception::has_context() const noexcept {
```

https://github.com/llvm/llvm-project/pull/166927


More information about the llvm-commits mailing list