# include <string.h>
#endif
-# include "irprog_t.h"
-# include "irgraph_t.h"
-# include "pseudo_irg.h"
-# include "array.h"
-# include "obst.h"
-# include "typegmod.h"
+#include "irprog_t.h"
+#include "irgraph_t.h"
+#include "pseudo_irg.h"
+#include "array.h"
+#include "obst.h"
+#include "typegmod.h"
+#include "irop_t.h"
#define GLOBAL_TYPE_NAME "GlobalType"
#define INITAL_PROG_NAME "no_name_set"
res->pseudo_graphs = NEW_ARR_F(ir_graph *, 0);
res->types = NEW_ARR_F(ir_type *, 0);
res->modes = NEW_ARR_F(ir_mode *, 0);
+ res->opcodes = NEW_ARR_F(ir_op *, 0);
#ifdef DEBUG_libfirm
res->max_node_nr = 0;
irp->const_code_irg = new_const_code_irg();
+ irp->phase_state = phase_building;
irp->outs_state = outs_none;
irp->ip_outedges = NULL;
irp->trouts_state = outs_none;
DEL_ARR_F(irp->pseudo_graphs);
DEL_ARR_F(irp->types);
DEL_ARR_F(irp->modes);
+ DEL_ARR_F(irp->opcodes);
irp->name = NULL;
irp->const_code_irg = NULL;
return _get_irp_type(pos);
}
-void set_irp_type(int pos, ir_type *typ) {
+void set_irp_type(int pos, ir_type *typ) {
assert (irp && typ);
assert (pos < (ARR_LEN((irp)->types)));
irp->types[pos] = typ;
ARR_APP1(ir_mode *, irp->modes, mode);
}
+/* Adds opcode to the list of opcodes in irp. */
+void add_irp_opcode(ir_op *opcode) {
+ assert(opcode != NULL);
+ assert(irp);
+ ARR_APP1(ir_op *, irp->opcodes, opcode);
+}
+
+/* Removes opcode from the list of opcodes and shrinks the list by one. */
+void remove_irp_opcode(ir_op *opcode) {
+ int i;
+ assert(opcode);
+
+ for (i = ARR_LEN(irp->opcodes) -1; i >= 0; i--) {
+ if (irp->opcodes[i] == opcode) {
+ for(; i < (ARR_LEN(irp->opcodes)) - 1; i++) {
+ irp->opcodes[i] = irp->opcodes[i+1];
+ }
+ ARR_SETLEN(ir_op *, irp->opcodes, (ARR_LEN(irp->opcodes)) - 1);
+ break;
+ }
+ }
+}
+
+/* Returns the number of all opcodes in the irp. */
+int (get_irp_n_opcodes)(void) {
+ return _get_irp_n_opcodes();
+}
+
+/* Returns the opcode at position pos in the irp. */
+ir_op *(get_irp_opcode)(int pos) {
+ return _get_irp_opcode(pos);
+}
+
+/* Sets the generic function pointer of all opcodes to NULL */
+void clear_irp_opcodes_generic_func(void) {
+ int i;
+
+ for (i = get_irp_n_opcodes() - 1; i >= 0; --i) {
+ ir_op *op = get_irp_opcode(i);
+ op->ops.generic = (op_func)NULL;
+ }
+}
+
/*- File name / executable name or the like -*/
void set_irp_prog_name(ident *name) {
irp->name = name;