projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
arm: Simplify confusing condition.
[libfirm]
/
ir
/
ana
/
trouts.c
diff --git
a/ir/ana/trouts.c
b/ir/ana/trouts.c
index
485285f
..
c0740c2
100644
(file)
--- a/
ir/ana/trouts.c
+++ b/
ir/ana/trouts.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1995-20
08
University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-20
11
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
*
* This file is part of libFirm.
*
@@
-22,11
+22,10
@@
* @brief Reverse edges that reference types/entities.
* @author Goetz Lindenmaier
* @date 29.10.2004
* @brief Reverse edges that reference types/entities.
* @author Goetz Lindenmaier
* @date 29.10.2004
- * @version $Id$
*/
#include "config.h"
*/
#include "config.h"
-#include "trouts.h"
+#include "trouts
_t
.h"
#include "array.h"
#include "pmap.h"
#include "array.h"
#include "pmap.h"
@@
-54,12
+53,10
@@
static pmap *type_arraytype_map = NULL;
*/
static ir_node **get_entity_access_array(const ir_entity *ent)
{
*/
static ir_node **get_entity_access_array(const ir_entity *ent)
{
- ir_node **res;
if (!entity_access_map) entity_access_map = pmap_create();
if (!entity_access_map) entity_access_map = pmap_create();
- if (pmap_contains(entity_access_map, ent)) {
- res = (ir_node **) pmap_get(entity_access_map, ent);
- } else {
+ ir_node **res = pmap_get(ir_node*, entity_access_map, ent);
+ if (!res) {
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(entity_access_map, ent, (void *)res);
}
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(entity_access_map, ent, (void *)res);
}
@@
-69,9
+66,7
@@
static ir_node **get_entity_access_array(const ir_entity *ent)
static void set_entity_access_array(const ir_entity *ent, ir_node **accs)
{
static void set_entity_access_array(const ir_entity *ent, ir_node **accs)
{
- ir_node **old = (ir_node**)pmap_get(entity_access_map, ent);
- if (old != accs)
- pmap_insert(entity_access_map, ent, (void *)accs);
+ pmap_insert(entity_access_map, ent, (void *)accs);
}
/**
}
/**
@@
-80,12
+75,10
@@
static void set_entity_access_array(const ir_entity *ent, ir_node **accs)
*/
static ir_node **get_entity_reference_array(const ir_entity *ent)
{
*/
static ir_node **get_entity_reference_array(const ir_entity *ent)
{
- ir_node **res;
if (!entity_reference_map) entity_reference_map = pmap_create();
if (!entity_reference_map) entity_reference_map = pmap_create();
- if (pmap_contains(entity_reference_map, ent)) {
- res = (ir_node **) pmap_get(entity_reference_map, ent);
- } else {
+ ir_node **res = pmap_get(ir_node*, entity_reference_map, ent);
+ if (!res) {
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(entity_reference_map, ent, (void *)res);
}
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(entity_reference_map, ent, (void *)res);
}
@@
-95,9
+88,7
@@
static ir_node **get_entity_reference_array(const ir_entity *ent)
static void set_entity_reference_array(const ir_entity *ent, ir_node **refs)
{
static void set_entity_reference_array(const ir_entity *ent, ir_node **refs)
{
- ir_node **old = (ir_node**)pmap_get(entity_reference_map, ent);
- if (old != refs)
- pmap_insert(entity_reference_map, ent, (void *)refs);
+ pmap_insert(entity_reference_map, ent, (void *)refs);
}
/**
}
/**
@@
-106,12
+97,10
@@
static void set_entity_reference_array(const ir_entity *ent, ir_node **refs)
*/
static ir_node **get_type_alloc_array(const ir_type *tp)
{
*/
static ir_node **get_type_alloc_array(const ir_type *tp)
{
- ir_node **res;
if (!type_alloc_map) type_alloc_map = pmap_create();
if (!type_alloc_map) type_alloc_map = pmap_create();
- if (pmap_contains(type_alloc_map, tp)) {
- res = (ir_node **) pmap_get(type_alloc_map, tp);
- } else {
+ ir_node **res = pmap_get(ir_node*, type_alloc_map, tp);
+ if (!res) {
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(type_alloc_map, tp, (void *)res);
}
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(type_alloc_map, tp, (void *)res);
}
@@
-121,9
+110,7
@@
static ir_node **get_type_alloc_array(const ir_type *tp)
static void set_type_alloc_array(const ir_type *tp, ir_node **alls)
{
static void set_type_alloc_array(const ir_type *tp, ir_node **alls)
{
- ir_node **old = (ir_node**)pmap_get(type_alloc_map, tp);
- if (old != alls)
- pmap_insert(type_alloc_map, tp, (void *)alls);
+ pmap_insert(type_alloc_map, tp, (void *)alls);
}
/**
}
/**
@@
-132,12
+119,10
@@
static void set_type_alloc_array(const ir_type *tp, ir_node **alls)
*/
static ir_node **get_type_cast_array(const ir_type *tp)
{
*/
static ir_node **get_type_cast_array(const ir_type *tp)
{
- ir_node **res;
if (!type_cast_map) type_cast_map = pmap_create();
if (!type_cast_map) type_cast_map = pmap_create();
- if (pmap_contains(type_cast_map, tp)) {
- res = (ir_node **) pmap_get(type_cast_map, tp);
- } else {
+ ir_node **res = pmap_get(ir_node*, type_cast_map, tp);
+ if (!res) {
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(type_cast_map, tp, (void *)res);
}
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(type_cast_map, tp, (void *)res);
}
@@
-146,9
+131,7
@@
static ir_node **get_type_cast_array(const ir_type *tp)
static void set_type_cast_array(const ir_type *tp, ir_node **alls)
{
static void set_type_cast_array(const ir_type *tp, ir_node **alls)
{
- ir_node **old = (ir_node**)pmap_get(type_cast_map, tp);
- if (old != alls)
- pmap_insert(type_cast_map, tp, (void *)alls);
+ pmap_insert(type_cast_map, tp, (void *)alls);
}
/**
}
/**
@@
-157,12
+140,10
@@
static void set_type_cast_array(const ir_type *tp, ir_node **alls)
*/
static ir_type **get_type_pointertype_array(const ir_type *tp)
{
*/
static ir_type **get_type_pointertype_array(const ir_type *tp)
{
- ir_type **res;
if (!type_pointertype_map) type_pointertype_map = pmap_create();
if (!type_pointertype_map) type_pointertype_map = pmap_create();
- if (pmap_contains(type_pointertype_map, tp)) {
- res = (ir_type **) pmap_get(type_pointertype_map, tp);
- } else {
+ ir_type **res = pmap_get(ir_type*, type_pointertype_map, tp);
+ if (!res) {
res = NEW_ARR_F(ir_type *, 0);
pmap_insert(type_pointertype_map, tp, (void *)res);
}
res = NEW_ARR_F(ir_type *, 0);
pmap_insert(type_pointertype_map, tp, (void *)res);
}
@@
-172,9
+153,7
@@
static ir_type **get_type_pointertype_array(const ir_type *tp)
static void set_type_pointertype_array(const ir_type *tp, ir_type **pts)
{
static void set_type_pointertype_array(const ir_type *tp, ir_type **pts)
{
- ir_type **old = (ir_type**)pmap_get(type_pointertype_map, tp);
- if (old != pts)
- pmap_insert(type_pointertype_map, tp, (void *)pts);
+ pmap_insert(type_pointertype_map, tp, (void *)pts);
}
/**
}
/**
@@
-183,12
+162,10
@@
static void set_type_pointertype_array(const ir_type *tp, ir_type **pts)
*/
static ir_type **get_type_arraytype_array(const ir_type *tp)
{
*/
static ir_type **get_type_arraytype_array(const ir_type *tp)
{
- ir_type **res;
if (!type_arraytype_map) type_arraytype_map = pmap_create();
if (!type_arraytype_map) type_arraytype_map = pmap_create();
- if (pmap_contains(type_arraytype_map, tp)) {
- res = (ir_type **) pmap_get(type_arraytype_map, tp);
- } else {
+ ir_type **res = pmap_get(ir_type*, type_arraytype_map, tp);
+ if (!res) {
res = NEW_ARR_F(ir_type *, 0);
pmap_insert(type_arraytype_map, tp, (void *)res);
}
res = NEW_ARR_F(ir_type *, 0);
pmap_insert(type_arraytype_map, tp, (void *)res);
}
@@
-198,9
+175,7
@@
static ir_type **get_type_arraytype_array(const ir_type *tp)
static void set_type_arraytype_array(const ir_type *tp, ir_type **pts)
{
static void set_type_arraytype_array(const ir_type *tp, ir_type **pts)
{
- ir_type **old = (ir_type**)pmap_get(type_arraytype_map, tp);
- if (old != pts)
- pmap_insert(type_arraytype_map, tp, (void *)pts);
+ pmap_insert(type_arraytype_map, tp, (void *)pts);
}
/*------------------------------------------------------------------*/
}
/*------------------------------------------------------------------*/
@@
-213,7
+188,7
@@
static void set_type_arraytype_array(const ir_type *tp, ir_type **pts)
/* Access routines for entities */
/**------------------------------------------------------------------*/
/* Access routines for entities */
/**------------------------------------------------------------------*/
-
in
t get_entity_n_accesses(const ir_entity *ent)
+
size_
t get_entity_n_accesses(const ir_entity *ent)
{
ir_node ** accs;
{
ir_node ** accs;
@@
-223,11
+198,11
@@
int get_entity_n_accesses(const ir_entity *ent)
return ARR_LEN(accs);
}
return ARR_LEN(accs);
}
-ir_node *get_entity_access(const ir_entity *ent,
in
t pos)
+ir_node *get_entity_access(const ir_entity *ent,
size_
t pos)
{
ir_node ** accs;
{
ir_node ** accs;
- assert(
0 <= pos &&
pos < get_entity_n_accesses(ent));
+ assert(pos < get_entity_n_accesses(ent));
accs = get_entity_access_array(ent);
return accs[pos];
accs = get_entity_access_array(ent);
return accs[pos];
@@
-260,7
+235,7
@@
void set_entity_access(const ir_entity *ent, int pos, ir_node *n)
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
-
in
t get_entity_n_references(const ir_entity *ent)
+
size_
t get_entity_n_references(const ir_entity *ent)
{
ir_node ** refs;
{
ir_node ** refs;
@@
-270,11
+245,11
@@
int get_entity_n_references(const ir_entity *ent)
return ARR_LEN(refs);
}
return ARR_LEN(refs);
}
-ir_node *get_entity_reference(const ir_entity *ent,
in
t pos)
+ir_node *get_entity_reference(const ir_entity *ent,
size_
t pos)
{
ir_node ** refs;
{
ir_node ** refs;
- assert(
0 <= pos &&
pos < get_entity_n_references(ent));
+ assert( pos < get_entity_n_references(ent));
refs = get_entity_reference_array(ent);
return refs[pos];
refs = get_entity_reference_array(ent);
return refs[pos];
@@
-310,7
+285,7
@@
void set_entity_reference(const ir_entity *ent, int pos, ir_node *n)
/**------------------------------------------------------------------*/
/* Number of Alloc nodes that create an instance of this type */
/**------------------------------------------------------------------*/
/* Number of Alloc nodes that create an instance of this type */
-
in
t get_type_n_allocs(const ir_type *tp)
+
size_
t get_type_n_allocs(const ir_type *tp)
{
ir_node **allocs;
{
ir_node **allocs;
@@
-321,10
+296,10
@@
int get_type_n_allocs(const ir_type *tp)
}
/* Alloc node that creates an instance of this type */
}
/* Alloc node that creates an instance of this type */
-ir_node *get_type_alloc(const ir_type *tp,
in
t pos)
+ir_node *get_type_alloc(const ir_type *tp,
size_
t pos)
{
ir_node **allocs;
{
ir_node **allocs;
- assert(
0 <= pos &&
pos < get_type_n_allocs(tp));
+ assert( pos < get_type_n_allocs(tp));
allocs = get_type_alloc_array(tp);
return allocs[pos];
allocs = get_type_alloc_array(tp);
return allocs[pos];
@@
-356,7
+331,7
@@
void set_type_alloc(const ir_type *tp, int pos, ir_node *n)
#endif
/* Number of Cast nodes that create an instance of this type */
#endif
/* Number of Cast nodes that create an instance of this type */
-
in
t get_type_n_casts(const ir_type *tp)
+
size_
t get_type_n_casts(const ir_type *tp)
{
ir_node **casts;
{
ir_node **casts;
@@
-367,10
+342,10
@@
int get_type_n_casts(const ir_type *tp)
}
}
-
in
t get_class_n_upcasts(const ir_type *clss)
+
size_
t get_class_n_upcasts(const ir_type *clss)
{
{
-
in
t i, n_casts = get_type_n_casts(clss);
-
in
t n_instances = 0;
+
size_
t i, n_casts = get_type_n_casts(clss);
+
size_
t n_instances = 0;
for (i = 0; i < n_casts; ++i) {
ir_node *cast = get_type_cast(clss, i);
if (is_Cast_upcast(cast))
for (i = 0; i < n_casts; ++i) {
ir_node *cast = get_type_cast(clss, i);
if (is_Cast_upcast(cast))
@@
-379,10
+354,10
@@
int get_class_n_upcasts(const ir_type *clss)
return n_instances;
}
return n_instances;
}
-
in
t get_class_n_downcasts(const ir_type *clss)
+
size_
t get_class_n_downcasts(const ir_type *clss)
{
{
-
in
t i, n_casts = get_type_n_casts(clss);
-
in
t n_instances = 0;
+
size_
t i, n_casts = get_type_n_casts(clss);
+
size_
t n_instances = 0;
for (i = 0; i < n_casts; ++i) {
ir_node *cast = get_type_cast(clss, i);
if (is_Cast_downcast(cast))
for (i = 0; i < n_casts; ++i) {
ir_node *cast = get_type_cast(clss, i);
if (is_Cast_downcast(cast))
@@
-391,11
+366,10
@@
int get_class_n_downcasts(const ir_type *clss)
return n_instances;
}
return n_instances;
}
-/* Cast node that creates an instance of this type */
-ir_node *get_type_cast(const ir_type *tp, int pos)
+ir_node *get_type_cast(const ir_type *tp, size_t pos)
{
ir_node **casts;
{
ir_node **casts;
- assert(
0 <= pos &&
pos < get_type_n_casts(tp));
+ assert(pos < get_type_n_casts(tp));
casts = get_type_cast_array(tp);
return casts[pos];
casts = get_type_cast_array(tp);
return casts[pos];
@@
-414,11
+388,11
@@
void add_type_cast(const ir_type *tp, ir_node *n)
}
#if 0
}
#if 0
-void set_type_cast(const ir_type *tp,
in
t pos, ir_node *n)
+void set_type_cast(const ir_type *tp,
size_
t pos, ir_node *n)
{
ir_node **casts;
{
ir_node **casts;
- assert(
0 <= pos &&
pos < get_type_n_casts(tp));
+ assert(pos < get_type_n_casts(tp));
assert(n && is_ir_node(n));
casts = get_type_cast_array(tp);
assert(n && is_ir_node(n));
casts = get_type_cast_array(tp);
@@
-428,7
+402,7
@@
void set_type_cast(const ir_type *tp, int pos, ir_node *n)
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
-
in
t get_type_n_pointertypes_to(const ir_type *tp)
+
size_
t get_type_n_pointertypes_to(const ir_type *tp)
{
ir_type ** pts;
{
ir_type ** pts;
@@
-438,11
+412,11
@@
int get_type_n_pointertypes_to(const ir_type *tp)
return ARR_LEN(pts);
}
return ARR_LEN(pts);
}
-ir_type *get_type_pointertype_to(const ir_type *tp,
in
t pos)
+ir_type *get_type_pointertype_to(const ir_type *tp,
size_
t pos)
{
ir_type ** pts;
{
ir_type ** pts;
- assert(
0 <= pos &&
pos < get_type_n_pointertypes_to(tp));
+ assert(pos < get_type_n_pointertypes_to(tp));
pts = get_type_pointertype_array(tp);
return pts[pos];
pts = get_type_pointertype_array(tp);
return pts[pos];
@@
-475,7
+449,7
@@
void set_type_pointertype_to(const ir_type *tp, int pos, ir_type *ptp)
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
-
in
t get_type_n_arraytypes_of(const ir_type *tp)
+
size_
t get_type_n_arraytypes_of(const ir_type *tp)
{
ir_type ** pts;
{
ir_type ** pts;
@@
-485,11
+459,11
@@
int get_type_n_arraytypes_of(const ir_type *tp)
return ARR_LEN(pts);
}
return ARR_LEN(pts);
}
-ir_type *get_type_arraytype_of(const ir_type *tp,
in
t pos)
+ir_type *get_type_arraytype_of(const ir_type *tp,
size_
t pos)
{
ir_type ** pts;
{
ir_type ** pts;
- assert(
0 <= pos &&
pos < get_type_n_arraytypes_of(tp));
+ assert(pos < get_type_n_arraytypes_of(tp));
pts = get_type_arraytype_array(tp);
return pts[pos];
pts = get_type_arraytype_array(tp);
return pts[pos];
@@
-604,8
+578,10
@@
static void chain_accesses(ir_node *n, void *env)
} else if (is_SymConst_addr_ent(n)) {
add_entity_reference(get_SymConst_entity(n), n);
return;
} else if (is_SymConst_addr_ent(n)) {
add_entity_reference(get_SymConst_entity(n), n);
return;
- } else if (is_memop(n)) {
- addr = get_memop_ptr(n);
+ } else if (is_Store(n)) {
+ addr = get_Store_ptr(n);
+ } else if (is_Load(n)) {
+ addr = get_Load_ptr(n);
} else if (is_Call(n)) {
addr = get_Call_ptr(n);
if (! is_Sel(addr)) return; /* Sels before Calls mean a Load / polymorphic Call. */
} else if (is_Call(n)) {
addr = get_Call_ptr(n);
if (! is_Sel(addr)) return; /* Sels before Calls mean a Load / polymorphic Call. */
@@
-636,37
+612,25
@@
static void chain_types(ir_type *tp)
}
}
}
}
-irg_outs_state get_trouts_state(void)
-{
- return irp->trouts_state;
-}
-
-void set_trouts_inconsistent(void)
-{
- if (irp->trouts_state == outs_consistent)
- irp->trouts_state = outs_inconsistent;
-}
-
-/* compute the trouts data structures. */
void compute_trouts(void)
{
void compute_trouts(void)
{
-
in
t i;
+
size_
t i;
free_trouts();
init_trouts();
/* Compute outs for IR nodes. */
free_trouts();
init_trouts();
/* Compute outs for IR nodes. */
- for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- irg_walk_graph(get_irp_irg(i), NULL, chain_accesses, NULL);
+ for (i = get_irp_n_irgs(); i > 0;) {
+ ir_graph *irg = get_irp_irg(--i);
+ irg_walk_graph(irg, NULL, chain_accesses, NULL);
}
walk_const_code(NULL, chain_accesses, NULL);
/* Compute outs for types */
}
walk_const_code(NULL, chain_accesses, NULL);
/* Compute outs for types */
- for (i = get_irp_n_types() - 1; i >= 0; --i) {
- chain_types(get_irp_type(i));
+ for (i = get_irp_n_types(); i > 0;) {
+ ir_type *type = get_irp_type(--i);
+ chain_types(type);
}
}
-
- irp->trouts_state = outs_consistent;
}
void free_trouts(void)
}
void free_trouts(void)
@@
-736,6
+700,4
@@
void free_trouts(void)
pmap_destroy(type_arraytype_map);
type_arraytype_map = NULL;
}
pmap_destroy(type_arraytype_map);
type_arraytype_map = NULL;
}
-
- irp->trouts_state = outs_none;
}
}