Re: GCC porting question

Michael Meissner <mrmnews@the-meissners.org>
17 Jul 2003 00:32:17 -0400

          From comp.compilers

Related articles
GCC porting question cjaiprakash@noida.hcltech.com (C Jaiprakash, Noida) (2003-07-13)
Re: GCC porting question o8ue2fg702@sneakemail.com (Tim Olson) (2003-07-15)
Re: GCC porting question kenrose@tfb.com (Ken Rose) (2003-07-17)
Re: GCC porting question mrmnews@the-meissners.org (Michael Meissner) (2003-07-17)
| List of all articles for this month |
From: Michael Meissner <mrmnews@the-meissners.org>
Newsgroups: comp.compilers
Date: 17 Jul 2003 00:32:17 -0400
Organization: Compilers Central
References: 03-07-086
Keywords: GCC, architecture
Posted-Date: 17 Jul 2003 00:32:17 EDT

"C Jaiprakash, Noida" <cjaiprakash@noida.hcltech.com> writes:


> Hi,
> Can gcc be ported to a machine which do not have diaplacement
> addressing mode?
> If yes then what sould macros related to base register be defined as?
> for ex ( REG_OK_FOR_BASE_P, BASE_REG_CLASS )


Sure, you can do it. The IA-64 is one such machine. Looking at the
gcc/config/ia64/ia64.h file, I see (note, I am not an expert on this port, for
help with it, consult the gcc help mailing list):


/* A macro whose definition is the name of the class to which a valid base
      register must belong. A base register is one used in an address which is
      the register value plus a displacement. */
#define BASE_REG_CLASS GENERAL_REGS


/* A macro whose definition is the name of the class to which a valid index
      register must belong. An index register is one used in an address where its
      value is either multiplied by a scale factor or added to another register
      (as well as added to a displacement). This is needed for POST_MODIFY. */
#define INDEX_REG_CLASS GENERAL_REGS


                /* code snipped */


/* A C expression which is nonzero if register number NUM is suitable for use
      as a base register in operand addresses. It may be either a suitable hard
      register or a pseudo register that has been allocated such a hard reg. */
#define REGNO_OK_FOR_BASE_P(REGNO) \
    (GENERAL_REGNO_P (REGNO) || GENERAL_REGNO_P (reg_renumber[REGNO]))


/* A C expression which is nonzero if register number NUM is suitable for use
      as an index register in operand addresses. It may be either a suitable hard
      register or a pseudo register that has been allocated such a hard reg.
      This is needed for POST_MODIFY. */
#define REGNO_OK_FOR_INDEX_P(NUM) REGNO_OK_FOR_BASE_P (NUM)


                /* code snipped */


/* A C expression that is 1 if the RTX X is a constant which is a valid
      address. */


#define CONSTANT_ADDRESS_P(X) 0


/* The max number of registers that can appear in a valid memory address. */


#define MAX_REGS_PER_ADDRESS 2


/* A C compound statement with a conditional `goto LABEL;' executed if X (an
      RTX) is a legitimate memory address on the target machine for a memory
      operand of mode MODE. */


#define LEGITIMATE_ADDRESS_REG(X) \
    ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
      || (GET_CODE (X) == SUBREG && GET_CODE (XEXP (X, 0)) == REG \
              && REG_OK_FOR_BASE_P (XEXP (X, 0))))


#define LEGITIMATE_ADDRESS_DISP(R, X) \
    (GET_CODE (X) == PLUS \
      && rtx_equal_p (R, XEXP (X, 0)) \
      && (LEGITIMATE_ADDRESS_REG (XEXP (X, 1)) \
              || (GET_CODE (XEXP (X, 1)) == CONST_INT \
&& INTVAL (XEXP (X, 1)) >= -256 \
&& INTVAL (XEXP (X, 1)) < 256)))


#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
do { \
    if (LEGITIMATE_ADDRESS_REG (X)) \
        goto LABEL; \
    else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC) \
&& LEGITIMATE_ADDRESS_REG (XEXP (X, 0)) \
&& XEXP (X, 0) != arg_pointer_rtx) \
        goto LABEL; \
    else if (GET_CODE (X) == POST_MODIFY \
&& LEGITIMATE_ADDRESS_REG (XEXP (X, 0)) \
&& XEXP (X, 0) != arg_pointer_rtx \
&& LEGITIMATE_ADDRESS_DISP (XEXP (X, 0), XEXP (X, 1))) \
        goto LABEL; \
} while (0)


/* A C expression that is nonzero if X (assumed to be a `reg' RTX) is valid for
      use as a base register. */


#ifdef REG_OK_STRICT
#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
#else
#define REG_OK_FOR_BASE_P(X) \
    (GENERAL_REGNO_P (REGNO (X)) || (REGNO (X) >= FIRST_PSEUDO_REGISTER))
#endif


/* A C expression that is nonzero if X (assumed to be a `reg' RTX) is valid for
      use as an index register. This is needed for POST_MODIFY. */


#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)


--
Michael Meissner
email: mrmnews@the-meissners.org
http://www.the-meissners.org


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.