+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Buckets for nodes and edges.
+ * @date 30.11.2008
+ * @author Sebastian Buchwald
+ * @version $Id$
+ */
+#include "config.h"
+
#include "adt/array.h"
#include "bucket.h"
#include "pbqp_edge_t.h"
+#include "pbqp_node.h"
#include "pbqp_node_t.h"
int edge_bucket_contains(pbqp_edge_bucket bucket, pbqp_edge *edge)
return edge;
}
+void node_bucket_shrink(pbqp_node_bucket *bucket, unsigned len)
+{
+ ARR_SHRINKLEN(*bucket, (int)len);
+}
+
int node_bucket_contains(pbqp_node_bucket bucket, pbqp_node *node)
{
assert(node);
&& bucket[node->bucket_index] == node;
}
+void node_bucket_copy(pbqp_node_bucket *dst, pbqp_node_bucket src)
+{
+ unsigned src_index;
+ unsigned src_length = node_bucket_get_length(src);
+
+ for (src_index = 0; src_index < src_length; ++src_index) {
+ node_bucket_insert(dst, src[src_index]);
+ }
+}
+
+void node_bucket_update(pbqp *pbqp, pbqp_node_bucket bucket)
+{
+ unsigned index;
+ unsigned length = node_bucket_get_length(bucket);
+
+ for (index = 0; index < length; ++index) {
+ pbqp->nodes[bucket[index]->index] = bucket[index];
+ }
+}
+
void node_bucket_free(pbqp_node_bucket *bucket)
{
DEL_ARR_F(*bucket);
node->bucket_index = UINT_MAX;
}
-pbqp_node_bucket *node_bucket_deep_copy(pbqp_node_bucket bucket)
+void node_bucket_deep_copy(pbqp *pbqp, pbqp_node_bucket *dst, pbqp_node_bucket src)
{
- pbqp_node_bucket *copy;
unsigned bucket_index;
unsigned bucket_length;
- node_bucket_init(copy);
- bucket_length = node_bucket_get_length(bucket);
+ bucket_length = node_bucket_get_length(src);
for (bucket_index = 0; bucket_index < bucket_length; ++bucket_index) {
- node_bucket_insert(copy, pbqp_node_deep_copy(bucket[bucket_index]));
+ node_bucket_insert(dst, pbqp_node_deep_copy(pbqp, *dst, src[bucket_index]));
}
-
- return copy;
}