diff options
author | Nathan Froyd <froydnj@codesourcery.com> | 2010-07-05 12:46:52 +0000 |
---|---|---|
committer | Nathan Froyd <froydnj@gcc.gnu.org> | 2010-07-05 12:46:52 +0000 |
commit | 989ea525bec01e16c29b69bf5194310c551d9c34 (patch) | |
tree | 5666dfc48fb2cc1c04e55452418033ee9e2438bd /gcc/vec.h | |
parent | 7ec6356e22e1644f3fee6314790b2680098778de (diff) | |
download | gcc-989ea525bec01e16c29b69bf5194310c551d9c34.zip gcc-989ea525bec01e16c29b69bf5194310c551d9c34.tar.gz gcc-989ea525bec01e16c29b69bf5194310c551d9c34.tar.bz2 |
vec.h (VEC_splice, [...]): New macros.
gcc/
* vec.h (VEC_splice, VEC_safe_splice): New macros. Add function
implementations.
gcc/fortran/
* trans.h (gfc_conv_procedure_call): Take a VEC instead of a tree.
* trans-intrinsic.c (gfc_conv_intrinsic_funcall): Adjust for new
type of gfc_conv_procedure_call.
(conv_generic_with_optional_char_arg): Likewise.
* trans-stmt.c (gfc_trans_call): Likewise.
* trans-expr.c (gfc_conv_function_expr): Likewise.
(gfc_conv_procedure_call): Use build_call_vec instead of
build_call_list.
From-SVN: r161834
Diffstat (limited to 'gcc/vec.h')
-rw-r--r-- | gcc/vec.h | 91 |
1 files changed, 91 insertions, 0 deletions
@@ -259,6 +259,32 @@ along with GCC; see the file COPYING3. If not see #define VEC_reserve_exact(T,A,V,R) \ (VEC_OP(T,A,reserve_exact)(&(V),R VEC_CHECK_INFO MEM_STAT_INFO)) +/* Copy elements with no reallocation + void VEC_T_splice (VEC(T) *dst, VEC(T) *src); // Integer + void VEC_T_splice (VEC(T) *dst, VEC(T) *src); // Pointer + void VEC_T_splice (VEC(T) *dst, VEC(T) *src); // Object + + Copy the elements in SRC to the end of DST as if by memcpy. DST and + SRC need not be allocated with the same mechanism, although they most + often will be. DST is assumed to have sufficient headroom + available. */ + +#define VEC_splice(T,DST,SRC) \ + (VEC_OP(T,base,splice)(VEC_BASE(DST), VEC_BASE(SRC) VEC_CHECK_INFO)) + +/* Copy elements with reallocation + void VEC_T_safe_splice (VEC(T,A) *&dst, VEC(T) *src); // Integer + void VEC_T_safe_splice (VEC(T,A) *&dst, VEC(T) *src); // Pointer + void VEC_T_safe_splice (VEC(T,A) *&dst, VEC(T) *src); // Object + + Copy the elements in SRC to the end of DST as if by memcpy. DST and + SRC need not be allocated with the same mechanism, although they most + often will be. DST need not have sufficient headroom and will be + reallocated if needed. */ + +#define VEC_safe_splice(T,A,DST,SRC) \ + (VEC_OP(T,A,safe_splice)(&(DST), VEC_BASE(SRC) VEC_CHECK_INFO MEM_STAT_INFO)) + /* Push object with no reallocation T *VEC_T_quick_push (VEC(T) *v, T obj); // Integer T *VEC_T_quick_push (VEC(T) *v, T obj); // Pointer @@ -589,6 +615,19 @@ static inline int VEC_OP (T,base,space) \ return vec_ ? vec_->alloc - vec_->num >= (unsigned)alloc_ : !alloc_; \ } \ \ +static inline void VEC_OP(T,base,splice) \ + (VEC(T,base) *dst_, VEC(T,base) *src_ VEC_CHECK_DECL) \ +{ \ + if (src_) \ + { \ + unsigned len_ = src_->num; \ + VEC_ASSERT (dst_->num + len_ <= dst_->alloc, "splice", T, base); \ + \ + memcpy (&dst_->vec[dst_->num], &src_->vec[0], len_ * sizeof (T)); \ + dst_->num += len_; \ + } \ +} \ + \ static inline T *VEC_OP (T,base,quick_push) \ (VEC(T,base) *vec_, T obj_ VEC_CHECK_DECL) \ { \ @@ -796,6 +835,19 @@ static inline void VEC_OP (T,A,safe_grow_cleared) \ sizeof (T) * (size_ - oldsize)); \ } \ \ +static inline void VEC_OP(T,A,safe_splice) \ + (VEC(T,A) **dst_, VEC(T,base) *src_ VEC_CHECK_DECL MEM_STAT_DECL) \ +{ \ + if (src_) \ + { \ + VEC_OP (T,A,reserve_exact) (dst_, src_->num \ + VEC_CHECK_PASS MEM_STAT_INFO); \ + \ + VEC_OP (T,base,splice) (VEC_BASE (*dst_), src_ \ + VEC_CHECK_PASS); \ + } \ +} \ + \ static inline T *VEC_OP (T,A,safe_push) \ (VEC(T,A) **vec_, T obj_ VEC_CHECK_DECL MEM_STAT_DECL) \ { \ @@ -881,6 +933,19 @@ static inline int VEC_OP (T,base,space) \ return vec_ ? vec_->alloc - vec_->num >= (unsigned)alloc_ : !alloc_; \ } \ \ +static inline void VEC_OP(T,base,splice) \ + (VEC(T,base) *dst_, VEC(T,base) *src_ VEC_CHECK_DECL) \ +{ \ + if (src_) \ + { \ + unsigned len_ = src_->num; \ + VEC_ASSERT (dst_->num + len_ <= dst_->alloc, "splice", T, base); \ + \ + memcpy (&dst_->vec[dst_->num], &src_->vec[0], len_ * sizeof (T)); \ + dst_->num += len_; \ + } \ +} \ + \ static inline T *VEC_OP (T,base,quick_push) \ (VEC(T,base) *vec_, const T *obj_ VEC_CHECK_DECL) \ { \ @@ -1084,6 +1149,19 @@ static inline void VEC_OP (T,A,safe_grow_cleared) \ sizeof (T) * (size_ - oldsize)); \ } \ \ +static inline void VEC_OP(T,A,safe_splice) \ + (VEC(T,A) **dst_, VEC(T,base) *src_ VEC_CHECK_DECL MEM_STAT_DECL) \ +{ \ + if (src_) \ + { \ + VEC_OP (T,A,reserve_exact) (dst_, src_->num \ + VEC_CHECK_PASS MEM_STAT_INFO); \ + \ + VEC_OP (T,base,splice) (VEC_BASE (*dst_), src_ \ + VEC_CHECK_PASS); \ + } \ +} \ + \ static inline T *VEC_OP (T,A,safe_push) \ (VEC(T,A) **vec_, const T *obj_ VEC_CHECK_DECL MEM_STAT_DECL) \ { \ @@ -1188,6 +1266,19 @@ static inline void VEC_OP (T,A,safe_grow_cleared) \ sizeof (T) * (size_ - oldsize)); \ } \ \ +static inline void VEC_OP(T,A,safe_splice) \ + (VEC(T,A) **dst_, VEC(T,base) *src_ VEC_CHECK_DECL MEM_STAT_DECL) \ +{ \ + if (src_) \ + { \ + VEC_OP (T,A,reserve_exact) (dst_, src_->num \ + VEC_CHECK_PASS MEM_STAT_INFO); \ + \ + VEC_OP (T,base,splice) (VEC_BASE (*dst_), src_ \ + VEC_CHECK_PASS); \ + } \ +} \ + \ static inline T *VEC_OP (T,A,safe_push) \ (VEC(T,A) **vec_, const T obj_ VEC_CHECK_DECL MEM_STAT_DECL) \ { \ |