aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/darwin.c
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2005-08-24 07:48:45 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2005-08-24 07:48:45 +0000
commit14a07c92824f33079e12d00118ef1a434128ac82 (patch)
treef4f0bb0f5074ee57bc0f4122196ae5ef2f886cfa /gcc/config/darwin.c
parentd49195a31bf02eed0b8d8360806d4c20602d75e0 (diff)
downloadgcc-14a07c92824f33079e12d00118ef1a434128ac82.zip
gcc-14a07c92824f33079e12d00118ef1a434128ac82.tar.gz
gcc-14a07c92824f33079e12d00118ef1a434128ac82.tar.bz2
darwin.c (gen_pic_offset): New.
2005-08-24 Paolo Bonzini <bonzini@gnu.org> * config/darwin.c (gen_pic_offset): New. (machopic_indirect_data_reference, machopic_legitimize_pic_address): Use it. From-SVN: r103434
Diffstat (limited to 'gcc/config/darwin.c')
-rw-r--r--gcc/config/darwin.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index c7cd1a3..bd5d5a8 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -227,6 +227,17 @@ machopic_function_base_sym (void)
return sym_ref;
}
+/* Return either ORIG or (const:P (minus:P ORIG PIC_BASE)), depending
+ on whether pic_base is NULL or not. */
+static inline rtx
+gen_pic_offset (rtx orig, rtx pic_base)
+{
+ if (!pic_base)
+ return orig;
+ else
+ return gen_rtx_CONST (Pmode, gen_rtx_MINUS (Pmode, orig, pic_base));
+}
+
static GTY(()) const char * function_base_func_name;
static GTY(()) int current_pic_label_num;
@@ -433,8 +444,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
{
#if defined (TARGET_TOC) || defined (HAVE_lo_sum)
rtx pic_base = machopic_function_base_sym ();
- rtx offset = gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode, orig, pic_base));
+ rtx offset = gen_pic_offset (orig, pic_base);
#endif
#if defined (TARGET_TOC) /* i.e., PowerPC */
@@ -591,9 +601,9 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
return reg;
}
- /* if dynamic-no-pic then use 0 as the pic base */
+ /* if dynamic-no-pic we don't have a pic base */
if (MACHO_DYNAMIC_NO_PIC_P)
- pic_base = CONST0_RTX (Pmode);
+ pic_base = NULL;
else
pic_base = machopic_function_base_sym ();
@@ -629,10 +639,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
if (GET_CODE (XEXP (orig, 0)) == SYMBOL_REF
|| GET_CODE (XEXP (orig, 0)) == LABEL_REF)
{
- rtx offset = gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode,
- XEXP (orig, 0),
- pic_base));
+ rtx offset = gen_pic_offset (XEXP (orig, 0), pic_base);
#if defined (TARGET_TOC) /* i.e., PowerPC */
/* Generating a new reg may expose opportunities for
common subexpression elimination. */
@@ -686,12 +693,9 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
PIC_OFFSET_TABLE_REGNUM)));
#endif
- pic_ref = gen_rtx_PLUS (Pmode,
- pic,
- gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode,
- XEXP (orig, 0),
- pic_base)));
+ pic_ref = gen_rtx_PLUS (Pmode, pic,
+ gen_pic_offset (XEXP (orig, 0),
+ pic_base));
}
#if !defined (TARGET_TOC)
@@ -706,9 +710,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
if (GET_CODE (orig) == SYMBOL_REF
|| GET_CODE (orig) == LABEL_REF)
{
- rtx offset = gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode,
- orig, pic_base));
+ rtx offset = gen_pic_offset (orig, pic_base);
#if defined (TARGET_TOC) /* i.e., PowerPC */
rtx hi_sum_reg;
@@ -762,9 +764,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
#endif
pic_ref = gen_rtx_PLUS (Pmode,
pic,
- gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode,
- orig, pic_base)));
+ gen_pic_offset (orig, pic_base));
}
}
}