Reuse already fetched values.
[libfirm] / ir / be / arm / arm_emitter.c
index 0744f59..b22754e 100644 (file)
@@ -25,9 +25,7 @@
  */
 #define SILENCER
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <limits.h>
 
@@ -47,7 +45,7 @@
 
 #include "../besched.h"
 #include "../beblocksched.h"
-#include "../beirg_t.h"
+#include "../beirg.h"
 #include "../begnuas.h"
 #include "../be_dbgout.h"
 
@@ -67,9 +65,7 @@
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
-static const arch_env_t     *arch_env = NULL;
 static const arm_code_gen_t *cg;
-static const arm_isa_t      *isa;
 static set                  *sym_or_tv;
 
 /**
@@ -85,16 +81,13 @@ static const arch_register_t *get_in_reg(const ir_node *irn, int pos) {
           in register we need. */
        op = get_irn_n(irn, pos);
 
-       reg = arch_get_irn_register(arch_env, op);
+       reg = arch_get_irn_register(op);
 
        assert(reg && "no in register found");
 
        /* in case of a joker register: just return a valid register */
        if (arch_register_type_is(reg, joker)) {
-               const arch_register_req_t *req;
-
-               /* ask for the requirements */
-               req = arch_get_register_req(arch_env, irn, pos);
+               const arch_register_req_t *req = arch_get_register_req(irn, pos);
 
                if (arch_register_req_is(req, limited)) {
                        /* in case of limited requirements: get the first allowed register */
@@ -123,9 +116,9 @@ static const arch_register_t *get_out_reg(const ir_node *node, int pos)
     /*           Proj with the corresponding projnum for the register */
 
     if (get_irn_mode(node) != mode_T) {
-        reg = arch_get_irn_register(arch_env, node);
+        reg = arch_get_irn_register(node);
     } else if (is_arm_irn(node)) {
-        reg = get_arm_out_reg(node, pos);
+        reg = arch_irn_get_register(node, pos);
     } else {
         const ir_edge_t *edge;
 
@@ -133,7 +126,7 @@ static const arch_register_t *get_out_reg(const ir_node *node, int pos)
             proj = get_edge_src_irn(edge);
             assert(is_Proj(proj) && "non-Proj from mode_T node");
             if (get_Proj_proj(proj) == pos) {
-                reg = arch_get_irn_register(arch_env, proj);
+                reg = arch_get_irn_register(proj);
                 break;
             }
         }
@@ -337,9 +330,9 @@ static ir_node *get_cfop_target_block(const ir_node *irn) {
  * Emits a block label for the given block.
  */
 static void arm_emit_block_name(const ir_node *block) {
-       if (has_Block_label(block)) {
-               be_emit_string(be_gas_block_label_prefix());
-               be_emit_irprintf("%lu", get_Block_label(block));
+       if (has_Block_entity(block)) {
+               ir_entity *entity = get_Block_entity(block);
+               be_gas_emit_entity(entity);
        } else {
                be_emit_cstring(BLOCK_PREFIX);
                be_emit_irprintf("%d", get_irn_node_nr(block));
@@ -703,7 +696,7 @@ static void emit_arm_SwitchJmp(const ir_node *irn) {
        block_nr = get_irn_node_nr(irn);
        n_projs = get_arm_SwitchJmp_n_projs(irn);
 
-       projs = xcalloc(n_projs , sizeof(ir_node*));
+       projs = XMALLOCNZ(ir_node*, n_projs);
 
        foreach_out_edge(irn, edge) {
                proj = get_edge_src_irn(edge);
@@ -816,7 +809,7 @@ static void emit_be_Copy(const ir_node *irn) {
        }
 
        if (mode_is_float(mode)) {
-               if (USE_FPA(isa)) {
+               if (USE_FPA(cg->isa)) {
                        be_emit_cstring("\tmvf");
                        arm_emit_mode(irn);
                        be_emit_char(' ');
@@ -969,7 +962,7 @@ static void emit_arm_fpaDbl2GP(const ir_node *irn) {
 
 static void emit_arm_LdTls(const ir_node *irn) {
        (void) irn;
-       panic("TLS not supported for this target\n");
+       panic("TLS not supported for this target");
        /* Er... our gcc does not support it... Install a newer toolchain. */
 }
 
@@ -996,7 +989,7 @@ typedef void (emit_func)(const ir_node *irn);
 /**
  * Set a node emitter. Make it a bit more type safe.
  */
-static INLINE void set_emitter(ir_op *op, emit_func arm_emit_node) {
+static inline void set_emitter(ir_op *op, emit_func arm_emit_node) {
        op->ops.generic = (op_func)arm_emit_node;
 }
 
@@ -1206,8 +1199,6 @@ void arm_gen_routine(const arm_code_gen_t *arm_cg, ir_graph *irg) {
        ir_entity *entity     = get_irg_entity(irg);
 
        cg        = arm_cg;
-       isa       = (const arm_isa_t *)cg->arch_env;
-       arch_env  = cg->arch_env;
        sym_or_tv = new_set(cmp_sym_or_tv, 8);
 
        arm_register_emitters();