This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: RFC: Plan for cleaning up the "Addressing Modes" macros


----Original Message----
>From: gcc-owner On Behalf Of Kazu Hirata 
>Sent: 28 February 2005 14:41

> So I would change each macro to an
> architecture-specific function in each architecture first.  For
> example, GO_IF_LEGITIMATE_ADDRESS should look like this (taken from
> i386.h):
> 
> #ifdef REG_OK_STRICT
> #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)
\
> do {									\
>   if (legitimate_address_p ((MODE), (X), 1))				\
>     goto ADDR;
\
> } while (0)
> 
> #else
> #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)
\
> do {									\
>   if (legitimate_address_p ((MODE), (X), 0))				\
>     goto ADDR;
\
> } while (0)
> 
> #endif
> 
> Note that REG_OK_STRICT is essentially used as an argument to
> legitimate_address_p and that the use of the function argument
> decouples legitimate_address_p and REG_OK_STRICT.

  I'm basically in agreement with you here, and just want to suggest you can
avoid an awful lot of code duplication by doing something like

#ifdef REG_OK_STRICT
#define ${CPU}_IS_STRICT 1
#else 
#define ${CPU}_IS_STRICT 0
#endif

at the top of the ${CPU}.h file, and then all the various macros can use it
directly as a boolean flag, rather than having two near-identical duplicate
definitions:

#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)			\
do {
\
  if (legitimate_address_p ((MODE), (X), ${CPU}_IS_STRICT))		\
    goto ADDR;								\
} while (0)

  This seems to me a reasonable way to prevent excessive code duplication in
the case where there may be many sub-macros that also depend on
REG_OK_STRICT.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]