[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

2024-08-01 Thread Justin Bogner via cfe-commits
@@ -157,6 +158,35 @@ static bool expandAnyIntrinsic(CallInst *Orig) { return true; } +static bool expandLengthIntrinsic(CallInst *Orig) { + Value *X = Orig->getOperand(0); + IRBuilder<> Builder(Orig->getParent()); + Builder.SetInsertPoint(Orig); + Type *Ty = X->getType()

[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

2024-08-01 Thread Justin Bogner via cfe-commits
@@ -157,6 +158,35 @@ static bool expandAnyIntrinsic(CallInst *Orig) { return true; } +static bool expandLengthIntrinsic(CallInst *Orig) { + Value *X = Orig->getOperand(0); + IRBuilder<> Builder(Orig->getParent()); + Builder.SetInsertPoint(Orig); + Type *Ty = X->getType()

[clang] [HLSL] cleanup builtin names elementwise usage (PR #101543)

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

[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

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

[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-08-02 Thread Justin Bogner via cfe-commits
@@ -112,17 +116,13 @@ struct BuiltinTypeDeclBuilder { Ty = Record->getASTContext().getPointerType( QualType(TTD->getTypeForDecl(), 0)); } -return addMemberVariable("h", Ty, Access); - } - - BuiltinTypeDeclBuilder &annotateHLSLResource(ResourceClass

[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-08-02 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Looks good modulo a couple of nitpicks. https://github.com/llvm/llvm-project/pull/101433 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-08-02 Thread Justin Bogner via cfe-commits
@@ -280,18 +280,22 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) { const auto *RD = Ty->getAsCXXRecordDecl(); if (!RD) return; - const auto *HLSLResAttr = RD->getAttr(); - const auto *HLSLResClassAttr = RD->getAttr(); - if (!HLSLR

[clang] Attach resource attributes to handle within record, instead of record (PR #101433)

2024-08-02 Thread Justin Bogner via cfe-commits
@@ -81,6 +81,7 @@ struct BuiltinTypeDeclBuilder { BuiltinTypeDeclBuilder & addMemberVariable(StringRef Name, QualType Type, +const llvm::SmallVector &Attrs, bogner wrote: Generally you don't want to pass the `SmallVector` template to a

[clang] [llvm] Add length builtins and length HLSL function to DirectX Backend (PR #101256)

2024-08-02 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,10 @@ +; RUN: not opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s 2>&1 | FileCheck %s + +; DXIL operation length does not support double overload type +; CHECK: LLVM ERROR: Invalid Overload + +define noundef double @test_length_double2(<2 x double> nou

[clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

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

[clang] [llvm] Add length builtins and length HLSL function to DirectX Backend (PR #101256)

2024-08-02 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/101256 ___ 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-08 Thread Justin Bogner via cfe-commits
https://github.com/bogner commented: It'd be better to make the attribute take no arguments, and we can tell if something is ROV by its presence alone, so: ```hlsl [[hlsl::is_rov]] __hlsl_resource_t handle; ``` would be an ROV resource, but ```hlsl __hlsl_resource_t handle; ``` would not. I thi

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-16 Thread Justin Bogner via cfe-commits
bogner wrote: > There is some discussion in the RFC, but I don't see a consensus on the "dot" > intrinsic in particular. I personally haven't found the arguments in favor of > it particularly compelling. > > This really needs an RFC specific to that intrinsic (class), which includes a > clear

[clang] [HLSL][Doc] Document multi-argument resolution (PR #104474)

2024-08-16 Thread Justin Bogner via cfe-commits
https://github.com/bogner commented: If I understand correctly from reading this, there should never be a case where both dxc and clang both choose an overload but those differ. Ie, any case where the behaviour disagrees will result in clang failing to resolve the overload because it's ambiguo

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

2024-08-19 Thread Justin Bogner via cfe-commits
https://github.com/bogner commented: We should be able to test this by defining a global or calling a function with the `__hlsl_resource_t` type. https://github.com/llvm/llvm-project/pull/104856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

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

2024-08-19 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] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-08-19 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,60 @@ +//===- 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

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

2024-08-19 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,60 @@ +//===- 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

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

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

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

2024-08-20 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,54 @@ +//===- DirectX.cpp +//---===// bogner wrote: Something happened to the formatting here https://github.com/llvm/llvm-project/pull/104856 ___ cfe-

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Justin Bogner via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Justin Bogner via cfe-commits
@@ -5683,6 +5685,14 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return true; return false; } + case UTT_IsIntangibleType: +if (!T->isVoidType() && !T->isIncompleteArrayType()) + if (Self.RequireCompleteType(TInfo->getTypeLoc().getBe

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Justin Bogner via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Justin Bogner via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Justin Bogner via cfe-commits
@@ -27,7 +29,7 @@ using namespace clang; -SemaHLSL::SemaHLSL(Sema &S) : SemaBase(S) {} +SemaHLSL::SemaHLSL(Sema &S) : SemaBase(S), IsIntangibleTypeCache(8) {} bogner wrote: Why initialize the DenseMap with a specific number of buckets here? Why 8? https://g

[clang] [HLSL] Implement `export` keyword (PR #96823)

2024-06-27 Thread Justin Bogner via cfe-commits
@@ -851,6 +851,21 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, CurContext->addDecl(D); PushDeclContext(S, D); + if (getLangOpts().HLSL) { +// exported functions cannot be in an unnamed namespace +for (const DeclContext *DC = CurContext;

[clang] [HLSL] Implement `export` keyword (PR #96823)

2024-06-27 Thread Justin Bogner via cfe-commits
@@ -924,6 +939,23 @@ static bool checkExportedDeclContext(Sema &S, DeclContext *DC, /// Check that it's valid to export \p D. static bool checkExportedDecl(Sema &S, Decl *D, SourceLocation BlockStart) { + // HLSL: export declaration is valid only on functions + if (S.getLan

[clang] [HLSL] Implement `export` keyword (PR #96823)

2024-06-27 Thread Justin Bogner via cfe-commits
@@ -924,6 +939,23 @@ static bool checkExportedDeclContext(Sema &S, DeclContext *DC, /// Check that it's valid to export \p D. static bool checkExportedDecl(Sema &S, Decl *D, SourceLocation BlockStart) { + // HLSL: export declaration is valid only on functions + if (S.getLan

[clang] [HLSL] Implement `export` keyword (PR #96823)

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

[clang] Update StructuredBuffer-AST test after removal of HLSLResourceClassAttr (PR #108292)

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

[clang] [HLSL] fix elementwise bitreverse test (PR #108128)

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

[clang] [HLSL] fix elementwise bitreverse test (PR #108128)

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

[clang] Update StructuredBuffer-AST test after removal of HLSLResourceClassAttr (PR #108292)

2024-09-11 Thread Justin Bogner via cfe-commits
https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/108292 ___ 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-12 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. 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] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -10,6 +10,7 @@ #define _HLSL_HLSL_INTRINSICS_H_ namespace hlsl { +#include "hlsl_details.h" bogner wrote: We shouldn't `#include` a file inside a namespace. Instead, "hlsl_details.h" should also have a `namespace hlsl {}` block around the `__detail` names

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

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,35 @@ +//===- hlsl_intrinsics.h - HLSL definitions for intrinsics --===// bogner wrote: This comment needs updating. https://github.com/llvm/llvm-project/pull/107292 ___ cfe-commits mailing list

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

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,35 @@ +//===- hlsl_intrinsics.h - HLSL definitions for intrinsics --===// +// +// 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: Apache

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

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,35 @@ +//===- hlsl_intrinsics.h - HLSL definitions for intrinsics --===// +// +// 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: Apache

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

2024-09-12 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: This still has `-verify-ignore-unexpected`... https:

[clang] [HLSL] Add HLSL 202y language mode (PR #108437)

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

[clang] [HLSL] Add HLSL 202y language mode (PR #108437)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -12397,6 +12397,9 @@ def warn_attr_min_eq_max: Warning< def err_hlsl_attribute_number_arguments_insufficient_shader_model: Error< "attribute %0 with %1 arguments requires shader model %2 or greater">; +def ext_hlsl_auto_type_specifier : ExtWarn< + "'auto' type specifier

[clang] [HLSL] Add HLSL 202y language mode (PR #108437)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -1347,6 +1347,8 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( Diag(LambdaBeginLoc, getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_lambda : diag::ext_lambda); + if (getLangOpts().HLSL) +Diag(Lambd

[clang] [HLSL] Fix move assignment of `this` (PR #108445)

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

[clang] [HLSL] Fix move assignment of `this` (PR #108445)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -43,3 +53,18 @@ void main() { // CHECK-NEXT:call void @llvm.memset.p0.i32(ptr align 4 %ref.tmp, i8 0, i32 8, i1 false) // CHECK-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 %this1, ptr align 4 %ref.tmp, i32 8, i1 false) // CHECK-NEXT:%Second = getelementptr inbounds n

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -942,6 +942,7 @@ class BTFTagAttributedTypeLoc struct HLSLAttributedResourceLocInfo { SourceRange Range; + TypeSourceInfo *ContainedTyTSI; bogner wrote: `ContainedTyInfo` might be a better name - we usually only use type abbreviations if its the whole

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -30,9 +31,9 @@ class Scope; // FIXME: This can be hidden (as static function in SemaHLSL.cpp) once we no // longer need to create builtin buffer types in HLSLExternalSemaSource. -bool CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, -

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -114,19 +115,30 @@ struct BuiltinTypeDeclBuilder { AccessSpecifier Access = AccessSpecifier::AS_private) { if (Record->isCompleteDefinition()) return *this; + +TypeSourceInfo *ElementTypeTSI = nullptr; bogner wrote: Same nami

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -563,18 +566,23 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } -bool clang::CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, - ArrayRef AttrList, -

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -563,18 +566,23 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } -bool clang::CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, - ArrayRef AttrList, -

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

2024-09-12 Thread Justin Bogner via cfe-commits
@@ -114,19 +115,30 @@ struct BuiltinTypeDeclBuilder { AccessSpecifier Access = AccessSpecifier::AS_private) { if (Record->isCompleteDefinition()) return *this; + +TypeSourceInfo *ElementTypeTSI = nullptr; + QualType Ty = Record->getASTContex

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

2024-09-13 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] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-13 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-13 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify bogner wrote: The `-emit-llvm-only` and `-disable-llvm-passes` flags don't really do anything

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

2024-09-13 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. looks good, thanks! 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] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

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

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

2024-09-15 Thread Justin Bogner via cfe-commits
@@ -30,15 +29,15 @@ RWBuffer Buffer; // CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <> implicit class RWBuffer definition // CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final -// CHECK-NEXT: implicit h 'element_type * {{\[\[}}hlsl::resource_class(UAV)]]':'element_type *

[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

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

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -1,19 +1,21 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { GV->eraseFromParent(); } } + +// Returns handle type of a resource, if the type is a resource +// or an array of resources +static const HLSLAttributedResourceType *findHandleTypeOnResource(QualTy

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { GV->eraseFromParent(); } } + +// Returns handle type of a resource, if the type is a resource +// or an array of resources +static const HLSLAttributedResourceType *findHandleTypeOnResource(QualTy

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { GV->eraseFromParent(); } } + +// Returns handle type of a resource, if the type is a resource +// or an array of resources +static const HLSLAttributedResourceType *findHandleTypeOnResource(QualTy

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { GV->eraseFromParent(); } } + +// Returns handle type of a resource, if the type is a resource +// or an array of resources +static const HLSLAttributedResourceType *findHandleTypeOnResource(QualTy

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { GV->eraseFromParent(); } } + +// Returns handle type of a resource, if the type is a resource +// or an array of resources +static const HLSLAttributedResourceType *findHandleTypeOnResource(QualTy

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

2024-10-15 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] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-15 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/110327 ___ 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)

2024-10-15 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/111010 ___ 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)

2024-10-15 Thread Justin Bogner via cfe-commits
bogner wrote: It would probably be good to have some test coverage for int16, half, and double here https://github.com/llvm/llvm-project/pull/111010 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -2235,3 +2280,107 @@ QualType SemaHLSL::getInoutParameterType(QualType Ty) { Ty.addRestrict(); return Ty; } + +void SemaHLSL::ActOnVariableDeclarator(VarDecl *VD) { + if (VD->hasGlobalStorage()) { +// make sure the declaration has a complete type +if (SemaRef.Re

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -102,6 +152,15 @@ class SemaHLSL : public SemaBase { llvm::DenseMap LocsForHLSLAttributedResources; + + // List of all resource bindings + ResourceBindings Bindings; + +private: + void FindResourcesOnVarDecl(VarDecl *D); + void FindResourcesOnUserRecordDecl(const

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -2235,3 +2280,107 @@ QualType SemaHLSL::getInoutParameterType(QualType Ty) { Ty.addRestrict(); return Ty; } + +void SemaHLSL::ActOnVariableDeclarator(VarDecl *VD) { + if (VD->hasGlobalStorage()) { +// make sure the declaration has a complete type +if (SemaRef.Re

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -4593,6 +4593,44 @@ def HLSLResourceBinding: InheritableAttr { let LangOpts = [HLSL]; let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>]; let Documentation = [HLSLResourceBindingDocs]; + let AdditionalMembers = [{ + enum class RegisterType : unsigned

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -985,88 +1026,92 @@ SemaHLSL::TakeLocForHLSLAttribute(const HLSLAttributedResourceType *RT) { return LocInfo; } -// get the record decl from a var decl that we expect -// represents a resource -static CXXRecordDecl *getRecordDeclFromVarDecl(VarDecl *VD) { - const Type *

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -83,6 +81,49 @@ static RegisterType getRegisterType(StringRef Slot) { } } +static ResourceClass getResourceClass(RegisterType RT) { + switch (RT) { + case RegisterType::SRV: +return ResourceClass::SRV; + case RegisterType::UAV: +return ResourceClass::UAV; + ca

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -985,88 +1026,92 @@ SemaHLSL::TakeLocForHLSLAttribute(const HLSLAttributedResourceType *RT) { return LocInfo; } -// get the record decl from a var decl that we expect -// represents a resource -static CXXRecordDecl *getRecordDeclFromVarDecl(VarDecl *VD) { - const Type *

[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

2024-10-10 Thread Justin Bogner via cfe-commits
bogner wrote: > > Despite all of this, DXC does indeed support 16- and 64-bit overloads, as > > seen here: https://hlsl.godbolt.org/z/qbc17xz35 > > Note that the return type of the operation is not overloaded - all of the > > overloads of this function return uint. > > Why is the return type n

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

2024-10-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Looks good once Chris's comments and the clang-format issue are resolved. https://github.com/llvm/llvm-project/pull/111010 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

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

2024-10-04 Thread Justin Bogner via cfe-commits
@@ -489,6 +542,9 @@ class OpLowerer { case Intrinsic::dx_typedBufferStore: HasErrors |= lowerTypedBufferStore(F); break; + case Intrinsic::dx_splitdouble: bogner wrote: There will need to be some logic in DXILOpLowering, because we n

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

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

[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

2024-10-04 Thread Justin Bogner via cfe-commits
@@ -928,6 +928,78 @@ float3 exp2(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2) float4 exp2(float4); +//===--===// +// firstbithigh builtins +//===

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-16 Thread Justin Bogner via cfe-commits
@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { GV->eraseFromParent(); } } + +// Returns handle type of a resource, if the type is a resource +// or an array of resources +static const HLSLAttributedResourceType *findHandleTypeOnResource(QualTy

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-16 Thread Justin Bogner via cfe-commits
@@ -985,88 +1034,94 @@ SemaHLSL::TakeLocForHLSLAttribute(const HLSLAttributedResourceType *RT) { return LocInfo; } -// get the record decl from a var decl that we expect -// represents a resource -static CXXRecordDecl *getRecordDeclFromVarDecl(VarDecl *VD) { - const Type *

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

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

[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-16 Thread Justin Bogner via cfe-commits
@@ -28,13 +28,60 @@ class AttributeCommonInfo; class IdentifierInfo; class ParsedAttr; class Scope; +class VarDecl; + +using llvm::dxil::ResourceClass; // FIXME: This can be hidden (as static function in SemaHLSL.cpp) once we no // longer need to create builtin buffer types

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-16 Thread Justin Bogner via cfe-commits
@@ -5622,6 +5622,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, getCUDARuntime().handleVarRegistration(D, *GV); } + if (LangOpts.HLSL) +getHLSLRuntime().handleGlobalVarDefinition(D, GV); bogner wrote: Pre-SM6.6 this will emit a

[clang] [HLSL][SPIRV] Use Spirv target codegen (PR #112573)

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

[clang] [clang][HLSL] Add GroupMemoryBarrierWithGroupSync intrinsic (PR #111883)

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

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

2024-10-21 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Could also consider checking for `ret void` instead, as that's more flexible if someone were to add another test case later in the file. This seems fine too though. https://github.com/llvm/llvm-project/pull/112461 __

[clang] [HLSL][NFC] Move IsIntangibleType from SemaHLSL to Type to make it accessible outside of Sema (PR #113206)

2024-10-21 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. I'm a little bit worried about how subtle the naming difference is from when we want to talk about if the builtin itself is intangible or if the type is transitively intangible, but that might just be because we're replacing one name with t

[clang] [llvm] [mlir] [polly] [NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (PR #111752)

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

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -18901,6 +18901,159 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + case Builtin::BI__builtin_hlsl_splitdouble: { + +assert((E->getArg(0)->getType()->hasFlo

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -4681,6 +4682,14 @@ void CallArg::copyInto(CodeGenFunction &CGF, Address Addr) const { IsUsed = true; } +void CodeGenFunction::EmitWritebacks(CodeGenFunction &CGF, + const CallArgList &Args) { + if (getTarget().getCXXABI().areArgsDest

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -18901,6 +18901,159 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + case Builtin::BI__builtin_hlsl_splitdouble: { + +assert((E->getArg(0)->getType()->hasFlo

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -18901,6 +18901,159 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + case Builtin::BI__builtin_hlsl_splitdouble: { + +assert((E->getArg(0)->getType()->hasFlo

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -47,6 +47,7 @@ def ResRetInt32Ty : DXILOpParamType; def HandleTy : DXILOpParamType; def ResBindTy : DXILOpParamType; def ResPropsTy : DXILOpParamType; +def ResSplitDoubleTy : DXILOpParamType; bogner wrote: This should just be "SplitDoubleTy". The types that

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -461,6 +479,27 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerSplitDouble(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(CI); + + Value *Arg0 = CI->getArgOper

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple spirv-vulkan-library %s -fnative-half-type -emit-ll

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

2024-10-09 Thread Justin Bogner via cfe-commits
@@ -264,6 +264,24 @@ class OpLowerer { return lowerToBindAndAnnotateHandle(F); } + Error replaceSplitDoubleCallUsages(CallInst *Intrin, CallInst *Op) { +IRBuilder<> &IRB = OpBuilder.getIRB(); + +for (Use &U : make_early_inc_range(Intrin->uses())) { + if (au

[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

2024-10-04 Thread Justin Bogner via cfe-commits
bogner wrote: It is not correct to limit firstbithigh to 32 bit integers. There are a couple of reasons that might make one think that it is, but we do in fact want/need to support int16 and int64 here. 1. The [HLSL docs](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/firstbithi

[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

2024-10-04 Thread Justin Bogner via cfe-commits
@@ -564,6 +564,30 @@ def CBits : DXILOp<31, unary> { let attributes = [Attributes]; } +def FBH : DXILOp<33, unary> { + let Doc = "Returns the location of the first set bit starting from " +"the highest order bit and working downward."; + let LLVMIntrinsic = i

[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

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

<    1   2   3   4   5   6   7   8   9   10   >