[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-25 Thread Tex Riddell via cfe-commits
@@ -95,6 +99,126 @@ static void initializeAlloca(CodeGenFunction &CGF, AllocaInst *AI, Value *Size, I->addAnnotationMetadata("auto-init"); } +static Value *handleHlslSplitdouble(const CallExpr *E, CodeGenFunction *CGF) { + Value *Op0 = CGF->EmitScalarExpr(E->getArg(0)); +

[clang] Add CHECK-LABEL to avoid source tree path sensitivity in test (PR #112461)

2024-10-15 Thread Tex Riddell via cfe-commits
https://github.com/tex3d created https://github.com/llvm/llvm-project/pull/112461 The test `clang/test/CodeGen/2004-02-20-Builtins.c` will erroneously fail if "builtin" is in the path to your source tree. This change adds a `CHECK-LABEL !llvm.ident` after the `CHECK-NOT` to avoid searching in

[clang] Emit constrained atan2 intrinsic for clang builtin (PR #113636)

2024-11-06 Thread Tex Riddell via cfe-commits
https://github.com/tex3d updated https://github.com/llvm/llvm-project/pull/113636 >From a6776121bb118fe4083ccb94fa582cca1aef7f9b Mon Sep 17 00:00:00 2001 From: Tex Riddell Date: Tue, 15 Oct 2024 16:18:44 -0700 Subject: [PATCH 1/3] Emit constrained atan2 intrinsic for clang builtin This change

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -343,27 +336,224 @@ struct TemplateParameterListBuilder { Params.clear(); QualType T = Builder.Template->getInjectedClassNameSpecialization(); -T = S.Context.getInjectedClassNameType(Builder.Record, T); +T = AST.getInjectedClassNameType(Builder.Record, T);

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -2161,6 +2186,22 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_buffer_update_counter: { +if (SemaRef.checkArgCount(TheCall, 2) || +CheckResourceHandle(&Sema

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -1880,6 +1880,31 @@ static bool CheckVectorSelect(Sema *S, CallExpr *TheCall) { return false; } +static bool CheckResourceHandle(Sema *S, CallExpr *TheCall, unsigned ArgIndex) { + assert(TheCall->getNumArgs() >= ArgIndex); + QualType ArgType = TheCall->getArg(ArgIndex

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -2161,6 +2186,22 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_buffer_update_counter: { +if (SemaRef.checkArgCount(TheCall, 2) || +CheckResourceHandle(&Sema

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -553,3 +748,20 @@ void HLSLExternalSemaSource::CompleteType(TagDecl *Tag) { return; It->second(Record); } + +static FunctionDecl *lookupBuiltinFunction(Sema &S, StringRef Name) { + IdentifierInfo &II = + S.getASTContext().Idents.get(Name, tok::TokenKind::identifi

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -343,27 +336,224 @@ struct TemplateParameterListBuilder { Params.clear(); QualType T = Builder.Template->getInjectedClassNameSpecialization(); -T = S.Context.getInjectedClassNameType(Builder.Record, T); +T = AST.getInjectedClassNameType(Builder.Record, T);

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
https://github.com/tex3d deleted https://github.com/llvm/llvm-project/pull/114148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
https://github.com/tex3d deleted https://github.com/llvm/llvm-project/pull/114148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -2161,6 +2186,22 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_buffer_update_counter: { +if (SemaRef.checkArgCount(TheCall, 2) || +CheckResourceHandle(&Sema

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -553,3 +748,20 @@ void HLSLExternalSemaSource::CompleteType(TagDecl *Tag) { return; It->second(Record); } + +static FunctionDecl *lookupBuiltinFunction(Sema &S, StringRef Name) { + IdentifierInfo &II = + S.getASTContext().Idents.get(Name, tok::TokenKind::identifi

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -emit-llvm-only -disable-llvm-passes -verify + +using handle_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(int)]]; tex3d wrote:

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -35,6 +35,9 @@ def int_dx_typedBufferLoad_checkbit def int_dx_typedBufferStore : DefaultAttrsIntrinsic<[], [llvm_any_ty, llvm_i32_ty, llvm_anyvector_ty]>; +def int_dx_bufferUpdateCounter +: DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_i32_ty], [IntrWrite

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-07 Thread Tex Riddell via cfe-commits
@@ -343,27 +336,224 @@ struct TemplateParameterListBuilder { Params.clear(); QualType T = Builder.Template->getInjectedClassNameSpecialization(); -T = S.Context.getInjectedClassNameType(Builder.Record, T); +T = AST.getInjectedClassNameType(Builder.Record, T);

[clang] [HLSL] Implement SV_GroupID semantic (PR #115911)

2024-11-25 Thread Tex Riddell via cfe-commits
https://github.com/tex3d approved this pull request. I think this will do for now, since most of this will have to be reworked for general semantics support anyway. https://github.com/llvm/llvm-project/pull/115911 ___ cfe-commits mailing list cfe-comm

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-25 Thread Tex Riddell via cfe-commits
@@ -271,53 +246,70 @@ struct BuiltinTypeDeclBuilder { return *this; } + FieldDecl *getResourceHandleField() { +FieldDecl *FD = Fields["h"]; tex3d wrote: I thought `lookup` was right: https://github.com/llvm/llvm-project/blob/30af6fb163add17a6be5152

[clang] Emit constrained atan2 intrinsic for clang builtin (PR #113636)

2024-11-08 Thread Tex Riddell via cfe-commits
https://github.com/tex3d edited https://github.com/llvm/llvm-project/pull/113636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Forward arguments in BuiltinTypeMethodBuilder::callBuiltin. NFC (PR #117789)

2024-11-26 Thread Tex Riddell via cfe-commits
https://github.com/tex3d approved this pull request. Looks good. https://github.com/llvm/llvm-project/pull/117789 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Forward arguments in BuiltinTypeMethodBuilder::callBuiltin. NFC (PR #117789)

2024-11-26 Thread Tex Riddell via cfe-commits
@@ -564,9 +585,9 @@ struct BuiltinTypeMethodBuilder { OK_Ordinary); } - BuiltinTypeMethodBuilder & - callBuiltin(StringRef BuiltinName, ArrayRef CallParms, - bool AddResourceHandleAsFirstArg = true) { + template + Built

[clang] [HLSL] Implement SV_GroupID semantic (PR #115911)

2024-11-26 Thread Tex Riddell via cfe-commits
https://github.com/tex3d closed https://github.com/llvm/llvm-project/pull/115911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][HLSL] Allow target intrinsic switching to optionally be set. (PR #117648)

2024-12-02 Thread Tex Riddell via cfe-commits
https://github.com/tex3d approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/117648 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

2024-12-04 Thread Tex Riddell via cfe-commits
@@ -49,3 +49,28 @@ void CSMain3_GID(uint3 : SV_GroupID) { // CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:24 'uint3' // CHECK-NEXT: HLSLSV_GroupIDAttr } + +[numthreads(8,8,1)] +void CSMain_GThreadID(uint ID : SV_GroupThreadID) { +// CHECK: FunctionDecl 0x{{[0-9a-fA-F

[clang] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

2024-12-04 Thread Tex Riddell via cfe-commits
@@ -2,15 +2,18 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-mesh -hlsl-entry CSMain -x hlsl -finclude-default-header -verify -o - %s [numthreads(8,8,1)] -// expected-error@+3 {{attribute 'SV_GroupIndex' is unsupported in 'mesh' shaders, requires compute}} -// expect

[clang] [llvm] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

2024-12-09 Thread Tex Riddell via cfe-commits
https://github.com/tex3d approved this pull request. I think it's good, with minor nit about unnecessary comments. https://github.com/llvm/llvm-project/pull/117781 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] [llvm] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

2024-12-09 Thread Tex Riddell via cfe-commits
@@ -2851,7 +2851,21 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, .constrainAllUses(TII, TRI, RBI); break; case Intrinsic::spv_thread_id: -return selectSpvThreadId(ResVReg, ResType, I); +// The HLSL SV_DispatchThreadID semantic is

[clang] [llvm] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

2024-12-06 Thread Tex Riddell via cfe-commits
@@ -3606,6 +3613,32 @@ bool SPIRVInstructionSelector::selectSpvThreadId(Register ResVReg, return Result && MIB.constrainAllUses(TII, TRI, RBI); } +bool SPIRVInstructionSelector::selectSpvThreadId(Register ResVReg, + const SPIR

[clang] [llvm] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

2024-12-06 Thread Tex Riddell via cfe-commits
@@ -3606,6 +3613,32 @@ bool SPIRVInstructionSelector::selectSpvThreadId(Register ResVReg, return Result && MIB.constrainAllUses(TII, TRI, RBI); } +bool SPIRVInstructionSelector::selectSpvThreadId(Register ResVReg, + const SPIR

[clang] [llvm] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

2024-12-06 Thread Tex Riddell via cfe-commits
@@ -3606,6 +3613,32 @@ bool SPIRVInstructionSelector::selectSpvThreadId(Register ResVReg, return Result && MIB.constrainAllUses(TII, TRI, RBI); } +bool SPIRVInstructionSelector::selectSpvThreadId(Register ResVReg, + const SPIR

[clang] [HLSL] cbuffer: Create host layout structs (PR #122820)

2025-01-22 Thread Tex Riddell via cfe-commits
@@ -253,12 +257,229 @@ static void validatePackoffset(Sema &S, HLSLBufferDecl *BufDecl) { } } +// Returns true if the array has a zero size = if any of the dimensions is 0 +static bool isZeroSizedArray(const ConstantArrayType *CAT) { + while (CAT && !CAT->isZeroSize()) +

[clang] [HLSL] cbuffer: Create host layout structs (PR #122820)

2025-01-22 Thread Tex Riddell via cfe-commits
@@ -253,12 +257,229 @@ static void validatePackoffset(Sema &S, HLSLBufferDecl *BufDecl) { } } +// Returns true if the array has a zero size = if any of the dimensions is 0 +static bool isZeroSizedArray(const ConstantArrayType *CAT) { + while (CAT && !CAT->isZeroSize()) +

[clang] [HLSL] cbuffer: Create host layout structs (PR #122820)

2025-01-22 Thread Tex Riddell via cfe-commits
@@ -253,12 +257,229 @@ static void validatePackoffset(Sema &S, HLSLBufferDecl *BufDecl) { } } +// Returns true if the array has a zero size = if any of the dimensions is 0 +static bool isZeroSizedArray(const ConstantArrayType *CAT) { + while (CAT && !CAT->isZeroSize()) +

[clang] [HLSL] cbuffer: Create host layout structs (PR #122820)

2025-01-23 Thread Tex Riddell via cfe-commits
@@ -253,12 +257,229 @@ static void validatePackoffset(Sema &S, HLSLBufferDecl *BufDecl) { } } +// Returns true if the array has a zero size = if any of the dimensions is 0 +static bool isZeroSizedArray(const ConstantArrayType *CAT) { + while (CAT && !CAT->isZeroSize()) +

[clang] [HLSL] Make memory representation of boolean vectors in HLSL, vectors of i32. Add support for boolean swizzling. (PR #123977)

2025-02-12 Thread Tex Riddell via cfe-commits
@@ -110,6 +131,24 @@ float2 HowManyFloats(float V) { return V.rr.rr; } +// CHECK-LABEL: HowManyBools +// CHECK: [[VAddr:%.*]] = alloca i32, align 4 +// CHECK-NEXT: [[Vec2Ptr:%.*]] = alloca <2 x i32>, align 8 +// CHECK-NEXT: [[Tmp:%.*]] = zext i1 {{.*}} to i32 +// CHECK-NEXT:

[clang] [HLSL] Implement HLSL intialization list support (PR #123141)

2025-02-12 Thread Tex Riddell via cfe-commits
https://github.com/tex3d commented: This is interesting. I wonder though what it looks like in the AST when initializing something with the result of a function call that return an aggregate that must be split up across different boundaries? Or what about expressions with side-effects? How

[clang] [HLSL] Implement HLSL intialization list support (PR #123141)

2025-02-12 Thread Tex Riddell via cfe-commits
tex3d wrote: > How does it not duplicate sub-expressions while also not creating temporary > variables to capture results? The way I thought of to comprehensively solve this in a clear general way was to: - create a new temporary with an anonymous struct type containing the exact sequence of

[clang] [HLSL][Sema] Fix Struct Size Calculation containing 16/32 bit scalars (PR #128086)

2025-02-24 Thread Tex Riddell via cfe-commits
https://github.com/tex3d approved this pull request. Looks good! https://github.com/llvm/llvm-project/pull/128086 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL][Sema] Fix Struct Size Calculation containing 16/32 bit scalars (PR #128086)

2025-02-24 Thread Tex Riddell via cfe-commits
@@ -172,6 +172,23 @@ Decl *SemaHLSL::ActOnStartBuffer(Scope *BufferScope, bool CBuffer, return Result; } +static unsigned calculateLegacyCbufferFieldAlign(const ASTContext &Context, + QualType T) { + // Arrays and Structs are

[clang] [HLSL][Sema] Fix Struct Size Calculation containing 16/32 bit scalars (PR #128086)

2025-02-25 Thread Tex Riddell via cfe-commits
@@ -172,6 +172,23 @@ Decl *SemaHLSL::ActOnStartBuffer(Scope *BufferScope, bool CBuffer, return Result; } +static unsigned calculateLegacyCbufferFieldAlign(const ASTContext &Context, + QualType T) { + // Arrays and Structs are

[clang] [llvm] [HLSL][NFC] Update resource metadata tests to not use obsolete annotations (PR #130222)

2025-03-11 Thread Tex Riddell via cfe-commits
https://github.com/tex3d approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/130222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][NFC] Update resource metadata tests to not use obsolete annotations (PR #130222)

2025-03-11 Thread Tex Riddell via cfe-commits
https://github.com/tex3d unassigned https://github.com/llvm/llvm-project/pull/130222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

<    1   2