Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need: ANSI C to p-code compiler

97 views
Skip to first unread message

Vijay Chand

unread,
Oct 26, 2000, 2:46:44 AM10/26/00
to
Are there any free ANSI C compiler implementation (source) which
generates some explicit intermediate code for simple stack machine?
(or can be easily tailored to do that).

No code generation besides that is required, nor _any_ optimizations
(besides may be simple constant pasting in expression trees).

the compiler is about to be used for embedding into applications
(maybe java or something else. So size is much more important than
speed).

thanks in advance.

Derek M Jones

unread,
Oct 31, 2000, 2:34:11 PM10/31/00
to
Vijay,

>Are there any free ANSI C compiler implementation (source) which
>generates some explicit intermediate code for simple stack machine?
>(or can be easily tailored to do that).

I don't know of any free ones. Ours costs real money.

>No code generation besides that is required, nor _any_ optimizations
>(besides may be simple constant pasting in expression trees).

We originally did no optimizations. But then silly things like
adding zero to an address to get the addres sof the first member of a
struct started to look like cutting our nose off to spite our face.
So some 'obvious' optimizations were done.

Hmm, what is simple constant foloding? We don't do any except in
contexts required by the standard. It means that the semantics are
guaranteed to be identical to the same values occurring in operands
that are objects.

>the compiler is about to be used for embedding into applications
>(maybe java or something else. So size is much more important than
>speed).

The compiler source is 49k lines. lcc is about the same size (but excludes
a preprocessor).

Targeting the JVM? Quiet hard to do since you need to rely on undefined
behaviour (accessing arrays with types different from when they were
allocated).

Chris Fraser

unread,
Nov 22, 2000, 3:00:00 AM11/22/00
to
You might consider the "bytecode" back end that's now part of the lcc
distri bution (http://www.cs.princeton.edu/software/lcc/). It's a
straight-forward postfix encoding of the lcc IR, which is documented
in the lcc book (Chapter 5) and at the
http://www.cs.princeton.edu/software/lcc/pkg/doc/4.html.

The encoding is not particularly compact, but it serves as a good
source of fodder for compressors. Indeed, bytecode.c is the basis for
the emitters that I've used for several recent compression projects.

Chris Fraser


"Vijay Chand" <vch...@cs.man.ac.uk> wrote in message news:00-1...@comp.com
pilers...

0 new messages