summaryrefslogtreecommitdiffhomepage
path: root/ir/be/becopyilp2.c
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2014-04-07 15:22:15 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2014-04-08 15:56:28 +0200
commitc565b0f57330f3b16ebaca39358131e5558e8b71 (patch)
treedeb592f1be3c45be6a6c8f518f2ba8ead192b190 /ir/be/becopyilp2.c
parent162fe0bb4ab6f41f0cc0792df84ea8b3fff20abf (diff)
becopyilp2: Factorise common code.
Also remove useless pointer to int casts.
Diffstat (limited to 'ir/be/becopyilp2.c')
-rw-r--r--ir/be/becopyilp2.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/ir/be/becopyilp2.c b/ir/be/becopyilp2.c
index d9bb6f6..142d459 100644
--- a/ir/be/becopyilp2.c
+++ b/ir/be/becopyilp2.c
@@ -277,19 +277,24 @@ static int compare_edge_t(const void *k1, const void *k2, size_t size)
return ! (e1->n1 == e2->n1 && e1->n2 == e2->n2);
}
+static void init_edge(edge_t *const edge, ir_node *const n1, ir_node *const n2)
+{
+ if (n1 < n2) {
+ edge->n1 = n1;
+ edge->n2 = n2;
+ } else {
+ edge->n1 = n2;
+ edge->n2 = n1;
+ }
+}
+
#define HASH_EDGE(e) (hash_irn((e)->n1) ^ hash_irn((e)->n2))
static inline edge_t *add_edge(set *edges, ir_node *n1, ir_node *n2, size_t *counter)
{
edge_t new_edge;
+ init_edge(&new_edge, n1, n2);
- if (PTR_TO_INT(n1) < PTR_TO_INT(n2)) {
- new_edge.n1 = n1;
- new_edge.n2 = n2;
- } else {
- new_edge.n1 = n2;
- new_edge.n2 = n1;
- }
(*counter)++;
return set_insert(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
}
@@ -297,29 +302,17 @@ static inline edge_t *add_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou
static inline edge_t *find_edge(set *edges, ir_node *n1, ir_node *n2)
{
edge_t new_edge;
+ init_edge(&new_edge, n1, n2);
- if (PTR_TO_INT(n1) < PTR_TO_INT(n2)) {
- new_edge.n1 = n1;
- new_edge.n2 = n2;
- } else {
- new_edge.n1 = n2;
- new_edge.n2 = n1;
- }
return set_find(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
}
static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *counter)
{
- edge_t new_edge, *e;
+ edge_t new_edge;
+ init_edge(&new_edge, n1, n2);
- if (PTR_TO_INT(n1) < PTR_TO_INT(n2)) {
- new_edge.n1 = n1;
- new_edge.n2 = n2;
- } else {
- new_edge.n1 = n2;
- new_edge.n2 = n1;
- }
- e = set_find(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
+ edge_t *const e = set_find(edge_t, edges, &new_edge, sizeof(new_edge), HASH_EDGE(&new_edge));
if (e) {
e->n1 = NULL;
e->n2 = NULL;