This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add new flag: TYPE_ALIGN_OK


This flag was previously just used by the Ada front end, but is something 
that's now better handled in common code.  This change also includes some
minor improvements discovered while testing that code.

Tested on alphaev56-dec-osf4.0c.

Sun Nov 18 14:13:52 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* tree.h (TYPE_ALIGN_OK): New flag.
	* emit-rtl.c (set_mem_attributes): Handle it.
	* expr.c (emit_single_push_insn): Only set to alias set 0 if
	doing sibcall optimization.
	(expand_expr, case COMPONENT_REF): Call set_mem_attributes on case
	when make temporary.
	(expand_expr, case CONVERT_EXPR): Simplify convert-to-union case.
	(expand_expr, case ADDR_EXPR): Abort if TYPE_ALIGN_OK and need copy.

*** emit-rtl.c	2001/11/15 23:44:54	1.226
--- emit-rtl.c	2001/11/18 19:02:35
*************** set_mem_attributes (ref, t, objectp)
*** 1700,1707 ****
      MEM_SCALAR_P (ref) = 1;
  
!   /* We can set the alignment from the type if we are makign an object or
!      if this is an INDIRECT_REF.  */
!   if (objectp || TREE_CODE (t) == INDIRECT_REF)
!     align = TYPE_ALIGN (type);
  
    /* If the size is known, we can set that.  */
--- 1700,1707 ----
      MEM_SCALAR_P (ref) = 1;
  
!   /* We can set the alignment from the type if we are making an object,
!      this is an INDIRECT_REF, or if TYPE_ALIGN_OK.  */
!   if (objectp || TREE_CODE (t) == INDIRECT_REF || TYPE_ALIGN_OK (type))
!     align = MAX (align, TYPE_ALIGN (type));
  
    /* If the size is known, we can set that.  */
*** expr.c	2001/11/16 14:02:55	1.380
--- expr.c	2001/11/18 19:03:01
*************** emit_single_push_insn (mode, x, type)
*** 3200,3208 ****
      {
        set_mem_attributes (dest, type, 1);
!       /* Function incoming arguments may overlap with sibling call
!          outgoing arguments and we cannot allow reordering of reads
!          from function arguments with stores to outgoing arguments
!          of sibling calls.  */
!       set_mem_alias_set (dest, 0);
      }
    emit_move_insn (dest, x);
--- 3200,3210 ----
      {
        set_mem_attributes (dest, type, 1);
! 
!       if (flag_optimize_sibling_calls)
! 	/* Function incoming arguments may overlap with sibling call
! 	   outgoing arguments and we cannot allow reordering of reads
! 	   from function arguments with stores to outgoing arguments
! 	   of sibling calls.  */
! 	set_mem_alias_set (dest, 0);
      }
    emit_move_insn (dest, x);
*************** expand_expr (exp, target, tmode, modifie
*** 7181,7191 ****
  	    if (mode == BLKmode)
  	      {
! 		tree nt = build_qualified_type (type_for_mode (ext_mode, 0),
! 						TYPE_QUAL_CONST);
! 		rtx new = assign_temp (nt, 0, 1, 1);
  
  		emit_move_insn (new, op0);
  		op0 = copy_rtx (new);
  		PUT_MODE (op0, BLKmode);
  	      }
  
--- 7183,7194 ----
  	    if (mode == BLKmode)
  	      {
! 		rtx new = assign_temp (build_qualified_type
! 				       (type_for_mode (ext_mode, 0),
! 					TYPE_QUAL_CONST), 0, 1, 1);
  
  		emit_move_insn (new, op0);
  		op0 = copy_rtx (new);
  		PUT_MODE (op0, BLKmode);
+ 		set_mem_attributes (op0, exp, 1);
  	      }
  
*************** expand_expr (exp, target, tmode, modifie
*** 7423,7435 ****
  	{
  	  tree valtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  
! 	  /* If both input and output are BLKmode, this conversion
! 	     isn't actually doing anything unless we need to make the
! 	     alignment stricter.  */
! 	  if (mode == BLKmode && TYPE_MODE (valtype) == BLKmode
! 	      && (TYPE_ALIGN (type) <= TYPE_ALIGN (valtype)
! 		  || TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT))
! 	    return expand_expr (TREE_OPERAND (exp, 0), target, tmode,
! 				modifier);
  
  	  if (target == 0)
--- 7426,7441 ----
  	{
  	  tree valtype = TREE_TYPE (TREE_OPERAND (exp, 0));
+ 
+ 	  /* If both input and output are BLKmode, this conversion isn't doing
+ 	     anything except possibly changing memory attribute.  */
+ 	  if (mode == BLKmode && TYPE_MODE (valtype) == BLKmode)
+ 	    {
+ 	      rtx result = expand_expr (TREE_OPERAND (exp, 0), target, tmode,
+ 					modifier);
  
! 	      result = copy_rtx (result);
! 	      set_mem_attributes (result, exp, 0);
! 	      return result;
! 	    }
  
  	  if (target == 0)
*************** expand_expr (exp, target, tmode, modifie
*** 8673,8676 ****
--- 8679,8685 ----
  					    (TYPE_QUALS (inner_type)
  					     | TYPE_QUAL_CONST)));
+ 
+ 	      if (TYPE_ALIGN_OK (inner_type))
+ 		abort ();
  
  	      emit_block_move (new, op0, expr_size (TREE_OPERAND (exp, 0)));
*** tree.h	2001/11/18 11:04:41	1.284
--- tree.h	2001/11/18 19:03:41
*************** extern void tree_class_check_failed PARA
*** 597,600 ****
--- 597,608 ----
  #define TREE_NOTHROW(NODE) ((NODE)->common.nothrow_flag)
  
+ /* In a type, nonzero means that all objects of the type are guaranteed by the
+    language or front-end to be properly aligned, so we can indicate that a MEM
+    of this type is aligned at least to the alignment of the type, even if it
+    doesn't appear that it is.  We see this, for example, in object-oriented
+    languages where a tag field may show this is an object of a more-aligned
+    variant of the more generic type.  */
+ #define TYPE_ALIGN_OK(NODE) (TYPE_CHECK (NODE)->common.nothrow_flag)
+ 
  /* Used in classes in C++.  */
  #define TREE_PRIVATE(NODE) ((NODE)->common.private_flag)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]