Re: [Patch,AVR] Fix PR51345: split multilibs for SPH / no-SPH devices, Take #2

2011-12-25 Thread Denis Chertykov
2011/12/19 Georg-Johann Lay :
> Joseph S. Myers wrote:
>> On Sun, 18 Dec 2011, Georg-Johann Lay wrote:
>>
 This new file needs to have the standard copyright and license notices.
 It's desirable to generate such notices in the output files as well.
>>> What is the right copyright for the generated files?
>>
>> See other examples.
>
> There is more than one flavour if the license... From what you wrote it's okay
> to use GPL in all cases even if included libgcc, so I used that text.
>
> Besides printing license, there are two minor changes compared to the original
> patch:
>
> * lib1funcs.S defines macro SPEED_DIV that trades speed against code size.
>  It uses __AVR_HAVE_8BIT_SP__ now to get better estimation of flash size.
>
> * avr-c.c use AVR_HAVE_8BIT_SP instead of avr_current_device->short_sp to
>  define respective built-in macros __AVR_HAVE_8/16BIT_SP__.
>
> Ok?
>
> Johann
>
> contrib/
>        PR target/51345
>        * gcc_update (files_and_dependencies): Add
>        gcc/config/avr/t-multilib, gcc/config/avr/multilib.h.
>
> libgcc/
>        PR target/51345
>        * config/avr/lib1funcs.S: Remove FIXME comments.
>        (SPEED_DIV): Depend on __AVR_HAVE_8BIT_SP__.
> gcc/
>        PR target/51345
>        * config.gcc (tm_file target=avr]): Add avr/avr-multilib.h
>        (tmake_file target=avr): Add avr/t-multilib.
>
>        * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use AVR_HAVE_8BIT_SP
>        to built-in define __AVR_HAVE_8BIT_SP__, __AVR_HAVE_16BIT_SP__.
>        * config/avr/genmultilib.awk: New file.
>        * config/avr/t-multilib: New auto-generated file.
>        * config/avr/multilib.h: New auto-generated file.
>        * config/avr/t-avr (AVR_MCUS): New variable.
>        (genopt.sh): Use it.
>        (s-mlib): Depend on t-multilib.
>        (t-multilib, multilib.h): New dependencies.
>        (s-avr-mlib): New rule to build t-multilib, multilib.h from AVR_MCUS.
>        (MULTILIB_OPTIONS): Remove.
>        (MULTILIB_MATCHES): Remove.
>        (MULTILIB_DIRNAMES): Remove.
>        (MULTILIB_EXCEPTIONS): Remove:
>        * config/avr/genopt.sh: Don't use hard coded file name;
>        pass AVR_MCUS from t-avr instead.
>

Approved.

Denis.


Re: Ping #2: [Patch,AVR] Light-weight DImode implementation.

2011-12-25 Thread Denis Chertykov
2011/12/15 Georg-Johann Lay :
> http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00471.html
>
> Georg-Johann Lay wrote:
>> Georg-Johann Lay wrote:
>>> Denis Chertykov wrote:
>>>
>>> The only question that remains is what the -m64 option should be like?
>>>
>>> [ ] Omit it altogether
>>> [ ] Leave it as is (off per default)
>>> [ ] Set it on per default
>>>
>>> As soon as the direction is clear, I'll post a follow-up patch to
>>> add the missing bits like, e.g., documentation for the new switch.
>> I'll leave the decision to Denis, but I'm for omitting it.
> I will also defer to Denis, but I'd rather avoid having another option,
> if we can. Keep it simple for the users.
>>> It might also be a hidden option like -morder2 and on per default.
>>> Such thing is nice for developers to play :-)
>>>
 I'm agree with Richard. I'm for omitting it.
 Denis.
>>
>> Here is a combined patch if that is more convenient for review.
>>
>> The variable avr_have_dimode that was originally set in avr.opt is still 
>> there
>> but always set to true in avr.c. Option -m64 is omitted and thus avr.opt is
>> unchanged.
>>
>> Passed without regressions.
>>
>> Ok?
>>
>> Johann
>>
>> gcc/
>>       * config/avr/avr-dimode.md: New file.
>>       * config/avr/avr.md: Include it.
>>       (adjust_len): Add alternatives: plus64, compare64.
>>       (HIDI): Remove code iterator.
>>       (code_stdname): New code attribute.
>>       (rotx, rotsmode): Remove DI from interators.
>>       (rotl3, *rotw, *rotb): Use HISI instead of HIDI
>>       as code iterator.
>>       * config/avr/avr-protos.h (avr_have_dimode): New.
>>       (avr_out_plus64, avr_out_compare64): New.
>>       * config/avr/avr.c (avr_out_compare): Handle DImode.
>>       (avr_have_dimode): New variable definition and initialization.
>>       (avr_out_compare64, avr_out_plus64): New functions.
>>       (avr_out_plus_1): Use simplify_unary_operation to negate xval.
>>       (adjust_insn_length): Handle ADJUST_LEN_COMPARE64, ADJUST_LEN_PLUS64.
>>       (avr_compare_pattern): Skip DImode comparisons.
>>
>> libgcc/
>>       * config/avr/t-avr (LIB1ASMFUNCS): Add _adddi3, _adddi3_s8,
>>       _subdi3, _cmpdi2, _cmpdi2_s8, _rotldi3.
>>       * config/avr/lib1funcs.S (__adddi3, __adddi3_s8, __subdi3,
>>       __cmpdi2, __cmpdi2_s8, __rotldi3): New functions.
>>
>

Approved.

Denis.


Re: [patch] Flag-controlled type conversions/promotions

2011-12-25 Thread Steve Kargl
On Wed, Nov 09, 2011 at 06:09:58PM -0500, Andreas Kloeckner wrote:
> 
> please find attached the patch and the Changelog entry for our work on
> the fortran bug #48426.
> 
> The attached patch implements the options
> 
> -finteger-4-integer-8
> -freal-4-real-8
> -freal-4-real-10
> -freal-4-real-16
> -freal-8-real-4
> -freal-8-real-10
> -freal-8-real-16
> 
> to implement a variety of automatic type promotions.  (This is
> particularly helpful if one wants to quickly check whether a
> certain code has a bug limiting its precision away from full
> machine accuracy.)
> 
> A similar promotion feature is available in Fujitsu compilers, see here:
> 
> http://www.lahey.com/docs/fujitsu%20compiler%20option%20list.pdf
> 
> (e.g. -CcR8R16)
> 
> The implementation work on this was done by Zydrunas Gimbutas, not by me.
> Zydrunas has authorized me to submit this for inclusion in gcc. Both he
> and I have gone through the FSF's copyright assignment process and have
> current papers for that on file.
> 
> We tested the change by running Kahan's Fortran paranoia tests using all
> supported conversions, we ran the LINPACK tests (at all supported
> conversions) as well as a number of manually-written conversion tests.
> 

All, 

I have taken Zydrunas and Andreas patche applied it to my tree,
updated for it GNU Coding Style, and written the gfortran manual
entries.  The ChangeLog is
 
2011-12-25  Zydrunas Gimbutas  
Andreas Kloeckner  
Steven G. Kargl  

PR fortran/48426
* gfortran.h: Make global variables flag_*_kind to store
* lang.opt: Add options -freal-4-real-8, -freal-4-real-10,
-freal-4-real-16, -freal-8-real-4, -freal-8-real-10, -freal-8-real-16
and -finteger-4-integer-8.
user-desired type conversion information.
* decl.c (gfc_match_old_kind_spec,kind_expr): Type conversions
in declaration parsing.
* trans-types.c (gfc_init_kinds): User-specified type conversion
checked for current backend.
* primary.c (match_integer_constant,match_real_constant): Implement
type conversion in constant parsing.
* options.c (gfc_init_options,gfc_handle_option): Translate input
options to flags in internal options data structure.
* invoke.texi: Document new options.  Re-order options in Options
summary section.

I regression tested the patch on i686-*-freebsd.  No problems occurred.
Can one of the other gfortran reviewers/committers cast a quick glance
over the patch.  I would like to commit this within next day or two.

OK for trunk?

-- 
Steve
Index: decl.c
===
--- decl.c	(revision 182680)
+++ decl.c	(working copy)
@@ -2101,6 +2101,33 @@ gfc_match_old_kind_spec (gfc_typespec *t
 	  return MATCH_ERROR;
 	}
   ts->kind /= 2;
+
+}
+
+  if (ts->type == BT_INTEGER && ts->kind == 4 && gfc_option.flag_integer4_kind == 8)
+ts->kind = 8;
+
+  if (ts->type == BT_REAL || ts->type == BT_COMPLEX)
+{
+  if (ts->kind == 4)
+	{
+	  if (gfc_option.flag_real4_kind == 8)
+	ts->kind =  8;
+	  if (gfc_option.flag_real4_kind == 10)
+	ts->kind = 10;
+	  if (gfc_option.flag_real4_kind == 16)
+	ts->kind = 16;
+	}
+
+  if (ts->kind == 8)
+	{
+	  if (gfc_option.flag_real8_kind == 4)
+	ts->kind = 4;
+	  if (gfc_option.flag_real8_kind == 10)
+	ts->kind = 10;
+	  if (gfc_option.flag_real8_kind == 16)
+	ts->kind = 16;
+	}
 }
 
   if (gfc_validate_kind (ts->type, ts->kind, true) < 0)
@@ -2246,7 +2273,33 @@ kind_expr:
 
   if(m == MATCH_ERROR)
  gfc_current_locus = where;
-  
+
+  if (ts->type == BT_INTEGER && ts->kind == 4 && gfc_option.flag_integer4_kind == 8)
+ts->kind =  8;
+
+  if (ts->type == BT_REAL || ts->type == BT_COMPLEX)
+{
+  if (ts->kind == 4)
+	{
+	  if (gfc_option.flag_real4_kind == 8)
+	ts->kind =  8;
+	  if (gfc_option.flag_real4_kind == 10)
+	ts->kind = 10;
+	  if (gfc_option.flag_real4_kind == 16)
+	ts->kind = 16;
+	}
+
+  if (ts->kind == 8)
+	{
+	  if (gfc_option.flag_real8_kind == 4)
+	ts->kind = 4;
+	  if (gfc_option.flag_real8_kind == 10)
+	ts->kind = 10;
+	  if (gfc_option.flag_real8_kind == 16)
+	ts->kind = 16;
+	}
+}
+
   /* Return what we know from the test(s).  */
   return m;
 
Index: trans-types.c
===
--- trans-types.c	(revision 182680)
+++ trans-types.c	(working copy)
@@ -362,7 +362,7 @@ gfc_init_kinds (void)
   unsigned int mode;
   int i_index, r_index, kind;
   bool saw_i4 = false, saw_i8 = false;
-  bool saw_r4 = false, saw_r8 = false, saw_r16 = false;
+  bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false;
 
   for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT; mode++)
 {
@@ -456,6 +456,8 @@ gfc_init_kinds (void)
 	saw_r4 = true;
   if (kind == 8)
 	saw_r8 = true;
+  if (kind == 10)
+	saw_r10 = true;
   if (kind ==