The main part of getting avr to work was changing the type used to handle the insert_bits mask, which went into mainline first. This just mops up a couple of other problems.
The first two hunks are from still using double_int for fixed-point. Tested by comparing avr-rtems between the branch and merge point. The only differences in gcc.dg, g++.dg or gcc.c-torture -O2 output was in gcc.dg/fixed-point/const-1.c, which IMO is a bug fix. (Will say more about the comparison later.) OK to install? Thanks, Richard Index: gcc/config/avr/avr.c =================================================================== --- gcc/config/avr/avr.c 2013-11-05 13:06:54.127234867 +0000 +++ gcc/config/avr/avr.c 2013-11-05 13:20:04.832627661 +0000 @@ -7546,6 +7546,8 @@ avr_out_round (rtx insn ATTRIBUTE_UNUSED // The smallest fractional bit not cleared by the rounding is 2^(-RP). int fbit = (int) GET_MODE_FBIT (mode); double_int i_add = double_int_zero.set_bit (fbit-1 - INTVAL (xop[2])); + wide_int wi_add = wi::set_bit_in_zero (fbit-1 - INTVAL (xop[2]), + GET_MODE_PRECISION (imode)); // Lengths of PLUS and AND parts. int len_add = 0, *plen_add = plen ? &len_add : NULL; int len_and = 0, *plen_and = plen ? &len_and : NULL; @@ -7575,7 +7577,7 @@ avr_out_round (rtx insn ATTRIBUTE_UNUSED // Rounding point ^^^^^^^ // Added above ^^^^^^^^^ rtx xreg = simplify_gen_subreg (imode, xop[0], mode, 0); - rtx xmask = immed_double_int_const (-i_add - i_add, imode); + rtx xmask = immed_wide_int_const (-wi_add - wi_add, imode); xpattern = gen_rtx_SET (VOIDmode, xreg, gen_rtx_AND (imode, xreg, xmask)); @@ -12226,8 +12228,8 @@ avr_fold_builtin (tree fndecl, int n_arg break; } - tmap = wide_int_to_tree (map_type, widest_int (arg[0])); - map = TREE_INT_CST_LOW (tmap); + tmap = wide_int_to_tree (map_type, arg[0]); + map = tree_to_uhwi (tmap); if (TREE_CODE (tval) != INTEGER_CST && 0 == avr_map_metric (map, MAP_MASK_PREIMAGE_F)) @@ -12331,8 +12333,7 @@ avr_fold_builtin (tree fndecl, int n_arg /* Use map o G^-1 instead of original map to undo the effect of G. */ - tmap = wide_int_to_tree (map_type, - widest_int (best_g.map)); + tmap = wide_int_to_tree (map_type, best_g.map); return build_call_expr (fndecl, 3, tmap, tbits, tval); } /* AVR_BUILTIN_INSERT_BITS */