fix cvt emitter
[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 extern be_execution_unit_t be_machine_execution_units_DUMMY[1];
35
36 /**
37  * Initialize generic dummy unit.
38  */
39 void be_machine_init_dummy_unit(void);
40
41 /**
42  * Returns the generic dummy unit.
43  */
44 be_execution_unit_t *be_machine_get_dummy_unit(void);
45
46 /**
47  * Check if given unit is the generic dummy unit.
48  */
49 int be_machine_is_dummy_unit(const be_execution_unit_t *unit);
50
51 /**
52  * Check if given unit is the generic dummy unit type.
53  */
54 int be_machine_is_dummy_unit_type(const be_execution_unit_type_t *tp);
55
56 /**
57  * Get the number of available unit types in the given machine.
58  */
59 #define be_machine_get_n_unit_types(machine) ((machine)->n_unit_types)
60
61 /**
62  * Get the unit type number @p i from the given machine.
63  */
64 #define be_machine_get_unit_type(machine, i) ((machine)->unit_types[(i)])
65
66 /**
67  * Get the name of the given unit type.
68  */
69 #define be_machine_get_unit_type_name(tp) ((tp)->name)
70
71 /**
72  * Get the number of available execution units from the given unit type.
73  */
74 #define be_machine_get_n_execunits(tp) ((tp)->n_units)
75
76 /**
77  * Get the execution unit number @p i from the given unit type.
78  */
79 #define be_machine_get_execunit(tp, i) ((tp)->units[(i)])
80
81 /**
82  * Get the name of the given execution unit.
83  */
84 #define be_machine_get_execunit_name(unit) ((unit)->name)
85
86 /**
87  * Get the unit type of the given execution unit.
88  */
89 #define be_machine_get_execunit_type(unit) ((unit)->tp)
90
91 #endif /* _BE_MACHINE_H_ */