[clang] [llvm] [HLSL] Use hlsl_device address space for getpointer. (PR #127675)

2025-04-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/127675 >From acd00a62efc6ca58311800caffe1e46735f8cc57 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Wed, 12 Feb 2025 15:45:32 -0500 Subject: [PATCH] [HLSL] Use hlsl_device address space for getpointer. We add th

[clang] [HLSL] Add support for SV_GroupIndex in SPIR-V (PR #130672)

2025-04-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/130672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][SPIR-V] Add hlsl_private address space for SPIR-V (PR #133464)

2025-04-03 Thread Steven Perron via cfe-commits
Nathan =?utf-8?q?Gau=C3=ABr?= , Nathan =?utf-8?q?Gau=C3=ABr?= Message-ID: In-Reply-To: https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/133464 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

[clang] [llvm] [HLSL] Run finalize linkage pass for all targets (PR #134260)

2025-04-03 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/134260 HLSL has three levels of visibility for functions. See section 3.6 of the [HLSL spec](https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf) for details. 1. Functions marked `static` have internal linkage. Thes

[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)

2025-03-31 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/133469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][SPIR-V] Add hlsl_private address space for SPIR-V (PR #133464)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/133464 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][SPIR-V] Add hlsl_private address space for SPIR-V (PR #133464)

2025-03-28 Thread Steven Perron via cfe-commits
@@ -94,6 +94,8 @@ bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, (A == LangAS::Default && (B == LangAS::cuda_constant || B == LangAS::cuda_device || B == LangAS::cuda_shared)) || + // Default is a superset of HLSL priv

[clang] [llvm] [HLSL][SPIR-V] Add hlsl_private address space for SPIR-V (PR #133464)

2025-03-28 Thread Steven Perron via cfe-commits
@@ -5150,6 +5152,9 @@ bool Type::isHLSLIntangibleType() const { CXXRecordDecl *RD = RT->getAsCXXRecordDecl(); assert(RD != nullptr && "all HLSL structs and classes should be CXXRecordDecl"); + + if (!RD->isCompleteDefinition()) +return false; assert(RD->isC

[clang] [llvm] [HLSL][SPIR-V] Add hlsl_private address space for SPIR-V (PR #133464)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron commented: Please add more AST tests. You seem to only have one, which is the static in a cbuffer. I believe all of the AST work should be correct at this point. Can you test global scalars, global struct with member functions, etc.. Make the sure AST is correct in

[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/133469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron commented: The changes look correct, but I want to double check that they are complete. https://github.com/llvm/llvm-project/pull/133469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)

2025-03-28 Thread Steven Perron via cfe-commits
@@ -57,22 +58,37 @@ void main(unsigned GI : SV_GroupIndex) { // CHECK: define void @main() // CHECK-NEXT: entry: // Verify destructor is emitted -// NOINLINE-NEXT: call void @_GLOBAL__sub_I_GlobalDestructors.hlsl() -// NOINLINE-NEXT: %0 = call i32 @llvm.dx.flattened.th

[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #133468)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/133468 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #133468)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/133468 >From 7838678ca8ec5870cd8df81b109f9e1b30699f4e Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Fri, 24 Jan 2025 13:04:29 -0500 Subject: [PATCH 1/2] [HLSL] Add SPIR-V target type for RWStructuredBuffers This

[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #133468)

2025-03-28 Thread Steven Perron via cfe-commits
@@ -386,13 +386,22 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType( if (ContainedTy.isNull()) return nullptr; -assert(!ResAttrs.RawBuffer && - "Raw buffers handles are not implemented for SPIR-V yet"); assert(!ResAttrs.IsROV &&

[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #133468)

2025-03-28 Thread Steven Perron via cfe-commits
@@ -386,13 +386,22 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType( if (ContainedTy.isNull()) return nullptr; -assert(!ResAttrs.RawBuffer && - "Raw buffers handles are not implemented for SPIR-V yet"); assert(!ResAttrs.IsROV &&

[clang] [llvm] [HLSL] Add SPIR-V target type for StructuredBuffers (PR #132027)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/132027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #133468)

2025-03-28 Thread Steven Perron via cfe-commits
s-perron wrote: FYI: @cassiebeckley can you review too? https://github.com/llvm/llvm-project/pull/133468 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #133468)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/133468 This PR adds the target type for main storage for HLSL raw buffer types. It does not handle the counter variables that are associated with those buffers. This is implementing part of https://github.com/llvm/wg

[clang] [llvm] [SPIRV] Emit HLSL structured buffers (PR #132034)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/132034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add __spirv__ macro (PR #132848)

2025-03-28 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/132848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add __spirv__ macro (PR #132848)

2025-03-26 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. This is useful because to will match the DXC behaviour, and make code more easier to port. Even if we have `__SPIRV__` is to good to have `__spirv__`. https://github.com/llvm/llvm-project/pull/132848 ___

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. The SPV code looks good to me. I just want one small suggestion. https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Steven Perron via cfe-commits
@@ -0,0 +1,60 @@ +; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} s-perron wrote: I would like to start having the

[clang] [llvm] [HLSL] Add SPIR-V target type for StructuredBuffers (PR #132027)

2025-03-25 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/132027 >From 78348586c0b237db689b669fcf4352e6b42898a1 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Wed, 12 Feb 2025 15:45:32 -0500 Subject: [PATCH 1/3] [HLSL] Use hlsl_device address space for getpointer. We ad

[clang] [HLSL] Add __spirv__ macro (PR #132848)

2025-03-25 Thread Steven Perron via cfe-commits
https://github.com/s-perron commented: Thanks. I was thinking of adding this myself, but it was pushed off. I don't know the best place to put it. I'll let others who know the FE review. https://github.com/llvm/llvm-project/pull/132848 ___ cfe-commits

[clang] [llvm] [HLSL] Use hlsl_device address space for getpointer. (PR #127675)

2025-03-20 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/127675 >From 78348586c0b237db689b669fcf4352e6b42898a1 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Wed, 12 Feb 2025 15:45:32 -0500 Subject: [PATCH] [HLSL] Use hlsl_device address space for getpointer. We add th

[clang] [llvm] [SPIRV] Emit HLSL structured buffers (PR #132034)

2025-03-19 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/132034 >From d56c4165207aaf1b14802f115a0706e189571c4f Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Fri, 24 Jan 2025 13:04:29 -0500 Subject: [PATCH 1/5] [HLSL] Add SPIR-V target type for RWStructuredBuffers This

[clang] [llvm] [SPIRV] Emit HLSL structured buffers (PR #132034)

2025-03-19 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/132034 >From d56c4165207aaf1b14802f115a0706e189571c4f Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Fri, 24 Jan 2025 13:04:29 -0500 Subject: [PATCH 1/4] [HLSL] Add SPIR-V target type for RWStructuredBuffers This

[clang] [HLSL] Add SPIR-V target type for StructuredBuffers (PR #132027)

2025-03-19 Thread Steven Perron via cfe-commits
https://github.com/s-perron converted_to_draft https://github.com/llvm/llvm-project/pull/132027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #132027)

2025-03-19 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/132027 This PR adds the target type that should be used for RWStructuredBuffers. It does not handle ByteAddressBuffers yet. For now all structs will be laid out using the standard C/C++ layout rules. Other layout rule

[clang] [HLSL] Add support for SV_GroupIndex in SPIR-V (PR #130672)

2025-03-17 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/130672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add support for SV_GroupIndex in SPIR-V (PR #130672)

2025-03-17 Thread Steven Perron via cfe-commits
@@ -1,7 +1,8 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - -hlsl-entry main %s

[clang] [HLSL] Buffer handle globals should not be constants (PR #130231)

2025-03-17 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/130231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Fix resource wrapper declaration (PR #129100)

2025-03-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/129100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Fix resource wrapper declaration (PR #129100)

2025-03-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/129100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Fix resrouce wrapper declaration (PR #129100)

2025-03-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/129100 >From 1e794cd4b79235282795891f943f8f4609738d4f Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Tue, 4 Feb 2025 11:47:42 -0500 Subject: [PATCH 1/6] [HLSL] Fix resrouce wrapper declaration The resource wrappe

[clang] [HLSL] Fix resrouce wrapper declaration (PR #129100)

2025-03-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/129100 >From 6961d5683a4bc38c2fee053bc956475d0ccb0b80 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Tue, 4 Feb 2025 11:47:42 -0500 Subject: [PATCH 1/6] [HLSL] Fix resrouce wrapper declaration The resource wrappe

[clang] [HLSL] Fix resrouce wrapper declaration (PR #129100)

2025-02-27 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/129100 >From 6961d5683a4bc38c2fee053bc956475d0ccb0b80 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Tue, 4 Feb 2025 11:47:42 -0500 Subject: [PATCH 1/2] [HLSL] Fix resrouce wrapper declaration The resource wrappe

[clang] [HLSL] Fix resrouce wrapper declaration (PR #129100)

2025-02-27 Thread Steven Perron via cfe-commits
s-perron wrote: I created a new PR to make the resource wrappers static. @hekota Was right. Not much needed to change in codegen. We were already initializing all global (internal or external) that have the resource binding attribute. I must have been testing the wrong examples when I said cod

[clang] [HLSL] Fix resrouce wrapper declaration (PR #129100)

2025-02-27 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/129100 The resource wrapper should have internal linkage because it contains a handle to the global resource, and it not the actual global. Makeing this changed exposed that we were zeroinitializing the resouce, which

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-26 Thread Steven Perron via cfe-commits
s-perron wrote: We discussed, and we will be make the wrapper static, but it should be done in sema. https://github.com/llvm/llvm-project/pull/125718 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-26 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/125718 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Use hlsl_device address space for getpointer. (PR #127675)

2025-02-19 Thread Steven Perron via cfe-commits
@@ -94,6 +94,11 @@ bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, (A == LangAS::Default && (B == LangAS::cuda_constant || B == LangAS::cuda_device || B == LangAS::cuda_shared)) || + // In HLSL, the this pointer for mem

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-18 Thread Steven Perron via cfe-commits
s-perron wrote: > 2\. It feels wrong to do this in CodeGen. It seems like we should be > identifying an appropriate storage class in Sema such that we assign the > correct linkage automatically. If we change the storage class in Sema, then codegen is not able to distinguish between: ``` stat

[clang] [llvm] [HLSL] Use hlsl_device address space for getpointer. (PR #127675)

2025-02-18 Thread Steven Perron via cfe-commits
@@ -94,6 +94,11 @@ bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, (A == LangAS::Default && (B == LangAS::cuda_constant || B == LangAS::cuda_device || B == LangAS::cuda_shared)) || + // In HLSL, the this pointer for mem

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-18 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/125718 >From 3ba76b95757a43002d8f799651d7846658011e37 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Tue, 4 Feb 2025 11:47:42 -0500 Subject: [PATCH 1/2] [HLSL] Fix resrouce wrapper declaration The resource wrappe

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-18 Thread Steven Perron via cfe-commits
https://github.com/s-perron converted_to_draft https://github.com/llvm/llvm-project/pull/125718 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Use hlsl_device address space for getpointer. (PR #127675)

2025-02-18 Thread Steven Perron via cfe-commits
@@ -94,6 +94,11 @@ bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, (A == LangAS::Default && (B == LangAS::cuda_constant || B == LangAS::cuda_device || B == LangAS::cuda_shared)) || + // In HLSL, the this pointer for mem

[clang] [llvm] [HLSL] Use hlsl_device address space for getpointer. (PR #127675)

2025-02-18 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/127675 We add the hlsl_device address space to represent the device memory space as defined in section 1.7.1.3 of the [HLSL spec](https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf). Fixes https://github.com/llvm/l

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-18 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/125718 >From a65ccd00e3201af94059a2431f29da6ebfa6 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Tue, 4 Feb 2025 11:47:42 -0500 Subject: [PATCH 1/2] [HLSL] Fix resrouce wrapper declaration The resource wrappe

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-11 Thread Steven Perron via cfe-commits
s-perron wrote: The other option is https://github.com/llvm/llvm-project/pull/123811. However, can you clarify "separate compilation". It is not clear to me exactly what type of linking you have in mind. This make it hard for me to reason about what should be done, and when. Are you thinking

[clang] [HLSL] Fix resource wrapper declaration (PR #125718)

2025-02-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/125718 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Fix resrouce wrapper declaration (PR #125718)

2025-02-05 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/125718 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Fix resrouce wrapper declaration (PR #125718)

2025-02-04 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/125718 The resource wrapper should have internal linkage because it cotains a handle to the global resource, and it not the actual global. Makeing this changed exposed that we were zeroinitializing the resouce, which

[clang] [llvm] [HLSL] Create HLSL legalization passes (PR #123811)

2025-01-24 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/123811 >From 4e62f38b70c0c0ae130d0379ebee4d3f3bcb4797 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Thu, 16 Jan 2025 11:32:16 -0500 Subject: [PATCH 1/2] [HLSL] Create HLSL legalization passes The semantics of HL

[clang] [HLSL] Fix global resource initialization (PR #123394)

2025-01-22 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/123394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Fix global resource initialization (PR #123394)

2025-01-22 Thread Steven Perron via cfe-commits
@@ -536,89 +536,84 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { } } -void CGHLSLRuntime::handleGlobalVarDefinition(const VarDecl *VD, - llvm::GlobalVariable *GV) { - // If the global variable has resource binding, add i

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveMax` intrinsic (PR #123428)

2025-01-22 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/123428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveMax` intrinsic (PR #123428)

2025-01-22 Thread Steven Perron via cfe-commits
@@ -0,0 +1,55 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-vulkan-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-vulkan-unknown %s -o - -filetype=obj | spirv-val %} + +; Test lowering to spir-v backend for various types and scalar/vec

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveMax` intrinsic (PR #123428)

2025-01-22 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. LGTM, just a couple small touchups. https://github.com/llvm/llvm-project/pull/123428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveMax` intrinsic (PR #123428)

2025-01-22 Thread Steven Perron via cfe-commits
@@ -2132,6 +2135,33 @@ bool SPIRVInstructionSelector::selectWaveActiveCountBits( return Result; } +bool SPIRVInstructionSelector::selectWaveReduceMax(Register ResVReg, + const SPIRVType *ResType, +

[clang] [HLSL] Fix global resource initialization (PR #123394)

2025-01-22 Thread Steven Perron via cfe-commits
@@ -536,89 +536,84 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { } } -void CGHLSLRuntime::handleGlobalVarDefinition(const VarDecl *VD, - llvm::GlobalVariable *GV) { - // If the global variable has resource binding, add i

[clang] [llvm] [HLSL] Create HLSL legalization passes (PR #123811)

2025-01-21 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/123811 >From 4e62f38b70c0c0ae130d0379ebee4d3f3bcb4797 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Thu, 16 Jan 2025 11:32:16 -0500 Subject: [PATCH 1/2] [HLSL] Create HLSL legalization passes The semantics of HL

[clang] [llvm] [HLSL] Create HLSL legalization passes (PR #123811)

2025-01-21 Thread Steven Perron via cfe-commits
https://github.com/s-perron deleted https://github.com/llvm/llvm-project/pull/123811 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Create HLSL legalization passes (PR #123811)

2025-01-21 Thread Steven Perron via cfe-commits
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/123811 >From 4e62f38b70c0c0ae130d0379ebee4d3f3bcb4797 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Thu, 16 Jan 2025 11:32:16 -0500 Subject: [PATCH] [HLSL] Create HLSL legalization passes The semantics of HLSL r

[clang] [llvm] [HLSL] Create HLSL legalization passes (PR #123811)

2025-01-21 Thread Steven Perron via cfe-commits
@@ -1164,6 +1166,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline( LangOpts.HIPStdParInterposeAlloc) MPM.addPass(HipStdParAllocationInterpositionPass()); + if (LangOpts.HLSL) { +// HLSL legalization passes +MPM.addPass(HLSLFinalizeLinkage()); +MPM.

[clang] [llvm] [HLSL] Create HLSL legalization passes (PR #123811)

2025-01-21 Thread Steven Perron via cfe-commits
@@ -61,7 +61,7 @@ unsigned RemoveDupes(unsigned Buf[MAX], unsigned size) { } -RWBuffer Indices; +RWBuffer Indices : register(u0); s-perron wrote: Resources without explicit register assignments are not supported yet. If we do not do this then we end up with

[clang] [llvm] [HLSL] Create HLSL legalization passes (PR #123811)

2025-01-21 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/123811 The semantics of HLSL require passes some passes to be run that will modify the llvm-ir created by clang to match what is expected by the backend. In this PR, wewe move the DXILFinalizeLinkage to be run for all

[clang] [llvm] handle wrapper (PR #123795)

2025-01-21 Thread Steven Perron via cfe-commits
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/123795 - **[SPIRV] Expand RWBuffer load and store from HLSL** - **Move type deduction for getpointer into `CallInst` case.** - **Remove unused table entry.** - **Move DXILFinalizeLinkage out of backend to clang.** - **

[clang] [llvm] handle wrapper (PR #123795)

2025-01-21 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/123795 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SPIRV] add pre legalization instruction combine (PR #122839)

2025-01-17 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. I don't see any problem, but I'm not familiar with standard practices in llvm. I like having the combiner pass. https://github.com/llvm/llvm-project/pull/122839 ___ cfe-commits mailing list cfe-c

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-15 Thread Steven Perron via cfe-commits
s-perron wrote: The spir-v test failures are unrelated to your change. It is caused by a problem in spirv-val, and it has been fixed.Don't let that stop you from merging. https://github.com/llvm/llvm-project/pull/116858 ___ cfe-commits mailing list c

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-15 Thread Steven Perron via cfe-commits
@@ -0,0 +1,219 @@ +; RUN: llc -verify-machineinstrs -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 %} + +; CHECK-DAG: [[glsl_450_ext:%.+]] = OpExtInstImport "GLSL.std.4

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-13 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/118580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2025-01-13 Thread Steven Perron via cfe-commits
@@ -0,0 +1,56 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - -filetype=obj | spirv-val %} s-perron wrote: https://github.com/llvm

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2025-01-13 Thread Steven Perron via cfe-commits
@@ -0,0 +1,56 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - -filetype=obj | spirv-val %} s-perron wrote: I don't think anything

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-13 Thread Steven Perron via cfe-commits
https://github.com/s-perron requested changes to this pull request. https://github.com/llvm/llvm-project/pull/118580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2025-01-13 Thread Steven Perron via cfe-commits
@@ -0,0 +1,56 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - -filetype=obj | spirv-val %} s-perron wrote: Sorry I missed this in

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-13 Thread Steven Perron via cfe-commits
@@ -0,0 +1,41 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - -filetype=obj | spirv-val %} s-perron wrote: Once you make that chan

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-13 Thread Steven Perron via cfe-commits
@@ -0,0 +1,41 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - -filetype=obj | spirv-val %} s-perron wrote: ```suggestion ; RUN: ll

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-13 Thread Steven Perron via cfe-commits
https://github.com/s-perron commented: I will take a look to see if the capabilities are correctly generated. At the very least, I think the spirv test should check the capabilities. https://github.com/llvm/llvm-project/pull/118580 ___ cfe-commits ma

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-13 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/118580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-13 Thread Steven Perron via cfe-commits
s-perron wrote: The non-uniform group operand require the `GroupNonUniformArithmetic` capability. You should be checking for that in the test. If it is not being added, you might need to update SPIRVModuleAnalysis.cpp. https://github.com/llvm/llvm-project/pul

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-13 Thread Steven Perron via cfe-commits
@@ -3181,136 +3193,250 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [HLSL] Implement the HLSL distance intrinsic (PR #122357)

2025-01-10 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/122357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement D3DCOLORtoUBYTE4 intrinsic (PR #122202)

2025-01-10 Thread Steven Perron via cfe-commits
@@ -33,6 +33,14 @@ constexpr enable_if_t bit_cast(T F) { return __builtin_bit_cast(U, F); } +constexpr vector d3d_color_to_ubyte4(vector V) { + // Use the same scaling factor used by FXC (i.e., 255.001953) + // Excerpt from stackoverflow discussion: + // "Built-in roundi

[clang] [HLSL] Implement D3DCOLORtoUBYTE4 intrinsic (PR #122202)

2025-01-10 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. https://github.com/llvm/llvm-project/pull/122202 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-10 Thread Steven Perron via cfe-commits
@@ -3181,136 +3193,250 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-10 Thread Steven Perron via cfe-commits
https://github.com/s-perron approved this pull request. Generally looks good to me. Thanks for fixing up the vector size issue. I have a couple minor issue, but I'm fine with this. https://github.com/llvm/llvm-project/pull/116858 ___ cfe-commits maili

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-10 Thread Steven Perron via cfe-commits
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/116858 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-10 Thread Steven Perron via cfe-commits
@@ -3181,136 +3193,250 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-10 Thread Steven Perron via cfe-commits
@@ -3181,136 +3193,250 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-10 Thread Steven Perron via cfe-commits
@@ -3181,136 +3193,250 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Explicitly set the SPIR-V version with spv-target-env (PR #121961)

2025-01-09 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/121961 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Add SPIR-V version of getPointer. (PR #121963)

2025-01-09 Thread Steven Perron via cfe-commits
@@ -104,6 +104,8 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(SClamp, sclamp) GENERATE_HLSL_INTRINSIC_FUNCTION(UClamp, uclamp) + GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetPointer, s-perron wrote: I was following the example of `Creat

[clang] [llvm] [HLSL] Add SPIR-V version of getPointer. (PR #121963)

2025-01-08 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/121963 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Add SPIR-V version of getPointer. (PR #121963)

2025-01-08 Thread Steven Perron via cfe-commits
https://github.com/s-perron reopened https://github.com/llvm/llvm-project/pull/121963 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Add SPIR-V version of getPointer. (PR #121963)

2025-01-08 Thread Steven Perron via cfe-commits
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/121963 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

  1   2   3   >