From b1d673bef74ea8295ec3775ec3133a478f9593f7 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Fri, 30 May 2003 21:41:21 +0000 Subject: [PATCH] emit-rtl.c (gen_complex_constant_part): New function for getting the constant real or imaginary part of a complex constant. * 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. From-SVN: r67252 --- gcc/ChangeLog | 7 +++++++ gcc/emit-rtl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) 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 + + * 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 * 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 -- 2.30.2