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
917ab466
Commit
917ab466
authored
Oct 26, 2011
by
Andreas Zwinkau
Browse files
Add remove_tuples function
parent
2e9fdf88
Changes
2
Show whitespace changes
Inline
Side-by-side
include/libfirm/irgopt.h
View file @
917ab466
...
...
@@ -72,6 +72,15 @@ FIRM_API void remove_unreachable_code(ir_graph *irg);
*/
FIRM_API
int
remove_bads
(
ir_graph
*
irg
);
/**
* Removes all Tuple nodes from a graph.
*
* @param irg The graph to be optimized.
*
* @return non-zero if at least one Tuple was removed, otherwise 0
*/
FIRM_API
int
remove_tuples
(
ir_graph
*
irg
);
/**
* Creates an ir_graph pass for optimize_graph_df().
*
...
...
ir/ir/rm_tuples.c
0 → 100644
View file @
917ab466
/*
* Copyright (C) 2011 Karlsruhe Institute of Technology. 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.
*/
/**
* @brief Remove all Tuple nodes from ir graph
* @author Andreas Zwinkau
*/
#include "config.h"
#include "irnode_t.h"
#include "irgopt.h"
#include "irgmod.h"
#include "irgwalk.h"
#include "irtools.h"
#include "irgopt.h"
/** Transforms:
* a
* |
* Tuple
* | =>
* Proj x a
*/
static
void
exchange_tuple_projs
(
ir_node
*
node
,
void
*
env
)
{
bool
*
changed
=
(
bool
*
)
env
;
ir_node
*
pred
;
int
proj
;
if
(
!
is_Proj
(
node
))
return
;
pred
=
get_Proj_pred
(
node
);
proj
=
get_Proj_proj
(
node
);
if
(
!
is_Tuple
(
pred
))
return
;
pred
=
get_Tuple_pred
(
pred
,
proj
);
exchange
(
node
,
pred
);
*
changed
=
true
;
}
/* Remove Tuple nodes from an ir graph.
*
* Postcondition: No Tuple nodes.
*/
int
remove_tuples
(
ir_graph
*
irg
)
{
bool
changed
=
0
;
irg_walk_graph
(
irg
,
exchange_tuple_projs
,
NULL
,
&
changed
);
return
changed
;
}
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