X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fhalfpic.c;h=3e0ae2135e06a3f0505b203e5eb9f5b42e26886d;hb=23d42a4b85e7fed42ffcb3f41962197ab73db92f;hp=fdbaccd2ee02d882be03c05d4bd9a637b55dd801;hpb=b550e0588e54efcea40f213bc2a92149514efa19;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/halfpic.c b/gcc/halfpic.c index fdbaccd2ee0..3e0ae2135e0 100644 --- a/gcc/halfpic.c +++ b/gcc/halfpic.c @@ -15,7 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ /* The OSF/rose half-pic model assumes that the non-library code does not need to have full PIC (position independent code), but rather, @@ -34,7 +35,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "tree.h" #include "rtl.h" #include -#include #include "obstack.h" #define obstack_chunk_alloc xmalloc @@ -46,9 +46,10 @@ extern rtx eliminate_constant_term (); extern void assemble_name (); extern void output_addr_const (); -int flag_half_pic; /* Global half-pic flag. */ -int half_pic_number_ptrs; /* # distinct pointers found */ -int half_pic_number_refs; /* # half-pic references */ +int flag_half_pic = 0; /* Global half-pic flag. */ +int half_pic_number_ptrs = 0; /* # distinct pointers found */ +int half_pic_number_refs = 0; /* # half-pic references */ +int (*ptr_half_pic_address_p)() = half_pic_address_p; /* Obstack to hold generated pic names. */ static struct obstack half_pic_obstack; @@ -134,7 +135,7 @@ half_pic_hash (name, len, create_p) /* name not in hash table. */ if (!create_p) - return (struct all_refs *)0; + return (struct all_refs *) 0; ptr = (struct all_refs *) obstack_alloc (&half_pic_obstack, sizeof (struct all_refs)); *ptr = zero_all_refs; @@ -143,7 +144,7 @@ half_pic_hash (name, len, create_p) ptr->real_len = len; /* Update circular links. */ - if (first == (struct all_refs *)0) + if (first == (struct all_refs *) 0) ptr->hash_next = ptr; else @@ -209,14 +210,26 @@ half_pic_encode (decl) if (code != VAR_DECL && code != FUNCTION_DECL) return; - /* If this is not an external reference, it can't be half-pic. */ - if (!TREE_EXTERNAL (decl)) - return; - asm_name = DECL_ASSEMBLER_NAME (decl); + if (!asm_name) return; +#ifdef HALF_PIC_DEBUG + if (HALF_PIC_DEBUG) + { + if (HALF_PIC_DEBUG) + fprintf (stderr, "\n========== Half_pic_encode %.*s\n", + IDENTIFIER_LENGTH (asm_name), + IDENTIFIER_POINTER (asm_name)); + debug_tree (decl); + } +#endif + + /* If this is not an external reference, it can't be half-pic. */ + if (!DECL_EXTERNAL (decl) && (code != VAR_DECL || !TREE_PUBLIC (decl))) + return; + ptr = half_pic_hash (IDENTIFIER_POINTER (asm_name), IDENTIFIER_LENGTH (asm_name), TRUE); @@ -225,7 +238,7 @@ half_pic_encode (decl) #ifdef HALF_PIC_DEBUG if (HALF_PIC_DEBUG) - fprintf (stderr, "\n========== Half_pic_encode %.*s\n", + fprintf (stderr, "\n%.*s is half-pic\n", IDENTIFIER_LENGTH (asm_name), IDENTIFIER_POINTER (asm_name)); #endif @@ -256,6 +269,30 @@ half_pic_declare (name) } +/* Mark that an object is explicitly external. */ + +void +half_pic_external (name) + char *name; +{ + struct all_refs *ptr; + + if (!flag_half_pic) + return; + + ptr = half_pic_hash (name, 0, TRUE); + if (!ptr) + return; + + ptr->external_p = TRUE; + +#ifdef HALF_PIC_DEBUG + if (HALF_PIC_DEBUG) + fprintf (stderr, "\n========== Half_pic_external %s\n", name); +#endif +} + + /* Return whether an address is half-pic. */ int @@ -277,7 +314,7 @@ half_pic_address_p (addr) case CONST: { rtx offset = const0_rtx; - addr = eliminate_constant_term (addr, &offset); + addr = eliminate_constant_term (XEXP (addr, 0), &offset); if (GET_CODE (addr) != SYMBOL_REF) return FALSE; } @@ -305,7 +342,7 @@ half_pic_address_p (addr) return FALSE; ptr = half_pic_hash (name, len, FALSE); - if (ptr == (struct all_refs *)0) + if (ptr == (struct all_refs *) 0) return FALSE; if (ptr->external_p) @@ -339,7 +376,7 @@ half_pic_ptr (operand) name = XSTR (operand, 0); len = strlen (name); p = half_pic_hash (name, len, FALSE); - if (p == (struct all_refs *)0 || !p->external_p) + if (p == (struct all_refs *) 0 || !p->external_p) return operand; if (!p->pointer_p)