[clang] [llvm] [Clang][SYCL][SPIRV] Accept IGCA targets and define macros for SYCL during device compilation (PR #227877)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 20:00:34 PST 2026


================
@@ -0,0 +1,59 @@
+//===--- OffloadTarget.h - Declare generic offload target -------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares a generic "offload" TargetInfo object.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_OFFLOADTARGET_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_OFFLOADTARGET_H
+
+#include "clang/Basic/OffloadArch.h"
+#include "clang/Basic/TargetInfo.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/TargetParser/Triple.h"
+
+namespace clang {
+namespace targets {
+
+/// Base TargetInfo class for offload device targets. Targets inheriting this
+/// class obtain an offload architecture from the `-target-cpu` option, which
+/// is then accessible via getOffloadArch().
+class LLVM_LIBRARY_VISIBILITY OffloadTargetInfo : public TargetInfo {
+  OffloadArch SelectedOffloadArch = OffloadArch::getUnused();
+
+protected:
+  /// \return true if \p Arch is an offload device architecture this target
+  /// should accept.
+  virtual bool isSupportedOffloadArch(OffloadArch Arch) const { return false; }
----------------
tahonermann wrote:

For consistency with `isValidCPUName()` and `isValidTuneCPUName()`, I suggest renaming `isSupportedOffloadArch()` to `isValidOffloadArch()`.
```suggestion
  virtual bool isValidOffloadArch(OffloadArch Arch) const { return false; }
```

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


More information about the cfe-commits mailing list