[LLVMdev] LLVM as a shared library

Sean Silva chisophugis at gmail.com
Wed Aug 6 14:54:47 PDT 2014


On Wed, Aug 6, 2014 at 9:28 AM, Eric Christopher <echristo at gmail.com> wrote:

> > I haven’t yet worked out the cleanest way to do this.  There’s 2 options
> I
> > think.  Either make some kind of command line registration available via
> the
> > PassRegistry already passed to initialize, or we add another parameter to
> > initialize which is the command line registry.
> >
> > What do you think?
> >
>
> I was thinking about this a while ago w.r.t. the backend options
> coming from clang as well. One thought would be to add
> elements/structures onto something like the LLVMContext and have them
> be able to be set via populating a structure while we take the command
> lines out/separated/etc that can also fill in the structure.
>
> I think this would work for most of the command line options within
> the passes as well, just give each one their own options structure?
>

I once thought a bit about this situation, and the (probably hopelessly
naive) thing that I came up with is something like adding roughly a
std::map<StringRef,StringRef> to the LLVMContext, which is essentially just
a "string'ly-typed" key-value store. Then we have a couple helper functions
that deserialize their respective values, e.g.

int NumTimes = getParameter<int>(KVs,"foo-num-times");
StringRef CFGRoot = getParameter<StringRef>(KVs,"foo-cfgroot");
std::vector<StringRef> UsedFuncs =
getParameter<std::vector<StringRef>>(KVs,"foo-used-funcs");
(a layer of caching of the deserialized values might be useful).

The idea is to avoid having a large impedance mismatch between command line
options (which are essentially string'ly typed) and the in-memory
configuration storage.
For tools, we have some sort of translation layer that pulls command line
options into the KV structure. For more modular needs, the KV structure can
be maintained manually and passed in at the desired granularity.

We can also have pass creation functions accept such a KV structure (if
relevant) for configuration stuff (or maybe have each pass have an
associated helper function that accepts a KV structure and turns it into
the actual configuration struct that the pass accepts).

-- Sean Silva


>
> *shrug*
>
> -eric
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140806/e1f76c55/attachment.html>


More information about the llvm-dev mailing list