simplify logic when x87 simulator is started
[libfirm] / ir / be / bespill.h
index 486c474..84f0457 100644 (file)
@@ -19,7 +19,8 @@
 
 /**
  * @file
- * @brief       Main spill driver.
+ * @brief       higher level abstraction for the creation of spill and reload
+ *              instructions and rematerialisation of values.
  * @author      Daniel Grund, Sebastian Hack, Matthias Braun
  * @date               29.09.2005
  * @version     $Id$
 #ifndef FIRM_BE_BESPILL_H
 #define FIRM_BE_BESPILL_H
 
-#include "irnode.h"
+#include "firm_types.h"
 #include "debug.h"
 
 #include "bearch.h"
 #include "beirg.h"
 
-typedef struct _spill_env_t spill_env_t;
+typedef struct spill_env_t spill_env_t;
 
 /**
  * Creates a new spill environment.
@@ -45,11 +46,6 @@ spill_env_t *be_new_spill_env(be_irg_t *birg);
  */
 void be_delete_spill_env(spill_env_t *senv);
 
-/**
- * Sets the debug module of a spill environment.
- */
-DEBUG_ONLY(void be_set_spill_env_dbg_module(spill_env_t *env, firm_dbg_module_t *dbg));
-
 /**
  * Inserts a new entry into the list of reloads to place (the real nodes will
  * be created when be_insert_spills_reloads is run). You don't have to
@@ -61,22 +57,25 @@ DEBUG_ONLY(void be_set_spill_env_dbg_module(spill_env_t *env, firm_dbg_module_t
  * @param to_spill    The node which is about to be spilled
  * @param before      The node before the reload should be added
  * @param reload_cls  The register class the reloaded value will be put into
- * @param allow_remat Set to 1 if the node may be rematerialized instead of reloaded
+ * @param allow_remat Set to 1 if the node may be rematerialized instead of
+ *                    reloaded
  */
 void be_add_reload(spill_env_t *senv, ir_node *to_spill, ir_node *before,
-       const arch_register_class_t *reload_cls, int allow_remat);
+                   const arch_register_class_t *reload_cls, int allow_remat);
 
 /**
  * Analog to be_add_reload, but places the reload "on an edge" between 2 blocks
  * @see be_add_reload
  */
-void be_add_reload_on_edge(spill_env_t *senv, ir_node *to_spill, ir_node *bl, int pos,
-       const arch_register_class_t *reload_cls, int allow_remat);
+void be_add_reload_on_edge(spill_env_t *senv, ir_node *to_spill, ir_node *bl,
+                           int pos, const arch_register_class_t *reload_cls,
+                           int allow_remat);
 
 /**
  * Analog to be_add_reload but adds an already created rematerialized node.
  */
-void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before, ir_node *rematted_node);
+void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before,
+                  ir_node *rematted_node);
 
 /**
  * The main function that places real spills/reloads (or rematerializes values)
@@ -94,18 +93,28 @@ void be_insert_spills_reloads(spill_env_t *senv);
  */
 void be_spill_phi(spill_env_t *env, ir_node *node);
 
+/**
+ * Returns the estimated costs if a node would ge spilled. This does only return
+ * the costs for the spill instructions, not the costs for needed reload
+ * instructions. The value is weighted by the estimated execution frequency of
+ * the spill.
+ */
+double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *after);
+
 /**
  * Returns the estimated costs if a node would get reloaded at a specific place
- * This usually returns the cost of spill + reload operation. But might return
- * smaller values if the value has already been spilled in a former run or
- * when it is possible to rematerialize the value.
+ * This returns the costs for a reload instructions, or when possible the costs
+ * for a rematerialisation. The value is weighted by the estimated execution
+ * frequency of the reload/rematerialisation.
  */
-int be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before);
+double be_get_reload_costs(spill_env_t *env, ir_node *to_spill,
+                           ir_node *before);
 
 /**
  * Analog to be_get_reload_costs but returns the cost if the reload would be
  * placed "on an edge" between 2 blocks
  */
-int be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block, int pos);
+double be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill,
+                                   ir_node *block, int pos);
 
-#endif /* FIRM_BE_BESPILL_H */
+#endif