ctrump/common/varray.h File Reference

variable length array module More...

#include <stddef.h>
#include "ctrump/common/dll.h"

Include dependency graph for varray.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ctrump_varray
 可変長配列 More...

Defines

#define VA_ELEM(t, a, n)   (((t*)((a)->elements))[n])
 get element of array
#define VA_TOP(t, a)   VA_ELEM(t,a,(a)->nelem-1)
 get top element
#define VA_ELEM_PTR(t, a, n)   (&(((t*)((a)->elements))[n]))
 get pointer of element
#define VA_LAST_PTR(t, a)   (&(((t*)((a)->elements))[(a)->nelem-1]))
 get pointer of last element
#define VA_PUSH(t, a, e)   do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc(a); VA_ELEM(t,a,(a)->nelem++) = (e); } while(0)
 append element
#define VA_NEWELEM(a)   do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc(a); (a)->nelem++; } while(0)
 append size
#define VA_NEWELEM_P(a, p)   do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc_pool(a,p); (a)->nelem++; } while(0)
 append size
#define VA_POP(t, a)   VA_ELEM(t, (a), --((a)->nelem))
 extract and remove element
#define VA_PUSH_P(t, a, e, p)   do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc_pool(a,p); VA_ELEM(t,a,(a)->nelem++) = (e); } while(0)

Functions

CTRUMP_EXTDEF void ctrump_varray_init (struct ctrump_varray *a, size_t n, size_t es)
 create array
CTRUMP_EXTDEF void ctrump_varray_init_pool (struct ctrump_varray *a, size_t n, size_t es, struct ctrump_mempool *pool)
CTRUMP_EXTDEF void ctrump_varray_realloc (struct ctrump_varray *a)
 resize array
CTRUMP_EXTDEF void ctrump_varray_realloc_pool (struct ctrump_varray *a, struct ctrump_mempool *pool)
CTRUMP_EXTDEF void * ctrump_varray_close (struct ctrump_varray *a, struct ctrump_mempool *p)
 free array and copy contents to buffer that is allocated from pool
CTRUMP_EXTDEF void * ctrump_varray_copy (struct ctrump_varray *a, struct ctrump_mempool *p)
 copy to buffer that is allocated from pool
CTRUMP_EXTDEF void ctrump_varray_discard (struct ctrump_varray *a)
 free array


Detailed Description

variable length array module

Definition in file varray.h.


Define Documentation

#define VA_ELEM ( t,
a,
 )     (((t*)((a)->elements))[n])

get element of array

Parameters:
t type of element
a array
n index

Definition at line 64 of file varray.h.

Referenced by build_cfg(), build_dom(), dfs_order(), find_df(), and resolve_bb_vec().

#define VA_ELEM_PTR ( t,
a,
 )     (&(((t*)((a)->elements))[n]))

get pointer of element

Parameters:
t type of element
a array
n index

Definition at line 79 of file varray.h.

#define VA_LAST_PTR ( t,
 )     (&(((t*)((a)->elements))[(a)->nelem-1]))

#define VA_NEWELEM (  )     do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc(a); (a)->nelem++; } while(0)

append size

Parameters:
t type of element
a array

Definition at line 102 of file varray.h.

Referenced by append_nd_subscript(), append_record_member_ref(), expr_subscripts_to_loop_subscript(), recog_array_access(), and single_expr_subscripts_to_loop_subscript().

#define VA_NEWELEM_P ( a,
 )     do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc_pool(a,p); (a)->nelem++; } while(0)

#define VA_POP ( t,
 )     VA_ELEM(t, (a), --((a)->nelem))

extract and remove element

Parameters:
t type of element
a array

Definition at line 117 of file varray.h.

Referenced by assign_pdg_node_bb(), and single_expr_subscripts_to_loop_subscript().

#define VA_PUSH ( t,
a,
 )     do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc(a); VA_ELEM(t,a,(a)->nelem++) = (e); } while(0)

append element

Parameters:
t type of element
a array
e element

Definition at line 95 of file varray.h.

Referenced by alloc_pdg_node(), analyze_loop_control_flow(), append_root(), assign_pdg_node(), assign_pdg_node_bb(), build_bfs_order(), and single_expr_subscripts_to_loop_subscript().

#define VA_PUSH_P ( t,
a,
e,
 )     do { if ((a)->nelem>=(a)->size) ctrump_varray_realloc_pool(a,p); VA_ELEM(t,a,(a)->nelem++) = (e); } while(0)

Definition at line 119 of file varray.h.

Referenced by append_succs(), build_dom(), find_df(), new_bb(), and test_index().

#define VA_TOP ( t,
 )     VA_ELEM(t,a,(a)->nelem-1)

get top element

Parameters:
t type of element
a array

Definition at line 71 of file varray.h.

Referenced by assign_pdg_node_bb().


Function Documentation

CTRUMP_EXTDEF void* ctrump_varray_close ( struct ctrump_varray a,
struct ctrump_mempool p 
)

free array and copy contents to buffer that is allocated from pool

Parameters:
a array
p memory pool
Returns:
contents of array

Definition at line 101 of file varray.c.

References ctrump_varray_copy(), and ctrump_varray::elements.

Referenced by recog_array_access().

CTRUMP_EXTDEF void* ctrump_varray_copy ( struct ctrump_varray a,
struct ctrump_mempool p 
)

copy to buffer that is allocated from pool

Parameters:
a array
p memory pool
Returns:
contents of array

Definition at line 87 of file varray.c.

References ctrump_mempool_alloc, ctrump_varray::elem_size, ctrump_varray::elements, and ctrump_varray::nelem.

Referenced by analyze_loop_control_flow(), append_nd_subscript(), classify_memop(), ctrump_analyze(), ctrump_varray_close(), expr_subscripts_to_loop_subscript(), and get_distance_vector().

CTRUMP_EXTDEF void ctrump_varray_discard ( struct ctrump_varray a  ) 

CTRUMP_EXTDEF void ctrump_varray_init ( struct ctrump_varray a,
size_t  n,
size_t  es 
)

CTRUMP_EXTDEF void ctrump_varray_init_pool ( struct ctrump_varray a,
size_t  n,
size_t  es,
struct ctrump_mempool pool 
)

CTRUMP_EXTDEF void ctrump_varray_realloc ( struct ctrump_varray a  ) 

resize array

Parameters:
a array

Definition at line 70 of file varray.c.

References ctrump_varray::elem_size, ctrump_varray::elements, and ctrump_varray::size.

CTRUMP_EXTDEF void ctrump_varray_realloc_pool ( struct ctrump_varray a,
struct ctrump_mempool pool 
)


Generated on Tue Mar 31 20:19:24 2009 for ctrump by  doxygen 1.5.6