Skip to content

Commit 2c74854

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:139688a699f6db784bd559b147334f1d51314f9c into amd-gfx:cf8fb1be1ea5
Local branch amd-gfx cf8fb1b Merged main:be6aed90c70b7ef718c6c9217158933c8dd57372 into amd-gfx:a2173ce377e5 Remote branch main 139688a [SPIRV] Add atan2 function lowering (p2) (llvm#110037)
2 parents cf8fb1b + 139688a commit 2c74854

File tree

61 files changed

+1106
-369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1106
-369
lines changed

clang/include/clang/Basic/Builtins.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,12 +4703,6 @@ def HLSLClamp : LangBuiltin<"HLSL_LANG"> {
47034703
let Prototype = "void(...)";
47044704
}
47054705

4706-
def HLSLCreateHandle : LangBuiltin<"HLSL_LANG"> {
4707-
let Spellings = ["__builtin_hlsl_create_handle"];
4708-
let Attributes = [NoThrow, Const];
4709-
let Prototype = "void*(unsigned char)";
4710-
}
4711-
47124706
def HLSLDotProduct : LangBuiltin<"HLSL_LANG"> {
47134707
let Spellings = ["__builtin_hlsl_dot"];
47144708
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12388,6 +12388,7 @@ def err_hlsl_packoffset_alignment_mismatch : Error<"packoffset at 'y' not match
1238812388
def err_hlsl_pointers_unsupported : Error<
1238912389
"%select{pointers|references}0 are unsupported in HLSL">;
1239012390
def err_hlsl_missing_resource_class : Error<"HLSL resource needs to have [[hlsl::resource_class()]] attribute">;
12391+
def err_hlsl_attribute_needs_intangible_type: Error<"attribute %0 can be used only on HLSL intangible type %1">;
1239112392

1239212393
def err_hlsl_operator_unsupported : Error<
1239312394
"the '%select{&|*|->}0' operator is unsupported in HLSL">;

clang/include/clang/Sema/SemaHLSL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SemaHLSL : public SemaBase {
7070
void handleShaderAttr(Decl *D, const ParsedAttr &AL);
7171
void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL);
7272
void handleParamModifierAttr(Decl *D, const ParsedAttr &AL);
73-
bool handleResourceTypeAttr(const ParsedAttr &AL);
73+
bool handleResourceTypeAttr(QualType T, const ParsedAttr &AL);
7474

7575
bool CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
7676
QualType ProcessResourceTypeAttributes(QualType Wrapped);

clang/lib/Sema/HLSLExternalSemaSource.cpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -193,36 +193,8 @@ struct BuiltinTypeDeclBuilder {
193193
ExplicitSpecifier(), false, true, false,
194194
ConstexprSpecKind::Unspecified);
195195

196-
DeclRefExpr *Fn =
197-
lookupBuiltinFunction(AST, S, "__builtin_hlsl_create_handle");
198-
Expr *RCExpr = emitResourceClassExpr(AST, RC);
199-
Expr *Call = CallExpr::Create(AST, Fn, {RCExpr}, AST.VoidPtrTy, VK_PRValue,
200-
SourceLocation(), FPOptionsOverride());
201-
202-
CXXThisExpr *This = CXXThisExpr::Create(
203-
AST, SourceLocation(), Constructor->getFunctionObjectParameterType(),
204-
true);
205-
Expr *Handle = MemberExpr::CreateImplicit(AST, This, false, Fields["h"],
206-
Fields["h"]->getType(), VK_LValue,
207-
OK_Ordinary);
208-
209-
// If the handle isn't a void pointer, cast the builtin result to the
210-
// correct type.
211-
if (Handle->getType().getCanonicalType() != AST.VoidPtrTy) {
212-
Call = CXXStaticCastExpr::Create(
213-
AST, Handle->getType(), VK_PRValue, CK_Dependent, Call, nullptr,
214-
AST.getTrivialTypeSourceInfo(Handle->getType(), SourceLocation()),
215-
FPOptionsOverride(), SourceLocation(), SourceLocation(),
216-
SourceRange());
217-
}
218-
219-
BinaryOperator *Assign = BinaryOperator::Create(
220-
AST, Handle, Call, BO_Assign, Handle->getType(), VK_LValue, OK_Ordinary,
221-
SourceLocation(), FPOptionsOverride());
222-
223-
Constructor->setBody(
224-
CompoundStmt::Create(AST, {Assign}, FPOptionsOverride(),
225-
SourceLocation(), SourceLocation()));
196+
Constructor->setBody(CompoundStmt::Create(
197+
AST, {}, FPOptionsOverride(), SourceLocation(), SourceLocation()));
226198
Constructor->setAccess(AccessSpecifier::AS_public);
227199
Record->addDecl(Constructor);
228200
return *this;

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,19 @@ bool clang::CreateHLSLAttributedResourceType(
693693
// HLSL resource. The attributes are collected in HLSLResourcesTypeAttrs and at
694694
// the end of the declaration they are applied to the declaration type by
695695
// wrapping it in HLSLAttributedResourceType.
696-
bool SemaHLSL::handleResourceTypeAttr(const ParsedAttr &AL) {
697-
Attr *A = nullptr;
696+
bool SemaHLSL::handleResourceTypeAttr(QualType T, const ParsedAttr &AL) {
697+
// only allow resource type attributes on intangible types
698+
if (!T->isHLSLResourceType()) {
699+
Diag(AL.getLoc(), diag::err_hlsl_attribute_needs_intangible_type)
700+
<< AL << getASTContext().HLSLResourceTy;
701+
return false;
702+
}
698703

699704
// validate number of arguments
700705
if (!AL.checkExactlyNumArgs(SemaRef, AL.getMinArgs()))
701706
return false;
702707

708+
Attr *A = nullptr;
703709
switch (AL.getKind()) {
704710
case ParsedAttr::AT_HLSLResourceClass: {
705711
if (!AL.isArgIdent(0)) {

clang/lib/Sema/SemaType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8860,7 +8860,7 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type,
88608860
// decl-specifier-seq; do not collect attributes on declarations or those
88618861
// that get to slide after declaration name.
88628862
if (TAL == TAL_DeclSpec &&
8863-
state.getSema().HLSL().handleResourceTypeAttr(attr))
8863+
state.getSema().HLSL().handleResourceTypeAttr(type, attr))
88648864
attr.setUsedAsTypeAttr();
88658865
break;
88668866
}

clang/test/AST/HLSL/RWBuffer-AST.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ RWBuffer<float> Buffer;
6666
// CHECK: TemplateArgument type 'float'
6767
// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
6868
// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
69-
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit referenced h 'float *
69+
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'float *
7070
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
7171
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(float)]]
7272
// CHECK-SAME: ':'float *'

clang/test/AST/HLSL/StructuredBuffer-AST.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ StructuredBuffer<float> Buffer;
7070
// CHECK: TemplateArgument type 'float'
7171
// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
7272
// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
73-
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit referenced h 'float *
73+
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'float *
7474
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
7575
// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
7676
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(float)]]

clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
22
// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
33

4+
// XFAIL: *
5+
// This expectedly fails because create.handle is no longer called
6+
// from RWBuffer constructor and the replacement has not been
7+
// implemented yet. This test should be updated to expect
8+
// dx.create.handleFromBinding as part of issue #105076.
9+
410
RWBuffer<float> Buf;
511

612
// CHECK: define linkonce_odr noundef ptr @"??0?$RWBuffer@M@hlsl@@QAA@XZ"
@@ -10,4 +16,4 @@ RWBuffer<float> Buf;
1016
// CHECK: store ptr %[[HandleRes]], ptr %h, align 4
1117

1218
// CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
13-
// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
19+
// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8

clang/test/CodeGenHLSL/builtins/StructuredBuffer-constructor.hlsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
12
// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
23

4+
// XFAIL: *
5+
// This expectedly fails because create.handle is no longer invoked
6+
// from StructuredBuffer constructor and the replacement has not been
7+
// implemented yet. This test should be updated to expect
8+
// dx.create.handleFromBinding as part of issue #105076.
9+
310
StructuredBuffer<float> Buf;
411

512
// CHECK: define linkonce_odr noundef ptr @"??0?$StructuredBuffer@M@hlsl@@QAA@XZ"

0 commit comments

Comments
 (0)