X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FExtendingLLVM.html;h=99e209b89403027305729cee2082bdeeb0bad93c;hb=8f00ae6a3f8d392ce0f42a81223e479f97876d7f;hp=b072ed3b6e8532fdc10f66b21975813cd7a6b58f;hpb=068da2781170e793607be74b6af16f4fc122fea5;p=oota-llvm.git diff --git a/docs/ExtendingLLVM.html b/docs/ExtendingLLVM.html index b072ed3b6e8..99e209b8940 100644 --- a/docs/ExtendingLLVM.html +++ b/docs/ExtendingLLVM.html @@ -2,15 +2,16 @@ "http://www.w3.org/TR/html4/strict.dtd"> + Extending LLVM: Adding instructions, intrinsics, types, etc. - + -
+

Extending LLVM: Adding instructions, intrinsics, types, etc. -

+
  1. Introduction and Warning
  2. @@ -31,12 +32,12 @@ -
    +

    Introduction and Warning -

    + -
    +

    During the course of using LLVM, you may wish to customize it for your research project or for experimentation. At this point, you may realize that @@ -68,12 +69,12 @@ effort by doing so.

    - + -
    +

    Adding a new intrinsic function to LLVM is much easier than adding a new instruction. Almost all extensions to LLVM should start as an intrinsic @@ -104,19 +105,6 @@ function and then be turned into an instruction if warranted.

    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. For - most intrinsics, it makes sense to add code to lower your intrinsic in - LowerIntrinsicCall in lib/CodeGen/IntrinsicLowering.cpp. - Second, if it makes sense to lower the intrinsic to an expanded sequence of - C code in all cases, just emit the expansion in visitCallInst in - Writer.cpp. 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 support to the .td file for the target(s) of your choice in lib/Target/*/*.td.
    @@ -130,12 +118,12 @@ support for it. Generally you must do the following steps:

    - + -
    +

    As with intrinsics, adding a new SelectionDAG node to LLVM is much easier than adding a new instruction. New nodes are often added to help represent @@ -146,7 +134,7 @@ cases, new nodes have been added to allow many targets to perform a common task complicated behavior in a single node (rotate).

      -
    1. include/llvm/CodeGen/SelectionDAGNodes.h: +
    2. include/llvm/CodeGen/ISDOpcodes.h: Add an enum value for the new SelectionDAG node.
    3. lib/CodeGen/SelectionDAG/SelectionDAG.cpp: Add code to print the node to getOperationName. If your new node @@ -220,12 +208,12 @@ complicated behavior in a single node (rotate).

    - + -
    +

    WARNING: adding instructions changes the bitcode format, and it will take some effort to maintain compatibility with @@ -277,25 +265,23 @@ to understand this new instruction.

    - + -
    +

    WARNING: adding new types changes the bitcode format, and will break compatibility with currently-existing LLVM installations. Only add new types if it is absolutely necessary.

    -
    - - + -
    +
      @@ -317,11 +303,11 @@ installations. Only add new types if it is absolutely necessary.

    - + -
    +
    1. llvm/include/llvm/Type.h: @@ -373,16 +359,18 @@ void calcTypeName(const Type *Ty,
    +
    +
    Valid CSS! + src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"> Valid HTML 4.01! + src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"> - The LLVM Compiler Infrastructure + The LLVM Compiler Infrastructure
    Last modified: $Date$