[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] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

2024-10-22 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-22 Thread Justin Bogner via cfe-commits
@@ -2626,6 +2671,148 @@ Register SPIRVInstructionSelector::buildPointerToResource( MIRBuilder); } +bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, +const

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

2024-10-22 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Looks good to me once @farzonl's feedback is taken into account. https://github.com/llvm/llvm-project/pull/111082 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

2024-10-22 Thread Justin Bogner via cfe-commits
@@ -461,6 +461,67 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerCtpopToCBits(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +Type *Int32Ty = IRB.getInt32Ty(); + +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

2024-10-22 Thread Justin Bogner via cfe-commits
@@ -553,11 +553,10 @@ def Rbits : DXILOp<30, unary> { let attributes = [Attributes]; } -def CBits : DXILOp<31, unary> { +def CBits : DXILOp<31, unaryBits> { bogner wrote: Can we rename this to CountBits while we're at it? It's best if the OpCode names h

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

2024-10-22 Thread Justin Bogner via cfe-commits
@@ -461,6 +461,67 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerCtpopToCBits(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +Type *Int32Ty = IRB.getInt32Ty(); + +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

2024-10-22 Thread Justin Bogner via cfe-commits
@@ -461,6 +461,67 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerCtpopToCBits(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +Type *Int32Ty = IRB.getInt32Ty(); + +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

2024-10-25 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. A couple of minor style nitpicks, but otherwise this LGTM! https://github.com/llvm/llvm-project/pull/113189 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

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

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

2024-10-24 Thread Justin Bogner via cfe-commits
@@ -460,6 +460,70 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerCtpopToCountBits(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +Type *Int32Ty = IRB.getInt32Ty(); + +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPo

[clang] [llvm] [HLSL] Re-implement countbits with the correct return type (PR #113189)

2024-10-24 Thread Justin Bogner via cfe-commits
@@ -460,6 +460,70 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerCtpopToCountBits(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +Type *Int32Ty = IRB.getInt32Ty(); + +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPo

[clang] [HLSL] Remove old resource annotations for UAVs and SRVs (PR #114139)

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

[clang] [HLSL][NFC] Cleanup - removed unused function, includes and param, fix typos (PR #113649)

2024-11-04 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/113649 ___ 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 #112400)

2024-11-11 Thread Justin Bogner via cfe-commits
@@ -1824,6 +1824,23 @@ static bool CheckAnyScalarOrVector(Sema *S, CallExpr *TheCall, return false; } +static bool CheckNotScalarType(Sema *S, CallExpr *TheCall, QualType Scalar, + unsigned ArgIndex) { + assert(TheCall->getNumArgs() >= ArgInde

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

2024-11-11 Thread Justin Bogner via cfe-commits
@@ -2217,6 +2217,105 @@ __attribute__((convergent)) double3 WaveReadLaneAt(double3, int32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) __attribute__((convergent)) double4 WaveReadLaneAt(double4, int32_t); +//===

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

2024-10-26 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-26 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. A few last minor nitpicks, but this LGTM! 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

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

2024-10-26 Thread Justin Bogner via cfe-commits
@@ -5897,7 +5897,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, // Emit any call-associated writebacks immediately. Arguably this // should happen after any return-value munging. if (CallArgs.hasWritebacks()) -emitWritebacks(*this, CallArgs);

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

2024-10-26 Thread Justin Bogner via cfe-commits
@@ -5460,9 +5460,8 @@ LValue CodeGenFunction::EmitOpaqueValueLValue(const OpaqueValueExpr *e) { return getOrCreateOpaqueLValueMapping(e); } -void CodeGenFunction::EmitHLSLOutArgExpr(const HLSLOutArgExpr *E, - CallArgList &Args, QualTy

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

2024-10-26 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,77 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 bogner wrote: Are these assertions actually autogenerated? They look like they've been written by hand to me (which is fine, but if that's the case

[clang] [llvm] [HLSL] Print struct body definition when within the context of defining a target extension type (PR #115971)

2024-11-13 Thread Justin Bogner via cfe-commits
bogner wrote: This doesn't look right to me. Changing the type printer so it doesn't differentiate between named and anonymous structs inside a target extension type like this looks like it will break round-tripping through LLVM IR, since the fact that this was associated with a named struct a

[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] 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] [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
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 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 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
@@ -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] 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] [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] [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] 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] [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] [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][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][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] 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
@@ -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] 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] [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] [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] [llvm] [HLSL][SPIRV] Added clamp intrinsic (PR #113394)

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

[clang] [HLSL] Add Append/ConsumeStructuredBuffer definitions to HLSLExternalSemaSource (PR #113643)

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

[clang] [HLSL] Add Append/ConsumeStructuredBuffer definitions to HLSLExternalSemaSource (PR #113643)

2024-11-07 Thread Justin Bogner via cfe-commits
bogner wrote: I'm not entirely convinced that these AST tests that are all more or less duplicates of each other are really worth it for every single buffer type. They aren't easy to read or update and they vary from one another by literally just a few charac

[clang] [HLSL] Add Append/ConsumeStructuredBuffer definitions to HLSLExternalSemaSource (PR #113643)

2024-11-07 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Looks good. I have a comment about the testing strategy in general but that can be addressed separately from this PR. https://github.com/llvm/llvm-project/pull/113643 ___ cfe-commits mailing list c

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

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

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

2024-10-25 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,99 @@ +// 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] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-15 Thread Justin Bogner via cfe-commits
bogner wrote: I think it's reasonable to limit this to implement things that are independently testable and leave the parts that aren't yet being used for some future change. https://github.com/llvm/llvm-project/pull/111203 ___ cfe-commits mailing li

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

2024-10-15 Thread Justin Bogner via cfe-commits
@@ -2018,6 +2018,11 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_group_memory_barrier_with_group_sync: { +if (SemaRef.checkArgCountAtMost(TheCall, 0)) ---

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

2024-10-17 Thread Justin Bogner via cfe-commits
@@ -5334,3 +5334,18 @@ std::string FunctionEffectWithCondition::description() const { Result += "(expr)"; return Result; } + +const HLSLAttributedResourceType * +HLSLAttributedResourceType::findHandleTypeOnResource(const Type *RT) { + // If the type T is an HLSL resourc

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

2024-10-17 Thread Justin Bogner via cfe-commits
@@ -489,3 +494,92 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() { GV->eraseFromParent(); } } + +// Returns handle type from a resource, if the type is a resource +static const HLSLAttributedResourceType * +findHandleTypeOnResource(const clang::Type *Ty) { + retu

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

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

[clang] [llvm] [DirectX] Calculate resource binding offsets using the lower bound (PR #117303)

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

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

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

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-11-25 Thread Justin Bogner via cfe-commits
bogner wrote: This isn't testing the AST, so it shouldn't be in the `test/AST` folder. In any case, I think there's sufficient coverage by the changes to the `CodeGenHLSL/builtins` tests and `TypesTest`, so this one can probably just be removed. https://gith

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-11-25 Thread Justin Bogner via cfe-commits
@@ -40,10 +40,43 @@ TEST(TypesTest, TargetExtType) { Type *A = TargetExtType::get(Context, "typea"); Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1}); Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1}); + // Opaque types with same parameter

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-11-25 Thread Justin Bogner via cfe-commits
@@ -40,10 +40,43 @@ TEST(TypesTest, TargetExtType) { Type *A = TargetExtType::get(Context, "typea"); Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1}); Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1}); + // Opaque types with same parameter

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-11-25 Thread Justin Bogner via cfe-commits
@@ -40,10 +40,43 @@ TEST(TypesTest, TargetExtType) { Type *A = TargetExtType::get(Context, "typea"); Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1}); Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1}); + // Opaque types with same parameter

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-11-25 Thread Justin Bogner via cfe-commits
@@ -40,10 +40,43 @@ TEST(TypesTest, TargetExtType) { Type *A = TargetExtType::get(Context, "typea"); Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1}); Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1}); + // Opaque types with same parameter

[clang] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

2024-11-22 Thread Justin Bogner via cfe-commits
https://github.com/bogner updated https://github.com/llvm/llvm-project/pull/117017 >From a4e932c29bddb78bd287cabca2e9ea0da6c96337 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 13 Nov 2024 17:04:30 -0800 Subject: [PATCH 1/3] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_res

[clang] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

2024-11-22 Thread Justin Bogner via cfe-commits
@@ -12487,6 +12487,7 @@ def err_hlsl_pointers_unsupported : Error< "%select{pointers|references}0 are unsupported in HLSL">; def err_hlsl_missing_resource_class : Error<"HLSL resource needs to have [[hlsl::resource_class()]] attribute">; def err_hlsl_attribute_needs_intangib

[clang] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

2024-11-22 Thread Justin Bogner via cfe-commits
@@ -4738,6 +4738,12 @@ def GetDeviceSideMangledName : LangBuiltin<"CUDA_LANG"> { } // HLSL +def HLSLTypedBufferPointer : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_resource_getpointer"]; bogner wrote: All buffer types, the name was leftove

[clang] [HLSL] Get the index for resource bindings from the slot (PR #117303)

2024-11-22 Thread Justin Bogner via cfe-commits
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/117303 Resource bindings are indexed from the beginning of the binding space, not from the binding itself. This means that we need to populate the index for non-array resources with the same value as the slot number (a

[clang] [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (PR #116700)

2024-11-18 Thread Justin Bogner via cfe-commits
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/116700 This is a kind of StructuredBuffer, so it should be "Raw" and not "Typed". >From 0650fee514af7b4e5ca58f2bba4a8447ef1dd9c4 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 13 Nov 2024 17:02:52 -0800 Subjec

[clang] [HLSL] Rename resource's "h" member to "__handle". NFC (PR #116696)

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

[clang] [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (PR #116700)

2024-11-19 Thread Justin Bogner via cfe-commits
@@ -480,8 +480,8 @@ void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { onCompletion(Decl, [this](CXXRecordDecl *Decl) { setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, -ResourceKind::TypedBuffer, -/*IsROV=

[clang] [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (PR #116700)

2024-11-19 Thread Justin Bogner via cfe-commits
@@ -547,9 +543,8 @@ void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { .addSimpleTemplateParams(*SemaPtr, {"element_type"}) .Record; onCompletion(Decl, [this](CXXRecordDecl *Decl) { -setupBufferType(Decl, *SemaPtr, ResourceC

[clang] [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (PR #116700)

2024-11-18 Thread Justin Bogner via cfe-commits
https://github.com/bogner updated https://github.com/llvm/llvm-project/pull/116700 >From 0650fee514af7b4e5ca58f2bba4a8447ef1dd9c4 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 13 Nov 2024 17:02:52 -0800 Subject: [PATCH 1/2] [HLSL] Fix resource kind for RasterizerOrderedStructuredBuff

[clang] [HLSL] Rename resource's "h" member to "__handle". NFC (PR #116696)

2024-11-18 Thread Justin Bogner via cfe-commits
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/116696 This makes it clearer that the handle is an implementation detail by using a name that's reserved. >From 23eeca7761e1af49be14d36ab7c6a0aa004a4232 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Sun, 3 Nov 20

[clang] [HLSL] Fix placement of `const` for resource operator[] (PR #116698)

2024-11-18 Thread Justin Bogner via cfe-commits
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/116698 We had an incorrect AST here - We want `const T &`, not `T &const`. >From 7b8f568725dc3828c6ce1fdfac2151de9359ae2d Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 13 Nov 2024 13:56:28 -0800 Subject: [PAT

[clang] [HLSL] Fix placement of `const` for resource operator[] (PR #116698)

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

[clang] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

2024-11-20 Thread Justin Bogner via cfe-commits
https://github.com/bogner updated https://github.com/llvm/llvm-project/pull/117017 >From a4e932c29bddb78bd287cabca2e9ea0da6c96337 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 13 Nov 2024 17:04:30 -0800 Subject: [PATCH 1/2] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_res

[clang] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

2024-11-20 Thread Justin Bogner via cfe-commits
https://github.com/bogner created https://github.com/llvm/llvm-project/pull/117017 This introduces `__builtin_hlsl_resource_getpointer`, which lowers to `llvm.dx.resource.getpointer` and is used to implement indexing into resources. This will only work through the backend for typed buffers at

[clang] [HLSL] Add empty struct test cases to `__builtin_hlsl_is_typed_resource_element_compatible` test file (PR #115045)

2024-11-14 Thread Justin Bogner via cfe-commits
bogner wrote: When you change what a PR does, please remember to update the title and description. This went in saying it's about adding some test cases but it actually changes much more than that. https://github.com/llvm/llvm-project/pull/115045 ___

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

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

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

2024-11-26 Thread Justin Bogner via cfe-commits
@@ -656,18 +670,20 @@ BuiltinTypeDeclBuilder::addSimpleTemplateParams(ArrayRef Names, } BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addIncrementCounterMethod() { + using PH = BuiltinTypeMethodBuilder::PlaceHolder; return BuiltinTypeMethodBuilder(SemaRef, *this, "Incre

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

2024-11-26 Thread Justin Bogner via cfe-commits
@@ -502,7 +520,10 @@ struct BuiltinTypeMethodBuilder { HLSLParamModifierAttr::Spelling Modifier = HLSLParamModifierAttr::Keyword_in) { assert(Method == nullptr && "Cannot add param, method already

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

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

[clang] [HLSL][NFC] Refactor resource buffers AST tests (PR #117659)

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

[clang] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

2024-11-26 Thread Justin Bogner via cfe-commits
@@ -6,14 +6,17 @@ RasterizerOrderedStructuredBuffer Out2; [numthreads(1,1,1)] void main(unsigned GI : SV_GroupIndex) { + // CHECK: define void @main() + + // CHECK: %[[INPTR:.*]] = call noundef nonnull align 4 dereferenceable(4) ptr @llvm.dx.resource.getpointer.p0.tdx.RawB

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

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

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-12-02 Thread Justin Bogner via cfe-commits
@@ -40,10 +40,42 @@ TEST(TypesTest, TargetExtType) { Type *A = TargetExtType::get(Context, "typea"); Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1}); Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1}); + // Opaque types with same parameter

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

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

[clang] [llvm] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

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

[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-12-02 Thread Justin Bogner via cfe-commits
bogner wrote: The title and description are out of date since we changed the approach here - please update them. https://github.com/llvm/llvm-project/pull/115971 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma

[clang] [HLSL] Implement `Append` and `Consume` methods on `Append`/`ConsumeStructuredBuffer` (PR #118536)

2024-12-03 Thread Justin Bogner via cfe-commits
@@ -430,12 +432,20 @@ struct BuiltinTypeMethodBuilder { // Argument placeholders, inspired by std::placeholder. These are the indices // of arguments to forward to `callBuiltin`, and additionally `Handle` which // refers to the resource handle. - enum class PlaceHolder {

[clang] [HLSL] Implement `Append` and `Consume` methods on `Append`/`ConsumeStructuredBuffer` (PR #118536)

2024-12-03 Thread Justin Bogner via cfe-commits
https://github.com/bogner commented: Looks basically good, but I'll hold off on approving until we've discussed my comment regarding the API. https://github.com/llvm/llvm-project/pull/118536 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http

[clang] [HLSL] Implement `Append` and `Consume` methods on `Append`/`ConsumeStructuredBuffer` (PR #118536)

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

[clang] [llvm] [HLSL] Do not print details in IR for target extension types (PR #115971)

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

[clang] [HLSL] Implement `Append` and `Consume` methods on `Append`/`ConsumeStructuredBuffer` (PR #118536)

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

[clang] [llvm] [NFC] fix up typos (PR #121842)

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

[clang] [llvm] [HLSL] Move length support out of the DirectX Backend (PR #121611)

2025-01-03 Thread Justin Bogner via cfe-commits
@@ -13,6 +13,14 @@ namespace hlsl { namespace __detail { +template struct is_same { + static const bool value = false; +}; + +template struct is_same { + static const bool value = true; +}; bogner wrote: These seem fine, but we should make sure we're bei

<    2   3   4   5   6   7   8   9   >