This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Minimal machine description file
- From: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>
- To: "Roger.Gough" <Roger dot Gough at ul dot ie>, "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Date: Fri, 2 May 2003 13:04:25 +0200
- Subject: Re: Minimal machine description file
- References: <0B2F845E9599D611A6FA00B0D0D1DE4AA431C4@exch-staff4.ul.ie>
> I have managed to modify my configure scripts so that gcc recognizes my new
> target (called "npe"). Thanks to Alex Courbot for his help here.
> My next challenge is to write my machine description files. Scrolling
> through the gcc archives, I realised that many people have been looking for
> the minimal characteristics to achieve a functioning port of gcc. I was
> wondering if anybody had achieved this and if so where would I find it
> documented?
The GCC Internals manual has a detailled description of the macros that take
place in target.h chapter 10. It is said when a macro is optional, so I'd
advice you to go through this chapter (or rather, go through the entire
manual to get a good overview of the compiler first) and start implementing
the macros you need and those which are mandatory. Then, chapter 9 has a
description of all the instructions names you can use to match your RTL
templates. The most obviously needed being moving instructions, some basic
arithmetic, extension, jumping, calling. Chapter 8 and 9 are *very* important
for this part.
> If not, would anybody recommend some target files for a similar
> architecture to mine. y intention would then be to modify these files to
> accomodate my architecture.
In my experience I have started my port completely from scratch. Having a look
at some description files of architectures I knew were useful, but I haven't
started with a modified version of some other arch. My architecture is quite
particular however, so your mileage may vary. Anyway, starting a first port
is something I've found very difficult, but perseverance do pay. Now that you
have the configure stuff working, don't dive into coding. Read the manual
carefully, make sure you understand the Parse tree/RTL generation/RTL
matching stuff. Then, start writing your target.h file the following way:
order your macros in the same order as they are in the manual, and copy their
documentation into comments above each of them. Then write a basic target.md
and target.c. You won't be able to compile gcc before you get these files
written in their minimal form. So your goal should be to get something that
compiles, then something that runs without segfaulting even if it doesn't
produce something useful. Once you have a basic skeleton, start writing your
macros the right way. I don't know whether a skeleton architecture (something
that compiles and run, but doesn't produce anything), heavily commented,
could be doable/useful considering how much architectures are different.
Like, putting in gcc/config a 'dummy' directory which doesn't compile
anything useful but makes a sane basis for newporters. Maybe I can submit it
in this case, if I can find my earlier work. I remember I had needed one
whole month (plus several stupid questions here) to get my first successful
compilation.
Alex.