RFA: Add Epiphany port
diff mbox

Message ID 20111104015458.f7hzapyfqck4gw84-nzlynne@webmail.spamcop.net
State New
Headers show

Commit Message

Joern Rennecke Nov. 4, 2011, 5:54 a.m. UTC
Quoting "Joseph S. Myers" <joseph@codesourcery.com>:

> You should go through the checklist in sourcebuild.texi, Back End, and
> fill in missing pieces, such as md.texi, contrib.texi, config-list.mk and
> the website patches.

install.texi is a bit funny.  sourcebuild.texi says to add configurations
to the list in config.texi even if you have nothing to say about them.
install.texi says you shouldn't do that.  But after a while, it does do
that for a number of newer ports.  So this seems to be a case of 'do what I
do, not what I say' ...

I don't think posting the newlib libraries here makes much sense - the newlib
port is larger than the GCC port, and it's a separate project, anyway.

I have filled in the backends.html 's' coloumn under the assumption that
the remaining parts of the cgen-based simulator will be accepted.

This leaves the following items from the checklist:
:@item
:A note in @file{gcc/doc/contrib.texi} under the person or people who
:contributed the target support.
:
:If the back end is added to the official GCC source repository, the
:following are also necessary:
:
:@itemize @bullet
:@item
:An entry for the target architecture in @file{readings.html} on the
:GCC web site, with any relevant links.
:@item
:A news item about the contribution of support for that target
:architecture, in @file{index.html} on the GCC web site.

Jeremy, could you fill these in?

:@item
:Normally, one or more maintainers of that target listed in
:@file{MAINTAINERS}.  Some existing architectures may be unmaintained,
:but it would be unusual to add support for a target that does not have
:a maintainer when support is added.
:@end itemize

Doesn't this have to go through the Steering Commitee first?
2011-11-03  Joern Rennecke <joern.rennecke@embecosm.com>

gcc:
	* config.gcc (epiphany-*-*): New architecture.
	(epiphany-*-elf): New configuration.
	* config/epiphany, common/config/epiphany : New directories.
	* doc/extend.texi (disinterrupt attribute): Add Epiphany.
	(interrupt attribute): Add Epiphany.
	(long_call, short_call attribute): Add Epiphany.
	* doc/invoke.texi (Options): Add Epiphany options.
	* doc/md.texi (Machine Constraints): Add Epiphany constraints.
	* doc/install.texi (Options specification):
	Add --with-stack-offset=@var{num} description.
	(host/target specific issues): Add epiphany-*-elf.
gcc/testsuite:
	* gcc.c-torture/execute/ieee/mul-subnormal-single-1.x:
	Disable test on Epiphany.
	* gcc.c-torture/execute/20101011-1.c: Disable test on Epiphany.
	* gcc.dg/stack-usage-1.c [__epiphany__] (SIZE): Define.
	* gcc.dg/pragma-pack-3.c: Disable test on Epiphany.
	* g++.dg/parse/pragma3.C: Likewise.
	* stackalign/builtin-apply-2.c (STACK_ARGUMENTS_SIZE): Define.
	(bar): Use it.
	* gcc.dg/weak/typeof-2.c [epiphany-*-*]: Add option -mshort-calls.
	* gcc.dg/tls/thr-cse-1.c: Likewise.
	* g++.dg/opt/devirt2.C: Likewise.
	* gcc.dg/20020312-2.c [epiphany-*-*] (PIC_REG): Define.
	* gcc.dg/builtin-apply2.c [__epiphany__]: (STACK_ARGUMENTS_SIZE): 20.
	* gcc.target/epiphany: New directory.
libgcc:
	* config.host (epiphany-*-elf*): New configuration.
	* config/epiphany: New Directory.
contrib:
	* contrib-list.mk: Add Epiphany configurations.

Index: htdocs/backends.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/backends.html,v
retrieving revision 1.41
diff -u -r1.41 backends.html
--- htdocs/backends.html	15 Jul 2011 09:48:14 -0000	1.41
+++ htdocs/backends.html	4 Nov 2011 04:23:02 -0000
@@ -73,6 +73,7 @@
 c4x      |  ??  N I BD       g  d  e 
 c6x      |   S     CB      p g bda 
 cris     |       F  B     cp g b a  s
+epiphany |         C       p g  da  s
 fr30     | ??    FI B        gm     s
 frv      | ??       B      p    da  s
 h8300    |       FI       cp g      s

Comments

Rainer Orth Nov. 4, 2011, 9:31 a.m. UTC | #1
Joern Rennecke <amylaar@spamcop.net> writes:

> Index: libgcc/config.host
> ===================================================================
> --- libgcc/config.host	(revision 180924)
> +++ libgcc/config.host	(working copy)
> @@ -433,6 +433,10 @@
>  cris-*-linux* | crisv32-*-linux*)
>  	tmake_file="$tmake_file cris/t-cris t-fdpbit cris/t-linux"
>  	;;
> +epiphany-*-elf*)
> +	tmake_file="epiphany/t-epiphany t-fdpbit epiphany/t-custom-eqsf"
> +	extra_parts="crti.o crtint.o crtrunc.o crtm1reg-r43.o crtm1reg-r63.o crtbegin.o crtend.o crtn.o"
> +	;;

No need for crtbegin.o and crtend.o, just add to the *-*-elf extra_parts
instead.

> Index: gcc/testsuite/gcc.dg/weak/typeof-2.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/weak/typeof-2.c	(revision 180924)
> +++ gcc/testsuite/gcc.dg/weak/typeof-2.c	(working copy)
> @@ -5,6 +5,9 @@
>  /* { dg-require-weak "" } */
>  /* { dg-require-alias "" } */
>  /* { dg-options "-O2" } */
> +/* Using -mshort-calls avoids loading the function addresses in
> +   registers and thus getting the counts wrong.  */
> +/* { dg-options "-O2 -mshort-calls" { target epiphany-*-* } } */

You should consider using dg-additional-options here, rather than
repeating the dg-options default (and in several other tests).

Thanks.
        Rainer
Joseph Myers Nov. 4, 2011, 12:27 p.m. UTC | #2
On Fri, 4 Nov 2011, Joern Rennecke wrote:

> :@item
> :Normally, one or more maintainers of that target listed in
> :@file{MAINTAINERS}.  Some existing architectures may be unmaintained,
> :but it would be unusual to add support for a target that does not have
> :a maintainer when support is added.
> :@end itemize
> 
> Doesn't this have to go through the Steering Commitee first?

Yes, all new port submissions should also have a separate message sent to 
the gcc@ list, for the attention of the SC, requesting the appointment of 
a maintainer (and proposing who that should be).

> +@item Cm1
> +A signed 11-bit constant added to -1

@minus{}1.  Likewise elsewhere.

> +Can only match when epiphany_m1reg is valid.

This doesn't make sense to me in the context of a user manual describing 
what can be used in inline asm.

> +Can only match when epiphany_m1reg is valid.

Likewise.

> +@item Csy
> +symbolic constant for call/jump instruction

Consistently start each of these items with a capital letter and end with 
".".

> +Constant suitable for the addsi3_r pattern.  This is a valid offset

"addsi3_r" also seems inappropriate for the user manual.

Any constraints not for use in asms can be put inside @ifset INTERNALS 
here - though really it's just those that can be used in asms that it's 
important to document here.

Patch
diff mbox

Index: contrib/config-list.mk
===================================================================
--- contrib/config-list.mk	(revision 180924)
+++ contrib/config-list.mk	(working copy)
@@ -18,7 +18,8 @@  LIST = alpha-linux-gnu alpha-freebsd6 al
   arm-linux-androideabi arm-uclinux_eabi arm-ecos-elf arm-eabi \
   arm-symbianelf arm-rtems arm-elf arm-wince-pe avr-rtems avr-elf \
   bfin-elf bfin-uclinux bfin-linux-uclibc bfin-rtems bfin-openbsd \
-  c6x-elf c6x-uclinux cris-elf cris-linux crisv32-elf crisv32-linux fido-elf \
+  c6x-elf c6x-uclinux cris-elf cris-linux crisv32-elf crisv32-linux \
+  epiphany-elf epiphany-elfOPT-with-stack-offset=16 fido-elf \
   fr30-elf frv-elf frv-linux h8300-elf h8300-rtems hppa-linux-gnu \
   hppa-linux-gnuOPT-enable-sjlj-exceptions=yes hppa64-linux-gnu \
   hppa2.0-hpux10.1 hppa64-hpux11.3 \
Index: libgcc/config.host
===================================================================
--- libgcc/config.host	(revision 180924)
+++ libgcc/config.host	(working copy)
@@ -433,6 +433,10 @@ 
 cris-*-linux* | crisv32-*-linux*)
 	tmake_file="$tmake_file cris/t-cris t-fdpbit cris/t-linux"
 	;;
+epiphany-*-elf*)
+	tmake_file="epiphany/t-epiphany t-fdpbit epiphany/t-custom-eqsf"
+	extra_parts="crti.o crtint.o crtrunc.o crtm1reg-r43.o crtm1reg-r63.o crtbegin.o crtend.o crtn.o"
+	;;
 fr30-*-elf)
 	tmake_file="$tmake_file fr30/t-fr30 t-fdpbit"
 	extra_parts="$extra_parts crti.o crtn.o"
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi	(revision 180924)
+++ gcc/doc/extend.texi	(working copy)
@@ -2192,7 +2192,7 @@  types (@pxref{Variable Attributes}, @pxr
 
 @item disinterrupt
 @cindex @code{disinterrupt} attribute
-On MeP targets, this attribute causes the compiler to emit
+On Epiphany and MeP targets, this attribute causes the compiler to emit
 instructions to disable interrupts for the duration of the given
 function.
 
@@ -2551,7 +2551,7 @@  void bar (void)
 
 @item interrupt
 @cindex interrupt handler functions
-Use this attribute on the ARM, AVR, M32C, M32R/D, m68k, MeP, MIPS,
+Use this attribute on the ARM, AVR, Epiphany, M32C, M32R/D, m68k, MeP, MIPS,
 RX and Xstormy16 ports to indicate that the specified function is an
 interrupt handler.  The compiler will generate function entry and exit
 sequences suitable for use in an interrupt handler when this attribute
@@ -2723,7 +2723,8 @@  least version 2.20.1), and GNU C library
 @item long_call/short_call
 @cindex indirect calls on ARM
 This attribute specifies how a particular function is called on
-ARM@.  Both attributes override the @option{-mlong-calls} (@pxref{ARM Options})
+ARM and Epiphany.  Both attributes override the
+@option{-mlong-calls} (@pxref{ARM Options})
 command-line switch and @code{#pragma long_calls} settings.  The
 @code{long_call} attribute indicates that the function might be far
 away from the call site and require a different (more expensive)
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 180924)
+++ gcc/doc/invoke.texi	(working copy)
@@ -458,6 +458,14 @@  cpp(1), gcov(1), as(1), ld(1), gdb(1), a
 @c Try and put the significant identifier (CPU or system) first,
 @c so users have a clue at guessing where the ones they want will be.
 
+@emph{Adapteva Epiphany Options}
+@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
+-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf @gol
+-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} @gol
+-mround-nearest -mlong-calls -mshort-calls -msmall16 @gol
+-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} @gol
+-msplit-vecmove-early -m1reg-@var{reg}}
+
 @emph{ARM Options}
 @gccoptlist{-mapcs-frame  -mno-apcs-frame @gol
 -mabi=@var{name} @gol
@@ -10226,6 +10234,7 @@  finds any @option{-l} options and any no
 @c in Machine Dependent Options
 
 @menu
+* Adapteva Epiphany Options::
 * ARM Options::
 * AVR Options::
 * Blackfin Options::
@@ -10274,6 +10283,161 @@  finds any @option{-l} options and any no
 * zSeries Options::
 @end menu
 
+@node Adapteva Epiphany Options
+@subsection Adapteva Epiphany Options
+
+These @samp{-m} options are defined for Adapteva Epiphany:
+
+@table @gcctabopt
+@item -mhalf-reg-file
+@opindex mhalf-reg-file
+Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
+That allows code to run on hardware variants that lack these registers.
+
+@item -mprefer-short-insn-regs
+@opindex mprefer-short-insn-regs
+Preferrentially allocate registers that allow short instruction generation.
+This can result in increasesd instruction count, so if this reduces or
+increases code size might vary from case to case.
+
+@item -mbranch-cost=@var{num}
+@opindex mbranch-cost
+Set the cost of branches to roughly @var{num} ``simple'' instructions.
+This cost is only a heuristic and is not guaranteed to produce
+consistent results across releases.
+
+@item -mcmove
+@opindex mcmove
+Enable the generation of conditional moves.
+
+@item -mnops=@var{num}
+@opindex mnops
+Emit @var{num} nops before every other generated instruction.
+
+@item -mno-soft-cmpsf
+@opindex mno-soft-cmpsf
+For single-precision floating point comparisons, emit an fsub instruction
+and test the flags.  This is faster than a software comparison, but can
+get incorrect results in the presence of NaNs, or when two different small
+numbers are compared such that their difference is calculated as zero.
+The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
+software comparisons.
+
+@item -mstack-offset=@var{num}
+@opindex mstack-offset
+Set the offset between the top of the stack and the stack pointer.
+E.g., a value of 8 means that the eight bytes in the range sp+0@dots{}sp+7
+can be used by leaf functions without stack allocation.
+Values other than @samp{8} or @samp{16} are untested and unlikely to work.
+Note also that this option changes the ABI, compiling a program with a
+different stack offset than the libraries have been compiled with
+will generally not work.
+This option can be useful if you want to evaluate if a different stack
+offset would give you better code, but to actually use a different stack
+offset to build working programs, it is recommended to configure the
+toolchain with the appropriate @samp{--with-stack-offset=@var{num}} option.
+
+@item -mno-round-nearest
+@opindex mno-round-nearest
+Make the scheduler assume that the rounding mode has been set to
+truncating.  The default is @option{-mround-nearest}.
+
+@item -mlong-calls
+@opindex mlong-calls
+If not otherwise specified by an attribute, assume all calls might be beyond
+the offset range of the b / bl instructions, and therefore load the
+function address into a register before performing a (otherwise direct) call.
+This is the default.
+
+@item -mshort-calls
+@opindex short-calls
+If not otherwise specified by an attribute, assume all direct calls are
+in the range of the b / bl instructions, so use these instructions
+for direct calls.  The default is @option{-mlong-calls}.
+
+@item -msmall16
+@opindex msmall16
+Assume addresses can be loaded as 16 bit unsigned values.  This does not
+apply to function addresses for which @option{-mlong-calls} semantics
+are in effect.
+
+@item -mfp-mode=@var{mode}
+@opindex mfp-mode
+Set the prevailing mode of the floating point unit.
+This determines the floating point mode that is provided and expected
+at function call and return time.  Making this mode match the mode you
+predominantly need at function start can make your programs smaller and
+faster by avoiding unnecessary mode switches.
+
+@var{mode} can be set to one the following values:
+
+@table @samp
+@item caller
+Any mode at function entry is valid, and retained or restored when
+the function returns, and when it calls other functions.
+This mode is useful for compiling libraries or other compilation units
+you might want to incorporate into different programs with different
+prevailing FPU modes, and the convenience of being able to use a single
+object file outweighs the size and speed overhead for any extra
+mode switching that might be needed, compared with what would be needed
+with a more specific choice of prevailing FPU mode.
+
+@item truncate
+This is the mode used for floating point calculations with
+truncating (i.e.@: round towards zero) rounding mode.  That includes
+conversion from floating point to integer.
+
+@item round-nearest
+This is the mode used for floating point calculations with
+round-to-nearest-or-even rounding mode.
+
+@item int
+This is the mode used to perform integer calculations in the FPU, e.g.@:
+integer multiply, or integer multiply-and-accumulate.
+@end table
+
+The default is @option{-mfp-mode=caller}
+
+@item -mnosplit-lohi
+@opindex mnosplit-lohi
+@item -mno-postinc
+@opindex mno-postinc
+@item -mno-postmodify
+@opindex mno-postmodify
+Code generation tweaks that disable, respectively, splitting of 32
+bit loads, generation of post-increment addresses, and generation of
+post-modify addresses.  The defaults are @option{msplit-lohi},
+@option{-mpost-inc}, and @option{-mpost-modify}.
+
+@item -mnovect-double
+@opindex mno-vect-double
+Change the preferred SIMD mode to SImode.  The default is
+@option{-mvect-double}, which uses DImode as preferred SIMD mode.
+
+@item -max-vect-align=@var{num}
+@opindex max-vect-align
+The maximum alignment for SIMD vector mode types.
+@var{num} may be 4 or 8.  The default is 8.
+Note that this is an ABI change, even though many library function
+interfaces will be unaffected, if they don't use SIMD vector modes
+in places where they affect size and/or alignment of relevant types.
+
+@item -msplit-vecmove-early
+@opindex msplit-vecmove-early
+Split vector moves into single word moves before reload.  In theory this
+could give better register allocation, but so far the reverse seems to be
+generally the case.
+
+@item -m1reg-@var{reg}
+@opindex m1reg-
+Specify a register to hold the constant -1, which makes loading small negative
+constants and certain bitmasks faster.
+Allowable values for reg are r43 and r63, which specify to use that register
+as a fixed register, and none, which means that no register is used for this
+purpose.  The default is @option{-m1reg-none}.
+
+@end table
+
 @node ARM Options
 @subsection ARM Options
 @cindex ARM options
Index: gcc/doc/md.texi
===================================================================
--- gcc/doc/md.texi	(revision 180924)
+++ gcc/doc/md.texi	(working copy)
@@ -1,5 +1,5 @@ 
 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2001,
-@c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+@c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 @c Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
@@ -1778,6 +1778,74 @@  Register pair Z (r31:r30)
 Constant integer 4
 @end table
 
+@item Epiphany---@file{config/epiphany/constraints.md}
+@table @code
+@item U16
+An unsigned 16-bit constant.
+
+@item K
+An unsigned 5-bit constant.
+
+@item L
+A signed 11-bit constant.
+
+@item Cm1
+A signed 11-bit constant added to -1
+
+@item Cl1
+Left-shift of -1, i.e., a bit mask with a block of leading ones, the rest
+being a block of trailing zeroes.
+Can only match when epiphany_m1reg is valid.
+
+@item Cr1
+Right-shift of -1, i.e., a bit mask with a trailing block of ones, the
+rest being zeroes.  Or to put it another way, one less than a power of two.
+Can only match when epiphany_m1reg is valid.
+
+@item Cal
+Constant for arithmetic/logical operations.
+This is like @code{i}, except that for position independent code,
+no symbols / expressions needing relocations are allowed.
+
+@item Csy
+symbolic constant for call/jump instruction
+
+@item Rcs
+The register class usable in short insns.  This is a register class
+constraint, and can thus drive register allocation.
+This constraint won't match unless @option{-mprefer-short-insn-regs} is
+in effect.
+
+@item Rsc
+The the register class of registers that can be used to hold a
+sibcall call address.  I.e., a caller-saved register.
+
+@item Rct
+Core control register class.
+
+@item Rgs
+The register group usable in short insns.
+This constraint does not use a register class, so that it only
+passively matches suitable registers, and doesn't drive register allocation.
+
+@item Car
+Constant suitable for the addsi3_r pattern.  This is a valid offset
+For byte, halfword, or word addressing.
+
+@item Rra
+Matches the return address if it can be replaced with the link register.
+
+@item Rcc
+Matches the integer condition code register.
+
+@item Sra
+Matches the return address if it is in a stack slot.
+
+@item Cfm
+Matches control register values to switch fp mode, which are encapsulated in
+@code{UNSPEC_FP_MODE}.
+@end table
+
 @item Hewlett-Packard PA-RISC---@file{config/pa/pa.h}
 @table @code
 @item a
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi	(revision 180924)
+++ gcc/doc/install.texi	(working copy)
@@ -1208,6 +1208,11 @@  Specify that the target supports TLS (Th
 Specify if the compiler should default to @option{-marm} or @option{-mthumb}.
 This option is only supported on ARM targets.
 
+@item --with-stack-offset=@var{num}
+This option sets the default for the -mstack-offset=@var{num} option,
+and will thus generally also control the setting of this option for
+libraries.  This option is only supported on Epiphany targets.
+
 @item --with-fpmath=@var{isa}
 This options sets @option{-mfpmath=sse} by default and specifies the default
 ISA for floating-point arithmetics.  You can select either @samp{sse} which
@@ -3314,6 +3319,13 @@  Collection (GCC)},
 
 @html
 <hr />
+@end html
+@heading @anchor{epiphany-x-elf}epiphany-*-elf
+Adapteva Epiphany.
+This configuration is intended for embedded systems.
+
+@html
+<hr />
 @end html
 @heading @anchor{x-x-freebsd}*-*-freebsd*
 
Index: gcc/testsuite/gcc.c-torture/execute/ieee/mul-subnormal-single-1.x
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/ieee/mul-subnormal-single-1.x	(revision 180924)
+++ gcc/testsuite/gcc.c-torture/execute/ieee/mul-subnormal-single-1.x	(working copy)
@@ -1,3 +1,8 @@ 
+if [istarget "epiphany-*-*"] {
+    # The Epiphany single-precision floating point format does not
+    # support subnormals.
+    return 1
+}
 if [istarget "mips-sgi-irix6*"] {
     # IRIX 6 sets the MIPS IV flush to zero bit by default, so this test
     # isn't expected to work for n32 and n64 on MIPS IV targets.
Index: gcc/testsuite/gcc.c-torture/execute/20101011-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/20101011-1.c	(revision 180924)
+++ gcc/testsuite/gcc.c-torture/execute/20101011-1.c	(working copy)
@@ -28,6 +28,10 @@ 
   /* Not all Linux kernels deal correctly the breakpoints generated by
      MIPS16 divisions by zero.  They show up as a SIGTRAP instead.  */
 # define DO_TEST 0
+#elif defined (__epiphany__)
+  /* Epiphany does not have hardware division, and the software implementation
+     has truly undefined behaviour for division by 0.  */
+# define DO_TEST 0
 #else
 # define DO_TEST 1
 #endif
Index: gcc/testsuite/gcc.dg/stack-usage-1.c
===================================================================
--- gcc/testsuite/gcc.dg/stack-usage-1.c	(revision 180924)
+++ gcc/testsuite/gcc.dg/stack-usage-1.c	(working copy)
@@ -52,6 +52,8 @@ 
 #  define SIZE 160 /* 256 -  96 bytes for register save area */
 #elif defined (__SPU__)
 #  define SIZE 224
+#elif defined (__epiphany__)
+#  define SIZE (256 - __EPIPHANY_STACK_OFFSET__)
 #else
 #  define SIZE 256
 #endif
Index: gcc/testsuite/gcc.dg/pragma-pack-3.c
===================================================================
--- gcc/testsuite/gcc.dg/pragma-pack-3.c	(revision 180924)
+++ gcc/testsuite/gcc.dg/pragma-pack-3.c	(working copy)
@@ -1,6 +1,7 @@ 
 /* PR c++/25294 */
 /* { dg-options "-std=gnu99" } */
-/* { dg-do run } */
+/* Epiphany makes struct S 8-byte aligned.  */
+/* { dg-do run { target { ! epiphany-*-* } } } */
 
 extern void abort (void);
 
Index: gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c	(revision 180924)
+++ gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c	(working copy)
@@ -9,6 +9,15 @@ 
 
 #define INTEGER_ARG  5
 
+#if defined(__ARM_PCS) || defined(__epiphany__)
+/* For Base AAPCS, NAME is passed in r0.  D is passed in r2 and r3.
+   E, F and G are passed on stack.  So the size of the stack argument
+   data is 20.  */
+#define STACK_ARGUMENTS_SIZE  20
+#else
+#define STACK_ARGUMENTS_SIZE  64
+#endif
+
 extern void abort(void);
 
 void foo(char *name, double d, double e, double f, int g)
@@ -19,7 +28,7 @@  void foo(char *name, double d, double e,
 
 void bar(char *name, ...)
 {
-  __builtin_apply(foo, __builtin_apply_args(), 64);
+  __builtin_apply(foo, __builtin_apply_args(), STACK_ARGUMENTS_SIZE);
 }
 
 int main(void)
Index: gcc/testsuite/gcc.dg/weak/typeof-2.c
===================================================================
--- gcc/testsuite/gcc.dg/weak/typeof-2.c	(revision 180924)
+++ gcc/testsuite/gcc.dg/weak/typeof-2.c	(working copy)
@@ -5,6 +5,9 @@ 
 /* { dg-require-weak "" } */
 /* { dg-require-alias "" } */
 /* { dg-options "-O2" } */
+/* Using -mshort-calls avoids loading the function addresses in
+   registers and thus getting the counts wrong.  */
+/* { dg-options "-O2 -mshort-calls" { target epiphany-*-* } } */
 
 extern int foo1 (int x) __asm ("baz1");
 int bar1 (int x) { return x; }
Index: gcc/testsuite/gcc.dg/tls/thr-cse-1.c
===================================================================
--- gcc/testsuite/gcc.dg/tls/thr-cse-1.c	(revision 180924)
+++ gcc/testsuite/gcc.dg/tls/thr-cse-1.c	(working copy)
@@ -1,5 +1,8 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O1" } */
+/* Using -mshort-calls avoids loading the function addresses in
+   registers and thus getting the counts wrong.  */
+/* { dg-options "-O1 -mshort-calls" { target epiphany-*-* } } */
 /* { dg-require-effective-target tls_emulated } */
 
 /* Test that we only get one call to emutls_get_address when CSE is
Index: gcc/testsuite/gcc.dg/20020312-2.c
===================================================================
--- gcc/testsuite/gcc.dg/20020312-2.c	(revision 180924)
+++ gcc/testsuite/gcc.dg/20020312-2.c	(working copy)
@@ -20,6 +20,8 @@  extern void abort (void);
 /* No pic register.  */
 #elif defined(__cris__)
 # define PIC_REG  "0"
+#elif defined(__epiphany__)
+#define PIC_REG "r28"
 #elif defined(__fr30__)
 /* No pic register.  */
 #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__)
Index: gcc/testsuite/gcc.dg/builtin-apply2.c
===================================================================
--- gcc/testsuite/gcc.dg/builtin-apply2.c	(revision 180924)
+++ gcc/testsuite/gcc.dg/builtin-apply2.c	(working copy)
@@ -12,7 +12,7 @@ 
 
 #define INTEGER_ARG  5
 
-#ifdef __ARM_PCS
+#if defined(__ARM_PCS) || defined(__epiphany__)
 /* For Base AAPCS, NAME is passed in r0.  D is passed in r2 and r3.
    E, F and G are passed on stack.  So the size of the stack argument
    data is 20.  */
Index: gcc/testsuite/g++.dg/opt/devirt2.C
===================================================================
--- gcc/testsuite/g++.dg/opt/devirt2.C	(revision 180924)
+++ gcc/testsuite/g++.dg/opt/devirt2.C	(working copy)
@@ -1,5 +1,8 @@ 
 // { dg-do compile }
 // { dg-options "-O2" }
+/* Using -mshort-calls avoids loading the function addresses in
+   registers and thus getting the counts wrong.  */
+// { dg-options "-O2 -mshort-calls" {target epiphany-*-*} }
 // { dg-final { scan-assembler-times "xyzzy" 2 { target { ! { alpha*-*-* hppa*-*-* ia64*-*-hpux* sparc*-*-* } } } } }
 // The IA64 and HPPA compilers generate external declarations in addition
 // to the call so those scans need to be more specific.
Index: gcc/testsuite/g++.dg/parse/pragma3.C
===================================================================
--- gcc/testsuite/g++.dg/parse/pragma3.C	(revision 180924)
+++ gcc/testsuite/g++.dg/parse/pragma3.C	(working copy)
@@ -1,5 +1,6 @@ 
 // PR c++/25294
-// { dg-do run }
+// Epiphany makes struct S 8-byte aligned.
+// { dg-do run { target { ! epiphany-*-* } } }
 
 extern "C" void abort (void);
 
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 180924)
+++ gcc/config.gcc	(working copy)
@@ -967,6 +967,14 @@ 
 		;;
 	esac
 	;;
+epiphany-*-elf )
+	tm_file="dbxelf.h elfos.h newlib-stdint.h ${tm_file}"
+	tmake_file="epiphany/t-epiphany"
+	extra_options="${extra_options} fused-madd.opt"
+	extra_objs="$extra_objs mode-switch-use.o resolve-sw-modes.o"
+	tm_defines="${tm_defines} EPIPHANY_STACK_OFFSET=${with_stack_offset:-8}"
+	extra_headers="epiphany_intrinsics.h"
+	;;
 fr30-*-elf)
 	tm_file="dbxelf.h elfos.h newlib-stdint.h ${tm_file}"
 	;;