OSDN Git Service

config/m32r.c (m32r_legitimize_pic_address): Changed to support GOTOFF
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Dec 2004 12:13:07 +0000 (12:13 +0000)
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Dec 2004 12:13:07 +0000 (12:13 +0000)
               relocation.
config/m32r.md (UNSPEC_GOTOFF): New.
               (gotoff_load_addr): New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92186 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/m32r/m32r.c
gcc/config/m32r/m32r.md

index 461f595..bbdaeab 100644 (file)
@@ -3,6 +3,11 @@
        * config/m32r/m32r.h (PREFERRED_DEBUGGING_TYPE):
        Use DWARF2_DEBUG.
 
        * config/m32r/m32r.h (PREFERRED_DEBUGGING_TYPE):
        Use DWARF2_DEBUG.
 
+       * config/m32r.c (m32r_legitimize_pic_address): Changed
+       to support GOTOFF relocation.
+       * config/m32r.md (UNSPEC_GOTOFF): New.
+       (gotoff_load_addr): New.
+
 2004-12-15  Richard Sandiford  <rsandifo@redhat.com>
 
        * config/mips/mips.c (mips_arg_info): Use FUNCTION_ARG_BOUNDARY to
 2004-12-15  Richard Sandiford  <rsandifo@redhat.com>
 
        * config/mips/mips.c (mips_arg_info): Use FUNCTION_ARG_BOUNDARY to
index 384b5ae..b5a5325 100644 (file)
@@ -1987,12 +1987,21 @@ m32r_legitimize_pic_address (rtx orig, rtx reg)
       else
         address = reg;
 
       else
         address = reg;
 
+      current_function_uses_pic_offset_table = 1;
+
+      if (GET_CODE (orig) == LABEL_REF
+          || (GET_CODE (orig) == SYMBOL_REF && SYMBOL_REF_LOCAL_P (orig)))
+        {
+          emit_insn (gen_gotoff_load_addr (reg, orig));
+          emit_insn (gen_addsi3 (reg, reg, pic_offset_table_rtx));
+          return reg;
+        }
+
       emit_insn (gen_pic_load_addr (address, orig));
 
       emit_insn (gen_addsi3 (address, address, pic_offset_table_rtx));
       pic_ref = gen_const_mem (Pmode, address);
       insn = emit_move_insn (reg, pic_ref);
       emit_insn (gen_pic_load_addr (address, orig));
 
       emit_insn (gen_addsi3 (address, address, pic_offset_table_rtx));
       pic_ref = gen_const_mem (Pmode, address);
       insn = emit_move_insn (reg, pic_ref);
-      current_function_uses_pic_offset_table = 1;
 #if 0
       /* Put a REG_EQUAL note on this insn, so that it can be optimized
          by loop.  */
 #if 0
       /* Put a REG_EQUAL note on this insn, so that it can be optimized
          by loop.  */
index f1236d4..37f94e4 100644 (file)
@@ -31,7 +31,9 @@
   [(UNSPEC_LOAD_SDA_BASE       2)
    (UNSPEC_SET_CBIT            3)
    (UNSPEC_PIC_LOAD_ADDR       4)
   [(UNSPEC_LOAD_SDA_BASE       2)
    (UNSPEC_SET_CBIT            3)
    (UNSPEC_PIC_LOAD_ADDR       4)
-   (UNSPEC_GET_PC              5)])
+   (UNSPEC_GET_PC              5)
+   (UNSPEC_GOTOFF              6)
+   ])
 
 ;; Insn type.  Used to default other attribute values.
 (define_attr "type"
 
 ;; Insn type.  Used to default other attribute values.
 (define_attr "type"
   "ld24 %0,%#%1"
   [(set_attr "type" "int4")])
 
   "ld24 %0,%#%1"
   [(set_attr "type" "int4")])
 
+(define_insn "gotoff_load_addr"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+        (unspec:SI [(match_operand 1 "" "")] UNSPEC_GOTOFF))]
+  "flag_pic"
+  "seth %0, %#shigh(%1@GOTOFF)\;add3 %0, %0, low(%1@GOTOFF)"
+  [(set_attr "type"    "int4")
+   (set_attr "length"  "8")])
+
 ;; Load program counter insns.
 
 (define_insn "get_pc"
 ;; Load program counter insns.
 
 (define_insn "get_pc"