gnupic: Re: [gnupic] What About GCC and PIC's
Subject:
Re: [gnupic] What About GCC and PIC's
From:
Scott Dattalo ####@####.####
Date:
18 Apr 2005 21:20:54 +0100
Message-Id: <4264168D.5040901@dattalo.com>
Shaun wrote:
> The current effort to make an open-source C compiler for the PIC is here
> http://sdcc.sourceforge.net/ (Small Device C Compiler)
> I don't know what state it's in as I'm downloading it at the moment.
>
> I think a PIC targetted GCC was tried once but quickly stagnated
> although I can't seem to find any reference to it now so maybe I
> imagined it.
Shaun,
I was the one that started the SDCC port to the PIC. However, I haven't
worked on it for quite some time - Vangelis has done most of the work
recently.
When starting the project, I looked at both SDCC and gcc. I chose SDCC
because quite frankly it was easier for me to follow the code. At the
time (around 2000 - 2001), the avr gcc port was being developed and one
strategy could have been to use it as a starting point for PICs. In
addition, it wasn't obvious to me at the time that one could use another
assembler (like gpasm) instead of gas. Similarly, I didn't feel like
dealing with the new object file formats for the simulator... So, the
complexity of gcc coupled with the fear of having to write assembler and
simulator infrastructure tools steered me away.
But looking back now, I have some new insight (or hind sight). I've seen
two more examples of small micro's becoming gcc targets. The first is
the dsPic family the other is a custom processor for my employer. It
turns out that a first cut pass at adding a new target is not as bad as
I had first thought. gcc's overall system optimizer is more
sophisticated than SDCC's. gcc is a multipass compiler. Each pass is
more or less heirarchical. One of these stages involves optimizing using
the target description. In SDCC I wrote a bunch code/infrastructure to
(poorly) implement this stage. But in gcc, it possible to describe
assembly instructions and things like the bits of the status registers
in terms of gcc RTL (Register Transfer Language) constructs. Once this
is done, then gcc's infrastructure can perform its magic!
Scott