Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does C-- compare to LLVM?

After learning a bit of how LLVM work I'm really excited about how portable low-level code can be generated and how modular this 'thing' is built.

But I discovered today the existence of C-- that seems to share some concepts with LLVM.

So I'm looking for some information helping me understand the main differences between these two projects... and why both exist.

For me LLVM looks a bit like the ultimate Swiss Army knife for compiler infrastructure, and C-- looks far less advanced.

like image 810
Alois Cochard Avatar asked Oct 08 '10 14:10

Alois Cochard


People also ask

Is GCC better than LLVM?

While LLVM and GCC both support a wide variety languages and libraries, they are licensed and developed differently. LLVM libraries are licensed more liberally and GCC has more restrictions for its reuse. When it comes to performance differences, GCC has been considered superior in the past.

Why is LLVM so good?

Each library supports a particular component in a typical compiler pipeline (lexing, parsing, optimizations of a particular type, machine code generation for a particular architecture, etc.). What makes it so popular is that its modular design allows its functionality to be adapted and reused very easily.

Is Clang the same as LLVM?

LLVM is a backend compiler meant to build compilers on top of it. It deals with optimizations and production of code adapted to the target architecture. CLang is a front end which parses C, C++ and Objective C code and translates it into a representation suitable for LLVM.


1 Answers

They differ in how expressive the low level machine type system is.

The LLVM machine is pretty expressive. The C-- machine on the other hand, puts a lot of responsibility on the language front end. Quoting from the C-- FAQ: "simply, C-- has no high-level types---it does not even distinguish floating-point variables from integer variables. This model gives the front end total control of representation and type system"

Also visually they look a lot different. C-- looks a lot like C, LLVM looks a lot like assembler.

Pragmatically, LLVM has a lot more momentum right now. It has a JIT compiler, Apple is using it for 3D pipeline things and people are using it to connect to GCC and all sorts of weird and wonderful things. Someone called it "almost absurdly easy to work with".

On the other hand C-- is much smaller and probably easier to entirely comprehend. (I imagine a normal person with some dedication can fully understand all aspects of it.)

like image 66
Prof. Falken Avatar answered Nov 08 '22 07:11

Prof. Falken