Added new get_irn_pinned() function
[libfirm] / ir / ir / irarch.h
index 3c1a4f2..6b733ed 100644 (file)
@@ -43,8 +43,10 @@ const arch_dep_params_t *arch_dep_default_factory(void);
  * Optimization flags.
  */
 typedef enum {
-  arch_dep_none = 0,
-  arch_dep_mul_to_shift = 1
+  arch_dep_none         = 0,
+  arch_dep_mul_to_shift = 1,   /**< optimize Mul into Shift/Add/Sub */
+  arch_dep_div_to_shift = 2,   /**< optimize Div into Shift/Add/Mul */
+  arch_dep_mod_to_shift = 4    /**< optimize Mod into Shift/Add/Mul */
 } arch_dep_opts_t;
 
 /**
@@ -79,4 +81,57 @@ void arch_dep_set_opts(arch_dep_opts_t opts);
  */
 ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn);
 
+/**
+ * Replace Divs with Shifts and Add/Subs.
+ * This function is driven by the 3 parameters:
+ * - also_use_subs
+ * - maximum_shifts
+ * - highest_shift_amount
+ *
+ * If irn is a Div with a Const, The constant is inspected, if it meets the
+ * requirements of the three variables stated above. If a Shl/Add/Sub
+ * sequence can be generated, that meets these requirements, this expression
+ * is returned. In each other case, irn is returned unmodified.
+ *
+ * @param irn       The Firm node to inspect.
+ * @return          A replacement expression for irn.
+ */
+ir_node *arch_dep_replace_div_with_shifts(ir_node *irn);
+
+/**
+ * Replace Mods with Shifts and Add/Subs.
+ * This function is driven by the 3 parameters:
+ * - also_use_subs
+ * - maximum_shifts
+ * - highest_shift_amount
+ *
+ * If irn is a Div with a Const, The constant is inspected, if it meets the
+ * requirements of the three variables stated above. If a Shl/Add/Sub
+ * sequence can be generated, that meets these requirements, this expression
+ * is returned. In each other case, irn is returned unmodified.
+ *
+ * @param irn       The Firm node to inspect.
+ * @return          A replacement expression for irn.
+ */
+ir_node *arch_dep_replace_mod_with_shifts(ir_node *irn);
+
+/**
+ * Replace Mods with Shifts and Add/Subs.
+ * This function is driven by the 3 parameters:
+ * - also_use_subs
+ * - maximum_shifts
+ * - highest_shift_amount
+ *
+ * If irn is a Div with a Const, The constant is inspected, if it meets the
+ * requirements of the three variables stated above. If a Shl/Add/Sub
+ * sequence can be generated, that meets these requirements, this expression
+ * is returned. In each other case, irn is returned unmodified.
+ *
+ * @param div       After call contains the Firm node div result or NULL.
+ * @param mod       After call contains the Firm node mod result or NULL.
+ * @param irn       The Firm node to inspect.
+ * @return          A replacement expression for irn.
+ */
+void arch_dep_replace_divmod_with_shifts(ir_node **div, ir_node **mod, ir_node *irn);
+
 #endif