API Change: Use graph state instead of parameter
authorAndreas Zwinkau <zwinkau@kit.edu>
Tue, 16 Aug 2011 11:28:18 +0000 (13:28 +0200)
committerAndreas Zwinkau <zwinkau@kit.edu>
Tue, 16 Aug 2011 11:38:54 +0000 (13:38 +0200)
The lowering phase had a lower_bitfield parameter.
Instead of passing "true", the (e.g. EDG) frontends now must
set_irg_state(irg, IR_GRAPH_STATE_IMPLICIT_BITFIELD_MASKING).

This is necessary, because not only the lowering phase is affected.
Additionally, the load store optimisation should handle Sels differently.

include/libfirm/irgraph.h
include/libfirm/lowering.h
ir/lower/lower_hl.c

index 83b89de..03a916e 100644 (file)
@@ -508,6 +508,12 @@ typedef enum {
         * later in the other (NORMALISATION2).
         */
        IR_GRAPH_STATE_NORMALISATION2        = 1U << 4,
+       /**
+        * Define the semantic of Load(Sel(x)), if x has a bit offset (Bitfields!).
+        * Normally, the frontend is responsible for bitfield masking operations.
+        * Set IMPLICIT_BITFIELD_MASKING, if the lowering phase must insert masking operations.
+        */
+       IR_GRAPH_STATE_IMPLICIT_BITFIELD_MASKING  = 1U << 5,
 } ir_graph_state_t;
 ENUM_BITSET(ir_graph_state_t)
 
index 44ea887..70e3893 100644 (file)
@@ -59,25 +59,20 @@ FIRM_API void lower_switch(ir_graph *irg, unsigned small_switch,
  * Handle bit fields by added And/Or calculations.
  *
  * @param irg               the graph to lower
- * @param lower_bitfields   the graph contains old-style bitfield
- *                          constructs
  *
  * @note: There is NO lowering ob objects oriented types. This is highly compiler
  *        and ABI specific and should be placed directly in the compiler.
  */
-FIRM_API void lower_highlevel_graph(ir_graph *irg, int lower_bitfields);
+FIRM_API void lower_highlevel_graph(ir_graph *irg);
 
 /**
  * Creates an ir_graph pass for lower_highlevel_graph().
  *
  * @param name              the name of this pass or NULL
- * @param lower_bitfields   the graph contains old-style bitfield
- *                          constructs
  *
  * @return  the newly created ir_graph pass
  */
-FIRM_API ir_graph_pass_t *lower_highlevel_graph_pass(const char *name,
-                                                     int lower_bitfields);
+FIRM_API ir_graph_pass_t *lower_highlevel_graph_pass(const char *name);
 
 /**
  * Replaces SymConsts by a real constant if possible.
@@ -88,7 +83,7 @@ FIRM_API ir_graph_pass_t *lower_highlevel_graph_pass(const char *name,
  * @note There is NO lowering of objects oriented types. This is highly compiler
  *       and ABI specific and should be placed directly in the compiler.
  */
-FIRM_API void lower_highlevel(int lower_bitfields);
+FIRM_API void lower_highlevel(void);
 
 /**
  * does the same as lower_highlevel for all nodes on the const code irg
index ab4f599..4de0332 100644 (file)
@@ -513,9 +513,9 @@ static void lower_bf_access(ir_node *irn, void *env)
  * Replace Sel nodes by address computation.  Also resolves array access.
  * Handle Bitfields by added And/Or calculations.
  */
-void lower_highlevel_graph(ir_graph *irg, int lower_bitfields)
+void lower_highlevel_graph(ir_graph *irg)
 {
-       if (lower_bitfields) {
+       if (is_irg_state(irg, IR_GRAPH_STATE_IMPLICIT_BITFIELD_MASKING)) {
                /* First step: lower bitfield access: must be run as long as Sels still
                 * exists. */
                irg_walk_graph(irg, NULL, lower_bf_access, NULL);
@@ -527,7 +527,6 @@ void lower_highlevel_graph(ir_graph *irg, int lower_bitfields)
 
 typedef struct pass_t {
        ir_graph_pass_t pass;
-       int            lower_bitfields;
 } pass_t;
 
 /**
@@ -535,17 +534,16 @@ typedef struct pass_t {
  */
 static int lower_highlevel_graph_wrapper(ir_graph *irg, void *context)
 {
-       pass_t *pass = (pass_t*)context;
+       (void)context;
 
-       lower_highlevel_graph(irg, pass->lower_bitfields);
+       lower_highlevel_graph(irg);
        return 0;
 }  /* lower_highlevel_graph_wrapper */
 
-ir_graph_pass_t *lower_highlevel_graph_pass(const char *name, int lower_bitfields)
+ir_graph_pass_t *lower_highlevel_graph_pass(const char *name)
 {
        pass_t *pass = XMALLOCZ(pass_t);
 
-       pass->lower_bitfields = lower_bitfields;
        return def_graph_pass_constructor(
                &pass->pass, name ? name : "lower_hl", lower_highlevel_graph_wrapper);
 }  /* lower_highlevel_graph_pass */
@@ -568,14 +566,14 @@ ir_prog_pass_t *lower_const_code_pass(const char *name)
  * Replace Sel nodes by address computation.  Also resolves array access.
  * Handle Bitfields by added And/Or calculations.
  */
-void lower_highlevel(int lower_bitfields)
+void lower_highlevel()
 {
        size_t i, n;
 
        n = get_irp_n_irgs();
        for (i = 0; i < n; ++i) {
                ir_graph *irg = get_irp_irg(i);
-               lower_highlevel_graph(irg, lower_bitfields);
+               lower_highlevel_graph(irg);
        }
        lower_const_code();
 }  /* lower_highlevel */