-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang][hlsl][dxil][spirv][x86] Add tan intrinsic #90088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Apr 26, 2024
farzonl
added a commit
that referenced
this pull request
May 8, 2024
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 If you want an overarching view of how this will all connect see: #90088 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/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic - `llvm/docs/LangRef.rst` - Document the tan intrinsic
farzonl
added a commit
that referenced
this pull request
May 8, 2024
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 If you want an overarching view of how this will all connect see: #90088 Changes: - `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic - `llvm/lib/Target/DirectX/DXIL.td` - Map `int_tan` (the tan intrinsic) to the equivalent DXIL Op.
farzonl
added a commit
that referenced
this pull request
May 8, 2024
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 If you want an overarching view of how this will all connect see: #90088 Changes: - `llvm/docs/GlobalISel/GenericOpcode.rst` - Document the `G_FTAN` opcode - `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic - `llvm/include/llvm/Support/TargetOpcodes.def` - Create a `G_FTAN` Opcode handler - `llvm/include/llvm/Target/GenericOpcodes.td` - Define the `G_FTAN` Opcode - `llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp` Map the tan intrinsic to `G_FTAN` Opcode - `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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 X86ISelLowering 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 builtinclang/lib/Headers/hlsl/hlsl_intrinsics.h
- Associate the tan builtin with the equivalent hlsl apisclang/lib/Sema/SemaChecking.cpp
- Add generic sema checks as well as HLSL specifc sema checks to the tan builtinllvm/docs/GlobalISel/GenericOpcode.rst
- Document theG_FTAN
opcodellvm/docs/LangRef.rst
- Document the tan intrinsicllvm/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 toISD::FTAN
llvm/include/llvm/CodeGen/ISDOpcodes.h
- Define ISD opcodes forFTAN
andSTRICT_FTAN
llvm/include/llvm/IR/Intrinsics.td
- Create the tan intrinsicllvm/include/llvm/IR/RuntimeLibcalls.def
- Define tan libcall mappingsllvm/include/llvm/Target/GenericOpcodes.td
- Define theG_FTAN
Opcodellvm/include/llvm/Support/TargetOpcodes.def
- Create aG_FTAN
Opcode handlerllvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
- MapG_FTAN
toftan
llvm/include/llvm/Target/TargetSelectionDAG.td
- Defineftan
,strict_ftan
, andany_ftan
and map them to the ISD opcodes forFTAN
andSTRICT_FTAN
llvm/lib/Analysis/VectorUtils.cpp
- Associate the tan intrinsic as a vector intrinsicllvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Map the tan intrinsic toG_FTAN
Opcodellvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
- AddG_FTAN
to the list of floating point math operations also associateG_FTAN
with theTAN_F
runtime lib.llvm/lib/CodeGen/GlobalISel/Utils.cpp
- More floating point math operation common behaviors.FTAN
andSTRICT_FTAN
. Also define both opcodes inPromoteNode
.llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
- MoreFTAN
andSTRICT_FTAN
handling in the legalizerllvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
- DefineSoftenFloatRes_FTAN
andExpandFloatRes_FTAN
.llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
- DefineFTAN
as a legal vector operation.llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
- DefineFTAN
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
MapLibFunc_tan
,LibFunc_tanf
, andLibFunc_tanl
toISD::FTAN
. MapIntrinsic::tan
toISD::FTAN
and add selection dag handling forIntrinsic::tan
.llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
- Defineftan
andstrict_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
- Mapint_tan
(the tan intrinsic) to the equivalent DXIL Op.llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
- Map theG_FTAN
opcode to the GLSL 4.5 and openCL tan instructions.llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
- DefineG_FTAN
as a legal spirv target opcode.llvm/lib/Target/X86/X86ISelLowering.cpp
- Add x86_64 lowering for tan intrinsiccloses #70082
This change might also resolve #34950