aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-05 19:57:56 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-05 19:57:56 +0000
commit798014c58e9e54b068c30e8e2113d278a0bd6e07 (patch)
tree342022676600dfe2e5948350a06d04966f949872 /gcc
parent3981fbb65a43dff3a81ebc32c94d6f86bb4f9783 (diff)
downloadgcc-798014c58e9e54b068c30e8e2113d278a0bd6e07.zip
gcc-798014c58e9e54b068c30e8e2113d278a0bd6e07.tar.gz
gcc-798014c58e9e54b068c30e8e2113d278a0bd6e07.tar.bz2
Make mode_for_size_tree return an opt_mode
...for consistency with mode_for_size 2017-09-05 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * stor-layout.h (mode_for_size_tree): Return an opt_mode. * stor-layout.c (mode_for_size_tree): Likewise. (mode_for_array): Update accordingly. (layout_decl): Likewise. (compute_record_mode): Likewise. Only set the mode once. gcc/ada/ * gcc-interface/utils.c (make_packable_type): Update call to mode_for_size_tree. From-SVN: r251732
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/utils.c3
-rw-r--r--gcc/stor-layout.c43
-rw-r--r--gcc/stor-layout.h2
5 files changed, 39 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f521a27..5eb76c2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
+ * stor-layout.h (mode_for_size_tree): Return an opt_mode.
+ * stor-layout.c (mode_for_size_tree): Likewise.
+ (mode_for_array): Update accordingly.
+ (layout_decl): Likewise.
+ (compute_record_mode): Likewise. Only set the mode once.
+
+2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
+
* target.def (get_mask_mode): Change return type to opt_mode.
Expand commentary.
* doc/tm.texi: Regenerate.
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index ce3d6fe..e1c7545 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
+ * gcc-interface/utils.c (make_packable_type): Update call to
+ mode_for_size_tree.
+
+2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
+
* gcc-interface/utils2.c (build_load_modify_store):
Use int_mode_for_size.
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 1c83a08..89dbc8d 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1080,7 +1080,8 @@ make_packable_type (tree type, bool in_record, unsigned int max_align)
in case the record itself contains a BLKmode field. */
if (in_record && TYPE_MODE (new_type) == BLKmode)
SET_TYPE_MODE (new_type,
- mode_for_size_tree (TYPE_SIZE (new_type), MODE_INT, 1));
+ mode_for_size_tree (TYPE_SIZE (new_type),
+ MODE_INT, 1).else_blk ());
/* If neither mode nor size nor alignment shrunk, return the old type. */
if (TYPE_MODE (new_type) == BLKmode && new_size >= size && max_align == 0)
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index baaf5f3..8a3b0fe 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -321,19 +321,19 @@ mode_for_size (unsigned int size, enum mode_class mclass, int limit)
/* Similar, except passed a tree node. */
-machine_mode
+opt_machine_mode
mode_for_size_tree (const_tree size, enum mode_class mclass, int limit)
{
unsigned HOST_WIDE_INT uhwi;
unsigned int ui;
if (!tree_fits_uhwi_p (size))
- return BLKmode;
+ return opt_machine_mode ();
uhwi = tree_to_uhwi (size);
ui = uhwi;
if (uhwi != ui)
- return BLKmode;
- return mode_for_size (ui, mclass, limit).else_blk ();
+ return opt_machine_mode ();
+ return mode_for_size (ui, mclass, limit);
}
/* Return the narrowest mode of class MCLASS that contains at least
@@ -563,7 +563,7 @@ mode_for_array (tree elem_type, tree size)
int_size / int_elem_size))
limit_p = false;
}
- return mode_for_size_tree (size, MODE_INT, limit_p);
+ return mode_for_size_tree (size, MODE_INT, limit_p).else_blk ();
}
/* Subroutine of layout_decl: Force alignment required for the data type.
@@ -683,17 +683,18 @@ layout_decl (tree decl, unsigned int known_align)
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
&& GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT)
{
- machine_mode xmode
- = mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
- unsigned int xalign = GET_MODE_ALIGNMENT (xmode);
-
- if (xmode != BLKmode
- && !(xalign > BITS_PER_UNIT && DECL_PACKED (decl))
- && (known_align == 0 || known_align >= xalign))
+ machine_mode xmode;
+ if (mode_for_size_tree (DECL_SIZE (decl),
+ MODE_INT, 1).exists (&xmode))
{
- SET_DECL_ALIGN (decl, MAX (xalign, DECL_ALIGN (decl)));
- SET_DECL_MODE (decl, xmode);
- DECL_BIT_FIELD (decl) = 0;
+ unsigned int xalign = GET_MODE_ALIGNMENT (xmode);
+ if (!(xalign > BITS_PER_UNIT && DECL_PACKED (decl))
+ && (known_align == 0 || known_align >= xalign))
+ {
+ SET_DECL_ALIGN (decl, MAX (xalign, DECL_ALIGN (decl)));
+ SET_DECL_MODE (decl, xmode);
+ DECL_BIT_FIELD (decl) = 0;
+ }
}
}
@@ -1756,22 +1757,24 @@ compute_record_mode (tree type)
if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode
&& tree_fits_uhwi_p (TYPE_SIZE (type))
&& GET_MODE_BITSIZE (mode) == tree_to_uhwi (TYPE_SIZE (type)))
- SET_TYPE_MODE (type, mode);
+ ;
else
- SET_TYPE_MODE (type, mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1));
+ mode = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1).else_blk ();
/* If structure's known alignment is less than what the scalar
mode would need, and it matters, then stick with BLKmode. */
- if (TYPE_MODE (type) != BLKmode
+ if (mode != BLKmode
&& STRICT_ALIGNMENT
&& ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT
- || TYPE_ALIGN (type) >= GET_MODE_ALIGNMENT (TYPE_MODE (type))))
+ || TYPE_ALIGN (type) >= GET_MODE_ALIGNMENT (mode)))
{
/* If this is the only reason this type is BLKmode, then
don't force containing types to be BLKmode. */
TYPE_NO_FORCE_BLK (type) = 1;
- SET_TYPE_MODE (type, BLKmode);
+ mode = BLKmode;
}
+
+ SET_TYPE_MODE (type, mode);
}
/* Compute TYPE_SIZE and TYPE_ALIGN for TYPE, once it has been laid
diff --git a/gcc/stor-layout.h b/gcc/stor-layout.h
index 08c37ca..6c8d833 100644
--- a/gcc/stor-layout.h
+++ b/gcc/stor-layout.h
@@ -99,7 +99,7 @@ extern tree make_unsigned_type (int);
If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
The value is BLKmode if no other mode is found. This is like
mode_for_size, but is passed a tree. */
-extern machine_mode mode_for_size_tree (const_tree, enum mode_class, int);
+extern opt_machine_mode mode_for_size_tree (const_tree, enum mode_class, int);
extern tree bitwise_type_for_mode (machine_mode);