[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)

2024-09-05 Thread Justin Bogner via cfe-commits
@@ -556,46 +562,120 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } -void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) { - if (!AL.isArgIdent(0)) { -Diag(AL.getLoc(), diag::err_attribute_argument_type) -

[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)

2024-09-05 Thread Justin Bogner via cfe-commits
@@ -559,46 +563,123 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } -void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) { - if (!AL.isArgIdent(0)) { -Diag(AL.getLoc(), diag::err_attribute_argument_type) -

[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)

2024-09-05 Thread Justin Bogner via cfe-commits
@@ -559,46 +563,123 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } -void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) { - if (!AL.isArgIdent(0)) { -Diag(AL.getLoc(), diag::err_attribute_argument_type) -

[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)

2024-09-05 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. A couple more very minor comments then this LGTM! https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -387,6 +387,23 @@ float3 asin(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) float4 asin(float4); +//===--===// +// asuint builtins +//===--

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner edited https://github.com/llvm/llvm-project/pull/107292 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner commented: This is going in the right direction but the tests need some work. I made a couple of comments to point you in the right direction. We also need to make sure we're testing all of the cases we care about, so we need tests with inputs of `int`, `uint`, vector

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s bogner wrote: It's probably better if we remove the `-disable-llvm-passes` and

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -387,6 +387,23 @@ float3 asin(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) float4 asin(float4); +//===--===// +// asuint builtins +//===--

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: test_asuint4_uint +// CHECK: ret i32 %0 +export uint test_asuint4_uint(uint

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: test_asuint4_uint +// CHECK: ret i32 %0 +export uint test_asuint4_uint(uint

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: test_asuint4_uint +// CHECK: ret i32 %0 +export uint test_asuint4_uint(uint

[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK + +// CHECK: %hlsl.select = select i1 +// CHECK: ret i32 %hlsl.selec

[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK + +// CHECK: %hlsl.select = select i1 +// CHECK: ret i32 %hlsl.selec

[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK + +// CHECK: %hlsl.select = select i1 +// CHECK: ret i32 %hlsl.selec

[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -1603,6 +1603,32 @@ double3 saturate(double3); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate) double4 saturate(double4); +//===--===// +// select builtins +//===---

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -2692,14 +2692,19 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { return CGF.CGM.createOpenCLIntToSamplerConversion(E, CGF); case CK_HLSLVectorTruncation: { -assert(DestTy->isVectorType() && "Expected dest type to be vector type"); +assert((DestTy->

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -2032,26 +2032,42 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, if (S.Context.hasSameUnqualifiedType(FromType, ToType)) return false; + // HLSL allows implicit truncation of vector types. + if (S.getLangOpts().HLSL) { +auto *ToE

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner edited https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -4828,18 +4830,23 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } case ICK_HLSL_Vector_Truncation: { // Note: HLSL built-in vectors are ExtVectors. Since this truncates a - // vector to a smaller vector, this can only operate on argument

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Just a few style nitpicks. LG! https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Fix implicit conversion rank ordering (PR #106811)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/106811 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -879,6 +879,10 @@ static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) { ScalableVectorType::get(Type::getInt8Ty(C), TotalNumElts)); } + // DirectX intangible types + if (Name.starts_with("dx.")) bogner wrote: Yeah, it's definitely

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,52 @@ +//===- DirectX.cpp-===// +// +// 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: Apa

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s + +void foo(__hlsl_resource_t res); + +// CHECK: define void @"?bar@@YAXU__hlsl_resource_t@@@Z"(target("dx.TypedBuffer", <4 x float>, 1, 0,

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -879,6 +879,10 @@ static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) { ScalableVectorType::get(Type::getInt8Ty(C), TotalNumElts)); } + // DirectX intangible types + if (Name.starts_with("dx.")) +return TargetTypeInfo(PointerType::get(C, 0), Ta

[clang] [llvm] Add step builtins and step HLSL function to DirectX and SPIR-V backend (PR #106471)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,33 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; Make sure SPIRV operation function calls for step are lowered correctly. + +; CHECK-D

[clang] [llvm] Add step builtins and step HLSL function to DirectX and SPIR-V backend (PR #106471)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -320,6 +321,28 @@ static Value *expandPowIntrinsic(CallInst *Orig) { return Exp2Call; } +static Value *expandStepIntrinsic(CallInst *Orig) { + + Value *X = Orig->getOperand(0); + Value *Y = Orig->getOperand(1); + Type *Ty = X->getType(); + IRBuilder<> Builder(Orig); +

[clang] [llvm] Add step builtins and step HLSL function to DirectX and SPIR-V backend (PR #106471)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,100 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_

[clang] [llvm] Add step builtins and step HLSL function to DirectX and SPIR-V backend (PR #106471)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,79 @@ +; RUN: opt -S -dxil-intrinsic-expansion < %s | FileCheck %s --check-prefix=CHECK +; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library < %s | FileCheck %s --check-prefix=CHECK + +; Make sure dxil operation function calls for step are generate

[clang] [HLSL][Docs] Update function calls docs (PR #106860)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/106860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -387,6 +387,23 @@ float3 asin(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) float4 asin(float4); +//===--===// +// asuint builtins +//===--

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-09 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected bogner wrote: I don't think we should be using `-verify-ignore-unex

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-09 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected + + +export uint4 test_asuint_too_many_arg(float p0, float p1) { + return __builtin_

[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

2024-09-09 Thread Justin Bogner via cfe-commits
https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-09 Thread Justin Bogner via cfe-commits
https://github.com/bogner edited https://github.com/llvm/llvm-project/pull/104856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-09 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/104856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-09 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,52 @@ +//===- DirectX.cpp-===// +// +// 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: Apa

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-10 Thread Justin Bogner via cfe-commits
@@ -387,6 +387,65 @@ float3 asin(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) float4 asin(float4); +//===--===// +// asuint builtins +//===--

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner edited https://github.com/llvm/llvm-project/pull/107292 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Allow narrowing in initialization lists (PR #108035)

2024-09-10 Thread Justin Bogner via cfe-commits
bogner wrote: Can we test this? https://github.com/llvm/llvm-project/pull/108035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Warn on duplicate is_rov attribute; remove unnecessary parentheses (PR #107973)

2024-09-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. It's a little awkward to do all three of these things together in one change, but it all looks simple and correct. https://github.com/llvm/llvm-project/pull/107973 ___ cfe-commits mailing list cfe-

[clang] [HLSL] Add `[[hlsl::row_access]]` attribute (PR #107954)

2024-09-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/107954 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add `[[hlsl::row_access]]` attribute (PR #107954)

2024-09-10 Thread Justin Bogner via cfe-commits
@@ -6169,9 +6169,13 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode { // Data gathered from HLSL resource attributes llvm::dxil::ResourceClass ResourceClass; uint8_t IsROV : 1; -Attributes(llvm::dxil::ResourceClass ResourceClass,

[clang] [HLSL] Add `[[hlsl::row_access]]` attribute (PR #107954)

2024-09-10 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify + +// expected-error@+1{{'row_access' attribute cannot be applied to a declaration}} +[[hlsl::row_access]] __hlsl_resource_t res0; + +// expected-error@+1{{HLSL resource needs to

[clang] [HLSL] Add `[[hlsl::row_access]]` attribute (PR #107954)

2024-09-10 Thread Justin Bogner via cfe-commits
@@ -6169,9 +6169,13 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode { // Data gathered from HLSL resource attributes llvm::dxil::ResourceClass ResourceClass; uint8_t IsROV : 1; -Attributes(llvm::dxil::ResourceClass ResourceClass,

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC] [HLSL] Update test for HLSL 202x (PR #108097)

2024-09-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/108097 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Split out the ROV attribute from the resource attribute, make it a new spellable attribute. (PR #102414)

2024-08-12 Thread Justin Bogner via cfe-commits
@@ -296,12 +296,13 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) { for (auto *FD : RD->fields()) { const auto *HLSLResAttr = FD->getAttr(); const auto *HLSLResClassAttr = FD->getAttr(); +const auto *ROVAttr = FD->getAttr();

[clang] [HLSL] Split out the ROV attribute from the resource attribute, make it a new spellable attribute. (PR #102414)

2024-08-12 Thread Justin Bogner via cfe-commits
@@ -116,12 +116,17 @@ struct BuiltinTypeDeclBuilder { QualType(TTD->getTypeForDecl(), 0)); } // add handle member -llvm::SmallVector Attrs; Attr *ResourceClassAttr = HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC); A

[clang] Create Texture Dimension attribute in HLSL (PR #104239)

2024-08-14 Thread Justin Bogner via cfe-commits
bogner wrote: What is this attribute supposed to mean? I think we need some design here before we create the attribute, as it isn't clear to me that a single integer covers our needs. The texture kinds that need to be representable by this and whatever other attributes we design are 1D, 2D, 3D

[clang] [llvm] Remove unused variable, and unneeded extract element instruction (PR #103489)

2024-08-14 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/103489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Create Texture Dimension attribute in HLSL (PR #104239)

2024-08-15 Thread Justin Bogner via cfe-commits
bogner wrote: > You're right, a single integer won't be able to match to all those dimension > kinds. I propose we make an enum, much like llvm::ResourceKind, called > TextureDimensionKind, that enumerates all the texture kinds you listed above. > Then I can make the attribute take a single en

[clang] [HLSL] Flesh out basic type typedefs (PR #104479)

2024-08-15 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/104479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][DXIL][SPIRV] Implementation of an abstraction for intrinsic selection of HLSL backends (PR #87171)

2024-04-04 Thread Justin Bogner via cfe-commits
bogner wrote: The `GENERATE_HLSL_INTRINSIC_FUNCTION` abstraction parts of this look fairly reasonable, but do we really want/need dx and spirv intrinsics for the "all" function? This is trivial to generate pretty generic IR for and I don't really see the value of maintaining that the user wrot

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -7367,8 +7367,72 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, return; } - // FIXME: check reg type match decl. Issue - // https://github.com/llvm/llvm-project/issues/57886. + VarDecl *VD = dyn_cast(D); + HLSLBufferDecl *BD = dyn_cast(D); + + if

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -482,15 +484,18 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, bool IsROV) { return BuiltinTypeDeclBuilder(Decl) .addHandleMember() - .addDefaultHandleConstructor(S, RC) - .annot

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -7333,12 +7333,12 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, } else { Slot = Str; } - + QualType Ty = ((clang::ValueDecl *)D)->getType(); bogner wrote: LLVM avoids C-style casting. This would normally be spelled `QualType QT =

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -119,8 +119,10 @@ struct BuiltinTypeDeclBuilder { ResourceKind RK, bool IsROV) { if (Record->isCompleteDefinition()) return *this; -Record->addAttr(HLSLResourceAttr::CreateImplicit(Record->getASTContext(), -

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -7367,8 +7367,72 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, return; } - // FIXME: check reg type match decl. Issue - // https://github.com/llvm/llvm-project/issues/57886. + VarDecl *VD = dyn_cast(D); + HLSLBufferDecl *BD = dyn_cast(D); + + if

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -7367,8 +7367,72 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, return; } - // FIXME: check reg type match decl. Issue - // https://github.com/llvm/llvm-project/issues/57886. + VarDecl *VD = dyn_cast(D); + HLSLBufferDecl *BD = dyn_cast(D); + + if

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -7367,8 +7367,72 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, return; } - // FIXME: check reg type match decl. Issue - // https://github.com/llvm/llvm-project/issues/57886. + VarDecl *VD = dyn_cast(D); + HLSLBufferDecl *BD = dyn_cast(D); + + if

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -7367,8 +7367,72 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, return; } - // FIXME: check reg type match decl. Issue - // https://github.com/llvm/llvm-project/issues/57886. + VarDecl *VD = dyn_cast(D); + HLSLBufferDecl *BD = dyn_cast(D); + + if

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-10 Thread Justin Bogner via cfe-commits
@@ -7367,8 +7367,72 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, return; } - // FIXME: check reg type match decl. Issue - // https://github.com/llvm/llvm-project/issues/57886. + VarDecl *VD = dyn_cast(D); + HLSLBufferDecl *BD = dyn_cast(D); + + if

[clang] [HLSL] Remove an unnecessary .ll file in clang/test/SemaHLSL/. (PR #87346)

2024-04-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/87346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][NFC] Move more functions to `SemaHLSL` (PR #88354)

2024-04-11 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/88354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Strict Availability Diagnostics (PR #93860)

2024-06-11 Thread Justin Bogner via cfe-commits
@@ -834,34 +841,41 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability( OffendingDecl)) return; -// We would like to emit the diagnostic even if -Wunguarded-availability is -// not specified for deployment

[clang] [HLSL] Fix FileCheck annotation typos (PR #95155)

2024-06-11 Thread Justin Bogner via cfe-commits
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/95155 These are the HLSL specific fixes from #93193. Thanks @klensy! >From ef5fbb85ba550c1baefc6357e118f339e6d7d5bd Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 11 Jun 2024 10:48:30 -0700 Subject: [PATCH] [H

[clang] [HLSL] Fix FileCheck annotation typos (PR #95155)

2024-06-11 Thread Justin Bogner via cfe-commits
@@ -4,9 +4,8 @@ void test() { // CHECK: VarDecl {{.*}} used f3 'vector':'float __attribute__((ext_vector_type(3)))' cinit - // CHECK-NEXt: ImplicitCastExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(3)))' - // CHECK-NEXt: ImplicitCastExpr {{.*}} 'float' -

[clang] [HLSL] Fix FileCheck annotation typos (PR #95155)

2024-06-11 Thread Justin Bogner via cfe-commits
@@ -4,9 +4,8 @@ void test() { // CHECK: VarDecl {{.*}} used f3 'vector':'float __attribute__((ext_vector_type(3)))' cinit - // CHECK-NEXt: ImplicitCastExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(3)))' - // CHECK-NEXt: ImplicitCastExpr {{.*}} 'float' -

[clang] [HLSL] Fix FileCheck annotation typos (PR #95155)

2024-06-11 Thread Justin Bogner via cfe-commits
https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/95155 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Use hlsl vector template in type printer (PR #95489)

2024-06-14 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/95489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][clang] Add elementwise builtins for trig intrinsics (PR #95999)

2024-06-19 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/95999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] Move ResourceClass enum into DXILABI. NFC (PR #96335)

2024-06-21 Thread Justin Bogner via cfe-commits
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/96335 The resource class isn't HLSL specific, and we'll need to use it in the DirectX backend as well. I've also removed the "invalid" enum value since it isn't needed or used, which necessitates fixing up the clang a

[clang] [llvm] [DirectX] Move ResourceClass enum into DXILABI. NFC (PR #96335)

2024-06-21 Thread Justin Bogner via cfe-commits
https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/96335 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-21 Thread Justin Bogner via cfe-commits
https://github.com/bogner edited https://github.com/llvm/llvm-project/pull/96346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-21 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify + +// previously, this test would result in an error shown below on the line that +// declares variable a in struct Eg9: +// error: use of undeclared identifier +// 'SV_Dispat

[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-21 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify + +// previously, this test would result in an error shown below on the line that +// declares variable a in struct Eg9: +// error: use of undeclared identifier +// 'SV_Dispat

[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-21 Thread Justin Bogner via cfe-commits
https://github.com/bogner commented: Please add some tests that show that we still handle bitfields correctly in HLSL with this change. https://github.com/llvm/llvm-project/pull/96346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] cc1: Report an error for multiple actions unless separated by -main-file-name (PR #91140)

2024-05-28 Thread Justin Bogner via cfe-commits
bogner wrote: > > I don't really understand the rationale for this, and it's kind of > > annoying. Most of the compiler's flags behave in the "last one wins" > > fashion (such as `-O2` and `-O0`) and it's always been convenient to add > > the flag you want at the end. Why treat action flags an

[clang] [HLSL] Use llvm::Triple::EnvironmentType instead of HLSLShaderAttr::ShaderType (PR #93847)

2024-05-30 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/93847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Strict Availability Diagnostics (PR #93860)

2024-05-31 Thread Justin Bogner via cfe-commits
@@ -834,34 +829,55 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability( OffendingDecl)) return; -// We would like to emit the diagnostic even if -Wunguarded-availability is -// not specified for deployment

[clang] [HLSL] add loop unroll (PR #93879)

2024-06-03 Thread Justin Bogner via cfe-commits
https://github.com/bogner edited https://github.com/llvm/llvm-project/pull/93879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] add loop unroll (PR #93879)

2024-06-03 Thread Justin Bogner via cfe-commits
@@ -114,18 +114,21 @@ Parser::ParseStatementOrDeclaration(StmtVector &Stmts, // here because we don't want to allow arbitrary orderings. ParsedAttributes CXX11Attrs(AttrFactory); MaybeParseCXX11Attributes(CXX11Attrs, /*MightBeObjCMessageSend*/ true); - ParsedAttributes G

[clang] [HLSL] add loop unroll (PR #93879)

2024-06-03 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/93879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-16 Thread Justin Bogner via cfe-commits
bogner wrote: Looks like this missed a spot, causing the .hlsl to spir-v tests to fail. I've put up a fix in #88939 https://github.com/llvm/llvm-project/pull/88455 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/

[clang] [clang][SPIR-V] Set AS for the SPIR-V logical triple (PR #88939)

2024-04-16 Thread Justin Bogner via cfe-commits
bogner wrote: > a) Thanks!; b) apologies for the noise; c) this was actually done on purpose, > I actively eschewed changing Logical SPIRV because it wasn't actually clear > to me if in the long run it'd have the same AS map / would use numerical 1 > for globals. If Logical SPIRV is going to g

[clang] [clang][SPIR-V] Set AS for the SPIR-V logical triple (PR #88939)

2024-04-16 Thread Justin Bogner via cfe-commits
https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/88939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC] Rename hlsl semantics to hlsl annotations (PR #89309)

2024-04-18 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/89309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SPIRV][HLSL] Add mad intrinsic lowering for spirv (PR #89130)

2024-04-18 Thread Justin Bogner via cfe-commits
bogner wrote: This feels complicated and not very scalable. I don't think we should be implementing ad-hoc vtables via a map of function pointers. It might be worth sketching out a design for an API that can handle the various cases we're running into here. We need to be able to handle (1) ope

[clang] [llvm] [SPIRV][HLSL] Add mad intrinsic lowering for spirv (PR #89130)

2024-04-18 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Yeah, this is definitely better. https://github.com/llvm/llvm-project/pull/89130 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SPIR-V] Always add convervence intrinsics (PR #88918)

2024-04-22 Thread Justin Bogner via cfe-commits
Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= Message-ID: In-Reply-To: @@ -3101,3 +3130,68 @@ CodeGenFunction::GenerateCapturedStmtFunction(const CapturedStmt &S) { return F; } + +namespace { +// Returns the first convergence entry/loop/anchor instruction found in

[clang] [clang][SPIR-V] Always add convervence intrinsics (PR #88918)

2024-04-22 Thread Justin Bogner via cfe-commits
Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= Message-ID: In-Reply-To: @@ -3101,3 +3130,68 @@ CodeGenFunction::GenerateCapturedStmtFunction(const CapturedStmt &S) { return F; } + +namespace { +// Returns the first convergence entry/loop/anchor instruction found in

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-22 Thread Justin Bogner via cfe-commits
@@ -7334,6 +7334,81 @@ static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } +static void DiagnoseHLSLResourceRegType(Sema &S, SourceLocation &ArgLoc, +Decl *D, StringRef &Slot) { + // Sa

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-22 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,74 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify + +// the below will cause an llvm unreachable, because RWBuffers don't have resource attributes yet +// NOT YET IMPLEMENTED : {{invalid register name prefix 'b' for

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-22 Thread Justin Bogner via cfe-commits
@@ -478,33 +478,35 @@ void HLSLExternalSemaSource::defineTrivialHLSLTypes() { /// Set up common members and attributes for buffer types static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, - ResourceClass RC,

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-22 Thread Justin Bogner via cfe-commits
@@ -45,7 +45,7 @@ void foo2() { extern RWBuffer U2 : register(u5); } // FIXME: expect-error once fix https://github.com/llvm/llvm-project/issues/57886. -float b : register(u0, space1); +// float b : register(u0, space1) {} bogner wrote: Shouldn't we be addi

[clang] Implement resource binding type prefix mismatch errors (PR #87578)

2024-04-22 Thread Justin Bogner via cfe-commits
@@ -7334,6 +7334,81 @@ static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } +static void DiagnoseHLSLResourceRegType(Sema &S, SourceLocation &ArgLoc, +Decl *D, StringRef &Slot) { + // Sa

[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-22 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,44 @@ +set(LLVM_LINK_COMPONENTS + ${LLVM_TARGETS_TO_BUILD} + BitWriter + Core + BinaryFormat + MC + Target + TransformUtils + Analysis + Passes + IRReader + Object + Option + Support + TargetParser + CodeGen + LTO + ) + +set(LLVM_TARGET_DEFINITIONS NVLi

<    1   2   3   4   5   6   7   8   9   >