cppbuiltin.c (define_builtin_macros_for_type_sizes): Round pointer size up to a power of two.

* cppbuiltin.c (define_builtin_macros_for_type_sizes): Round
pointer size up to a power of two.
* defaults.h (DWARF2_ADDR_SIZE): Round up.
(POINTER_SIZE_UNITS): New, rounded up value.
* dwarf2asm.c (size_of_encoded_value): Use it.
(dw2_output_indirect_constant_1): Likewise.
* expmed.c (init_expmed_one_conv): We now know the sizes of
partial int modes.
* loop-iv.c (iv_number_of_iterations): Use precision, not size.
* optabs.c (expand_float): Use precision, not size.
(expand_fix): Likewise.
* simplify-rtx (simplify_unary_operation_1): Likewise.
* tree-dfa.c (get_ref_base_and_extent): Likewise.
* varasm.c (assemble_addr_to_section): Round up pointer sizes.
(default_assemble_integer) Likewise.
(dump_tm_clone_pairs): Likewise.
* dwarf2out.c (mem_loc_descriptor): Allow partial-int modes also.
* var-tracking.c (adjust_mems): Allow partial-int modes also.
(prepare_call_arguments): Likewise.
* stor-layout.c (finalize_type_size): Preserve precision.
(layout_type): Use precision, not size.

From-SVN: r214748
This commit is contained in:
DJ Delorie 2014-08-29 19:35:12 -04:00 committed by DJ Delorie
parent aea3d681ec
commit 50b6ee8b71
13 changed files with 87 additions and 43 deletions

View File

@ -1,5 +1,27 @@
2014-08-29 DJ Delorie <dj@redhat.com>
* cppbuiltin.c (define_builtin_macros_for_type_sizes): Round
pointer size up to a power of two.
* defaults.h (DWARF2_ADDR_SIZE): Round up.
(POINTER_SIZE_UNITS): New, rounded up value.
* dwarf2asm.c (size_of_encoded_value): Use it.
(dw2_output_indirect_constant_1): Likewise.
* expmed.c (init_expmed_one_conv): We now know the sizes of
partial int modes.
* loop-iv.c (iv_number_of_iterations): Use precision, not size.
* optabs.c (expand_float): Use precision, not size.
(expand_fix): Likewise.
* simplify-rtx (simplify_unary_operation_1): Likewise.
* tree-dfa.c (get_ref_base_and_extent): Likewise.
* varasm.c (assemble_addr_to_section): Round up pointer sizes.
(default_assemble_integer) Likewise.
(dump_tm_clone_pairs): Likewise.
* dwarf2out.c (mem_loc_descriptor): Allow partial-int modes also.
* var-tracking.c (adjust_mems): Allow partial-int modes also.
(prepare_call_arguments): Likewise.
* stor-layout.c (finalize_type_size): Preserve precision.
(layout_type): Use precision, not size.
* expr.c (convert_move): If the target has an explicit converter,
use it.

View File

@ -175,7 +175,7 @@ define_builtin_macros_for_type_sizes (cpp_reader *pfile)
/* ptr_type_node can't be used here since ptr_mode is only set when
toplev calls backend_init which is not done with -E switch. */
cpp_define_formatted (pfile, "__SIZEOF_POINTER__=%d",
POINTER_SIZE / BITS_PER_UNIT);
1 << ceil_log2 ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT));
}

View File

@ -451,7 +451,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
Dwarf 2 addresses need to be larger than the architecture's
pointers. */
#ifndef DWARF2_ADDR_SIZE
#define DWARF2_ADDR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
#define DWARF2_ADDR_SIZE ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
#endif
/* The size in bytes of a DWARF field indicating an offset or length
@ -751,6 +751,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#ifndef POINTER_SIZE
#define POINTER_SIZE BITS_PER_WORD
#endif
#ifndef POINTER_SIZE_UNITS
#define POINTER_SIZE_UNITS ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
#endif
#ifndef PIC_OFFSET_TABLE_REGNUM
#define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM

View File

@ -390,7 +390,7 @@ size_of_encoded_value (int encoding)
switch (encoding & 0x07)
{
case DW_EH_PE_absptr:
return POINTER_SIZE / BITS_PER_UNIT;
return POINTER_SIZE_UNITS;
case DW_EH_PE_udata2:
return 2;
case DW_EH_PE_udata4:
@ -920,7 +920,7 @@ dw2_output_indirect_constant_1 (splay_tree_node node,
sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
assemble_variable (decl, 1, 1, 1);
assemble_integer (sym_ref, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
assemble_integer (sym_ref, POINTER_SIZE_UNITS, POINTER_SIZE, 1);
return 0;
}

View File

@ -12576,7 +12576,8 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
pool. */
case CONST:
case SYMBOL_REF:
if (GET_MODE_CLASS (mode) != MODE_INT
if ((GET_MODE_CLASS (mode) != MODE_INT
&& GET_MODE_CLASS (mode) != MODE_PARTIAL_INT)
|| (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
#ifdef POINTERS_EXTEND_UNSIGNED
&& (mode != Pmode || mem_mode == VOIDmode)

View File

@ -118,13 +118,19 @@ init_expmed_one_conv (struct init_expmed_rtl *all, enum machine_mode to_mode,
int to_size, from_size;
rtx which;
/* We're given no information about the true size of a partial integer,
only the size of the "full" integer it requires for storage. For
comparison purposes here, reduce the bit size by one in that case. */
to_size = (GET_MODE_BITSIZE (to_mode)
- (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT));
from_size = (GET_MODE_BITSIZE (from_mode)
- (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT));
to_size = GET_MODE_PRECISION (to_mode);
from_size = GET_MODE_PRECISION (from_mode);
/* Most partial integers have a precision less than the "full"
integer it requires for storage. In case one doesn't, for
comparison purposes here, reduce the bit size by one in that
case. */
if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT
&& exact_log2 (to_size) != -1)
to_size --;
if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT
&& exact_log2 (from_size) != -1)
from_size --;
/* Assume cost of zero-extend and sign-extend is the same. */
which = (to_size < from_size ? all->trunc : all->zext);

View File

@ -2430,7 +2430,7 @@ iv_number_of_iterations (struct loop *loop, rtx_insn *insn, rtx condition,
comp_mode = iv0.extend_mode;
mode = iv0.mode;
size = GET_MODE_BITSIZE (mode);
size = GET_MODE_PRECISION (mode);
get_mode_bounds (mode, (cond == LE || cond == LT), comp_mode, &mmin, &mmax);
mode_mmin = lowpart_subreg (mode, mmin, comp_mode);
mode_mmax = lowpart_subreg (mode, mmax, comp_mode);

View File

@ -5205,7 +5205,7 @@ expand_float (rtx to, rtx from, int unsignedp)
rtx value;
convert_optab tab = unsignedp ? ufloat_optab : sfloat_optab;
if (GET_MODE_SIZE (GET_MODE (from)) < GET_MODE_SIZE (SImode))
if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_PRECISION (SImode))
from = convert_to_mode (SImode, from, unsignedp);
libfunc = convert_optab_libfunc (tab, GET_MODE (to), GET_MODE (from));
@ -5383,7 +5383,7 @@ expand_fix (rtx to, rtx from, int unsignedp)
that the mode of TO is at least as wide as SImode, since those are the
only library calls we know about. */
if (GET_MODE_SIZE (GET_MODE (to)) < GET_MODE_SIZE (SImode))
if (GET_MODE_PRECISION (GET_MODE (to)) < GET_MODE_PRECISION (SImode))
{
target = gen_reg_rtx (SImode);

View File

@ -1364,8 +1364,8 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op)
(sign_extend:M (zero_extend:N <X>)) is (zero_extend:M <X>). */
if (GET_CODE (op) == SIGN_EXTEND || GET_CODE (op) == ZERO_EXTEND)
{
gcc_assert (GET_MODE_BITSIZE (mode)
> GET_MODE_BITSIZE (GET_MODE (op)));
gcc_assert (GET_MODE_PRECISION (mode)
> GET_MODE_PRECISION (GET_MODE (op)));
return simplify_gen_unary (GET_CODE (op), mode, XEXP (op, 0),
GET_MODE (XEXP (op, 0)));
}
@ -1476,15 +1476,15 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op)
/* (zero_extend:M (lshiftrt:N (ashift <X> (const_int I)) (const_int I)))
is (zero_extend:M (subreg:O <X>)) if there is mode with
GET_MODE_BITSIZE (N) - I bits. */
GET_MODE_PRECISION (N) - I bits. */
if (GET_CODE (op) == LSHIFTRT
&& GET_CODE (XEXP (op, 0)) == ASHIFT
&& CONST_INT_P (XEXP (op, 1))
&& XEXP (XEXP (op, 0), 1) == XEXP (op, 1)
&& GET_MODE_BITSIZE (GET_MODE (op)) > INTVAL (XEXP (op, 1)))
&& GET_MODE_PRECISION (GET_MODE (op)) > INTVAL (XEXP (op, 1)))
{
enum machine_mode tmode
= mode_for_size (GET_MODE_BITSIZE (GET_MODE (op))
= mode_for_size (GET_MODE_PRECISION (GET_MODE (op))
- INTVAL (XEXP (op, 1)), MODE_INT, 1);
if (tmode != BLKmode)
{
@ -3079,10 +3079,10 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
#if defined(HAVE_rotate) && defined(HAVE_rotatert)
if (CONST_INT_P (trueop1)
&& IN_RANGE (INTVAL (trueop1),
GET_MODE_BITSIZE (mode) / 2 + (code == ROTATE),
GET_MODE_BITSIZE (mode) - 1))
GET_MODE_PRECISION (mode) / 2 + (code == ROTATE),
GET_MODE_PRECISION (mode) - 1))
return simplify_gen_binary (code == ROTATE ? ROTATERT : ROTATE,
mode, op0, GEN_INT (GET_MODE_BITSIZE (mode)
mode, op0, GEN_INT (GET_MODE_PRECISION (mode)
- INTVAL (trueop1)));
#endif
/* FALLTHRU */
@ -3099,7 +3099,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
canonicalize_shift:
if (SHIFT_COUNT_TRUNCATED && CONST_INT_P (op1))
{
val = INTVAL (op1) & (GET_MODE_BITSIZE (mode) - 1);
val = INTVAL (op1) & (GET_MODE_PRECISION (mode) - 1);
if (val != INTVAL (op1))
return simplify_gen_binary (code, mode, op0, GEN_INT (val));
}
@ -3779,7 +3779,8 @@ simplify_const_binary_operation (enum rtx_code code, enum machine_mode mode,
}
/* We can fold some multi-word operations. */
if (GET_MODE_CLASS (mode) == MODE_INT
if ((GET_MODE_CLASS (mode) == MODE_INT
|| GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
&& CONST_SCALAR_INT_P (op0)
&& CONST_SCALAR_INT_P (op1))
{

View File

@ -1785,6 +1785,7 @@ finalize_type_size (tree type)
tree size = TYPE_SIZE (type);
tree size_unit = TYPE_SIZE_UNIT (type);
unsigned int align = TYPE_ALIGN (type);
unsigned int precision = TYPE_PRECISION (type);
unsigned int user_align = TYPE_USER_ALIGN (type);
enum machine_mode mode = TYPE_MODE (type);
@ -1796,6 +1797,7 @@ finalize_type_size (tree type)
TYPE_SIZE (variant) = size;
TYPE_SIZE_UNIT (variant) = size_unit;
TYPE_ALIGN (variant) = align;
TYPE_PRECISION (variant) = precision;
TYPE_USER_ALIGN (variant) = user_align;
SET_TYPE_MODE (variant, mode);
}
@ -2132,6 +2134,7 @@ layout_type (tree type)
SET_TYPE_MODE (type,
smallest_mode_for_size (TYPE_PRECISION (type), MODE_INT));
TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
/* Don't set TYPE_PRECISION here, as it may be set by a bitfield. */
TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type)));
break;
@ -2202,9 +2205,9 @@ layout_type (tree type)
case OFFSET_TYPE:
TYPE_SIZE (type) = bitsize_int (POINTER_SIZE);
TYPE_SIZE_UNIT (type) = size_int (POINTER_SIZE / BITS_PER_UNIT);
/* A pointer might be MODE_PARTIAL_INT,
but ptrdiff_t must be integral. */
TYPE_SIZE_UNIT (type) = size_int (POINTER_SIZE_UNITS);
/* A pointer might be MODE_PARTIAL_INT, but ptrdiff_t must be
integral, which may be an __intN. */
SET_TYPE_MODE (type, mode_for_size (POINTER_SIZE, MODE_INT, 0));
TYPE_PRECISION (type) = POINTER_SIZE;
break;
@ -2232,7 +2235,7 @@ layout_type (tree type)
TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode));
TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode));
TYPE_UNSIGNED (type) = 1;
TYPE_PRECISION (type) = GET_MODE_BITSIZE (mode);
TYPE_PRECISION (type) = GET_MODE_PRECISION (mode);
}
break;

View File

@ -407,7 +407,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
if (mode == BLKmode)
size_tree = TYPE_SIZE (TREE_TYPE (exp));
else
bitsize = int (GET_MODE_BITSIZE (mode));
bitsize = int (GET_MODE_PRECISION (mode));
}
if (size_tree != NULL_TREE
&& TREE_CODE (size_tree) == INTEGER_CST)

View File

@ -1141,10 +1141,12 @@ adjust_mems (rtx loc, const_rtx old_rtx, void *data)
|| GET_CODE (SUBREG_REG (tem)) == MINUS
|| GET_CODE (SUBREG_REG (tem)) == MULT
|| GET_CODE (SUBREG_REG (tem)) == ASHIFT)
&& GET_MODE_CLASS (GET_MODE (tem)) == MODE_INT
&& GET_MODE_CLASS (GET_MODE (SUBREG_REG (tem))) == MODE_INT
&& GET_MODE_SIZE (GET_MODE (tem))
< GET_MODE_SIZE (GET_MODE (SUBREG_REG (tem)))
&& (GET_MODE_CLASS (GET_MODE (tem)) == MODE_INT
|| GET_MODE_CLASS (GET_MODE (tem)) == MODE_PARTIAL_INT)
&& (GET_MODE_CLASS (GET_MODE (SUBREG_REG (tem))) == MODE_INT
|| GET_MODE_CLASS (GET_MODE (SUBREG_REG (tem))) == MODE_PARTIAL_INT)
&& GET_MODE_PRECISION (GET_MODE (tem))
< GET_MODE_PRECISION (GET_MODE (SUBREG_REG (tem)))
&& subreg_lowpart_p (tem)
&& use_narrower_mode_test (SUBREG_REG (tem), tem))
return use_narrower_mode (SUBREG_REG (tem), GET_MODE (tem),
@ -6240,8 +6242,10 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
if (GET_MODE (link) == VOIDmode
|| GET_MODE (link) == BLKmode
|| (GET_MODE (link) != GET_MODE (x)
&& (GET_MODE_CLASS (GET_MODE (link)) != MODE_INT
|| GET_MODE_CLASS (GET_MODE (x)) != MODE_INT)))
&& ((GET_MODE_CLASS (GET_MODE (link)) != MODE_INT
&& GET_MODE_CLASS (GET_MODE (link)) != MODE_PARTIAL_INT)
|| (GET_MODE_CLASS (GET_MODE (x)) != MODE_INT
&& GET_MODE_CLASS (GET_MODE (x)) != MODE_PARTIAL_INT))))
/* Can't do anything for these, if the original type mode
isn't known or can't be converted. */;
else if (REG_P (x))
@ -6249,7 +6253,8 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
cselib_val *val = cselib_lookup (x, GET_MODE (x), 0, VOIDmode);
if (val && cselib_preserved_value_p (val))
item = val->val_rtx;
else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT)
else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
|| GET_MODE_CLASS (GET_MODE (x)) == MODE_PARTIAL_INT)
{
enum machine_mode mode = GET_MODE (x);
@ -6288,7 +6293,8 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
val = cselib_lookup (mem, GET_MODE (mem), 0, VOIDmode);
if (val && cselib_preserved_value_p (val))
item = val->val_rtx;
else if (GET_MODE_CLASS (GET_MODE (mem)) != MODE_INT)
else if (GET_MODE_CLASS (GET_MODE (mem)) != MODE_INT
&& GET_MODE_CLASS (GET_MODE (mem)) != MODE_PARTIAL_INT)
{
/* For non-integer stack argument see also if they weren't
initialized by integers. */
@ -6331,7 +6337,8 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
&& reg
&& REG_P (reg)
&& GET_MODE (reg) == mode
&& GET_MODE_CLASS (mode) == MODE_INT
&& (GET_MODE_CLASS (mode) == MODE_INT
|| GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
&& REG_P (x)
&& REGNO (x) == REGNO (reg)
&& GET_MODE (x) == mode

View File

@ -1489,7 +1489,7 @@ assemble_addr_to_section (rtx symbol, section *sec)
{
switch_to_section (sec);
assemble_align (POINTER_SIZE);
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
assemble_integer (symbol, POINTER_SIZE_UNITS, POINTER_SIZE, 1);
}
/* Return the numbered .ctors.N (if CONSTRUCTOR_P) or .dtors.N (if
@ -2645,7 +2645,7 @@ default_assemble_integer (rtx x ATTRIBUTE_UNUSED,
const char *op = integer_asm_op (size, aligned_p);
/* Avoid GAS bugs for large values. Specifically negative values whose
absolute value fits in a bfd_vma, but not in a bfd_signed_vma. */
if (size > UNITS_PER_WORD && size > POINTER_SIZE / BITS_PER_UNIT)
if (size > UNITS_PER_WORD && size > POINTER_SIZE_UNITS)
return false;
return op && (assemble_integer_with_op (op, x), true);
}
@ -5765,9 +5765,9 @@ dump_tm_clone_pairs (vec<tm_alias_pair> tm_alias_pairs)
}
assemble_integer (XEXP (DECL_RTL (src), 0),
POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
POINTER_SIZE_UNITS, POINTER_SIZE, 1);
assemble_integer (XEXP (DECL_RTL (dst), 0),
POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
POINTER_SIZE_UNITS, POINTER_SIZE, 1);
}
}