Skip to content

Commit f46abee

Browse files
committed
[AMDGPU] Changes image desc macro to use opaque ptr type macro and minor changes
1 parent ef4abb9 commit f46abee

File tree

10 files changed

+23
-47
lines changed

10 files changed

+23
-47
lines changed

clang/include/clang/Basic/AMDGPUTypes.def

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,11 @@
2020
AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
2121
#endif
2222

23-
#ifndef AMDGPU_IMAGE_RSRC_TYPE
24-
#define AMDGPU_IMAGE_RSRC_TYPE(Name, Id, SingletonId) \
25-
AMDGPU_TYPE(Name, Id, SingletonId, 256, 256)
26-
#endif
27-
2823
AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy, 128, 128, 8)
29-
AMDGPU_IMAGE_RSRC_TYPE("__amdgpu_image_rsrc_t", AMDGPUImageDescRsrc, AMDGPUImageDescRsrcTy)
24+
AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_texture_t", AMDGPUTexture, AMDGPUTextureTy, 256, 256, 0)
3025

3126
AMDGPU_NAMED_BARRIER_TYPE("__amdgpu_named_workgroup_barrier_t", AMDGPUNamedWorkgroupBarrier, AMDGPUNamedWorkgroupBarrierTy, 128, 32, 0)
3227

3328
#undef AMDGPU_TYPE
3429
#undef AMDGPU_OPAQUE_PTR_TYPE
3530
#undef AMDGPU_NAMED_BARRIER_TYPE
36-
#undef AMDGPU_IMAGE_RSRC_TYPE

clang/include/clang/Basic/Builtins.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// Q -> target builtin type, followed by a character to distinguish the builtin type
3535
// Qa -> AArch64 svcount_t builtin type.
3636
// Qb -> AMDGPU __amdgpu_buffer_rsrc_t builtin type.
37-
// Qt -> AMDGPU __amdgpu_image_desc_t builtin type.
37+
// Qt -> AMDGPU __amdgpu_texture_t builtin type.
3838
// E -> ext_vector, followed by the number of elements and the base type.
3939
// X -> _Complex, followed by the base type.
4040
// Y -> ptrdiff_t

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12581,7 +12581,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
1258112581
break;
1258212582
}
1258312583
case 't': {
12584-
Type = Context.AMDGPUImageDescRsrcTy;
12584+
Type = Context.AMDGPUTextureTy;
1258512585
break;
1258612586
}
1258712587
default:

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,14 +1020,6 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
10201020
DBuilder.createBasicType(Name, Width, llvm::dwarf::DW_ATE_unsigned); \
10211021
return SingletonId; \
10221022
}
1023-
#define AMDGPU_IMAGE_RSRC_TYPE(Name, Id, SingletonId) \
1024-
case BuiltinType::Id: { \
1025-
if (!SingletonId) \
1026-
SingletonId = \
1027-
DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name, \
1028-
TheCU, TheCU->getFile(), 0); \
1029-
return SingletonId; \
1030-
}
10311023
#include "clang/Basic/AMDGPUTypes.def"
10321024
case BuiltinType::UChar:
10331025
case BuiltinType::Char_U:

clang/lib/CodeGen/CodeGenTypes.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
581581
case BuiltinType::Id: \
582582
return llvm::TargetExtType::get(getLLVMContext(), "amdgcn.named.barrier", \
583583
{}, {Scope});
584-
#define AMDGPU_IMAGE_RSRC_TYPE(Name, Id, SingletonId) \
585-
case BuiltinType::Id: \
586-
return llvm::VectorType::get(llvm::Type::getInt32Ty(getLLVMContext()), 8, \
587-
false);
588584
#include "clang/Basic/AMDGPUTypes.def"
589585
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
590586
#include "clang/Basic/HLSLIntangibleTypes.def"

clang/test/CodeGen/amdgpu-image-rsrc-type-debug-info.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
// CHECK-LABEL: define dso_local void @test_locals(
66
// CHECK-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG6:![0-9]+]] {
77
// CHECK-NEXT: [[ENTRY:.*:]]
8-
// CHECK-NEXT: [[IMG:%.*]] = alloca <8 x i32>, align 32, addrspace(5)
8+
// CHECK-NEXT: [[IMG:%.*]] = alloca ptr, align 32, addrspace(5)
99
// CHECK-NEXT: [[IMG_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[IMG]] to ptr
1010
// CHECK-NEXT: #dbg_declare(ptr addrspace(5) [[IMG]], [[META11:![0-9]+]], !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef), [[META14:![0-9]+]])
11-
// CHECK-NEXT: [[TMP0:%.*]] = load <8 x i32>, ptr [[IMG_ASCAST]], align 32, !dbg [[DBG15:![0-9]+]]
11+
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[IMG_ASCAST]], align 32, !dbg [[DBG15:![0-9]+]]
1212
// CHECK-NEXT: ret void, !dbg [[DBG16:![0-9]+]]
1313
//
1414
void test_locals(void) {
15-
__amdgpu_image_rsrc_t img;
15+
__amdgpu_texture_t img;
1616
(void)img;
1717
}
18-

clang/test/CodeGenCXX/amdgpu-image-rsrc-typeinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// REQUIRES: amdgpu-registered-target
33
// RUN: %clang_cc1 -triple amdgcn %s -emit-llvm -o - | FileCheck %s
44
namespace std { class type_info; }
5-
auto &a = typeid(__amdgpu_image_rsrc_t);
5+
auto &a = typeid(__amdgpu_texture_t);
66
//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
77
// CHECK: {{.*}}

clang/test/SemaCXX/amdgpu-image-rsrc.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@
33
// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 -triple amdgcn -Wno-unused-value %s
44

55
void foo() {
6-
int n = 1;
7-
__amdgpu_image_rsrc_t v = 0; // expected-error {{cannot initialize a variable of type '__amdgpu_image_rsrc_t' with an rvalue of type 'int'}}
8-
static_cast<__amdgpu_image_rsrc_t>(n); // expected-error {{static_cast from 'int' to '__amdgpu_image_rsrc_t' is not allowed}}
9-
reinterpret_cast<__amdgpu_image_rsrc_t>(n); // expected-error {{reinterpret_cast from 'int' to '__amdgpu_image_rsrc_t' is not allowed}}
10-
(void)(v + v); // expected-error {{invalid operands}}
11-
int x(v); // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type '__amdgpu_image_rsrc_t'}}
12-
__amdgpu_image_rsrc_t k;
6+
int n = 100;
7+
__amdgpu_texture_t v = 0; // expected-error {{cannot initialize a variable of type '__amdgpu_texture_t' with an rvalue of type 'int'}}
8+
static_cast<__amdgpu_texture_t>(n); // expected-error {{static_cast from 'int' to '__amdgpu_texture_t' is not allowed}}
9+
reinterpret_cast<__amdgpu_texture_t>(n); // expected-error {{reinterpret_cast from 'int' to '__amdgpu_texture_t' is not allowed}}
10+
(void)(v + v); // expected-error {{invalid operands to binary expression ('__amdgpu_texture_t' and '__amdgpu_texture_t')}}
11+
int x(v); // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type '__amdgpu_texture_t'}}
12+
__amdgpu_texture_t k;
1313
}
1414

15-
static_assert(sizeof(__amdgpu_image_rsrc_t) == 32, "size");
16-
static_assert(alignof(__amdgpu_image_rsrc_t) == 32, "align");
17-
1815
template<class T> void bar(T);
19-
void use(__amdgpu_image_rsrc_t r) { bar(r); }
20-
struct S { __amdgpu_image_rsrc_t r; int a; };
21-
static_assert(sizeof(S) == 64, "struct layout");
16+
void use(__amdgpu_texture_t r) { bar(r); }
17+
struct S { __amdgpu_texture_t r; int a; };

clang/test/SemaOpenCL/amdgpu-image-rsrc.cl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
void f() {
77
int n = 3;
8-
__amdgpu_image_rsrc_t v = 0; // expected-error {{initializing '__private __amdgpu_image_rsrc_t' with an expression of incompatible type 'int'}}
9-
int k = v; // expected-error {{initializing '__private int' with an expression of incompatible type '__private __amdgpu_image_rsrc_t'}}
10-
(void)(v + v); // expected-error {{invalid operands}}
11-
__amdgpu_image_rsrc_t r;
12-
int *p = (int*)r; // expected-error {{operand of type '__amdgpu_image_rsrc_t' where arithmetic or pointer type is required}}
13-
(void)p;
8+
__amdgpu_texture_t v = (__amdgpu_texture_t)0; // expected-error {{used type '__amdgpu_texture_t' where arithmetic or pointer type is required}}
9+
int k = v; // expected-error {{initializing '__private int' with an expression of incompatible type '__private __amdgpu_texture_t'}}
10+
(void)(v + v); // expected-error {{invalid operands}}
11+
__amdgpu_texture_t r;
12+
int *p = (int*)r; // expected-error {{operand of type '__amdgpu_texture_t' where arithmetic or pointer type is required}}
1413
}

clang/test/SemaOpenMP/amdgpu-image-rsrc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void foo() {
66
#pragma omp target
77
{
88
int n = 5;
9-
__amdgpu_image_rsrc_t v = 0; // expected-error {{cannot initialize a variable of type '__amdgpu_image_rsrc_t' with an rvalue of type 'int'}}
10-
(void)(v + v); // expected-error {{invalid operands to binary expression ('__amdgpu_image_rsrc_t' and '__amdgpu_image_rsrc_t'}}
9+
__amdgpu_texture_t v = 0; // expected-error {{cannot initialize a variable of type '__amdgpu_texture_t' with an rvalue of type 'int'}}
10+
(void)(v + v); // expected-error {{invalid operands to binary expression}}
1111
}
1212
}

0 commit comments

Comments
 (0)