llvm.org GIT mirror llvm / 63dc318
Regenerate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73597 91177308-0d34-0410-b5e6-96231b3b80d8 Mikhail Glushenkov 10 years ago
2 changed file(s) with 13 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
5656 by plugins, which can be either statically or dynamically linked. This
5757 makes it possible to easily adapt LLVMC for other purposes - for
5858 example, as a build tool for game resources.

59

Because LLVMC employs TableGen as its configuration language, you

59

Because LLVMC employs TableGen as its configuration language, you

6060 need to be familiar with it to customize LLVMC.

6161
6262
7070 $ ./a.out
7171 hello
7272
73

One nice feature of LLVMC is that one doesn't have to distinguish

74 between different compilers for different languages (think g++ and
75 gcc) - the right toolchain is chosen automatically based on input
76 language names (which are, in turn, determined from file
77 extensions). If you want to force files ending with ".c" to compile as
78 C++, use the -x option, just like you would do it with gcc:

73

One nice feature of LLVMC is that one doesn't have to distinguish between

74 different compilers for different languages (think g++ vs. gcc) - the
75 right toolchain is chosen automatically based on input language names (which
76 are, in turn, determined from file extensions). If you want to force files
77 ending with ".c" to compile as C++, use the -x option, just like you would
78 do it with gcc:

7979

                  
                
8080 $ # hello.c is really a C++ file
8181 $ llvmc -x c++ hello.c
157157
158158

To build your plugin as a dynamic library, just cd to its source

159159 directory and run make. The resulting file will be called
160 LLVMC$(LLVMC_PLUGIN).$(DLL_EXTENSION) (in our case,
161 LLVMCMyPlugin.so). This library can be then loaded in with the
160 plugin_llvmc_$(LLVMC_PLUGIN).$(DLL_EXTENSION) (in our case,
161 plugin_llvmc_MyPlugin.so). This library can be then loaded in with the
162162 -load option. Example:

163163

                  
                
164164 $ cd $LLVMC_DIR/plugins/Simple
165165 $ make
166 $ llvmc -load $LLVM_DIR/Release/lib/LLVMCSimple.so
166 $ llvmc -load $LLVM_DIR/Release/lib/plugin_llvmc_Simple.so
167167
168168
169169
196196 $ cd $LLVMC_DIR
197197 $ make LLVMC_BUILTIN_PLUGINS=MyPlugin LLVMC_BASED_DRIVER_NAME=mydriver
198198
199

This works with both srcdir==objdir and srcdir != objdir, but assumes that the

199

This works with both srcdir == objdir and srcdir != objdir, but assumes that the

200200 plugin source directory was placed under $LLVMC_DIR/plugins.

201201

Sometimes, you will want a 'bare-bones' version of LLVMC that has no

202202 built-in plugins. It can be compiled with the following command:

4747
4848
4949

Using LLVMC to generate toolchain drivers

50

LLVMC plugins are written mostly using TableGen, so you need to

50

LLVMC plugins are written mostly using TableGen, so you need to

5151 be familiar with it to get anything done.

5252

Start by compiling example/Simple, which is a primitive wrapper for

5353 gcc:

5454

                  
                
5555 $ cd $LLVM_DIR/tools/llvmc
56 $ cp -r example/Simple plugins/Simple
5657
5758 # NB: A less verbose way to compile standalone LLVMC-based drivers is
5859 # described in the reference manual.