backend: created a (not so nice) macro to iterate over all values defined by an instr...
[libfirm] / ir / be / ia32 / ia32_emitter.c
index 9fd10c8..d0f2bc6 100644 (file)
@@ -70,6 +70,7 @@
 #include "../be_dbgout.h"
 
 #include "ia32_emitter.h"
+#include "ia32_common_transform.h"
 #include "gen_ia32_emitter.h"
 #include "gen_ia32_regalloc_if.h"
 #include "ia32_nodes_attr.h"
@@ -205,16 +206,6 @@ static char *get_unique_label(char *buf, size_t buflen, const char *prefix)
        return buf;
 }
 
-/*************************************************************
- *             _       _    __   _          _
- *            (_)     | |  / _| | |        | |
- *  _ __  _ __ _ _ __ | |_| |_  | |__   ___| |_ __   ___ _ __
- * | '_ \| '__| | '_ \| __|  _| | '_ \ / _ \ | '_ \ / _ \ '__|
- * | |_) | |  | | | | | |_| |   | | | |  __/ | |_) |  __/ |
- * | .__/|_|  |_|_| |_|\__|_|   |_| |_|\___|_| .__/ \___|_|
- * | |                                       | |
- * |_|                                       |_|
- *************************************************************/
 
 /**
  * Emit the name of the 8bit low register
@@ -429,7 +420,7 @@ void ia32_emit_x87_mode_suffix(const ir_node *node)
                        case 128: be_emit_char('t'); return;
                }
        } else {
-               assert(mode_is_int(mode));
+               assert(mode_is_int(mode) || mode_is_reference(mode));
                switch (get_mode_size_bits(mode)) {
                        case 16: be_emit_char('s');     return;
                        case 32: be_emit_char('l');     return;
@@ -1216,16 +1207,6 @@ static void emit_ia32_CMovcc(const ir_node *node)
        ia32_emitf(node, "\tcmov%P %#AR, %#R\n", pnc, in_true, out);
 }
 
-/*********************************************************
- *                 _ _       _
- *                (_) |     (_)
- *   ___ _ __ ___  _| |_     _ _   _ _ __ ___  _ __  ___
- *  / _ \ '_ ` _ \| | __|   | | | | | '_ ` _ \| '_ \/ __|
- * |  __/ | | | | | | |_    | | |_| | | | | | | |_) \__ \
- *  \___|_| |_| |_|_|\__|   | |\__,_|_| |_| |_| .__/|___/
- *                         _/ |               | |
- *                        |__/                |_|
- *********************************************************/
 
 /* jump table entry (target and corresponding number) */
 typedef struct _branch_t {
@@ -1525,16 +1506,6 @@ static void emit_ia32_Asm(const ir_node *node)
        ia32_emitf(NULL, "\n#NO_APP\n");
 }
 
-/**********************************
- *   _____                  ____
- *  / ____|                |  _ \
- * | |     ___  _ __  _   _| |_) |
- * | |    / _ \| '_ \| | | |  _ <
- * | |___| (_) | |_) | |_| | |_) |
- *  \_____\___/| .__/ \__, |____/
- *             | |     __/ |
- *             |_|    |___/
- **********************************/
 
 /**
  * Emit movsb/w instructions to make mov count divideable by 4
@@ -1574,17 +1545,6 @@ static void emit_ia32_CopyB_i(const ir_node *node)
 }
 
 
-
-/***************************
- *   _____
- *  / ____|
- * | |     ___  _ ____   __
- * | |    / _ \| '_ \ \ / /
- * | |___| (_) | | | \ V /
- *  \_____\___/|_| |_|\_/
- *
- ***************************/
-
 /**
  * Emit code for conversions (I, FP), (FP, I) and (FP, FP).
  */
@@ -1639,16 +1599,6 @@ static void emit_ia32_Call(const ir_node *node)
 }
 
 
-/*******************************************
- *  _                          _
- * | |                        | |
- * | |__   ___ _ __   ___   __| | ___  ___
- * | '_ \ / _ \ '_ \ / _ \ / _` |/ _ \/ __|
- * | |_) |  __/ | | | (_) | (_| |  __/\__ \
- * |_.__/ \___|_| |_|\___/ \__,_|\___||___/
- *
- *******************************************/
-
 /**
  * Emits code to increase stack pointer.
  */
@@ -1875,16 +1825,6 @@ static void emit_Nothing(const ir_node *node)
 }
 
 
-/***********************************************************************************
- *                  _          __                                             _
- *                 (_)        / _|                                           | |
- *  _ __ ___   __ _ _ _ __   | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
- * | '_ ` _ \ / _` | | '_ \  |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
- * | | | | | | (_| | | | | | | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
- * |_| |_| |_|\__,_|_|_| |_| |_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
- *
- ***********************************************************************************/
-
 /**
  * Enters the emitter functions for handled nodes into the generic
  * pointer of an opcode.
@@ -2032,7 +1972,7 @@ static void ia32_emit_align_label(void)
 static int should_align_block(const ir_node *block)
 {
        static const double DELTA = .0001;
-       ir_exec_freq *exec_freq   = cg->birg->exec_freq;
+       ir_exec_freq *exec_freq   = be_get_irg_exec_freq(cg->irg);
        ir_node      *prev        = get_prev_block_sched(block);
        double        block_freq;
        double        prev_freq = 0;  /**< execfreq of the fallthrough block */
@@ -2079,7 +2019,7 @@ static void ia32_emit_block_header(ir_node *block)
        ir_graph     *irg = current_ir_graph;
        int           need_label = block_needs_label(block);
        int           i, arity;
-       ir_exec_freq *exec_freq = cg->birg->exec_freq;
+       ir_exec_freq *exec_freq = be_get_irg_exec_freq(cg->irg);
 
        if (block == get_irg_end_block(irg))
                return;
@@ -2215,7 +2155,7 @@ void ia32_gen_routine(ia32_code_gen_t *ia32_cg, ir_graph *irg)
 
        cg       = ia32_cg;
        isa      = cg->isa;
-       do_pic   = cg->birg->main_env->options->pic;
+       do_pic   = be_get_irg_options(cg->irg)->pic;
 
        be_gas_elf_type_char = '@';
 
@@ -2223,7 +2163,7 @@ void ia32_gen_routine(ia32_code_gen_t *ia32_cg, ir_graph *irg)
 
        get_unique_label(pic_base_label, sizeof(pic_base_label), "PIC_BASE");
 
-       be_dbg_method_begin(entity, be_abi_get_stack_layout(cg->birg->abi));
+       be_dbg_method_begin(entity);
        be_gas_emit_function_prolog(entity, ia32_cg_config.function_alignment);
 
        /* we use links to point to target blocks */