[clang] [llvm] [DirectX] Make dx.RawBuffer an op that can't be replaced (PR #154620)

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

[clang] [llvm] [DirectX] Make dx.RawBuffer an op that can't be replaced (PR #154620)

2025-08-29 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/154620 >From b51b68d7b5e7019687f2b8617178f2a8d9932278 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 20 Aug 2025 17:11:37 -0400 Subject: [PATCH 01/14] [DirectX] Make dx.RawBuffer an op that can't be replaced

[clang] [llvm] [DirectX] Make dx.RawBuffer an op that can't be replaced (PR #154620)

2025-08-29 Thread Farzon Lotfi via cfe-commits
farzonl wrote: current failure is `Clang-Unit :: ./AllClangUnitTests/TimeProfilerTest/ConstantEvaluationCxx20`. Which is not related to this PRs changes. https://github.com/llvm/llvm-project/pull/154620 ___ cfe-commits mailing list cfe-commits@lists.

[clang] [HLSL][DirectX] Add the Qdx-rootsignature-strip driver option (PR #154454)

2025-08-22 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Wait for Justin or Chris, this isn't my area of expertise. https://github.com/llvm/llvm-project/pull/154454 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL][DirectX] Add the Qdx-rootsignature-strip driver option (PR #154454)

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

[clang] [HLSL][DirectX] Add the Qdx-rootsignature-strip driver option (PR #154454)

2025-08-22 Thread Farzon Lotfi via cfe-commits
@@ -295,6 +295,32 @@ void tools::hlsl::MetalConverter::ConstructJob( Exec, CmdArgs, Inputs, Input)); } +void tools::LLVMObjcopy::ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &O

[clang] [HLSL] Rewrite semantics parsing (PR #152537)

2025-08-18 Thread Farzon Lotfi via cfe-commits
@@ -396,7 +396,7 @@ class ClangGCC } // HLSL Annotation spellings -class HLSLAnnotation : Spelling; +class HLSLAnnotation : Spelling {} farzonl wrote: curious why this line changed? https://github.com/llvm/llvm-project/pull/152537 ___

[clang] [llvm] [HLSL][DirectX] Fix `dot2add` DXIL operation to use float overload (PR #152781)

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

[clang] [Clang][Sema] Reject unsupported opencl address space attributes in SYCL and HLSL (PR #152528)

2025-08-11 Thread Farzon Lotfi via cfe-commits
=?utf-8?q?Mészáros?= Gergely , =?utf-8?q?Mészáros?= Gergely ,Gergely Meszaros Message-ID: In-Reply-To: https://github.com/farzonl approved this pull request. >From an HLSL perspective this change is fine. Approval subject to satisying >concerns for SYCL and general Sema issues that other dom

[clang] [llvm] [HLSL][DirectX] Fix `dot2add` DXIL operation to use float overload (PR #152781)

2025-08-11 Thread Farzon Lotfi via cfe-commits
@@ -1,5 +1,5 @@ // RUN: %clang_cc1 -finclude-default-header -fnative-half-type -triple \ -// RUN: dxil-pc-shadermodel6.3-compute %s -emit-llvm -o - | \ +// RUN: dxil-pc-shadermodel6.4-compute %s -emit-llvm -o - | \ farzonl wrote: Should we add an error test

[clang] [llvm] [HLSL][Sema] Use hlsl::BindingInfoBuilder instead of RangeInfo. NFC (PR #150634)

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

[clang] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int (PR #151353)

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

[clang] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int (PR #151353)

2025-07-31 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/151353 >From b5f34ee30c375fb90fb2d4d1e4cdbb417a30812b Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 30 Jul 2025 11:32:38 -0400 Subject: [PATCH 1/3] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int fixes #150

[clang] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int (PR #151353)

2025-07-31 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/151353 >From b5f34ee30c375fb90fb2d4d1e4cdbb417a30812b Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 30 Jul 2025 11:32:38 -0400 Subject: [PATCH 1/3] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int fixes #150

[clang] [clang] Rename files that MacOS libtool warns about (NFC) (PR #150054)

2025-07-31 Thread Farzon Lotfi via cfe-commits
farzonl wrote: > Should we just use ar/ranlib instead of libtool on Apple platform? I'm not > sure how much performance difference there is between ar and libtool. I'm pretty sure if you use an entirely llvm based tool chain that is what is happening and you won't see this error. The problem I

[clang] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int (PR #151353)

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

[clang] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int (PR #151353)

2025-07-31 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/151353 >From b5f34ee30c375fb90fb2d4d1e4cdbb417a30812b Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 30 Jul 2025 11:32:38 -0400 Subject: [PATCH 1/2] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int fixes #150

[clang] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int (PR #151353)

2025-07-31 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/151353 >From f89ea77874da5f5964a857f6871476058a9bc673 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 30 Jul 2025 11:32:38 -0400 Subject: [PATCH 1/2] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int fixes #150

[clang] [HLSL] fix D3DCOLORtoUBYTE4 return type to be int (PR #151353)

2025-07-30 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/151353 fixes #150673 fixes #150678 The issue was we were using the wrong return type. >From f89ea77874da5f5964a857f6871476058a9bc673 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 30 Jul 2025 11:32:38 -0400 S

[clang] [HLSL] Avoid putting the byval attribute on out and inout parameters (PR #150495)

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

[clang] [clang] Rename files that MacOS libtool warns about (NFC) (PR #150054)

2025-07-23 Thread Farzon Lotfi via cfe-commits
@@ -1,4 +1,4 @@ -//===--- AMDCPU.cpp - Emit LLVM Code for builtins -===// +//===--- BuiltinAMDCPU.cpp - Emit LLVM Code for builtins --===// farzonl wrote: ```suggestion //===--- BuiltinAMDGPU.cpp - Emit LLVM Code for

[clang] [clang] Rename files that MacOS libtool warns about (NFC) (PR #150054)

2025-07-22 Thread Farzon Lotfi via cfe-commits
farzonl wrote: This change will absolutely fix the issue, I was advised on my few attempts that we want to be able to keep the same name and the fix should be in cmake and not a file rename. For example We have many `AMDGPU.cpp` - clang/lib/Basic/Targets/AMDGPU.cpp - clang/lib/CodeGen/Targets/

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

2025-07-16 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/147342 ___ 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 #147342)

2025-07-16 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -O1 -triple spirv-pc-vulkan-compute %s -emit-llvm -o - | FileCheck %s + +typedef float float2 __attribute__((ext_vector_type(2))); +typedef float float3 __attribute__((ext_vector_type(3))); +typedef float float4 __attribute__((ext_vector_type(

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

2025-07-10 Thread Farzon Lotfi via cfe-commits
@@ -235,6 +288,30 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(const TargetInfo &TI, TheCall->setType(RetTy); break; } + case SPIRV::BI__builtin_spirv_refract: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +llvm::function_ref +C

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

2025-07-10 Thread Farzon Lotfi via cfe-commits
@@ -71,6 +71,17 @@ constexpr vector reflect_vec_impl(vector I, vector N) { #endif } +template constexpr T refract_impl(T I, T N, U Eta) { +#if (__has_builtin(__builtin_spirv_refract)) + if (is_vector::value) farzonl wrote: It looks like SPIRV refract does

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

2025-07-09 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/147342 ___ 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 #147342)

2025-07-09 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,36 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} farzonl wrote: There is no spirv64 target if you want to use the glsl e

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

2025-07-09 Thread Farzon Lotfi via cfe-commits
@@ -235,6 +288,30 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(const TargetInfo &TI, TheCall->setType(RetTy); break; } + case SPIRV::BI__builtin_spirv_refract: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +llvm::function_ref +C

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

2025-07-08 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/147342 ___ 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 #147342)

2025-07-08 Thread Farzon Lotfi via cfe-commits
@@ -475,6 +475,65 @@ reflect(__detail::HLSL_FIXED_VECTOR I, return __detail::reflect_vec_impl(I, N); } +//===--===// +// refract builtin +//===

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

2025-07-08 Thread Farzon Lotfi via cfe-commits
@@ -71,6 +71,42 @@ constexpr vector reflect_vec_impl(vector I, vector N) { #endif } +template constexpr T refract_impl(T I, T N, T Eta) { + T Mul = N * I; + T K = 1 - Eta * Eta * (1 - (Mul * Mul)); + T Result = (Eta * I - (Eta * Mul + sqrt(K)) * N); + return select(K < 0

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

2025-07-08 Thread Farzon Lotfi via cfe-commits
@@ -475,6 +475,65 @@ reflect(__detail::HLSL_FIXED_VECTOR I, return __detail::reflect_vec_impl(I, N); } +//===--===// +// refract builtin +//===

[clang] [llvm] [SPIRV] Add more id and range builtIns (PR #143909)

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

[clang] [llvm] [SPIRV] Add more id and range builtIns (PR #143909)

2025-06-24 Thread Farzon Lotfi via cfe-commits
farzonl wrote: There is an advantage to intrinsics that builtins lack in that intrinsics being entirely a backend feature set makes it easier to support non clang based frontends. Say we wanted to do something MLIR based. https://github.com/llvm/llvm-project/pull/143909 __

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

2025-06-23 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] [HLSL] Don't use CreateRuntimeFunction for intrinsics (PR #145334)

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

[clang] [HLSL] Don't use CreateRuntimeFunction for intrinsics (PR #145334)

2025-06-23 Thread Farzon Lotfi via cfe-commits
@@ -676,35 +676,23 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, case Builtin::BI__builtin_hlsl_wave_active_sum: { // Due to the use of variadic arguments, explicitly retreive argument Value *OpExpr = EmitScalarExpr(E->getArg(0)); -llvm::Func

[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)"

  1   2   3   4   5   6   7   8   9   10   >