Announcement

Collapse
No announcement yet.

Can someone explain LLVM+clang?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can someone explain LLVM+clang?

    I've read the wikipedia entries and browsed the sites and watched some YouTube videos, but I still have some simple overview questions:

    When I worked with Metrowerks CodeWarrior, they had a C/C++ "front end" that converted source to "IL" (intermediate language) which was a general platform agnostic language and then different back ends for different CPU platforms such as x86 and ARM that convert the IL code to CPU native code. LLVM sounds like it is conceptually identical to what Metrowerks called "IL". It is a virtual machine in the sense that it is like a general platform agnostic CPU. Is this correct?

    Secondly, LLVM+clang sounds like just another C/C++ tool chain that promises a variety of implementation improvements. Is this correct? It is supposed to be faster, cleaner, and more tool friendly than gcc, but it still does the same basic thing which is take C/C++ (and also Objective C variants) and convert to native CPU code? Are the final binaries native CPU code or are they LLVM code with an embedded interpreter?

    (does this site not have a programmer forum? that seems rather odd)

  • #2
    Originally posted by DanLamb View Post
    When I worked with Metrowerks CodeWarrior, they had a C/C++ "front end" that converted source to "IL" (intermediate language) which was a general platform agnostic language and then different back ends for different CPU platforms such as x86 and ARM that convert the IL code to CPU native code. LLVM sounds like it is conceptually identical to what Metrowerks called "IL". It is a virtual machine in the sense that it is like a general platform agnostic CPU. Is this correct?"

    Secondly, LLVM+clang sounds like just another C/C++ tool chain that promises a variety of implementation improvements. Is this correct? It is supposed to be faster, cleaner, and more tool friendly than gcc, but it still does the same basic thing which is take C/C++ (and also Objective C variants) and convert to native CPU code? Are the final binaries native CPU code or are they LLVM code with an embedded interpreter?
    The "Virtual Machine" aspect of the name is historical, from the LLVM homepage: "Despite its name, LLVM has little to do with traditional virtual machines...The name "LLVM" itself is not an acronym; it is the full name of the project."

    Clang takes C/C++/ObjC and converts it to the intermediate language used by LLVM. LLVM takes this intermediate language (though they call it an Intermediate Representation (IR)) and converts it to native CPU code. The two are commonly used together but the great strength is that they can be used separately.

    One reason LLVM is generating a lot of interest is that it doesn't matter where the intermediate representation comes from: it doesn't need to be from Clang. One of the notable uses is in the open source radeon drivers: the developers have written a front-end that compiles GPU shader code to LLVM's IR, which means they get LLVM's optimisation 'free', just by writing the shader-to-IR front-end.

    Postscript: llvm.org contains a list of related projects

    Comment


    • #3
      Originally posted by archibald View Post
      One reason LLVM is generating a lot of interest is that it doesn't matter where the intermediate representation comes from: it doesn't need to be from Clang.
      That's how all IR works. With Metrowerks CodeWarrior, for example, they supported Pascal as well as C/C++/Obj-C.

      It's basically just another, probably better, C-style native code compiler system. LLVM seems more published and adopted than than traditional proprietary compiler IR.

      Comment


      • #4
        Apologies, that was a poorly-phrased attempt to emphasise that whilst LLVM and clang are often used together (as a native code compiler), they don't need to be.

        Comment

        Working...
        X