[patch] function.c: Use VEC instaed of VARRAY.

Kazu Hirata kazu@codesourcery.com
Mon Apr 17 02:27:00 GMT 2006


Hi,

Attached is a patch to use VEC instead of VARRAY.

Tested on x86_64-pc-linux-gnu.  Will commit this patch in 24 hours or
so as preapproved.

Kazu Hirata

2006-04-17  Kazu Hirata  <kazu@codesourcery.com>

	* function.c (temp_slots_at_level, max_slot_level): Use VEC
	instead of VARRAY.
	* function.h (temp_slot_p): New.
	(function): Change the type of x_used_temp_slots to
	VEC(temp_slot_p,gc) *.

Index: function.c
===================================================================
*** function.c	(revision 112985)
--- function.c	(working copy)
***************
*** 546,559 ****
  static struct temp_slot **
  temp_slots_at_level (int level)
  {
  
!   if (!used_temp_slots)
!     VARRAY_GENERIC_PTR_INIT (used_temp_slots, 3, "used_temp_slots");
! 
!   while (level >= (int) VARRAY_ACTIVE_SIZE (used_temp_slots))
!     VARRAY_PUSH_GENERIC_PTR (used_temp_slots, NULL);
  
!   return (struct temp_slot **) &VARRAY_GENERIC_PTR (used_temp_slots, level);
  }
  
  /* Returns the maximal temporary slot level.  */
--- 546,563 ----
  static struct temp_slot **
  temp_slots_at_level (int level)
  {
+   if (level >= (int) VEC_length (temp_slot_p, used_temp_slots))
+     {
+       size_t old_length = VEC_length (temp_slot_p, used_temp_slots);
+       temp_slot_p *p;
  
!       VEC_safe_grow (temp_slot_p, gc, used_temp_slots, level + 1);
!       p = VEC_address (temp_slot_p, used_temp_slots);
!       memset (&p[old_length], 0,
! 	      sizeof (temp_slot_p) * (level + 1 - old_length));
!     }
  
!   return &(VEC_address (temp_slot_p, used_temp_slots)[level]);
  }
  
  /* Returns the maximal temporary slot level.  */
***************
*** 564,570 ****
    if (!used_temp_slots)
      return -1;
  
!   return VARRAY_ACTIVE_SIZE (used_temp_slots) - 1;
  }
  
  /* Moves temporary slot TEMP to LEVEL.  */
--- 568,574 ----
    if (!used_temp_slots)
      return -1;
  
!   return VEC_length (temp_slot_p, used_temp_slots) - 1;
  }
  
  /* Moves temporary slot TEMP to LEVEL.  */
Index: function.h
===================================================================
*** function.h	(revision 112985)
--- function.h	(working copy)
***************
*** 159,164 ****
--- 159,170 ----
  #define forced_labels (cfun->expr->x_forced_labels)
  #define stack_pointer_delta (cfun->expr->x_stack_pointer_delta)
  
+ struct temp_slot;
+ typedef struct temp_slot *temp_slot_p;
+ 
+ DEF_VEC_P(temp_slot_p);
+ DEF_VEC_ALLOC_P(temp_slot_p,gc);
+ 
  /* This structure can save all the important global and static variables
     describing the status of the current function.  */
  
***************
*** 266,272 ****
    rtx x_parm_birth_insn;
  
    /* List of all used temporaries allocated, by level.  */
!   struct varray_head_tag * GTY((param_is (struct temp_slot))) x_used_temp_slots;
  
    /* List of available temp slots.  */
    struct temp_slot *x_avail_temp_slots;
--- 272,278 ----
    rtx x_parm_birth_insn;
  
    /* List of all used temporaries allocated, by level.  */
!   VEC(temp_slot_p,gc) *x_used_temp_slots;
  
    /* List of available temp slots.  */
    struct temp_slot *x_avail_temp_slots;



More information about the Gcc-patches mailing list