This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC porting questions
- From: Ian Lance Taylor <iant at google dot com>
- To: "Radu Hobincu" <radu dot hobincu at arh dot pub dot ro>
- Cc: gcc at gcc dot gnu dot org, "Petronela Agache" <petronela dot silvia at gmail dot com>
- Date: Thu, 10 Jun 2010 10:20:56 -0700
- Subject: Re: GCC porting questions
- References: <38232.141.85.94.100.1276182650.squirrel@www.arh.pub.ro>
"Radu Hobincu" <radu.hobincu@arh.pub.ro> writes:
> I have written here a few weeks ago regarding some tutorials on GCC
> porting and got some very interesting replies. However, I seem to have
> gotten stuck with a couple of issues in spite of my massive Googling, and
> I was wondering if anyone could spare a couple of minutes for some
> clarifications.
>
> I am having troubles with the condition codes (cc_status). I have looked
> over a couple of architectures and I do not seem to understand how they
> work.
>
> The machine I am porting GCC for has 1 4bit status register for carry,
> zero, less than and equal. I do not have explicit comparison instructions,
> all of the ALU instructions modify one or more flags.
>
> What I figured out so far looking over AVR and Cris machine descriptions
> is that each instruction that modifies the flags contain an attr
> declaration which specify what flags it is changing. Also, there is a
> macro called NOTICE_UPDATE_CC which sets up the cc_status accordingly by
> reading this attr. This is the part of the code I do not understand. There
> are certain functions for which I could not find any descriptions, like
> "single_set" and macros like "SET_DEST" and "SET_SRC". Also, looking over
> conditions.h, I see that the CC_STATUS structure contains 2 rtx fields:
> "value1" and "value2", and also an int called "flags". What do they
> represent? Is "flags" the contents of the machine's flag register?
For a new port I recommend that you avoid cc0, cc_status, and
NOTICE_UPDATE_CC. Instead, model the condition codes as 1 or 4
pseudo-registers. In your define_insn statements, include SET
expressions which show how the condition code is updated. This is how
the i386 backend works; see uses of FLAGS_REG in i386.md.
As far as things like single_set, SET_DEST, and SET_SRC, you have
reached the limits of the internal documentation. You have to open
the source code and look at the comments. Similarly, the description
of the CC_STATUS fields may be found in the comments above the
definition of CC_STATUS in conditions.h.
Ian