[llvm-commits] [PATCH][CMake] Document CMake build feature to develop passes out-source.

Óscar Fuentes ofv at wanadoo.es
Tue Apr 12 08:15:05 PDT 2011


arrowdodger <6yearold at gmail.com> writes:

> This patch adds explanation and code snippets how to develop LLVM passes out
> of LLVM source tree.

[snip]

> +  <p>It is possible to develop LLVM passes against installed LLVM.
> +     An example of project layout provided below:</p>
> +
> +  <div class="doc_code">
> +    <pre>
> +      <project dir>/
> +          |
> +          CMakeLists.txt
> +          <pass name>/
> +              |
> +              CMakeLists.txt
> +              Pass.cpp
> +              ...

Here you mention Pass.cpp ...

> +    </pre>
> +  </div>
> +
> +  <p>Contents of <project dir>/CMakeLists.txt:</p>
> +
> +  <div class="doc_code">
> +    <pre>
> +    find_package(LLVM)
> +
> +    <b># Define add_llvm_* macro's.</b>
> +    include(AddLLVM)
> +
> +    add_definitions(${LLVM_DEFINITIONS})
> +    include_directories(${LLVM_INCLUDE_DIRS})
> +    link_directories(${LLVM_LIBRARY_DIRS})
> +
> +    add_subdirectory(<pass name>)
> +    </pre>
> +  </div>
> +
> +  <p>Contents of <project dir>/<pass name>/CMakeLists.txt:</p>
> +
> +  <div class="doc_code">
> +    <pre>
> +    add_llvm_loadable_module(LLVMHello
> +      Hello.cpp

... and here Hello.cpp.

Also, LLVMHello is a bad name because it is already created by the LLVM
build. As the current practice in LLVM is to name directories after the
library it contains, I suggest something like LLVMYourPass as the name
for both the directory and the pass.

> +      )
> +    </pre>
> +  </div>
> +
> +  <p>This layout allows easy integration of developed pass
> +     into mainstream. It consists in two steps:<br>
> +     1. Copying <pass name> folder into <LLVM root>/lib/Transform directory.<br>
> +     2. Adding "add_subdirectory(<pass name>)" line into <LLVM root>/lib/Transform/CMakeLists.txt</p>

Maybe you should make clear that the above paragraph is meaningful only
after you finished your work and want to contribute your pass to LLVM.




More information about the llvm-commits mailing list