[clang] [HLSL] Apply NoRecurse attrib to all HLSL functions (PR #105907)

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

[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

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

[clang] [clang][HLSL] Add sign intrinsic part 3 (PR #101989)

2024-08-28 Thread Farzon Lotfi via cfe-commits
farzonl wrote: @tgymnich you got approval on this PR, is there something you are waiting on? https://github.com/llvm/llvm-project/pull/101989 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [clang][HLSL] Add sign intrinsic part 3 (PR #101989)

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

[clang] [clang][HLSL] Add sign intrinsic part 3 (PR #101989)

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

[clang] [clang][HLSL] Add sign intrinsic part 3 (PR #101989)

2024-08-29 Thread Farzon Lotfi via cfe-commits
farzonl wrote: > @farzonl This PR requires the SPIRV part (#101987) to be merged. I haven't signed off on that one because I wanted input from others. I'll ping some folks. If the pr is still sitting we can make a small change in this pr that will unbloc it. Add the spirv intrinsic to this pr t

[clang] [HLSL] add loop unroll (PR #93879)

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

[clang] [HLSL] add loop unroll (PR #93879)

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

[clang] [NFC][clang] Replace unchecked dyn_cast with cast (PR #98948)

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

[clang] [clang] Emit constraint intrinsics for arc and hyperbolic trig clang builtins (PR #98949)

2024-07-15 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/98949 ## Change(s) - `Builtins.td` - Add f16 support for libm arc and hyperbolic trig functions - `CGBuiltin.cpp` - Emit constraint intrinsics for trig clang builtins ## History This change is part of an implementation

[clang] [llvm] [x86] Add tan intrinsic part 4 (PR #90503)

2024-04-30 Thread Farzon Lotfi via cfe-commits
@@ -654,6 +655,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, setOperationAction(ISD::FSIN , VT, Expand); setOperationAction(ISD::FCOS , VT, Expand); setOperationAction(ISD::FSINCOS, VT, Expand); + setOperationAction(ISD::FTAN,

[clang] [NFC][HLSL] Cleanup TargetInfo handling (PR #90694)

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

[clang] [NFC][HLSL] Cleanup TargetInfo handling (PR #90694)

2024-05-01 Thread Farzon Lotfi via cfe-commits
@@ -406,6 +406,16 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) { LongDoubleAlign = 64; } + // HLSL explicitly defines the sizes and formats of some data types, and we + // need to conform to those regardless of what architecture you are tar

[clang] [HLSL] Shore up floating point conversions (PR #90222)

2024-05-01 Thread Farzon Lotfi via cfe-commits
@@ -4393,6 +4401,24 @@ getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS) { return FixedEnumPromotion::ToPromotedUnderlyingType; } +static ImplicitConversionSequence::CompareKind +HLSLCompareFloatingRank(QualType LHS, QualType RHS) { + assert(LHS->isVecto

[clang] [HLSL] Shore up floating point conversions (PR #90222)

2024-05-01 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,229 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -fnative-half-type -finclude-default-header -Wconversion -verify -o - %s +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -fnative-half-type -finclude-default-header -ast-dump %s | FileCheck %

[clang] [HLSL] Shore up floating point conversions (PR #90222)

2024-05-01 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Are there test cases in `OverloadResolutionBugs.hlsl` that have been fixed by this change and would need to be removed from that file? https://github.com/llvm/llvm-project/pull/90222 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[clang] [HLSL] Shore up floating point conversions (PR #90222)

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

[clang] [llvm] [x86] Add tan intrinsic part 4 (PR #90503)

2024-05-03 Thread Farzon Lotfi via cfe-commits
farzonl wrote: @RKSimon @topperc When you have time could I get a review. Thank you! https://github.com/llvm/llvm-project/pull/90503 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][hlsl] Add tan intrinsic part 1 (PR #90276)

2024-05-03 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Hi @efriedma-quic @RKSimon when you have time could I get a review? Thank you! https://github.com/llvm/llvm-project/pull/90276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [llvm] [clang][hlsl] Add tan intrinsic part 1 (PR #90276)

2024-05-06 Thread Farzon Lotfi via cfe-commits
farzonl wrote: > I'm worried if we add a whole new series of math intrinsics without adding > the corresponding constrained intrinsics, it's going to be confusing for > anyone trying to understand how math intrinsics work. Why does tan exist, but > not constrained tan? > > `tan` is defined ba

[clang] [llvm] [clang][hlsl] Add tan intrinsic part 1 (PR #90276)

2024-05-07 Thread Farzon Lotfi via cfe-commits
farzonl wrote: > > I didn't want the current set of changes to go stale. > > How many changes are we talking about here? If it's just the tan() ones, > that's fine; it probably makes sense to land constrained-tan separately > anyway. There are 4 for tan. There will be more for the other intri

[clang] [llvm] [clang][hlsl] Add tan intrinsic part 1 (PR #90276)

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

[clang] [llvm] [clang][hlsl][dxil][spirv][x86] Add tan intrinsic (PR #90088)

2024-05-07 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/90088 >From 745447fe5d55d08b1d0e212d9bfa7e56a8af94f6 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 24 Apr 2024 17:34:04 -0400 Subject: [PATCH 1/5] start of tan intrinsic --- clang/docs/LanguageExtensions.rst

[clang] [llvm] [clang][hlsl][dxil][spirv][x86] Add tan intrinsic (PR #90088)

2024-05-07 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/90088 >From 745447fe5d55d08b1d0e212d9bfa7e56a8af94f6 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Wed, 24 Apr 2024 17:34:04 -0400 Subject: [PATCH 1/5] start of tan intrinsic --- clang/docs/LanguageExtensions.rst

[clang] [llvm] [clang][hlsl][dxil][spirv][x86] Add tan intrinsic (PR #90088)

2024-05-09 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl closed https://github.com/llvm/llvm-project/pull/90088 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-05-14 Thread Farzon Lotfi via cfe-commits
@@ -3861,11 +3864,17 @@ def warn_availability_fuchsia_unavailable_minor : Warning< InGroup; def warn_unguarded_availability : - Warning<"%0 is only available on %1 %2 or newer">, + Warning<"%0 is only available %select{|in %4 environment }3on %1 %2 or newer">, --

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-05-14 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl deleted https://github.com/llvm/llvm-project/pull/89809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-05-14 Thread Farzon Lotfi via cfe-commits
@@ -18,14 +18,21 @@ namespace hlsl { #define _HLSL_BUILTIN_ALIAS(builtin) \ __attribute__((clang_builtin_alias(builtin))) -#define _HLSL_AVAILABILITY(environment, version) \ - __attribute__((availabil

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-05-14 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,140 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel5.0-compute -fsyntax-only -verify %s farzonl wrote: could we do different runs for pixel and mesh to cover their different version availabilities from compute? https://github.com/llvm/llvm-proje

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

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

[clang] [llvm] [clang] Add tanf16 builtin and support for tan constrained intrinsic (PR #93314)

2024-05-24 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/93314 - `Builtins.td` - replace TanF128 with F16F128MathTemplate - `CGBuiltin.cpp` - map existing tan builtins to `tan` and `constrained_tan` intrinsic - `ConstrainedOps.def` map tan and constrained_tan to an ISD

[clang] [llvm] [clang] Add tanf16 builtin and support for tan constrained intrinsic (PR #93314)

2024-05-24 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/93314 >From 683dfa875e024acba12b229dbecd6d10573c891f Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Fri, 24 May 2024 10:01:52 -0400 Subject: [PATCH 1/2] [clang] Add tanf16 builtin and support for tan constrained in

[clang] [llvm] [clang] Add tanf16 builtin and support for tan constrained intrinsic (PR #93314)

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

[clang] [llvm] [clang] Add tanf16 builtin and support for tan constrained intrinsic (PR #93314)

2024-05-24 Thread Farzon Lotfi via cfe-commits
farzonl wrote: > IMO it'd be good to have a bit more context in the commit description about > why this is being done. If you follow the breadcrumbs from the issue to the > thread in the PR I think you can put it together, but a more local summary > might be helpful. done https://github.com

[clang] [llvm] [clang] Add tanf16 builtin and support for tan constrained intrinsic (PR #93314)

2024-05-24 Thread Farzon Lotfi via cfe-commits
@@ -183,6 +183,14 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c, _ // CHECK: call x86_fp80 @llvm.experimental.constrained.sqrt.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict") // CHECK: call fp128 @llvm.experime

[clang] [llvm] [clang] Add tanf16 builtin and support for tan constrained intrinsic (PR #93314)

2024-05-24 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/93314 >From 683dfa875e024acba12b229dbecd6d10573c891f Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Fri, 24 May 2024 10:01:52 -0400 Subject: [PATCH 1/3] [clang] Add tanf16 builtin and support for tan constrained in

[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

2024-08-01 Thread Farzon Lotfi via cfe-commits
@@ -63,5 +63,6 @@ let TargetPrefix = "spv" in { def int_spv_frac : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty]>; def int_spv_lerp : Intrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>,LLVMMatchType<0>], [IntrNoMem, IntrWillReturn] >; +

[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

2024-08-01 Thread Farzon Lotfi via cfe-commits
@@ -4707,6 +4707,12 @@ def HLSLIsinf : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } +def HLSLLength : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_elementwise_length"]; farzonl wrote: This shouldn't be an elementwise builtin s

[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

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

[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

2024-08-01 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl deleted https://github.com/llvm/llvm-project/pull/101256 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

2024-08-01 Thread Farzon Lotfi via cfe-commits
@@ -4707,6 +4707,12 @@ def HLSLIsinf : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } +def HLSLLength : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_elementwise_length"]; farzonl wrote: I agree with Justin, This shouldn't be an

[clang] [llvm] Add length HLSL function to DirectX Backend (PR #101256)

2024-08-01 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,10 @@ +; RUN: not opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s 2>&1 | FileCheck %s + +; DXIL operation length does not support double overload type +; CHECK: LLVM ERROR: Invalid Overload + +define noundef double @test_length_double2(<2 x double> nou

[clang] [HLSL] cleanup builtin names used by HLSL (PR #101543)

2024-08-01 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/101543 Remove elementwise description for builtins that don't perform elementwise operations. >From 506961aad924a717365c65de0b91c88e1010ca15 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Thu, 1 Aug 2024 14:55:14

[clang] [HLSL] cleanup builtin names elementwise usage (PR #101543)

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

[clang] [HLSL] cleanup builtin names elementwise usage (PR #101543)

2024-08-01 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/101543 >From 7664c3ea206a2c2e851b8d925c377af6e4bb6e11 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Thu, 1 Aug 2024 14:55:14 -0400 Subject: [PATCH 1/2] [HLSL] cleanup builtin names used by HLSL Remove elementwise

[clang] [HLSL] cleanup builtin names elementwise usage (PR #101543)

2024-08-01 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Current test failures are because of https://github.com/llvm/llvm-project/commit/5e84646982d1e should be fixed by https://github.com/llvm/llvm-project/commit/c5f1395f2f7f92015748069528d46ad89cecc9f1 https://github.com/llvm/llvm-project/pull/101549 https://github.com/llvm/llvm-

[clang] [HLSL] cleanup builtin names elementwise usage (PR #101543)

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

[clang] [llvm] Add length builtins and length HLSL function to DirectX Backend (PR #101256)

2024-08-02 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,10 @@ +; RUN: not opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s 2>&1 | FileCheck %s + +; DXIL operation length does not support scalar types +; CHECK: error: invalid intrinsic signature + +define noundef float @test_length_float(float noundef %p0) {

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-16 Thread Farzon Lotfi via cfe-commits
@@ -284,41 +303,55 @@ static bool expandClampIntrinsic(CallInst *Orig, Intrinsic::ID ClampIntrinsic) { Builder.SetInsertPoint(Orig); auto *MaxCall = Builder.CreateIntrinsic( Ty, getMaxForClamp(Ty, ClampIntrinsic), {X, Min}, nullptr, "dx.max"); - auto *MinCall = -

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

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

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-16 Thread Farzon Lotfi via cfe-commits
@@ -18666,6 +18666,15 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { /*ReturnType=*/Op0->getType(), CGM.getHLSLRuntime().getRsqrtIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.rsqrt"); } + case Builtin::BI__builtin_hlsl_elementwise_saturate: { +Value

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-16 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,NATIVE_HALF +// RUN: %

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-16 Thread Farzon Lotfi via cfe-commits
@@ -362,6 +364,34 @@ static bool expandClampIntrinsic(CallInst *Orig, Intrinsic::ID ClampIntrinsic) { return true; } +static bool expandSaturateIntrinsic(CallInst *SaturateCall) { farzonl wrote: wait for @pow2clk change merges then change this to return `

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-16 Thread Farzon Lotfi via cfe-commits
@@ -1285,6 +1289,34 @@ static unsigned getBoolCmpOpcode(unsigned PredNum) { } } +static APFloat getZeroFP(const Type *LLVMFloatTy) { farzonl wrote: I'm a little suprised this didn't already exist. https://github.com/llvm/llvm-project/pull/104619 __

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-17 Thread Farzon Lotfi via cfe-commits
@@ -325,6 +325,16 @@ def Abs : DXILOp<6, unary> { let attributes = [Attributes]; } +def Saturate : DXILOp<7, unary> { + let Doc = "Clamps a single or double precision floating point value to [0.0f...1.0f]."; + let LLVMIntrinsic = int_dx_saturate; + let arguments = [ove

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

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

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-17 Thread Farzon Lotfi via cfe-commits
@@ -362,6 +364,34 @@ static bool expandClampIntrinsic(CallInst *Orig, Intrinsic::ID ClampIntrinsic) { return true; } +static bool expandSaturateIntrinsic(CallInst *SaturateCall) { + FunctionType *FT = SaturateCall->getFunctionType(); + Type *FTRetTy = FT->getReturnType();

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

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

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -362,6 +364,34 @@ static bool expandClampIntrinsic(CallInst *Orig, Intrinsic::ID ClampIntrinsic) { return true; } +static bool expandSaturateIntrinsic(CallInst *SaturateCall) { + FunctionType *FT = SaturateCall->getFunctionType(); + Type *FTRetTy = FT->getReturnType();

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -7,155 +7,155 @@ // RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF #ifdef __HLSL_ENABLE_16_BIT -// NATIVE_HALF: %dx.dot = mul i16 %0, %1 -// NATIVE_HALF: ret i16 %dx.dot +// NATIVE_HALF: %hlsl.dot = mul i16 %0, %1 +// NATIVE_HALF: ret i16 %hlsl.dot int16_t test_

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -68,28 +69,65 @@ static Value *expandAbs(CallInst *Orig) { "dx.max"); } -static Value *expandIntegerDot(CallInst *Orig, Intrinsic::ID DotIntrinsic) { +// Create DXIL dot intrinsics for floating point dot operations +static Value *expandFloat

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

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

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -1446,6 +1449,67 @@ bool SPIRVInstructionSelector::selectRsqrt(Register ResVReg, .constrainAllUses(TII, TRI, RBI); } +// Since there is no integer dot implementation, expand by piecewise multiplying farzonl wrote: ```suggestion // Since there is no

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -2157,6 +2221,16 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, break; case Intrinsic::spv_thread_id: return selectSpvThreadId(ResVReg, ResType, I); + case Intrinsic::spv_fdot: +return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpDot)

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

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

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
farzonl wrote: could you fixup normalize to use some of you fdot expansion? I think you need to split the intrinsic check from the emitting check https://github.com/llvm/llvm-project/blob/9cf27a4d8b1da0e7b51eacb9fb6096155c294d3f/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp#L278-L289 ht

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -2157,6 +2221,16 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, break; case Intrinsic::spv_thread_id: return selectSpvThreadId(ResVReg, ResType, I); + case Intrinsic::spv_fdot: +return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpDot)

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

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

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -7,155 +7,155 @@ // RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF #ifdef __HLSL_ENABLE_16_BIT -// NATIVE_HALF: %dx.dot = mul i16 %0, %1 -// NATIVE_HALF: ret i16 %dx.dot +// NATIVE_HALF: %hlsl.dot = mul i16 %0, %1 +// NATIVE_HALF: ret i16 %hlsl.dot int16_t test_

[clang] [llvm] [clang][HLSL] Add WaveIsFirstLane() intrinsic (PR #103299)

2024-08-19 Thread Farzon Lotfi via cfe-commits
farzonl wrote: closes #99158 https://github.com/llvm/llvm-project/pull/103299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][HLSL] Add WaveIsFirstLane() intrinsic (PR #103299)

2024-08-19 Thread Farzon Lotfi via cfe-commits
farzonl wrote: > > We have this work tracked here: #99158 > > there should be some dxil specific tasks. > > Seems like most boxes would be checked by this PR, except Sema checks: > > * what kind of Sema checks would be required for this one? > Also, the intrinsic name in the issue is using ca

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -363,9 +382,13 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) { case Intrinsic::dx_normalize: Result = expandNormalizeIntrinsic(Orig); break; + case Intrinsic::dx_fdot: +Result = +expandFloatDotIntrinsic(Orig, Orig->getOperand(0), Orig->g

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -1,161 +1,172 @@ // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ // RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ // RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ -// RUN: --check-prefixes=CHECK,NATIVE_HALF +// RUN: --check-pr

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -1446,6 +1452,90 @@ bool SPIRVInstructionSelector::selectRsqrt(Register ResVReg, .constrainAllUses(TII, TRI, RBI); } +// Select the OpDot instruction for the given float dot +bool SPIRVInstructionSelector::selectFloatDot(Register ResVReg, +

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -15,6 +15,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/Passes.h" +#include "llvm/IR/DerivedTypes.h" farzonl wrote: revert? https://github.com/llvm/llvm-project/pull/104619 ___

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,69 @@ +; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s +; Make sure the intrinsic dx.saturate is to appropriate DXIL op for half/float/double data types. + +target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,69 @@ +; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s +; Make sure the intrinsic dx.saturate is to appropriate DXIL op for half/float/double data types. + +target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,69 @@ +; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s +; Make sure the intrinsic dx.saturate is to appropriate DXIL op for half/float/double data types. + +target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,69 @@ +; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s +; Make sure the intrinsic dx.saturate is to appropriate DXIL op for half/float/double data types. + +target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

2024-08-19 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,14 @@ +; RUN: not opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s 2>&1 | FileCheck %s +; Make sure the intrinsic dx.saturate is to appropriate DXIL op for half/float/double data types. + +target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i6

[clang] [llvm] [HLSL] Implement support for HLSL intrinsic - saturate (PR #104619)

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

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

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

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

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

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

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

[clang] [HLSL] Add __builtin_hlsl_is_scalarized_layout_compatible (PR #102227)

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

[clang] [HLSL][clang] Add elementwise builtins for trig intrinsics (PR #95999)

2024-06-22 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/95999 >From bb837fd791d627fceffb73eaac70b8f4db2f4dda Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Tue, 18 Jun 2024 17:47:13 -0400 Subject: [PATCH] [HLSL][clang] Add elementwise builtins for trig intrinsics This c

[clang] [HLSL][clang] Add elementwise builtins for trig intrinsics (PR #95999)

2024-06-22 Thread Farzon Lotfi via cfe-commits
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/95999 >From 632ec448202a111a313536ffbf22589499dd214b Mon Sep 17 00:00:00 2001 From: Farzon Lotfi Date: Tue, 18 Jun 2024 17:47:13 -0400 Subject: [PATCH] [HLSL][clang] Add elementwise builtins for trig intrinsics This c

[clang] [HLSL][clang] Add elementwise builtins for trig intrinsics (PR #95999)

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

[clang] [HLSL] add loop unroll (PR #93879)

2024-06-24 Thread Farzon Lotfi via cfe-commits
@@ -584,6 +585,39 @@ static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A, return ::new (S.Context) OpenCLUnrollHintAttr(S.Context, A, UnrollFactor); } +static Attr *handleHLSLLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A, +

[clang] [HLSL] add loop unroll (PR #93879)

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

[clang] [HLSL] fix elementwise bitreverse test (PR #108128)

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

[clang] [llvm] [HLSL] Implement elementwise popcount (PR #108121)

2024-09-11 Thread Farzon Lotfi via cfe-commits
@@ -1522,6 +1522,14 @@ bool CheckUnsignedIntRepresentation(Sema *S, CallExpr *TheCall) { checkAllUnsignedTypes); } +bool CheckIntRepresentation(Sema *S, CallExpr *TheCall) { farzonl wrote: It doesn't seem like this function

[clang] [llvm] [HLSL] Implement elementwise popcount (PR #108121)

2024-09-11 Thread Farzon Lotfi via cfe-commits
farzonl wrote: I don't see a `clang/test/CodeGenHLSL/builtins/countbits.hlsl` https://github.com/llvm/llvm-project/pull/108121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement elementwise popcount (PR #108121)

2024-09-11 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Also we probably still want a `clang/test/SemaHLSL/BuiltIns/countbits-errors.hlsl` to check the errors for float representations. https://github.com/llvm/llvm-project/pull/108121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [llvm] [HLSL] Implement elementwise popcount (PR #108121)

2024-09-11 Thread Farzon Lotfi via cfe-commits
farzonl wrote: Code looks fine, I need to see more tests before I can sign off. https://github.com/llvm/llvm-project/pull/108121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-09-11 Thread Farzon Lotfi via cfe-commits
@@ -1490,6 +1490,18 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { TheCall->setType(ArgTyA); break; } + case Builtin::BI__builtin_hlsl_step: { +if (CheckFloatOrHalfRepresentations(&SemaRef, TheCall)) + return true; +

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

2024-09-11 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected + +void test_too_few_arg() +{ + return __builtin_hlsl_step(); + // expected-error@-1 {{too few argu

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

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

[clang] [llvm] [HLSL] Implement elementwise popcount (PR #108121)

2024-09-12 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,80 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define nound

[clang] [llvm] [HLSL] Implement elementwise popcount (PR #108121)

2024-09-12 Thread Farzon Lotfi via cfe-commits
@@ -0,0 +1,28 @@ +; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s farzonl wrote: so I don't have to clean this up later can you change this to ```suggestion ; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shader

<    1   2   3   4   5   6   7   8   9   10   >