Added the bearch files to the makefile
[libfirm] / ir / be / bearch.h
1
2 #ifndef _FIRM_BEARCH_H
3 #define _FIRM_BEARCH_H
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 struct bitset_t;
10
11 /*
12  * Define the types of the arch facility.
13  * All arch object names are stored in bearch_obj.def
14  */
15 #define ARCH_OBJ(x,list) typedef struct _arch_ ## x ## _t arch_ ## x ## _t;
16 #include "bearch_obj.def"
17 #undef ARCH_OBJ
18
19 /**
20  * A callback to determine the set of valid registers.
21  *
22  * @param irn                           The node which represents an instance of the instruction.
23  * @param pos                           The number of the insn's operand to consider.
24  * @param valid_regs    A bitset where all valid registers are put.
25  */
26 typedef void (arch_register_callback_t)(ir_node *irn, int pos, struct bitset_t *valid_regs);
27
28
29 /**
30  * Add a new instruction set architecture.
31  * @param name The name of the isa.
32  * @return The isa object.
33  */
34 arch_isa_t *arch_add_isa(const char *name);
35
36 /**
37  * Add a register class to the isa.
38  * @param isa The isa to add the reg class to.
39  * @param name The name of the register class.
40  * @param n_regs The number of registers in that class.
41  * @param mode The mode of the registers in that class.
42  */
43 arch_register_class_t *arch_add_register_class(arch_isa_t *isa, const char *name, int n_regs);
44
45 /**
46  * Add a register to a register class.
47  * @param cls The register class.
48  * @param index The index of the register (its number within the
49  * class).
50  * @param name The name of the register.
51  * @return The register.
52  */
53 arch_register_t *arch_add_register(arch_register_class_t *cls, int index, const char *name);
54
55 /**
56  * Add an immediate to the instruction set architecture.
57  * @param isa The isa.
58  * @param name The name of the immediate.
59  * @param mode The mode of the immediate.
60  * @return The immediate.
61  */
62 arch_immediate_t *arch_add_immediate(arch_isa_t *isa, const char *name, ir_mode *mode);
63
64 /**
65  * Add an instruction format to an isa.
66  * @param isa The isa.
67  * @param name The name of the instruction format.
68  * @param n_in The number of in operands.
69  * @param n_out The number of out operands.
70  * @return The format.
71  */
72 arch_insn_format_t *arch_add_insn_format(arch_isa_t *isa, const char *name, int n_in, int n_out);
73
74 /**
75  * Add a register set as an operand type.
76  * @param fmt The instruction format whose operand is to be set.
77  * @param pos The position of the operand. Note that input operands are
78  * numbered from 0 to n and output operands from -1 to -m.
79  * @param set The register set.
80  * @return The corresponding operand type.
81  */
82 arch_operand_t *arch_add_operand_register_set(arch_insn_format_t *fmt,
83                 int pos, const arch_register_set_t *set);
84
85 arch_operand_t *arch_add_operand_callback(arch_insn_format_t *fmt,
86                 int pos, arch_register_callback_t *cb);
87
88 arch_operand_t *arch_add_operand_immediate(arch_insn_format_t *fmt,
89                 int pos, const arch_immediate_t *imm);
90
91 /**
92  * Add an instruction to the isa.
93  * @param fmt The instructon format.
94  * @param name The name of the instruction.
95  */
96 arch_insn_t *arch_add_insn(arch_insn_format_t *fmt, const char *name);
97
98
99 /**
100  * Find an instruction format.
101  * @param isa The isa.
102  * @param name The name of the instruction format.
103  * @return The instruction format, if it was added before, or NULL if it
104  * is unknown.
105  */
106 arch_insn_format_t *arch_find_insn_format(const arch_isa_t *isa, const char *name);
107
108 /**
109  * Find an isa.
110  * @param name The name of the isa.
111  * @return The isa if it has been added, or NULl if it is unknwon.
112  */
113 arch_isa_t *arch_find_isa(const char *name);
114
115 /**
116  * Find an sintrsuction in the instruction set architecture.
117  * @param isa The instruction set architecture.
118  * @param name The name of the instruction.
119  * @return The instruction or NULL if no such instruction exists.
120  */
121 arch_insn_t *arch_find_insn(const arch_isa_t *isa, const char *name);
122
123 /**
124  * Find a register class of an isa.
125  * @param isa The isa.
126  * @param name The name of the register class.
127  * @return The register class, if it has been added, NULL if it is
128  * unknown.
129  */
130 arch_register_class_t *arch_find_register_class(arch_isa_t *isa, const char *name);
131
132 /**
133  * Get the register set for a register class.
134  * Each register class possesses a set containing all registers known in
135  * the class.
136  * @param cls The class.
137  * @return The register set for the register class.
138  */
139 arch_register_set_t *arch_get_register_set_for_class(arch_register_class_t *cls);
140
141 /**
142  * Get a mode which is a placeholder for an unknown mode.
143  * @return Some mode to use, if you don't know which mode you will need,
144  * yet.
145  */
146 ir_mode *arch_get_unknown_mode(void);
147
148 /**
149  * Make a new bare instance of an insn.
150  * @param insn The instruction.
151  * @param irg The graph.
152  * @param arity The number of operands to reserve for the ir_node.
153  * @return An ir node. Its block and operands are set to an Unknown
154  * node.
155  */
156 ir_node *arch_new_node_bare(const arch_insn_t *insn, ir_graph *irg, int arity);
157
158 /**
159  * Make a new instance of an insn.
160  * This functions works like new_ir_node() and uses the op in the
161  * insn.
162  */
163 ir_node *arch_new_node(const arch_insn_t *insn, ir_graph *irg, ir_node *block,
164                 ir_mode *mode, int arity, ir_node **in);
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif