summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-30 21:41:21 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-30 21:41:21 +0000
commit591356e89c63314530db8af7a6f4e50470140fa3 (patch)
treee3f7936041f7780813578631d0a29df7c23cc0c1
parentb3e17f149db1db4efb165dbdd46daaed2c35ade6 (diff)
downloadgcc-591356e89c63314530db8af7a6f4e50470140fa3.tar.gz
* emit-rtl.c (gen_complex_constant_part): New function for getting
the constant real or imaginary part of a complex constant. (gen_realpart): Use it. (gen_imagpart): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67252 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/emit-rtl.c45
2 files changed, 52 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d98af3a1d34..07455ab8d2a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2003-05-30 Roger Sayle <roger@eyesopen.com>
+
+ * emit-rtl.c (gen_complex_constant_part): New function for getting
+ the constant real or imaginary part of a complex constant.
+ (gen_realpart): Use it.
+ (gen_imagpart): Likewise.
+
2003-05-30 Kazu Hirata <kazu@cs.umass.edu>
* doc/invoke.texi: Fix typos.
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index f5689919343..1bb79dd0aa4 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -202,6 +202,8 @@ static int reg_attrs_htab_eq PARAMS ((const void *,
static reg_attrs *get_reg_attrs PARAMS ((tree, int));
static tree component_ref_for_mem_expr PARAMS ((tree));
static rtx gen_const_vector_0 PARAMS ((enum machine_mode));
+static rtx gen_complex_constant_part PARAMS ((enum machine_mode,
+ rtx, int));
/* Probability of the conditional branch currently proceeded by try_split.
Set to -1 otherwise. */
@@ -1294,6 +1296,35 @@ gen_lowpart_common (mode, x)
return 0;
}
+/* Return the constant real or imaginary part (which has mode MODE)
+ of a complex value X. The IMAGPART_P argument determines whether
+ the real or complex component should be returned. This function
+ returns NULL_RTX if the component isn't a constant. */
+
+static rtx
+gen_complex_constant_part (mode, x, imagpart_p)
+ enum machine_mode mode;
+ rtx x;
+ int imagpart_p;
+{
+ tree decl, part;
+
+ if (GET_CODE (x) == MEM
+ && GET_CODE (XEXP (x, 0)) == SYMBOL_REF
+ && TREE_CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)))
+ {
+ decl = SYMBOL_REF_DECL (XEXP (x, 0));
+ if (decl != NULL_TREE && TREE_CODE (decl) == COMPLEX_CST)
+ {
+ part = imagpart_p ? TREE_IMAGPART (decl) : TREE_REALPART (decl);
+ if (TREE_CODE (part) == REAL_CST
+ || TREE_CODE (part) == INTEGER_CST)
+ return expand_expr (part, NULL_RTX, mode, 0);
+ }
+ }
+ return NULL_RTX;
+}
+
/* Return the real part (which has mode MODE) of a complex value X.
This always comes at the low address in memory. */
@@ -1302,6 +1333,13 @@ gen_realpart (mode, x)
enum machine_mode mode;
rtx x;
{
+ rtx part;
+
+ /* Handle complex constants. */
+ part = gen_complex_constant_part (mode, x, 0);
+ if (part != NULL_RTX)
+ return part;
+
if (WORDS_BIG_ENDIAN
&& GET_MODE_BITSIZE (mode) < BITS_PER_WORD
&& REG_P (x)
@@ -1322,6 +1360,13 @@ gen_imagpart (mode, x)
enum machine_mode mode;
rtx x;
{
+ rtx part;
+
+ /* Handle complex constants. */
+ part = gen_complex_constant_part (mode, x, 1);
+ if (part != NULL_RTX)
+ return part;
+
if (WORDS_BIG_ENDIAN)
return gen_lowpart (mode, x);
else if (! WORDS_BIG_ENDIAN