Patchwork VEC re-write [patch 18/25]

login
register
mail settings
Submitter Diego Novillo
Date Nov. 15, 2012, 9:54 p.m.
Message ID <20121115215412.3B1F6C0916@torture.tor.corp.google.com>
Download mbox | patch
Permalink /patch/199437/
State New
Headers show

Comments

Diego Novillo - Nov. 15, 2012, 9:54 p.m.
2012-11-15  Diego Novillo  <dnovillo@google.com>

	Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)

	* config/mips/mips.c: Use new vec API in vec.h.
Richard Sandiford - Nov. 15, 2012, 10:48 p.m.
Thanks for all your work on this.

dnovillo@google.com (Diego Novillo) writes:
> 	* config/mips/mips.c: Use new vec API in vec.h.

Looks good to me.  Just a couple of minor nits:

> @@ -4013,11 +4013,9 @@ struct mips_multi_member {
>  typedef struct mips_multi_member mips_multi_member;
> 
>  /* Vector definitions for the above.  */
> -DEF_VEC_O(mips_multi_member);
> -DEF_VEC_ALLOC_O(mips_multi_member, heap);

Please delete the comment too.

> @@ -4093,7 +4091,7 @@ mips_multi_copy_insn (unsigned int i)
>    struct mips_multi_member *member;
>  
>    member = mips_multi_add ();
> -  memcpy (member, &VEC_index (mips_multi_member, mips_multi_members, i),
> +  memcpy (member, &mips_multi_members[i],
>  	  sizeof (*member));
>    gcc_assert (!member->is_label_p);
>  }

This call now fits comfortably onto one line.

Doesn't need a retest, obviously. :-)

Richard
Diego Novillo - Nov. 16, 2012, 3:40 p.m.
On Thu, Nov 15, 2012 at 5:48 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:

>> @@ -4013,11 +4013,9 @@ struct mips_multi_member {
>>  typedef struct mips_multi_member mips_multi_member;
>>
>>  /* Vector definitions for the above.  */
>> -DEF_VEC_O(mips_multi_member);
>> -DEF_VEC_ALLOC_O(mips_multi_member, heap);
>
> Please delete the comment too.

Done.

>
>> @@ -4093,7 +4091,7 @@ mips_multi_copy_insn (unsigned int i)
>>    struct mips_multi_member *member;
>>
>>    member = mips_multi_add ();
>> -  memcpy (member, &VEC_index (mips_multi_member, mips_multi_members, i),
>> +  memcpy (member, &mips_multi_members[i],
>>         sizeof (*member));
>>    gcc_assert (!member->is_label_p);
>>  }
>
> This call now fits comfortably onto one line.

Done.

Diego.

Patch

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 01f6b61..ebe21a9 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -4013,11 +4013,9 @@  struct mips_multi_member {
 typedef struct mips_multi_member mips_multi_member;
 
 /* Vector definitions for the above.  */
-DEF_VEC_O(mips_multi_member);
-DEF_VEC_ALLOC_O(mips_multi_member, heap);
 
 /* The instructions that make up the current multi-insn sequence.  */
-static VEC (mips_multi_member, heap) *mips_multi_members;
+static vec<mips_multi_member> mips_multi_members;
 
 /* How many instructions (as opposed to labels) are in the current
    multi-insn sequence.  */
@@ -4028,7 +4026,7 @@  static unsigned int mips_multi_num_insns;
 static void
 mips_multi_start (void)
 {
-  VEC_truncate (mips_multi_member, mips_multi_members, 0);
+  mips_multi_members.truncate (0);
   mips_multi_num_insns = 0;
 }
 
@@ -4038,7 +4036,7 @@  static struct mips_multi_member *
 mips_multi_add (void)
 {
   mips_multi_member empty;
-  return VEC_safe_push (mips_multi_member, heap, mips_multi_members, empty);
+  return mips_multi_members.safe_push (empty);
 }
 
 /* Add a normal insn with the given asm format to the current multi-insn
@@ -4081,7 +4079,7 @@  mips_multi_add_label (const char *label)
 static unsigned int
 mips_multi_last_index (void)
 {
-  return VEC_length (mips_multi_member, mips_multi_members) - 1;
+  return mips_multi_members.length () - 1;
 }
 
 /* Add a copy of an existing instruction to the current multi-insn
@@ -4093,7 +4091,7 @@  mips_multi_copy_insn (unsigned int i)
   struct mips_multi_member *member;
 
   member = mips_multi_add ();
-  memcpy (member, &VEC_index (mips_multi_member, mips_multi_members, i),
+  memcpy (member, &mips_multi_members[i],
 	  sizeof (*member));
   gcc_assert (!member->is_label_p);
 }
@@ -4105,7 +4103,7 @@  mips_multi_copy_insn (unsigned int i)
 static void
 mips_multi_set_operand (unsigned int i, unsigned int op, rtx x)
 {
-  VEC_index (mips_multi_member, mips_multi_members, i).operands[op] = x;
+  mips_multi_members[i].operands[op] = x;
 }
 
 /* Write out the asm code for the current multi-insn sequence.  */
@@ -4116,7 +4114,7 @@  mips_multi_write (void)
   struct mips_multi_member *member;
   unsigned int i;
 
-  FOR_EACH_VEC_ELT (mips_multi_member, mips_multi_members, i, member)
+  FOR_EACH_VEC_ELT (mips_multi_members, i, member)
     if (member->is_label_p)
       fprintf (asm_out_file, "%s\n", member->format);
     else