X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=bucket.c;h=fdbe753d43c1c1dd052deb7f32f2c68ad968851b;hb=9d8563f82cf2569c101282d893bf912ceaea97c0;hp=90e180f912696bf555a12233c4368b789616b4ae;hpb=a9432653be2d89b257422ac8cb48d98bc8f2d376;p=libfirm diff --git a/bucket.c b/bucket.c index 90e180f91..fdbe753d4 100644 --- a/bucket.c +++ b/bucket.c @@ -1,7 +1,36 @@ +/* + * 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) @@ -49,6 +78,11 @@ pbqp_edge *edge_bucket_pop(pbqp_edge_bucket *bucket) 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); @@ -57,6 +91,26 @@ int node_bucket_contains(pbqp_node_bucket bucket, pbqp_node *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); @@ -114,18 +168,14 @@ void node_bucket_remove(pbqp_node_bucket *bucket, pbqp_node *node) 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; }