r2 for its caller's TOC. Such a function may make sibcalls to any
function, whether local or external, without restriction based on
TOC-save/restore rules. */
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
return true;
/* Otherwise, under the AIX or ELFv2 ABIs we can't allow sibcalls
return false;
/* PC-relative functions never generate a global entry point prologue. */
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
return false;
/* Ensure we have a global entry point for thunks. ??? We could
fputs ("\n", file);
}
- else if (rs6000_pcrel_p (cfun))
+ else if (rs6000_pcrel_p ())
{
const char *name = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
/* All functions compiled to use PC-relative addressing will
dest = gen_reg_rtx (Pmode);
if (model == TLS_MODEL_LOCAL_EXEC
- && (rs6000_tls_size == 16 || rs6000_pcrel_p (cfun)))
+ && (rs6000_tls_size == 16 || rs6000_pcrel_p ()))
{
rtx tlsreg;
them in the .got section. So use a pointer to the .got section,
not one to secondary TOC sections used by 64-bit -mminimal-toc,
or to secondary GOT sections used by 32-bit -fPIC. */
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
got = const0_rtx;
else if (TARGET_64BIT)
got = gen_rtx_REG (Pmode, 2);
rtx uns = gen_rtx_UNSPEC (Pmode, vec, UNSPEC_TLS_GET_ADDR);
set_unique_reg_note (get_last_insn (), REG_EQUAL, uns);
- if (rs6000_tls_size == 16 || rs6000_pcrel_p (cfun))
+ if (rs6000_tls_size == 16 || rs6000_pcrel_p ())
{
if (TARGET_64BIT)
insn = gen_tls_dtprel_64 (dest, tmp1, addr);
else
insn = gen_tls_got_tprel_32 (tmp2, got, addr);
emit_insn (insn);
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
{
if (TARGET_64BIT)
insn = gen_tls_tls_pcrel_64 (dest, tmp2, addr);
? "+32768" : ""));
static char str[32]; /* 1 spare */
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
sprintf (str, "b%s %s@notoc%s", sibcall ? "" : "l", z, arg);
else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg,
rel64);
}
- const char *notoc = rs6000_pcrel_p (cfun) ? "_NOTOC" : "";
+ const char *notoc = rs6000_pcrel_p () ? "_NOTOC" : "";
const char *addend = (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT
&& flag_pic == 2 ? "+32768" : "");
if (!speculate)
else if (!speculate)
s += sprintf (s, "crset 2\n\t");
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
{
if (speculate)
sprintf (s, "b%%T%ul", funop);
{
rtx base = const0_rtx;
int regno = 12;
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
{
rtx reg = gen_rtx_REG (Pmode, regno);
rtx u = gen_rtx_UNSPEC_VOLATILE (Pmode,
if (!SYMBOL_REF_P (func)
|| (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (func)))
{
- if (!rs6000_pcrel_p (cfun))
+ if (!rs6000_pcrel_p ())
{
/* Save the TOC into its reserved slot before the call,
and prepare to restore it after the call. */
else
{
/* No TOC register needed for calls from PC-relative callers. */
- if (!rs6000_pcrel_p (cfun))
+ if (!rs6000_pcrel_p ())
/* Direct calls use the TOC: for local calls, the callee will
assume the TOC register is set; for non-local calls, the
PLT stub needs the TOC register. */
insn = emit_call_insn (insn);
/* Note use of the TOC register. */
- if (!rs6000_pcrel_p (cfun))
+ if (!rs6000_pcrel_p ())
use_reg (&CALL_INSN_FUNCTION_USAGE (insn),
gen_rtx_REG (Pmode, TOC_REGNUM));
/* Return whether we should generate PC-relative code for *FN. */
bool
-rs6000_pcrel_p (struct function *fn)
+rs6000_function_pcrel_p (struct function *fn)
{
if (DEFAULT_ABI != ABI_ELFv2)
return false;
return rs6000_fndecl_pcrel_p (fn->decl);
}
+/* Return whether we should generate PC-relative code for the current
+ function. */
+bool
+rs6000_pcrel_p ()
+{
+ return (DEFAULT_ABI == ABI_ELFv2
+ && (rs6000_isa_flags & OPTION_MASK_PCREL) != 0
+ && TARGET_CMODEL == CMODEL_MEDIUM);
+}
+
\f
/* Given an address (ADDR), a mode (MODE), and what the format of the
non-prefixed address (NON_PREFIXED_FORMAT) is, return the instruction format
(match_operand:P 3 "" "")]
UNSPECV_PLT_PCREL))]
"HAVE_AS_PLTSEQ && TARGET_ELF
- && rs6000_pcrel_p (cfun)"
+ && rs6000_pcrel_p ()"
{
return rs6000_pltseq_template (operands, RS6000_PLTSEQ_PLT_PCREL34);
}
else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
output_asm_insn ("creqv 6,6,6", operands);
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
return "bl %z0@notoc";
return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@local" : "bl %z0";
}
else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
output_asm_insn ("creqv 6,6,6", operands);
- if (rs6000_pcrel_p (cfun))
+ if (rs6000_pcrel_p ())
return "bl %z1@notoc";
return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@local" : "bl %z1";
}
}
[(set_attr "type" "branch")
(set (attr "length")
- (if_then_else (match_test "rs6000_pcrel_p (cfun)")
+ (if_then_else (match_test "rs6000_pcrel_p ()")
(const_int 4)
(const_int 8)))])
}
[(set_attr "type" "branch")
(set (attr "length")
- (if_then_else (match_test "rs6000_pcrel_p (cfun)")
+ (if_then_else (match_test "rs6000_pcrel_p ()")
(const_int 4)
(const_int 8)))])
(match_operand 1))
(use (match_operand:SI 2 "immediate_operand" "n,n,n"))
(clobber (reg:P LR_REGNO))]
- "rs6000_pcrel_p (cfun)"
+ "rs6000_pcrel_p ()"
{
return rs6000_indirect_call_template (operands, 0);
}
(match_operand:P 2 "unspec_tls" "")))
(use (match_operand:SI 3 "immediate_operand" "n,n,n"))
(clobber (reg:P LR_REGNO))]
- "rs6000_pcrel_p (cfun)"
+ "rs6000_pcrel_p ()"
{
return rs6000_indirect_call_template (operands, 1);
}