[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)

Dominik Adamski via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 05:06:54 PST 2023


https://github.com/DominikAdamski updated https://github.com/llvm/llvm-project/pull/73944

>From 60ceda3d1025891f5037f020a2efe35108f62ca3 Mon Sep 17 00:00:00 2001
From: Dominik Adamski <dominik.adamski at amd.com>
Date: Thu, 30 Nov 2023 08:06:12 -0600
Subject: [PATCH 1/2] [NFC][AMDGPU] Move address space enum to LLVM directory

Types of AMDGPU address space were defined in Clang-specific
class. In consequence this enum cannot be reused by other frontends
like Flang.

If we move address space enum to LLVM directory, then we can reuse
it in other frontends like Flang.
---
 clang/lib/Basic/Targets/AMDGPU.cpp            | 80 +++++++++----------
 clang/lib/Basic/Targets/AMDGPU.h              | 17 ++--
 flang/lib/Frontend/FrontendActions.cpp        | 10 +--
 llvm/include/llvm/TargetParser/TargetParser.h |  9 +++
 4 files changed, 56 insertions(+), 60 deletions(-)

diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index 409ae32ab4242..3fe9f9fa9c42d 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -37,50 +37,50 @@ static const char *const DataLayoutStringAMDGCN =
     "-ni:7:8";
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
-    Generic,  // Default
-    Global,   // opencl_global
-    Local,    // opencl_local
-    Constant, // opencl_constant
-    Private,  // opencl_private
-    Generic,  // opencl_generic
-    Global,   // opencl_global_device
-    Global,   // opencl_global_host
-    Global,   // cuda_device
-    Constant, // cuda_constant
-    Local,    // cuda_shared
-    Global,   // sycl_global
-    Global,   // sycl_global_device
-    Global,   // sycl_global_host
-    Local,    // sycl_local
-    Private,  // sycl_private
-    Generic,  // ptr32_sptr
-    Generic,  // ptr32_uptr
-    Generic,  // ptr64
-    Generic,  // hlsl_groupshared
+    llvm::AMDGPU::Generic,  // Default
+    llvm::AMDGPU::Global,   // opencl_global
+    llvm::AMDGPU::Local,    // opencl_local
+    llvm::AMDGPU::Constant, // opencl_constant
+    llvm::AMDGPU::Private,  // opencl_private
+    llvm::AMDGPU::Generic,  // opencl_generic
+    llvm::AMDGPU::Global,   // opencl_global_device
+    llvm::AMDGPU::Global,   // opencl_global_host
+    llvm::AMDGPU::Global,   // cuda_device
+    llvm::AMDGPU::Constant, // cuda_constant
+    llvm::AMDGPU::Local,    // cuda_shared
+    llvm::AMDGPU::Global,   // sycl_global
+    llvm::AMDGPU::Global,   // sycl_global_device
+    llvm::AMDGPU::Global,   // sycl_global_host
+    llvm::AMDGPU::Local,    // sycl_local
+    llvm::AMDGPU::Private,  // sycl_private
+    llvm::AMDGPU::Generic,  // ptr32_sptr
+    llvm::AMDGPU::Generic,  // ptr32_uptr
+    llvm::AMDGPU::Generic,  // ptr64
+    llvm::AMDGPU::Generic,  // hlsl_groupshared
 };
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
-    Private,  // Default
-    Global,   // opencl_global
-    Local,    // opencl_local
-    Constant, // opencl_constant
-    Private,  // opencl_private
-    Generic,  // opencl_generic
-    Global,   // opencl_global_device
-    Global,   // opencl_global_host
-    Global,   // cuda_device
-    Constant, // cuda_constant
-    Local,    // cuda_shared
+    llvm::AMDGPU::Private,  // Default
+    llvm::AMDGPU::Global,   // opencl_global
+    llvm::AMDGPU::Local,    // opencl_local
+    llvm::AMDGPU::Constant, // opencl_constant
+    llvm::AMDGPU::Private,  // opencl_private
+    llvm::AMDGPU::Generic,  // opencl_generic
+    llvm::AMDGPU::Global,   // opencl_global_device
+    llvm::AMDGPU::Global,   // opencl_global_host
+    llvm::AMDGPU::Global,   // cuda_device
+    llvm::AMDGPU::Constant, // cuda_constant
+    llvm::AMDGPU::Local,    // cuda_shared
     // SYCL address space values for this map are dummy
-    Generic, // sycl_global
-    Generic, // sycl_global_device
-    Generic, // sycl_global_host
-    Generic, // sycl_local
-    Generic, // sycl_private
-    Generic, // ptr32_sptr
-    Generic, // ptr32_uptr
-    Generic, // ptr64
-    Generic, // hlsl_groupshared
+    llvm::AMDGPU::Generic, // sycl_global
+    llvm::AMDGPU::Generic, // sycl_global_device
+    llvm::AMDGPU::Generic, // sycl_global_host
+    llvm::AMDGPU::Generic, // sycl_local
+    llvm::AMDGPU::Generic, // sycl_private
+    llvm::AMDGPU::Generic, // ptr32_sptr
+    llvm::AMDGPU::Generic, // ptr32_uptr
+    llvm::AMDGPU::Generic, // ptr64
+    llvm::AMDGPU::Generic, // hlsl_groupshared
 
 };
 } // namespace targets
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 300d9691d8a0f..1e12f9e12af59 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -29,13 +29,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
 
   static const char *const GCCRegNames[];
 
-  enum AddrSpace {
-    Generic = 0,
-    Global = 1,
-    Local = 3,
-    Constant = 4,
-    Private = 5
-  };
   static const LangASMap AMDGPUDefIsGenMap;
   static const LangASMap AMDGPUDefIsPrivMap;
 
@@ -106,7 +99,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
       return 32;
     unsigned TargetAS = getTargetAddressSpace(AS);
 
-    if (TargetAS == Private || TargetAS == Local)
+    if (TargetAS == llvm::AMDGPU::Private || TargetAS == llvm::AMDGPU::Local)
       return 32;
 
     return 64;
@@ -376,7 +369,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
   }
 
   std::optional<LangAS> getConstantAddressSpace() const override {
-    return getLangASFromTargetAS(Constant);
+    return getLangASFromTargetAS(llvm::AMDGPU::Constant);
   }
 
   const llvm::omp::GV &getGridValue() const override {
@@ -392,7 +385,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
 
   /// \returns Target specific vtbl ptr address space.
   unsigned getVtblPtrAddressSpace() const override {
-    return static_cast<unsigned>(Constant);
+    return static_cast<unsigned>(llvm::AMDGPU::Constant);
   }
 
   /// \returns If a target requires an address within a target specific address
@@ -405,9 +398,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
   getDWARFAddressSpace(unsigned AddressSpace) const override {
     const unsigned DWARF_Private = 1;
     const unsigned DWARF_Local = 2;
-    if (AddressSpace == Private) {
+    if (AddressSpace == llvm::AMDGPU::Private) {
       return DWARF_Private;
-    } else if (AddressSpace == Local) {
+    } else if (AddressSpace == llvm::AMDGPU::Local) {
       return DWARF_Local;
     } else {
       return std::nullopt;
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 1be95cc27f42c..3741668eea67d 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -272,12 +272,6 @@ static void addAMDGPUSpecificMLIRItems(mlir::ModuleOp &mlirModule,
   const llvm::Triple triple(targetOpts.triple);
   const llvm::StringRef codeObjectVersionGlobalOpName = "__oclc_ABI_version";
 
-  // TODO: Share address spaces enumeration between Clang and Flang.
-  // Currently this enumeration is defined in Clang specific class
-  // defined in file: clang/lib/Basic/Targets/AMDGPU.h .
-  // and we need to move it to LLVM directory.
-  const int constantAddressSpace = 4;
-
   if (!triple.isAMDGPU()) {
     return;
   }
@@ -308,7 +302,7 @@ static void addAMDGPUSpecificMLIRItems(mlir::ModuleOp &mlirModule,
     originalGVOp.setValueAttr(
         builder.getIntegerAttr(int32Type, oclcABIVERsion));
     originalGVOp.setUnnamedAddr(mlir::LLVM::UnnamedAddr::Local);
-    originalGVOp.setAddrSpace(constantAddressSpace);
+    originalGVOp.setAddrSpace(llvm::AMDGPU::Constant);
     originalGVOp.setVisibility_(mlir::LLVM::Visibility::Hidden);
     return;
   }
@@ -319,7 +313,7 @@ static void addAMDGPUSpecificMLIRItems(mlir::ModuleOp &mlirModule,
       /* Name */ codeObjectVersionGlobalOpName,
       /* Value */ builder.getIntegerAttr(int32Type, oclcABIVERsion));
   covInfo.setUnnamedAddr(mlir::LLVM::UnnamedAddr::Local);
-  covInfo.setAddrSpace(constantAddressSpace);
+  covInfo.setAddrSpace(llvm::AMDGPU::Constant);
   covInfo.setVisibility_(mlir::LLVM::Visibility::Hidden);
   builder.setInsertionPointToStart(mlirModule.getBody());
   builder.insert(covInfo);
diff --git a/llvm/include/llvm/TargetParser/TargetParser.h b/llvm/include/llvm/TargetParser/TargetParser.h
index 6464285980f00..b0df831c47567 100644
--- a/llvm/include/llvm/TargetParser/TargetParser.h
+++ b/llvm/include/llvm/TargetParser/TargetParser.h
@@ -31,6 +31,15 @@ class Triple;
 // back-end to TableGen to create these clean tables.
 namespace AMDGPU {
 
+/// Address space values for AMD GPUs
+enum AddrSpace {
+  Generic = 0,
+  Global = 1,
+  Local = 3,
+  Constant = 4,
+  Private = 5
+};
+
 /// GPU kinds supported by the AMDGPU target.
 enum GPUKind : uint32_t {
   // Not specified processor.

>From 0d2ea7f38ed247b6f900ed85833fbe40b7a04a12 Mon Sep 17 00:00:00 2001
From: Dominik Adamski <dominik.adamski at amd.com>
Date: Tue, 5 Dec 2023 06:51:18 -0600
Subject: [PATCH 2/2] Applied review remarks

---
 clang/lib/Basic/Targets/AMDGPU.cpp            | 86 ++++++++++---------
 clang/lib/Basic/Targets/AMDGPU.h              | 15 ++--
 flang/lib/Frontend/FrontendActions.cpp        |  7 +-
 llvm/include/llvm/Support/AMDGPUAddrSpace.h   | 31 +++++++
 llvm/include/llvm/TargetParser/TargetParser.h |  9 --
 5 files changed, 92 insertions(+), 56 deletions(-)
 create mode 100644 llvm/include/llvm/Support/AMDGPUAddrSpace.h

diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index 3fe9f9fa9c42d..082029f93f2f2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -37,50 +37,56 @@ static const char *const DataLayoutStringAMDGCN =
     "-ni:7:8";
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
-    llvm::AMDGPU::Generic,  // Default
-    llvm::AMDGPU::Global,   // opencl_global
-    llvm::AMDGPU::Local,    // opencl_local
-    llvm::AMDGPU::Constant, // opencl_constant
-    llvm::AMDGPU::Private,  // opencl_private
-    llvm::AMDGPU::Generic,  // opencl_generic
-    llvm::AMDGPU::Global,   // opencl_global_device
-    llvm::AMDGPU::Global,   // opencl_global_host
-    llvm::AMDGPU::Global,   // cuda_device
-    llvm::AMDGPU::Constant, // cuda_constant
-    llvm::AMDGPU::Local,    // cuda_shared
-    llvm::AMDGPU::Global,   // sycl_global
-    llvm::AMDGPU::Global,   // sycl_global_device
-    llvm::AMDGPU::Global,   // sycl_global_host
-    llvm::AMDGPU::Local,    // sycl_local
-    llvm::AMDGPU::Private,  // sycl_private
-    llvm::AMDGPU::Generic,  // ptr32_sptr
-    llvm::AMDGPU::Generic,  // ptr32_uptr
-    llvm::AMDGPU::Generic,  // ptr64
-    llvm::AMDGPU::Generic,  // hlsl_groupshared
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic),  // Default
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Global),   // opencl_global
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Local),    // opencl_local
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant), // opencl_constant
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Private),  // opencl_private
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic),  // opencl_generic
+    static_cast<unsigned>(
+        llvm::AMDGPU::AddrSpace::Global), // opencl_global_device
+    static_cast<unsigned>(
+        llvm::AMDGPU::AddrSpace::Global), // opencl_global_host
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Global),   // cuda_device
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant), // cuda_constant
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Local),    // cuda_shared
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Global),   // sycl_global
+    static_cast<unsigned>(
+        llvm::AMDGPU::AddrSpace::Global), // sycl_global_device
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Global),  // sycl_global_host
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Local),   // sycl_local
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Private), // sycl_private
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // ptr32_sptr
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // ptr32_uptr
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // ptr64
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // hlsl_groupshared
 };
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
-    llvm::AMDGPU::Private,  // Default
-    llvm::AMDGPU::Global,   // opencl_global
-    llvm::AMDGPU::Local,    // opencl_local
-    llvm::AMDGPU::Constant, // opencl_constant
-    llvm::AMDGPU::Private,  // opencl_private
-    llvm::AMDGPU::Generic,  // opencl_generic
-    llvm::AMDGPU::Global,   // opencl_global_device
-    llvm::AMDGPU::Global,   // opencl_global_host
-    llvm::AMDGPU::Global,   // cuda_device
-    llvm::AMDGPU::Constant, // cuda_constant
-    llvm::AMDGPU::Local,    // cuda_shared
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Private),  // Default
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Global),   // opencl_global
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Local),    // opencl_local
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant), // opencl_constant
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Private),  // opencl_private
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic),  // opencl_generic
+    static_cast<unsigned>(
+        llvm::AMDGPU::AddrSpace::Global), // opencl_global_device
+    static_cast<unsigned>(
+        llvm::AMDGPU::AddrSpace::Global), // opencl_global_host
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Global),   // cuda_device
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant), // cuda_constant
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Local),    // cuda_shared
     // SYCL address space values for this map are dummy
-    llvm::AMDGPU::Generic, // sycl_global
-    llvm::AMDGPU::Generic, // sycl_global_device
-    llvm::AMDGPU::Generic, // sycl_global_host
-    llvm::AMDGPU::Generic, // sycl_local
-    llvm::AMDGPU::Generic, // sycl_private
-    llvm::AMDGPU::Generic, // ptr32_sptr
-    llvm::AMDGPU::Generic, // ptr32_uptr
-    llvm::AMDGPU::Generic, // ptr64
-    llvm::AMDGPU::Generic, // hlsl_groupshared
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // sycl_global
+    static_cast<unsigned>(
+        llvm::AMDGPU::AddrSpace::Generic), // sycl_global_device
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // sycl_global_host
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // sycl_local
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // sycl_private
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // ptr32_sptr
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // ptr32_uptr
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // ptr64
+    static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Generic), // hlsl_groupshared
 
 };
 } // namespace targets
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 1e12f9e12af59..5d909785490a1 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -17,6 +17,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/Support/AMDGPUAddrSpace.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/TargetParser/TargetParser.h"
 #include "llvm/TargetParser/Triple.h"
@@ -99,7 +100,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
       return 32;
     unsigned TargetAS = getTargetAddressSpace(AS);
 
-    if (TargetAS == llvm::AMDGPU::Private || TargetAS == llvm::AMDGPU::Local)
+    if (TargetAS == static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Private) ||
+        TargetAS == static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Local))
       return 32;
 
     return 64;
@@ -369,7 +371,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
   }
 
   std::optional<LangAS> getConstantAddressSpace() const override {
-    return getLangASFromTargetAS(llvm::AMDGPU::Constant);
+    return getLangASFromTargetAS(
+        static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant));
   }
 
   const llvm::omp::GV &getGridValue() const override {
@@ -385,7 +388,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
 
   /// \returns Target specific vtbl ptr address space.
   unsigned getVtblPtrAddressSpace() const override {
-    return static_cast<unsigned>(llvm::AMDGPU::Constant);
+    return static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant);
   }
 
   /// \returns If a target requires an address within a target specific address
@@ -398,9 +401,11 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
   getDWARFAddressSpace(unsigned AddressSpace) const override {
     const unsigned DWARF_Private = 1;
     const unsigned DWARF_Local = 2;
-    if (AddressSpace == llvm::AMDGPU::Private) {
+    if (AddressSpace ==
+        static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Private)) {
       return DWARF_Private;
-    } else if (AddressSpace == llvm::AMDGPU::Local) {
+    } else if (AddressSpace ==
+               static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Local)) {
       return DWARF_Local;
     } else {
       return std::nullopt;
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 3741668eea67d..a9b695e9c388b 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -58,6 +58,7 @@
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Passes/StandardInstrumentations.h"
+#include "llvm/Support/AMDGPUAddrSpace.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
@@ -302,7 +303,8 @@ static void addAMDGPUSpecificMLIRItems(mlir::ModuleOp &mlirModule,
     originalGVOp.setValueAttr(
         builder.getIntegerAttr(int32Type, oclcABIVERsion));
     originalGVOp.setUnnamedAddr(mlir::LLVM::UnnamedAddr::Local);
-    originalGVOp.setAddrSpace(llvm::AMDGPU::Constant);
+    originalGVOp.setAddrSpace(
+        static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant));
     originalGVOp.setVisibility_(mlir::LLVM::Visibility::Hidden);
     return;
   }
@@ -313,7 +315,8 @@ static void addAMDGPUSpecificMLIRItems(mlir::ModuleOp &mlirModule,
       /* Name */ codeObjectVersionGlobalOpName,
       /* Value */ builder.getIntegerAttr(int32Type, oclcABIVERsion));
   covInfo.setUnnamedAddr(mlir::LLVM::UnnamedAddr::Local);
-  covInfo.setAddrSpace(llvm::AMDGPU::Constant);
+  covInfo.setAddrSpace(
+      static_cast<unsigned>(llvm::AMDGPU::AddrSpace::Constant));
   covInfo.setVisibility_(mlir::LLVM::Visibility::Hidden);
   builder.setInsertionPointToStart(mlirModule.getBody());
   builder.insert(covInfo);
diff --git a/llvm/include/llvm/Support/AMDGPUAddrSpace.h b/llvm/include/llvm/Support/AMDGPUAddrSpace.h
new file mode 100644
index 0000000000000..7923524ea5568
--- /dev/null
+++ b/llvm/include/llvm/Support/AMDGPUAddrSpace.h
@@ -0,0 +1,31 @@
+//===---------------- AMDGPUAddrSpace.h -------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// AMDGPU address space definition
+///
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_AMDGPUADDRSPACE_H
+#define LLVM_SUPPORT_AMDGPUADDRSPACE_H
+
+namespace llvm {
+namespace AMDGPU {
+enum class AddrSpace {
+  Generic = 0,
+  Global = 1,
+  Local = 3,
+  Constant = 4,
+  Private = 5
+};
+
+} // end namespace AMDGPU
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_AMDGPUADDRSPACE_H
diff --git a/llvm/include/llvm/TargetParser/TargetParser.h b/llvm/include/llvm/TargetParser/TargetParser.h
index b0df831c47567..6464285980f00 100644
--- a/llvm/include/llvm/TargetParser/TargetParser.h
+++ b/llvm/include/llvm/TargetParser/TargetParser.h
@@ -31,15 +31,6 @@ class Triple;
 // back-end to TableGen to create these clean tables.
 namespace AMDGPU {
 
-/// Address space values for AMD GPUs
-enum AddrSpace {
-  Generic = 0,
-  Global = 1,
-  Local = 3,
-  Constant = 4,
-  Private = 5
-};
-
 /// GPU kinds supported by the AMDGPU target.
 enum GPUKind : uint32_t {
   // Not specified processor.



More information about the cfe-commits mailing list