public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Legitimize address, Please HELP!
@ 2001-12-05  3:36 dimmy
  2001-12-05  7:31 ` Jan Hubicka
  2001-12-05 15:52 ` Richard Henderson
  0 siblings, 2 replies; 9+ messages in thread
From: dimmy @ 2001-12-05  3:36 UTC (permalink / raw)
  To: gcc

Fellows,

Sorry bothering you.

I am writing msp430 support and got a question:
How to get rid of operands like:

(mem/s:HI (plus:HI (mem:HI (plus:HI (reg/f:HI 1 r1)
                        (const_int 18 [0x12])) 0)
                (const_int 2 [0x2])) 3))

The CPU core does support (mem:xx (plus reg:xx const_int)), but not the
operand above.

I define  GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR)
as:
------------------------
#ifdef REG_OK_STRICT
#  define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR) \
{                                                       \
  if (legitimate_address_p (mode, operand, 1))          \
    goto ADDR;                                          \
}
#  else
#  define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR) \
{                                                       \
  if (legitimate_address_p (mode, operand, 0))          \
    goto ADDR;                                          \
}
#endif
--------------------------
where legitimate_address_p is defined as follows:
--------------------------
int
legitimate_address_p (mode, operand, strict)
enum machine_mode mode;
rtx operand;
int strict;
{
    rtx x = operand;

    /* accept @Rn */
    if (GET_CODE (operand) == REG
            &&(strict ? REG_OK_FOR_BASE_STRICT_P (x)
               : REG_OK_FOR_BASE_NOSTRICT_P (x)))  
        return 1;

    /* accept address */
    if (CONSTANT_ADDRESS_P (operand))
        return 1;

    /* accept X(Rn) */
    if (GET_CODE (operand) == PLUS
            && GET_CODE (XEXP (operand, 0)) == REG
            && REG_OK_FOR_BASE_P (XEXP (operand, 0))
            && CONSTANT_ADDRESS_P (XEXP (operand, 1)))
        return 1;

}
--------------------------

Shall I define something else to prevent invalid address generation or what?

By now I cannot compile only 'unwind-dw2-fde.c' in gcc-3.0/gcc
Everything else seems to be fine!!!

by the way, when I run xgcc, it produces invalid code,
when cc1, it does not want to compile and says:

unwind-dw2-fde.c: In function `search_object':
unwind-dw2-fde.c:930: Unrecognizable insn:
(insn 1212 29 30 (set (reg:HI 14 r14 [49])
        (mem/s:HI (plus:HI (mem:HI (plus:HI (reg/f:HI 1 r1)
                        (const_int 12 [0xc])) 0)
                (const_int 10 [0xa])) 13)) -1 (nil)
    (nil))

Tricks like if (GET_CODE (operand) == PLUS && GET_CODE (XEXP (operand, 
0)) == MEM) return 0; do not help at all.


Thanks in advance,
Dmitry.


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Legitimize address, Please HELP!
@ 2001-12-06  5:03 dimmy the wild
  0 siblings, 0 replies; 9+ messages in thread
From: dimmy the wild @ 2001-12-06  5:03 UTC (permalink / raw)
  To: rth; +Cc: gcc


Richard,
thanks...
I set it up as:
    /* accept X(Rn) :  (Rn + X) points to the operand address*/
    if (GET_CODE (operand) == PLUS
            && GET_CODE (XEXP (operand, 0)) == REG
            && CONSTANT_ADDRESS_P (XEXP (operand, 1))
            &&(strict ? REG_OK_FOR_BASE_STRICT_P (XEXP (operand, 0))
                      : REG_OK_FOR_BASE_NOSTRICT_P (XEXP (operand, 0)))
        )
        goto granded;

Did not help eather.

Also, I found, that if fails to compile the following:

static /* inline */  fde *
binary_search_mixed_encoding_fdes (struct object *ob, void *pc)
{
#ifdef WILL_CRASH_IF_NOT_DEFINED
        char tt[20];
#endif
        struct fde_vector *vec = ob->u.sort; /* THIS LEADS TO INCORRECT CODE */
        size_t lo, hi;

#ifdef WILL_CRASH_IF_NOT_DEFINED
/* this is not a part of unwind-dw2-fde.c 
   but these two dummie calls helping gcc to produce correct code!!!
*/
        set(vec->array,&lo,&hi,tt);
        reset(vec,tt, lo,hi);
#endif

        for (lo = 0, hi = vec->count; lo < hi; )
        {
                size_t i = (lo + hi) / 2;
                fde *f = vec->array[i];
                _Unwind_Ptr pc_begin, pc_range;
                const char *p;
                int encoding;

                encoding = get_fde_encoding (f);
                p = read_encoded_value_with_base (encoding,
                                                  base_from_object (encoding,
ob),
                                                  f->pc_begin, &pc_begin);
                read_encoded_value_with_base (encoding & 0x0F, 0, p, &pc_range);

                if ((_Unwind_Ptr)pc < pc_begin)
                        hi = i;
                else if ((_Unwind_Ptr)pc >= pc_begin + pc_range )
                        lo = i + 1;
                else
                        return f;
        }

        return 0;
}

which is a part of unwind-dw2-fde.c
But, guring gcc build xgcc does not complain about wrong operand (assembler
does), but if I run
cc1 it says:


unwind-dw2-fde.c: In function `search_object':
unwind-dw2-fde.c:930: Unrecognizable insn:
(insn 1212 29 30 (set (reg:HI 14 r14 [49])
        (mem/s:HI (plus:HI (mem:HI (plus:HI (reg/f:HI 1 r1)
                        (const_int 12 [0xc])) 0)
                (const_int 10 [0xa])) 13)) -1 (nil)

One more thing:
The function above is inlined in unwind-dw2-fde.c
Any sort of optimization results as wrong operand, 
Absemse of optimization results Unrecognizable insn.

The example above can be compiled without optimization fine.
With -Ox it produces wrong code but does not complain about 
wron addressing mode.


Does anybody have any idea why?
If you want I can send you complete sources of the gcc port.
Thanks in advance,
Dmitry.



On Wed, 5 Dec 2001 15:51:13 -0800
Richard Henderson <rth@redhat.com> wrote:

> On Wed, Dec 05, 2001 at 03:33:37PM +0300, dimmy wrote:
> >     if (GET_CODE (operand) == PLUS
> >             && GET_CODE (XEXP (operand, 0)) == REG
> >             && REG_OK_FOR_BASE_P (XEXP (operand, 0))
> 
> Should depend on strict here.
> 
> 
> r~
> 


*********************************************************************
   ("`-''-/").___..--''"`-._     (\       Dimmy the Wild      UA1ACZ
    `6_ 6  )   `-.  (     ).`-.__.`)      Enterprise Information Sys 
    (_Y_.)'  ._   )  `._ `. ``-..-'       Nevsky prospekt,   20 / 44
  _..`--'_..-_/  /--'_.' ,'               Saint Petersburg,   Russia
 (il),-''  (li),'  ((!.-'                 +7 (812) 314-8860, 5585314
*********************************************************************

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-12-06 12:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-05  3:36 Legitimize address, Please HELP! dimmy
2001-12-05  7:31 ` Jan Hubicka
2001-12-05  8:23   ` dimmy
2001-12-05  9:16     ` Jan Hubicka
     [not found]       ` <3C0E6806.3060706@mail.ru>
2001-12-05  9:52         ` Jan Hubicka
2001-12-05 11:14           ` dimmy
2001-12-05 11:23             ` Jan Hubicka
2001-12-05 15:52 ` Richard Henderson
2001-12-06  5:03 dimmy the wild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).