llvm.org GIT mirror llvm / b383203
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358194 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin P. Neal 6 months ago
2 changed file(s) with 99 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ==================================================
1 How To Add A Constrained Floating-Point Intrinsic
2 ==================================================
3
4 .. contents::
5 :local:
6
7 .. warning::
8 This is a work in progress.
9
10 Add the intrinsic
11 =================
12
13 Multiple files need to be updated when adding a new constrained intrinsic.
14
15 Add the new intrinsic to the table of intrinsics.::
16
17 include/llvm/IR/Intrinsics.td
18
19 Update class ConstrainedFPIntrinsic to know about the intrinsics.::
20
21 include/llvm/IR/IntrinsicInst.h
22
23 Functions like ConstrainedFPIntrinsic::isUnaryOp() or
24 ConstrainedFPIntrinsic::isTernaryOp() may need to know about the new
25 intrinsic.::
26
27 lib/IR/IntrinsicInst.cpp
28
29 Update the IR verifier::
30
31 lib/IR/Verifier.cpp
32
33 Add SelectionDAG node types
34 ===========================
35
36 Add the new STRICT version of the node type to the ISD::NodeType enum.::
37
38 include/llvm/CodeGen/ISDOpcodes.h
39
40 In class SDNode update isStrictFPOpcode()::
41
42 include/llvm/CodeGen/SelectionDAGNodes.h
43
44 A mapping from the STRICT SDnode type to the non-STRICT is done in
45 TargetLoweringBase::getStrictFPOperationAction(). This allows STRICT
46 nodes to be legalized similarly to the non-STRICT node type.::
47
48 include/llvm/CodeGen/TargetLowering.h
49
50 Building the SelectionDAG
51 -------------------------
52
53 The switch statement in SelectionDAGBuilder::visitIntrinsicCall() needs
54 to be updated to call SelectionDAGBuilder::visitConstrainedFPIntrinsic().
55 That function, in turn, needs to be updated to know how to create the
56 SDNode for the intrinsic. The new STRICT node will eventually be converted
57 to the matching non-STRICT node. For this reason it should have the same
58 operands and values as the non-STRICT version but should also use the chain.
59 This makes subsequent sharing of code for STRICT and non-STRICT code paths
60 easier.::
61
62 lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
63
64 Most of the STRICT nodes get legalized the same as their matching non-STRICT
65 counterparts. A new STRICT node with this property must get added to the
66 switch in SelectionDAGLegalize::LegalizeOp().::
67
68 lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
69
70 Other parts of the legalizer may need to be updated as well. Look for
71 places where the non-STRICT counterpart is legalized and update as needed.
72 Be careful of the chain since STRICT nodes use it but their counterparts
73 often don't.::
74
75 The code to do the conversion or mutation of the STRICT node to a non-STRICT
76 version of the node happens in SelectionDAG::mutateStrictFPToFP(). Be
77 careful updating this function since some nodes have the same return type
78 as their input operand, but some are different. Both of these cases must
79 be properly handled.::
80
81 lib/CodeGen/SelectionDAG/SelectionDAG.cpp
82
83 To make debug logs readable it is helpful to update the SelectionDAG's
84 debug logger:::
85
86 lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
87
88 Add documentation and tests
89 ===========================
90
91 ::
92
93 docs/LangRef.rst
266266 Bugpoint
267267 CodeGenerator
268268 ExceptionHandling
269 AddingConstrainedIntrinsics
269270 LinkTimeOptimization
270271 SegmentedStacks
271272 TableGenFundamentals
344345 This document describes the design and implementation of exception handling
345346 in LLVM.
346347
348 :doc:`AddingConstrainedIntrinsics`
349 Gives the steps necessary when adding a new constrained math intrinsic
350 to LLVM.
351
347352 :doc:`Bugpoint`
348353 Automatic bug finder and test-case reducer description and usage
349354 information.