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]

Re: Machine Description '.md'


> Date: Wed, 7 Jun 2000 12:08:31 -0300 (EST)
> From: Marcio de Oliveira Buss  <ra990898@ic.unicamp.br>
> To: gcc@gcc.gnu.org

>  I am studying the possibility of apply gcc to reconfigurable
>  architectures, and so, the machine description has to be changed
>  many times. Is it mean that I have to recompile gcc for every new
>  target architecture?

Yes or no, depending upon the design.  There are companies now that
have reconfigurable CPU architectures, that use gcc for
compilations.  One way to do it, would be to just add predicates to
instructions (for example the entire floating point unit):

/* Nonzero if we should generate code to use the fpu.  */
#define MASK_FPU 1
#define TARGET_FPU (target_flags & MASK_FPU)

(define_expand "cmpsf"
  ;; The 96 here isn't ever used by anyone.
  [(set (reg:CCFP 96)
  (compare:CCFP (match_operand:SF 0 "register_operand" "")
		      (match_operand:SF 1 "register_operand" "")))]
  "TARGET_FPU"
  "
{
  sparc_compare_op0 = operands[0];
  sparc_compare_op1 = operands[1];
  DONE;
}")

and another example where we only have a trap on a V9:

(define_insn ""
  [(trap_if (match_operator 0 "noov_compare_op" [(reg:CCX 100) (const_int 0)])
      (match_operand:SI 1 "arith_operand" "rM"))]
  "TARGET_V9"
  "t%C0\\t%%xcc, %1"
  [(set_attr "type" "misc")
   (set_attr "length" "1")])

The .md files are littered with conditional upon conditionals.  If you
need to conditionalize register sets:

#define CONDITIONAL_REGISTER_USAGE				\
do								\
  {								\
    if (flag_pic)						\
      {								\
	fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;		\
	call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;		\
      }								\

Maybe you don't allow some registers at some times, above, we don't
`have' register PIC_OFFSET_TABLE_REGNUM when flag_pic is used.  In the
below, we vanish an entire set of registers for V9:

    if (! TARGET_V9)						\
      {								\
	int regno;						\
	for (regno = SPARC_FIRST_V9_FP_REG;			\
	     regno <= SPARC_LAST_V9_FP_REG;			\
	     regno++)						\
	  fixed_regs[regno] = 1;				\

and so on...  For a flexible architecture, we can a read processor
definition from a file, and set bits for the md file to use.  People
even change 32 bitness or 64 bitness:

#define BITS_PER_WORD	  (TARGET_ARCH64 ? 64 : 32)

Talk about a radical change.  So, yes, there is much you can do,
without recompiling the compiler.

Hope this helps.

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