fixed SymConst address handling (stores and moves)
authorChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Wed, 22 Mar 2006 10:09:06 +0000 (10:09 +0000)
committerChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Wed, 22 Mar 2006 10:09:06 +0000 (10:09 +0000)
ir/be/ia32/ia32_emitter.c
ir/be/ia32/ia32_spec.pl
ir/be/ia32/ia32_transform.c

index 143ae0d..d391370 100644 (file)
@@ -297,7 +297,10 @@ char *ia32_emit_binop(const ir_node *n, ia32_emit_env_t *env) {
                        break;
                case ia32_AddrModeD:
                        if (get_ia32_cnst(n)) {
-                               lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%s, %s", ia32_emit_am(n, env), get_ia32_cnst(n));
+                               lc_esnprintf(ia32_get_arg_env(), buf, SNPRINTF_BUF_LEN, "%s,%s%s",
+                                       ia32_emit_am(n, env),
+                                       get_ia32_sc(n) ? " OFFSET FLAT:" : " ",    /* In case of a symconst we must add OFFSET to */
+                                       get_ia32_cnst(n));                         /* tell the assembler to store it's address.   */
                        }
                        else {
                                const arch_register_t *in1 = get_in_reg(n, 2);
index 3b03f16..afc7581 100644 (file)
@@ -371,7 +371,7 @@ $comment_string = "/*";
   }
   else {
     if (get_ia32_sc(n)) {
-6.    lea %D1, %C /* Load address of SymConst into register */
+6.    mov %D1, OFFSET FLAT:%C /* Move address of SymConst into register */
     }
        else {
 6.    mov %D1, %C /* Mov Const into register */
@@ -553,7 +553,7 @@ $comment_string = "/*";
   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
   "reg_req"  => { "in" => [ "gp", "gp", "fp", "none" ] },
-  "emit"     => '. movs%M %ia32_emit_am, %S3 /* Store(%S3) -> (%A1) */'
+  "emit"     => '. movs%M %ia32_emit_binop /* Store(%S3) -> (%A1) */'
 },
 
 # CopyB
index 7331314..1cec30f 100644 (file)
@@ -1204,7 +1204,7 @@ static ir_node *gen_Store(ia32_transform_env_t *env) {
        ir_node *new_op;
 
        /* in case of storing a const (but not a symconst) -> make it an attribute */
-       if (is_ia32_Const(val) && get_ia32_op_type(val) == ia32_Const) {
+       if (is_ia32_Const(val)) {
                sval = noreg;
        }
 
@@ -1219,7 +1219,7 @@ static ir_node *gen_Store(ia32_transform_env_t *env) {
        }
 
        /* stored const is an attribute (saves a register) */
-       if (is_ia32_Const(val) && get_ia32_op_type(val) == ia32_Const) {
+       if (is_ia32_Const(val)) {
                set_ia32_Immop_attr(new_op, val);
        }