added ports per unit
[libfirm] / ir / be / bemachine.h
1 #ifndef _BE_MACHINE_H_
2 #define _BE_MACHINE_H_
3
4 /**
5  * Abstract machine interface.
6  * @author Christian Wuerdig
7  * @date   23.10.2006
8  * @cvs-id $Id$
9  */
10
11 typedef struct _be_execution_unit_type_t be_execution_unit_type_t;
12 typedef struct _be_execution_unit_t      be_execution_unit_t;
13 typedef struct _be_machine_t             be_machine_t;
14
15 struct _be_execution_unit_t {
16         be_execution_unit_type_t *tp;
17         const char               *name;
18 };
19
20 struct _be_execution_unit_type_t {
21         unsigned            n_units;
22         unsigned            ports_per_unit;
23         const char          *name;
24         be_execution_unit_t *units;
25 };
26
27 struct _be_machine_t {
28         unsigned                 bundle_size;
29         unsigned                 bundels_per_cycle;
30         unsigned                 n_unit_types;
31         be_execution_unit_type_t *unit_types;
32 };
33
34 /**
35  * Get the number of available unit types in the given machine.
36  */
37 #define be_machine_get_n_unit_types(machine) ((machine)->n_unit_types)
38
39 /**
40  * Get the unit type number @p i from the given machine.
41  */
42 #define be_machine_get_unit_type(machine, i) ((machine)->unit_types[(i)])
43
44 /**
45  * Get the name of the given unit type.
46  */
47 #define be_machine_get_unit_type_name(tp) ((tp)->name)
48
49 /**
50  * Get the number of available execution units from the given unit type.
51  */
52 #define be_machine_get_n_execunits(tp) ((tp)->n_units)
53
54 /**
55  * Get the execution unit number @p i from the given unit type.
56  */
57 #define be_machine_get_execunit(tp, i) ((tp)->units[(i)])
58
59 /**
60  * Get the name of the given execution unit.
61  */
62 #define be_machine_get_execunit_name(unit) ((unit)->name)
63
64 /**
65  * Get the unit type of the given execution unit.
66  */
67 #define be_machine_get_execunit_type(unit) ((unit)->tp)
68
69 #endif /* _BE_MACHINE_H_ */