[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-10 Thread Farzon Lotfi via cfe-commits
Nathan =?utf-8?q?Gau=C3=ABr?= , Nathan =?utf-8?q?Gau=C3=ABr?= , Nathan =?utf-8?q?Gau=C3=ABr?= , Nathan =?utf-8?q?Gau=C3=ABr?= , Nathan =?utf-8?q?Gau=C3=ABr?= Message-ID: In-Reply-To: https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/141759 __

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-10 Thread Farzon Lotfi via cfe-commits
Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= Message-ID: In-Reply-To: @@ -1147,6 +1154,26 @@ void SemaHLSL::handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL) {

[clang] [HLSL][SPIR-V] Change SPV AS map for groupshared (PR #143519)

2025-06-10 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/143519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-10 Thread Farzon Lotfi via cfe-commits
Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= , Nathan =?utf-8?q?Gauër?= Message-ID: In-Reply-To: @@ -1147,6 +1154,26 @@ void SemaHLSL::handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL) {

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -1147,6 +1154,26 @@ void SemaHLSL::handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL) { HLSLSV_DispatchThreadIDAttr(getASTContext(), AL)); } +bool SemaHLSL::diagnosePositionType(QualType T, const ParsedAttr &AL) { + const auto *VT = T->getAs();

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -764,6 +764,13 @@ void SemaHLSL::CheckSemanticAnnotation( return; DiagnoseAttrStageMismatch(AnnotationAttr, ST, {llvm::Triple::Compute}); break; + case attr::HLSLSV_Position: +// TODO: allow use on other shader types & output once the overall semantic

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -407,6 +429,13 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B, llvm::Function *GroupIDIntrinsic = CGM.getIntrinsic(getGroupIdIntrinsic()); return buildVectorInput(B, GroupIDIntrinsic, Ty); } + if (D.hasAttr()) { +if (getArch() == llvm::Triple

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -384,6 +384,28 @@ static Value *buildVectorInput(IRBuilder<> &B, Function *F, llvm::Type *Ty) { return B.CreateCall(F, {B.getInt32(0)}); } +static void addBuiltinDecoration(llvm::GlobalVariable *GV, unsigned BuiltIn) { + LLVMContext &Ctx = GV->getContext(); + IRBuilder

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/141759 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -384,6 +384,28 @@ static Value *buildVectorInput(IRBuilder<> &B, Function *F, llvm::Type *Ty) { return B.CreateCall(F, {B.getInt32(0)}); } +static void addBuiltinDecoration(llvm::GlobalVariable *GV, unsigned BuiltIn) { + LLVMContext &Ctx = GV->getContext(); + IRBuilder

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -8472,6 +8472,20 @@ The full documentation is available here: https://docs.microsoft.com/en-us/windo }]; } +def HLSLSV_PositionDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``SV_Position`` semantic, when applied to an input parameter i

[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -8472,6 +8472,20 @@ The full documentation is available here: https://docs.microsoft.com/en-us/windo }]; } +def HLSLSV_PositionDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``SV_Position`` semantic, when applied to an input parameter i

[clang] [llvm] [HLSL] Add WaveGetLaneCount() intrinsic to FE (PR #143127)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -2350,6 +2350,10 @@ _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane) __attribute__((convergent)) bool WaveIsFirstLane(); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_get_lane_count) +__attribute__(

[clang] [llvm] [HLSL] Add WaveGetLaneCount() intrinsic to FE (PR #143127)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -4909,6 +4909,12 @@ def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } +def HLSLWaveGetLaneCount : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_wave_get_lane_count"]; + let Attributes = [NoThrow, Const]; + let Prototype

[clang] [llvm] [HLSL] Add WaveGetLaneCount() intrinsic to FE (PR #143127)

2025-06-06 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/143127 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Add WaveGetLaneCount() intrinsic to FE (PR #143127)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -691,6 +691,11 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, return EmitRuntimeCall( Intrinsic::getOrInsertDeclaration(&CGM.getModule(), ID)); } + case Builtin::BI__builtin_hlsl_wave_get_lane_count: { +Intrinsic::ID ID = CGM.getHLSLRu

[clang] [llvm] [HLSL] Add WaveGetLaneCount() intrinsic to FE (PR #143127)

2025-06-06 Thread Farzon Lotfi via cfe-commits
@@ -4909,6 +4909,12 @@ def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } +def HLSLWaveGetLaneCount : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_wave_get_lane_count"]; + let Attributes = [NoThrow, Const]; + let Prototype

[clang] [llvm] [DirectX] add GEP i8 legalization (PR #142475)

2025-06-03 Thread Farzon Lotfi via cfe-commits
@@ -106,3 +106,57 @@ define i32 @all_imm() { %2 = sext i8 %1 to i32 ret i32 %2 } + +define i32 @scalar_i8_geps() { + ; CHECK-LABEL: define i32 @scalar_i8_geps( + ; CHECK-NEXT:[[ALLOCA:%.*]] = alloca i32, align 4 + ; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds

[clang] [llvm] [DirectX] add GEP i8 legalization (PR #142475)

2025-06-03 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/142475 >From 244b01e43f4c974c682c90d1315c59605da2b289 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Mon, 2 Jun 2025 15:40:22 -0400 Subject: [PATCH 1/5] [DirectX] add GEP i8 legalization The i8 legalization code in

[clang] [SPIR-V] Only emit __spirv__ when targeting HLSL (PR #142401)

2025-06-02 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/142401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-05-29 Thread Farzon Lotfi via cfe-commits
farzonl wrote: @Naghasan @VyacheslavLevytskyy there is an issue in SemaSPIRV.cpp ``` clang/lib/Sema/SemaSPIRV.cpp:132:3: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default] 132 | default: | ^ 1 error generated. ``` https://github.co

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-05-21 Thread Farzon Lotfi via cfe-commits
@@ -20,7 +20,7 @@ namespace clang { class SemaSPIRV : public SemaBase { public: SemaSPIRV(Sema &S); - + bool CheckVectorArgs(CallExpr *TheCall, unsigned NumArgsToCheck); farzonl wrote: This is a helper, we don't need to expose it in the class. No one needs

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-05-21 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,28 @@ +// RUN: %clang_cc1 %s -triple spirv-pc-vulkan-compute -verify + +typedef float float2 __attribute__((ext_vector_type(2))); + +float2 test_no_second_arg(float2 p0) { + return __builtin_spirv_refract(p0); + // expected-error@-1 {{too few arguments to function cal

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-05-21 Thread Farzon Lotfi via cfe-commits
@@ -26,6 +26,12 @@ def SPIRVReflect : Builtin { let Prototype = "void(...)"; } +def SPIRVRefract : Builtin { + let Spellings = ["__builtin_spirv_refract"]; + let Attributes = [NoThrow, Const]; farzonl wrote: You need to add `CustomTypeChecking`. ```sugges

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-05-21 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,290 @@ +// RUN: %clang_cc1 -finclude-default-header -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -finclude-default-header -triple \ +// RUN: spirv-unknown-vulkan-compute %s -f

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-21 Thread Farzon Lotfi via cfe-commits
@@ -2507,13 +2441,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { break; } case Builtin::BI__builtin_hlsl_dot: { -if (SemaRef.checkArgCount(TheCall, 2)) farzonl wrote: a comment to this effect would be good, b

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-21 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/138429 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Move where ZExt happens in 'EmitStoreThroughExtVectorComponentLValue' to handle bug with hlsl boolean vector swizzles (PR #140627)

2025-05-19 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/140627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX][SPIRV] Fix the lowering of dot4add (PR #140315)

2025-05-16 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/140315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,63 @@ +# RUN: llc -verify-machineinstrs -O0 -mtriple spirv-unknown-unknown -run-pass=spirv-prelegalizer-combiner %s -o - | FileCheck %s +# REQUIRES: asserts +--- +name:faceforward_instcombine_float +tracksRegLiveness: true +legalized: true +body:

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,63 @@ +# RUN: llc -verify-machineinstrs -O0 -mtriple spirv-unknown-unknown -run-pass=spirv-prelegalizer-combiner %s -o - | FileCheck %s +# REQUIRES: asserts +--- +name:faceforward_instcombine_float +tracksRegLiveness: true +legalized: true +body:

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/139959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/139959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -98,21 +110,98 @@ void applySPIRVDistance(MachineInstr &MI, MachineRegisterInfo &MRI, SPIRVGlobalRegistry *GR = MI.getMF()->getSubtarget().getSPIRVGlobalRegistry(); - auto RemoveAllUses = [&](Register Reg) { -SmallVector UsesToErase( -llvm::make_pointe

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,63 @@ +# RUN: llc -verify-machineinstrs -O0 -mtriple spirv-unknown-unknown -run-pass=spirv-prelegalizer-combiner %s -o - | FileCheck %s +# REQUIRES: asserts +--- +name:faceforward_instcombine_float +tracksRegLiveness: true +legalized: true +body:

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/139959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/139959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,63 @@ +# RUN: llc -verify-machineinstrs -O0 -mtriple spirv-unknown-unknown -run-pass=spirv-prelegalizer-combiner %s -o - | FileCheck %s +# REQUIRES: asserts +--- +name:faceforward_instcombine_float +tracksRegLiveness: true +legalized: true +body:

[clang] [llvm] [SPIRV] Add PreLegalizer instCombine for `faceforward` (PR #139959)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,13 @@ +; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s +; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s + +; CHECK: LLVM ERROR: %{{.*}} = G_INTR

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -42,47 +42,47 @@ float2 test_mad_element_type_mismatch(half2 p0, float2 p1) { float2 test_builtin_mad_float2_splat(float p0, float2 p1) { return __builtin_hlsl_mad(p0, p1, p1); - // expected-error@-1 {{all arguments to '__builtin_hlsl_mad' must be vectors}} + // expect

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -2507,13 +2441,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { break; } case Builtin::BI__builtin_hlsl_dot: { -if (SemaRef.checkArgCount(TheCall, 2)) farzonl wrote: Why did you remove this? Since you are le

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -2446,37 +2376,41 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case Builtin::BI__builtin_hlsl_any: { if (SemaRef.checkArgCount(TheCall, 1)) return true; +if (CheckAnyScalarOrVector(&SemaRef, TheCall, 0)) + return t

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -2446,37 +2376,41 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case Builtin::BI__builtin_hlsl_any: { if (SemaRef.checkArgCount(TheCall, 1)) return true; +if (CheckAnyScalarOrVector(&SemaRef, TheCall, 0)) + return t

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -2446,37 +2376,41 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case Builtin::BI__builtin_hlsl_any: { if (SemaRef.checkArgCount(TheCall, 1)) return true; +if (CheckAnyScalarOrVector(&SemaRef, TheCall, 0)) + return t

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -2446,37 +2376,41 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case Builtin::BI__builtin_hlsl_any: { if (SemaRef.checkArgCount(TheCall, 1)) return true; +if (CheckAnyScalarOrVector(&SemaRef, TheCall, 0)) + return t

[clang] [HLSL] Update Sema Checking Diagnostics for builtins (PR #138429)

2025-05-15 Thread Farzon Lotfi via cfe-commits
@@ -2164,30 +2083,48 @@ static bool CheckModifiableLValue(Sema *S, CallExpr *TheCall, return true; } -static bool CheckNoDoubleVectors(Sema *S, CallExpr *TheCall) { - auto checkDoubleVector = [](clang::QualType PassedType) -> bool { -if (const auto *VecTy = PassedType-

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-05-14 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,356 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -finclude-default-header -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -O1 -o - | FileChe

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-05-12 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Handle init list with OpaqueValueExprs in CGExprScalar (PR #138541)

2025-05-05 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/138541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `ldexp` intrinsic (PR #138182)

2025-05-02 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Might be worth looking at usages of ldexp in https://github.com/microsoft/DirectX-Graphics-Samples/tree/master/MiniEngine/Core/Shaders/PixelPacking_RGBE.hlsli specically lines 52 and 79 and make sure their is no ambiguous cases to answer @V-FEXrt question here: https://github.

[clang] [HLSL] Implement the `ldexp` intrinsic (PR #138182)

2025-05-02 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/138182 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `ldexp` intrinsic (PR #138182)

2025-05-02 Thread Farzon Lotfi via cfe-commits
@@ -303,6 +303,48 @@ fmod(__detail::HLSL_FIXED_VECTOR X, return __detail::fmod_vec_impl(X, Y); } +//===--===// +// ldexp builtins +//===--=

[clang] [HLSL] Implement the `ldexp` intrinsic (PR #138182)

2025-05-02 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. This looks fine. I would not like to carry forward native half testing of intrinsics that are written purely in HLSL. I think the builtin ones aren't great either but I understand how they came to exist. As for looking at notes. its eas

[clang] [HLSL] Implement the `ldexp` intrinsic (PR #138182)

2025-05-02 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/138182 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `ldexp` intrinsic (PR #138182)

2025-05-02 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify + +float test_double_inputs(double p0, double p1) { + return ldexp(p0, p1); + // expected-error@-1 {{no matc

[clang] [HLSL] Implement the `ldexp` intrinsic (PR #138182)

2025-05-02 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s farzonl wrote: I was hoping we would only do those for intrinsics that require

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-05-02 Thread Farzon Lotfi via cfe-commits
@@ -147,7 +147,7 @@ template constexpr vector lit_impl(T NDotL, T NDotH, T M) { return Result; } -} // namespace __detail +} // namespace __dETAil farzonl wrote: fix this too https://github.com/llvm/llvm-project/pull/136026 __

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-05-02 Thread Farzon Lotfi via cfe-commits
@@ -10,7 +10,7 @@ #define _HLSL_HLSL_INTRINSIC_HELPERS_H_ namespace hlsl { -namespace __detail { +namespace __dETAil { farzonl wrote: this looks like you did find replace for eta. Please revert this change. In the future you can use clangd' vscode plugin to

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-30 Thread Farzon Lotfi via cfe-commits
farzonl wrote: I have a strong suspicion all the `*-overload.hlsl` tests have the same mistake and are also incorrect and need to updated. Can you file a ticket for investigating\cleaning up the other overload tests. Not work you have to do, but we should at least track that it needs ot be d

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-30 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/137898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/137898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -1,108 +1,160 @@ -// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ -// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ -// RUN: -o - | FileCheck %s --check-prefixes=CHECK \ -// RUN: -DFNATTRS="noundef nofpclass(nan inf)"

[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/137877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Since we are open to this for lerp I think we should file a similar issue for `pow(vector<*>, scalar>);` Its much more user friendlly if we had an overload that would let us use a scalar for the exponent. https://github.com/llvm/llvm-project/pull/137877 ___

[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -277,6 +277,12 @@ constexpr bool4 isinf(double4 V) { return isinf((float4)V); } // lerp builtins overloads //===--===// +template +constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> -

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -71,6 +71,27 @@ constexpr vector reflect_vec_impl(vector I, vector N) { #endif } +template constexpr T refract_impl(T I, T N, T eta) { + T k = 1 - eta * eta * (1 - (N * I * N *I)); farzonl wrote: Install clangd vscode extension it has a tool that will f

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-04-29 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/136026 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -3087,6 +3087,8 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, return selectExtInst(ResVReg, ResType, I, CL::fract, GL::Fract); case Intrinsic::spv_normalize: return selectExtInst(ResVReg, ResType, I, CL::normalize, GL::Normalize); + case Int

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() con

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() con

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl deleted https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -5837,12 +5838,13 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64(); bool IsARM = S.Context.getTargetInfo().getTriple().isARM(); bool IsRISCV = S.Context.getTargetInfo().g

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() con

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() con

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Farzon Lotfi via cfe-commits
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() con

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-04-28 Thread Farzon Lotfi via cfe-commits
@@ -71,6 +71,27 @@ constexpr vector reflect_vec_impl(vector I, vector N) { #endif } +template constexpr T refract_impl(T I, T N, T eta) { + T k = 1 - eta * eta * (1 - (N * I * N *I)); + if(k < 0) farzonl wrote: I feel like we can simplify these conditiona

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-04-28 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,356 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -finclude-default-header -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -O1 -o - | FileChe

[clang] [llvm] [HLSL][DXIL] Implement `refract` intrinsic (PR #136026)

2025-04-28 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,356 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -finclude-default-header -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -O1 -o - | FileChe

[clang] [HLSL] Treat classes and structs as packed by default (PR #137391)

2025-04-28 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/137391 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DXIL] Remove incompatible metadata types when preparing DXIL. (PR #136386)

2025-04-28 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/136386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DXIL] Remove incompatible metadata types when preparing DXIL. (PR #136386)

2025-04-28 Thread Farzon Lotfi via cfe-commits
@@ -189,6 +201,9 @@ class DXILPrepareModule : public ModulePass { for (auto &BB : F) { IRBuilder<> Builder(&BB); for (auto &I : make_early_inc_range(BB)) { + + I.dropUnknownNonDebugMetadata(DXILCompatibleMDs); + if (I.getOpcode() == Ins

[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-24 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/135878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Boolean in a RawBuffer should be i32 and Boolean vector in a RawBuffer should be (PR #135848)

2025-04-21 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/135848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Reland; Make it possible to assign an array from a cbuffer (PR #136580)

2025-04-21 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/136580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-21 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,63 @@ +; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val --target-env vulkan1.3 %} + +; TODO(#136344): This test currently fail

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-21 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl closed https://github.com/llvm/llvm-project/pull/136234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-18 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/136234 >From 562084ce64581b1cffe30024082f9eb84393875c Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Thu, 17 Apr 2025 17:42:34 -0700 Subject: [PATCH 1/4] [DirectX] add Function name to DiagnosticInfoUnsupported Msg

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-18 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl deleted https://github.com/llvm/llvm-project/pull/136234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-18 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,7 @@ +// RUN: %if clang-dxc %{not %clang_dxc -T lib_6_3 %s 2>&1 | FileCheck %s %} farzonl wrote: I tried REQUIRES: directx-registered-target and it just makes it so the test gets skipped as unsupported even on my local machine with the directx target

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-18 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/136234 >From 562084ce64581b1cffe30024082f9eb84393875c Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Thu, 17 Apr 2025 17:42:34 -0700 Subject: [PATCH 1/3] [DirectX] add Function name to DiagnosticInfoUnsupported Msg

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-18 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/136234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-18 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/136234 >From 562084ce64581b1cffe30024082f9eb84393875c Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Thu, 17 Apr 2025 17:42:34 -0700 Subject: [PATCH 1/2] [DirectX] add Function name to DiagnosticInfoUnsupported Msg

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-18 Thread Farzon Lotfi via cfe-commits
farzonl wrote: > This doesn't seem right. Are we just misusing `DiagnosticInfoUnsupported` > here? The `Function` argument for `DiagnosticInfoWithLocationBase` is clearly > meant to be part of the location (as evidenced by the "in function XYZ" part > of the message). I suspect that we should

[clang] [llvm] [DirectX] add Function name to DiagnosticInfoUnsupported Msg in DXILOpLowering (PR #136234)

2025-04-17 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/136234 fixes #135654 In #128613 we added safe guards to prevent the lowering of just any intrinsic in the backend. We used `DiagnosticInfoUnsupported` to do this. What we found was when using `opt` the diagnostic pri

[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-17 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/135878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-17 Thread Farzon Lotfi via cfe-commits
@@ -105,35 +136,27 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, if (SemaRef.checkArgCount(TheCall, 3)) return true; -// check if the all arguments have floating representation -for (unsigned i = 0; i < TheCall->getNumArgs(); ++i) { -

[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-17 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,35 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1 -O1 -triple spirv-pc-vulkan-compute %s -emit-llvm -o - | FileCheck %s + +typedef float float2 __attribute__((ext_vector_type(2))); +typedef

[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-17 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/135878 ___ 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   >