Re: RFA: MN10300: Fix building libstdc++-v3

2014-02-04 Thread nick clifton

Hi Jeff,


But how/why did an extended register get selected to begin with?


It happens in reload.c:find_valid_class().


HARD_REGNO_MODE_OK and other macros/hooks ought to be preventing this
relatively early.


Ah - and that is the problem.  mn10300_hard_regno_mode_ok is allowing 
extended registers to match some classes even in MN10300.


So how about the patch below ?  This also allows the libstdc++-v3 
library to be built.


Cheers
  Nick

gcc/ChangeLog
2014-02-04  Nick Clifton  ni...@redhat.com

* config/mn10300/mn10300.c (mn10300_hard_regno_mode_ok): Do not
accept extended registers in any mode when compiling for the
MN10300.



Index: gcc/config/mn10300/mn10300.c
===
--- gcc/config/mn10300/mn10300.c(revision 207452)
+++ gcc/config/mn10300/mn10300.c(working copy)
@@ -2614,7 +2612,10 @@
   || REGNO_REG_CLASS (regno) == FP_ACC_REGS)
 /* Do not store integer values in FP registers.  */
 return GET_MODE_CLASS (mode) == MODE_FLOAT  ((regno  1) == 0);
-
+
+  if (! TARGET_AM33  REGNO_REG_CLASS (regno) == EXTENDED_REGS)
+return false;
+
   if (((regno)  1) == 0 || GET_MODE_SIZE (mode) == 4)
 return true;




Re: RFA: MN10300: Fix building libstdc++-v3

2014-02-04 Thread Jeff Law

On 02/04/14 10:45, nick clifton wrote:

Hi Jeff,


But how/why did an extended register get selected to begin with?


It happens in reload.c:find_valid_class().


HARD_REGNO_MODE_OK and other macros/hooks ought to be preventing this
relatively early.


Ah - and that is the problem.  mn10300_hard_regno_mode_ok is allowing
extended registers to match some classes even in MN10300.

So how about the patch below ?  This also allows the libstdc++-v3
library to be built.

Cheers
   Nick

gcc/ChangeLog
2014-02-04  Nick Clifton  ni...@redhat.com

 * config/mn10300/mn10300.c (mn10300_hard_regno_mode_ok): Do not
 accept extended registers in any mode when compiling for the
 MN10300.
This is fine.  I'm assuming that insn predicate checks prevent similar 
situations from occurring with FP_REGS  FP_ACC_REGS.  ie, patterns with 
constraints which allow those registers are conditional on TARGET_AM33.


Jeff



Re: RFA: MN10300: Fix building libstdc++-v3

2014-02-03 Thread Jeff Law

On 02/03/14 10:11, Nick Clifton wrote:

Hi Jeff, Hi Alex,

   Currently the mainline MN10300 toolchain does not build the
   libstdc++-v3 library because:

 /libstdc++-v3/include/bits/locale_facets_nonio.tcc:1213:5:
 error: unable to find a register to spill in class 'EXTENDED_REGS'

 
mn10300-elf/mn10300-elf/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1213:5:
 internal compiler error: in spill_failure, at reload1.c:2106

   Of course the MN10300 does not have any extended registers, so it is
   not surprising that reload cannot find any to spill.  The reason why
   reload thinks that it can use the EXTENDED_REGS class however is the
   mn10300_register_move_cost() function which tells it that it only costs
   2 to move via those registers.  Hence the patch below.

   With the patch applied the libstdc++-v3 library now builds.  OK to
   apply ?

gcc/ChangeLog
2014-02-03  Nick Clifton  ni...@redhat.com

* config/mn10300/mn10300.c (mn10300_register_move_cost): Prevent
moves via extended registers in MN10300 mode.
But how/why did an extended register get selected to begin with? 
HARD_REGNO_MODE_OK and other macros/hooks ought to be preventing this 
relatively early.


Twiddling costs just seems to be papering over some deeper issue.

jeff


RFA: MN10300: Fix building libstdc++-v3

2014-02-03 Thread Nick Clifton
Hi Jeff, Hi Alex,

  Currently the mainline MN10300 toolchain does not build the
  libstdc++-v3 library because:

/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1213:5:
error: unable to find a register to spill in class 'EXTENDED_REGS'


mn10300-elf/mn10300-elf/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1213:5:
internal compiler error: in spill_failure, at reload1.c:2106

  Of course the MN10300 does not have any extended registers, so it is
  not surprising that reload cannot find any to spill.  The reason why
  reload thinks that it can use the EXTENDED_REGS class however is the
  mn10300_register_move_cost() function which tells it that it only costs
  2 to move via those registers.  Hence the patch below.

  With the patch applied the libstdc++-v3 library now builds.  OK to
  apply ?

gcc/ChangeLog
2014-02-03  Nick Clifton  ni...@redhat.com

* config/mn10300/mn10300.c (mn10300_register_move_cost): Prevent
moves via extended registers in MN10300 mode.

Index: gcc/config/mn10300/mn10300.c
===
--- gcc/config/mn10300/mn10300.c(revision 207416)
+++ gcc/config/mn10300/mn10300.c(working copy)
@@ -2216,6 +2214,11 @@
   enum reg_class to = (enum reg_class) ito;
   enum reg_class scratch, test;
 
+  /* Make sure that moves via the extended register class
+ are too expensive to ever be chosen for the MN10300.  */
+  if (! TARGET_AM33  (ifrom == EXTENDED_REGS || ito == EXTENDED_REGS))
+return 100;
+
   /* Simplify the following code by unifying the fp register classes.  */
   if (to == FP_ACC_REGS)
 to = FP_REGS;