RE: Machine description and code generation

2014-11-26 Thread Mathias Roslund
> From: gcc-ow...@gcc.gnu.org [mailto:gcc-ow...@gcc.gnu.org] On Behalf Of
> Jeff Law
> Sent: Wednesday, October 29, 2014 9:36 PM
> To: Mathias Roslund; gcc@gcc.gnu.org
> Subject: Re: Machine description and code generation
> 
> On 10/29/14 07:40, Mathias Roslund wrote:
> > Hello,
> >
> > I'm considering attempting a 65816 target but decided it would be a
> > good idea to start with something simple in order to learn how GCC
> > generate code. So I created a minimal machine description with just
> > two instructions (plus the mandatory nop/jump/etc):
> That's ambitious, primarily because something like the 65816's register
file
> does not map well to the types of register files GCC typically works with.
You
> may end up having to do something similar to the virtual registers on the
rl78
> port.

That is/was the plan. I actually took the easy route a while back and create
a MIPS to 65816 recompiler. Works quite well. It wasn't until I started
messing around with tracking register usage and sizes in order to improve
the recompiler that I figured it would be better to attempt a 65816 target
for GCC instead. So I'm basically treating the 65816 as if it were a weird
MIPS like CPU with few instructions, a lot of registers, byte/word
operations and memory to memory operations.

> > What's so special about the first entry in an array that causes this?
> > I have a feeling I'm missing something obvious here :-)
> The best thing to do is to start looking at the various debugging dumps.
>   Probably the most interesting would be the .expand dump which shows
> things as you move from the higher level GIMPLE IL into the initial RTL
IL.  The
> GIMPLE IL will look at lot like C code and should have a form similar to
the
> original input.  The RTL will roughly correspond to instructions.
> 
>  From there you'll either work forward or backwards into gimple or the RTL
> codepaths depending on what your initial analysis shows.

Thanks for the hint. I added the "-da" when compiling and option and had a
look at the output. Was quite interesting and confusing :-) Turned out my
issues were related to costs after all. After implementing TARGET_RTX_COSTS
things started to make a lot more sense.

Since then I've added more instructions and gotten to the point where most
stuff seems to be working. My current issue is that signed divide and all
shift operations insists on sign/zero extending the operands, resulting in
32bit operations even when only 8bit ones would be required. Interestingly,
multiplies and unsigned divides behave as desired, i.e. only operate on the
required number of bits.

Example:

unsigned char data[3];

data[2] = data[0] / data[1];

Is expanded as:

unsigned char _2;
unsigned char _3;
unsigned char _4;
_2 = data[0];
_3 = data[1];
_4 = _2 / _3;
data[2] = _4;

While:

signed char data[3];

data[2] = data[0] / data[1];

Is expanded as:

signed char _4;
int _5;
signed char _6;
int _7;
int _8;
signed char _9;
_4 = data[0];
_5 = (int) _4;
_6 = data[1];
_7 = (int) _6;
_8 = _5 / _7;
_9 = (signed char) _8;
data[2] = _9;

And I really have no idea why the sign extension/truncation does take place
or how to avoid it.

Best regards,

Mathias Roslund




Re: Machine description and code generation

2014-11-26 Thread Joern Rennecke
On 26 November 2014 at 16:48, Mathias Roslund  wrote:
> Since then I've added more instructions and gotten to the point where most
> stuff seems to be working. My current issue is that signed divide and all
> shift operations insists on sign/zero extending the operands, resulting in
> 32bit operations even when only 8bit ones would be required.

That's a matter of the input language.  In C, you get default promotions to
int from narrower integer types.

> Interestingly,
> multiplies and unsigned divides behave as desired, i.e. only operate on the
> required number of bits.

That's because the results are the same regardless, and the optimizers
are able to undo the effects of the type promotions.


David Malcolm as JIT subsystem maintainer

2014-11-26 Thread Jeff Law


I'm pleased to announce that David Malcolm been appointed as maintainer 
for the GCC JIT subsystem.


David, please add yourself as the maintainer for that code in the 
MAINTAINERS file.  I believe you have some patches to review and approve ;-)




Thanks for your patience,


Jeff


gcc-4.9-20141126 is now available

2014-11-26 Thread gccadmin
Snapshot gcc-4.9-20141126 is now available on
  ftp://gcc.gnu.org/pub/gcc/snapshots/4.9-20141126/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 4.9 SVN branch
with the following options: svn://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch 
revision 218104

You'll find:

 gcc-4.9-20141126.tar.bz2 Complete GCC

  MD5=c97670d09b7da5cc3929858271f6a5aa
  SHA1=e1da80aeee3a6ad113f222d35a1d60ad726aaf54

Diffs from 4.9-20141119 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-4.9
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.


Getting a build failure in glibc due to gcc changes on 32bit x86 glibc

2014-11-26 Thread Andrew Pinski
Hi all,
  I am getting the following failure on the 32bit x86 glibc with the
top of the trunk gcc 5.0 and glibc from the commit
(e5e0d9a4f632735cf3bb440eecb5caee5eea44c1).  While building
dl-load.os:
/tmp/ccRtDgmR.s: Assembler messages:
/tmp/ccRtDgmR.s:9498: Error: symbol `__x86.get_pc_thunk.cx' is already defined

The problem is GCC no longer uses a fixed register for the PIC
register so in this case GCC uses ecx for the PIC register.

This looks like the same issue as I reported before about
check_consistency() since that is what is failing to assemble here
too.

Thanks,
Andrew Pinski


Re: Getting a build failure in glibc due to gcc changes on 32bit x86 glibc

2014-11-26 Thread Siddhesh Poyarekar
On Wed, Nov 26, 2014 at 02:59:34PM -0800, Andrew Pinski wrote:
> Hi all,
>   I am getting the following failure on the 32bit x86 glibc with the
> top of the trunk gcc 5.0 and glibc from the commit
> (e5e0d9a4f632735cf3bb440eecb5caee5eea44c1).  While building

Is that the right commit?

Siddhesh


pgpZ9Nj6Pu3IU.pgp
Description: PGP signature