Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.compilers > #3347
| From | Thomas Koenig <tkoenig@netcologne.de> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Are there different programming languages that are compiled to the same intermediate language? |
| Date | 2023-01-29 22:14 +0000 |
| Organization | news.netcologne.de |
| Message-ID | <23-01-080@comp.compilers> (permalink) |
| References | <23-01-078@comp.compilers> |
Roger L Costello <costello@mitre.org> schrieb: > Hi Folks, > > Programming_Language_1 has a compiler which generates Intermediate_Code_1. > Many backends are created for Intermediate_Code_1. > > Time passes .... > > Sally Smith creates Programming_Language_2. Sally wants to leverage the > compiler work done on Programming_Language_1. She considers two approaches: > > 1. Create a compiler front-end for Programming_Language_2 which compiles > instances to Intermediate_Code_1. Compilers have been doing that for a very long time. I remember reading that the IBM PL.8 compiler used a target-independent intermediate representation, and gcc and LLVM both adopt this. Makes sense - most of the optimizations are target-indpendent. Typically, SSA (single static assignment) is used these days because it offers many optimization opportunites. > 2. Create a translator which converts instances of Programming_Language_2 into > Programming_Language_1 instances. That is also an approach, which works if the Programming_Language_2 is sufficiently low-level, and yet sufficiently flexible, to allow a reasonable representation. In practice, this usually means C, where things like pointer arithmetic can be used to implement multi-dimensional arrays. Fortran is a prime example. Both the well-known f2c translator, based on the Bell Labs Fortran 77 compiler, and the NAG Fortran comppiler use C as intermediate language. > Sally is concerned. She asks herself: > > - With either approach, how do I prove that my mapping is correct? Usually, she can't. Compiler front ends are well-known to have bugs, and it would be very hard to prove their correctness, especially if the bugs are in semantics, which are usually not described in a formal way. > - For approach 1, how do I prove that the Intermediate_Code_1 that I generate > is correct for my programming language? See above. > - For approach 2, how do I prove that the instance of Programming_Language_1 > that I generate is semantically equivalent to my Programming_Language_2 > instance?" Same problem. [Target-independent intermediate forms work OK when the source languages are semantically similar, e.g. C and Fortran, and range of target architectures is limited, e.g., two's complement machines with 8-bit byte flat addressing. Every few years someone comes up with the bright idea to do an all purpose intermediate language, which never works. See UNCOL around 1960 for the first time that idea failed. By the way, f2c is based on f77 which compiled Fortran into the intermediate language the PDP-11 C compiler used. -John]
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Are there different programming languages that are compiled to the same intermediate language? Roger L Costello <costello@mitre.org> - 2023-01-29 15:49 +0000
Re: Are there different programming languages that are compiled to the same intermediate language? Thomas Koenig <tkoenig@netcologne.de> - 2023-01-29 22:14 +0000
Re: Are there different programming languages that are compiled to the same intermediate language? arnold@freefriends.org (Aharon Robbins) - 2023-01-30 08:03 +0000
Re: Are there different programming languages that are compiled to the same intermediate language? William Fahle <billfahle@gmail.com> - 2023-01-30 02:00 -0800
Re: Are there different programming languages that are compiled to the same intermediate language? Roger L Costello <costello@mitre.org> - 2023-01-30 14:36 +0000
Re: Are there different programming languages that are compiled to the same intermediate language? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-01-30 17:36 +0000
Re: Are there different programming languages that are compiled to the same intermediate language? gah4 <gah4@u.washington.edu> - 2023-01-31 22:59 -0800
Re: Are there different programming languages that are compiled to the same intermediate language? gah4 <gah4@u.washington.edu> - 2023-02-02 16:24 -0800
Re: Are there different programming languages that are compiled to the same intermediate language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2023-02-03 11:44 +0000
Re: OoO, VLIW, Are there different programming languages that are compiled to the same intermediate language? gah4 <gah4@u.washington.edu> - 2023-02-03 19:13 -0800
Re: OoO, VLIW, Are there different programming languages that are compiled to the same intermediate language? gah4 <gah4@u.washington.edu> - 2023-02-04 02:55 -0800
Re: OoO, VLIW, Are there different programming languages that are compiled to the same intermediate language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2023-02-07 08:35 +0000
Re: OoO, VLIW, Are there different programming languages that are compiled to the same intermediate language? gah4 <gah4@u.washington.edu> - 2023-02-08 01:04 -0800
csiph-web