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

2025-05-19 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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 pattern matching for `faceforward` (PR #139959)

2025-05-19 Thread Kaitlin Peng 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 pattern matching for `faceforward` (PR #139959)

2025-05-16 Thread Kaitlin Peng 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 pattern matching for `faceforward` (PR #139959)

2025-05-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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 pattern matching for `faceforward` (PR #139959)

2025-05-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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 pattern matching for `faceforward` (PR #139959)

2025-05-16 Thread Kaitlin Peng 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 pattern matching for `faceforward` (PR #139959)

2025-05-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/139959 >From be7df595c1df0f310a1941da3d3ac3529270241e Mon Sep 17 00:00:00 2001 From: kmpeng Date: Tue, 29 Apr 2025 16:46:08 -0700 Subject: [PATCH 1/5] WIP - debug `matchSelectToFaceForward` --- .../lib/Headers/hlsl/hl

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

2025-05-16 Thread Kaitlin Peng 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 pattern matching for `faceforward` (PR #139959)

2025-05-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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 pattern matching for `faceforward` (PR #139959)

2025-05-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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 Kaitlin Peng 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-14 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng created https://github.com/llvm/llvm-project/pull/139959 Tasks completed: - instCombine `select(fcmp(dot(p2, p3), 0), p1, 0 - p1)` to `faceforward(p1, p2, p3)` - Remove HLSL `faceforward` intrinsic's SPIR-V fast path - Add instCombine tests to `prelegalizercombiner-sel

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

2025-05-02 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng closed 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 Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/138182 >From d5187a940fc0a16325eedb0c67bcf647deb95d8f Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 1 May 2025 11:48:47 -0700 Subject: [PATCH 1/4] ldexp implementation and tests --- .../lib/Headers/hlsl/hlsl_intrin

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

2025-05-01 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/138182 >From d5187a940fc0a16325eedb0c67bcf647deb95d8f Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 1 May 2025 11:48:47 -0700 Subject: [PATCH 1/3] ldexp implementation and tests --- .../lib/Headers/hlsl/hlsl_intrin

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

2025-05-01 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/138182 >From d5187a940fc0a16325eedb0c67bcf647deb95d8f Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 1 May 2025 11:48:47 -0700 Subject: [PATCH 1/2] ldexp implementation and tests --- .../lib/Headers/hlsl/hlsl_intrin

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

2025-05-01 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng created https://github.com/llvm/llvm-project/pull/138182 Closes #99133. Implemented `ldexp` entirely in `hlsl_intrinsics.h` and `hlsl_intrinsic_helpers.h`, added coresponding tests in `clang/test/CodeGenHLSL/builtins/ldexp.hlsl` and `clang/test/SemaHLSL/BuiltIns/lde

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

2025-04-29 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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 Kaitlin Peng via cfe-commits
@@ -89,7 +132,7 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, QualType ArgTyB = B.get()->getType(); auto *VTyB = ArgTyB->getAs(); if (VTyB == nullptr) { - SemaRef.Diag(A.get()->getBeginLoc(), + SemaRef.Diag(B.get()->getBeginLoc(), -

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

2025-04-29 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng deleted 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 Kaitlin Peng 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-04-29 Thread Kaitlin Peng 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)); kmpeng wrote: Variables should [start with an upper-case letter](https:

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

2025-04-29 Thread Kaitlin Peng via cfe-commits
@@ -89,7 +132,7 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, QualType ArgTyB = B.get()->getType(); auto *VTyB = ArgTyB->getAs(); if (VTyB == nullptr) { - SemaRef.Diag(A.get()->getBeginLoc(), + SemaRef.Diag(B.get()->getBeginLoc(), -

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

2025-04-24 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng closed 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-24 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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-24 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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-24 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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-24 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/135878 >From 115b4f8e6276c4dd19e66136a5ad01b6b22f7586 Mon Sep 17 00:00:00 2001 From: kmpeng Date: Mon, 7 Apr 2025 14:46:07 -0700 Subject: [PATCH 1/5] create int_spv_faceforward intrinsic, create faceforward lowering &

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

2025-04-24 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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-18 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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-18 Thread Kaitlin Peng 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-18 Thread Kaitlin Peng via cfe-commits
@@ -126,6 +126,24 @@ template constexpr vector lit_impl(T NDotL, T NDotH, T M) { return Result; } +template constexpr T faceforward_impl(T N, T I, T Ng) { kmpeng wrote: You're right. Removed vector implementation https://github.com/llvm/llvm-project/pul

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

2025-04-18 Thread Kaitlin Peng 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-18 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/135878 >From d953d95867574dd575cf098668554dfa8e7ffad5 Mon Sep 17 00:00:00 2001 From: kmpeng Date: Mon, 7 Apr 2025 14:46:07 -0700 Subject: [PATCH 1/4] create int_spv_faceforward intrinsic, create faceforward lowering &

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

2025-04-18 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/135878 >From 69aee464d31dcf585c355808053b0c4d1c7d7f3c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Mon, 7 Apr 2025 14:46:07 -0700 Subject: [PATCH 1/4] create int_spv_faceforward intrinsic, create faceforward lowering &

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

2025-04-17 Thread Kaitlin Peng 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-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/135878 >From 69aee464d31dcf585c355808053b0c4d1c7d7f3c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Mon, 7 Apr 2025 14:46:07 -0700 Subject: [PATCH 1/3] create int_spv_faceforward intrinsic, create faceforward lowering &

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

2025-04-16 Thread Kaitlin Peng via cfe-commits
@@ -214,6 +214,53 @@ const inline double4 dst(double4 Src0, double4 Src1) { return __detail::dst_impl(Src0, Src1); } +//===--===// +// faceforward builtin +//===--

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

2025-04-16 Thread Kaitlin Peng via cfe-commits
@@ -137,6 +137,42 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, TheCall->setType(RetTy); break; } + case SPIRV::BI__builtin_spirv_faceforward: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +// check if all arguments h

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

2025-04-16 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,94 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ kmpeng wrote: Code updated https://github.com/llvm/llvm-project/pull/135878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:

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

2025-04-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng 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-16 Thread Kaitlin Peng via cfe-commits
@@ -137,6 +137,42 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, TheCall->setType(RetTy); break; } + case SPIRV::BI__builtin_spirv_faceforward: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +// check if all arguments h

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

2025-04-16 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/135878 >From 69aee464d31dcf585c355808053b0c4d1c7d7f3c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Mon, 7 Apr 2025 14:46:07 -0700 Subject: [PATCH 1/2] create int_spv_faceforward intrinsic, create faceforward lowering &

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

2025-04-15 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng created https://github.com/llvm/llvm-project/pull/135878 Resolves #99114. There will be a follow-up PR on pattern matching later. Tasks completed: - Implement `faceforward` in `hlsl_intrinsics.h`/`hlsl_intrinsic_helpers.h` - Implement `faceforward` SPIR-V target builti

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-10 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-10 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-09 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng closed https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-09 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/134171 >From 719bb94279f64f134c826faa22898e4e549bb23c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 27 Mar 2025 14:39:27 -0700 Subject: [PATCH 01/11] finished lit implementation, added codegen and sema tests --- .

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected=note + +float4 test_double_inputs(double p0, double p1, double p2) { + retur

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/134171 >From d87804880ceee63329761178e780bd301b3e50f6 Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 27 Mar 2025 14:39:27 -0700 Subject: [PATCH 01/13] finished lit implementation, added codegen and sema tests --- .

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,34 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s ---

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/134171 >From d87804880ceee63329761178e780bd301b3e50f6 Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 27 Mar 2025 14:39:27 -0700 Subject: [PATCH 01/12] finished lit implementation, added codegen and sema tests --- .

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
@@ -280,6 +280,17 @@ constexpr bool4 isinf(double4 V) { return isinf((float4)V); } _DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(lerp) _DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(lerp) +//===--===// +// lit builtins overloa

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify + +float4 test_no_second_arg(float p0) { + return lit(p0); + // expected-error@-1 {{no matching funct

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=half +// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s -DTEST_TYPE=int16_t +// RUN: not %clang_dxc -enable-16bit-types -T cs_6_

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-08 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/134171 >From 719bb94279f64f134c826faa22898e4e549bb23c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 27 Mar 2025 14:39:27 -0700 Subject: [PATCH 01/12] finished lit implementation, added codegen and sema tests --- .

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-07 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-07 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-07 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-07 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-07 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-07 Thread Kaitlin Peng via cfe-commits
kmpeng wrote: I currently don't have `-fnative-half-type` enabled in that file, so yes this test case ends up having `float` input/return types (though it's not necessarily being converted in the function, if that's what you're asking). With `-fnative-half-ty

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-04-05 Thread Kaitlin Peng via cfe-commits
@@ -322,5 +322,53 @@ reflect(__detail::HLSL_FIXED_VECTOR I, __detail::HLSL_FIXED_VECTOR N) { return __detail::reflect_vec_impl(I, N); } + +//===--===// +// smoothstep builtin +//===---

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-05 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/134171 >From 719bb94279f64f134c826faa22898e4e549bb23c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 27 Mar 2025 14:39:27 -0700 Subject: [PATCH 1/8] finished lit implementation, added codegen and sema tests --- .../

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-04 Thread Kaitlin Peng via cfe-commits
@@ -253,6 +253,37 @@ const inline float length(__detail::HLSL_FIXED_VECTOR X) { return __detail::length_vec_impl(X); } +//===--===// +// lit builtins +//===--

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-04 Thread Kaitlin Peng via cfe-commits
@@ -101,6 +101,16 @@ constexpr vector smoothstep_vec_impl(vector Min, vector Max, #endif } +template constexpr vector lit_impl(T NDotL, T NDotH, T M) { + bool DiffuseCond = NDotL < 0; + T Diffuse = select(DiffuseCond, 0, NDotL); + vector Result = {1, Diffuse, 0, 1}; + bo

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-04 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
@@ -280,6 +280,22 @@ constexpr bool4 isinf(double4 V) { return isinf((float4)V); } _DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(lerp) _DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(lerp) +//===--===// +// lit builtins overloa

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
@@ -280,6 +280,22 @@ constexpr bool4 isinf(double4 V) { return isinf((float4)V); } _DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(lerp) _DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(lerp) +//===--===// +// lit builtins overloa

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/134171 >From 719bb94279f64f134c826faa22898e4e549bb23c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 27 Mar 2025 14:39:27 -0700 Subject: [PATCH 1/9] finished lit implementation, added codegen and sema tests --- .../

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
@@ -253,6 +253,37 @@ const inline float length(__detail::HLSL_FIXED_VECTOR X) { return __detail::length_vec_impl(X); } +//===--===// +// lit builtins +//===--

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
@@ -280,6 +280,22 @@ constexpr bool4 isinf(double4 V) { return isinf((float4)V); } _DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(lerp) _DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(lerp) +//===--===// +// lit builtins overloa

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng deleted https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
@@ -101,6 +101,16 @@ constexpr vector smoothstep_vec_impl(vector Min, vector Max, #endif } +template constexpr vector lit_impl(T NDotL, T NDotH, T M) { + bool DiffuseCond = NDotL < 0; + T Diffuse = select(DiffuseCond, 0, NDotL); + vector Result = {1, Diffuse, 0, 1}; + bo

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,36 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s + +// CHECK

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/134171 >From 719bb94279f64f134c826faa22898e4e549bb23c Mon Sep 17 00:00:00 2001 From: kmpeng Date: Thu, 27 Mar 2025 14:39:27 -0700 Subject: [PATCH 1/7] finished lit implementation, added codegen and sema tests --- .../

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
@@ -253,6 +253,37 @@ const inline float length(__detail::HLSL_FIXED_VECTOR X) { return __detail::length_vec_impl(X); } +//===--===// +// lit builtins +//===--

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-03 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-02 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/134171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

2025-04-02 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng created https://github.com/llvm/llvm-project/pull/134171 Closes #99135. Tasks completed: - Wrote implementation in `hlsl_intrinsics.h`/`hlsl_intrinsic_helpers.h` that matches DXC - Created overloads in `hlsl_compat_overloads.h` that take doubles/ints and explicitly

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-28 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/132288 >From 1d28510653b39fcabe45ad37197674bdd0217add Mon Sep 17 00:00:00 2001 From: kmpeng Date: Tue, 18 Mar 2025 13:25:10 -0700 Subject: [PATCH 01/11] create int_spv_smoothstep intrinsic, create smoothstep lowering &

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-27 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-27 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,60 @@ +; 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 %} kmpeng wrote: @s-perron Changing the target envir

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,60 @@ +; 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 %} kmpeng wrote: Seems like this change produces thi

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng deleted https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
@@ -101,6 +101,52 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, TheCall->setType(RetTy); break; } + case SPIRV::BI__builtin_spirv_smoothstep: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +// check if the all argument

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/132288 >From 1d28510653b39fcabe45ad37197674bdd0217add Mon Sep 17 00:00:00 2001 From: kmpeng Date: Tue, 18 Mar 2025 13:25:10 -0700 Subject: [PATCH 01/10] create int_spv_smoothstep intrinsic, create smoothstep lowering &

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
@@ -0,0 +1,60 @@ +; 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 %} kmpeng wrote: Code updated with `--target-env vul

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng edited https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
@@ -101,6 +101,52 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, TheCall->setType(RetTy); break; } + case SPIRV::BI__builtin_spirv_smoothstep: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +// check if the all argument

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-26 Thread Kaitlin Peng via cfe-commits
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/132288 >From 7853b27b8fffa6d2c0393a4004abaac9a7954608 Mon Sep 17 00:00:00 2001 From: kmpeng Date: Tue, 18 Mar 2025 13:25:10 -0700 Subject: [PATCH 01/10] create int_spv_smoothstep intrinsic, create smoothstep lowering &

  1   2   >