# Load Polly into dragonegg and automatically run it at -O3

Note:This is a quick note on how to load Polly into dragonegg. The choice of front-end does not affect the passes available with Polly, only the syntax is different. The examples for use with clang can also be performed with Polly, with suitable corrections in the syntax.

## Compile dragonegg with support for LLVM plugins

The support for LLVM plugins in dragonegg is still experimental, and hence protected by a build option. You must rebuild dragonegg with the following options:

    $ GCC=${PATH_TO_GCC} LLVM_CONFIG=${PATH_TO_LLVM_CONFIG} ENABLE_LLVM_PLUGINS=1 make

## Load Polly into dragonegg

By loading Polly into dragonegg, the Polly options become automatically available. You can load Polly either by adding the relevant commands to the CPPFLAGS or by creating an alias.

    $ export CPPFLAGS="-fplugin=/path/to/dragonegg.so -fplugin-arg-dragonegg-llvm-option=-load:${POLLY_BUILD_DIR}/lib/LLVMPolly.so"

or

    $ alias pollycc gcc -fplugin=/path/to/dragonegg.so -fplugin-arg-dragonegg-llvm-option=-load:${POLLY_BUILD_DIR}/lib/LLVMPolly.so

## Optimizing with Polly

Optimizing with Polly is as easy as adding -O3 -fplugin-arg-dragonegg-llvm-option=-polly to your compiler flags (Polly is only available at -O3).

    pollycc -O3 -fplugin-arg-dragonegg-llvm-option=-polly file.c

## Passing various options to Polly

As must be evident from the examples so far, options to LLVM and its plugins are passed via the -fplugin-arg-dragonegg-llvm-option commandline argment. The examples for use with clang can be executed with dragonegg by replacing the -mllvm syntax with the dragonegg syntax.