#ifndef FIRM_ADT_PQUEUE_H
#define FIRM_ADT_PQUEUE_H
-typedef struct _pqueue_t pqueue;
+typedef struct _pqueue_t pqueue_t;
/**
* Creates a new priority queue.
* @return A priority queue of initial length 0.
*/
-pqueue *new_pqueue(void);
+pqueue_t *new_pqueue(void);
/**
* Frees all memory allocated by the priority queue.
* @param q The priority queue to destroy.
*/
-void del_pqueue(pqueue *q);
+void del_pqueue(pqueue_t *q);
/**
* Inserts a new element into a priority queue.
* @param data The actual data which should be stored in the queue.
* @param key The priority for the data.
*/
-void pqueue_put(pqueue *q, void *data, int key);
+void pqueue_put(pqueue_t *q, void *data, int key);
/**
* Returns and removes the first element, ie. that one with the highest priority, from the queue.
* @param q The priority queue.
* @return The first element of the queue. Asserts if queue is empty.
*/
-void *pqueue_get(pqueue *q);
+void *pqueue_pop_front(pqueue_t *q);
/**
* Get the length of the priority queue.
* @param q The priority queue.
* @return The length of the queue.
*/
-int pqueue_length(pqueue *q);
+int pqueue_length(const pqueue_t *q);
/**
* Returns true if queue is empty.
* @param q The priority queue.
* @return 1 if the queue is empty, 0 otherwise.
*/
-int pqueue_empty(pqueue *q);
+int pqueue_empty(const pqueue_t *q);
#endif
* Enforces the heap characteristics if the queue
* starting from element at position @p pos.
*/
-static void pqueue_heapify(pqueue *q, unsigned pos) {
+static void pqueue_heapify(pqueue_t *q, unsigned pos) {
unsigned len = ARR_LEN(q->elems);
while (pos * 2 < len) {
/**
* Sifts up a newly inserted element at position @p pos.
*/
-static void pqueue_sift_up(pqueue *q, unsigned pos) {
+static void pqueue_sift_up(pqueue_t *q, unsigned pos) {
while(q->elems[pos].key > q->elems[pos / 2].key) {
pqueue_el_t tmp;
}
}
-/**
- * Creates a new priority queue.
- * @return A priority queue of initial length 0.
- */
-pqueue *new_pqueue(void) {
- pqueue *res = xmalloc(sizeof(*res));
+pqueue_t *new_pqueue(void) {
+ pqueue_t *res = xmalloc(sizeof(*res));
res->elems = NEW_ARR_F(pqueue_el_t, 0);
return res;
}
-/**
- * Frees all memory allocated by the priority queue.
- * @param q The priority queue to destroy.
- */
-void del_pqueue(pqueue *q) {
+void del_pqueue(pqueue_t *q) {
DEL_ARR_F(q->elems);
free(q);
}
-/**
- * Inserts a new element into a priority queue.
- * @param q The priority queue the element should be inserted to.
- * @param data The actual data which should be stored in the queue.
- * @param key The priority for the data.
- */
-void pqueue_put(pqueue *q, void *data, int key) {
+void pqueue_put(pqueue_t *q, void *data, int key) {
pqueue_el_t el;
el.data = data;
pqueue_sift_up(q, ARR_LEN(q->elems) - 1);
}
-/**
- * Returns and removes the first element, ie. that one with the highest priority, from the queue.
- * @param q The priority queue.
- * @return The first element of the queue. Asserts if queue is empty.
- */
-void *pqueue_get(pqueue *q) {
+void *pqueue_pop_front(pqueue_t *q) {
switch(ARR_LEN(q->elems)) {
case 0:
assert(0 && "Attempt to retrieve element from empty priority queue.");
}
}
-/**
- * Get the length of the priority queue.
- * @param q The priority queue.
- * @return The length of the queue.
- */
-int pqueue_length(pqueue *q) {
+int pqueue_length(const pqueue_t *q) {
return ARR_LEN(q->elems);
}
-/**
- * Returns true if queue is empty.
- * @param q The priority queue.
- * @return 1 if the queue is empty, 0 otherwise.
- */
-int pqueue_empty(pqueue *q) {
+int pqueue_empty(const pqueue_t *q) {
return ARR_LEN(q->elems) == 0;
}
int k; /**< number of non-ignore registers in class */
bitset_t *ignore_regs; /**< set containing all global ignore registers */
ir_phase ph; /**< phase object holding data for nodes */
- pqueue *chunks; /**< priority queue for chunks */
+ pqueue_t *chunks; /**< priority queue for chunks */
pset *chunkset; /**< set holding all chunks */
be_ifg_t *ifg; /**< the interference graph */
const arch_env_t *aenv; /**< the arch environment */
static __attribute__((unused)) void chunk_order_nodes(co_mst_env_t *env, aff_chunk_t *chunk)
{
- pqueue *grow = new_pqueue();
+ pqueue_t *grow = new_pqueue();
const ir_node *max_node = NULL;
int max_weight = 0;
int i;
bitset_remv_irn(visited, max_node);
i = 0;
while (!pqueue_empty(grow)) {
- ir_node *irn = pqueue_get(grow);
+ ir_node *irn = pqueue_pop_front(grow);
affinity_node_t *an = get_affinity_info(env->co, irn);
neighb_t *neigh;
/* color chunks as long as there are some */
while (! pqueue_empty(mst_env.chunks)) {
- aff_chunk_t *chunk = pqueue_get(mst_env.chunks);
+ aff_chunk_t *chunk = pqueue_pop_front(mst_env.chunks);
color_aff_chunk(&mst_env, chunk);
DB((dbg, LEVEL_4, "<<<====== Coloring chunk (%u) done\n", chunk->id));