[LLVMdev] Extending LLVM
sabre at nondot.org
Fri Mar 26 16:53:14 PST 2004
On Fri, 26 Mar 2004, Reid Spencer wrote:
> Would people other than myself find it useful to have a standardized
> extension framework for LLVM? I'm thinking of something that would allow
> new LLVM instructions, fundamental types, structured types, etc. This
> would require significant work to allow the various pieces of LLVM
> (assembler, disassembler, runtime, JIT, optimization, analysis, code
> gen, etc.) to be extended arbitrarily.
It sounds interesting! However, I would make sure that you are _very_
clear about what the goals of this are. Many of the things you mentioned
have very different uses. In particular, what can't LLVM do now that
adding this would enable?
> Each extension would be a self-contained piece of code that could be
> dynamically loaded by LLVM core and used at the right times during LLVM
Again, the examples you gave are all over the board. This would require
being able to plug things into the code generator, various
transformations, etc. While possible, I'm curious what the real goals
> Such things as threading support,
It is already planned for LLVM to get some sort of first-class support for
threading and mutual exclusion, but again, what real purpose does adding
it to the language give you? In the case of thread support, we are going
for two primary goals:
1. Allow multithreading to be expressed at the LLVM level WITHOUT
target-specific dependences. This would allow the same threaded LLVM
bytecode file to run on both linux with pthreads and windows with their
threads, for example.
2. Expose the semantics of the operations to the optimizer, to allow
redundant lock removal, etc.
Note that #2 isn't even strictly necessary either. It's perfectly
reasonable to look for "pthread_mutex_lock" and do optimizations. Our
hope is that we the eventual threading support that LLVM has will be a
lower-level subset of what pthreads provides (providing enough to
implement pthreads on top of it) making it easier to analyze and xform
than pthreads calls directly.
> advanced math functions, scientific computations and types
> (rational,complex,etc.), higher order data structures, etc. could all be
> done as extensions instead of adding them to the core.
I'm not sure what adding support for these to the LLVM language would
allow us to do. Can you give some examples?
> This would keep the core small(ish) and allow researchers and
> implementors to add things to LLVM in an isolated fashion.
This is definitely a great goal, but can you be specific about what kinds
of things this will allow LLVM to do? In particular, none of these have
property #1 above (they can already be implemented portably with existing
LLVM constructs) so they don't increase the "expressiveness" of LLVM.
More information about the llvm-dev