This is the mail archive of the
mailing list for the GCC project.
Re: [RL78] Questions about code-generation
- From: DJ Delorie <dj at redhat dot com>
- To: peper03 at yahoo dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 10 Mar 2014 17:37:13 -0400
- Subject: Re: [RL78] Questions about code-generation
- Authentication-results: sourceware.org; auth=none
- References: <1394465260 dot 82407 dot YahooMailNeo at web125603 dot mail dot ne1 dot yahoo dot com>
> I've managed to build GCC myself so that I could experiment a bit
> but as this is my first foray into compiler internals, I'm
> struggling to work out how things fit together and what affects
The key thing to know about the RL78 backend, is that it has two
"targets" it uses. For the first part of the compilation, up until
after reload, the model uses 16 virtual registers (R8 through R15) and
a virtual machine to give gcc an orthogonal model that it can generate
code for. After reload, there's a "devirtualization" pass in the RL78
backend that maps the virtual model to the real model (R0 through R7),
which means copying values in and out of the real registers according
to which addressing modes are needed. Then GCC continues optimizing,
which gets rid of most of the unneeded instructions.
The problem you're probably running into is that deciding which real
registers to use for each virtual one is a very tricky task, and the
post-reload optimizers aren't expecing the code to look like what it
> What causes that code to be generated when using a variable instead
> of a fixed memory address?
The use of "volatile" disables many of GCC's optimizations. I
consider this a bug in GCC, but at the moment it needs to be "fixed"
in the backends on a case-by-case basis.