[llvm-commits] Dynamically loadable targets

Chris Lattner sabre at nondot.org
Sat Jul 10 23:34:01 PDT 2004


Hi guys,

I just checked in support for auto-registrating targets.  I think that
this should make your lives substantially easier by not having to have
hacky code in llc.cpp, the allocate*TargetMachine business is now all
gone, and you can even dynamically load your targets as plugins to avoid
having to rebuild llc all of the time.

If updated targets that are in CVS, but Vladimir, I obviously can't update
yours.  If you look at the CVS commits for the PPC backend, you'll see
what I basically did.  Here's the synopsis:

1. delete allocate*TargetMachine
2. TargetMachineImpls.h is gone
3. TargetOptions.h now contains the PrintMachineCode flag
4. You must register your target with RegisterTarget<X>.
5. If you want llc/lli to auto pick your target when run a -march=x option
   is not specified, implement the TargetMachine::getModuleMatchQuality
   getJITMatchQuality methods.  When we have target triple support, we
   can do much more interesting things, but for now see the X86 or V9
   implementations of them.
6. You can choose to either statically link your TargetMachine into
   llc/lli or to dynamically load it with -load.

To use -load, put "SHARED_LIBRARY=1" in your target makefile (to build the
so), then use this to verify that it is being loaded correctly:

llc -load .../path/to/yourtarget.so --help

Your target should be listed.

Enjoy,

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://nondot.org/sabre/





More information about the llvm-commits mailing list