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

2024-10-04 Thread Justin Bogner via cfe-commits
https://github.com/bogner commented: This LGTM but I'm not familiar enough with the mangling aspects or the implications of adding a canonical type to be comfortable signing off on it. https://github.com/llvm/llvm-project/pull/110327 ___ cfe-commits m

[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] 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] [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
@@ -928,6 +928,78 @@ float3 exp2(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2) float4 exp2(float4); +//===--===// +// firstbithigh builtins +//===

[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

[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] Add cross builtins and cross HLSL function to DirectX and SPIR-V backend (PR #109180)

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

[clang] [HLSL] Array by-value assignment (PR #109323)

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

[clang] [HLSL] Treat `main` as any other function (PR #110546)

2024-09-30 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. There is still logic elsewhere that sets the default entry point to "main", right? This looks right to me. https://github.com/llvm/llvm-project/pull/110546 ___ cfe-commits mailing list cfe-commits@

[clang] [llvm] [HLSL] Replace `element_type*` handles in HLSLExternalSemaSource with `__hlsl_resource_t` builtin type (PR #110079)

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

[clang] [HLSL] Allow resource type attributes only on `__hlsl_resource_t` (PR #110143)

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

[clang] [HLSL] Implement `asint` casting using `bit_cast` (PR #110027)

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

[clang] [llvm] [HLSL] Remove `__builtin_hlsl_create_handle` (PR #109910)

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

[clang] [HLSL] Vector Usual Arithmetic Conversions (PR #108659)

2024-09-26 Thread Justin Bogner via cfe-commits
@@ -401,6 +401,194 @@ void SemaHLSL::DiagnoseAttrStageMismatch( << (AllowedStages.size() != 1) << join(StageStrings, ", "); } +template +static void castVector(Sema &S, ExprResult &E, QualType &Ty, unsigned Sz) { + if (const auto *VTy = Ty->getAs()) +Ty = VTy->getE

[clang] [HLSL] Vector Usual Arithmetic Conversions (PR #108659)

2024-09-25 Thread Justin Bogner via cfe-commits
@@ -401,6 +401,194 @@ void SemaHLSL::DiagnoseAttrStageMismatch( << (AllowedStages.size() != 1) << join(StageStrings, ", "); } +template +static void castVector(Sema &S, ExprResult &E, QualType &Ty, unsigned Sz) { + if (const auto *VTy = Ty->getAs()) +Ty = VTy->getE

[clang] [HLSL] Vector Usual Arithmetic Conversions (PR #108659)

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

[clang] [clang][NFC] add static for internal linkage function (PR #109436)

2024-09-23 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. I assume you noticed this through some clang-tidy or other type of tooling? It would be good to mention that in the PR/commit description. In any case, the changes LGTM. https://github.com/llvm/llvm-project/pull/109436 _

[clang] [HLSL] Array by-value assignment (PR #109323)

2024-09-23 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope + +// CHECK-LABEL: define void {{.*}}arr_assign1 +// CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4 +// CHECK: [[Arr2:%.*]] = allo

[clang] [HLSL] Array by-value assignment (PR #109323)

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

[clang] [HLSL] Array by-value assignment (PR #109323)

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

[clang] [HLSL] Array by-value assignment (PR #109323)

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

[clang] [HLSL] Array by-value assignment (PR #109323)

2024-09-23 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope + +// CHECK-LABEL: define void {{.*}}arr_assign1 +// CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4 +// CHECK: [[Arr2:%.*]] = allo

[clang] [HLSL] Array by-value assignment (PR #109323)

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

[clang] [HLSL] Array by-value assignment (PR #109323)

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

[clang] [HLSL] Array by-value assignment (PR #109323)

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

[clang] [HLSL] Array by-value assignment (PR #109323)

2024-09-23 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope + +// CHECK-LABEL: define void {{.*}}arr_assign1 +// CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4 +// CHECK: [[Arr2:%.*]] = allo

[clang] [HLSL] Array by-value assignment (PR #109323)

2024-09-23 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope + +// CHECK-LABEL: define void {{.*}}arr_assign1 +// CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4 +// CHECK: [[Arr2:%.*]] = allo

[clang] [HLSL] Make casting functions constexpr (PR #108902)

2024-09-18 Thread Justin Bogner via cfe-commits
@@ -13,23 +13,23 @@ namespace hlsl { namespace __detail { -#define _HLSL_INLINE \ - __attribute__((__always_inline__, __nodebug__)) static inline bogner wrote: Note that while constexpr implies `inl

[clang] [HLSL] Make casting functions constexpr (PR #108902)

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

[clang] [HLSL][NFC] Update resource attribute tests (PR #108919)

2024-09-18 Thread Justin Bogner via cfe-commits
@@ -2,18 +2,27 @@ typedef vector float4; -// CHECK: -TypeAliasDecl 0x{{[0-9a-f]+}} -// CHECK: -HLSLAttributedResourceType 0x{{[0-9a-f]+}} '__hlsl_resource_t {{\[\[}}hlsl::resource_class(UAV)]] {{\[\[}}hlsl::contained_type(int)]]' sugar +// CHECK: -TypeAliasDecl 0x{{[0-9a-f]

[clang] [HLSL][NFC] Update resource attribute tests (PR #108919)

2024-09-18 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Yeah, I think this is overall an improvement for readability. Thanks! https://github.com/llvm/llvm-project/pull/108919 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/

[clang] [HLSL][NFC] Update resource attribute tests (PR #108919)

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

[clang] [HLSL][NFC] Remove RegisterBindingFlags struct (PR #108924)

2024-09-18 Thread Justin Bogner via cfe-commits
@@ -839,100 +842,84 @@ static void updateResourceClassFlagsFromRecordType(RegisterBindingFlags &Flags, const Type *FieldTy = FD->getType().getTypePtr(); if (const HLSLAttributedResourceType *AttrResType = dyn_cast(FieldTy)) { -updateResourceCl

[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] [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 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] 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] 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 edited https://github.com/llvm/llvm-project/pull/107292 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] 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] [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::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; 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
@@ -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
@@ -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] 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] 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] 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] 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
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] 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] 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,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
@@ -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] [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] 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] 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] [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] 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] [NFC] [HLSL] Update test for HLSL 202x (PR #108097)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2024-09-09 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,52 @@ +//===- DirectX.cpp-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

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

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

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

2024-09-09 Thread Justin Bogner via cfe-commits
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] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,52 @@ +//===- DirectX.cpp-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

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

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

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

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

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

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

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

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

  1   2   3   4   5   6   >