declarations on the fly ?

4 views
Skip to first unread message

Lukasz Fronc

unread,
Apr 15, 2010, 6:09:21 AM4/15/10
to llvm-py: Python Bindings for LLVM
Hi,

I'm using llvm-py for a month now and I wonder if there is any way to
add declaration on the fly.
What I'm doing now is:

file = open('base_decl.ll', 'r')
module = Module.from_assembly(file)

The declarations I want are known at compilation time, adding them on
the fly could save a static analysis pass.


Thank you for taking the time to answer my questions.

Cheers,
Lukasz

Mahadevan R

unread,
Apr 15, 2010, 12:32:37 PM4/15/10
to llv...@googlegroups.com
On Thu, Apr 15, 2010 at 3:39 PM, Lukasz Fronc <thelv...@gmail.com> wrote:
> Hi,
>
> I'm using llvm-py for a month now and I wonder if there is any way to
> add declaration on the fly.

Declarations are just functions without any basic blocks. Create an
empty module (Module.new), then function types, and add functions of
that type. If you do not append any basic blocks to the functions,
they remain declarations.

HTH,
-Mahadevan.

> What I'm doing now is:
>
> file = open('base_decl.ll', 'r')
> module = Module.from_assembly(file)
>
> The declarations I want are known at compilation time, adding them on
> the fly could save a static analysis pass.
>
>
> Thank you for taking the time to answer my questions.
>
> Cheers,
> Lukasz
>
>

> --
> To unsubscribe, reply using "remove me" as the subject.
>

Lukasz Fronc

unread,
Apr 16, 2010, 8:34:25 AM4/16/10
to llvm-py: Python Bindings for LLVM


On Apr 15, 6:32 pm, Mahadevan R <mdevan.foo...@gmail.com> wrote:
> On Thu, Apr 15, 2010 at 3:39 PM, Lukasz Fronc <thelvyn...@gmail.com> wrote:
> > Hi,
>
> > I'm using llvm-py for a month now and I wonder if there is any way to
> > add declaration on the fly.
>
> Declarations are just functions without any basic blocks. Create an
> empty module (Module.new), then function types, and add functions of
> that type. If you do not append any basic blocks to the functions,
> they remain declarations.
>
> HTH,
> -Mahadevan.
>

That works, thanks !
Lukasz


--
Subscription settings: http://groups.google.com/group/llvm-py/subscribe?hl=en
Reply all
Reply to author
Forward
0 new messages