[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian closed https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/yxsamliu approved this pull request. LGTM. Thanks. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: ping https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 013a40d474e3acaa7a090d5e279f2d8a2f18fbd8 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 18:48:33 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 20 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,19 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fsyntax-only -verify -triple amdgcn -Wno-unused-value %s + yxsamliu wrote: Add a run line: // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64 -aux-triple amdgcn -Wno-unused-value %s https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: @yxsamliu https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/arsenm approved this pull request. LGTM but I'm not a frontend expert https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 913d0761133b5f6f7785e04b23d0a8744e140842 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 15:29:47 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 19 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From bc137f40cd524c47094ce39ec4e4d567283fc2da Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 15:19:39 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 19 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 11 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 297 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,11 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -verify -triple amdgcn-amd-amdhsa -Wno-unused-value %s arsenm wrote: set explicit -cl-std, and check 1.2 and 2.0? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,17 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 -triple amdgcn -Wno-unused-value %s + shiltian wrote: TBH I don't think there is any difference but I added them anyway. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 15347886bf3327d1a23a2caa65f58cba7ef86fe5 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 14:27:09 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 19 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 11 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 296 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 1751b9ed484e88213ba56be9961769bcabf085be Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 14:23:00 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 11 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 31 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,84 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s arsenm wrote: Not much point in testing all the subtargets here https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,84 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +typedef struct AA_ty { + int x; + __amdgcn_buffer_rsrc_t r; +} AA; + +AA getAA(void *p); +__amdgcn_buffer_rsrc_t getBufferImpl(void *p); +void consumeBuffer(__amdgcn_buffer_rsrc_t); + +// CHECK-LABEL: define {{[^@]+}}@getBuffer arsenm wrote: I guess that covers it, but we don't get to see the return attributes now https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,9 @@ + arsenm wrote: Extra blank line https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,17 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 -triple amdgcn -Wno-unused-value %s + arsenm wrote: We probably want another similar sema test for OpenCL/HIP/OpenMP https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 15ed0af5f5d23213fd4c10ff704ac26bb1b80030 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Sun, 16 Jun 2024 23:07:29 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 7b31bbbd9efd13ea78d1a7bfef00cbd943e27876 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 14 Jun 2024 13:22:17 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_PTR_TYPE +#define AMDGPU_OPAQUE_PTR_TYPE(Name, MangledName, AS, Width, Align, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_PTR_TYPE("__amdgcn_buffer_rsrc_t", "__amdgcn_buffer_rsrc_t", 8, 128, 128, AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) arsenm wrote: Things are gradually moving to use amdgpu https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_PTR_TYPE +#define AMDGPU_OPAQUE_PTR_TYPE(Name, MangledName, AS, Width, Align, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_PTR_TYPE("__amdgcn_buffer_rsrc_t", "__amdgcn_buffer_rsrc_t", 8, 128, 128, AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) shiltian wrote: What is our standard here? Our builtin, intrinsics, and target triple are using `amdgcn`. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,84 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +typedef struct AA_ty { + int x; + __amdgcn_buffer_rsrc_t r; +} AA; + +AA getAA(void *p); +__amdgcn_buffer_rsrc_t getBufferImpl(void *p); +void consumeBuffer(__amdgcn_buffer_rsrc_t); + +// CHECK-LABEL: define {{[^@]+}}@getBuffer shiltian wrote: As I mentioned in the previous outdated comment, `update_cc_test_checks.py` doesn't check return type even with `--function-signature`. However, the `ret` instruction at the end of the function can be used to verify the return type. In this case, it has `ret ptr addrspace(8) [[CALL]]` so the return type is `ptr addrspace(8)`. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,84 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +typedef struct AA_ty { + int x; + __amdgcn_buffer_rsrc_t r; +} AA; + +AA getAA(void *p); +__amdgcn_buffer_rsrc_t getBufferImpl(void *p); +void consumeBuffer(__amdgcn_buffer_rsrc_t); + +// CHECK-LABEL: define {{[^@]+}}@getBuffer arsenm wrote: This is not showing the return type https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_PTR_TYPE +#define AMDGPU_OPAQUE_PTR_TYPE(Name, MangledName, AS, Width, Align, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_PTR_TYPE("__amdgcn_buffer_rsrc_t", "__amdgcn_buffer_rsrc_t", 8, 128, 128, AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) arsenm wrote: Should use amdgpu not amdgcn https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From baa19285069854598437694cb2094283598cf8c2 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 14 Jun 2024 12:58:08 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,69 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +typedef struct AA_ty { + int x; + __amdgcn_buffer_rsrc_t r; +} AA; + +AA getAA(void *p); +__amdgcn_buffer_rsrc_t getBuffer(void *p); +void consumeBuffer(__amdgcn_buffer_rsrc_t); + +// CHECK-LABEL: @consumeBufferPtr( shiltian wrote: `update_cc_test_checks.py` doesn't appear to have an argument to check the function return type. I added `--function-signature` though. The `ret` instruction at the end of each function can be used to verify the return type. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 24703e0480835fb2c491b7140c2ab5022218777d Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 13 Jun 2024 18:43:29 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,69 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +typedef struct AA_ty { + int x; + __amdgcn_buffer_rsrc_t r; +} AA; + +AA getAA(void *p); +__amdgcn_buffer_rsrc_t getBuffer(void *p); +void consumeBuffer(__amdgcn_buffer_rsrc_t); + +// CHECK-LABEL: @consumeBufferPtr( arsenm wrote: The interesting check here is the IR type in the function signature which are missing. Also should test it as a return value (and return value in a struct) https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,9 @@ + +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s + +// CHECK: name: "__amdgcn_buffer_rsrc_t",{{.*}}baseType: ![[BT:[0-9]+]] +// CHECK: [[BT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "__amdgcn_buffer_rsrc_t", {{.*}} flags: DIFlagFwdDecl) krzysz00 wrote: Yeah, debug as a struct's probably a more sensible representation, since it basically is a struct https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 2eb6b3a58692ae3b8a6250e87516450a5085fa0f Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 13 Jun 2024 17:02:11 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 ++ clang/include/clang/Basic/AMDGPUTypes.def | 21 ++ .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 + clang/lib/AST/ASTImporter.cpp | 4 ++ clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 ++ clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 ++ clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 69 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 + clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip -aux-triple amdgcn-amd-amdhsa %s -fsyntax-only -verify + +#define __device__ __attribute__((device)) + +__device__ __amdgcn_buffer_rsrc_t test_buffer_rsrc_t_device() {} // expected-warning {{non-void function does not return a value}} +__amdgcn_buffer_rsrc_t test_buffer_rsrc_t_host() {} // expected-error {{'__amdgcn_buffer_rsrc_t' can only be used in device-side function}} shiltian wrote: Okay, that makes sense. Then I'll remove this test. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip -aux-triple amdgcn-amd-amdhsa %s -fsyntax-only -verify + +#define __device__ __attribute__((device)) + +__device__ __amdgcn_buffer_rsrc_t test_buffer_rsrc_t_device() {} // expected-warning {{non-void function does not return a value}} +__amdgcn_buffer_rsrc_t test_buffer_rsrc_t_host() {} // expected-error {{'__amdgcn_buffer_rsrc_t' can only be used in device-side function}} yxsamliu wrote: As discussed in https://github.com/llvm/llvm-project/pull/69366, I think the trend is to make HIP more like C++ where every function is both device and host function, and de-emphasize handling based on host/device attributes. Ideally, we can imagine we are compiling a HIP program for a processor that has the capability of both the host CPU and the device GPU, so that we can ignore host/device difference during semantic checking, and we defer the diagnosing to codegen or linker. The reason is that C++ is not designed with host/device in mind and the current parser/sema does not consider host/device attributes in many cases, especially about templates. Adding more host/device based sema seems to make things more complicated and not to help making generic C++ code (e.g. the standard C++ library) work for both host/device. Another reason not to emphasize the host/device difference is that difference in device/host AST risks violation of ODR and causes issues difficult to diagnose. In a word, I would not recommend restricting a type to device only. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip -aux-triple amdgcn-amd-amdhsa %s -fsyntax-only -verify + +#define __device__ __attribute__((device)) + +__device__ __amdgcn_buffer_rsrc_t test_buffer_rsrc_t_device() {} // expected-warning {{non-void function does not return a value}} +__amdgcn_buffer_rsrc_t test_buffer_rsrc_t_host() {} // expected-error {{'__amdgcn_buffer_rsrc_t' can only be used in device-side function}} shiltian wrote: The only thing left is this part. Is it possible to force it to only be used in device-side function? @yxsamliu https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,9 @@ + +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s + +// CHECK: name: "__amdgcn_buffer_rsrc_t",{{.*}}baseType: ![[BT:[0-9]+]] +// CHECK: [[BT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "__amdgcn_buffer_rsrc_t", {{.*}} flags: DIFlagFwdDecl) shiltian wrote: For the debug type, I made it a struct type, because I don't think we expose it as a pointer even though it is used internally as one. It is not an integer as well. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: Now `__amdgcn_buffer_rsrc_t` is a 128-bit wide builtin opaque type. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From bbe2a055c2448d8caf020d33c7e96a3e3bd75165 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 13 Jun 2024 15:39:02 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 ++ clang/include/clang/Basic/AMDGPUTypes.def | 21 ++ .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 + clang/lib/AST/ASTImporter.cpp | 4 ++ clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 ++ clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 ++ clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 69 +++ clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu | 6 ++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 + clang/tools/libclang/CIndex.cpp | 2 + 30 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
arsenm wrote: > Just a note - and maybe this was already discussed above - is there good > reason not to explicitly make this type a 128-bit scalar? The LLVM data > layout already does this I thought this was the 160 bit version? Can we have an opaque-but-sized type? The concern is exposing this as a raw pointer right away https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
krzysz00 wrote: Just a note - and maybe this was already discussed above - is there good reason not to explicitly make this type a 128-bit scalar? The LLVM data layout already does this https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip -aux-triple amdgcn-amd-amdhsa %s -fsyntax-only -verify + +#define __device__ __attribute__((device)) + +__device__ __buffer_rsrc_t test_buffer_rsrc_t_device() {} // expected-warning {{non-void function does not return a value}} +__buffer_rsrc_t test_buffer_rsrc_t_host() {} // expected-error {{'__buffer_rsrc_t' can only be used in device-side function}} shiltian wrote: @yxsamliu I forced that the type is only available if the target triple or the aux target triple is amdgpu. However, that doesn't force the check that `__buffer_rsrc_t` can only be used in device-side function. How do we do this kind of type check in Sema? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From cbb274f279c918bd0aaa601f87e50a2d10b71c25 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 12 Jun 2024 15:46:55 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 12 + clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 7 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu | 6 + clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 30 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
yxsamliu wrote: > > how does a user initialize/populate this type of objects? by calling a > > builtin function? > > yes. The builtin functions will come next. > > > need a SemaCUDA test to make sure it is defined with %clang_cc1 -triple > > x86_64-unknown-gnu-linux -aux-triple amdgcn-amd-amdhsa , like > > https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCUDA/builtin-mangled-name.cu > > Why do we need this to be defined in that way? This should only be used in > kernel. I purposely made the type available only when the target triple is > amdgcn. @yxsamliu HIP is single source program, meaning the same source code is visible to both device compilation and host compilation. If you have code that only compiles in device compilation, you have to put `#if __HIP_DEVICE_COMPILE__ #endif` around it. That would clutter the program. The difference between source code seen in device compilation and host compilation also increases the risk of violation of one-definition-rule. Therefore, in general, we request types, function declarations/definitions and pre-defined macros to be visible to both device and host compilation. This is true to the existing amdgcn builtin functions. Due to the mechanism already in place about -aux-triple, we see device builtin functions in current host compilation, otherwise, HIP programs will be cluttered with `#if __HIP_DEVICE_COMPILE__ #endif` everywhere. We just request the newly added builtin type to follow this existing convention. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 1b06131a10e1f8067961624b02bba3354d5057c0 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 12 Jun 2024 09:18:49 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..2328141b27e79 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 +//
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: > how does a user initialize/populate this type of objects? by calling a > builtin function? yes. The builtin functions will come next. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
yxsamliu wrote: how does a user initialize/populate this type of objects? by calling a builtin function? need a SemaCUDA test to make sure it is defined with %clang_cc1 -triple x86_64-unknown-gnu-linux -aux-triple amdgcn-amd-amdhsa , like https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCUDA/builtin-mangled-name.cu https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: any comment/concern? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 731c2adb3bf69bd1f337691eeb34756e521d47f3 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 10 Jun 2024 15:40:41 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 +//
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2201,6 +2207,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 0; + Align = 256; shiltian wrote: Based on our data layout, it looks like AS8 pointer is 128 bit and AS7 is 160 bit. The alignment here should be 128. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 57e60fb4d4d37f19ddfbc4a0878b7ee2e180aa2d Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 10 Jun 2024 15:23:07 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 +//
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2201,6 +2207,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 0; + Align = 256; arsenm wrote: If we expose this as a pointer there are a lot of sharp edges we need to fix. If we expose it as an opaque type for builtins, the broken cases are hidden from end users. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2201,6 +2207,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 0; + Align = 256; krzysz00 wrote: Hold on, there're two types that it'd make sense to builtin here. The first is the "buffer rsrc", which the ISA manual calls a `V#`. This is a 128-bit data structure that's quite opaque as far as C semantics go. LLVM-wise they're `ptr addrspace(8)` The other are the various flavor of buffer fat pointer, which are 160- or 192-bit values that are a buffer resource with offset bits hanging off the other end. `ptr addrspace(7)` can act like a pointer-pointer if you squint and there are LLVM lowerings to make it work https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,11 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fsyntax-only -verify -triple amdgcn -Wno-unused-value %s + +void foo() { + int n = 100; + __buffer_rsrc_t v = 0; // expected-error {{cannot initialize a variable of type '__buffer_rsrc_t' with an rvalue of type 'int'}} + static_cast<__buffer_rsrc_t>(n); // expected-error {{static_cast from 'int' to '__buffer_rsrc_t' is not allowed}} + dynamic_cast<__buffer_rsrc_t>(n); // expected-error {{invalid target type '__buffer_rsrc_t' for dynamic_cast; target type must be a reference or pointer type to a defined class}} + reinterpret_cast<__buffer_rsrc_t>(n); // expected-error {{reinterpret_cast from 'int' to '__buffer_rsrc_t' is not allowed}} + int c(v); // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type '__buffer_rsrc_t'}} +} arsenm wrote: Also test some c style casts to other pointer types https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,11 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fsyntax-only -verify -triple amdgcn -Wno-unused-value %s + +void foo() { + int n = 100; + __buffer_rsrc_t v = 0; // expected-error {{cannot initialize a variable of type '__buffer_rsrc_t' with an rvalue of type 'int'}} + static_cast<__buffer_rsrc_t>(n); // expected-error {{static_cast from 'int' to '__buffer_rsrc_t' is not allowed}} + dynamic_cast<__buffer_rsrc_t>(n); // expected-error {{invalid target type '__buffer_rsrc_t' for dynamic_cast; target type must be a reference or pointer type to a defined class}} + reinterpret_cast<__buffer_rsrc_t>(n); // expected-error {{reinterpret_cast from 'int' to '__buffer_rsrc_t' is not allowed}} + int c(v); // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type '__buffer_rsrc_t'}} +} arsenm wrote: What about sizeof / alignof? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2201,6 +2207,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 0; + Align = 256; shiltian wrote: This has to be power of 2 so 160 -> 256. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From b468736cad511e36c7ac22d2ad86ba01ca21d8a5 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 10 Jun 2024 11:37:17 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 6 + clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 11 clang/tools/libclang/CIndex.cpp | 2 ++ 28 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types. +//
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2200,6 +2206,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 128; + Align = 128; arsenm wrote: Sizeless object is probably the safest option for now. It shouldn't be a vector. I foresee more difficulty introducing a wide pointer, and if we change our minds on how fat pointers should work it's harder to change the size later https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,9 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fclang-abi-compat=latest -triple amdgcn %s -emit-llvm -o - | FileCheck %s shiltian wrote: Copy/paste from other tests Lol https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_TYPE +#define AMDGPU_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_TYPE("__buffer_rsrc_t", "__buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) shiltian wrote: Probably not. I checked WASM reference types and they don't have wasm prefix. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2200,6 +2206,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 128; + Align = 128; shiltian wrote: Do we want to expose it as a pointer, a sizeless object, or a vector of 160 bits? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,9 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fclang-abi-compat=latest -triple amdgcn %s -emit-llvm -o - | FileCheck %s arsenm wrote: Why do you need -fclang-abi-compat=latest https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_TYPE +#define AMDGPU_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_TYPE("__buffer_rsrc_t", "__buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) arsenm wrote: Should it include an amdgpu prefix? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2200,6 +2206,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 128; + Align = 128; arsenm wrote: If we were exposing the pointer, it would be 160/192 https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/arsenm commented: Need stacked PR that adds the make_buffer_rsrc builtin that shows its use https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -1091,6 +1091,9 @@ enum PredefinedTypeIDs { // \brief WebAssembly reference types with auto numeration #define WASM_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// \breif AMDGPU types with auto numeration arsenm wrote: Typo breif https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Shilei Tian (shiltian) Changes --- Patch is 23.90 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94830.diff 30 Files Affected: - (modified) clang/include/clang/AST/ASTContext.h (+2) - (modified) clang/include/clang/AST/Type.h (+3) - (modified) clang/include/clang/AST/TypeProperties.td (+4) - (added) clang/include/clang/Basic/AMDGPUTypes.def (+21) - (modified) clang/include/clang/Basic/Builtins.def (+1) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+4-1) - (modified) clang/lib/AST/ASTContext.cpp (+15) - (modified) clang/lib/AST/ASTImporter.cpp (+4) - (modified) clang/lib/AST/ExprConstant.cpp (+2) - (modified) clang/lib/AST/ItaniumMangle.cpp (+6) - (modified) clang/lib/AST/MicrosoftMangle.cpp (+2) - (modified) clang/lib/AST/NSAPI.cpp (+2) - (modified) clang/lib/AST/PrintfFormatString.cpp (+2) - (modified) clang/lib/AST/Type.cpp (+6) - (modified) clang/lib/AST/TypeLoc.cpp (+2) - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+2-1) - (modified) clang/lib/CodeGen/CGDebugInfo.h (+2) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+2) - (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+2) - (modified) clang/lib/Index/USRGeneration.cpp (+4) - (modified) clang/lib/Sema/Sema.cpp (+6) - (modified) clang/lib/Sema/SemaExpr.cpp (+4) - (modified) clang/lib/Serialization/ASTCommon.cpp (+5) - (modified) clang/lib/Serialization/ASTReader.cpp (+5) - (added) clang/test/AST/ast-dump-amdgpu-types.c (+9) - (added) clang/test/CodeGen/amdgpu-buffer-rsrc-type.c (+8) - (added) clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp (+8) - (added) clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl (+26) - (added) clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp (+11) - (modified) clang/tools/libclang/CIndex.cpp (+2) ``diff diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..2328141b27e79 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_TYPE +#define AMDGPU_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_TYPE("__buffer_rsrc_t", "__buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) + +#undef AMDGPU_TYPE +#undef AMDGPU_OPAQUE_TYPE diff --git a/clang/include/clang/Basic/Builtins.def
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/94830 None >From 891c37a3f6002c40aa0ded803330f61c3d16e6bb Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 7 Jun 2024 22:37:13 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ clang/include/clang/Basic/Builtins.def| 1 + .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 15 +++ clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 6 + clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 3 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 9 +++ clang/test/CodeGen/amdgpu-buffer-rsrc-type.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 8 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 11 clang/tools/libclang/CIndex.cpp | 2 ++ 30 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..2328141b27e79 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 +//