RSS

(root)/ildjit/libiljitiroptimizer : 1 : src/optimizations_utilities.c

« back to all changes in this revision

Viewing changes to src/optimizations_utilities.c

Speziale Ettore
2009-11-18 09:45:28
Revision ID: ettore@mars-20091118094528-nogwlpufu2snhf6p
Initial import into Bazaar.

Show diffs side-by-side

added added

removed removed

 
1
/*
 
2
 * Copyright (C) 2008  Campanoni Simone
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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
 
17
 */
 
18
#include <ir_method.h>
 
19
#include <jitsystem.h>
 
20
 
 
21
// My headers
 
22
#include <optimizations_utilities.h>
 
23
// End
 
24
 
 
25
#define DIM_BUF 1024
 
26
 
 
27
void internal_callMethodOptimization (ir_optimizer_t *lib, ir_method_t *method, ir_lib_t *irLib, JITUINT32 optimizationKind){
 
28
        XanListItem             *item;
 
29
        ir_optimization_t       *plugin;
 
30
 
 
31
        /* Assertions                                           */
 
32
        assert(lib != NULL);
 
33
        assert(irLib != NULL);
 
34
        assert(method != NULL);
 
35
        assert(lib->plugins != NULL);
 
36
        
 
37
        /* Check if there is one plugin at least                */
 
38
        if (lib->plugins->length(lib->plugins) == 0) return;
 
39
 
 
40
        /* Optimize the method                                  */
 
41
        item            = lib->plugins->first(lib->plugins);
 
42
                        
 
43
        /* Call all the plugins                                 */
 
44
        while (item != NULL){
 
45
                
 
46
                /* Call a plugin                                */
 
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);
 
51
 
 
52
                /* Call the plugin                              */
 
53
                if (plugin->plugin->get_job_kind() == optimizationKind){
 
54
                        plugin->plugin->do_job(method);
 
55
                        break;
 
56
                }
 
57
                        
 
58
                /* Fetch the next plugin                        */
 
59
                item = (lib->plugins)->next(lib->plugins, item);
 
60
        }
 
61
        if (item == NULL) {
 
62
                char    buf[DIM_BUF];
 
63
                snprintf(buf, DIM_BUF, "Optimization %s is missing. ", lib->jobToString(lib, optimizationKind));
 
64
                print_err(buf, 0);
 
65
                abort();
 
66
        }
 
67
 
 
68
        /* Return                                               */
 
69
        return;
 
70
}

Loggerhead 1.17 is a web-based interface for Bazaar branches