diff --git a/docs/ExtendingLLVM.html b/docs/ExtendingLLVM.html index ef784982ef7..d40b18f8482 100644 --- a/docs/ExtendingLLVM.html +++ b/docs/ExtendingLLVM.html @@ -24,8 +24,8 @@
-

Written by Misha Brukman and - Brad Jones

+

Written by Misha Brukman, + Brad Jones, and Chris Lattner

@@ -86,9 +86,6 @@ function and then be turned into an instruction if warranted.

  • llvm/include/llvm/Intrinsics.h: add an enum in the llvm::Intrinsic namespace
  • -
  • llvm/lib/CodeGen/IntrinsicLowering.cpp: - implement the lowering for this intrinsic
  • -
  • llvm/lib/VMCore/Verifier.cpp: Add code to check the invariants of the intrinsic are respected.
  • @@ -100,17 +97,63 @@ function and then be turned into an instruction if warranted.

    not access memory or does not write to memory, add it to the relevant list of functions. -
  • llvm/lib/Transforms/Utils/Local.cpp: If it is possible to - constant-propagate your intrinsic, add support to it in the - canConstantFoldCallTo and ConstantFoldCall functions.
  • +
  • llvm/lib/Transforms/Utils/Local.cpp: If it is possible to constant +fold your intrinsic, add support to it in the canConstantFoldCallTo and +ConstantFoldCall functions.
  • Test your intrinsic
  • llvm/test/Regression/*: add your test cases to the test suite
  • -

    If this intrinsic requires code generator support (i.e., it cannot be -lowered), you should also add support to the code generator in question.

    +

    Once the intrinsic has been added to the system, you must add code generator +support for it. Generally you must do the following steps:

    + +
    +
    Add support to the C backend in lib/Target/CBackend/
    + +
    Depending on the intrinsic, there are a few ways to implement this. First, +if it makes sense to lower the intrinsic to an expanded sequence of C code in +all cases, just emit the expansion in visitCallInst. Second, if the +intrinsic has some way to express it with GCC (or any other compiler) +extensions, it can be conditionally supported based on the compiler compiling +the CBE output (see llvm.prefetch for an example). Third, if the intrinsic +really has no way to be lowered, just have the code generator emit code that +prints an error message and calls abort if executed. +
    + +
    Add a enum value for the SelectionDAG node in +include/llvm/CodeGen/SelectionDAGNodes.h
    + +
    Also, add code to lib/CodeGen/SelectionDAG/SelectionDAG.cpp (and +SelectionDAGPrinter.cpp) to print the node.
    + +
    Add code to SelectionDAG/SelectionDAGISel.cpp to recognize the +intrinsic.
    + +
    Presumably the intrinsic should be recognized and turned into the node you +added above.
    + +
    Add code to SelectionDAG/LegalizeDAG.cpp to legalize, promote, and +expand the node as necessary.
    + +
    If the intrinsic can be expanded to primitive operations, legalize can break +the node down into other elementary operations that are be supported.
    + +
    Add target-specific support to specific code generators.
    + +
    Extend the code generators you are interested in to recognize and support +the node, emitting the code you want.
    +
    + +

    +Unfortunately, the process of extending the code generator to support a new node +is not extremely well documented. As such, it is often helpful to look at other +intrinsics (e.g. llvm.ctpop) to see how they are recognized and turned +into a node by SelectionDAGISel.cpp, legalized by +LegalizeDAG.cpp, then finally emitted by the various code generators. +

    @@ -277,7 +320,6 @@ void calcTypeName(const Type *Ty, Valid HTML 4.01! - Misha Brukman
    The LLVM Compiler Infrastructure
    Last modified: $Date$