digitalmars.D.learn - Doubt about compiler: Front-End vs Back-End
- Curious (16/20) Feb 16 2020 Hi, could anyone shed a light about the Frond-End and Back-End?
- Adam D. Ruppe (17/22) Feb 16 2020 Compare dmd:
- Curious (10/33) Feb 16 2020 Hmm I see now, so DMD compiler has both Front-End and Back-End,
Hi, could anyone shed a light about the Frond-End and Back-End? I understood the Back-End part, where "roughly" each compiler will generate a machine code based on a IR (Intermediate Representation) generated by the Front-End. But I'm having trouble with the Front-End part, and for what I gather here: https://wiki.dlang.org/DMD_Source_GuideThe front-end (DMD-FE) implements all things D-specific: lexing and parsing D syntax, instantiating templates, producing error messages, etc. The same front-end code is used by DMD, GDC and LDC.Note the ending: "The same front-end code is used by DMD, GDC and LDC." But what the meaning of this sentence? These are 3 different projects so how they share the SAME front-end or how they are connected? Is it a source written in *.CPP for example and the 3 compilers uses the same source? Or the "SAME" means each compiler needs to implement the same code? Looking over Github: https://github.com/dlang/ I see DMD, Phobos and so on, but no separated project called Front-End. Thanks in advance.
Feb 16 2020
On Monday, 17 February 2020 at 02:55:56 UTC, Curious wrote:Note the ending: "The same front-end code is used by DMD, GDC and LDC." But what the meaning of this sentence?They literally share like 97% of the code.Looking over Github: https://github.com/dlang/ I see DMD, Phobos and so on, but no separated project called Front-End.Compare dmd: https://github.com/dlang/dmd/ to ldc: https://github.com/ldc-developers/ldc/ dmd has a `src` folder. ldc has a `dmd` folder. inside those you'll find most the content is identical - written in D btw. gdc is a little different because it is based on an older version of dmd when it was written in C++ before it was ported to D. it will be moving to the D version probably later this year too, but it had to be C++ at first for gcc inclusion. But even so, it is still almost all the same code and even has some patches from new D versions ported back to c++ for it. But basically all three compilers are branches of the same codebase with most the same patches applied going forward so they share the vast, vast majority of frontend code.
Feb 16 2020
On Monday, 17 February 2020 at 03:07:33 UTC, Adam D. Ruppe wrote:On Monday, 17 February 2020 at 02:55:56 UTC, Curious wrote:Hmm I see now, so DMD compiler has both Front-End and Back-End, the LDC in this case is getting only the Front-End part from DMD project. So since the Front-End written in D and the GDC is still the older version (C++), then they need to replicate the new features from D to C++. Well this seems a pain. By the way since the Front-End is in D, so it's occurring bootstrapping, interesting. Thanks.Note the ending: "The same front-end code is used by DMD, GDC and LDC." But what the meaning of this sentence?They literally share like 97% of the code.Looking over Github: https://github.com/dlang/ I see DMD, Phobos and so on, but no separated project called Front-End.Compare dmd: https://github.com/dlang/dmd/ to ldc: https://github.com/ldc-developers/ldc/ dmd has a `src` folder. ldc has a `dmd` folder. inside those you'll find most the content is identical - written in D btw. gdc is a little different because it is based on an older version of dmd when it was written in C++ before it was ported to D. it will be moving to the D version probably later this year too, but it had to be C++ at first for gcc inclusion. But even so, it is still almost all the same code and even has some patches from new D versions ported back to c++ for it. But basically all three compilers are branches of the same codebase with most the same patches applied going forward so they share the vast, vast majority of frontend code.
Feb 16 2020