2
* Copyright (C) 2008 Campanoni Simone
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
#include <ir_method.h>
19
#include <jitsystem.h>
22
#include <optimizations_utilities.h>
27
void internal_callMethodOptimization (ir_optimizer_t *lib, ir_method_t *method, ir_lib_t *irLib, JITUINT32 optimizationKind){
29
ir_optimization_t *plugin;
33
assert(irLib != NULL);
34
assert(method != NULL);
35
assert(lib->plugins != NULL);
37
/* Check if there is one plugin at least */
38
if (lib->plugins->length(lib->plugins) == 0) return;
40
/* Optimize the method */
41
item = lib->plugins->first(lib->plugins);
43
/* Call all the plugins */
47
plugin = (ir_optimization_t *)(lib->plugins)->data(lib->plugins, item);
48
assert(plugin != NULL);
49
assert(plugin->plugin != NULL);
50
assert(plugin->plugin->do_job != NULL);
53
if (plugin->plugin->get_job_kind() == optimizationKind){
54
plugin->plugin->do_job(method);
58
/* Fetch the next plugin */
59
item = (lib->plugins)->next(lib->plugins, item);
63
snprintf(buf, DIM_BUF, "Optimization %s is missing. ", lib->jobToString(lib, optimizationKind));