[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] [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 |  2 +-
 clang/test/CodeGenHLSL/builtins/tan.hlsl  |  2 +-
 llvm/include/llvm/Analysis/VecFuncs.def   |  1 +
 llvm/include/llvm/CodeGen/BasicTTIImpl.h  |  3 +++
 llvm/include/llvm/CodeGen/ISDOpcodes.h|  2 ++
 llvm/include/llvm/IR/RuntimeLibcalls.def  |  5 
 .../Target/GlobalISel/SelectionDAGCompat.td   |  1 +
 .../include/llvm/Target/TargetSelectionDAG.td |  6 +
 llvm/lib/Analysis/VectorUtils.cpp |  1 +
 .../CodeGen/GlobalISel/LegalizerHelper.cpp|  5 
 llvm/lib/CodeGen/GlobalISel/Utils.cpp |  2 ++
 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp |  8 +++
 .../SelectionDAG/LegalizeFloatTypes.cpp   | 23 +++
 llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h |  2 ++
 .../SelectionDAG/LegalizeVectorOps.cpp|  1 +
 .../SelectionDAG/LegalizeVectorTypes.cpp  |  3 +++
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp |  1 +
 .../SelectionDAG/SelectionDAGBuilder.cpp  |  8 +++
 .../SelectionDAG/SelectionDAGDumper.cpp   |  2 ++
 llvm/lib/CodeGen/TargetLoweringBase.cpp   |  3 ++-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  1 +
 21 files changed, 79 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 3627a780886a0..9e9ff8d0714f6 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -665,7 +665,7 @@ Unless specified otherwise operation(±0) = ±0 and 
operation(±infinity) = ±in
  T __builtin_elementwise_bitreverse(T x) return the integer represented 
after reversing the bits of x integer types
  T __builtin_elementwise_exp(T x)returns the base-e exponential, 
e^x, of the specified value  floating point types
  T __builtin_elementwise_exp2(T x)   returns the base-2 exponential, 
2^x, of the specified value  floating point types
-
+ 
  T __builtin_elementwise_sqrt(T x)   return the square root of a 
floating-point numberfloating point types
  T __builtin_elementwise_roundeven(T x)  round x to the nearest integer 
value in floating point format,   floating point types
  rounding halfway cases to even 
(that is, to the nearest value
diff --git a/clang/test/CodeGenHLSL/builtins/tan.hlsl 
b/clang/test/CodeGenHLSL/builtins/tan.hlsl
index aa542fac226d0..d440144ae880e 100644
--- a/clang/test/CodeGenHLSL/builtins/tan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/tan.hlsl
@@ -56,4 +56,4 @@ float3 test_tan_float3 ( float3 p0 ) {
 // CHECK: call <4 x float> @llvm.tan.v4f32
 float4 test_tan_float4 ( float4 p0 ) {
   return tan ( p0 );
-}
+}
\ No newline at end of file
diff --git a/llvm/include/llvm/Analysis/VecFuncs.def 
b/llvm/include/llvm/Analysis/VecFuncs.def
index 10f1333cf8885..a8cb3c13e0b6e 100644
--- a/llvm/include/llvm/Analysis/VecFuncs.def
+++ b/llvm/include/llvm/Analysis/VecFuncs.def
@@ -54,6 +54,7 @@ TLI_DEFINE_VECFUNC("llvm.sin.f32", "vsinf", FIXED(4), 
"_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("cosf", "vcosf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("llvm.cos.f32", "vcosf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("tanf", "vtanf", FIXED(4), "_ZGV_LLVM_N4v")
+TLI_DEFINE_VECFUNC("llvm.tan.f32", "vtanf", FIXED(4))
 TLI_DEFINE_VECFUNC("asinf", "vasinf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("acosf", "vacosf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("atanf", "vatanf", FIXED(4), "_ZGV_LLVM_N4v")
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h 
b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index c6e90e57e46ed..6c15dc63a115d 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1924,6 +1924,9 @@ class BasicTTIImplBase : public 
TargetTransformInfoImplCRTPBase {
 case Intrinsic::cos:
   ISD = ISD::FCOS;
   break;
+case Intrinsic::tan:
+  ISD = ISD::FTAN;
+  break;
 case Intrinsic::exp:
   ISD = ISD::FEXP;
   break;
diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h 
b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index 6429947958ee9..c38c83f5b80df 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -415,6 +415,7 @@ enum NodeType {
   STRICT_FLDEXP,
   STRICT_FSIN,
   STRICT_FCOS,
+  STRICT_FTAN,
   STRICT_FEXP,
   STRICT_FEXP2,
   STRICT_FLOG,
@@ -934,6 +935,7 @@ enum NodeType {
   FCBRT,
   FSIN,
   FCOS,
+  FTAN,
   FPOW,
   FPOWI,
   /// FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.def 
b/llvm/include/llvm/IR/RuntimeLibcalls.def
index 5e082769fa974..f4f93bf7ba24c 100644
--- 

[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 |  2 +-
 clang/test/CodeGenHLSL/builtins/tan.hlsl  |  2 +-
 llvm/include/llvm/Analysis/VecFuncs.def   |  1 +
 llvm/include/llvm/CodeGen/BasicTTIImpl.h  |  3 +++
 llvm/include/llvm/CodeGen/ISDOpcodes.h|  2 ++
 llvm/include/llvm/IR/RuntimeLibcalls.def  |  5 
 .../Target/GlobalISel/SelectionDAGCompat.td   |  1 +
 .../include/llvm/Target/TargetSelectionDAG.td |  6 +
 llvm/lib/Analysis/VectorUtils.cpp |  1 +
 .../CodeGen/GlobalISel/LegalizerHelper.cpp|  5 
 llvm/lib/CodeGen/GlobalISel/Utils.cpp |  2 ++
 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp |  8 +++
 .../SelectionDAG/LegalizeFloatTypes.cpp   | 23 +++
 llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h |  2 ++
 .../SelectionDAG/LegalizeVectorOps.cpp|  1 +
 .../SelectionDAG/LegalizeVectorTypes.cpp  |  3 +++
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp |  1 +
 .../SelectionDAG/SelectionDAGBuilder.cpp  |  8 +++
 .../SelectionDAG/SelectionDAGDumper.cpp   |  2 ++
 llvm/lib/CodeGen/TargetLoweringBase.cpp   |  3 ++-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  1 +
 21 files changed, 79 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 3627a780886a0..9e9ff8d0714f6 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -665,7 +665,7 @@ Unless specified otherwise operation(±0) = ±0 and 
operation(±infinity) = ±in
  T __builtin_elementwise_bitreverse(T x) return the integer represented 
after reversing the bits of x integer types
  T __builtin_elementwise_exp(T x)returns the base-e exponential, 
e^x, of the specified value  floating point types
  T __builtin_elementwise_exp2(T x)   returns the base-2 exponential, 
2^x, of the specified value  floating point types
-
+ 
  T __builtin_elementwise_sqrt(T x)   return the square root of a 
floating-point numberfloating point types
  T __builtin_elementwise_roundeven(T x)  round x to the nearest integer 
value in floating point format,   floating point types
  rounding halfway cases to even 
(that is, to the nearest value
diff --git a/clang/test/CodeGenHLSL/builtins/tan.hlsl 
b/clang/test/CodeGenHLSL/builtins/tan.hlsl
index aa542fac226d0..d440144ae880e 100644
--- a/clang/test/CodeGenHLSL/builtins/tan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/tan.hlsl
@@ -56,4 +56,4 @@ float3 test_tan_float3 ( float3 p0 ) {
 // CHECK: call <4 x float> @llvm.tan.v4f32
 float4 test_tan_float4 ( float4 p0 ) {
   return tan ( p0 );
-}
+}
\ No newline at end of file
diff --git a/llvm/include/llvm/Analysis/VecFuncs.def 
b/llvm/include/llvm/Analysis/VecFuncs.def
index 10f1333cf8885..a8cb3c13e0b6e 100644
--- a/llvm/include/llvm/Analysis/VecFuncs.def
+++ b/llvm/include/llvm/Analysis/VecFuncs.def
@@ -54,6 +54,7 @@ TLI_DEFINE_VECFUNC("llvm.sin.f32", "vsinf", FIXED(4), 
"_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("cosf", "vcosf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("llvm.cos.f32", "vcosf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("tanf", "vtanf", FIXED(4), "_ZGV_LLVM_N4v")
+TLI_DEFINE_VECFUNC("llvm.tan.f32", "vtanf", FIXED(4))
 TLI_DEFINE_VECFUNC("asinf", "vasinf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("acosf", "vacosf", FIXED(4), "_ZGV_LLVM_N4v")
 TLI_DEFINE_VECFUNC("atanf", "vatanf", FIXED(4), "_ZGV_LLVM_N4v")
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h 
b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index c6e90e57e46ed..6c15dc63a115d 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1924,6 +1924,9 @@ class BasicTTIImplBase : public 
TargetTransformInfoImplCRTPBase {
 case Intrinsic::cos:
   ISD = ISD::FCOS;
   break;
+case Intrinsic::tan:
+  ISD = ISD::FTAN;
+  break;
 case Intrinsic::exp:
   ISD = ISD::FEXP;
   break;
diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h 
b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index 6429947958ee9..c38c83f5b80df 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -415,6 +415,7 @@ enum NodeType {
   STRICT_FLDEXP,
   STRICT_FSIN,
   STRICT_FCOS,
+  STRICT_FTAN,
   STRICT_FEXP,
   STRICT_FEXP2,
   STRICT_FLOG,
@@ -934,6 +935,7 @@ enum NodeType {
   FCBRT,
   FSIN,
   FCOS,
+  FTAN,
   FPOW,
   FPOWI,
   /// FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.def 
b/llvm/include/llvm/IR/RuntimeLibcalls.def
index 5e082769fa974..f4f93bf7ba24c 100644
--- 

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

2024-04-29 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl edited 
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] [llvm] [clang][hlsl][dxil][spirv][x86] Add tan intrinsic (PR #90088)

2024-04-25 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl updated 
https://github.com/llvm/llvm-project/pull/90088

>From de6abd27cb5118e4389d6382a972b66acece5166 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Wed, 24 Apr 2024 17:34:04 -0400
Subject: [PATCH 1/6] start of tan intrinsic

---
 clang/docs/LanguageExtensions.rst |  3 +-
 clang/include/clang/Basic/Builtins.td |  6 ++
 clang/lib/CodeGen/CGBuiltin.cpp   |  4 +-
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 23 
 clang/lib/Sema/SemaChecking.cpp   |  2 +
 .../test/CodeGen/builtins-elementwise-math.c  | 16 ++
 .../CodeGen/strictfp-elementwise-bulitins.cpp | 10 
 clang/test/CodeGenHLSL/builtins/tan.hlsl  | 56 +++
 clang/test/Sema/aarch64-sve-vector-trig-ops.c |  6 ++
 clang/test/Sema/builtins-elementwise-math.c   | 21 +++
 clang/test/Sema/riscv-rvv-vector-trig-ops.c   |  6 ++
 .../SemaCXX/builtins-elementwise-math.cpp |  7 +++
 llvm/docs/GlobalISel/GenericOpcode.rst|  2 +-
 llvm/docs/LangRef.rst | 37 
 llvm/include/llvm/Analysis/VecFuncs.def   |  1 +
 llvm/include/llvm/CodeGen/BasicTTIImpl.h  |  3 +
 llvm/include/llvm/CodeGen/ISDOpcodes.h|  2 +
 llvm/include/llvm/IR/Intrinsics.td|  1 +
 llvm/include/llvm/IR/RuntimeLibcalls.def  |  5 ++
 llvm/include/llvm/Support/TargetOpcodes.def   |  3 +
 llvm/include/llvm/Target/GenericOpcodes.td|  7 +++
 .../Target/GlobalISel/SelectionDAGCompat.td   |  1 +
 .../include/llvm/Target/TargetSelectionDAG.td |  6 ++
 llvm/lib/Analysis/VectorUtils.cpp |  1 +
 llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp  |  2 +
 .../CodeGen/GlobalISel/LegalizerHelper.cpp|  5 ++
 llvm/lib/CodeGen/GlobalISel/Utils.cpp |  2 +
 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp |  8 +++
 .../SelectionDAG/LegalizeFloatTypes.cpp   | 23 
 llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h |  2 +
 .../SelectionDAG/LegalizeVectorOps.cpp|  1 +
 .../SelectionDAG/LegalizeVectorTypes.cpp  |  3 +
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp |  1 +
 .../SelectionDAG/SelectionDAGBuilder.cpp  |  8 +++
 .../SelectionDAG/SelectionDAGDumper.cpp   |  2 +
 llvm/lib/CodeGen/TargetLoweringBase.cpp   |  3 +-
 .../Target/SPIRV/SPIRVInstructionSelector.cpp |  2 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  1 +
 38 files changed, 288 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CodeGenHLSL/builtins/tan.hlsl

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..cd0079d45d8a29 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -656,6 +656,7 @@ Unless specified otherwise operation(±0) = ±0 and 
operation(±infinity) = ±in
  T __builtin_elementwise_ceil(T x)   return the smallest integral 
value greater than or equal to xfloating point types
  T __builtin_elementwise_sin(T x)return the sine of x interpreted 
as an angle in radians  floating point types
  T __builtin_elementwise_cos(T x)return the cosine of x 
interpreted as an angle in radiansfloating point types
+ T __builtin_elementwise_tan(T x)return the tangent of x 
interpreted as an angle in radians   floating point types
  T __builtin_elementwise_floor(T x)  return the largest integral value 
less than or equal to xfloating point types
  T __builtin_elementwise_log(T x)return the natural logarithm of x 
   floating point types
  T __builtin_elementwise_log2(T x)   return the base 2 logarithm of x  
   floating point types
@@ -664,7 +665,7 @@ Unless specified otherwise operation(±0) = ±0 and 
operation(±infinity) = ±in
  T __builtin_elementwise_bitreverse(T x) return the integer represented 
after reversing the bits of x integer types
  T __builtin_elementwise_exp(T x)returns the base-e exponential, 
e^x, of the specified value  floating point types
  T __builtin_elementwise_exp2(T x)   returns the base-2 exponential, 
2^x, of the specified value  floating point types
-
+ 
  T __builtin_elementwise_sqrt(T x)   return the square root of a 
floating-point numberfloating point types
  T __builtin_elementwise_roundeven(T x)  round x to the nearest integer 
value in floating point format,   floating point types
  rounding halfway cases to even 
(that is, to the nearest value
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index de721a87b3341d..11982af3fa609b 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1326,6 +1326,12 @@ def ElementwiseSqrt : Builtin {
   let Prototype = "void(...)";
 }
 
+def ElementwiseTan : Builtin {
+  let Spellings = 

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

2024-04-25 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl edited 
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] [llvm] [clang][hlsl][dxil][spirv][x86] Add tan intrinsic (PR #90088)

2024-04-25 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl created 
https://github.com/llvm/llvm-project/pull/90088


This change is an implementation of #87367's investigation on supporting IEEE 
math operations as intrinsics.
Which was discussed in this RFC:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

All the x86 portions of this pr and tests should be credited to 
https://github.com/junaire
https://reviews.llvm.org/D146905

Changes:
- `clang/docs/LanguageExtensions.rst` - Document the new elementwise tan 
builtin.
-  `clang/include/clang/Basic/Builtins.td` - Implement the tan builtin.
-  `clang/lib/CodeGen/CGBuiltin.cpp` - invoke the tan intrinsic on uses of the 
builtin
-  `clang/lib/Headers/hlsl/hlsl_intrinsics.h` - Associate the tan builtin with 
the equivalent hlsl apis
-  `clang/lib/Sema/SemaChecking.cpp` - Add generic sema checks as well as HLSL 
specifc sema checks to the tan builtin
-  `llvm/docs/GlobalISel/GenericOpcode.rst` - Document the `G_FTAN` opcode 
-  `llvm/docs/LangRef.rst` - Document the tan intrinsic
-  `llvm/include/llvm/Analysis/VecFuncs.def` - Associate the tan intrinsic as a 
vector function similar to the tanf libcall.
-  `llvm/include/llvm/CodeGen/BasicTTIImpl.h` - Map the tan intrinsic to 
`ISD::FTAN`
-  `llvm/include/llvm/CodeGen/ISDOpcodes.h` - Define ISD opcodes for `FTAN` and 
`STRICT_FTAN`
-  `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic
-  `llvm/include/llvm/IR/RuntimeLibcalls.def` - Define tan libcall mappings
-  `llvm/include/llvm/Target/GenericOpcodes.td` - Define the `G_FTAN` Opcode
-  `llvm/include/llvm/Support/TargetOpcodes.def` - Create a `G_FTAN` Opcode 
handler
-  `llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td`  - Map `G_FTAN` 
to `ftan`
-  `llvm/include/llvm/Target/TargetSelectionDAG.td` - Define `ftan`, 
`strict_ftan`,  and `any_ftan` and map them to the ISD opcodes for `FTAN` and 
`STRICT_FTAN`
-  `llvm/lib/Analysis/VectorUtils.cpp` - Associate the tan intrinsic as a 
vector intrinsic
-  `llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp` Map the tan intrinsic to  
`G_FTAN` Opcode
-  `llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp` - Add `G_FTAN` to the list 
of  floating point math operations also associate `G_FTAN` with the `TAN_F` 
runtime lib.
- `llvm/lib/CodeGen/GlobalISel/Utils.cpp` - More floating point math operation 
common behaviors.
-  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp - List the function expansion 
operations for `FTAN` and `STRICT_FTAN`. Also define both opcodes in 
`PromoteNode`.
- `llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp` - More `FTAN` and 
`STRICT_FTAN` handling in the legalizer
-  `llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h` - Define 
`SoftenFloatRes_FTAN` and `ExpandFloatRes_FTAN`.
- `llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp` - Define `FTAN` as a 
legal vector operation.
-  `llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp` - Define `FTAN` as a 
legal vector operation.
-  `llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp` - define tan as an 
intrinsic that doesn't return NaN.
-  `llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp` Map `LibFunc_tan`, 
`LibFunc_tanf`, and `LibFunc_tanl` to `ISD::FTAN`. Map `Intrinsic::tan` to 
`ISD::FTAN` and add selection dag handling for `Intrinsic::tan`.
-  `llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp` - Define  `ftan` and 
`strict_ftan` names for the equivalent ISD  opcodes.
- `llvm/lib/CodeGen/TargetLoweringBase.cpp` -Define a Tan128 libcall and 
ISD::FTAN as a target lowering action.
- `llvm/lib/Target/DirectX/DXIL.td`  - Map `int_tan` (the tan intrinsic) to the 
equivalent DXIL Op.
- `llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp` - Map the `G_FTAN`  
opcode to the  GLSL 4.5 and openCL tan instructions.
-  `llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp` - Define `G_FTAN` as a legal 
spirv  target opcode.
-  `llvm/lib/Target/X86/X86ISelLowering.cpp` - Add x86_64 lowering for tan 
intrinsic


closes #70082

>From de6abd27cb5118e4389d6382a972b66acece5166 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 |  3 +-
 clang/include/clang/Basic/Builtins.td |  6 ++
 clang/lib/CodeGen/CGBuiltin.cpp   |  4 +-
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 23 
 clang/lib/Sema/SemaChecking.cpp   |  2 +
 .../test/CodeGen/builtins-elementwise-math.c  | 16 ++
 .../CodeGen/strictfp-elementwise-bulitins.cpp | 10 
 clang/test/CodeGenHLSL/builtins/tan.hlsl  | 56 +++
 clang/test/Sema/aarch64-sve-vector-trig-ops.c |  6 ++
 clang/test/Sema/builtins-elementwise-math.c   | 21 +++
 clang/test/Sema/riscv-rvv-vector-trig-ops.c   |  6 ++
 .../SemaCXX/builtins-elementwise-math.cpp |  7 +++
 llvm/docs/GlobalISel/GenericOpcode.rst|  2 +-
 llvm/docs/LangRef.rst | 37 
 llvm/include/llvm/Analysis/VecFuncs.def   |  1