A C compiler written in C targeting C

dg@tao.co.uk (David Given)
23 Mar 1999 00:31:55 -0500

          From comp.compilers

Related articles
A C compiler written in C targeting C dg@tao.co.uk (1999-03-23)
Re: A C compiler written in C targeting C mikee@cetasoft.cog (1999-03-28)
Re: A C compiler written in C targeting C kadhim@lucent.com (Basim Kadhim) (1999-03-28)
Re: A C compiler written in C targeting C nshaf@intur.net (Nick Shaffner) (1999-03-28)
Re: A C compiler written in C targeting C dmk42@my-dejanews.com (1999-03-28)
Re: A C compiler written in C targeting C derek@knosof.co.uk (1999-03-28)
Re: A C compiler written in C targeting C eclectictech@usa.net (1999-03-28)
[3 later articles]
| List of all articles for this month |

From: dg@tao.co.uk (David Given)
Newsgroups: comp.compilers
Date: 23 Mar 1999 00:31:55 -0500
Organization: I'm organised? Wow!
Keywords: C, question, comment

Yes, I know it's an odd request.


I have an operating system with strange memory semantics (GEOS, if
you're interested). Blocks of memory may move at any time unless
locked down. You're not supposed to leave blocks locked. You refer to
blocks by their handles.


So, to read from memory, you lock the handle, which gives you a
pointer; dereference the pointer; and then unlock the handle again.


This all works very nicely except that standard ANSI C programs won't
run, because they expect fixed blocks of memory.


What I want to do is write a C compiler that changes the pointer
semantics of the program, emitting another program that I can feed
into GEOS' odd C compiler.


I'm currently playing with lcc, and have a fair amount of success; I
have a back end that generates more-or-less correct C code, and
pointer dereferences are correctly wrapped, but the output code is
still going to be dire. I can't get lcc to let me handle switch
statements, for example, and since I can't use jump tables it's going
to produce a sequence of if...goto pairs.


Are there any compilers (lcc, gcc) around that have C back ends? Are
there any type analysis tools around that can be modified to write out
the code once they've read it in (because I don't need a fully fledged
code generator)? Am I going at this in completely the wrong way?


--
+- David Given ---------------McQ-
| Work: dg@tao-group.com
| Play: dgiven@iname.com
+- http://wired.st-and.ac.uk/~dg -
[MacOS does sort of the same thing, maybe there's some hackery there. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.