libFirm

Macros

#define NEW_ARR_F(type, nelts)   ((type *)ir_new_arr_f((nelts), sizeof(type) * (nelts)))
 Creates a flexible array. More...
 
#define NEW_ARR_FZ(type, nelts)   ((type*)memset(NEW_ARR_F(type, (nelts)), 0, sizeof(type) * (nelts)))
 Create a flexible array and null its contents. More...
 
#define DUP_ARR_F(type, arr)   ((type*)memcpy(NEW_ARR_F(type, ARR_LEN((arr))), (arr), sizeof(type) * ARR_LEN((arr))))
 Duplicates an array and returns the new flexible one. More...
 
#define NEW_ARR_D(type, obstack, nelts)
 Creates a dynamic array on an obstack. More...
 
#define NEW_ARR_DZ(type, obstack, nelts)   ((type*)memset(NEW_ARR_D(type, (obstack), (nelts)), 0, sizeof(type) * (nelts)))
 Create a dynamic array on an obstack and null its contents. More...
 
#define DUP_ARR_D(type, obstack, arr)   ((type*)memcpy(NEW_ARR_D(type, (obstack), ARR_LEN((arr))), (arr), sizeof(type) * ARR_LEN ((arr))))
 Duplicates an array and returns the new dynamic one. More...
 
#define ARR_RESIZE(type, arr, n)   ((arr) = (type*) ir_arr_resize((void *)(arr), (n), sizeof(type)))
 Resize a flexible array, allocate more data if needed but do NOT reduce. More...
 
#define ARR_SETLEN(type, arr, n)   ((arr) = (type*) ir_arr_setlen((void *)(arr), (n), sizeof(type) * (n)))
 Resize a flexible array, always reallocate data. More...
 
#define ARR_EXTEND(type, arr, delta)   ARR_RESIZE(type, (arr), ARR_LEN((arr)) + (delta))
 Resize a flexible array by growing it by delta elements. More...
 
#define ARR_EXTO(type, arr, n)
 Resize a flexible array to hold n elements only if it is currently shorter than n. More...
 
#define ARR_APP1(type, arr, elt)   (ARR_EXTEND(type, (arr), 1), (arr)[ARR_LEN((arr))-1] = (elt))
 Append one element to a flexible array. More...
 

Functions

void DEL_ARR_F (void *arr)
 Delete a flexible array. More...
 
static size_t ARR_LEN (void const *const arr)
 Returns the length of an array. More...
 

Detailed Description

Macro Definition Documentation

◆ ARR_APP1

#define ARR_APP1 (   type,
  arr,
  elt 
)    (ARR_EXTEND(type, (arr), 1), (arr)[ARR_LEN((arr))-1] = (elt))

Append one element to a flexible array.

Parameters
typeThe element type of the array.
arrThe array, which must be an lvalue.
eltThe new element, must be of type (type).

Definition at line 276 of file array.h.

◆ ARR_EXTEND

#define ARR_EXTEND (   type,
  arr,
  delta 
)    ARR_RESIZE(type, (arr), ARR_LEN((arr)) + (delta))

Resize a flexible array by growing it by delta elements.

Parameters
typeThe element type of the array.
arrThe array, which must be an lvalue.
deltaThe delta number of elements.
Remarks
This macro may change arr, so update all references!

Definition at line 251 of file array.h.

◆ ARR_EXTO

#define ARR_EXTO (   type,
  arr,
 
)
Value:
do { \
if ((n) >= ARR_LEN(arr)) { ARR_RESIZE(type, arr, (n)+1); } \
} while(0)
static size_t ARR_LEN(void const *const arr)
Returns the length of an array.
Definition: array.h:209
#define ARR_RESIZE(type, arr, n)
Resize a flexible array, allocate more data if needed but do NOT reduce.
Definition: array.h:227

Resize a flexible array to hold n elements only if it is currently shorter than n.

Parameters
typeThe element type of the array.
arrThe array, which must be an lvalue.
nThe new size of the array.
Remarks
This macro may change arr, so update all references!

Definition at line 264 of file array.h.

◆ ARR_RESIZE

#define ARR_RESIZE (   type,
  arr,
 
)    ((arr) = (type*) ir_arr_resize((void *)(arr), (n), sizeof(type)))

Resize a flexible array, allocate more data if needed but do NOT reduce.

Parameters
typeThe element type of the array.
arrThe array, which must be an lvalue.
nThe new size of the array.
Remarks
This macro may change arr, so update all references!

Definition at line 227 of file array.h.

◆ ARR_SETLEN

#define ARR_SETLEN (   type,
  arr,
 
)    ((arr) = (type*) ir_arr_setlen((void *)(arr), (n), sizeof(type) * (n)))

Resize a flexible array, always reallocate data.

Parameters
typeThe element type of the array.
arrThe array, which must be an lvalue.
nThe new size of the array.
Remarks
This macro may change arr, so update all references!

Definition at line 239 of file array.h.

◆ DUP_ARR_D

#define DUP_ARR_D (   type,
  obstack,
  arr 
)    ((type*)memcpy(NEW_ARR_D(type, (obstack), ARR_LEN((arr))), (arr), sizeof(type) * ARR_LEN ((arr))))

Duplicates an array and returns the new dynamic one.

Parameters
typeThe element type of the new array.
obstackAn struct obstack * were the data will be allocated
arrAn array from which the elements will be duplicated

This macro creates a dynamic array of a given type at runtime. The size of the array cannot be changed later.

Returns
A pointer to the dynamic array (can be used as a pointer to the first element of this array).

Definition at line 201 of file array.h.

◆ DUP_ARR_F

#define DUP_ARR_F (   type,
  arr 
)    ((type*)memcpy(NEW_ARR_F(type, ARR_LEN((arr))), (arr), sizeof(type) * ARR_LEN((arr))))

Duplicates an array and returns the new flexible one.

Parameters
typeThe element type of the new array.
arrAn array from which the elements will be duplicated

This macro creates a flexible array of a given type at runtime. The size of the array can be changed later.

Returns
A pointer to the flexible array (can be used as a pointer to the first element of this array).

Definition at line 155 of file array.h.

◆ NEW_ARR_D

#define NEW_ARR_D (   type,
  obstack,
  nelts 
)
Value:
( nelts \
? (type *)ir_new_arr_d((obstack), (nelts), sizeof(type) * (nelts)) \
: (type *)arr_mt_descr.elts)

Creates a dynamic array on an obstack.

Parameters
typeThe element type of the new array.
obstackA struct obstack * were the data will be allocated
neltsA size_t expression evaluating to the number of elements

This macro creates a dynamic array of a given type at runtime. The size of the array cannot be changed later.

Returns
A pointer to the dynamic array (can be used as a pointer to the first element of this array).

Definition at line 177 of file array.h.

◆ NEW_ARR_DZ

#define NEW_ARR_DZ (   type,
  obstack,
  nelts 
)    ((type*)memset(NEW_ARR_D(type, (obstack), (nelts)), 0, sizeof(type) * (nelts)))

Create a dynamic array on an obstack and null its contents.

Definition at line 185 of file array.h.

◆ NEW_ARR_F

#define NEW_ARR_F (   type,
  nelts 
)    ((type *)ir_new_arr_f((nelts), sizeof(type) * (nelts)))

Creates a flexible array.

Parameters
typeThe element type of the new array.
neltsa size_t expression evaluating to the number of elements

This macro creates a flexible array of a given type at runtime. The size of the array can be changed later.

Returns
A pointer to the flexible array (can be used as a pointer to the first element of this array).

Definition at line 134 of file array.h.

◆ NEW_ARR_FZ

#define NEW_ARR_FZ (   type,
  nelts 
)    ((type*)memset(NEW_ARR_F(type, (nelts)), 0, sizeof(type) * (nelts)))

Create a flexible array and null its contents.

Definition at line 140 of file array.h.

Function Documentation

◆ ARR_LEN()

static size_t ARR_LEN ( void const *const  arr)
inlinestatic

Returns the length of an array.

Parameters
arra flexible, dynamic, automatic or static array.

Definition at line 209 of file array.h.

◆ DEL_ARR_F()

void DEL_ARR_F ( void *  arr)

Delete a flexible array.

Parameters
arrThe flexible array.