we don't need no stinking selfs
[libfirm] / ir / be / bemachine.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Abstract machine interface.
23  * @author      Christian Wuerdig
24  * @date        23.10.2006
25  * @version     $Id$
26  */
27 #ifndef FIRM_BE_BEMACHINE_H
28 #define FIRM_BE_BEMACHINE_H
29
30 typedef struct _be_execution_unit_type_t be_execution_unit_type_t;
31 typedef struct _be_execution_unit_t      be_execution_unit_t;
32 typedef struct _be_machine_t             be_machine_t;
33
34 struct _be_execution_unit_t {
35         be_execution_unit_type_t *tp;
36         const char               *name;
37 };
38
39 struct _be_execution_unit_type_t {
40         unsigned            n_units;
41         unsigned            ports_per_unit;
42         const char          *name;
43         be_execution_unit_t *units;
44 };
45
46 struct _be_machine_t {
47         unsigned                 bundle_size;
48         unsigned                 bundels_per_cycle;
49         unsigned                 n_unit_types;
50         be_execution_unit_type_t *unit_types;
51 };
52
53 extern be_execution_unit_t be_machine_execution_units_DUMMY[1];
54
55 /**
56  * Initialize generic dummy unit.
57  */
58 void be_machine_init_dummy_unit(void);
59
60 /**
61  * Returns the generic dummy unit.
62  */
63 be_execution_unit_t *be_machine_get_dummy_unit(void);
64
65 /**
66  * Check if given unit is the generic dummy unit.
67  */
68 int be_machine_is_dummy_unit(const be_execution_unit_t *unit);
69
70 /**
71  * Check if given unit is the generic dummy unit type.
72  */
73 int be_machine_is_dummy_unit_type(const be_execution_unit_type_t *tp);
74
75 /**
76  * Get the number of available unit types in the given machine.
77  */
78 #define be_machine_get_n_unit_types(machine) ((machine)->n_unit_types)
79
80 /**
81  * Get the unit type number @p i from the given machine.
82  */
83 #define be_machine_get_unit_type(machine, i) ((machine)->unit_types[(i)])
84
85 /**
86  * Get the name of the given unit type.
87  */
88 #define be_machine_get_unit_type_name(tp) ((tp)->name)
89
90 /**
91  * Get the number of available execution units from the given unit type.
92  */
93 #define be_machine_get_n_execunits(tp) ((tp)->n_units)
94
95 /**
96  * Get the execution unit number @p i from the given unit type.
97  */
98 #define be_machine_get_execunit(tp, i) ((tp)->units[(i)])
99
100 /**
101  * Get the name of the given execution unit.
102  */
103 #define be_machine_get_execunit_name(unit) ((unit)->name)
104
105 /**
106  * Get the unit type of the given execution unit.
107  */
108 #define be_machine_get_execunit_type(unit) ((unit)->tp)
109
110 #endif /* FIRM_BE_BEMACHINE_H */