views:

302

answers:

4

Hello.

for my own education I am curious what compilers use which C++ front-end and backend. Can you enlighten me where the following technologies are used and what hallmarks/advantages they have if any?

  • Open64 - is it backend, front-end, or both? Which compilers use it? I encounter it in cuda compiler.

  • EDG - as far as I can tell this is a frontend use by Intel compilers and Comeau. do other compilers use it? I found quite a few references to it in boost source code.

  • ANTLR - this is general parser. Do any common compilers use it?

Regarding compilers:

  • with front-end/backend does gcc compiler suite uses? does it have common heritage with any other compiler?

  • what front-end/backend PGI and PathScale compilers use?

  • what front-end/backend XL compiler uses (IBM offering).

in-depth links on the Internet or your personal know-how would be great. I did some Google searching, but information I generally encountered was rather superficial.

Thanks.

+5  A: 

with front-end/backend does gcc compiler suite uses? does it have common heritage with any other compiler?

The acronym “GCC” stands for “GNU compiler collection” (originally “GNU C compiler”) and this already gives a hint: GNU compilers are a collection of compilers, most notably for C and C++ but also for Fortran, Objective-C and others. They share a common back-end and intermediate representation that was developed for GCC specifically.

The front-ends are all custom-written for the GCC. Some were contributed by third parties, most notably the Objective-C front-end, which was contributed by Apple.

Konrad Rudolph
+5  A: 

The Clang project provides new front-ends for C/C++/Objective C on top of the LLVM backend. The LLVM project also provide a LLVM-gcc, using the GCC front end and the LLVM backend. The DragonEgg project seeks to replace the GCC backend with LLVM.

The Codeplay VectorC, Sieve and Offload compilers use a custom front-end and back-end

grrussel
+2  A: 

Visual studio uses EDG for its intellisense engine.

Motti
But note that it's only for Intellisense. The compiler is still entirely Microsoft's own creation.
Jerry Coffin
@Jerry, true, I'll update my answer.
Motti
+5  A: 

EDG is a front-end used by Intel and Comeau. See EDG's list of customers for other users.

ANTLR is a parser generator. I'm not aware of any C++ compiler built around a parser that was built with ANTLR (that doesn't mean it couldn't exist though).

Gcc is a suite of compilers, with front ends for C, C++, Fortran, Ada, Java, etc., and back-ends for more processors than I'd care to think about.

Open64 is also a suite of compilers including several front-ends (for C, C++, Fortran, and possibly others I don't remember at the moment) and back-ends (targeting X64, Itanium, ARM, and, again, probably others I don't remember and/or don't know about). I believe its origin (pun noted by not intended) is SGI's compiler(s). I seem to remember reading something hinting that Open64 was derived from some version of the gcc front end(s), but offhand I don't know 1) how similar it remains to gcc internally, or 2) the version of gcc from which it derived -- but it's been around long enough that I'd guess it was gcc 3.x at the most recent, and quite possibly gcc 2.x.

I believe PathScale has created at least one compiler derived from Open64, but they may have others as well.

As far as I know, IBM's compiler is entirely their own creation. I'd guess IBM's (now discontinued) VisualAge for C++ shared some heritage/development/code with XL C++, but don't know that for sure, and can't even begin to guess at the extent of it, even assuming it's true.

Jerry Coffin
thanks .With nvcc (open 64) I get major problems when trying to use boost type traits (or anything that includes it). hopefully I will have some reference when looking for compiler workarounds
aaa
C++ isn't LALR, so that's why (name your favorite parser generator) isn't used for the front end. ANTLR works based on LL(*) instead of LALR, but I stink that also isn't sufficient for some of C++'s trickier syntax. C++ grammar isn't context-free, which is a requirement for most generalized parser generators.
Ben Voigt
@Ben:While that's pretty accurate with respect to most parser generators, there are a few that should be able to handle C++. I'm reasonably certain C++ should fit within the (few) constraints of a GLR grammar. A few generators can deal with GLR grammars (e.g., Elkhound).
Jerry Coffin
@Jerry: From http://scottmcpeak.com/elkhound/: <quote>GLR works with any context-free grammar</quote> C++ isn't context-free, so not even Elkhound can parse it. Not to say that it isn't a useful part of the task, but I believe you end up with lexed tokens parsed down to a set of possible meanings, and then the contextual analyzer finishes the parsing process as it builds symbol tables, etc.
Ben Voigt
@Ben:Yes and no -- C++ has context-dependent semantics (e.g. the infamous "most vexing parse"), but a parser doesn't *need* to deal with that -- it only has to accept well formed code and reject malformed code. From that perspective, C++ is (or can be treated as) context free -- though you have to "sort out" more later in the compiler if you do that.
Jerry Coffin
A parser that doesn't distinguish "most vexing parse" isn't a complete parser. Like I said, such a quasi-parser is still very useful, but the output still isn't fully parsed, the contextual analyzer has to finish the job.
Ben Voigt
@Ben:not really true -- determining meaning is the domain of semantic analysis. Yes, we'd generally *prefer* that a parser make the semantic analysis easy, but it's not required for a parser to qualify as a parser.
Jerry Coffin
A parser is supposed to determine what "part of speech" each word has in a sentence, or what function each token has in source code. See http://yosefk.com/c++fqa/web-vs-c++.html#misfeature-2 and http://www.merriam-webster.com/dictionary/parse
Ben Voigt
@Ben:quoting Yossi Kreinin as an authority hardly does your cause any good. In any case, it simply comes down to a question of how you choose to define "parser". Frankly, I just don't much care -- if you prefer to think of cfront (for one example) as not having had a parser because it was developed using yacc, so be it.
Jerry Coffin
@Jerry: In general, that page in full of FUD. But it does have several good examples of context-dependent parse. And he's absolutely right that the abstract syntax tree is totally different in those cases. Really, I think we're in agreement on this issue: a parser generator can be very helpful in processing C++ but the contextual parts of the grammar have to be more fully processed by later steps.
Ben Voigt
@Ben:well put, and quite right.
Jerry Coffin