12 * Define the types of the arch facility.
13 * All arch object names are stored in bearch_obj.def
15 #define ARCH_OBJ(x,list) typedef struct _arch_ ## x ## _t arch_ ## x ## _t;
16 #include "bearch_obj.def"
20 * A callback to determine the set of valid registers.
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.
26 typedef void (arch_register_callback_t)(ir_node *irn, int pos, struct bitset_t *valid_regs);
30 * Add a new instruction set architecture.
31 * @param name The name of the isa.
32 * @return The isa object.
34 arch_isa_t *arch_add_isa(const char *name);
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.
43 arch_register_class_t *arch_add_register_class(arch_isa_t *isa, const char *name, int n_regs);
46 * Add a register set to an isa.
47 * @param cls The register class the set belongs to.
48 * @param name The name of the register set.
49 * @return The register set.
51 arch_register_set_t *arch_add_register_set(arch_isa_t *isa,
52 const arch_register_class_t *cls, const char *name);
55 * Add a register to a register set.
56 * @param set The register set.
57 * @param index The index of the register in the class.
59 void arch_register_set_add_register(arch_register_set_t *set, int index);
62 * Add a register to a register class.
63 * @param cls The register class.
64 * @param index The index of the register (its number within the
66 * @param name The name of the register.
67 * @return The register.
69 arch_register_t *arch_add_register(arch_register_class_t *cls, int index, const char *name);
72 * Add an immediate to the instruction set architecture.
74 * @param name The name of the immediate.
75 * @param mode The mode of the immediate.
76 * @return The immediate.
78 arch_immediate_t *arch_add_immediate(arch_isa_t *isa, const char *name, ir_mode *mode);
81 * Add an instruction format to an isa.
83 * @param name The name of the instruction format.
84 * @param n_in The number of in operands.
85 * @param n_out The number of out operands.
88 arch_insn_format_t *arch_add_insn_format(arch_isa_t *isa, const char *name, int n_in, int n_out);
91 * Add a register set as an operand type.
92 * @param fmt The instruction format whose operand is to be set.
93 * @param pos The position of the operand. Note that input operands are
94 * numbered from 0 to n and output operands from -1 to -m.
95 * @param set The register set.
96 * @return The corresponding operand type.
98 arch_operand_t *arch_set_operand_register_set(arch_insn_format_t *fmt,
99 int pos, const arch_register_set_t *set);
102 * Set the operand to a callback.
103 * @param fmt The instruction format.
104 * @param pos The position of the operand. See also
105 * arch_set_operand_register_set().
106 * @param cb The callback function which decides about the registers to
108 * @return The operand.
110 arch_operand_t *arch_set_operand_callback(arch_insn_format_t *fmt,
111 int pos, arch_register_callback_t *cb);
114 * Mark an operand as an immediate.
115 * @param fmt The instructionm format.
116 * @param pos The position. See also arch_set_operand_register_set().
117 * @param imm The immediate which expected.
118 * @return The operand.
120 arch_operand_t *arch_set_operand_immediate(arch_insn_format_t *fmt,
121 int pos, const arch_immediate_t *imm);
124 * Mark an operand as a memory operand.
125 * @param fmt The format.
126 * @param pos The position of the operand.
127 * @return The operand.
129 arch_operand_t *arch_set_operand_memory(arch_insn_format_t *fmt, int pos);
132 * Denote, that an operand must equal another.
133 * This only makes sense with registers. Then, this operand must get the
134 * same register as the one denoted by same_as_pos.
136 * @param fmt The instruction format.
137 * @param pos The position of the operand.
138 * @param same_as_pos The position of the other operand.
139 * @return The operand.
141 arch_operand_t *arch_set_operand_equals(arch_insn_format_t *fmt, int pos, int same_as_pos);
145 * Add an instruction to the isa.
146 * @param fmt The instructon format.
147 * @param name The name of the instruction.
149 arch_insn_t *arch_add_insn(arch_insn_format_t *fmt, const char *name);
153 * Find an instruction format.
154 * @param isa The isa.
155 * @param name The name of the instruction format.
156 * @return The instruction format, if it was added before, or NULL if it
159 arch_insn_format_t *arch_find_insn_format(const arch_isa_t *isa, const char *name);
163 * @param name The name of the isa.
164 * @return The isa if it has been added, or NULl if it is unknwon.
166 arch_isa_t *arch_find_isa(const char *name);
169 * Find an sintrsuction in the instruction set architecture.
170 * @param isa The instruction set architecture.
171 * @param name The name of the instruction.
172 * @return The instruction or NULL if no such instruction exists.
174 arch_insn_t *arch_find_insn(const arch_isa_t *isa, const char *name);
177 * Find a register class of an isa.
178 * @param isa The isa.
179 * @param name The name of the register class.
180 * @return The register class, if it has been added, NULL if it is
183 arch_register_class_t *arch_find_register_class(const arch_isa_t *isa, const char *name);
186 * Find a register set in an isa.
187 * @param isa The isa.
188 * @param name The name of the register set.
189 * @return The register set or NULL if it does not exist.
191 arch_register_set_t *arch_find_register_set(const arch_isa_t *isa, const char *name);
194 * find an immediate registered in some isa.
195 * @param isa The isa.
196 * @param name The name of the immediate.
197 * @return The immediate, or NULL if it did not exist.
199 arch_immediate_t *arch_find_immediate(const arch_isa_t *isa, const char *name);
202 * Get the register set for a register class.
203 * Each register class possesses a set containing all registers known in
205 * @param cls The class.
206 * @return The register set for the register class.
208 arch_register_set_t *arch_get_register_set_for_class(arch_register_class_t *cls);
211 * Get a mode which is a placeholder for an unknown mode.
212 * @return Some mode to use, if you don't know which mode you will need,
215 ir_mode *arch_get_unknown_mode(void);
218 * Make a new bare instance of an insn.
219 * @param insn The instruction.
220 * @param irg The graph.
221 * @param arity The number of operands to reserve for the ir_node.
222 * @return An ir node. Its block and operands are set to an Unknown
225 ir_node *arch_new_node_bare(const arch_insn_t *insn, ir_graph *irg, int arity);
228 * Make a new instance of an insn.
229 * This functions works like new_ir_node() and uses the op in the
232 ir_node *arch_new_node(const arch_insn_t *insn, ir_graph *irg, ir_node *block,
233 ir_mode *mode, int arity, ir_node **in);