🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.modula2
4 messages
4 total messages Started by Duncan C White Thu, 16 Jul 1987 16:31
Translating M2 -> C
#3713
Author: Duncan C White
Date: Thu, 16 Jul 1987 16:31
40 lines
2438 bytes
I have a proposal which I would like people to consider, and comment on:
I will outline it as a series of observations, leading to the proposal:

1).	every system worth talking about has a C compiler.

2).	often, the C compiler is heavily optimised.

3).	C is often referred to as a high-level assembler.
	What people omit is the important word 'portable'.

4).	Compilers conventionally produce assembler code.

5).	Why not bring all these together, and write a portable M2 compiler
	which generates C as it's intermediate code.  This would imply no
	tedious mucking around with new backends for different processors.
	This is the approach used by C++...

So, there is the proposal...  is the translation likely to be incredibly
difficult ?  What about processes ?  Libraries ?  Any other pitfalls I should
watch out for ?  Anyone else interested in cooperating on such a project ?
[Is it completely irrevelent, or crackpot... all suggestions considered]

Personally, I would much prefer to write such a compiler in C [on the grounds
that it then becomes easier to port the compiler to other systems]

Obviously, you'd get a free M2->C translator for the one-off conversion...

	Duncan.

-----------------------------------------------------------------------------
JANET address : dcw@uk.ac.ic.doc| Snail Mail :  Duncan White,
--------------------------------|               Dept of Computing,
  This space intentionally      |               Imperial College,
  left blank......              |               180 Queen's Gate,
  (paradoxical excerpt from     |               South Kensington,
  IBM manuals)                  |               London SW7
----------------------------------------------------------------------------
Tel: UK 01-589-5111 x 4982/4991
----------------------------------------------------------------------------
Translating M2 -> C
#3719
Author: lmjm
Date: Fri, 17 Jul 1987 18:03
57 lines
3038 bytes
   Date: 16 Jul 87 16:31:05 GMT
   From: Duncan C White <eagle!icdoc!dcw@ucbvax.berkeley.edu>
   Organization: Dept. of Computing, Imperial College, London, UK.

   1).	every system worth talking about has a C compiler.
True, true.

   2).	often, the C compiler is heavily optimised.
Not quite so true - but getting better - eg: GCC.

   3).	C is often referred to as a high-level assembler.
	   What people omit is the important word 'portable'.
Hmmmmmmmm

   4).	Compilers conventionally produce assembler code.
Most Unix compilers do anyway.

   5).	Why not bring all these together, and write a portable M2 compiler
	   which generates C as it's intermediate code.  This would imply no
	   tedious mucking around with new backends for different processors.
	   This is the approach used by C++...

When I last had to port a M2 compiler to a new machine I thought about
this.  The recent messge from Chuck Bilbe covers the problems I was
able to think of.  I instead chose a slightly different route.

Most Unix machines (not all) support a two pass C compiler commonly
called PCC (Portable C Compiler).  The second pass is the code
generator and is also used by a pascal and fortran compiler.  I took
the ETH 4 pass compiler and converted its 4th pass to output a file
suitable for PCC's code generator to use.  This means the M2 compiler is
pretty portable - so long as you have PCC on your target machine - but
dodges many of the problems going to C.  Since the machine it was
targeted for was blindingly fast I never bothered with optimisation
but I get some for free by using the standard C optimiser (which works
on the code generated by PCC).  Given the structure of the ETH
compiler adding in simple lifetime analysis is relatively straight
forward.

This is a simplified description but should give you the gist of it.
Obviously this approach is not as generally useful as Duncan's.  But
lets face it, there are a lot of Unix boxes out there now.

A idea I was toying with would be to do something similar to the above
scheme except going to the GNU optimising C compiler as this is likely
to become available on a wide range of machines.

	Lee.

--
UKUUCP SUPPORT  Lee McLoughlin
	"What you once thought was only a nightmare is now a reality!"

Janet: lmjm@uk.ac.ic.doc, lmcl@uk.ac.ukc
DARPA: lmjm@doc.ic.ac.uk (or lmjm%uk.ac.ic.doc@cs.ucl.ac.uk)
Uucp:  lmjm@icdoc.UUCP, ukc!icdoc!lmjm
Re: Translating M2 -> C
#3726
Author: Bob Pendleton
Date: Mon, 20 Jul 1987 14:31
23 lines
1574 bytes
in article <482@ivax.doc.ic.ac.uk>, dcw@doc.ic.ac.uk (Duncan C White) says:
> 
> 4).	Compilers conventionally produce assembler code.
> 
This statement is only true in the UNIX(TM) world. It still just plain blows
me away when I encounter people who have never used a compiler that didn't
generate assembly code. My experience, measurments made on assemblers I've
written and used, is that 40 to 60 percent of assembly time is lexical 
analysis. Formatting and writing assembly code in a compiler can add 10 or
more percent to compilation times, in non optimizing compilers it can be 25%.

Generating a linkable file directly is a major performance win. Why does the
UNIX world tolerate such slow compilation?

What Duncan suggests will work. But it will be sloooow.
> 
> 	Duncan.
> 
-- 
Bob Pendleton @ Evans & Sutherland
UUCP Address:  {decvax,ucbvax,ihnp4,allegra}!decwrl!esunix!bpendlet
Alternate:     {ihnp4,seismo}!utah-cs!utah-gr!uplherc!esunix!bpendlet
        I am solely responsible for what I say.
Re: Translating M2 -> C
#3733
Author: Ronald Cole
Date: Fri, 07 Aug 1987 07:55
23 lines
1621 bytes
In article <482@ivax.doc.ic.ac.uk>, dcw@doc.ic.ac.uk (Duncan C White) writes:
> 
> I have a proposal which I would like people to consider, and comment on:
> I will outline it as a series of observations, leading to the proposal:
  ...
> 5).	Why not bring all these together, and write a portable M2 compiler
> 	which generates C as it's intermediate code.

Duncan,

	I have been working on this project in my spare time for the last
year now.  My compiler is a four pass compiler implemented using yacc and
lex in C.  Translating Modula-2 to C is a lot easier than translating C
to Modula-2.  I am generating a very portable C as per J.E. Lapin's new
portable C book.  If you are interested in more information send me email.

							Ron

-- 
Ronald Cole				| uucp:     ihnp4!csun!csuchic!ronald
AT&T 3B5 System Administrator		| PhoneNet: ronald@csuchico.edu
@ the #_1_ party school in the nation:	| voice     (916) 895-4635
California State University, Chico	"It's O.K." -Hal Landon Jr., Eraserhead
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads