Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
b8f889ed
Commit
b8f889ed
authored
Apr 19, 2011
by
Matthias Braun
Browse files
hide cdep struct behind getter, make it more robust with an additional skip_Id
parent
04302ff9
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/libfirm/cdep.h
View file @
b8f889ed
...
...
@@ -29,20 +29,18 @@
#include "firm_types.h"
#include "begin.h"
/**
* An entry in the control dependence list.
*/
struct
ir_cdep
{
ir_node
*
node
;
/**< A node on which the current block is control dependent on. */
ir_cdep
*
next
;
/**< Link to the next one if any. */
};
/** Compute the control dependence graph for a graph. */
FIRM_API
void
compute_cdep
(
ir_graph
*
irg
);
/** Free the control dependence info. */
FIRM_API
void
free_cdep
(
ir_graph
*
irg
);
/** Return control dependent block */
FIRM_API
ir_node
*
get_cdep_node
(
const
ir_cdep
*
cdep
);
/** Get next entry in a list of cdeps */
FIRM_API
ir_cdep
*
get_cdep_next
(
const
ir_cdep
*
cdep
);
/**
* Return a list of all control dependences of a block.
*/
...
...
ir/ana/cdep.c
View file @
b8f889ed
...
...
@@ -32,7 +32,7 @@
#include "pmap.h"
#include "obst.h"
#include "xmalloc.h"
#include "cdep.h"
#include "cdep
_t
.h"
#include "irprintf.h"
#include "irdump.h"
...
...
@@ -43,14 +43,27 @@ typedef struct cdep_info {
static
cdep_info
*
cdep_data
;
ir_node
*
(
get_cdep_node
)(
const
ir_cdep
*
cdep
)
{
return
_get_cdep_node
(
cdep
);
}
ir_cdep
*
(
get_cdep_next
)(
const
ir_cdep
*
cdep
)
{
return
_get_cdep_next
(
cdep
);
}
/* Return a list of all control dependences of a block. */
ir_cdep
*
find_cdep
(
const
ir_node
*
block
)
{
assert
(
is_Block
(
block
));
return
(
ir_cdep
*
)
pmap_get
(
cdep_data
->
cdep_map
,
block
);
}
void
exchange_cdep
(
ir_node
*
old
,
const
ir_node
*
nw
)
{
ir_cdep
*
cdep
=
find_cdep
(
nw
);
assert
(
is_Block
(
old
));
pmap_insert
(
cdep_data
->
cdep_map
,
old
,
cdep
);
}
...
...
@@ -61,6 +74,7 @@ static void add_cdep(ir_node *node, ir_node *dep_on)
{
ir_cdep
*
dep
=
find_cdep
(
node
);
assert
(
is_Block
(
dep_on
));
if
(
dep
==
NULL
)
{
ir_cdep
*
newdep
=
OALLOC
(
&
cdep_data
->
obst
,
ir_cdep
);
...
...
@@ -71,7 +85,7 @@ static void add_cdep(ir_node *node, ir_node *dep_on)
ir_cdep
*
newdep
;
for
(;;)
{
if
(
dep
->
node
==
dep_on
)
return
;
if
(
get_c
dep
_
node
(
dep
)
==
dep_on
)
return
;
if
(
dep
->
next
==
NULL
)
break
;
dep
=
dep
->
next
;
}
...
...
@@ -189,7 +203,7 @@ int is_cdep_on(const ir_node *dependee, const ir_node *candidate)
const
ir_cdep
*
dep
;
for
(
dep
=
find_cdep
(
dependee
);
dep
!=
NULL
;
dep
=
dep
->
next
)
{
if
(
dep
->
node
==
candidate
)
return
1
;
if
(
get_c
dep
_
node
(
dep
)
==
candidate
)
return
1
;
}
return
0
;
}
...
...
@@ -198,7 +212,7 @@ ir_node *get_unique_cdep(const ir_node *block)
{
ir_cdep
*
cdep
=
find_cdep
(
block
);
return
cdep
!=
NULL
&&
cdep
->
next
==
NULL
?
cdep
->
node
:
NULL
;
return
cdep
!=
NULL
&&
cdep
->
next
==
NULL
?
get_
cdep
_
node
(
cdep
)
:
NULL
;
}
int
has_multiple_cdep
(
const
ir_node
*
block
)
...
...
ir/ana/cdep_t.h
0 → 100644
View file @
b8f889ed
/*
* 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 control dependence analysis
* @author Christoph Mallon
* @version $Id$
*/
#ifndef FIRM_ANA_CDEP_T_H
#define FIRM_ANA_CDEP_T_H
#include "cdep.h"
/**
* An entry in the control dependence list.
*/
struct
ir_cdep
{
ir_node
*
node
;
/**< A node on which the current block is control dependent on. */
ir_cdep
*
next
;
/**< Link to the next one if any. */
};
static
inline
ir_node
*
_get_cdep_node
(
const
ir_cdep
*
cdep
)
{
return
skip_Id
(
cdep
->
node
);
}
static
inline
ir_cdep
*
_get_cdep_next
(
const
ir_cdep
*
cdep
)
{
return
cdep
->
next
;
}
#define get_cdep_node(cdep) _get_cdep_node(cdep)
#define get_cdep_next(cdep) _get_cdep_next(cdep)
#endif
ir/opt/ifconv.c
View file @
b8f889ed
...
...
@@ -31,7 +31,7 @@
#include "iroptimize.h"
#include "obst.h"
#include "irnode_t.h"
#include "cdep.h"
#include "cdep
_t
.h"
#include "ircons.h"
#include "irgmod.h"
#include "irgopt.h"
...
...
@@ -288,8 +288,8 @@ restart:
ir_cdep
*
cdep
;
pred0
=
get_Block_cfgpred_block
(
block
,
i
);
for
(
cdep
=
find_cdep
(
pred0
);
cdep
!=
NULL
;
cdep
=
cdep
->
next
)
{
const
ir_node
*
dependency
=
cdep
->
node
;
for
(
cdep
=
find_cdep
(
pred0
);
cdep
!=
NULL
;
cdep
=
get_
cdep
_
next
(
cdep
)
)
{
const
ir_node
*
dependency
=
get_
cdep
_
node
(
cdep
)
;
ir_node
*
projx0
=
walk_to_projx
(
pred0
,
dependency
);
ir_node
*
cond
;
int
j
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment