Commit 114278e7 by Richard Henderson Committed by Richard Henderson

s390.c (SYMBOL_FLAG_ALIGN1): New.

        * config/s390/s390.c (SYMBOL_FLAG_ALIGN1): New.
        (tls_model_chars): Remove.
        (larl_operand): Use SYMBOL_REF_FLAGS.
        (tls_symbolic_operand): Use SYMBOL_REF_TLS_MODEL.
        (legitimize_pic_address): Use SYMBOL_REF_LOCAL_P.
        (s390_output_mi_thunk): Likewise.
        (s390_emit_prologue): Set SYMBOL_FLAG_LOCAL as needed.
        (s390_function_profiler): Likewise.
        (s390_encode_section_info): Use default_encode_section_info
        and SYMBOL_FLAG_ALIGN1.
        (s390_strip_name_encoding): Remove.
        * config/s390/s390.h (ASM_OUTPUT_LABELREF): Remove.
        * config/s390/s390.md (call, call_value): Use SYMBOL_REF_LOCAL_P.
        (builtin_setjmp_receiver): Set SYMBOL_FLAG_LOCAL as needed.

From-SVN: r65734
parent e95ef187
2003-04-17 Richard Henderson <rth@redhat.com> 2003-04-17 Richard Henderson <rth@redhat.com>
* config/s390/s390.c (SYMBOL_FLAG_ALIGN1): New.
(tls_model_chars): Remove.
(larl_operand): Use SYMBOL_REF_FLAGS.
(tls_symbolic_operand): Use SYMBOL_REF_TLS_MODEL.
(legitimize_pic_address): Use SYMBOL_REF_LOCAL_P.
(s390_output_mi_thunk): Likewise.
(s390_emit_prologue): Set SYMBOL_FLAG_LOCAL as needed.
(s390_function_profiler): Likewise.
(s390_encode_section_info): Use default_encode_section_info
and SYMBOL_FLAG_ALIGN1.
(s390_strip_name_encoding): Remove.
* config/s390/s390.h (ASM_OUTPUT_LABELREF): Remove.
* config/s390/s390.md (call, call_value): Use SYMBOL_REF_LOCAL_P.
(builtin_setjmp_receiver): Set SYMBOL_FLAG_LOCAL as needed.
2003-04-17 Richard Henderson <rth@redhat.com>
* config/ns32k/ns32k.c (ns32k_encode_section_info): Remove. * config/ns32k/ns32k.c (ns32k_encode_section_info): Remove.
(global_symbolic_reference_mentioned_p): Use SYMBOL_REF_LOCAL_P. (global_symbolic_reference_mentioned_p): Use SYMBOL_REF_LOCAL_P.
(print_operand_address): Likewise. (print_operand_address): Likewise.
......
...@@ -50,11 +50,14 @@ Boston, MA 02111-1307, USA. */ ...@@ -50,11 +50,14 @@ Boston, MA 02111-1307, USA. */
#include "langhooks.h" #include "langhooks.h"
#include "optabs.h" #include "optabs.h"
/* Machine-specific symbol_ref flags. */
#define SYMBOL_FLAG_ALIGN1 (SYMBOL_FLAG_MACH_DEP << 0)
static bool s390_assemble_integer PARAMS ((rtx, unsigned int, int)); static bool s390_assemble_integer PARAMS ((rtx, unsigned int, int));
static void s390_select_rtx_section PARAMS ((enum machine_mode, rtx, static void s390_select_rtx_section PARAMS ((enum machine_mode, rtx,
unsigned HOST_WIDE_INT)); unsigned HOST_WIDE_INT));
static void s390_encode_section_info PARAMS ((tree, int)); static void s390_encode_section_info PARAMS ((tree, int));
static const char *s390_strip_name_encoding PARAMS ((const char *));
static bool s390_cannot_force_const_mem PARAMS ((rtx)); static bool s390_cannot_force_const_mem PARAMS ((rtx));
static rtx s390_delegitimize_address PARAMS ((rtx)); static rtx s390_delegitimize_address PARAMS ((rtx));
static void s390_init_builtins PARAMS ((void)); static void s390_init_builtins PARAMS ((void));
...@@ -89,8 +92,6 @@ static int s390_address_cost PARAMS ((rtx)); ...@@ -89,8 +92,6 @@ static int s390_address_cost PARAMS ((rtx));
#undef TARGET_ENCODE_SECTION_INFO #undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO s390_encode_section_info #define TARGET_ENCODE_SECTION_INFO s390_encode_section_info
#undef TARGET_STRIP_NAME_ENCODING
#define TARGET_STRIP_NAME_ENCODING s390_strip_name_encoding
#ifdef HAVE_AS_TLS #ifdef HAVE_AS_TLS
#undef TARGET_HAVE_TLS #undef TARGET_HAVE_TLS
...@@ -135,9 +136,6 @@ static int s390_sr_alias_set = 0; ...@@ -135,9 +136,6 @@ static int s390_sr_alias_set = 0;
emitted. */ emitted. */
rtx s390_compare_op0, s390_compare_op1; rtx s390_compare_op0, s390_compare_op1;
/* The encoding characters for the four TLS models present in ELF. */
static char const tls_model_chars[] = " GLil";
/* Structure used to hold the components of a S/390 memory /* Structure used to hold the components of a S/390 memory
address. A legitimate address on S/390 is of the general address. A legitimate address on S/390 is of the general
form form
...@@ -1050,12 +1048,10 @@ larl_operand (op, mode) ...@@ -1050,12 +1048,10 @@ larl_operand (op, mode)
/* Allow labels and local symbols. */ /* Allow labels and local symbols. */
if (GET_CODE (op) == LABEL_REF) if (GET_CODE (op) == LABEL_REF)
return 1; return 1;
if (GET_CODE (op) == SYMBOL_REF if (GET_CODE (op) == SYMBOL_REF)
&& XSTR (op, 0)[0] != '@' return ((SYMBOL_REF_FLAGS (op) & SYMBOL_FLAG_ALIGN1) == 0
&& !tls_symbolic_operand (op) && SYMBOL_REF_TLS_MODEL (op) == 0
&& (!flag_pic || SYMBOL_REF_FLAG (op) && (!flag_pic || SYMBOL_REF_LOCAL_P (op)));
|| CONSTANT_POOL_ADDRESS_P (op)))
return 1;
/* Everything else must have a CONST, so strip it. */ /* Everything else must have a CONST, so strip it. */
if (GET_CODE (op) != CONST) if (GET_CODE (op) != CONST)
...@@ -1074,12 +1070,10 @@ larl_operand (op, mode) ...@@ -1074,12 +1070,10 @@ larl_operand (op, mode)
/* Labels and local symbols allowed here as well. */ /* Labels and local symbols allowed here as well. */
if (GET_CODE (op) == LABEL_REF) if (GET_CODE (op) == LABEL_REF)
return 1; return 1;
if (GET_CODE (op) == SYMBOL_REF if (GET_CODE (op) == SYMBOL_REF)
&& XSTR (op, 0)[0] != '@' return ((SYMBOL_REF_FLAGS (op) & SYMBOL_FLAG_ALIGN1) == 0
&& !tls_symbolic_operand (op) && SYMBOL_REF_TLS_MODEL (op) == 0
&& (!flag_pic || SYMBOL_REF_FLAG (op) && (!flag_pic || SYMBOL_REF_LOCAL_P (op)));
|| CONSTANT_POOL_ADDRESS_P (op)))
return 1;
/* Now we must have a @GOTENT offset or @PLT stub /* Now we must have a @GOTENT offset or @PLT stub
or an @INDNTPOFF TLS offset. */ or an @INDNTPOFF TLS offset. */
...@@ -1320,15 +1314,9 @@ int ...@@ -1320,15 +1314,9 @@ int
tls_symbolic_operand (op) tls_symbolic_operand (op)
register rtx op; register rtx op;
{ {
const char *symbol_str;
if (GET_CODE (op) != SYMBOL_REF) if (GET_CODE (op) != SYMBOL_REF)
return 0; return 0;
symbol_str = XSTR (op, 0); return SYMBOL_REF_TLS_MODEL (op);
if (symbol_str[0] != '%')
return 0;
return strchr (tls_model_chars, symbol_str[1]) - tls_model_chars;
} }
/* Return true if OP is a load multiple operation. It is known to be a /* Return true if OP is a load multiple operation. It is known to be a
...@@ -2159,7 +2147,7 @@ s390_load_address (dst, src) ...@@ -2159,7 +2147,7 @@ s390_load_address (dst, src)
2. Static data references, constant pool addresses, and code labels 2. Static data references, constant pool addresses, and code labels
compute the address as an offset from the GOT, whose base is in compute the address as an offset from the GOT, whose base is in
the PIC reg. Static data objects have SYMBOL_REF_FLAG set to the PIC reg. Static data objects have SYMBOL_FLAG_LOCAL set to
differentiate them from global data objects. The returned differentiate them from global data objects. The returned
address is the PIC reg + an unspec constant. address is the PIC reg + an unspec constant.
...@@ -2176,9 +2164,7 @@ legitimize_pic_address (orig, reg) ...@@ -2176,9 +2164,7 @@ legitimize_pic_address (orig, reg)
rtx base; rtx base;
if (GET_CODE (addr) == LABEL_REF if (GET_CODE (addr) == LABEL_REF
|| (GET_CODE (addr) == SYMBOL_REF || (GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_LOCAL_P (addr)))
&& (SYMBOL_REF_FLAG (addr)
|| CONSTANT_POOL_ADDRESS_P (addr))))
{ {
/* This is a local symbol. */ /* This is a local symbol. */
if (TARGET_64BIT && larl_operand (addr, VOIDmode)) if (TARGET_64BIT && larl_operand (addr, VOIDmode))
...@@ -2330,9 +2316,7 @@ legitimize_pic_address (orig, reg) ...@@ -2330,9 +2316,7 @@ legitimize_pic_address (orig, reg)
/* Check first to see if this is a constant offset /* Check first to see if this is a constant offset
from a local symbol reference. */ from a local symbol reference. */
if ((GET_CODE (op0) == LABEL_REF if ((GET_CODE (op0) == LABEL_REF
|| (GET_CODE (op0) == SYMBOL_REF || (GET_CODE (op0) == SYMBOL_REF && SYMBOL_REF_LOCAL_P (op0)))
&& (SYMBOL_REF_FLAG (op0)
|| CONSTANT_POOL_ADDRESS_P (op0))))
&& GET_CODE (op1) == CONST_INT) && GET_CODE (op1) == CONST_INT)
{ {
if (TARGET_64BIT && larl_operand (op0, VOIDmode)) if (TARGET_64BIT && larl_operand (op0, VOIDmode))
...@@ -5485,7 +5469,7 @@ s390_emit_prologue () ...@@ -5485,7 +5469,7 @@ s390_emit_prologue ()
if (flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM]) if (flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM])
{ {
rtx got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_"); rtx got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
SYMBOL_REF_FLAG (got_symbol) = 1; SYMBOL_REF_FLAGS (got_symbol) = SYMBOL_FLAG_LOCAL;
if (TARGET_64BIT) if (TARGET_64BIT)
{ {
...@@ -6354,7 +6338,7 @@ s390_function_profiler (file, labelno) ...@@ -6354,7 +6338,7 @@ s390_function_profiler (file, labelno)
op[2] = gen_rtx_REG (Pmode, 1); op[2] = gen_rtx_REG (Pmode, 1);
op[3] = gen_rtx_SYMBOL_REF (Pmode, label); op[3] = gen_rtx_SYMBOL_REF (Pmode, label);
SYMBOL_REF_FLAG (op[3]) = 1; SYMBOL_REF_FLAGS (op[3]) = SYMBOL_FLAG_LOCAL;
op[4] = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); op[4] = gen_rtx_SYMBOL_REF (Pmode, "_mcount");
if (flag_pic) if (flag_pic)
...@@ -6419,101 +6403,20 @@ s390_select_rtx_section (mode, x, align) ...@@ -6419,101 +6403,20 @@ s390_select_rtx_section (mode, x, align)
} }
/* Encode symbol attributes (local vs. global, tls model) of a SYMBOL_REF /* Encode symbol attributes (local vs. global, tls model) of a SYMBOL_REF
into its name and SYMBOL_REF_FLAG. */ into its SYMBOL_REF_FLAGS. */
static void static void
s390_encode_section_info (decl, first) s390_encode_section_info (decl, first)
tree decl; tree decl;
int first ATTRIBUTE_UNUSED; int first;
{ {
bool local_p = (*targetm.binds_local_p) (decl); default_encode_section_info (decl, first);
rtx rtl, symbol;
rtl = DECL_P (decl) ? DECL_RTL (decl) : TREE_CST_RTL (decl); /* If a variable has a forced alignment to < 2 bytes, mark it with
if (GET_CODE (rtl) != MEM) SYMBOL_FLAG_ALIGN1 to prevent it from being used as LARL operand. */
return; if (TREE_CODE (decl) == VAR_DECL
symbol = XEXP (rtl, 0); && DECL_USER_ALIGN (decl) && DECL_ALIGN (decl) < 16)
if (GET_CODE (symbol) != SYMBOL_REF) SYMBOL_REF_FLAGS (XEXP (DECL_RTL (decl), 0)) |= SYMBOL_FLAG_ALIGN1;
return;
/* When using PIC, SYMBOL_REF_FLAG marks non-global symbols
that can be accessed directly. */
if (flag_pic)
SYMBOL_REF_FLAG (symbol) = local_p;
/* Encode thread-local data with %[GLil] for "global dynamic",
"local dynamic", "initial exec" or "local exec" TLS models,
respectively. */
if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
{
const char *symbol_str = XSTR (symbol, 0);
char *newstr;
size_t len;
enum tls_model kind = decl_tls_model (decl);
if (!flag_pic)
{
/* We don't allow non-pic code for shared libraries,
so don't generate GD/LD TLS models for non-pic code. */
switch (kind)
{
case TLS_MODEL_GLOBAL_DYNAMIC:
kind = TLS_MODEL_INITIAL_EXEC; break;
case TLS_MODEL_LOCAL_DYNAMIC:
kind = TLS_MODEL_LOCAL_EXEC; break;
default:
break;
}
}
if (symbol_str[0] == '%')
{
if (symbol_str[1] == tls_model_chars[kind])
return;
symbol_str += 2;
}
len = strlen (symbol_str) + 1;
newstr = alloca (len + 2);
newstr[0] = '%';
newstr[1] = tls_model_chars[kind];
memcpy (newstr + 2, symbol_str, len);
XSTR (symbol, 0) = ggc_alloc_string (newstr, len + 2 - 1);
}
/* If a variable has a forced alignment to < 2 bytes, mark it
with '@' to prevent it from being used as LARL operand. */
else if (TREE_CODE (decl) == VAR_DECL
&& DECL_USER_ALIGN (decl) && DECL_ALIGN (decl) < 16
&& XSTR (symbol, 0)[0] != '@')
{
const char *symbol_str = XSTR (symbol, 0);
size_t len = strlen (symbol_str) + 1;
char *newstr = alloca (len + 1);
newstr[0] = '@';
memcpy (newstr + 1, symbol_str, len);
XSTR (symbol, 0) = ggc_alloc_string (newstr, len + 1 - 1);
}
}
/* Undo the above when printing symbol names. */
static const char *
s390_strip_name_encoding (str)
const char *str;
{
if (str[0] == '%')
str += 2;
if (str[0] == '@')
str += 1;
if (str[0] == '*')
str += 1;
return str;
} }
/* Output thunk to FILE that implements a C++ virtual function call (with /* Output thunk to FILE that implements a C++ virtual function call (with
...@@ -6534,7 +6437,7 @@ s390_output_mi_thunk (file, thunk, delta, vcall_offset, function) ...@@ -6534,7 +6437,7 @@ s390_output_mi_thunk (file, thunk, delta, vcall_offset, function)
/* Operand 0 is the target function. */ /* Operand 0 is the target function. */
op[0] = XEXP (DECL_RTL (function), 0); op[0] = XEXP (DECL_RTL (function), 0);
if (flag_pic && !SYMBOL_REF_FLAG (op[0])) if (flag_pic && !SYMBOL_REF_LOCAL_P (op[0]))
{ {
op[0] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[0]), 113); op[0] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[0]), 113);
op[0] = gen_rtx_CONST (Pmode, op[0]); op[0] = gen_rtx_CONST (Pmode, op[0]);
......
...@@ -917,10 +917,6 @@ extern int flag_pic; ...@@ -917,10 +917,6 @@ extern int flag_pic;
#define ASM_OUTPUT_SKIP(FILE, SIZE) \ #define ASM_OUTPUT_SKIP(FILE, SIZE) \
fprintf ((FILE), "\t.set\t.,.+%u\n", (SIZE)) fprintf ((FILE), "\t.set\t.,.+%u\n", (SIZE))
/* Output a reference to a user-level label named NAME. */
#define ASM_OUTPUT_LABELREF(FILE, NAME) \
asm_fprintf ((FILE), "%U%s", (*targetm.strip_name_encoding) (NAME))
/* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */ /* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */
#define LOCAL_LABEL_PREFIX "." #define LOCAL_LABEL_PREFIX "."
......
...@@ -6256,7 +6256,7 @@ ...@@ -6256,7 +6256,7 @@
/* When calling a global routine in PIC mode, we must /* When calling a global routine in PIC mode, we must
replace the symbol itself with the PLT stub. */ replace the symbol itself with the PLT stub. */
if (flag_pic && !SYMBOL_REF_FLAG (sym)) if (flag_pic && !SYMBOL_REF_LOCAL_P (sym))
{ {
sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), 113); sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), 113);
sym = gen_rtx_CONST (Pmode, sym); sym = gen_rtx_CONST (Pmode, sym);
...@@ -6375,7 +6375,7 @@ ...@@ -6375,7 +6375,7 @@
/* When calling a global routine in PIC mode, we must /* When calling a global routine in PIC mode, we must
replace the symbol itself with the PLT stub. */ replace the symbol itself with the PLT stub. */
if (flag_pic && !SYMBOL_REF_FLAG (sym)) if (flag_pic && !SYMBOL_REF_LOCAL_P (sym))
{ {
sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), 113); sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), 113);
sym = gen_rtx_CONST (Pmode, sym); sym = gen_rtx_CONST (Pmode, sym);
...@@ -6720,7 +6720,7 @@ ...@@ -6720,7 +6720,7 @@
{ {
rtx gotreg = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM); rtx gotreg = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
rtx got = gen_rtx_SYMBOL_REF (Pmode, \"_GLOBAL_OFFSET_TABLE_\"); rtx got = gen_rtx_SYMBOL_REF (Pmode, \"_GLOBAL_OFFSET_TABLE_\");
SYMBOL_REF_FLAG (got) = 1; SYMBOL_REF_FLAGS (got) = SYMBOL_FLAG_LOCAL;
emit_move_insn (gotreg, got); emit_move_insn (gotreg, got);
emit_insn (gen_rtx_USE (VOIDmode, gotreg)); emit_insn (gen_rtx_USE (VOIDmode, gotreg));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment