- Fix a few more problems when creating and emitting constants
authorMatthias Braun <matze@braunis.de>
Mon, 11 Sep 2006 11:16:15 +0000 (11:16 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 11 Sep 2006 11:16:15 +0000 (11:16 +0000)
ir/be/ia32/ia32_emitter.c
ir/be/ia32/ia32_new_nodes.c

index 2211297..57fc734 100644 (file)
@@ -1792,22 +1792,21 @@ static void emit_ia32_Const(const ir_node *n, ia32_emit_env_t *env) {
        ir_mode *mode = get_irn_mode(n);
        tarval *tv = get_ia32_Immop_tarval(n);
 
-       /* beware: in some rare cases mode is mode_b which has no tarval_null() */
-       if (tv == get_tarval_b_false() || tv == get_tarval_null(mode)) {
-               const char *instr = "xor";
-               if (env->isa->opt_arch == arch_pentium_4) {
-                       /* P4 prefers sub r, r, others xor r, r */
-                       instr = "sub";
-               }
-               lc_esnprintf(arg_env, cmd_buf, 256, "%s %1D, %1D ", instr, n, n);
-               lc_esnprintf(arg_env, cmnt_buf, 256, "/* optimized mov 0 to register */");
-       }
-       else {
-               if (get_ia32_op_type(n) == ia32_SymConst) {
-                       lc_esnprintf(arg_env, cmd_buf, 256, "mov %1D, OFFSET FLAT:%C ", n, n);
-                       lc_esnprintf(arg_env, cmnt_buf, 256, "/* Move address of SymConst into register */");
-               }
-               else {
+       if (get_ia32_op_type(n) == ia32_SymConst) {
+               lc_esnprintf(arg_env, cmd_buf, 256, "mov %1D, OFFSET FLAT:%C ", n, n);
+               lc_esnprintf(arg_env, cmnt_buf, 256, "/* Move address of SymConst into register */");
+       } else {
+               assert(mode == get_tarval_mode(tv));
+               /* beware: in some rare cases mode is mode_b which has no tarval_null() */
+               if (tv == get_tarval_b_false() || tv == get_tarval_null(mode)) {
+                       const char *instr = "xor";
+                       if (env->isa->opt_arch == arch_pentium_4) {
+                               /* P4 prefers sub r, r, others xor r, r */
+                               instr = "sub";
+                       }
+                       lc_esnprintf(arg_env, cmd_buf, 256, "%s %1D, %1D ", instr, n, n);
+                       lc_esnprintf(arg_env, cmnt_buf, 256, "/* optimized mov 0 to register */");
+               } else {
                        lc_esnprintf(arg_env, cmd_buf, 256, "mov %1D, %C ", n, n);
                        lc_esnprintf(arg_env, cmnt_buf, 256, "/* Mov Const into register */");
                }
index d1b4df5..f100c24 100644 (file)
@@ -1172,8 +1172,9 @@ void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst) {
                        attr->cnst_val.tv = get_Const_tarval(cnst);
                        mode = get_tarval_mode(attr->cnst_val.tv);
                        if (mode_is_reference(mode) &&
-                           get_mode_null(mode) == attr->cnst_val.tv)
-                               attr->cnst_val.tv = get_mode_null(mode_Is);
+                           get_mode_null(mode) == attr->cnst_val.tv) {
+                               attr->cnst_val.tv = get_mode_null(mode_Iu);
+                       }
                        attr->cnst        = get_ident_for_tv(attr->cnst_val.tv);
                        break;
                case iro_SymConst: