Mulh is now an official opcode
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 12 Sep 2007 08:15:35 +0000 (08:15 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 12 Sep 2007 08:15:35 +0000 (08:15 +0000)
[r15748]

include/libfirm/irop.h
ir/ir/irarch.c
ir/ir/irop.c

index 1f92e19..200b301 100644 (file)
@@ -81,7 +81,7 @@ typedef enum {
        iro_Start, iro_End, iro_Jmp, iro_IJmp, iro_Cond, iro_Return,
        iro_Const, iro_SymConst,
        iro_Sel,
-       iro_Call, iro_Add, iro_Sub, iro_Minus, iro_Mul, iro_Quot, iro_DivMod,
+       iro_Call, iro_Add, iro_Sub, iro_Minus, iro_Mul, iro_Mulh, iro_Quot, iro_DivMod,
        iro_Div,  iro_Mod, iro_Abs, iro_And, iro_Or, iro_Eor, iro_Not,
        iro_Cmp,  iro_Shl, iro_Shr, iro_Shrs, iro_Rot, iro_Conv, iro_Cast,
        iro_Carry, iro_Borrow,
@@ -115,6 +115,7 @@ extern ir_op *op_Add;             ir_op *get_op_Add       (void);
 extern ir_op *op_Sub;             ir_op *get_op_Sub       (void);
 extern ir_op *op_Minus;           ir_op *get_op_Minus     (void);
 extern ir_op *op_Mul;             ir_op *get_op_Mul       (void);
+extern ir_op *op_Mulh;            ir_op *get_op_Mulh      (void);
 extern ir_op *op_Quot;            ir_op *get_op_Quot      (void);
 extern ir_op *op_DivMod;          ir_op *get_op_DivMod    (void);
 extern ir_op *op_Div;             ir_op *get_op_Div       (void);
@@ -196,7 +197,7 @@ const char *get_op_pin_state_name(op_pin_state s);
 op_pin_state get_op_pinned(const ir_op *op);
 
 /** Sets pinned in the opcode.  Setting it to floating has no effect
-   for Block, Phi and control flow nodes. */
+    for Block, Phi and control flow nodes. */
 void set_op_pinned(ir_op *op, op_pin_state pinned);
 
 /** Returns the next free IR opcode number, allows to register user ops */
@@ -327,23 +328,35 @@ typedef enum {
  */
 typedef int (*dump_node_func)(ir_node *self, FILE *F, dump_reason_t reason);
 
+/**
+ * Export a node to an archive.
+ */
+typedef void (*ar_export_func)(ir_node *self, FILE *F);
+
+/**
+ * Read a node back from an archive.
+ */
+typedef void (*ar_import_func)(ir_node *self, FILE *F);
+
 /**
  * io_op Operations.
  */
 typedef struct {
-       computed_value_func   computed_value;   /**< evaluates a node into a tarval if possible. */
-       equivalent_node_func  equivalent_node;  /**< optimizes the node by returning an equivalent one. */
-       transform_node_func   transform_node;   /**< optimizes the node by transforming it. */
-       node_cmp_attr_func    node_cmp_attr;    /**< compares two node attributes. */
-       reassociate_func      reassociate;      /**< reassociate a tree */
-       copy_attr_func        copy_attr;        /**< copy node attributes */
-       get_type_func         get_type;         /**< return the type of a node */
-       get_type_attr_func    get_type_attr;    /**< return the type attribute of a node */
-       get_entity_attr_func  get_entity_attr;  /**< return the entity attribute of a node */
-       verify_node_func      verify_node;      /**< verify the node */
-       verify_proj_node_func verify_proj_node; /**< verify the Proj node */
-       dump_node_func        dump_node;        /**< dump a node */
-       op_func               generic;          /**< a generic function */
+       computed_value_func   computed_value;   /**< Evaluates a node into a tarval if possible. */
+       equivalent_node_func  equivalent_node;  /**< Optimizes the node by returning an equivalent one. */
+       transform_node_func   transform_node;   /**< Optimizes the node by transforming it. */
+       node_cmp_attr_func    node_cmp_attr;    /**< Compares two node attributes. */
+       reassociate_func      reassociate;      /**< Reassociate a tree. */
+       copy_attr_func        copy_attr;        /**< Copy node attributes. */
+       get_type_func         get_type;         /**< Return the type of a node. */
+       get_type_attr_func    get_type_attr;    /**< Return the type attribute of a node. */
+       get_entity_attr_func  get_entity_attr;  /**< Return the entity attribute of a node. */
+       verify_node_func      verify_node;      /**< Verify the node. */
+       verify_proj_node_func verify_proj_node; /**< Verify the Proj node. */
+       dump_node_func        dump_node;        /**< Dump a node. */
+       ar_export_func        write_node;       /**< Export a node into an archive. */
+       ar_import_func        read_node;        /**< Import a node from an archive. */
+       op_func               generic;          /**< A generic function pointer. */
 } ir_op_ops;
 
 /**
@@ -365,8 +378,8 @@ typedef struct {
  * The behavior of new opcode depends on the operations \c ops and the \c flags.
  */
 ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
-                 unsigned flags, op_arity opar, int op_index, size_t attr_size,
-                 const ir_op_ops *ops);
+       unsigned flags, op_arity opar, int op_index, size_t attr_size,
+       const ir_op_ops *ops);
 
 /** Returns the ir_op_ops of an ir_op. */
 const ir_op_ops *get_op_ops(const ir_op *op);
index e6d3aba..73a4821 100644 (file)
@@ -70,9 +70,6 @@ static const ir_settings_arch_dep_t *params = NULL;
 /** The bit mask, which optimizations to apply. */
 static arch_dep_opts_t opts;
 
-/* we need this new pseudo op */
-static ir_op *op_Mulh = NULL;
-
 /**
  * construct a Mulh: Mulh(a,b) = (a * b) >> w, w is the with in bits of a, b
  */
@@ -90,20 +87,11 @@ new_rd_Mulh (dbg_info *db, ir_graph *irg, ir_node *block,
        return res;
 }
 
-ir_op *get_op_Mulh(void)  { return op_Mulh; }
-
 void arch_dep_init(arch_dep_params_factory_t factory) {
        opts = arch_dep_none;
 
        if (factory != NULL)
                params = factory();
-
-       if (! op_Mulh) {
-               int mulh_opc = get_next_ir_opcode();
-
-               /* create the Mulh operation */
-               op_Mulh = new_ir_op(mulh_opc, "Mulh",  op_pin_state_floats, irop_flag_commutative, oparity_binary, 0, 0, NULL);
-       }
 }
 
 void arch_dep_set_opts(arch_dep_opts_t the_opts) {
index 793a0ff..4101343 100644 (file)
@@ -65,6 +65,7 @@ ir_op *op_Add;         ir_op *get_op_Add       (void) { return op_Add;       }
 ir_op *op_Sub;         ir_op *get_op_Sub       (void) { return op_Sub;       }
 ir_op *op_Minus;       ir_op *get_op_Minus     (void) { return op_Minus;     }
 ir_op *op_Mul;         ir_op *get_op_Mul       (void) { return op_Mul;       }
+ir_op *op_Mulh;        ir_op *get_op_Mulh      (void) { return op_Mulh;      }
 ir_op *op_Quot;        ir_op *get_op_Quot      (void) { return op_Quot;      }
 ir_op *op_DivMod;      ir_op *get_op_DivMod    (void) { return op_DivMod;    }
 ir_op *op_Div;         ir_op *get_op_Div       (void) { return op_Div;       }
@@ -303,6 +304,7 @@ init_op(void)
        op_Sub       = new_ir_op(iro_Sub,       "Sub",       op_pin_state_floats, N,       oparity_binary,    0, 0, NULL);
        op_Minus     = new_ir_op(iro_Minus,     "Minus",     op_pin_state_floats, N,       oparity_unary,     0, 0, NULL);
        op_Mul       = new_ir_op(iro_Mul,       "Mul",       op_pin_state_floats, C,       oparity_binary,    0, 0, NULL);
+       op_Mulh      = new_ir_op(iro_Mulh,      "Mulh",      op_pin_state_floats, C,       oparity_binary,    0, 0, NULL);
        op_Quot      = new_ir_op(iro_Quot,      "Quot",      op_pin_state_exc_pinned, F,   oparity_binary,    1, sizeof(divmod_attr), NULL);
        op_DivMod    = new_ir_op(iro_DivMod,    "DivMod",    op_pin_state_exc_pinned, F,   oparity_binary,    1, sizeof(divmod_attr), NULL);
        op_Div       = new_ir_op(iro_Div,       "Div",       op_pin_state_exc_pinned, F,   oparity_binary,    1, sizeof(divmod_attr), NULL);
@@ -390,6 +392,7 @@ void finish_op(void) {
        free_ir_op (op_Minus    ); op_Minus     = NULL;
        free_ir_op (op_Sub      ); op_Sub       = NULL;
        free_ir_op (op_Mul      ); op_Mul       = NULL;
+       free_ir_op (op_Mulh     ); op_Mulh      = NULL;
        free_ir_op (op_Quot     ); op_Quot      = NULL;
        free_ir_op (op_DivMod   ); op_DivMod    = NULL;
        free_ir_op (op_Div      ); op_Div       = NULL;