This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
New target macro, STRUCT_FORCE_BLK
- To: gcc-patches at gcc dot gnu dot org
- Subject: New target macro, STRUCT_FORCE_BLK
- From: Michael Hayes <m dot hayes at elec dot canterbury dot ac dot nz>
- Date: Thu, 06 Jan 2000 12:18:01 +1300 (NZDT)
We generate poor code for the c4x if a small structure containing a
floating point field (for example, a complex float) is stored in an
integer mode. The only way I've found to prevent this happening is to
define yet another target macro...
Michael.
2000-01-06 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* stor-layout.c (layout_type): If STRUCT_FORCE_BLK defined, use it.
* tm.texi (STRUCT_FORCE_BLK): Document it.
* config/c4x/c4x.h (STRUCT_FORCE_BLK): Define.
Index: tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.101
diff -c -3 -p -r1.101 tm.texi
*** tm.texi 2000/01/04 20:29:31 1.101
--- tm.texi 2000/01/05 23:27:21
*************** be momentarily unaligned while pushing a
*** 819,824 ****
--- 819,833 ----
@item FUNCTION_BOUNDARY
Alignment required for a function entry point, in bits.
+ @findex STRUCT_FORCE_BLK
+ @item STRUCT_FORCE_BLK (@var{field})
+ Return 1 if a structure containing @var{field} should be stored using
+ @code{BLKMODE}.
+
+ Normally, this is not needed. See the file @file{c4x.h} for an example
+ of how to use this macro to prevent a structure having a floating point
+ field from being stored in an integer mode.
+
@findex BIGGEST_ALIGNMENT
@item BIGGEST_ALIGNMENT
Biggest alignment that any data type can require on this machine, in bits.
Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stor-layout.c,v
retrieving revision 1.42
diff -c -3 -p -r1.42 stor-layout.c
*** stor-layout.c 2000/01/04 08:10:30 1.42
--- stor-layout.c 2000/01/05 23:27:21
*************** layout_type (type)
*** 1057,1062 ****
--- 1057,1070 ----
register instead of forcing it to live in the stack. */
if (simple_cst_equal (TYPE_SIZE (type), DECL_SIZE (field)))
mode = DECL_MODE (field);
+
+ #ifdef STRUCT_FORCE_BLK
+ /* Some targets, eg. c4x, cannot allow structures with
+ a floating point field to be stored in an integer mode
+ so check if BLKMODE should be used. */
+ if (mode == VOIDmode && STRUCT_FORCE_BLK (field))
+ goto record_lose;
+ #endif /* STRUCT_FORCE_BLK */
}
if (mode != VOIDmode)
Index: config/c4x/c4x.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/c4x/c4x.h,v
retrieving revision 1.37
diff -c -3 -p -r1.37 c4x.h
*** c4x.h 2000/01/05 22:38:09 1.37
--- c4x.h 2000/01/05 23:27:22
*************** extern const char *c4x_rpts_cycles_strin
*** 352,357 ****
--- 352,361 ----
#define TARGET_FLOAT_FORMAT C4X_FLOAT_FORMAT
#define MAX_FIXED_MODE_SIZE 64 /* HImode */
+ /* If a structure has a floating point field then force structure
+ to have BLKMODE. */
+ #define STRUCT_FORCE_BLK(FIELD) (TREE_CODE (TREE_TYPE (FIELD)) == REAL_TYPE)
+
/* Number of bits in the high and low parts of a two stage
load of an immediate constant. */
#define BITS_PER_HIGH 16