Best intermediate form to...

Hello Everyone!
   New to the forums, so hopefully I'm not a nuisance. I just wanted to
know where to go (since I heard there were about 5 different intermediate
forms for llvm) to find the highest level intermediate form of llvm. I want
to be able to get as much information from a front-end as possible. Mainly
I need to find out dependencies and control flows, amongst a few other
things. So far I've seen http://llvm.org/docs/LangRef.html which might be
what I'm looking for, but I just wanted to make sure.

   Also I heard that there's something that can convert GCCs GIMPLE to llvm
IR, which I looked up and I believe is llvm-gcc, but again, I want to make
sure that's it. Also, is there a plugin that converts llvm IR to GIMPLE, or
is there a project currently working on it?

Thanks in advance! =)
-nonpoly

nonpoly wrote:

Hello Everyone!
    New to the forums, so hopefully I'm not a nuisance. I just wanted to
know where to go (since I heard there were about 5 different intermediate
forms for llvm) to find the highest level intermediate form of llvm.

I assume you're referring to this comment:

   http://lwn.net/Articles/383707/

LLVM has one major IR that we mean when we say "the IR", and that's the one described by the LangRef you linked to.

As for the having five different ones, it really comes down to what you consider an IR. Many passes will to build up data structures on the side in order to facilitate their optimizations. At what point do those cross the line from being data to being another intermediate representation? I would argue that a good test is whether the intention is whether you lower from one to the next. For example, gcc lowers from GENERIC to GIMPLE and never looks back, Open64 lower VHL to HL to ML to LL to VLL the same way. The SCEV format at least isn't like that, but there is at least one lowering step from the IR to the DAG/MachineInsts that machine-specific CodeGen uses. MCInst may not be an IR on the grounds that it's not intermediate, it's just a direct representation of assembly instructions.

   I want

to be able to get as much information from a front-end as possible. Mainly
I need to find out dependencies and control flows, amongst a few other
things. So far I've seen http://llvm.org/docs/LangRef.html which might be
what I'm looking for, but I just wanted to make sure.

Yes.

    Also I heard that there's something that can convert GCCs GIMPLE to llvm
IR, which I looked up and I believe is llvm-gcc, but again, I want to make
sure that's it. Also, is there a plugin that converts llvm IR to GIMPLE, or
is there a project currently working on it?

Yes, there's llvm-gcc which is a modified gcc 4.2. It's getting less attention as more work is done on clang. There's also the plugin you mentioned, dragonegg.llvm.org.

Nick

Wow, thanks for the super fast reply!

I was asking about llvm-gcc because I want to be able to work with code that
compiles on GCC (since there is so much already out there), but in an
intermediate form. So I take it that clang plans on being able to compile
code that compiles on GCC? I'm assuming that's what they mean by "GCC
compatibility" on http://clang.llvm.org/ ;p

On a side note, is clang - at least for the most part - hand coded like g++
was for GCC? Or is it making use of generators like lex/flex and
yacc/bison?

Thanks again!
-nonpoly

Nick Lewycky wrote:

Wow, thanks for the super fast reply!

I was asking about llvm-gcc because I want to be able to work with code that
compiles on GCC (since there is so much already out there), but in an
intermediate form. So I take it that clang plans on being able to compile
code that compiles on GCC? I'm assuming that's what they mean by "GCC
compatibility" on http://clang.llvm.org/ ;p

With some caveats, yes... clang has gcc-compatible command-line
parsing and supports all the commonly used gcc extensions. See
http://clang.llvm.org/docs/UsersManual.html#c .

On a side note, is clang - at least for the most part - hand coded like g++
was for GCC? Or is it making use of generators like lex/flex and
yacc/bison?

Hand-coded; see http://clang.llvm.org/features.html#unifiedparser .

-Eli