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

2025-03-14 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley edited 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] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-04-01 Thread Cassandra Beckley via cfe-commits
cassiebeckley wrote: @s-perron @Keenuts https://github.com/llvm/llvm-project/pull/134034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-04-01 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley created https://github.com/llvm/llvm-project/pull/134034 This implements the design proposed by [Representing SpirvType in Clang's Type System](https://github.com/llvm/wg-hlsl/pull/181). It creates `HLSLInlineSpirvType` as a new `Type` subclass, and `__hlsl_spi

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-04-01 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley updated https://github.com/llvm/llvm-project/pull/134034 >From 78ac1bc4225b41bc4b9fbd9fd9ab9dc82a2953ca Mon Sep 17 00:00:00 2001 From: Cassandra Beckley Date: Tue, 1 Apr 2025 23:12:02 -0700 Subject: [PATCH 1/2] [HLSL] Implement `SpirvType` and `SpirvOpaqueType`

[clang] [HLSL][SPIRV] Add CLI option `-fspv-extension` (PR #137985)

2025-05-01 Thread Cassandra Beckley via cfe-commits
@@ -9213,6 +9213,11 @@ def metal : DXCFlag<"metal">, HelpText<"Generate Metal library">; def fspv_target_env_EQ : Joined<["-"], "fspv-target-env=">, Group, HelpText<"Specify the target environment">, Values<"vulkan1.2, vulkan1.3">; +def fspv_extension_EQ +: Joined<["-"

[clang] [HLSL][SPIRV] Add CLI option `-fspv-extension` (PR #137985)

2025-05-01 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley approved this pull request. https://github.com/llvm/llvm-project/pull/137985 ___ 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-25 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley updated https://github.com/llvm/llvm-project/pull/132848 >From 959f0374df39a97d22740ae81d132bed300159ea Mon Sep 17 00:00:00 2001 From: Cassandra Beckley Date: Mon, 24 Mar 2025 17:36:46 -0700 Subject: [PATCH 1/2] [HLSL] Add __spirv__ macro This macro can be used

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-04-02 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley updated https://github.com/llvm/llvm-project/pull/134034 >From 78ac1bc4225b41bc4b9fbd9fd9ab9dc82a2953ca Mon Sep 17 00:00:00 2001 From: Cassandra Beckley Date: Tue, 1 Apr 2025 23:12:02 -0700 Subject: [PATCH 1/3] [HLSL] Implement `SpirvType` and `SpirvOpaqueType`

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-04-02 Thread Cassandra Beckley via cfe-commits
cassiebeckley wrote: @philnik777 fyi for the changes to builtin templates https://github.com/llvm/llvm-project/pull/134034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-09 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley updated https://github.com/llvm/llvm-project/pull/134034 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
cassiebeckley wrote: Done. https://github.com/llvm/llvm-project/pull/134034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -3332,6 +3388,39 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, } return HasNoTypeMember; } + + case BTK__hlsl_spirv_type: { +assert(Converted.size() == 4); + +if (!Context.getTargetInfo().getTriple().isSPIRV()) { + SemaRef.Di

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -6330,6 +6331,140 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode { findHandleTypeOnResource(const Type *RT); }; +/// Instances of this class represent operands to a SPIR-V type instruction. +class SpirvOperand { +public: + enum SpirvOpera

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -6165,6 +6254,18 @@ bool UnnamedLocalNoLinkageFinder::VisitHLSLAttributedResourceType( return Visit(T->getWrappedType()); } +bool UnnamedLocalNoLinkageFinder::VisitHLSLInlineSpirvType( +const HLSLInlineSpirvType *T) { + for (auto &Operand : T->getOperands()) { +

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -0,0 +1,28 @@ +//===- hlsl_spirv.h - HLSL definitions for SPIR-V target --===// +// +// 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] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -6330,6 +6331,140 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode { findHandleTypeOnResource(const Type *RT); }; +/// Instances of this class represent operands to a SPIR-V type instruction. +class SpirvOperand { +public: + enum SpirvOpera

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -6330,6 +6331,140 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode { findHandleTypeOnResource(const Type *RT); }; +/// Instances of this class represent operands to a SPIR-V type instruction. +class SpirvOperand { +public: + enum SpirvOpera

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley updated https://github.com/llvm/llvm-project/pull/134034 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -5444,6 +5459,31 @@ QualType ASTContext::getHLSLAttributedResourceType( return QualType(Ty, 0); } + +QualType ASTContext::getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, +uint32_t Alignment, +

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -3228,6 +3228,62 @@ static QualType builtinCommonTypeImpl(Sema &S, TemplateName BaseTemplate, } } +static bool isInVkNamespace(const RecordType *RT) { + DeclContext *DC = RT->getDecl()->getDeclContext(); + if (!DC) +return false; + + NamespaceDecl *ND = dyn_cast(D

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -3228,6 +3228,62 @@ static QualType builtinCommonTypeImpl(Sema &S, TemplateName BaseTemplate, } } +static bool isInVkNamespace(const RecordType *RT) { + DeclContext *DC = RT->getDecl()->getDeclContext(); + if (!DC) +return false; + + NamespaceDecl *ND = dyn_cast(D

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -369,14 +369,102 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM, return nullptr; } +// Gets a spirv.IntegralConstant or spirv.Literal. If IntegralType is present, +// returns an IntegralConstant, otherwise returns a Literal. +static llvm::Ty

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -11763,6 +11804,22 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer, return LHS; return {}; } + case Type::HLSLInlineSpirv: +const HLSLInlineSpirvType *LHSTy = LHS->castAs(); +const HLSLInlineSpirvType *RHSTy = RHS->cas

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -1832,6 +1832,48 @@ ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType( ToWrappedType, ToContainedType, ToAttrs); } +ExpectedType clang::ASTNodeImporter::VisitHLSLInlineSpirvType( +const clang::HLSLInlineSpirvType *T) { + Error Err = Error::suc

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -369,14 +369,102 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM, return nullptr; } +// Gets a spirv.IntegralConstant or spirv.Literal. If IntegralType is present, +// returns an IntegralConstant, otherwise returns a Literal. +static llvm::Ty

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -877,6 +878,11 @@ bool CodeGenTypes::isZeroInitializable(QualType T) { if (const MemberPointerType *MPT = T->getAs()) return getCXXABI().isZeroInitializable(MPT); + // HLSL Inline SPIR-V types are non-zero-initializable. + if (T->getAs()) { +return false; + } -

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.0-compute %s \ +// RUN: -fsyntax-only -verify + +typedef vk::SpirvType<12, 2, 4, float> InvalidType1; // expected-error {{use of undeclared identifier 'vk'}} +vk::Li

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s + +template +using Array = vk::SpirvOpaqueType>; + +template +using ArrayBuffer = Array, Size

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.0-compute %s \ +// RUN: -fsyntax-only -verify + +typedef vk::SpirvType<12, 2, 4, float> InvalidType1; // expected-error {{use of undeclared identifier 'vk'}} +vk::Li

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
cassiebeckley wrote: Done. https://github.com/llvm/llvm-project/pull/134034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
cassiebeckley wrote: Done. https://github.com/llvm/llvm-project/pull/134034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-06 Thread Cassandra Beckley via cfe-commits
@@ -3332,6 +3388,39 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, } return HasNoTypeMember; } + + case BTK__hlsl_spirv_type: { +assert(Converted.size() == 4); + +if (!Context.getTargetInfo().getTriple().isSPIRV()) { + SemaRef.Di

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-15 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley updated https://github.com/llvm/llvm-project/pull/134034 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,

[clang] [clang] Emit convergence tokens for loop in global array init (PR #140120)

2025-05-15 Thread Cassandra Beckley via cfe-commits
https://github.com/cassiebeckley approved this pull request. https://github.com/llvm/llvm-project/pull/140120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-15 Thread Cassandra Beckley via cfe-commits
cassiebeckley wrote: @llvm-beanz I believe I've addressed all of your feedback; let me know if there's anything else I should do https://github.com/llvm/llvm-project/pull/134034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llv