diff options
author | Kevin P. Neal <kevin.neal@sas.com> | 2019-04-11 17:16:03 +0000 |
---|---|---|
committer | Kevin P. Neal <kevin.neal@sas.com> | 2019-04-11 17:16:03 +0000 |
commit | 339594e4dc10e91dca9e408dc37ee40932271726 (patch) | |
tree | 6794f936e603952aafa3683f44dd06a56bb5e03a /llvm/docs | |
parent | ab38599bb1240066ece60f0b1f38d96c9901691b (diff) | |
download | bcm5719-llvm-339594e4dc10e91dca9e408dc37ee40932271726.tar.gz bcm5719-llvm-339594e4dc10e91dca9e408dc37ee40932271726.zip |
New document skeleton describing how to add a constrained floating-point
intrinsic.
Reviewed by: andrew.w.kaylor, cameron.mcinally
Differential Revision: https://reviews.llvm.org/D59833
llvm-svn: 358194
Diffstat (limited to 'llvm/docs')
-rw-r--r-- | llvm/docs/AddingConstrainedIntrinsics.rst | 94 | ||||
-rw-r--r-- | llvm/docs/index.rst | 5 |
2 files changed, 99 insertions, 0 deletions
diff --git a/llvm/docs/AddingConstrainedIntrinsics.rst b/llvm/docs/AddingConstrainedIntrinsics.rst new file mode 100644 index 00000000000..047b419c25b --- /dev/null +++ b/llvm/docs/AddingConstrainedIntrinsics.rst @@ -0,0 +1,94 @@ +================================================== +How To Add A Constrained Floating-Point Intrinsic +================================================== + +.. contents:: + :local: + +.. warning:: + This is a work in progress. + +Add the intrinsic +================= + +Multiple files need to be updated when adding a new constrained intrinsic. + +Add the new intrinsic to the table of intrinsics.:: + + include/llvm/IR/Intrinsics.td + +Update class ConstrainedFPIntrinsic to know about the intrinsics.:: + + include/llvm/IR/IntrinsicInst.h + +Functions like ConstrainedFPIntrinsic::isUnaryOp() or +ConstrainedFPIntrinsic::isTernaryOp() may need to know about the new +intrinsic.:: + + lib/IR/IntrinsicInst.cpp + +Update the IR verifier:: + + lib/IR/Verifier.cpp + +Add SelectionDAG node types +=========================== + +Add the new STRICT version of the node type to the ISD::NodeType enum.:: + + include/llvm/CodeGen/ISDOpcodes.h + +In class SDNode update isStrictFPOpcode():: + + include/llvm/CodeGen/SelectionDAGNodes.h + +A mapping from the STRICT SDnode type to the non-STRICT is done in +TargetLoweringBase::getStrictFPOperationAction(). This allows STRICT +nodes to be legalized similarly to the non-STRICT node type.:: + + include/llvm/CodeGen/TargetLowering.h + +Building the SelectionDAG +------------------------- + +The switch statement in SelectionDAGBuilder::visitIntrinsicCall() needs +to be updated to call SelectionDAGBuilder::visitConstrainedFPIntrinsic(). +That function, in turn, needs to be updated to know how to create the +SDNode for the intrinsic. The new STRICT node will eventually be converted +to the matching non-STRICT node. For this reason it should have the same +operands and values as the non-STRICT version but should also use the chain. +This makes subsequent sharing of code for STRICT and non-STRICT code paths +easier.:: + + lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp + +Most of the STRICT nodes get legalized the same as their matching non-STRICT +counterparts. A new STRICT node with this property must get added to the +switch in SelectionDAGLegalize::LegalizeOp().:: + + lib/CodeGen/SelectionDAG/LegalizeDAG.cpp + +Other parts of the legalizer may need to be updated as well. Look for +places where the non-STRICT counterpart is legalized and update as needed. +Be careful of the chain since STRICT nodes use it but their counterparts +often don't.:: + +The code to do the conversion or mutation of the STRICT node to a non-STRICT +version of the node happens in SelectionDAG::mutateStrictFPToFP(). Be +careful updating this function since some nodes have the same return type +as their input operand, but some are different. Both of these cases must +be properly handled.:: + + lib/CodeGen/SelectionDAG/SelectionDAG.cpp + +To make debug logs readable it is helpful to update the SelectionDAG's +debug logger::: + + lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp + +Add documentation and tests +=========================== + +:: + + docs/LangRef.rst diff --git a/llvm/docs/index.rst b/llvm/docs/index.rst index d546d6c7b91..b03e6b78655 100644 --- a/llvm/docs/index.rst +++ b/llvm/docs/index.rst @@ -267,6 +267,7 @@ For API clients and LLVM developers. Bugpoint CodeGenerator ExceptionHandling + AddingConstrainedIntrinsics LinkTimeOptimization SegmentedStacks TableGenFundamentals @@ -345,6 +346,10 @@ For API clients and LLVM developers. This document describes the design and implementation of exception handling in LLVM. +:doc:`AddingConstrainedIntrinsics` + Gives the steps necessary when adding a new constrained math intrinsic + to LLVM. + :doc:`Bugpoint` Automatic bug finder and test-case reducer description and usage information. |