Author Topic: LLVM IR vs. GCC IR?  (Read 4422 times)

0 Members and 1 Guest are viewing this topic.

Ashbad

  • Guest
LLVM IR vs. GCC IR?
« on: August 08, 2011, 09:00:57 pm »
I had a few questions to anyone who's ever dabbled with the Intermediate Representation languages for the GCC and LLVM cross compilers.  I've been researching the two and found some major differences between them, and was wondering which ones people think are easier to work with concerning language parsers translating to them for compilation.

First off: why is it that GNU makes it such a PITA to find a decent tutorial (or at least in-depth documentation) for GCC IR?  LLVM IR *certainly* wins in this perspective, since all I have to do is search LLVM IR, and I get like 5 really good resources on the very first google page.

Secondly: which ones is supported by more *modern* and *most advanced* architectures and platforms?  I'm talking more about x86, x64, possibly ARM and others, and platforms like Windows, OSX, Linux, etc. (from what I can tell, LLVM IR is really good with x86 architectures, considering there's tons of extra feature just for them)

Lastly: which one of the two are the easiest to translate into?  LLVM IR is closer to abstract assembly, while from what I managed to find GCC IR seems to be more Lisp-like.  Which requires less translation to represent a certain assembly function/chunk, and which one has more control over lower-level aspects of an assembly translation?

TIA

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: LLVM IR vs. GCC IR?
« Reply #1 on: August 08, 2011, 10:58:52 pm »
GCC is such a PITA because the compiler is a mess.

However, portability wise, GCC is better. It supports more platforms and it runs on more platforms. However, LLVM is a lot newer than GCC and it has a more advanced architecture, allowing for better optimizations and faster compilation.

For control over the output source, I'd guess that they're both probably about equal in expressive power. LLVM is likely easier to express ASM in, though.

PS: If you're trying to make a compiler as I suspect you are, may I instead recommend something like YACC or ANTLR?
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Ashbad

  • Guest
Re: LLVM IR vs. GCC IR?
« Reply #2 on: August 09, 2011, 08:38:21 am »
GCC is such a PITA because the compiler is a mess.

From what I can tell, good enough reason for me, I agree the GCC compiler is really messy.

Quote
However, portability wise, GCC is better. It supports more platforms and it runs on more platforms. However, LLVM is a lot newer than GCC and it has a more advanced architecture, allowing for better optimizations and faster compilation.

That's what I thought, but wasn't sure.  Thanks

Quote
PS: If you're trying to make a compiler as I suspect you are, may I instead recommend something like YACC or ANTLR?

Well, I'm kinda considering using them, but I don't know if I want to trust them enough when I could make a half-decent parser on my own.  Good suggestion, though, I'll look into them and other Compiler-Compilers some more.