public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH V6 04/11] testsuite: new require effective target indirect_calls
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
@ 2019-08-29 15:14 ` Jose E. Marchesi
  2019-09-09  9:56   ` Jose E. Marchesi
  2019-09-11 18:55   ` Mike Stump
  2019-08-29 15:14 ` [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size Jose E. Marchesi
                   ` (9 subsequent siblings)
  10 siblings, 2 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:14 UTC (permalink / raw)
  To: gcc-patches

This patch adds a new dg_require_effective_target procedure to the
testsuite infrastructure: indirect_calls.  This new function tells
whether a target supports calls to non-constant call targets.

This patch also annotates the tests in the gcc.c-torture testuite that
require support for indirect calls.

gcc/ChangeLog:

	* doc/sourcebuild.texi (Effective-Target Keywords): Document
	indirect_calls.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp (check_effective_target_indirect_calls):
	New proc.
	* gcc.c-torture/compile/20010102-1.c: Annotate with
	dg-require-effective-target indirect_calls.
	* gcc.c-torture/compile/20010107-1.c: Likewise.
	* gcc.c-torture/compile/20011109-1.c: Likewise.
	* gcc.c-torture/compile/20011218-1.c: Likewise.
	* gcc.c-torture/compile/20011229-1.c: Likewise.
	* gcc.c-torture/compile/20020129-1.c: Likewise.
	* gcc.c-torture/compile/20020320-1.c: Likewise.
	* gcc.c-torture/compile/20020706-1.c: Likewise.
	* gcc.c-torture/compile/20020706-2.c: Likewise.
	* gcc.c-torture/compile/20021205-1.c: Likewise.
	* gcc.c-torture/compile/20030921-1.c: Likewise.
	* gcc.c-torture/compile/20031023-1.c: Likewise.
	* gcc.c-torture/compile/20031023-2.c: Likewise.
	* gcc.c-torture/compile/20031023-3.c: Likewise.
	* gcc.c-torture/compile/20031023-4.c: Likewise.
	* gcc.c-torture/compile/20040614-1.c: Likewise.
	* gcc.c-torture/compile/20040909-1.c: Likewise.
	* gcc.c-torture/compile/20050122-1.c: Likewise.
	* gcc.c-torture/compile/20050202-1.c: Likewise.
	* gcc.c-torture/compile/20060208-1.c: Likewise.
	* gcc.c-torture/compile/20081108-1.c: Likewise.
	* gcc.c-torture/compile/20150327.c: Likewise.
	* gcc.c-torture/compile/920428-2.c: Likewise.
	* gcc.c-torture/compile/920928-5.c: Likewise.
	* gcc.c-torture/compile/930117-1.c: Likewise.
	* gcc.c-torture/compile/930607-1.c: Likewise.
	* gcc.c-torture/compile/991213-2.c: Likewise.
	* gcc.c-torture/compile/callind.c: Likewise.
	* gcc.c-torture/compile/calls-void.c: Likewise.
	* gcc.c-torture/compile/calls.c: Likewise.
	* gcc.c-torture/compile/pr21840.c: Likewise.
	* gcc.c-torture/compile/pr32139.c: Likewise.
	* gcc.c-torture/compile/pr35607.c: Likewise.
	* gcc.c-torture/compile/pr37433-1.c: Likewise.
	* gcc.c-torture/compile/pr37433.c: Likewise.
	* gcc.c-torture/compile/pr39941.c: Likewise.
	* gcc.c-torture/compile/pr40080.c: Likewise.
	* gcc.c-torture/compile/pr43635.c: Likewise.
	* gcc.c-torture/compile/pr43791.c: Likewise.
	* gcc.c-torture/compile/pr43845.c: Likewise.
	* gcc.c-torture/compile/pr44043.c: Likewise.
	* gcc.c-torture/compile/pr51694.c: Likewise.
	* gcc.c-torture/compile/pr77754-2.c: Likewise.
	* gcc.c-torture/compile/pr77754-3.c: Likewise.
	* gcc.c-torture/compile/pr77754-4.c: Likewise.
	* gcc.c-torture/compile/pr89663-2.c: Likewise.
	* gcc.c-torture/compile/pta-1.c: Likewise.
	* gcc.c-torture/compile/stack-check-1.c: Likewise.
	* gcc.dg/Walloc-size-larger-than-18.c: Likewise.
---
 gcc/ChangeLog                                      |  5 ++
 gcc/doc/sourcebuild.texi                           |  4 ++
 gcc/testsuite/ChangeLog                            | 55 ++++++++++++++++++++++
 gcc/testsuite/gcc.c-torture/compile/20010102-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20010107-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20011109-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20011218-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20011229-1.c   |  3 ++
 gcc/testsuite/gcc.c-torture/compile/20020129-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20020320-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20020706-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20020706-2.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20021205-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20030921-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/20031023-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20031023-2.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20031023-3.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20031023-4.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20040614-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/20040909-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20050122-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20050202-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20060208-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20081108-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20150327.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/920428-2.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/920928-5.c     |  3 ++
 gcc/testsuite/gcc.c-torture/compile/930117-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/930607-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/991213-2.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/callind.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/calls-void.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/calls.c        |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr21840.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr32139.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr35607.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr37433-1.c    |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr37433.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr39941.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr40080.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr43635.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr43791.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr43845.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr44043.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr51694.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr77754-2.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr77754-3.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr77754-4.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr89663-2.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pta-1.c        |  2 +
 .../gcc.c-torture/compile/stack-check-1.c          |  1 +
 gcc/testsuite/gcc.dg/Walloc-size-larger-than-18.c  |  1 +
 gcc/testsuite/lib/target-supports.exp              |  8 ++++
 53 files changed, 162 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index f9fcd0916b3..88917ea77d3 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2377,6 +2377,10 @@ Target supports @code{wchar_t} that is compatible with @code{char32_t}.
 
 @item comdat_group
 Target uses comdat groups.
+
+@item indirect_calls
+Target supports indirect calls, i.e. calls where the target is not
+constant.
 @end table
 
 @subsubsection Local to tests in @code{gcc.target/i386}
diff --git a/gcc/testsuite/gcc.c-torture/compile/20010102-1.c b/gcc/testsuite/gcc.c-torture/compile/20010102-1.c
index a409b566098..3d9cc9edf72 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20010102-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20010102-1.c
@@ -4,6 +4,8 @@
 
    Copyright (C) 2001  Free Software Foundation.  */
 
+/* { dg-require-effective-target indirect_calls } */
+
 # define PTR_INT_TYPE __PTRDIFF_TYPE__
 
 struct _obstack_chunk
diff --git a/gcc/testsuite/gcc.c-torture/compile/20010107-1.c b/gcc/testsuite/gcc.c-torture/compile/20010107-1.c
index 222def4d9ef..22461a0521f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20010107-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20010107-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 unsigned long x[4];
 
 void foo(void)
diff --git a/gcc/testsuite/gcc.c-torture/compile/20011109-1.c b/gcc/testsuite/gcc.c-torture/compile/20011109-1.c
index f1987a74bf2..1deba2a52df 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20011109-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20011109-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef struct { short x[4]; } S;
 typedef struct { unsigned int a, b, c; S *d; } T;
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20011218-1.c b/gcc/testsuite/gcc.c-torture/compile/20011218-1.c
index bf63489b855..8db5b777089 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20011218-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20011218-1.c
@@ -2,6 +2,8 @@
    for the indirect call was exposed too early and reload couldn't
    allocate it for multiplication and division.  */
 
+/* { dg-require-effective-target indirect_calls } */
+
 struct S {
   int a, b;
   void (*f) (long, int);
diff --git a/gcc/testsuite/gcc.c-torture/compile/20011229-1.c b/gcc/testsuite/gcc.c-torture/compile/20011229-1.c
index 97b2655434a..99aeab7d7cd 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20011229-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20011229-1.c
@@ -1,5 +1,8 @@
 /* ICE: call insn does not satisfy its constraints, MMIX port.
    Origin: ghostscript-6.52, reduction from hp@bitrange.com.  */
+
+/* { dg-require-effective-target indirect_calls } */
+
 struct s0
 {
   void (*init_color)(void *, void *);
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020129-1.c b/gcc/testsuite/gcc.c-torture/compile/20020129-1.c
index 7b17ba475e4..c14ac07655e 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20020129-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20020129-1.c
@@ -1,5 +1,7 @@
 /* Test call to static variable.  */
 
+/* { dg-require-effective-target indirect_calls } */
+
 typedef struct
 {
   long long a[10];
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020320-1.c b/gcc/testsuite/gcc.c-torture/compile/20020320-1.c
index 385c061e193..5b7a17a3080 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20020320-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20020320-1.c
@@ -2,6 +2,8 @@
    This testcase caused infinite loop in flow (several places),
    because flow assumes gen_jump generates simple_jump_p.  */
 
+/* { dg-require-effective-target indirect_calls } */
+
 typedef void (*T) (void);
 extern T x[];
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020706-1.c b/gcc/testsuite/gcc.c-torture/compile/20020706-1.c
index c8811bc68ff..9bbfc8a66dd 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20020706-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20020706-1.c
@@ -1,6 +1,8 @@
 // Contributed by Alexandre Oliva <aoliva@redhat.com>
 // From Red Hat case 106165.
 
+/* { dg-require-effective-target indirect_calls } */
+
 typedef struct s1
 {
   unsigned short v1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020706-2.c b/gcc/testsuite/gcc.c-torture/compile/20020706-2.c
index b84dda60fd3..2391f2085e8 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20020706-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20020706-2.c
@@ -1,6 +1,8 @@
 // Contributed by Alexandre Oliva <aoliva@redhat.com>
 // From Red Hat case 106165.
 
+/* { dg-require-effective-target indirect_calls } */
+
 typedef unsigned short (FUNC_P) (void *, unsigned char *, unsigned short);
 
 void crashIt(int id, FUNC_P *func, unsigned char *funcparm)
diff --git a/gcc/testsuite/gcc.c-torture/compile/20021205-1.c b/gcc/testsuite/gcc.c-torture/compile/20021205-1.c
index 73648e94951..27f45875108 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20021205-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20021205-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef struct x x;
 extern void *baz(char *);
 struct x { char * (*bar) (int); };
diff --git a/gcc/testsuite/gcc.c-torture/compile/20030921-1.c b/gcc/testsuite/gcc.c-torture/compile/20030921-1.c
index 8199dc657f2..4bb3f4645af 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20030921-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20030921-1.c
@@ -2,6 +2,7 @@
    f is not being emitted. TREE_SYMBOL_REFERENCED was being set
    instead of calling mark_referenced.  */
 
+/* { dg-require-effective-target indirect_calls } */
 
 static void f(void);
 void g(void (*x) (void)){x();}
diff --git a/gcc/testsuite/gcc.c-torture/compile/20031023-1.c b/gcc/testsuite/gcc.c-torture/compile/20031023-1.c
index be837762e66..1ee1ff7aaa6 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20031023-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20031023-1.c
@@ -1,5 +1,7 @@
 /* Declaration of the frame size doesn't work on ptx.  */
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-effective-target indirect_calls } */
+
 #ifndef ASIZE
 # define ASIZE 0x10000000000UL
 #endif
diff --git a/gcc/testsuite/gcc.c-torture/compile/20031023-2.c b/gcc/testsuite/gcc.c-torture/compile/20031023-2.c
index 66d66458c85..50965169adc 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20031023-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20031023-2.c
@@ -1,4 +1,6 @@
 /* Declaration of the frame size doesn't work on ptx.  */
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-effective-target indirect_calls } */
+
 #define ASIZE 0x1000000000UL
 #include "20031023-1.c"
diff --git a/gcc/testsuite/gcc.c-torture/compile/20031023-3.c b/gcc/testsuite/gcc.c-torture/compile/20031023-3.c
index 5859634c343..1bb692f45a9 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20031023-3.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20031023-3.c
@@ -1,4 +1,6 @@
 /* Declaration of the frame size doesn't work on ptx.  */
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-effective-target indirect_calls } */
+
 #define ASIZE 0x100000000UL
 #include "20031023-1.c"
diff --git a/gcc/testsuite/gcc.c-torture/compile/20031023-4.c b/gcc/testsuite/gcc.c-torture/compile/20031023-4.c
index 5c61f3743d4..85c4dca9cb5 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20031023-4.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20031023-4.c
@@ -1,2 +1,4 @@
+/* { dg-require-effective-target indirect_calls } */
+
 #define ASIZE 0x80000000UL
 #include "20031023-1.c"
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040614-1.c b/gcc/testsuite/gcc.c-torture/compile/20040614-1.c
index b692ab569f2..c889bb251c8 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20040614-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20040614-1.c
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target label_values } */
+/* { dg-require-effective-target indirect_calls } */
 
 void f(int r1, int *fp) 
 {     
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040909-1.c b/gcc/testsuite/gcc.c-torture/compile/20040909-1.c
index 8bbf90191b4..0f66cb261db 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20040909-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20040909-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 static __inline__ int
 one_utf8_to_utf16 () { }
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20050122-1.c b/gcc/testsuite/gcc.c-torture/compile/20050122-1.c
index a70907d9051..7bb7cee5a32 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20050122-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20050122-1.c
@@ -1,4 +1,6 @@
 /* From PR 19484.  */
+/* { dg-require-effective-target indirect_calls } */
+
 extern void foo (void) __attribute__((noreturn));
 int n;
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20050202-1.c b/gcc/testsuite/gcc.c-torture/compile/20050202-1.c
index b3f81764538..58ed54eceb3 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20050202-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20050202-1.c
@@ -1,4 +1,6 @@
 /* From PR 19578.  */
+/* { dg-require-effective-target indirect_calls } */
+
 extern void foo (void) __attribute__((noreturn));
 
 void
diff --git a/gcc/testsuite/gcc.c-torture/compile/20060208-1.c b/gcc/testsuite/gcc.c-torture/compile/20060208-1.c
index 3881474f722..5025463d7ef 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20060208-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20060208-1.c
@@ -1,5 +1,7 @@
 /* PR middle-end/26092 */
+/* { dg-require-effective-target indirect_calls } */
 /* { dg-skip-if "can't take address of malloc" { nvptx-*-* } } */
+
 typedef __SIZE_TYPE__ size_t;
 extern void *malloc (size_t);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20081108-1.c b/gcc/testsuite/gcc.c-torture/compile/20081108-1.c
index 3209a90c83b..a1f54e8c5fe 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20081108-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20081108-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 /* Test function call with function designator involving VLA
    side-effects does not lead to an ICE.  */
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20150327.c b/gcc/testsuite/gcc.c-torture/compile/20150327.c
index 373ea6183c3..125b722a6eb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20150327.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20150327.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 int a;
 int (*b)(), (*c)();
 int fn1(int p1) {
diff --git a/gcc/testsuite/gcc.c-torture/compile/920428-2.c b/gcc/testsuite/gcc.c-torture/compile/920428-2.c
index f313b32986b..817fff061e9 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920428-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920428-2.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 double sin(double x);
 double cos(double x);
 double tan(double x);
diff --git a/gcc/testsuite/gcc.c-torture/compile/920928-5.c b/gcc/testsuite/gcc.c-torture/compile/920928-5.c
index 8c975f0c051..b9f9dcbaeb0 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920928-5.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920928-5.c
@@ -1,4 +1,7 @@
 /* REPRODUCED:CC1:SIGNAL MACHINE:m68k OPTIONS:-fpcc-struct-return */
+
+/* { dg-require-effective-target indirect_calls } */
+
 struct b{};
 f(struct b(*f)())
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/930117-1.c b/gcc/testsuite/gcc.c-torture/compile/930117-1.c
index 83317cdd07b..06466f5e587 100644
--- a/gcc/testsuite/gcc.c-torture/compile/930117-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/930117-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 f(x)
 {
   (*(void (*)())&x)();
diff --git a/gcc/testsuite/gcc.c-torture/compile/930607-1.c b/gcc/testsuite/gcc.c-torture/compile/930607-1.c
index 97c94b25ec3..360bbbc1508 100644
--- a/gcc/testsuite/gcc.c-torture/compile/930607-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/930607-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef void f ();
 typedef f *pf;
 long long i;
diff --git a/gcc/testsuite/gcc.c-torture/compile/991213-2.c b/gcc/testsuite/gcc.c-torture/compile/991213-2.c
index 98385d56263..dfbedf7d674 100644
--- a/gcc/testsuite/gcc.c-torture/compile/991213-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/991213-2.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef long		__kernel_time_t;
 typedef __kernel_time_t		time_t;
 time2(
diff --git a/gcc/testsuite/gcc.c-torture/compile/callind.c b/gcc/testsuite/gcc.c-torture/compile/callind.c
index 5938d1b88fc..893f4e764ac 100644
--- a/gcc/testsuite/gcc.c-torture/compile/callind.c
+++ b/gcc/testsuite/gcc.c-torture/compile/callind.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 bar (foo, a)
      int (**foo) ();
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/calls-void.c b/gcc/testsuite/gcc.c-torture/compile/calls-void.c
index eeed4fdfdc1..7e6f56c16fb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/calls-void.c
+++ b/gcc/testsuite/gcc.c-torture/compile/calls-void.c
@@ -1,5 +1,6 @@
 /* { dg-require-effective-target ptr32plus } */
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-effective-target indirect_calls } */
 
 typedef void  (*T)(void);
 f1 ()
diff --git a/gcc/testsuite/gcc.c-torture/compile/calls.c b/gcc/testsuite/gcc.c-torture/compile/calls.c
index ca07122a786..48a3b7c77a5 100644
--- a/gcc/testsuite/gcc.c-torture/compile/calls.c
+++ b/gcc/testsuite/gcc.c-torture/compile/calls.c
@@ -1,5 +1,6 @@
 /* { dg-require-effective-target ptr32plus } */
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-effective-target indirect_calls } */
 
 typedef void  *(*T)(void);
 f1 ()
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr21840.c b/gcc/testsuite/gcc.c-torture/compile/pr21840.c
index bec3d6bf5d7..f6f2a5dc133 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr21840.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr21840.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 void fn_show_state(void);
 typedef void (*fn_handler_fn)(void);
 static fn_handler_fn fn_handler[1];
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr32139.c b/gcc/testsuite/gcc.c-torture/compile/pr32139.c
index 7b8522f5174..3cc541cb328 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr32139.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr32139.c
@@ -1,4 +1,6 @@
 /* PR tree-optimization/32139 */
+/* { dg-require-effective-target indirect_calls } */
+
 int foo (void);
 int bar (void) __attribute__ ((const));
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr35607.c b/gcc/testsuite/gcc.c-torture/compile/pr35607.c
index 7f5aa7a2b7c..9debd46df58 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr35607.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr35607.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 extern void (*__fini_array_start []) (void);
 extern void (*__fini_array_end []) (void);
 void
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c b/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c
index 322c167d682..48a57b637d7 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 void regex_subst(void)
 {
   const void *subst = "";
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37433.c b/gcc/testsuite/gcc.c-torture/compile/pr37433.c
index 0ba1179886c..95d168afa2f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37433.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37433.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 int regex_subst(void)
 {
   const void *subst = "";
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39941.c b/gcc/testsuite/gcc.c-torture/compile/pr39941.c
index b6209086be9..5cb3b0554ee 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr39941.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr39941.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef void (*entry_func) (void) __attribute__ ((noreturn));
 extern entry_func entry_addr;
 static void bsd_boot_entry (void)
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40080.c b/gcc/testsuite/gcc.c-torture/compile/pr40080.c
index e36f14273e8..37c5a918ad4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr40080.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr40080.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 extern void *ff(void*,int);
 
 struct lpgl { struct lpgl *next; };
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43635.c b/gcc/testsuite/gcc.c-torture/compile/pr43635.c
index df826b6f4c0..3875f4efcd4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr43635.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr43635.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-effective-target indirect_calls } */
+
 extern void d (void);
 
 void (*foo (void)) (float)
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43791.c b/gcc/testsuite/gcc.c-torture/compile/pr43791.c
index 2b1d06ff789..710bf7e9ec9 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr43791.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr43791.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 int owner();
 int clear();
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43845.c b/gcc/testsuite/gcc.c-torture/compile/pr43845.c
index bdb45e7d2a8..83442decd1c 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr43845.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr43845.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef int __attribute__ ((const)) (*x264_pixel_cmp_t)(void);
 
 typedef struct {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44043.c b/gcc/testsuite/gcc.c-torture/compile/pr44043.c
index 943501b4091..bd51089a70a 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr44043.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr44043.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef unsigned char __u8;
 typedef unsigned short __u16;
 typedef unsigned int __u32;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr51694.c b/gcc/testsuite/gcc.c-torture/compile/pr51694.c
index f5c1a40df86..c06bc2118aa 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr51694.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr51694.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-effective-target indirect_calls } */
+
 void
 foo (x, fn)
   void (*fn) ();
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr77754-2.c b/gcc/testsuite/gcc.c-torture/compile/pr77754-2.c
index d088961963d..d649d719722 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr77754-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr77754-2.c
@@ -1,4 +1,5 @@
 // { dg-require-effective-target alloca }
+// { dg-require-effective-target indirect_calls }
 /* PR c/77754 */
 
 int fn3();
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr77754-3.c b/gcc/testsuite/gcc.c-torture/compile/pr77754-3.c
index fb25e234fe2..51d7ca71966 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr77754-3.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr77754-3.c
@@ -1,4 +1,5 @@
 // { dg-require-effective-target alloca }
+// { dg-require-effective-target indirect_calls }
 /* PR c/77754 */
 
 int fn3();
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr77754-4.c b/gcc/testsuite/gcc.c-torture/compile/pr77754-4.c
index 1c5c4619a33..53216bb6e7c 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr77754-4.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr77754-4.c
@@ -1,4 +1,5 @@
 // { dg-require-effective-target alloca }
+// { dg-require-effective-target indirect_calls }
 /* PR c/77754 */
 
 int fn3();
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89663-2.c b/gcc/testsuite/gcc.c-torture/compile/pr89663-2.c
index 052fe69f40e..efac68233f6 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr89663-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr89663-2.c
@@ -1,4 +1,5 @@
 /* PR middle-end/89663 */
+/* { dg-require-effective-target indirect_calls } */
 
 int irint (double);
 long lrint (double);
diff --git a/gcc/testsuite/gcc.c-torture/compile/pta-1.c b/gcc/testsuite/gcc.c-torture/compile/pta-1.c
index 515e5ff13f4..07dad8a16a7 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pta-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pta-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target indirect_calls } */
+
 typedef struct JSObject JSObject;
 typedef struct JSObjectMap *(*JSNewObjectMapOp) (JSObject *obj);
 typedef JSObject *(*JSGetMethodOp) (JSObject *obj);
diff --git a/gcc/testsuite/gcc.c-torture/compile/stack-check-1.c b/gcc/testsuite/gcc.c-torture/compile/stack-check-1.c
index 2a03f7c29ae..c06f5a19b01 100644
--- a/gcc/testsuite/gcc.c-torture/compile/stack-check-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/stack-check-1.c
@@ -1,3 +1,4 @@
+/* { dg-require-effective-target indirect_calls } */
 /* { dg-require-effective-target untyped_assembly } */
 /* { dg-require-stack-check "" } */
 /* { dg-additional-options "-fstack-check" } */
diff --git a/gcc/testsuite/gcc.dg/Walloc-size-larger-than-18.c b/gcc/testsuite/gcc.dg/Walloc-size-larger-than-18.c
index b4aa167f655..7888cb1b1da 100644
--- a/gcc/testsuite/gcc.dg/Walloc-size-larger-than-18.c
+++ b/gcc/testsuite/gcc.dg/Walloc-size-larger-than-18.c
@@ -4,6 +4,7 @@
    with zero or excessive size trigger either -Walloc-zero or
    -Walloc-size-larger-than warnings.
    { dg-do compile }
+   { dg-require-effective-target indirect_calls }
    { dg-options "-O2 -Wall -Walloc-zero -ftrack-macro-expansion=0" } */
 
 #define ATTR(...) __attribute__ ((__VA_ARGS__))
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 300d22a2d65..f457a46a02b 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9552,3 +9552,11 @@ proc check_effective_target_mfentry { } {
 	        void foo (void) { }
     } "-mfentry"]
 }
+
+# Return 1 if this target supports indirect calls
+proc check_effective_target_indirect_calls { } {
+  if { [istarget bpf-*-*] } {
+        return 0
+  }
+  return 1
+}
-- 
2.11.0

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

* [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
  2019-08-29 15:14 ` [PATCH V6 04/11] testsuite: new require effective target indirect_calls Jose E. Marchesi
@ 2019-08-29 15:14 ` Jose E. Marchesi
  2019-09-09  9:52   ` Jose E. Marchesi
  2019-09-11 18:42   ` Mike Stump
  2019-08-29 15:16 ` [PATCH V6 07/11] bpf: gcc.target eBPF testsuite Jose E. Marchesi
                   ` (8 subsequent siblings)
  10 siblings, 2 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:14 UTC (permalink / raw)
  To: gcc-patches

This patch annotates tests that make use of a significant a mount of
stack space.  Embedded and other restricted targets may have problems
compiling and running these tests.  Note that the annotations are in
many cases not exact.

testsuite/ChangeLog:

	* gcc.c-torture/compile/20000609-1.c: Annotate with
	dg-require-stack-size.
	* gcc/testsuite/gcc.c-torture/compile/20000804-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20020304-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20020604-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20021015-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20050303-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20060421-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20071207-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20080903-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20121027-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/20151204.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/920501-12.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/920501-4.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/920723-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/921202-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/931003-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/931004-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/950719-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/951222-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/990517-1.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/bcopy.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr23929.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr25310.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr34458.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr39937.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr41181.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr41634.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr43415.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr43417.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/pr44788.c: Likewise.
	* gcc/testsuite/gcc.c-torture/compile/sound.c: Likewise.
---
 gcc/testsuite/ChangeLog                          | 35 ++++++++++++++++++++++++
 gcc/testsuite/gcc.c-torture/compile/20000609-1.c |  2 ++
 gcc/testsuite/gcc.c-torture/compile/20000804-1.c |  1 +
 gcc/testsuite/gcc.c-torture/compile/20020304-1.c |  2 ++
 gcc/testsuite/gcc.c-torture/compile/20020604-1.c |  1 +
 gcc/testsuite/gcc.c-torture/compile/20021015-1.c |  1 +
 gcc/testsuite/gcc.c-torture/compile/20050303-1.c |  1 +
 gcc/testsuite/gcc.c-torture/compile/20060421-1.c |  2 ++
 gcc/testsuite/gcc.c-torture/compile/20071207-1.c |  1 +
 gcc/testsuite/gcc.c-torture/compile/20080903-1.c |  2 ++
 gcc/testsuite/gcc.c-torture/compile/20121027-1.c |  2 ++
 gcc/testsuite/gcc.c-torture/compile/20151204.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/920501-12.c  |  1 +
 gcc/testsuite/gcc.c-torture/compile/920501-4.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/920723-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/921202-1.c   |  2 ++
 gcc/testsuite/gcc.c-torture/compile/931003-1.c   |  2 ++
 gcc/testsuite/gcc.c-torture/compile/931004-1.c   |  2 ++
 gcc/testsuite/gcc.c-torture/compile/950719-1.c   |  2 ++
 gcc/testsuite/gcc.c-torture/compile/951222-1.c   |  2 ++
 gcc/testsuite/gcc.c-torture/compile/990517-1.c   |  3 ++
 gcc/testsuite/gcc.c-torture/compile/bcopy.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr23929.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr25310.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr34458.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr39937.c    |  2 ++
 gcc/testsuite/gcc.c-torture/compile/pr41181.c    |  2 ++
 gcc/testsuite/gcc.c-torture/compile/pr41634.c    |  2 ++
 gcc/testsuite/gcc.c-torture/compile/pr43415.c    |  2 ++
 gcc/testsuite/gcc.c-torture/compile/pr43417.c    |  2 ++
 gcc/testsuite/gcc.c-torture/compile/pr44788.c    |  2 ++
 gcc/testsuite/gcc.c-torture/compile/sound.c      |  1 +
 32 files changed, 84 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/compile/20000609-1.c b/gcc/testsuite/gcc.c-torture/compile/20000609-1.c
index f03aa35a7ac..e41701cc6d9 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20000609-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20000609-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "1024" } */
+
 int main ()
 {
   char temp[1024] = "tempfile";
diff --git a/gcc/testsuite/gcc.c-torture/compile/20000804-1.c b/gcc/testsuite/gcc.c-torture/compile/20000804-1.c
index 35464c212d2..550669b53a3 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20000804-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20000804-1.c
@@ -6,6 +6,7 @@
 /* { dg-skip-if "Not enough 64-bit registers" { pdp11-*-* } { "-O0" } { "" } } */
 /* { dg-xfail-if "Inconsistent constraint on asm" { csky-*-* } { "-O0" } { "" } } */
 /* { dg-xfail-if "" { h8300-*-* } } */
+/* { dg-require-stack-size "99*4+16" } */
 
 /* Copyright (C) 2000, 2003 Free Software Foundation */
 __complex__ long long f ()
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020304-1.c b/gcc/testsuite/gcc.c-torture/compile/20020304-1.c
index 3940d5ffd2e..046c5d69c94 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20020304-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20020304-1.c
@@ -4,6 +4,8 @@
    Original bug report is c/5830 by Manuel Serrano <Manuel.Serrano@inria.fr>.
  */
 
+/* { dg-require-stack-size "513" } */
+
 typedef union scmobj {
   struct pair {
     union scmobj *car;
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020604-1.c b/gcc/testsuite/gcc.c-torture/compile/20020604-1.c
index d2e186a7182..4846f7997a3 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20020604-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20020604-1.c
@@ -1,6 +1,7 @@
 /* { dg-do assemble } */
 /* { dg-require-effective-target ptr32plus } */
 /* { dg-xfail-if "The array too big" { "h8300-*-*" } { "-mno-h" "-mn" } { "" } } */
+/* { dg-require-stack-size "2048*4*4" } */
 
 /* PR c/6957
    This testcase ICEd at -O2 on IA-32, because
diff --git a/gcc/testsuite/gcc.c-torture/compile/20021015-1.c b/gcc/testsuite/gcc.c-torture/compile/20021015-1.c
index 789b8a8b176..9753876c2d7 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20021015-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20021015-1.c
@@ -1,4 +1,5 @@
 /* PR target/7370.  */
+/* { dg-require-stack-size "4000 + 8" } */
 
 int g (int *x, int *y);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20050303-1.c b/gcc/testsuite/gcc.c-torture/compile/20050303-1.c
index 22154b30af5..0261acd2c30 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20050303-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20050303-1.c
@@ -1,5 +1,6 @@
 /* { dg-require-effective-target int32plus } */
 /* { dg-require-effective-target size32plus } */
+/* { dg-require-stack-size "128*1024" } */
 
 void crc()
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/20060421-1.c b/gcc/testsuite/gcc.c-torture/compile/20060421-1.c
index 1bd4079b4c8..05396d3dcc1 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20060421-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20060421-1.c
@@ -1,4 +1,6 @@
 /* This test used to ICE on ARM with -mcpu=iwmmxt.  */
+/* { dg-require-stack-size "249*8+1" } */
+
 void
 foo (void)
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/20071207-1.c b/gcc/testsuite/gcc.c-torture/compile/20071207-1.c
index 27b871616b1..fecf5317734 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20071207-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20071207-1.c
@@ -1,4 +1,5 @@
 /* PR tree-optimization/34371 */
+/* { dg-require-stack-size "1108" } */
 /* Testcase by Martin Michlmayr <tbm@cyrius.com> */
 
 void centerln (int width, int ch, char *s)
diff --git a/gcc/testsuite/gcc.c-torture/compile/20080903-1.c b/gcc/testsuite/gcc.c-torture/compile/20080903-1.c
index 180b926bf3d..d446ebf7c93 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20080903-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20080903-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "4096" } */
+
 struct bar { unsigned short length; };
 
 int
diff --git a/gcc/testsuite/gcc.c-torture/compile/20121027-1.c b/gcc/testsuite/gcc.c-torture/compile/20121027-1.c
index 3d3ff31f69b..7c92f3fa436 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20121027-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20121027-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "1024+16" } */
+
 extern int nc;
 void f(void)
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/20151204.c b/gcc/testsuite/gcc.c-torture/compile/20151204.c
index e41f6c1dca9..a6bac5d7e1f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20151204.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20151204.c
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target size20plus } */
+/* { dg-require-stack-size "32753*2" } */
 
 typedef __SIZE_TYPE__ size_t;
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/920501-12.c b/gcc/testsuite/gcc.c-torture/compile/920501-12.c
index 68892a689df..089de4dcddb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920501-12.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920501-12.c
@@ -1,5 +1,6 @@
 /* { dg-do assemble } */
 /* { dg-skip-if "Array too big" { "pdp11-*-*" } { "-mint32" } } */
+/* { dg-require-stack-size "9999*4" } */
 
 x(x){            return 3 + x;}
 a(x){int y[994]; return 3 + x;}
diff --git a/gcc/testsuite/gcc.c-torture/compile/920501-4.c b/gcc/testsuite/gcc.c-torture/compile/920501-4.c
index 10736ae76a4..2ef54b5d35d 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920501-4.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920501-4.c
@@ -1,6 +1,7 @@
 /* { dg-do assemble } */
 /* { dg-skip-if "ptxas times out" { nvptx-*-* } { "-O1" } { "" } } */
 /* { dg-skip-if "Array too big" { "pdp11-*-*" } { "-mint32" } } */
+/* { dg-require-stack-size "8196*4" } */
 
 foo ()
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/920723-1.c b/gcc/testsuite/gcc.c-torture/compile/920723-1.c
index cd8710be7e8..2d778759e13 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920723-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920723-1.c
@@ -1,4 +1,5 @@
 /* { dg-add-options stack_size } */
+/* { dg-require-stack-size "75*75*4" } */
 
 #if defined(STACK_SIZE) && STACK_SIZE < 65536
 # define GITT_SIZE 75
diff --git a/gcc/testsuite/gcc.c-torture/compile/921202-1.c b/gcc/testsuite/gcc.c-torture/compile/921202-1.c
index 1287edc57b8..d97ddf6144e 100644
--- a/gcc/testsuite/gcc.c-torture/compile/921202-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/921202-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "2055*3*8" } */
+
 f ()
 {
   long dx[2055];
diff --git a/gcc/testsuite/gcc.c-torture/compile/931003-1.c b/gcc/testsuite/gcc.c-torture/compile/931003-1.c
index 922b14379c9..637b9aa6d26 100644
--- a/gcc/testsuite/gcc.c-torture/compile/931003-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/931003-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "52*8" } */
+
 f (n, a)
      int n;
      double a[];
diff --git a/gcc/testsuite/gcc.c-torture/compile/931004-1.c b/gcc/testsuite/gcc.c-torture/compile/931004-1.c
index 0e741fd4ac0..d5796cee97d 100644
--- a/gcc/testsuite/gcc.c-torture/compile/931004-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/931004-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "4*4*2*80" } */
+
 #define A "This is a long test that tests the structure initialization"
 #define B A,A
 #define C B,B,B,B
diff --git a/gcc/testsuite/gcc.c-torture/compile/950719-1.c b/gcc/testsuite/gcc.c-torture/compile/950719-1.c
index d3277fada4e..e1ac117daeb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/950719-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/950719-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "4092+4" } */
+
 typedef struct
 {
   int Header;
diff --git a/gcc/testsuite/gcc.c-torture/compile/951222-1.c b/gcc/testsuite/gcc.c-torture/compile/951222-1.c
index b8246f5fe81..f1818e322cf 100644
--- a/gcc/testsuite/gcc.c-torture/compile/951222-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/951222-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "10000+3*8" } */
+
 extern long long foo ();
 
 long long
diff --git a/gcc/testsuite/gcc.c-torture/compile/990517-1.c b/gcc/testsuite/gcc.c-torture/compile/990517-1.c
index c738d4be760..afdd844e305 100644
--- a/gcc/testsuite/gcc.c-torture/compile/990517-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/990517-1.c
@@ -1,4 +1,7 @@
 /* Extracted from the sdm module in perl.  */
+
+/* { dg-require-stack-size "12*2+8+1024+8" } */
+
 typedef struct {
 	char *dptr;
 	int dsize;
diff --git a/gcc/testsuite/gcc.c-torture/compile/bcopy.c b/gcc/testsuite/gcc.c-torture/compile/bcopy.c
index 8108f296600..fce95c842f3 100644
--- a/gcc/testsuite/gcc.c-torture/compile/bcopy.c
+++ b/gcc/testsuite/gcc.c-torture/compile/bcopy.c
@@ -1,4 +1,5 @@
 /* { dg-add-options stack_size } */
+/* { dg-require-stack-size "[dg-effective-target-value stack_size]*2" } */
 
 void
 bcopy1 (s, d, c)
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr23929.c b/gcc/testsuite/gcc.c-torture/compile/pr23929.c
index 210bb585e06..2ec658421d9 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr23929.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr23929.c
@@ -1,4 +1,5 @@
 /* PR tree-optimization/23929 */
+/* { dg-require-stack-size "2048+8" } */
 
 extern void bar (char *);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr25310.c b/gcc/testsuite/gcc.c-torture/compile/pr25310.c
index 54695e05b4f..7bdd0c574bd 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr25310.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr25310.c
@@ -1,4 +1,5 @@
 /* { dg-skip-if "Array too big" { "pdp11-*-*" } { "-mint32" } } */
+/* { dg-require-stack-size "65536+20" } */
 
 /* Prevent spurious test failures on 16-bit targets.  */
 #if __INT_MAX__ >= 2147483647L
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34458.c b/gcc/testsuite/gcc.c-torture/compile/pr34458.c
index 096cc0c9b89..77154937a63 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr34458.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr34458.c
@@ -1,4 +1,5 @@
 /* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+/* { dg-require-stack-size "1025*4" } */
 
 typedef struct
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39937.c b/gcc/testsuite/gcc.c-torture/compile/pr39937.c
index d0231053258..df280535f1f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr39937.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr39937.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "4096" } */
+
 int foo (__const char *__restrict __s);
 static void 
 read_anisou(char line[])
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr41181.c b/gcc/testsuite/gcc.c-torture/compile/pr41181.c
index f866249b605..4e12d374681 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr41181.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr41181.c
@@ -1,5 +1,7 @@
 /* { dg-require-effective-target ptr32plus } */
 /* { dg-skip-if "The array is too big" { "avr-*-*" "pdp11-*-*" } } */ 
+/* { dg-require-stack-size "250*250" } */
+
 char paths[1024];
 static void x264_slicetype_path(char (*best_paths)[250], int n, int length)
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr41634.c b/gcc/testsuite/gcc.c-torture/compile/pr41634.c
index 976e463e2ba..afad6d211bb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr41634.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr41634.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "2*512 + 256" } */
+
 extern int _xgetw();
 extern int foo(char*);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43415.c b/gcc/testsuite/gcc.c-torture/compile/pr43415.c
index c00e1c41ce9..66afe99a06b 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr43415.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr43415.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "256*8+4" } */
+
 int main()                                                                      
 {                                                                               
   unsigned long long table[256];                                          
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43417.c b/gcc/testsuite/gcc.c-torture/compile/pr43417.c
index 45bf053a0cb..5ae98be35b3 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr43417.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr43417.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "1004*4+2*8" } */
+
 int pid_count = 0;
 
 unsigned int getopt (int, const char**, const char*);
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44788.c b/gcc/testsuite/gcc.c-torture/compile/pr44788.c
index 99dc7982394..b570f65ff92 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr44788.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr44788.c
@@ -1,3 +1,5 @@
+/* { dg-require-stack-size "1060*4+4" } */
+
 void joint_decode(float* mlt_buffer1, int t) {
     int i;
     float decode_buffer[1060];
diff --git a/gcc/testsuite/gcc.c-torture/compile/sound.c b/gcc/testsuite/gcc.c-torture/compile/sound.c
index be727e3febb..66e24a00f68 100644
--- a/gcc/testsuite/gcc.c-torture/compile/sound.c
+++ b/gcc/testsuite/gcc.c-torture/compile/sound.c
@@ -1,3 +1,4 @@
+/* { dg-require-stack-size "8192+4" } */
 
 main ()
 {
-- 
2.11.0

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

* [PATCH V6 07/11] bpf: gcc.target eBPF testsuite
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
  2019-08-29 15:14 ` [PATCH V6 04/11] testsuite: new require effective target indirect_calls Jose E. Marchesi
  2019-08-29 15:14 ` [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size Jose E. Marchesi
@ 2019-08-29 15:16 ` Jose E. Marchesi
  2019-08-29 15:16 ` [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF Jose E. Marchesi
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:16 UTC (permalink / raw)
  To: gcc-patches

This patch adds a new testsuite to gcc.target, with eBPF specific
tests.

Tests are included for:
- Target specific diagnostics.
- All built-in functions.

testsuite/ChangeLog:

	* gcc.target/bpf/bpf.exp: New file.
	* gcc.target/bpf/builtin-load.c: Likewise.
	* cc.target/bpf/constant-calls.c: Likewise.
	* gcc.target/bpf/diag-funargs.c: Likewise.
	* cc.target/bpf/diag-indcalls.c: Likewise.
	* gcc.target/bpf/helper-bind.c: Likewise.
	* cc.target/bpf/helper-bpf-redirect.c: Likewise.
	* gcc.target/bpf/helper-clone-redirect.c: Likewise.
	* gcc.target/bpf/helper-csum-diff.c: Likewise.
	* gcc.target/bpf/helper-csum-update.c: Likewise.
	* gcc.target/bpf/helper-current-task-under-cgroup.c: Likewise.
	* gcc.target/bpf/helper-fib-lookup.c: Likewise.
	* gcc.target/bpf/helper-get-cgroup-classid.c: Likewise.
	* gcc.target/bpf/helper-get-current-cgroup-id.c: Likewise.
	* gcc.target/bpf/helper-get-current-comm.c: Likewise.
	* gcc.target/bpf/helper-get-current-pid-tgid.c: Likewise.
	* gcc.target/bpf/helper-get-current-task.c: Likewise.
	* gcc.target/bpf/helper-get-current-uid-gid.c: Likewise.
	* gcc.target/bpf/helper-get-hash-recalc.c: Likewise.
	* gcc.target/bpf/helper-get-listener-sock.c: Likewise.
	* gcc.target/bpf/helper-get-local-storage.c: Likewise.
	* gcc.target/bpf/helper-get-numa-node-id.c: Likewise.
	* gcc.target/bpf/helper-get-prandom-u32.c: Likewise.
	* gcc.target/bpf/helper-get-route-realm.c: Likewise.
	* gcc.target/bpf/helper-get-smp-processor-id.c: Likewise.
	* gcc.target/bpf/helper-get-socket-cookie.c: Likewise.
	* gcc.target/bpf/helper-get-socket-uid.c: Likewise.
	* gcc.target/bpf/helper-getsockopt.c: Likewise.
	* gcc.target/bpf/helper-get-stack.c: Likewise.
	* gcc.target/bpf/helper-get-stackid.c: Likewise.
	* gcc.target/bpf/helper-ktime-get-ns.c: Likewise.
	* gcc.target/bpf/helper-l3-csum-replace.c: Likewise.
	* gcc.target/bpf/helper-l4-csum-replace.c: Likewise.
	* gcc.target/bpf/helper-lwt-push-encap.c: Likewise.
	* gcc.target/bpf/helper-lwt-seg6-action.c: Likewise.
	* gcc.target/bpf/helper-lwt-seg6-adjust-srh.c: Likewise.
	* gcc.target/bpf/helper-lwt-seg6-store-bytes.c: Likewise.
	* gcc.target/bpf/helper-map-delete-elem.c: Likewise.
	* gcc.target/bpf/helper-map-lookup-elem.c: Likewise.
	* gcc.target/bpf/helper-map-peek-elem.c: Likewise.
	* gcc.target/bpf/helper-map-pop-elem.c: Likewise.
	* gcc.target/bpf/helper-map-push-elem.c: Likewise.
	* gcc.target/bpf/helper-map-update-elem.c: Likewise.
	* gcc.target/bpf/helper-msg-apply-bytes.c: Likewise.
	* gcc.target/bpf/helper-msg-cork-bytes.c: Likewise.
	* gcc.target/bpf/helper-msg-pop-data.c: Likewise.
	* gcc.target/bpf/helper-msg-pull-data.c: Likewise.
	* gcc.target/bpf/helper-msg-push-data.c: Likewise.
	* gcc.target/bpf/helper-msg-redirect-hash.c: Likewise.
	* gcc.target/bpf/helper-msg-redirect-map.c: Likewise.
	* gcc.target/bpf/helper-override-return.c: Likewise.
	* gcc.target/bpf/helper-perf-event-output.c: Likewise.
	* gcc.target/bpf/helper-perf-event-read.c: Likewise.
	* gcc.target/bpf/helper-perf-event-read-value.c: Likewise.
	* gcc.target/bpf/helper-perf-prog-read-value.c: Likewise.
	* gcc.target/bpf/helper-probe-read.c: Likewise.
	* gcc.target/bpf/helper-probe-read-str.c: Likewise.
	* gcc.target/bpf/helper-probe-write-user.c: Likewise.
	* gcc.target/bpf/helper-rc-keydown.c: Likewise.
	* gcc.target/bpf/helper-rc-pointer-rel.c: Likewise.
	* gcc.target/bpf/helper-rc-repeat.c: Likewise.
	* gcc.target/bpf/helper-redirect-map.c: Likewise.
	* gcc.target/bpf/helper-set-hash.c: Likewise.
	* gcc.target/bpf/helper-set-hash-invalid.c: Likewise.
	* gcc.target/bpf/helper-setsockopt.c: Likewise.
	* gcc.target/bpf/helper-skb-adjust-room.c: Likewise.
	* gcc.target/bpf/helper-skb-cgroup-id.c: Likewise.
	* gcc.target/bpf/helper-skb-change-head.c: Likewise.
	* gcc.target/bpf/helper-skb-change-proto.c: Likewise.
	* gcc.target/bpf/helper-skb-change-tail.c: Likewise.
	* gcc.target/bpf/helper-skb-change-type.c: Likewise.
	* gcc.target/bpf/helper-skb-ecn-set-ce.c: Likewise.
	* gcc.target/bpf/helper-skb-get-tunnel-key.c: Likewise.
	* gcc.target/bpf/helper-skb-get-tunnel-opt.c: Likewise.
	* gcc.target/bpf/helper-skb-get-xfrm-state.c: Likewise.
	* gcc.target/bpf/helper-skb-load-bytes.c: Likewise.
	* gcc.target/bpf/helper-skb-load-bytes-relative.c: Likewise.
	* gcc.target/bpf/helper-skb-pull-data.c: Likewise.
	* gcc.target/bpf/helper-skb-set-tunnel-key.c: Likewise.
	* gcc.target/bpf/helper-skb-set-tunnel-opt.c: Likewise.
	* gcc.target/bpf/helper-skb-store-bytes.c: Likewise.
	* gcc.target/bpf/helper-skb-under-cgroup.c: Likewise.
	* gcc.target/bpf/helper-skb-vlan-pop.c: Likewise.
	* gcc.target/bpf/helper-skb-vlan-push.c: Likewise.
	* gcc.target/bpf/helper-skc-lookup-tcp.c: Likewise.
	* gcc.target/bpf/helper-sk-fullsock.c: Likewise.
	* gcc.target/bpf/helper-sk-lookup-tcp.c: Likewise.
	* gcc.target/bpf/helper-sk-lookup-upd.c: Likewise.
	* gcc.target/bpf/helper-sk-redirect-hash.c: Likewise.
	* gcc.target/bpf/helper-sk-redirect-map.c: Likewise.
	* gcc.target/bpf/helper-sk-release.c: Likewise.
	* gcc.target/bpf/helper-sk-select-reuseport.c: Likewise.
	* gcc.target/bpf/helper-sk-storage-delete.c: Likewise.
	* gcc.target/bpf/helper-sk-storage-get.c: Likewise.
	* gcc.target/bpf/helper-sock-hash-update.c: Likewise.
	* gcc.target/bpf/helper-sock-map-update.c: Likewise.
	* gcc.target/bpf/helper-sock-ops-cb-flags-set.c: Likewise.
	* gcc.target/bpf/helper-spin-lock.c: Likewise.
	* gcc.target/bpf/helper-spin-unlock.c: Likewise.
	* gcc.target/bpf/helper-strtol.c: Likewise.
	* gcc.target/bpf/helper-strtoul.c: Likewise.
	* gcc.target/bpf/helper-sysctl-get-current-value.c: Likewise.
	* gcc.target/bpf/helper-sysctl-get-name.c: Likewise.
	* gcc.target/bpf/helper-sysctl-get-new-value.c: Likewise.
	* gcc.target/bpf/helper-sysctl-set-new-value.c: Likewise.
	* gcc.target/bpf/helper-tail-call.c: Likewise.
	* gcc.target/bpf/helper-tcp-check-syncookie.c: Likewise.
	* gcc.target/bpf/helper-tcp-sock.c: Likewise.
	* gcc.target/bpf/helper-trace-printk.c: Likewise.
	* gcc.target/bpf/helper-xdp-adjust-head.c: Likewise.
	* gcc.target/bpf/helper-xdp-adjust-meta.c: Likewise.
	* gcc.target/bpf/helper-xdp-adjust-tail.c: Likewise.
	* gcc.target/bpf/skb-ancestor-cgroup-id.c: Likewise.
	* gcc.target/bpf/sync-fetch-and-add.c: Likewise.
---
 gcc/testsuite/ChangeLog                            | 119 +++++++++++++++++++++
 gcc/testsuite/gcc.target/bpf/bpf.exp               |  41 +++++++
 gcc/testsuite/gcc.target/bpf/builtin-load.c        |  20 ++++
 gcc/testsuite/gcc.target/bpf/constant-calls.c      |  20 ++++
 gcc/testsuite/gcc.target/bpf/diag-funargs-2.c      |  26 +++++
 gcc/testsuite/gcc.target/bpf/diag-funargs-3.c      |  26 +++++
 gcc/testsuite/gcc.target/bpf/diag-funargs.c        |  15 +++
 gcc/testsuite/gcc.target/bpf/diag-indcalls.c       |  11 ++
 gcc/testsuite/gcc.target/bpf/helper-bind.c         |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c |  15 +++
 .../gcc.target/bpf/helper-clone-redirect.c         |  16 +++
 gcc/testsuite/gcc.target/bpf/helper-csum-diff.c    |  16 +++
 gcc/testsuite/gcc.target/bpf/helper-csum-update.c  |  15 +++
 .../bpf/helper-current-task-under-cgroup.c         |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c   |  16 +++
 .../gcc.target/bpf/helper-get-cgroup-classid.c     |  14 +++
 .../gcc.target/bpf/helper-get-current-cgroup-id.c  |  13 +++
 .../gcc.target/bpf/helper-get-current-comm.c       |  15 +++
 .../gcc.target/bpf/helper-get-current-pid-tgid.c   |  13 +++
 .../gcc.target/bpf/helper-get-current-task.c       |  13 +++
 .../gcc.target/bpf/helper-get-current-uid-gid.c    |  13 +++
 .../gcc.target/bpf/helper-get-hash-recalc.c        |  14 +++
 .../gcc.target/bpf/helper-get-listener-sock.c      |  13 +++
 .../gcc.target/bpf/helper-get-local-storage.c      |  14 +++
 .../gcc.target/bpf/helper-get-numa-node-id.c       |  13 +++
 .../gcc.target/bpf/helper-get-prandom-u32.c        |  13 +++
 .../gcc.target/bpf/helper-get-route-realm.c        |  14 +++
 .../gcc.target/bpf/helper-get-smp-processor-id.c   |  13 +++
 .../gcc.target/bpf/helper-get-socket-cookie.c      |  14 +++
 .../gcc.target/bpf/helper-get-socket-uid.c         |  14 +++
 gcc/testsuite/gcc.target/bpf/helper-get-stack.c    |  16 +++
 gcc/testsuite/gcc.target/bpf/helper-get-stackid.c  |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-getsockopt.c   |  17 +++
 gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c |  12 +++
 .../gcc.target/bpf/helper-l3-csum-replace.c        |  16 +++
 .../gcc.target/bpf/helper-l4-csum-replace.c        |  16 +++
 .../gcc.target/bpf/helper-lwt-push-encap.c         |  15 +++
 .../gcc.target/bpf/helper-lwt-seg6-action.c        |  16 +++
 .../gcc.target/bpf/helper-lwt-seg6-adjust-srh.c    |  16 +++
 .../gcc.target/bpf/helper-lwt-seg6-store-bytes.c   |  16 +++
 .../gcc.target/bpf/helper-map-delete-elem.c        |  14 +++
 .../gcc.target/bpf/helper-map-lookup-elem.c        |  12 +++
 .../gcc.target/bpf/helper-map-peek-elem.c          |  14 +++
 gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c |  14 +++
 .../gcc.target/bpf/helper-map-push-elem.c          |  16 +++
 .../gcc.target/bpf/helper-map-update-elem.c        |  16 +++
 .../gcc.target/bpf/helper-msg-apply-bytes.c        |  15 +++
 .../gcc.target/bpf/helper-msg-cork-bytes.c         |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c |  16 +++
 .../gcc.target/bpf/helper-msg-pull-data.c          |  16 +++
 .../gcc.target/bpf/helper-msg-push-data.c          |  16 +++
 .../gcc.target/bpf/helper-msg-redirect-hash.c      |  16 +++
 .../gcc.target/bpf/helper-msg-redirect-map.c       |  17 +++
 .../gcc.target/bpf/helper-override-return.c        |  15 +++
 .../gcc.target/bpf/helper-perf-event-output.c      |  17 +++
 .../gcc.target/bpf/helper-perf-event-read-value.c  |  16 +++
 .../gcc.target/bpf/helper-perf-event-read.c        |  15 +++
 .../gcc.target/bpf/helper-perf-prog-read-value.c   |  15 +++
 .../gcc.target/bpf/helper-probe-read-str.c         |  16 +++
 gcc/testsuite/gcc.target/bpf/helper-probe-read.c   |  15 +++
 .../gcc.target/bpf/helper-probe-write-user.c       |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c   |  17 +++
 .../gcc.target/bpf/helper-rc-pointer-rel.c         |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c    |  14 +++
 gcc/testsuite/gcc.target/bpf/helper-redirect-map.c |  16 +++
 .../gcc.target/bpf/helper-set-hash-invalid.c       |  13 +++
 gcc/testsuite/gcc.target/bpf/helper-set-hash.c     |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-setsockopt.c   |  19 ++++
 gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c  |  13 +++
 .../gcc.target/bpf/helper-sk-lookup-tcp.c          |  19 ++++
 .../gcc.target/bpf/helper-sk-lookup-upd.c          |  19 ++++
 .../gcc.target/bpf/helper-sk-redirect-hash.c       |  16 +++
 .../gcc.target/bpf/helper-sk-redirect-map.c        |  16 +++
 gcc/testsuite/gcc.target/bpf/helper-sk-release.c   |  14 +++
 .../gcc.target/bpf/helper-sk-select-reuseport.c    |  16 +++
 .../gcc.target/bpf/helper-sk-storage-delete.c      |  14 +++
 .../gcc.target/bpf/helper-sk-storage-get.c         |  16 +++
 .../gcc.target/bpf/helper-skb-adjust-room.c        |  17 +++
 .../gcc.target/bpf/helper-skb-cgroup-id.c          |  14 +++
 .../gcc.target/bpf/helper-skb-change-head.c        |  16 +++
 .../gcc.target/bpf/helper-skb-change-proto.c       |  16 +++
 .../gcc.target/bpf/helper-skb-change-tail.c        |  16 +++
 .../gcc.target/bpf/helper-skb-change-type.c        |  15 +++
 .../gcc.target/bpf/helper-skb-ecn-set-ce.c         |  14 +++
 .../gcc.target/bpf/helper-skb-get-tunnel-key.c     |  16 +++
 .../gcc.target/bpf/helper-skb-get-tunnel-opt.c     |  16 +++
 .../gcc.target/bpf/helper-skb-get-xfrm-state.c     |  17 +++
 .../bpf/helper-skb-load-bytes-relative.c           |  17 +++
 .../gcc.target/bpf/helper-skb-load-bytes.c         |  15 +++
 .../gcc.target/bpf/helper-skb-pull-data.c          |  15 +++
 .../gcc.target/bpf/helper-skb-set-tunnel-key.c     |  16 +++
 .../gcc.target/bpf/helper-skb-set-tunnel-opt.c     |  16 +++
 .../gcc.target/bpf/helper-skb-store-bytes.c        |  18 ++++
 .../gcc.target/bpf/helper-skb-under-cgroup.c       |  15 +++
 gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c |  14 +++
 .../gcc.target/bpf/helper-skb-vlan-push.c          |  16 +++
 .../gcc.target/bpf/helper-skc-lookup-tcp.c         |  17 +++
 .../gcc.target/bpf/helper-sock-hash-update.c       |  16 +++
 .../gcc.target/bpf/helper-sock-map-update.c        |  16 +++
 .../gcc.target/bpf/helper-sock-ops-cb-flags-set.c  |  16 +++
 gcc/testsuite/gcc.target/bpf/helper-spin-lock.c    |  13 +++
 gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c  |  13 +++
 gcc/testsuite/gcc.target/bpf/helper-strtol.c       |  18 ++++
 gcc/testsuite/gcc.target/bpf/helper-strtoul.c      |  18 ++++
 .../bpf/helper-sysctl-get-current-value.c          |  17 +++
 .../gcc.target/bpf/helper-sysctl-get-name.c        |  18 ++++
 .../gcc.target/bpf/helper-sysctl-get-new-value.c   |  17 +++
 .../gcc.target/bpf/helper-sysctl-set-new-value.c   |  17 +++
 gcc/testsuite/gcc.target/bpf/helper-tail-call.c    |  14 +++
 .../gcc.target/bpf/helper-tcp-check-syncookie.c    |  17 +++
 gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c     |  13 +++
 gcc/testsuite/gcc.target/bpf/helper-trace-printk.c |  13 +++
 .../gcc.target/bpf/helper-xdp-adjust-head.c        |  15 +++
 .../gcc.target/bpf/helper-xdp-adjust-meta.c        |  15 +++
 .../gcc.target/bpf/helper-xdp-adjust-tail.c        |  15 +++
 .../gcc.target/bpf/skb-ancestor-cgroup-id.c        |  16 +++
 gcc/testsuite/gcc.target/bpf/sync-fetch-and-add.c  |  14 +++
 117 files changed, 1944 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/bpf/bpf.exp
 create mode 100644 gcc/testsuite/gcc.target/bpf/builtin-load.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/constant-calls.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-funargs-2.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-funargs-3.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-funargs.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-indcalls.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-bind.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-clone-redirect.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-csum-diff.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-csum-update.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-current-task-under-cgroup.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-cgroup-classid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-cgroup-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-comm.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-pid-tgid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-task.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-uid-gid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-hash-recalc.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-listener-sock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-local-storage.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-numa-node-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-prandom-u32.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-route-realm.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-smp-processor-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-socket-cookie.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-socket-uid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-stack.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-stackid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-getsockopt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-l3-csum-replace.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-l4-csum-replace.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-push-encap.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-action.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-adjust-srh.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-store-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-delete-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-lookup-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-peek-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-push-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-update-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-apply-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-cork-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-pull-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-push-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-redirect-hash.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-redirect-map.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-override-return.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-event-output.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-event-read-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-event-read.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-prog-read-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-probe-read-str.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-probe-read.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-probe-write-user.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-rc-pointer-rel.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-redirect-map.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-set-hash-invalid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-set-hash.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-setsockopt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-lookup-tcp.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-lookup-upd.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-redirect-hash.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-redirect-map.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-release.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-select-reuseport.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-storage-delete.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-storage-get.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-adjust-room.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-cgroup-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-head.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-proto.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-tail.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-type.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-ecn-set-ce.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-key.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-opt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-get-xfrm-state.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes-relative.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-pull-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-key.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-opt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-store-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-under-cgroup.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-vlan-push.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skc-lookup-tcp.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sock-hash-update.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sock-map-update.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sock-ops-cb-flags-set.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-spin-lock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-strtol.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-strtoul.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-get-current-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-get-name.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-get-new-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-set-new-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-tail-call.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-tcp-check-syncookie.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-trace-printk.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-head.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-meta.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-tail.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/skb-ancestor-cgroup-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/sync-fetch-and-add.c

diff --git a/gcc/testsuite/gcc.target/bpf/bpf.exp b/gcc/testsuite/gcc.target/bpf/bpf.exp
new file mode 100644
index 00000000000..e5c8cfcf6b0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/bpf.exp
@@ -0,0 +1,41 @@
+# Copyright (C) 2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't an eBPF target.
+if ![istarget bpf-*-*] then {
+  return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+	"" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.target/bpf/builtin-load.c b/gcc/testsuite/gcc.target/bpf/builtin-load.c
new file mode 100644
index 00000000000..0f93d91fb6f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/builtin-load.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -std=gnu99" } */
+
+void foo ()
+{
+  long long ll, off;
+
+  /* Indirect.  */
+  ll = __builtin_bpf_load_byte (off);
+  ll = __builtin_bpf_load_half (off);
+  ll = __builtin_bpf_load_word (off);
+
+  /* Absolute.  */
+  ll = __builtin_bpf_load_byte (0);
+  ll = __builtin_bpf_load_half (4);
+  ll = __builtin_bpf_load_word (8);
+}
+
+/* { dg-final { scan-assembler "ldindb\t%r.,0.*ldindh\t%r.,0.*ldindw\t%r.,0" } } */
+/* { dg-final { scan-assembler "ldabsb\t0.*ldabsh\t4.*ldabsw\t8" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/constant-calls.c b/gcc/testsuite/gcc.target/bpf/constant-calls.c
new file mode 100644
index 00000000000..84612a92ae9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/constant-calls.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-xfail-if "" { bpf-*-* } } */
+
+typedef void  *(*T)(void);
+f1 ()
+{
+  ((T) 0)();
+}
+f2 ()
+{
+  ((T) 1000)();
+}
+f3 ()
+{
+  ((T) 1000000)();
+}
+
+/* { dg-final { scan-assembler "call\t0" } } */
+/* { dg-final { scan-assembler "call\t1000" } } */
+/* { dg-final { scan-assembler "call\t10000" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/diag-funargs-2.c b/gcc/testsuite/gcc.target/bpf/diag-funargs-2.c
new file mode 100644
index 00000000000..7c991af336b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/diag-funargs-2.c
@@ -0,0 +1,26 @@
+/* Verify proper errors are generated for functions taking too many
+   arguments, with aggregates and 128-bit arguments.  */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+#include <stdint.h>
+
+struct ja
+{
+  long i1;
+  long i2;
+  long i3;
+  long i4;
+  long i5;
+  long i6;
+};
+
+void jorl (struct ja, unsigned __int128, unsigned __int128, int i3);
+
+int foo ()
+{
+  struct ja je;
+  jorl (je, 1, 2, 3); /* { dg-error "too many function arguments" } */
+  return 2L /1;
+}
+
diff --git a/gcc/testsuite/gcc.target/bpf/diag-funargs-3.c b/gcc/testsuite/gcc.target/bpf/diag-funargs-3.c
new file mode 100644
index 00000000000..d9d42c18258
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/diag-funargs-3.c
@@ -0,0 +1,26 @@
+/* Verify proper errors are generated for functions taking too many
+   arguments, with aggregates and 128-bit arguments.  */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+#include <stdint.h>
+
+struct ja
+{
+  long i1;
+  long i2;
+  long i3;
+  long i4;
+  long i5;
+  long i6;
+};
+
+void jorl (struct ja, int, int, int, unsigned __int128);
+
+int foo ()
+{
+  struct ja je;
+  jorl (je, 1, 2, 3, 4); /* { dg-error "too many function arguments" } */
+  return 2L /1;
+}
+
diff --git a/gcc/testsuite/gcc.target/bpf/diag-funargs.c b/gcc/testsuite/gcc.target/bpf/diag-funargs.c
new file mode 100644
index 00000000000..d4e9c0683f2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/diag-funargs.c
@@ -0,0 +1,15 @@
+/* Verify proper errors are generated for functions taking too many
+   arguments.  */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int
+foo (int a1,  /* { dg-error "too many function arguments" } */
+     int a2,
+     int a3,
+     int a4,
+     int a5,
+     int a6)
+{
+  return a6;
+}
diff --git a/gcc/testsuite/gcc.target/bpf/diag-indcalls.c b/gcc/testsuite/gcc.target/bpf/diag-indcalls.c
new file mode 100644
index 00000000000..9263fcf7e1a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/diag-indcalls.c
@@ -0,0 +1,11 @@
+/* Verify proper errors are generated for indirect function calls.  */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+void (*fnp) (void);
+
+void
+foo ()
+{
+  (*fnp) ();
+} /* { dg-error "indirect call in function" } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-bind.c b/gcc/testsuite/gcc.target/bpf/helper-bind.c
new file mode 100644
index 00000000000..2d1fedc4ce8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-bind.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *addr;
+  int addr_len;
+
+  ret = __builtin_bpf_helper_bind (ctx, addr, addr_len);
+}
+
+/* { dg-final { scan-assembler "call\t64" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c b/gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c
new file mode 100644
index 00000000000..844c88d3e34
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  uint32_t ifindex;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_redirect (ifindex, flags);
+}
+
+/* { dg-final { scan-assembler "call\t23" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-clone-redirect.c b/gcc/testsuite/gcc.target/bpf/helper-clone-redirect.c
new file mode 100644
index 00000000000..a4fb8139234
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-clone-redirect.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t ifindex;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_clone_redirect (skb, ifindex, flags);
+}
+
+/* { dg-final { scan-assembler "call\t13" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-csum-diff.c b/gcc/testsuite/gcc.target/bpf/helper-csum-diff.c
new file mode 100644
index 00000000000..ef38192efd3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-csum-diff.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int64_t ret;
+  int32_t *to, *from;
+  uint64_t to_size, from_size;
+  int seed;
+
+  ret = __builtin_bpf_helper_csum_diff (from, from_size, to, to_size, seed);
+}
+
+/* { dg-final { scan-assembler "call\t28" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-csum-update.c b/gcc/testsuite/gcc.target/bpf/helper-csum-update.c
new file mode 100644
index 00000000000..3cde8678cb5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-csum-update.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int64_t ret;
+  void *skb;
+  int csum;
+
+  ret = __builtin_bpf_helper_csum_update (skb, csum);
+}
+
+/* { dg-final { scan-assembler "call\t40" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-current-task-under-cgroup.c b/gcc/testsuite/gcc.target/bpf/helper-current-task-under-cgroup.c
new file mode 100644
index 00000000000..a7eb6e617e8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-current-task-under-cgroup.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *map;
+  uint32_t index;
+
+  ret = __builtin_bpf_helper_current_task_under_cgroup (map, index);
+}
+
+/* { dg-final { scan-assembler "call\t37" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c b/gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c
new file mode 100644
index 00000000000..9a9f79d402c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *params;
+  int plen;
+  uint32_t flags;
+
+  ret = __builtin_bpf_helper_fib_lookup (ctx, params, plen, flags);
+}
+
+/* { dg-final { scan-assembler "call\t69" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-cgroup-classid.c b/gcc/testsuite/gcc.target/bpf/helper-get-cgroup-classid.c
new file mode 100644
index 00000000000..6cfd14d0ad1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-cgroup-classid.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint32_t ret;
+  void *skb;
+
+  ret = __builtin_bpf_helper_get_cgroup_classid (skb);
+}
+
+/* { dg-final { scan-assembler "call\t17" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-current-cgroup-id.c b/gcc/testsuite/gcc.target/bpf/helper-get-current-cgroup-id.c
new file mode 100644
index 00000000000..916dc4d3bb1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-current-cgroup-id.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+  
+  ret = __builtin_bpf_helper_get_current_cgroup_id ();
+}
+
+/* { dg-final { scan-assembler "call\t80" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-current-comm.c b/gcc/testsuite/gcc.target/bpf/helper-get-current-comm.c
new file mode 100644
index 00000000000..efc330c3c98
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-current-comm.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *buf;
+  uint32_t size_of_buf;
+
+  ret = __builtin_bpf_helper_get_current_comm (buf, size_of_buf);
+}
+
+/* { dg-final { scan-assembler "call\t16" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-current-pid-tgid.c b/gcc/testsuite/gcc.target/bpf/helper-get-current-pid-tgid.c
new file mode 100644
index 00000000000..32d3e9c91d1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-current-pid-tgid.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+
+  ret = __builtin_bpf_helper_get_current_pid_tgid ();
+}
+
+/* { dg-final { scan-assembler "call\t14" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-current-task.c b/gcc/testsuite/gcc.target/bpf/helper-get-current-task.c
new file mode 100644
index 00000000000..016c134b132
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-current-task.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+
+  ret = __builtin_bpf_helper_get_current_task ();
+}
+
+/* { dg-final { scan-assembler "call\t35" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-current-uid-gid.c b/gcc/testsuite/gcc.target/bpf/helper-get-current-uid-gid.c
new file mode 100644
index 00000000000..1dc2f9f41e5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-current-uid-gid.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+
+  ret = __builtin_bpf_helper_get_current_uid_gid ();
+}
+
+/* { dg-final { scan-assembler "call\t15" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-hash-recalc.c b/gcc/testsuite/gcc.target/bpf/helper-get-hash-recalc.c
new file mode 100644
index 00000000000..1db5d871c26
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-hash-recalc.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint32_t ret;
+  void *skb;
+
+  ret = __builtin_bpf_helper_get_hash_recalc (skb);
+}
+
+/* { dg-final { scan-assembler "call\t34" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-listener-sock.c b/gcc/testsuite/gcc.target/bpf/helper-get-listener-sock.c
new file mode 100644
index 00000000000..298da1c949b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-listener-sock.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret, *sk;
+
+  ret = __builtin_bpf_helper_get_listener_sock (sk);
+}
+
+/* { dg-final { scan-assembler "call\t98" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-local-storage.c b/gcc/testsuite/gcc.target/bpf/helper-get-local-storage.c
new file mode 100644
index 00000000000..88da67e99ae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-local-storage.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret, *map;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_get_local_storage (map, flags);
+}
+
+/* { dg-final { scan-assembler "call\t81" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-numa-node-id.c b/gcc/testsuite/gcc.target/bpf/helper-get-numa-node-id.c
new file mode 100644
index 00000000000..628e1012152
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-numa-node-id.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+
+  ret = __builtin_bpf_helper_get_numa_node_id ();
+}
+
+/* { dg-final { scan-assembler "call\t42" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-prandom-u32.c b/gcc/testsuite/gcc.target/bpf/helper-get-prandom-u32.c
new file mode 100644
index 00000000000..6d3e5bc7a22
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-prandom-u32.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint32_t ret;
+
+  ret = __builtin_bpf_helper_get_prandom_u32 ();
+}
+
+/* { dg-final { scan-assembler "call\t7" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-route-realm.c b/gcc/testsuite/gcc.target/bpf/helper-get-route-realm.c
new file mode 100644
index 00000000000..5056c4adb1f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-route-realm.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint32_t ret;
+  void *skb;
+
+  ret = __builtin_bpf_helper_get_route_realm (skb);
+}
+
+/* { dg-final { scan-assembler "call\t24" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-smp-processor-id.c b/gcc/testsuite/gcc.target/bpf/helper-get-smp-processor-id.c
new file mode 100644
index 00000000000..655b87341df
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-smp-processor-id.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint32_t ret;
+
+  ret = __builtin_bpf_helper_get_smp_processor_id ();
+}
+
+/* { dg-final { scan-assembler "call\t8" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-socket-cookie.c b/gcc/testsuite/gcc.target/bpf/helper-get-socket-cookie.c
new file mode 100644
index 00000000000..afd17ddcd50
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-socket-cookie.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+  void *skb;
+  
+  ret = __builtin_bpf_helper_get_socket_cookie (skb);
+}
+
+/* { dg-final { scan-assembler "call\t46" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-socket-uid.c b/gcc/testsuite/gcc.target/bpf/helper-get-socket-uid.c
new file mode 100644
index 00000000000..3a274c965f7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-socket-uid.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint32_t ret;
+  void *skb;
+  
+  ret = __builtin_bpf_helper_get_socket_uid (skb);
+}
+
+/* { dg-final { scan-assembler "call\t47" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-stack.c b/gcc/testsuite/gcc.target/bpf/helper-get-stack.c
new file mode 100644
index 00000000000..bbcdeb58775
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-stack.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *regs, *buf;
+  uint32_t size;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_get_stack (regs, buf, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t67" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-get-stackid.c b/gcc/testsuite/gcc.target/bpf/helper-get-stackid.c
new file mode 100644
index 00000000000..319d15cd2fa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-get-stackid.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *map;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_get_stackid (ctx, map, flags);
+}
+
+/* { dg-final { scan-assembler "call\t27" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-getsockopt.c b/gcc/testsuite/gcc.target/bpf/helper-getsockopt.c
new file mode 100644
index 00000000000..fb16f15e6ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-getsockopt.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *bpf_socket;
+  int level, optname, optlen;
+  char *optval;
+  
+  ret = __builtin_bpf_helper_getsockopt (bpf_socket, level,
+					 optname, optval, optlen);
+}
+
+/* { dg-final { scan-assembler "call\t57" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c b/gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c
new file mode 100644
index 00000000000..405df057e30
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+  ret = __builtin_bpf_helper_ktime_get_ns ();
+}
+
+/* { dg-final { scan-assembler "call\t5" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-l3-csum-replace.c b/gcc/testsuite/gcc.target/bpf/helper-l3-csum-replace.c
new file mode 100644
index 00000000000..ac17662c5d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-l3-csum-replace.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t offset;
+  uint64_t from, to, size;
+
+  ret = __builtin_bpf_helper_l3_csum_replace (skb, offset, from, to, size);
+}
+
+/* { dg-final { scan-assembler "call\t10" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-l4-csum-replace.c b/gcc/testsuite/gcc.target/bpf/helper-l4-csum-replace.c
new file mode 100644
index 00000000000..52b5514b6cb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-l4-csum-replace.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t offset;
+  uint64_t from, to, size;
+
+  ret = __builtin_bpf_helper_l4_csum_replace (skb, offset, from, to, size);
+}
+
+/* { dg-final { scan-assembler "call\t11" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-lwt-push-encap.c b/gcc/testsuite/gcc.target/bpf/helper-lwt-push-encap.c
new file mode 100644
index 00000000000..1baed27fac7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-lwt-push-encap.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *hdr;
+  uint32_t type, len;
+  
+  ret = __builtin_bpf_helper_lwt_push_encap (skb, type, hdr, len);
+}
+
+/* { dg-final { scan-assembler "call\t73" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-action.c b/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-action.c
new file mode 100644
index 00000000000..ccc94c1af9d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-action.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *param;
+  uint32_t action, param_len;
+  
+  ret = __builtin_bpf_helper_lwt_seg6_action (skb, action,
+					      param, param_len);
+}
+
+/* { dg-final { scan-assembler "call\t76" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-adjust-srh.c b/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-adjust-srh.c
new file mode 100644
index 00000000000..5e95124ad0f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-adjust-srh.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t offset, delta;
+  
+  ret = __builtin_bpf_helper_lwt_seg6_adjust_srh (skb, offset,
+						  delta);
+}
+
+/* { dg-final { scan-assembler "call\t75" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-store-bytes.c b/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-store-bytes.c
new file mode 100644
index 00000000000..098f97680f2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-store-bytes.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *from;
+  uint32_t offset, len;
+  
+  ret = __builtin_bpf_helper_lwt_seg6_store_bytes (skb, offset,
+						   from, len);
+}
+
+/* { dg-final { scan-assembler "call\t74" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-map-delete-elem.c b/gcc/testsuite/gcc.target/bpf/helper-map-delete-elem.c
new file mode 100644
index 00000000000..b8a6cdec4ee
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-map-delete-elem.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+  int ret;
+  char *key = 0;
+
+  ret = __builtin_bpf_helper_map_delete_elem (map (), key);
+}
+
+/* { dg-final { scan-assembler "call\t3" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-map-lookup-elem.c b/gcc/testsuite/gcc.target/bpf/helper-map-lookup-elem.c
new file mode 100644
index 00000000000..839cfc423a7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-map-lookup-elem.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+  char *key = 0, *value = 0;
+  value = __builtin_bpf_helper_map_lookup_elem (map (), key);
+}
+
+/* { dg-final { scan-assembler "call\t1" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-map-peek-elem.c b/gcc/testsuite/gcc.target/bpf/helper-map-peek-elem.c
new file mode 100644
index 00000000000..6d0acb1dcb7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-map-peek-elem.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+  int ret;
+  char *value = 0;
+
+  ret = __builtin_bpf_helper_map_peek_elem (map (), value);
+}
+
+/* { dg-final { scan-assembler "call\t89" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c b/gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c
new file mode 100644
index 00000000000..71a7851ca9c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+  int ret;
+  char *value = 0;
+
+  ret = __builtin_bpf_helper_map_pop_elem (map (), value);
+}
+
+/* { dg-final { scan-assembler "call\t88" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-map-push-elem.c b/gcc/testsuite/gcc.target/bpf/helper-map-push-elem.c
new file mode 100644
index 00000000000..53bc0ac5dd7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-map-push-elem.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+  int ret;
+  char *value = 0;
+  long long flags = 0;
+
+  ret = __builtin_bpf_helper_map_push_elem (map (), value, flags);
+}
+
+/* { dg-final { scan-assembler "call\t87" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-map-update-elem.c b/gcc/testsuite/gcc.target/bpf/helper-map-update-elem.c
new file mode 100644
index 00000000000..6281442ba3d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-map-update-elem.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+  int ret;
+  long long flags = 0;
+  char *key = 0, *value = 0;
+
+  ret = __builtin_bpf_helper_map_update_elem (map (), key, value, flags);
+}
+
+/* { dg-final { scan-assembler "call\t2" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-msg-apply-bytes.c b/gcc/testsuite/gcc.target/bpf/helper-msg-apply-bytes.c
new file mode 100644
index 00000000000..3b831acad64
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-msg-apply-bytes.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *msg;
+  uint32_t bytes;
+  
+  ret = __builtin_bpf_helper_msg_apply_bytes (msg, bytes);
+}
+
+/* { dg-final { scan-assembler "call\t61" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-msg-cork-bytes.c b/gcc/testsuite/gcc.target/bpf/helper-msg-cork-bytes.c
new file mode 100644
index 00000000000..2c4ee218832
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-msg-cork-bytes.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *msg;
+  uint32_t bytes;
+  
+  ret = __builtin_bpf_helper_msg_cork_bytes (msg, bytes);
+}
+
+/* { dg-final { scan-assembler "call\t62" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c b/gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c
new file mode 100644
index 00000000000..377c036603e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t start, pop;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_msg_pop_data (skb, start, pop, flags);
+}
+
+/* { dg-final { scan-assembler "call\t91" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-msg-pull-data.c b/gcc/testsuite/gcc.target/bpf/helper-msg-pull-data.c
new file mode 100644
index 00000000000..ef27493122b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-msg-pull-data.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *msg;
+  uint32_t start, end;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_msg_pull_data (msg, start, end, flags);
+}
+
+/* { dg-final { scan-assembler "call\t63" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-msg-push-data.c b/gcc/testsuite/gcc.target/bpf/helper-msg-push-data.c
new file mode 100644
index 00000000000..9e256bc5ca7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-msg-push-data.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t start, len;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_msg_push_data (skb, start, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t90" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-msg-redirect-hash.c b/gcc/testsuite/gcc.target/bpf/helper-msg-redirect-hash.c
new file mode 100644
index 00000000000..2e9d4137d66
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-msg-redirect-hash.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *msg, *map, *key;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_msg_redirect_hash (msg, map, key,
+						flags);
+}
+
+/* { dg-final { scan-assembler "call\t71" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-msg-redirect-map.c b/gcc/testsuite/gcc.target/bpf/helper-msg-redirect-map.c
new file mode 100644
index 00000000000..f5f8405e324
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-msg-redirect-map.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *msg, *map;
+  uint64_t key;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_msg_redirect_map (msg, map, key,
+					       flags);
+}
+
+/* { dg-final { scan-assembler "call\t60" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-override-return.c b/gcc/testsuite/gcc.target/bpf/helper-override-return.c
new file mode 100644
index 00000000000..3bd5424353f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-override-return.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *regs;
+  uint64_t rc;
+  
+  ret = __builtin_bpf_helper_override_return (regs, rc);
+}
+
+/* { dg-final { scan-assembler "call\t58" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-perf-event-output.c b/gcc/testsuite/gcc.target/bpf/helper-perf-event-output.c
new file mode 100644
index 00000000000..afb32010bdd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-perf-event-output.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *map;
+  uint64_t flags;
+  void *data;
+  uint64_t size;
+
+  ret = __builtin_bpf_helper_perf_event_output (ctx, map, flags, data, size);
+}
+
+/* { dg-final { scan-assembler "call\t25" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-perf-event-read-value.c b/gcc/testsuite/gcc.target/bpf/helper-perf-event-read-value.c
new file mode 100644
index 00000000000..1d512c9ec65
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-perf-event-read-value.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *map, *buf;
+  uint64_t flags;
+  uint64_t buf_size;
+  
+  ret = __builtin_bpf_helper_perf_event_read_value (map, flags, buf, buf_size);
+}
+
+/* { dg-final { scan-assembler "call\t55" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-perf-event-read.c b/gcc/testsuite/gcc.target/bpf/helper-perf-event-read.c
new file mode 100644
index 00000000000..f099a09d66f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-perf-event-read.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+  void *map;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_perf_event_read (map, flags);
+}
+
+/* { dg-final { scan-assembler "call\t22" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-perf-prog-read-value.c b/gcc/testsuite/gcc.target/bpf/helper-perf-prog-read-value.c
new file mode 100644
index 00000000000..00c4a3a78b5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-perf-prog-read-value.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *buf;
+  uint64_t buf_size;
+  
+  ret = __builtin_bpf_helper_perf_prog_read_value (ctx, buf, buf_size);
+}
+
+/* { dg-final { scan-assembler "call\t56" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-probe-read-str.c b/gcc/testsuite/gcc.target/bpf/helper-probe-read-str.c
new file mode 100644
index 00000000000..fd04760221d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-probe-read-str.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  int size;
+  void *dst;
+  const void *unsafe_ptr;
+  
+  ret = __builtin_bpf_helper_probe_read_str (dst, size, unsafe_ptr);
+}
+
+/* { dg-final { scan-assembler "call\t45" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-probe-read.c b/gcc/testsuite/gcc.target/bpf/helper-probe-read.c
new file mode 100644
index 00000000000..a77a907767b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-probe-read.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *src, *dst;
+  uint32_t size;
+
+  ret = __builtin_bpf_helper_probe_read (dst, size, src);
+}
+
+/* { dg-final { scan-assembler "call\t4" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-probe-write-user.c b/gcc/testsuite/gcc.target/bpf/helper-probe-write-user.c
new file mode 100644
index 00000000000..bf226206769
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-probe-write-user.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *dst, *src;
+  uint32_t len;
+
+  ret = __builtin_bpf_helper_probe_write_user (dst, src, len);
+}
+
+/* { dg-final { scan-assembler "call\t36" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c b/gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c
new file mode 100644
index 00000000000..58e9395dbeb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx;
+  uint32_t protocol, toggle;
+  uint64_t scancode;
+  
+  ret = __builtin_bpf_helper_rc_keydown (ctx, protocol,
+					 scancode, toggle);
+}
+
+/* { dg-final { scan-assembler "call\t78" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-rc-pointer-rel.c b/gcc/testsuite/gcc.target/bpf/helper-rc-pointer-rel.c
new file mode 100644
index 00000000000..e776bc75963
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-rc-pointer-rel.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx;
+  int32_t rel_x, rel_y;
+
+  ret = __builtin_bpf_helper_rc_pointer_rel (ctx, rel_x, rel_y);
+}
+
+/* { dg-final { scan-assembler "call\t92" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c b/gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c
new file mode 100644
index 00000000000..0ebc7de5bdf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx;
+  
+  ret = __builtin_bpf_helper_rc_repeat (ctx);
+}
+
+/* { dg-final { scan-assembler "call\t77" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-redirect-map.c b/gcc/testsuite/gcc.target/bpf/helper-redirect-map.c
new file mode 100644
index 00000000000..daeecc2a01e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-redirect-map.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *map;
+  uint32_t key;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_redirect_map (map, key, flags);
+}
+
+/* { dg-final { scan-assembler "call\t51" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-set-hash-invalid.c b/gcc/testsuite/gcc.target/bpf/helper-set-hash-invalid.c
new file mode 100644
index 00000000000..4bc63ffa063
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-set-hash-invalid.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *skb;
+
+  __builtin_bpf_helper_set_hash_invalid (skb);
+}
+
+/* { dg-final { scan-assembler "call\t41" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-set-hash.c b/gcc/testsuite/gcc.target/bpf/helper-set-hash.c
new file mode 100644
index 00000000000..d01ae6eb268
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-set-hash.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint32_t ret;
+  void *skb;
+  uint32_t hash;
+  
+  ret = __builtin_bpf_helper_set_hash (skb, hash);
+}
+
+/* { dg-final { scan-assembler "call\t48" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-setsockopt.c b/gcc/testsuite/gcc.target/bpf/helper-setsockopt.c
new file mode 100644
index 00000000000..6f3b450639e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-setsockopt.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *bpf_socket;
+  int level;
+  int optname;
+  void *optval;
+  int optlen;
+  
+  ret = __builtin_bpf_helper_setsockopt (bpf_socket, level, optname,
+					 optval, optlen);
+}
+
+/* { dg-final { scan-assembler "call\t49" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c b/gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c
new file mode 100644
index 00000000000..abe813d94f6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret, *sk;
+
+  ret = __builtin_bpf_helper_sk_fullsock (sk);
+}
+
+/* { dg-final { scan-assembler "call\t95" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-lookup-tcp.c b/gcc/testsuite/gcc.target/bpf/helper-sk-lookup-tcp.c
new file mode 100644
index 00000000000..4408640a6b2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-lookup-tcp.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret;
+  void *ctx, *tuple;
+  uint32_t tuple_size;
+  uint64_t netns, flags;
+  
+  ret = __builtin_bpf_helper_sk_lookup_tcp (ctx,
+					    tuple,
+					    tuple_size,
+					    netns, flags);
+}
+
+/* { dg-final { scan-assembler "call\t84" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-lookup-upd.c b/gcc/testsuite/gcc.target/bpf/helper-sk-lookup-upd.c
new file mode 100644
index 00000000000..4c50f9c6327
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-lookup-upd.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret;
+  void *ctx, *tuple;
+  uint32_t tuple_size;
+  uint64_t netns, flags;
+  
+  ret = __builtin_bpf_helper_sk_lookup_udp (ctx,
+					    tuple,
+					    tuple_size,
+					    netns, flags);
+}
+
+/* { dg-final { scan-assembler "call\t85" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-redirect-hash.c b/gcc/testsuite/gcc.target/bpf/helper-sk-redirect-hash.c
new file mode 100644
index 00000000000..7047c9f1290
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-redirect-hash.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *map, *key;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_sk_redirect_hash (skb, map, key,
+					       flags);
+}
+
+/* { dg-final { scan-assembler "call\t72" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-redirect-map.c b/gcc/testsuite/gcc.target/bpf/helper-sk-redirect-map.c
new file mode 100644
index 00000000000..5afb0ac4100
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-redirect-map.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *map;
+  uint32_t key;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_sk_redirect_map (ctx, map, key, flags);
+}
+
+/* { dg-final { scan-assembler "call\t52" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-release.c b/gcc/testsuite/gcc.target/bpf/helper-sk-release.c
new file mode 100644
index 00000000000..f054c90652c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-release.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *sock;
+  
+  ret = __builtin_bpf_helper_sk_release (sock);
+}
+
+/* { dg-final { scan-assembler "call\t86" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-select-reuseport.c b/gcc/testsuite/gcc.target/bpf/helper-sk-select-reuseport.c
new file mode 100644
index 00000000000..399ad2c0231
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-select-reuseport.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *reuse, *map, *key;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_sk_select_reuseport (reuse, map,
+						  key, flags);
+}
+
+/* { dg-final { scan-assembler "call\t82" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-storage-delete.c b/gcc/testsuite/gcc.target/bpf/helper-sk-storage-delete.c
new file mode 100644
index 00000000000..07c5875d930
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-storage-delete.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *map, *sk;
+  
+  ret = __builtin_bpf_helper_sk_storage_delete (map, sk);
+}
+
+/* { dg-final { scan-assembler "call\t108" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sk-storage-get.c b/gcc/testsuite/gcc.target/bpf/helper-sk-storage-get.c
new file mode 100644
index 00000000000..a199ef0ae64
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sk-storage-get.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret;
+  void *map, *sk, *value;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_sk_storage_get (map, sk, value,
+					     flags);
+}
+
+/* { dg-final { scan-assembler "call\t107" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-adjust-room.c b/gcc/testsuite/gcc.target/bpf/helper-skb-adjust-room.c
new file mode 100644
index 00000000000..88196f5e070
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-adjust-room.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  int32_t len_diff;
+  uint32_t mode;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_skb_adjust_room (skb, len_diff, mode, flags);
+}
+
+/* { dg-final { scan-assembler "call\t50" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-cgroup-id.c b/gcc/testsuite/gcc.target/bpf/helper-skb-cgroup-id.c
new file mode 100644
index 00000000000..7c9021e1763
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-cgroup-id.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  uint64_t ret;
+  void *skb;
+  
+  ret = __builtin_bpf_helper_skb_cgroup_id (skb);
+}
+
+/* { dg-final { scan-assembler "call\t79" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-change-head.c b/gcc/testsuite/gcc.target/bpf/helper-skb-change-head.c
new file mode 100644
index 00000000000..de6281539fd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-change-head.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t len;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_skb_change_head (skb, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t43" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-change-proto.c b/gcc/testsuite/gcc.target/bpf/helper-skb-change-proto.c
new file mode 100644
index 00000000000..5738f3cc59b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-change-proto.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  int16_t proto;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_skb_change_proto (skb, proto, flags);
+}
+
+/* { dg-final { scan-assembler "call\t31" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-change-tail.c b/gcc/testsuite/gcc.target/bpf/helper-skb-change-tail.c
new file mode 100644
index 00000000000..1fb6b45cd1b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-change-tail.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t len;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_skb_change_tail (skb, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t38" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-change-type.c b/gcc/testsuite/gcc.target/bpf/helper-skb-change-type.c
new file mode 100644
index 00000000000..bcf22cebc28
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-change-type.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t type;
+
+  ret = __builtin_bpf_helper_skb_change_type (skb, type);
+}
+
+/* { dg-final { scan-assembler "call\t32" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-ecn-set-ce.c b/gcc/testsuite/gcc.target/bpf/helper-skb-ecn-set-ce.c
new file mode 100644
index 00000000000..f769993f120
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-ecn-set-ce.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+
+  ret = __builtin_bpf_helper_skb_ecn_set_ce (skb);
+}
+
+/* { dg-final { scan-assembler "call\t97" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-key.c b/gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-key.c
new file mode 100644
index 00000000000..0d4db236865
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-key.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *key;
+  uint32_t size;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_skb_get_tunnel_key (skb, key, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t20" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-opt.c b/gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-opt.c
new file mode 100644
index 00000000000..9428657b932
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-opt.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint8_t *opt;
+  uint32_t size;
+
+  ret = __builtin_bpf_helper_skb_get_tunnel_opt (skb, opt, size);
+}
+
+/* { dg-final { scan-assembler "call\t29" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-get-xfrm-state.c b/gcc/testsuite/gcc.target/bpf/helper-skb-get-xfrm-state.c
new file mode 100644
index 00000000000..8217b4a17df
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-get-xfrm-state.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *xfrm_state;
+  uint32_t index, size;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_skb_get_xfrm_state (skb, index,
+						 xfrm_state, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t66" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes-relative.c b/gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes-relative.c
new file mode 100644
index 00000000000..bcaa43be9de
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes-relative.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *to;
+  uint32_t offset, len, start_header;
+
+  ret = __builtin_bpf_helper_skb_load_bytes_relative (skb, offset,
+						      to, len,
+						      start_header);
+}
+
+/* { dg-final { scan-assembler "call\t68" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes.c b/gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes.c
new file mode 100644
index 00000000000..9da545400c7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *to;
+  uint32_t offset, len;
+
+  ret = __builtin_bpf_helper_skb_load_bytes (skb, offset, to, len);
+}
+
+/* { dg-final { scan-assembler "call\t26" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-pull-data.c b/gcc/testsuite/gcc.target/bpf/helper-skb-pull-data.c
new file mode 100644
index 00000000000..9bb8b8d6e78
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-pull-data.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t len;
+
+  ret = __builtin_bpf_helper_skb_pull_data (skb, len);
+}
+
+/* { dg-final { scan-assembler "call\t39" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-key.c b/gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-key.c
new file mode 100644
index 00000000000..21b835f5cef
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-key.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *key;
+  uint32_t size;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_skb_set_tunnel_key (skb, key, size, flags);
+}
+
+/* { dg-final { scan-assembler "call\t21" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-opt.c b/gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-opt.c
new file mode 100644
index 00000000000..5a0528ec0a3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-opt.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint8_t *opt;
+  uint32_t size;
+
+  ret = __builtin_bpf_helper_skb_set_tunnel_opt (skb, opt, size);
+}
+
+/* { dg-final { scan-assembler "call\t30" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-store-bytes.c b/gcc/testsuite/gcc.target/bpf/helper-skb-store-bytes.c
new file mode 100644
index 00000000000..a41967cb904
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-store-bytes.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  uint32_t offset;
+  void *from;
+  uint32_t len;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_skb_store_bytes (skb, offset, from, len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t9" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-under-cgroup.c b/gcc/testsuite/gcc.target/bpf/helper-skb-under-cgroup.c
new file mode 100644
index 00000000000..0ccee8bed5c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-under-cgroup.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb, *map;
+  uint32_t index;
+
+  ret = __builtin_bpf_helper_skb_under_cgroup (skb, map, index);
+}
+
+/* { dg-final { scan-assembler "call\t33" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c b/gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c
new file mode 100644
index 00000000000..e99a0ac7802
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+
+  ret = __builtin_bpf_helper_skb_vlan_pop (skb);
+}
+
+/* { dg-final { scan-assembler "call\t19" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skb-vlan-push.c b/gcc/testsuite/gcc.target/bpf/helper-skb-vlan-push.c
new file mode 100644
index 00000000000..dbe52aee1b8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skb-vlan-push.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  int16_t vlan_proto;
+  uint16_t vlan_tci;
+
+  ret = __builtin_bpf_helper_skb_vlan_push (skb, vlan_proto, vlan_tci);
+}
+
+/* { dg-final { scan-assembler "call\t18" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-skc-lookup-tcp.c b/gcc/testsuite/gcc.target/bpf/helper-skc-lookup-tcp.c
new file mode 100644
index 00000000000..bbc4b99a808
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-skc-lookup-tcp.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret;
+  void *ctx, *tuple;
+  uint32_t tuple_size;
+  uint64_t netns, flags;
+
+  ret = __builtin_bpf_helper_skc_lookup_tcp (ctx, tuple,
+					     tuple_size, netns, flags);
+}
+
+/* { dg-final { scan-assembler "call\t99" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sock-hash-update.c b/gcc/testsuite/gcc.target/bpf/helper-sock-hash-update.c
new file mode 100644
index 00000000000..bbb77ef9ad5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sock-hash-update.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skops, *map, *key;
+  uint64_t flags;
+
+  ret = __builtin_bpf_helper_sock_hash_update (skops, map, key,
+					       flags);
+}
+
+/* { dg-final { scan-assembler "call\t70" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sock-map-update.c b/gcc/testsuite/gcc.target/bpf/helper-sock-map-update.c
new file mode 100644
index 00000000000..301e59e975b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sock-map-update.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skops, *map, *key;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_sock_map_update (skops, map, key,
+					      flags);
+}
+
+/* { dg-final { scan-assembler "call\t53" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sock-ops-cb-flags-set.c b/gcc/testsuite/gcc.target/bpf/helper-sock-ops-cb-flags-set.c
new file mode 100644
index 00000000000..2056312bcf3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sock-ops-cb-flags-set.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *bpf_sock;
+  int argval;
+  
+  ret = __builtin_bpf_helper_sock_ops_cb_flags_set (bpf_sock,
+						    argval);
+}
+
+/* { dg-final { scan-assembler "call\t59" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-spin-lock.c b/gcc/testsuite/gcc.target/bpf/helper-spin-lock.c
new file mode 100644
index 00000000000..4178914ae13
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-spin-lock.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *lock;
+
+  __builtin_bpf_helper_spin_lock (lock);
+}
+
+/* { dg-final { scan-assembler "call\t93" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c b/gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c
new file mode 100644
index 00000000000..c2416b66994
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *lock;
+
+  __builtin_bpf_helper_spin_unlock (lock);
+}
+
+/* { dg-final { scan-assembler "call\t94" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-strtol.c b/gcc/testsuite/gcc.target/bpf/helper-strtol.c
new file mode 100644
index 00000000000..e15b6d6b968
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-strtol.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+  int ret;
+  void *buf;
+  long res;
+  uint64_t flags;
+  size_t buf_len;
+  
+  ret = __builtin_bpf_helper_strtol (buf, buf_len, flags, &res);
+}
+
+/* { dg-final { scan-assembler "call\t105" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-strtoul.c b/gcc/testsuite/gcc.target/bpf/helper-strtoul.c
new file mode 100644
index 00000000000..bc0d77656d2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-strtoul.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+  int ret;
+  void *buf;
+  unsigned long res;
+  uint64_t flags;
+  size_t buf_len;
+  
+  ret = __builtin_bpf_helper_strtoul (buf, buf_len, flags, &res);
+}
+
+/* { dg-final { scan-assembler "call\t106" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-current-value.c b/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-current-value.c
new file mode 100644
index 00000000000..803584171dd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-current-value.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *buf;
+  size_t buf_len;
+  
+  ret = __builtin_bpf_helper_sysctl_get_current_value (ctx, buf,
+						       buf_len);
+}
+
+/* { dg-final { scan-assembler "call\t102" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-name.c b/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-name.c
new file mode 100644
index 00000000000..a748b4bf911
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-name.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *buf;
+  size_t buf_len;
+  uint64_t flags;
+  
+  ret = __builtin_bpf_helper_sysctl_get_name (ctx, buf,
+					      buf_len, flags);
+}
+
+/* { dg-final { scan-assembler "call\t101" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-new-value.c b/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-new-value.c
new file mode 100644
index 00000000000..2c4835100c9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sysctl-get-new-value.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *buf;
+  size_t buf_len;
+  
+  ret = __builtin_bpf_helper_sysctl_get_new_value (ctx, buf,
+						   buf_len);
+}
+
+/* { dg-final { scan-assembler "call\t103" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-sysctl-set-new-value.c b/gcc/testsuite/gcc.target/bpf/helper-sysctl-set-new-value.c
new file mode 100644
index 00000000000..fc3780da7e2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-sysctl-set-new-value.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+#include <stddef.h>
+
+void
+foo ()
+{
+  int ret;
+  void *ctx, *buf;
+  size_t buf_len;
+  
+  ret = __builtin_bpf_helper_sysctl_set_new_value (ctx, buf,
+						   buf_len);
+}
+
+/* { dg-final { scan-assembler "call\t104" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-tail-call.c b/gcc/testsuite/gcc.target/bpf/helper-tail-call.c
new file mode 100644
index 00000000000..618064f4aea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-tail-call.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ctx, *prog_array_map;
+  uint32_t index;
+
+  __builtin_bpf_helper_tail_call (ctx, prog_array_map, index);
+}
+
+/* { dg-final { scan-assembler "call\t12" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-tcp-check-syncookie.c b/gcc/testsuite/gcc.target/bpf/helper-tcp-check-syncookie.c
new file mode 100644
index 00000000000..95846c6f2d7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-tcp-check-syncookie.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *sk, *iph, *th;
+  uint32_t iph_len, th_len;
+  
+  ret = __builtin_bpf_helper_tcp_check_syncookie (sk, iph,
+						  iph_len,
+						  th, th_len);
+}
+
+/* { dg-final { scan-assembler "call\t100" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c b/gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c
new file mode 100644
index 00000000000..ab8f2de05d8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  void *ret, *sk;
+
+  ret = __builtin_bpf_helper_tcp_sock (sk);
+}
+
+/* { dg-final { scan-assembler "call\t96" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-trace-printk.c b/gcc/testsuite/gcc.target/bpf/helper-trace-printk.c
new file mode 100644
index 00000000000..fcf9d5c9e50
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-trace-printk.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+char *map () { return 0; }
+
+void
+foo ()
+{
+  int ret;
+
+  ret = __builtin_bpf_helper_trace_printk ("foo %d %d", sizeof ("foo %d %d"), 10, 20);
+}
+
+/* { dg-final { scan-assembler "call\t6" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-head.c b/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-head.c
new file mode 100644
index 00000000000..3dce5434535
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-head.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *xdp_md;
+  int delta;
+  
+  ret = __builtin_bpf_helper_xdp_adjust_head (xdp_md, delta);
+}
+
+/* { dg-final { scan-assembler "call\t44" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-meta.c b/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-meta.c
new file mode 100644
index 00000000000..38a13748737
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-meta.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *xdp_md;
+  int delta;
+  
+  ret = __builtin_bpf_helper_xdp_adjust_meta (xdp_md, delta);
+}
+
+/* { dg-final { scan-assembler "call\t54" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-tail.c b/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-tail.c
new file mode 100644
index 00000000000..319b65a233d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-tail.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *xdp_md;
+  int delta;
+
+  ret = __builtin_bpf_helper_xdp_adjust_tail (xdp_md, delta);
+}
+
+/* { dg-final { scan-assembler "call\t65" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/skb-ancestor-cgroup-id.c b/gcc/testsuite/gcc.target/bpf/skb-ancestor-cgroup-id.c
new file mode 100644
index 00000000000..ce193ec14bf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/skb-ancestor-cgroup-id.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+void
+foo ()
+{
+  int ret;
+  void *skb;
+  int ancestor_level;
+  
+  ret = __builtin_bpf_helper_skb_ancestor_cgroup_id (skb,
+						     ancestor_level);
+}
+
+/* { dg-final { scan-assembler "call\t83" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/sync-fetch-and-add.c b/gcc/testsuite/gcc.target/bpf/sync-fetch-and-add.c
new file mode 100644
index 00000000000..69949f14d0c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/sync-fetch-and-add.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+long delta;
+long *val;
+
+void
+foo ()
+{
+  __sync_fetch_and_add(val, delta);
+  __sync_fetch_and_add((int *)val, (int)delta);
+}
+
+/* { dg-final { scan-assembler "xadddw\t.*" } } */
+/* { dg-final { scan-assembler "xaddw\t.*" } } */
-- 
2.11.0

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

* [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (2 preceding siblings ...)
  2019-08-29 15:16 ` [PATCH V6 07/11] bpf: gcc.target eBPF testsuite Jose E. Marchesi
@ 2019-08-29 15:16 ` Jose E. Marchesi
  2019-09-11 18:58   ` Mike Stump
  2019-08-29 15:18 ` [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port Jose E. Marchesi
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:16 UTC (permalink / raw)
  To: gcc-patches

This patch makes the several effective target checks in
target-supports.exp to be aware of eBPF targets.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp
        (check_effective_target_trampolines): Adapt to eBPF.
	(check_effective_target_stack_size): Likewise.
	(dg-effective-target-value): Likewise.
	(check_effective_target_indirect_jumps): Likewise.
	(check_effective_target_nonlocal_goto): Likewise.
	(check_effective_target_global_constructor): Likewise.
	(check_effective_target_return_address): Likewise.
---
 gcc/testsuite/ChangeLog               |  9 +++++++++
 gcc/testsuite/lib/target-supports.exp | 18 +++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index f457a46a02b..ce08a2f8421 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -526,7 +526,8 @@ proc check_effective_target_trampolines { } {
 	 || [istarget nvptx-*-*]
 	 || [istarget hppa2.0w-hp-hpux11.23]
 	 || [istarget hppa64-hp-hpux11.23]
-	 || [istarget pru-*-*] } {
+	 || [istarget pru-*-*]
+	 || [istarget bpf-*-*] } {
 	return 0;
     }
     return 1
@@ -781,7 +782,7 @@ proc add_options_for_tls { flags } {
 # Return 1 if indirect jumps are supported, 0 otherwise.
 
 proc check_effective_target_indirect_jumps {} {
-    if { [istarget nvptx-*-*] } {
+    if { [istarget nvptx-*-*] || [istarget bpf-*-*] } {
 	return 0
     }
     return 1
@@ -790,7 +791,7 @@ proc check_effective_target_indirect_jumps {} {
 # Return 1 if nonlocal goto is supported, 0 otherwise.
 
 proc check_effective_target_nonlocal_goto {} {
-    if { [istarget nvptx-*-*] } {
+    if { [istarget nvptx-*-*] || [istarget bpf-*-*] } {
 	return 0
     }
     return 1
@@ -799,10 +800,9 @@ proc check_effective_target_nonlocal_goto {} {
 # Return 1 if global constructors are supported, 0 otherwise.
 
 proc check_effective_target_global_constructor {} {
-    if { [istarget nvptx-*-*] } {
-	return 0
-    }
-    if { [istarget amdgcn-*-*] } {
+    if { [istarget nvptx-*-*]
+	 || [istarget amdgcn-*-*]
+	 || [istarget bpf-*-*] } {
 	return 0
     }
     return 1
@@ -825,6 +825,10 @@ proc check_effective_target_return_address {} {
     if { [istarget nvptx-*-*] } {
 	return 0
     }
+    # No notion of return address in eBPF.
+    if { [istarget bpf-*-*] } {
+	return 0
+    }
     # It could be supported on amdgcn, but isn't yet.
     if { [istarget amdgcn*-*-*] } {
 	return 0
-- 
2.11.0

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

* [PATCH V6 10/11] bpf: manual updates for eBPF
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (4 preceding siblings ...)
  2019-08-29 15:18 ` [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port Jose E. Marchesi
@ 2019-08-29 15:18 ` Jose E. Marchesi
  2019-08-29 15:20 ` [PATCH V6 01/11] Update config.sub and config.guess Jose E. Marchesi
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:18 UTC (permalink / raw)
  To: gcc-patches

gcc/ChangeLog:

	* doc/invoke.texi (Option Summary): Cover eBPF.
	(eBPF Options): New section.
	* doc/extend.texi (BPF Built-in Functions): Likewise.
	(BPF Kernel Helpers): Likewise.
---
 gcc/ChangeLog       |   7 +++
 gcc/doc/extend.texi | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/doc/invoke.texi |  37 ++++++++++++
 3 files changed, 215 insertions(+)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 4aea4d31761..e821cafff1e 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13604,6 +13604,8 @@ instructions, but allow the compiler to schedule those calls.
 * ARM ARMv8-M Security Extensions::
 * AVR Built-in Functions::
 * Blackfin Built-in Functions::
+* BPF Built-in Functions::
+* BPF Kernel Helpers::
 * FR-V Built-in Functions::
 * MIPS DSP Built-in Functions::
 * MIPS Paired-Single Support::
@@ -14601,6 +14603,175 @@ void __builtin_bfin_csync (void)
 void __builtin_bfin_ssync (void)
 @end smallexample
 
+@node BPF Built-in Functions
+@subsection BPF Built-in Functions
+
+The following built-in functions are available for eBPF targets.
+
+@deftypefn {Built-in Function} unsigned long long __builtin_bpf_load_byte (unsigned long long @var{offset})
+Load a byte from the @code{struct sk_buff} packet data pointed by the register @code{%r6} and return it.
+@end deftypefn
+
+@deftypefn {Built-in Function} unsigned long long __builtin_bpf_load_half (unsigned long long @var{offset})
+Load 16-bits from the @code{struct sk_buff} packet data pointed by the register @code{%r6} and return it.
+@end deftypefn
+
+@deftypefn {Built-in Function} unsigned long long __builtin_bpf_load_word (unsigned long long @var{offset})
+Load 32-bits from the @code{struct sk_buff} packet data pointed by the register @code{%r6} and return it.
+@end deftypefn
+
+@node BPF Kernel Helpers
+@subsection BPF Kernel Helpers
+
+These built-in functions are available for calling kernel helpers, and
+they are available depending on the kernel version selected as the
+CPU.
+
+Rather than using the built-ins directly, it is preferred for programs
+to include @file{bpf-helpers.h} and use the wrappers defined there.
+
+For a full description of what the helpers do, the arguments they
+take, and the returned value, see the
+@file{linux/include/uapi/linux/bpf.h} in a Linux source tree.
+
+@smallexample
+void *__builtin_bpf_helper_map_lookup_elem (void *map, void *key)
+int   __builtin_bpf_helper_map_update_elem (void *map, void *key,
+                                            void *value,
+                                            unsigned long long flags)
+int   __builtin_bpf_helper_map_delete_elem (void *map, const void *key)
+int   __builtin_bpf_helper_map_push_elem (void *map, const void *value,
+                                          unsigned long long flags)
+int   __builtin_bpf_helper_map_pop_elem (void *map, void *value)
+int   __builtin_bpf_helper_map_peek_elem (void *map, void *value)
+int __builtin_bpf_helper_clone_redirect (void *skb,
+                                         unsigned int ifindex,
+                                         unsigned long long flags)
+int __builtin_bpf_helper_skb_get_tunnel_key (void *ctx, void *key, int size, int flags)
+int __builtin_bpf_helper_skb_set_tunnel_key (void *ctx, void *key, int size, int flags)
+int __builtin_bpf_helper_skb_get_tunnel_opt (void *ctx, void *md, int size)
+int __builtin_bpf_helper_skb_set_tunnel_opt (void *ctx, void *md, int size)
+int __builtin_bpf_helper_skb_get_xfrm_state (void *ctx, int index, void *state,
+				     int size, int flags)
+static unsigned long long __builtin_bpf_helper_skb_cgroup_id (void *ctx)
+static unsigned long long __builtin_bpf_helper_skb_ancestor_cgroup_id
+                                         (void *ctx, int level)
+int __builtin_bpf_helper_skb_vlan_push (void *ctx, __be16 vlan_proto, __u16 vlan_tci)
+int __builtin_bpf_helper_skb_vlan_pop (void *ctx)
+int __builtin_bpf_helper_skb_ecn_set_ce (void *ctx)
+
+int __builtin_bpf_helper_skb_load_bytes (void *ctx, int off, void *to, int len)
+int __builtin_bpf_helper_skb_load_bytes_relative (void *ctx, int off, void *to, int len, __u32 start_header)
+int __builtin_bpf_helper_skb_store_bytes (void *ctx, int off, void *from, int len, int flags)
+int __builtin_bpf_helper_skb_under_cgroup (void *ctx, void *map, int index)
+int __builtin_bpf_helper_skb_change_head (void *, int len, int flags)
+int __builtin_bpf_helper_skb_pull_data (void *, int len)
+int __builtin_bpf_helper_skb_change_proto (void *ctx, __be16 proto, __u64 flags)
+int __builtin_bpf_helper_skb_change_type (void *ctx, __u32 type)
+int __builtin_bpf_helper_skb_change_tail (void *ctx, __u32 len, __u64 flags)
+int __builtin_bpf_helper_skb_adjust_room (void *ctx, __s32 len_diff, __u32 mode,
+    				  unsigned long long flags)
+@end smallexample
+
+Other helpers:
+
+@smallexample
+int __builtin_bpf_helper_probe_read (void *dst, unsigned int size, void *src)
+unsigned long long __builtin_bpf_helper_ktime_get_ns (void)
+int __builtin_bpf_helper_trace_printk (const char *fmt, unsigned int fmt_size, ...)
+void __builtin_bpf_helper_tail_call (void *ctx, void *prog_array_map, unsigned int index)
+unsigned int __builtin_bpf_helper_get_smp_processor_id (void)
+unsigned long long __builtin_bpf_helper_get_current_pid_tgid (void)
+unsigned long long __builtin_bpf_helper_get_current_uid_gid (void)
+int __builtin_bpf_helper_get_current_comm (void *buf, unsigned int size_of_buf)
+unsigned long long __builtin_bpf_helper_perf_event_read (void *map, unsigned long long flags)
+
+int __builtin_bpf_helper_redirect (unsigned int ifindex, unsigned long long flags)
+int __builtin_bpf_helper_redirect_map (void *map, unsigned int key, unsigned long long flags)
+int __builtin_bpf_helper_perf_event_output (void *ctx,void *map, unsigned long long flags, void *data, unsigned long long size)
+int __builtin_bpf_helper_get_stackid (void *ctx, void *map, unsigned long long flags)
+int __builtin_bpf_helper_probe_write_user (void *dst, const void *src, unsigned int len)
+int __builtin_bpf_helper_current_task_under_cgroup (void *map, unsigned int index)
+
+static unsigned long long __builtin_bpf_helper_get_prandom_u32 (void)
+int __builtin_bpf_helper_xdp_adjust_head (void *ctx, int offset)
+int __builtin_bpf_helper_xdp_adjust_meta (void *ctx, int offset)
+int __builtin_bpf_helper_get_socket_cookie (void *ctx)
+int __builtin_bpf_helper_setsockopt (void *ctx, int level, int optname, void *optval,
+			     int optlen)
+int __builtin_bpf_helper_getsockopt (void *ctx, int level, int optname, void *optval,
+			     int optlen)
+int __builtin_bpf_helper_sock_ops_cb_flags_set (void *ctx, int flags)
+int __builtin_bpf_helper_sk_redirect_map (void *ctx, void *map, int key, int flags)
+int __builtin_bpf_helper_sk_redirect_hash (void *ctx, void *map, void *key, int flags)
+int __builtin_bpf_helper_sock_map_update (void *map, void *key, void *value,
+				  unsigned long long flags)
+int __builtin_bpf_helper_sock_hash_update (void *map, void *key, void *value,
+				   unsigned long long flags)
+int __builtin_bpf_helper_perf_event_read_value (void *map, unsigned long long flags,
+					void *buf, unsigned int buf_size)
+int __builtin_bpf_helper_perf_prog_read_value (void *ctx, void *buf,
+				       unsigned int buf_size)
+
+int __builtin_bpf_helper_override_return (void *ctx, unsigned long rc)
+int __builtin_bpf_helper_msg_redirect_map (void *ctx, void *map, int key, int flags)
+int __builtin_bpf_helper_msg_redirect_hash (void *ctx,
+				    void *map, void *key, int flags)
+int __builtin_bpf_helper_msg_apply_bytes (void *ctx, int len)
+int __builtin_bpf_helper_msg_cork_bytes (void *ctx, int len)
+int __builtin_bpf_helper_msg_pull_data (void *ctx, int start, int end, int flags)
+int __builtin_bpf_helper_msg_push_data (void *ctx, int start, int end, int flags)
+int __builtin_bpf_helper_msg_pop_data (void *ctx, int start, int cut, int flags)
+int __builtin_bpf_helper_bind (void *ctx, void *addr, int addr_len)
+int __builtin_bpf_helper_xdp_adjust_tail (void *ctx, int offset)
+int __builtin_bpf_helper_sk_select_reuseport (void *ctx, void *map, void *key, __u32 flags)
+int __builtin_bpf_helper_get_stack (void *ctx, void *buf, int size, int flags)
+int __builtin_bpf_helper_fib_lookup (void *ctx, struct bpf_fib_lookup *params,
+			     int plen, __u32 flags)
+
+int __builtin_bpf_helper_lwt_push_encap (void *ctx, unsigned int type, void *hdr,
+				 unsigned int len)
+int __builtin_bpf_helper_lwt_seg6_store_bytes (void *ctx, unsigned int offset,
+				       void *from, unsigned int len)
+int __builtin_bpf_helper_lwt_seg6_action (void *ctx, unsigned int action, void *param,
+				  unsigned int param_len)
+int __builtin_bpf_helper_lwt_seg6_adjust_srh (void *ctx, unsigned int offset,
+				      unsigned int len)
+int __builtin_bpf_helper_rc_repeat (void *ctx)
+int __builtin_bpf_helper_rc_keydown (void *ctx, unsigned int protocol,
+			     unsigned long long scancode, unsigned int toggle)
+static unsigned long long __builtin_bpf_helper_get_current_cgroup_id (void)
+static void *__builtin_bpf_helper_get_local_storage (void *map, unsigned long long flags)
+static struct bpf_sock *__builtin_bpf_helper_sk_lookup_tcp (void *ctx, void *tuple, int size, unsigned long long netns_id, unsigned long long flags)
+static struct bpf_sock *__builtin_bpf_helper_sk_lookup_udp (void *ctx, void *tuple, int size, unsigned long long netns_id, unsigned long long flags)
+int __builtin_bpf_helper_sk_release (struct bpf_sock *sk)
+int __builtin_bpf_helper_rc_pointer_rel (void *ctx, int rel_x, int rel_y)
+static void __builtin_bpf_helper_spin_lock (struct bpf_spin_lock *lock)
+static void __builtin_bpf_helper_spin_unlock (struct bpf_spin_lock *lock)
+
+static struct bpf_sock *__builtin_bpf_helper_sk_fullsock (struct bpf_sock *sk)
+static struct bpf_tcp_sock *__builtin_bpf_helper_tcp_sock (struct bpf_sock *sk)
+static struct bpf_sock *__builtin_bpf_helper_get_listener_sock (struct bpf_sock *sk)
+
+int __builtin_bpf_helper_l3_csum_replace (void *ctx, int off, int from, int to, int flags)
+int __builtin_bpf_helper_l4_csum_replace (void *ctx, int off, int from, int to, int flags)
+int __builtin_bpf_helper_csum_diff (void *from, int from_size, void *to, int to_size, int seed)
+
+static unsigned int __builtin_bpf_helper_get_cgroup_classid (void *ctx)
+static unsigned int __builtin_bpf_helper_get_route_realm (void *ctx)
+static unsigned int __builtin_bpf_helper_get_hash_recalc (void *ctx)
+static unsigned long long __builtin_bpf_helper_get_current_task (void *ctx)
+
+static long long __builtin_bpf_helper_csum_update (void *ctx, __u32 csum)
+static void __builtin_bpf_helper_set_hash_invalid (void *ctx)
+int __builtin_bpf_helper_get_numa_node_id (void)
+int __builtin_bpf_helper_probe_read_str (void *ctx, __u32 size,
+				 const void *unsafe_ptr)
+static unsigned int __builtin_bpf_helper_get_socket_uid (void *ctx)
+static unsigned int __builtin_bpf_helper_set_hash (void *ctx, __u32 hash)
+@end smallexample
+
+
 @node FR-V Built-in Functions
 @subsection FR-V Built-in Functions
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index aa9886ee09f..8e51bc7cc94 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -801,6 +801,10 @@ Objective-C and Objective-C++ Dialects}.
 -msmall-text  -mlarge-text @gol
 -mmemory-latency=@var{time}}
 
+@emph{eBPF Options}
+@gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
+-mframe-limit=@var{bytes}}
+
 @emph{FR30 Options}
 @gccoptlist{-msmall-model  -mno-lsim}
 
@@ -15680,6 +15684,7 @@ platform.
 * C-SKY Options::
 * Darwin Options::
 * DEC Alpha Options::
+* eBPF Options::
 * FR30 Options::
 * FT32 Options::
 * FRV Options::
@@ -19800,6 +19805,38 @@ Note that L3 is only valid for EV5.
 @end table
 @end table
 
+@node eBPF Options
+@subsection eBPF Options
+@cindex eBPF Options
+
+@table @gcctabopt
+@item -mframe-limit=@var{bytes}
+This specifies the hard limit for frame sizes, in bytes.  Currently,
+the value that can be specified should be less than or equal to
+@samp{32767}.  Defaults to whatever limit is imposed by the version of
+the Linux kernel targeted.
+
+@item -mkernel=@var{version}
+@opindex mkernel
+This specifies the minimum version of the kernel that will run the
+compiled program.  GCC uses this version to determine which
+instructions to use, what kernel helpers to allow, etc.  Currently,
+@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
+@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
+@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
+@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
+@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
+@samp{5.2}, @samp{latest} and @samp{native}.
+
+@item -mbig-endian
+@opindex mbig-endian
+Generate code for a big-endian target.
+
+@item -mlittle-endian
+@opindex mlittle-endian
+Generate code for a little-endian target.  This is the default.
+@end table
+
 @node FR30 Options
 @subsection FR30 Options
 @cindex FR30 Options
-- 
2.11.0

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

* [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (3 preceding siblings ...)
  2019-08-29 15:16 ` [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF Jose E. Marchesi
@ 2019-08-29 15:18 ` Jose E. Marchesi
  2019-09-08 11:36   ` Gerald Pfeifer
  2019-08-29 15:18 ` [PATCH V6 10/11] bpf: manual updates for eBPF Jose E. Marchesi
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:18 UTC (permalink / raw)
  To: gcc-patches

ChangeLog:

	* MAINTAINERS: Add myself as the maintainer of the eBPF port.
	Remove myself from Write After Approval section.
---
 ChangeLog   | 5 +++++
 MAINTAINERS | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5d8402949bc..5d69d696c2c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -57,6 +57,7 @@ arm port		Ramana Radhakrishnan	<ramana.radhakrishnan@arm.com>
 arm port		Kyrylo Tkachov		<kyrylo.tkachov@arm.com>
 avr port		Denis Chertykov		<chertykov@gmail.com>
 bfin port		Jie Zhang		<jzhang918@gmail.com>
+bpf port		Jose E. Marchesi	<jose.marchesi@oracle.com>
 c6x port		Bernd Schmidt		<bernds_cb1@t-online.de>
 cris port		Hans-Peter Nilsson	<hp@axis.com>
 c-sky port		Xianmiao Qu		<xianmiao_qu@c-sky.com>
@@ -497,7 +498,6 @@ Luis Machado					<luisgpm@br.ibm.com>
 Ziga Mahkovec					<ziga.mahkovec@klika.si>
 Matthew Malcomson				<matthew.malcomson@arm.com>
 Mikhail Maltsev					<maltsevm@gmail.com>
-Jose E. Marchesi				<jose.marchesi@oracle.com>
 Patrick Marlier					<patrick.marlier@gmail.com>
 Simon Martin					<simartin@users.sourceforge.net>
 Alejandro Martinez				<alejandro.martinezvicente@arm.com>
-- 
2.11.0

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

* [PATCH V6 01/11] Update config.sub and config.guess.
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (5 preceding siblings ...)
  2019-08-29 15:18 ` [PATCH V6 10/11] bpf: manual updates for eBPF Jose E. Marchesi
@ 2019-08-29 15:20 ` Jose E. Marchesi
  2019-09-09  9:17   ` Jose E. Marchesi
  2019-08-29 15:21 ` [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations Jose E. Marchesi
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:20 UTC (permalink / raw)
  To: gcc-patches

	* config.sub: Import upstream version 2019-06-30.
	* config.guess: Import upstream version 2019-07-24.
---
 ChangeLog    |   5 ++
 config.guess | 264 +++++++++++++++++++++++++++++++++++++++++++++++------------
 config.sub   |  50 +++++------
 3 files changed, 240 insertions(+), 79 deletions(-)

diff --git a/config.guess b/config.guess
index 8e2a58b864f..97ad0733304 100755
--- a/config.guess
+++ b/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2019 Free Software Foundation, Inc.
 
-timestamp='2019-01-03'
+timestamp='2019-07-24'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -262,6 +262,9 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
     *:SolidBSD:*:*)
 	echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
 	exit ;;
+    *:OS108:*:*)
+	echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE"
+	exit ;;
     macppc:MirBSD:*:*)
 	echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
 	exit ;;
@@ -275,8 +278,8 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	echo "$UNAME_MACHINE"-unknown-redox
 	exit ;;
     mips:OSF1:*.*)
-        echo mips-dec-osf1
-        exit ;;
+	echo mips-dec-osf1
+	exit ;;
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
 	*4.0)
@@ -385,20 +388,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
 	exit ;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-	set_cc_for_build
-	SUN_ARCH=sparc
-	# If there is a compiler, see if it is configured for 64-bit objects.
-	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
-	# This test works for both compilers.
-	if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
-	    if (echo '#ifdef __sparcv9'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-		grep IS_64BIT_ARCH >/dev/null
-	    then
-		SUN_ARCH=sparcv9
-	    fi
-	fi
-	echo "$SUN_ARCH"-sun-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
+	echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
 	exit ;;
     i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
 	echo i386-pc-auroraux"$UNAME_RELEASE"
@@ -998,22 +988,50 @@ EOF
 	exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
 	set_cc_for_build
+	IS_GLIBC=0
+	test x"${LIBC}" = xgnu && IS_GLIBC=1
 	sed 's/^	//' << EOF > "$dummy.c"
 	#undef CPU
-	#undef ${UNAME_MACHINE}
-	#undef ${UNAME_MACHINE}el
+	#undef mips
+	#undef mipsel
+	#undef mips64
+	#undef mips64el
+	#if ${IS_GLIBC} && defined(_ABI64)
+	LIBCABI=gnuabi64
+	#else
+	#if ${IS_GLIBC} && defined(_ABIN32)
+	LIBCABI=gnuabin32
+	#else
+	LIBCABI=${LIBC}
+	#endif
+	#endif
+
+	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+	CPU=mipsisa64r6
+	#else
+	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+	CPU=mipsisa32r6
+	#else
+	#if defined(__mips64)
+	CPU=mips64
+	#else
+	CPU=mips
+	#endif
+	#endif
+	#endif
+
 	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=${UNAME_MACHINE}el
+	MIPS_ENDIAN=el
 	#else
 	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=${UNAME_MACHINE}
+	MIPS_ENDIAN=
 	#else
-	CPU=
+	MIPS_ENDIAN=
 	#endif
 	#endif
 EOF
-	eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
-	test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
+	eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`"
+	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
 	;;
     mips64el:Linux:*:*)
 	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
@@ -1126,7 +1144,7 @@ EOF
 	    *Pentium)	     UNAME_MACHINE=i586 ;;
 	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
 	esac
-	echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
+	echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}"
 	exit ;;
     i*86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
@@ -1310,38 +1328,39 @@ EOF
 	echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
 	exit ;;
     *:Darwin:*:*)
-	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-	set_cc_for_build
-	if test "$UNAME_PROCESSOR" = unknown ; then
-	    UNAME_PROCESSOR=powerpc
+	UNAME_PROCESSOR=`uname -p`
+	case $UNAME_PROCESSOR in
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
+	if command -v xcode-select > /dev/null 2> /dev/null && \
+		! xcode-select --print-path > /dev/null 2> /dev/null ; then
+	    # Avoid executing cc if there is no toolchain installed as
+	    # cc will be a stub that puts up a graphical alert
+	    # prompting the user to install developer tools.
+	    CC_FOR_BUILD=no_compiler_found
+	else
+	    set_cc_for_build
 	fi
-	if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
-	    if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
-		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		       (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-		       grep IS_64BIT_ARCH >/dev/null
-		then
-		    case $UNAME_PROCESSOR in
-			i386) UNAME_PROCESSOR=x86_64 ;;
-			powerpc) UNAME_PROCESSOR=powerpc64 ;;
-		    esac
-		fi
-		# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
-		if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
-		       (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-		       grep IS_PPC >/dev/null
-		then
-		    UNAME_PROCESSOR=powerpc
-		fi
+	if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+		   grep IS_64BIT_ARCH >/dev/null
+	    then
+		case $UNAME_PROCESSOR in
+		    i386) UNAME_PROCESSOR=x86_64 ;;
+		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		esac
+	    fi
+	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+		   grep IS_PPC >/dev/null
+	    then
+		UNAME_PROCESSOR=powerpc
 	    fi
 	elif test "$UNAME_PROCESSOR" = i386 ; then
-	    # Avoid executing cc on OS X 10.9, as it ships with a stub
-	    # that puts up a graphical alert prompting to install
-	    # developer tools.  Any system running Mac OS X 10.7 or
-	    # later (Darwin 11 and later) is required to have a 64-bit
-	    # processor. This is not true of the ARM version of Darwin
-	    # that Apple uses in portable devices.
-	    UNAME_PROCESSOR=x86_64
+	    # uname -m returns i386 or x86_64
+	    UNAME_PROCESSOR=$UNAME_MACHINE
 	fi
 	echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
 	exit ;;
@@ -1446,6 +1465,143 @@ EOF
 	exit ;;
 esac
 
+# No uname command or uname output not recognized.
+set_cc_for_build
+cat > "$dummy.c" <<EOF
+#ifdef _SEQUENT_
+#include <sys/types.h>
+#include <sys/utsname.h>
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#include <signal.h>
+#if defined(_SIZE_T_) || defined(SIGLOST)
+#include <sys/utsname.h>
+#endif
+#endif
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+  "4"
+#else
+  ""
+#endif
+  ); exit (0);
+#endif
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+  struct utsname un;
+
+  uname(&un);
+  if (strncmp(un.version, "V2", 2) == 0) {
+    printf ("i386-sequent-ptx2\n"); exit (0);
+  }
+  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+    printf ("i386-sequent-ptx1\n"); exit (0);
+  }
+  printf ("i386-sequent-ptx\n"); exit (0);
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+#include <sys/param.h>
+#if defined (BSD)
+#if BSD == 43
+  printf ("vax-dec-bsd4.3\n"); exit (0);
+#else
+#if BSD == 199006
+  printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#else
+  printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#endif
+#else
+  printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#else
+#if defined(_SIZE_T_) || defined(SIGLOST)
+  struct utsname un;
+  uname (&un);
+  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
+#else
+  printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#if defined(_SIZE_T_) || defined(SIGLOST)
+  struct utsname *un;
+  uname (&un);
+  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
+#else
+  printf ("mips-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
+
 echo "$0: unable to guess system type" >&2
 
 case "$UNAME_MACHINE:$UNAME_SYSTEM" in
diff --git a/config.sub b/config.sub
index 75bb6a3135b..a318a468685 100755
--- a/config.sub
+++ b/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2019 Free Software Foundation, Inc.
 
-timestamp='2019-01-01'
+timestamp='2019-06-30'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -337,17 +337,14 @@ case $1 in
 				basic_machine=m88k-harris
 				os=sysv3
 				;;
-			hp300)
+			hp300 | hp300hpux)
 				basic_machine=m68k-hp
+				os=hpux
 				;;
 			hp300bsd)
 				basic_machine=m68k-hp
 				os=bsd
 				;;
-			hp300hpux)
-				basic_machine=m68k-hp
-				os=hpux
-				;;
 			hppaosf)
 				basic_machine=hppa1.1-hp
 				os=osf
@@ -360,10 +357,6 @@ case $1 in
 				basic_machine=i386-mach
 				os=mach
 				;;
-			vsta)
-				basic_machine=i386-pc
-				os=vsta
-				;;
 			isi68 | isi)
 				basic_machine=m68k-isi
 				os=sysv
@@ -612,6 +605,10 @@ case $1 in
 				basic_machine=vax-dec
 				os=vms
 				;;
+			vsta)
+				basic_machine=i386-pc
+				os=vsta
+				;;
 			vxworks960)
 				basic_machine=i960-wrs
 				os=vxworks
@@ -822,7 +819,9 @@ case $basic_machine in
 		cpu=m68k
 		vendor=next
 		case $os in
-		    nextstep* )
+		    openstep*)
+		        ;;
+		    nextstep*)
 			;;
 		    ns2*)
 		      os=nextstep2
@@ -919,7 +918,7 @@ case $basic_machine in
 		;;
 
 	*-*)
-	    	# shellcheck disable=SC2162
+		# shellcheck disable=SC2162
 		IFS="-" read cpu vendor <<EOF
 $basic_machine
 EOF
@@ -1170,7 +1169,7 @@ case $cpu-$vendor in
 			| asmjs \
 			| ba \
 			| be32 | be64 \
-			| bfin | bs2000 \
+			| bfin | bpf | bs2000 \
 			| c[123]* | c30 | [cjt]90 | c4x \
 			| c8051 | clipper | craynv | csky | cydra \
 			| d10v | d30v | dlx | dsp16xx \
@@ -1185,13 +1184,13 @@ case $cpu-$vendor in
 			| le32 | le64 \
 			| lm32 \
 			| m32c | m32r | m32rle \
-			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k | v70 | w65 \
-			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip \
+			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
+			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
 			| m88110 | m88k | maxq | mb | mcore | mep | metag \
 			| microblaze | microblazeel \
 			| mips | mipsbe | mipseb | mipsel | mipsle \
 			| mips16 \
-			| mips64 | mips64el \
+			| mips64 | mips64eb | mips64el \
 			| mips64octeon | mips64octeonel \
 			| mips64orion | mips64orionel \
 			| mips64r5900 | mips64r5900el \
@@ -1218,11 +1217,12 @@ case $cpu-$vendor in
 			| nds32 | nds32le | nds32be \
 			| nfp \
 			| nios | nios2 | nios2eb | nios2el \
-			| none | np1 | ns16k | ns32k \
+			| none | np1 | ns16k | ns32k | nvptx \
 			| open8 \
 			| or1k* \
 			| or32 \
 			| orion \
+			| picochip \
 			| pdp10 | pdp11 | pj | pjl | pn | power \
 			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
 			| pru \
@@ -1230,7 +1230,8 @@ case $cpu-$vendor in
 			| riscv | riscv32 | riscv64 \
 			| rl78 | romp | rs6000 | rx \
 			| score \
-			| sh | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
+			| sh | shl \
+			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
 			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
 			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
 			| sparclite \
@@ -1240,10 +1241,11 @@ case $cpu-$vendor in
 			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
 			| tron \
 			| ubicom32 \
-			| v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
+			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
 			| vax \
 			| visium \
-			| wasm32 \
+			| w65 \
+			| wasm32 | wasm64 \
 			| we32k \
 			| x86 | x86_64 | xc16x | xgate | xps100 \
 			| xstormy16 | xtensa* \
@@ -1345,7 +1347,7 @@ case $os in
 	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
 	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
 	     | knetbsd* | mirbsd* | netbsd* \
-	     | bitrig* | openbsd* | solidbsd* | libertybsd* \
+	     | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
 	     | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
 	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
 	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
@@ -1363,7 +1365,8 @@ case $os in
 	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
 	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
 	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
-	     | midnightbsd* | amdhsa* | unleashed* | emscripten*)
+	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
+	     | nsk* | powerunix)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	qnx*)
@@ -1447,9 +1450,6 @@ case $os in
 	ns2)
 		os=nextstep2
 		;;
-	nsk*)
-		os=nsk
-		;;
 	# Preserve the version number of sinix5.
 	sinix5.*)
 		os=`echo $os | sed -e 's|sinix|sysv|'`
-- 
2.11.0

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

* [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (6 preceding siblings ...)
  2019-08-29 15:20 ` [PATCH V6 01/11] Update config.sub and config.guess Jose E. Marchesi
@ 2019-08-29 15:21 ` Jose E. Marchesi
  2019-09-11 19:04   ` Mike Stump
  2019-08-29 15:21 ` [PATCH V6 06/11] bpf: new libgcc port Jose E. Marchesi
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:21 UTC (permalink / raw)
  To: gcc-patches

This patch makes many tests in gcc.dg and gcc.c-torture to be skipped
in bpf-*-* targets.  This is due to the many limitations imposed by
eBPF to what would be perfectly valid C code: no support for more than
5 arguments to function calls, no support for indirect jumps, a very
limited range for direct jumps, etc.

Hopefully some of these restrictions will be relaxed in the future.
Also, as semantics associated with object linking get developed in
eBPF, it may be possible at some point to provide a set of standard
run-time libraries for eBPF programs.

gcc/testsuite/ChangeLog:

	* gcc.dg/builtins-config.h: eBPF doesn't support C99 standard
	functions.
	* gcc.c-torture/compile/20101217-1.c: Add a function prototype for
	printf.
	* gcc.c-torture/compile/20000211-1.c: Skip if target bpf-*-*.
	* gcc.c-torture/compile/poor.c: Likewise.
	* gcc.c-torture/compile/pr25311.c: Likewise.
	* gcc.c-torture/compile/pr39928-1.c: Likewise.
	* gcc.c-torture/compile/pr70061.c: Likewise.
	* gcc.c-torture/compile/920501-7.c: Likewise.
	* gcc.c-torture/compile/20000403-1.c: Likewise.
	* gcc.c-torture/compile/20001226-1.c: Likewise.
	* gcc.c-torture/compile/20030903-1.c: Likewise.
	* gcc.c-torture/compile/20031125-1.c: Likewise.
	* gcc.c-torture/compile/20040101-1.c: Likewise.
	* gcc.c-torture/compile/20040317-2.c: Likewise.
	* gcc.c-torture/compile/20040726-1.c: Likewise.
	* gcc.c-torture/compile/20051216-1.c: Likewise.
	* gcc.c-torture/compile/900313-1.c: Likewise.
	* gcc.c-torture/compile/920625-1.c: Likewise.
	* gcc.c-torture/compile/930421-1.c: Likewise.
	* gcc.c-torture/compile/930623-1.c: Likewise.
	* gcc.c-torture/compile/961004-1.c: Likewise.
	* gcc.c-torture/compile/980504-1.c: Likewise.
	* gcc.c-torture/compile/980816-1.c: Likewise.
	* gcc.c-torture/compile/990625-1.c: Likewise.
	* gcc.c-torture/compile/DFcmp.c: Likewise.
	* gcc.c-torture/compile/HIcmp.c: Likewise.
	* gcc.c-torture/compile/HIset.c: Likewise.
	* gcc.c-torture/compile/QIcmp.c: Likewise.
	* gcc.c-torture/compile/QIset.c: Likewise.
	* gcc.c-torture/compile/SFset.c: Likewise.
	* gcc.c-torture/compile/SIcmp.c: Likewise.
	* gcc.c-torture/compile/SIset.c: Likewise.
	* gcc.c-torture/compile/UHIcmp.c: Likewise.
	* gcc.c-torture/compile/UQIcmp.c: Likewise.
	* gcc.c-torture/compile/USIcmp.c: Likewise.
	* gcc.c-torture/compile/consec.c: Likewise.
	* gcc.c-torture/compile/limits-fndefn.c: Likewise.
	* gcc.c-torture/compile/lll.c: Likewise.
	* gcc.c-torture/compile/parms.c: Likewise.
	* gcc.c-torture/compile/pass.c: Likewise.
	* gcc.c-torture/compile/pp.c: Likewise.
	* gcc.c-torture/compile/pr32399.c: Likewise.
	* gcc.c-torture/compile/pr34091.c: Likewise.
	* gcc.c-torture/compile/pr34688.c: Likewise.
	* gcc.c-torture/compile/pr37258.c: Likewise.
	* gcc.c-torture/compile/pr37327.c: Likewise.
	* gcc.c-torture/compile/pr37381.c: Likewise.
	* gcc.c-torture/compile/pr37669-2.c: Likewise.
	* gcc.c-torture/compile/pr37669.c: Likewise.
	* gcc.c-torture/compile/pr37742-3.c: Likewise.
	* gcc.c-torture/compile/pr44063.c: Likewise.
	* gcc.c-torture/compile/pr48596.c: Likewise.
	* gcc.c-torture/compile/pr51856.c: Likewise.
	* gcc.c-torture/compile/pr54428.c: Likewise.
	* gcc.c-torture/compile/pr54713-1.c: Likewise.
	* gcc.c-torture/compile/pr54713-2.c: Likewise.
	* gcc.c-torture/compile/pr54713-3.c: Likewise.
	* gcc.c-torture/compile/pr55921.c: Likewise.
	* gcc.c-torture/compile/pr70240.c: Likewise.
	* gcc.c-torture/compile/pr70355.c: Likewise.
	* gcc.c-torture/compile/pr82052.c: Likewise.
	* gcc.c-torture/compile/pr83487.c: Likewise.
	* gcc.c-torture/compile/pr86122.c: Likewise.
	* gcc.c-torture/compile/pret-arg.c: Likewise.
	* gcc.c-torture/compile/regs-arg-size.c: Likewise.
	* gcc.c-torture/compile/structret.c: Likewise.
	* gcc.c-torture/compile/uuarg.c: Likewise.
	* gcc.dg/20001009-1.c: Likewise.
	* gcc.dg/20020418-1.c: Likewise.
	* gcc.dg/20020426-2.c: Likewise.
	* gcc.dg/20020430-1.c: Likewise.
	* gcc.dg/20040306-1.c: Likewise.
	* gcc.dg/20040622-2.c: Likewise.
	* gcc.dg/20050603-2.c: Likewise.
	* gcc.dg/20050629-1.c: Likewise.
	* gcc.dg/20061026.c: Likewise.
	* gcc.dg/Warray-bounds-3.c: Likewise.
	* gcc.dg/Warray-bounds-30.c: Likewise.
	* gcc.dg/Wframe-larger-than-2.c: Likewise.
	* gcc.dg/Wframe-larger-than.c: Likewise.
	* gcc.dg/Wrestrict-11.c: Likewise.
	* gcc.c-torture/compile/20000804-1.c: Likewise.
---
 gcc/testsuite/ChangeLog                            | 87 ++++++++++++++++++++++
 gcc/testsuite/gcc.c-torture/compile/20000211-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20000403-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20000804-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/20001226-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/20030903-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20031125-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20040101-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/20040317-2.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20040726-1.c   |  2 +
 gcc/testsuite/gcc.c-torture/compile/20051216-1.c   |  1 +
 gcc/testsuite/gcc.c-torture/compile/20101217-1.c   |  4 +-
 gcc/testsuite/gcc.c-torture/compile/900313-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/920501-7.c     |  1 +
 gcc/testsuite/gcc.c-torture/compile/920625-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/930421-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/930623-1.c     |  1 +
 gcc/testsuite/gcc.c-torture/compile/961004-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/980504-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/980816-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/990625-1.c     |  2 +
 gcc/testsuite/gcc.c-torture/compile/DFcmp.c        |  2 +
 gcc/testsuite/gcc.c-torture/compile/HIcmp.c        |  2 +
 gcc/testsuite/gcc.c-torture/compile/HIset.c        |  2 +
 gcc/testsuite/gcc.c-torture/compile/QIcmp.c        |  2 +
 gcc/testsuite/gcc.c-torture/compile/QIset.c        |  2 +
 gcc/testsuite/gcc.c-torture/compile/SFset.c        |  1 +
 gcc/testsuite/gcc.c-torture/compile/SIcmp.c        |  2 +
 gcc/testsuite/gcc.c-torture/compile/SIset.c        |  2 +
 gcc/testsuite/gcc.c-torture/compile/UHIcmp.c       |  2 +
 gcc/testsuite/gcc.c-torture/compile/UQIcmp.c       |  2 +
 gcc/testsuite/gcc.c-torture/compile/USIcmp.c       |  2 +
 gcc/testsuite/gcc.c-torture/compile/consec.c       |  2 +
 .../gcc.c-torture/compile/limits-fndefn.c          |  1 +
 gcc/testsuite/gcc.c-torture/compile/lll.c          |  1 +
 gcc/testsuite/gcc.c-torture/compile/parms.c        |  1 +
 gcc/testsuite/gcc.c-torture/compile/pass.c         |  2 +
 gcc/testsuite/gcc.c-torture/compile/poor.c         |  2 +
 gcc/testsuite/gcc.c-torture/compile/pp.c           |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr25311.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr32399.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr34091.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr34688.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr37258.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr37327.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr37381.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr37669-2.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr37669.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr37742-3.c    |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr39928-1.c    |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr44063.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr48596.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr51856.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr54428.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr54713-1.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr54713-2.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr54713-3.c    |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr55921.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr70061.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr70240.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr70355.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr82052.c      |  2 +
 gcc/testsuite/gcc.c-torture/compile/pr83487.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/pr86122.c      |  1 +
 gcc/testsuite/gcc.c-torture/compile/pret-arg.c     |  2 +
 .../gcc.c-torture/compile/regs-arg-size.c          |  2 +
 gcc/testsuite/gcc.c-torture/compile/structret.c    |  2 +
 gcc/testsuite/gcc.c-torture/compile/uuarg.c        |  2 +
 gcc/testsuite/gcc.dg/20001009-1.c                  |  1 +
 gcc/testsuite/gcc.dg/20020418-1.c                  |  1 +
 gcc/testsuite/gcc.dg/20020426-2.c                  |  1 +
 gcc/testsuite/gcc.dg/20020430-1.c                  |  1 +
 gcc/testsuite/gcc.dg/20040306-1.c                  |  2 +-
 gcc/testsuite/gcc.dg/20040622-2.c                  |  1 +
 gcc/testsuite/gcc.dg/20050603-2.c                  |  1 +
 gcc/testsuite/gcc.dg/20050629-1.c                  |  1 +
 gcc/testsuite/gcc.dg/20061026.c                    |  1 +
 gcc/testsuite/gcc.dg/Warray-bounds-3.c             |  1 +
 gcc/testsuite/gcc.dg/Warray-bounds-30.c            |  3 +-
 gcc/testsuite/gcc.dg/Wframe-larger-than-2.c        |  3 +-
 gcc/testsuite/gcc.dg/Wframe-larger-than.c          |  1 +
 gcc/testsuite/gcc.dg/Wrestrict-11.c                |  3 +-
 gcc/testsuite/gcc.dg/builtins-config.h             |  4 +-
 83 files changed, 222 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.c-torture/compile/20000211-1.c b/gcc/testsuite/gcc.c-torture/compile/20000211-1.c
index 7a7c8c0cb20..b83d6a40520 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20000211-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20000211-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef __SIZE_TYPE__ size_t;
 typedef unsigned char Bufbyte;
 typedef int Bytecount;
diff --git a/gcc/testsuite/gcc.c-torture/compile/20000403-1.c b/gcc/testsuite/gcc.c-torture/compile/20000403-1.c
index 27345b56fef..cb56028fb8b 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20000403-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20000403-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 struct utsname {
 	char	sysname[32 ];	 
 	char	version[32 ];	 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20000804-1.c b/gcc/testsuite/gcc.c-torture/compile/20000804-1.c
index 550669b53a3..95bb0fafd70 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20000804-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20000804-1.c
@@ -5,6 +5,7 @@
 /* { dg-skip-if "No 64-bit registers" { m32c-*-* } } */
 /* { dg-skip-if "Not enough 64-bit registers" { pdp11-*-* } { "-O0" } { "" } } */
 /* { dg-xfail-if "Inconsistent constraint on asm" { csky-*-* } { "-O0" } { "" } } */
+/* { dg-xfail-if "Inconsistent constraint on asm" { bpf-*-* } { "-O0" } { "" } } */
 /* { dg-xfail-if "" { h8300-*-* } } */
 /* { dg-require-stack-size "99*4+16" } */
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20001226-1.c b/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
index be0bdcf7631..9f6bd0af2e5 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
@@ -3,6 +3,7 @@
 /* { dg-skip-if "too much code for pdp11" { "pdp11-*-*" } } */
 /* { dg-xfail-if "PR36698" { spu-*-* } { "-O0" } { "" } } */
 /* { dg-skip-if "" { m32c-*-* } } */
+/* { dg-skip-if "jumps too far for eBPF" { bpf-*-* } } */
 /* { dg-timeout-factor 4.0 } */
 
 /* This testcase exposed two branch shortening bugs on powerpc.  */
diff --git a/gcc/testsuite/gcc.c-torture/compile/20030903-1.c b/gcc/testsuite/gcc.c-torture/compile/20030903-1.c
index fa4d30db6c0..116b0923721 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20030903-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20030903-1.c
@@ -1,6 +1,8 @@
 /* Derived from PR optimization/11700.  */
 /* The compiler used to ICE during reload for m68k targets.  */
 
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
+
 void check_complex (__complex__ double, __complex__ double,
                     __complex__ double, __complex__ int);
 void check_float (double, double, double, int);
diff --git a/gcc/testsuite/gcc.c-torture/compile/20031125-1.c b/gcc/testsuite/gcc.c-torture/compile/20031125-1.c
index d3e92679c8b..bec6c9372a8 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20031125-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20031125-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 short *_offsetTable;
 /* This tests to make sure PRE splits the entry block ->block 0 edge
    when there are multiple block 0 predecessors.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040101-1.c b/gcc/testsuite/gcc.c-torture/compile/20040101-1.c
index 5c2688ad830..6027cb53fb4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20040101-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20040101-1.c
@@ -1,4 +1,5 @@
 /* { dg-skip-if "not enough registers" { pdp11-*-* } } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 typedef unsigned short uint16_t;
 typedef unsigned int uint32_t;
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040317-2.c b/gcc/testsuite/gcc.c-torture/compile/20040317-2.c
index 3c8ee2b8ec5..3a1fbde2969 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20040317-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20040317-2.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef struct _ScaleRec *ScaleWidget;
 typedef struct
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040726-1.c b/gcc/testsuite/gcc.c-torture/compile/20040726-1.c
index e53ccd655bb..aea43a56f34 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20040726-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20040726-1.c
@@ -1,4 +1,6 @@
 /* PR rtl-optimization/16643 */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 void foo (int a, int b, int c, int d, int e, int *f)
 {
   if (a == 0)
diff --git a/gcc/testsuite/gcc.c-torture/compile/20051216-1.c b/gcc/testsuite/gcc.c-torture/compile/20051216-1.c
index ed6ac723069..55751ec8ab2 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20051216-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20051216-1.c
@@ -1,4 +1,5 @@
 /* PR rtl-optimization/25432 */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 void *malloc (__SIZE_TYPE__);
 void *realloc (void *, __SIZE_TYPE__);
diff --git a/gcc/testsuite/gcc.c-torture/compile/20101217-1.c b/gcc/testsuite/gcc.c-torture/compile/20101217-1.c
index c4eef0ed464..46bdcf5e347 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20101217-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20101217-1.c
@@ -1,5 +1,7 @@
 /* Testcase provided by HUAWEI.  */
-#include <stdio.h>
+
+extern int printf (const char * __format, ...);
+
 int main()
 {
         int cur_k;
diff --git a/gcc/testsuite/gcc.c-torture/compile/900313-1.c b/gcc/testsuite/gcc.c-torture/compile/900313-1.c
index 2bac5814a7b..12252b4b229 100644
--- a/gcc/testsuite/gcc.c-torture/compile/900313-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/900313-1.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target alloca } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 main ()
 {
   char *a;
diff --git a/gcc/testsuite/gcc.c-torture/compile/920501-7.c b/gcc/testsuite/gcc.c-torture/compile/920501-7.c
index 2af15e3b7ec..0fac5f3495f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920501-7.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920501-7.c
@@ -1,3 +1,4 @@
 /* { dg-require-effective-target label_values } */
+/* { dg-skip-if "no support for indirect jumps" { bpf-*-* } } */
 
 x(){if(&&e-&&b<0)x();b:goto*&&b;e:;}
diff --git a/gcc/testsuite/gcc.c-torture/compile/920625-1.c b/gcc/testsuite/gcc.c-torture/compile/920625-1.c
index 720d43fd42f..759a356b5b7 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920625-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920625-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef unsigned long int unsigned_word;
 typedef signed long int signed_word;
 typedef unsigned_word word;
diff --git a/gcc/testsuite/gcc.c-torture/compile/930421-1.c b/gcc/testsuite/gcc.c-torture/compile/930421-1.c
index 01b465f7fec..9e16fe17dd9 100644
--- a/gcc/testsuite/gcc.c-torture/compile/930421-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/930421-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 double q(double);
 
 f (int **x, int *r, int *s, int a, int b, int c, int d)
diff --git a/gcc/testsuite/gcc.c-torture/compile/930623-1.c b/gcc/testsuite/gcc.c-torture/compile/930623-1.c
index 022ad01804e..dd45bbccc38 100644
--- a/gcc/testsuite/gcc.c-torture/compile/930623-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/930623-1.c
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-skip-if "no __builtin_apply in eBPF" { bpf-*-* } } */
 
 g (a, b) {}
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/961004-1.c b/gcc/testsuite/gcc.c-torture/compile/961004-1.c
index 6407b625d66..cf47f60d5ea 100644
--- a/gcc/testsuite/gcc.c-torture/compile/961004-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/961004-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 void
 f1 (o1, o2, o3, i, j, k)
      long long *o1, *o2, *o3;
diff --git a/gcc/testsuite/gcc.c-torture/compile/980504-1.c b/gcc/testsuite/gcc.c-torture/compile/980504-1.c
index 7b757ccd2e8..6e043a7af19 100644
--- a/gcc/testsuite/gcc.c-torture/compile/980504-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/980504-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef struct _geom_elem {
   double        coeffs[6];
 } pGeomDefRec, *pGeomDefPtr;
diff --git a/gcc/testsuite/gcc.c-torture/compile/980816-1.c b/gcc/testsuite/gcc.c-torture/compile/980816-1.c
index a79100fab57..5bd83b17063 100644
--- a/gcc/testsuite/gcc.c-torture/compile/980816-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/980816-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef __SIZE_TYPE__ size_t;
 typedef void *XtPointer;
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/990625-1.c b/gcc/testsuite/gcc.c-torture/compile/990625-1.c
index 97a2331c7a5..befff06579e 100644
--- a/gcc/testsuite/gcc.c-torture/compile/990625-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/990625-1.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "no string.h in eBPF" { bpf-*-* } } */
+
 #define __USE_STRING_INLINES
 #include <string.h>
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/DFcmp.c b/gcc/testsuite/gcc.c-torture/compile/DFcmp.c
index 3bb253476d7..808874de1a8 100644
--- a/gcc/testsuite/gcc.c-torture/compile/DFcmp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/DFcmp.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target int32plus } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define type double
 
 type glob0, glob1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/HIcmp.c b/gcc/testsuite/gcc.c-torture/compile/HIcmp.c
index 77b47886ed1..6e68271a009 100644
--- a/gcc/testsuite/gcc.c-torture/compile/HIcmp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/HIcmp.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define type short
 
 type glob0, glob1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/HIset.c b/gcc/testsuite/gcc.c-torture/compile/HIset.c
index 163cb7cbe32..a0d426c2c07 100644
--- a/gcc/testsuite/gcc.c-torture/compile/HIset.c
+++ b/gcc/testsuite/gcc.c-torture/compile/HIset.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define E0 ((type *)10000000)
 #define reg0 r0
 #define indreg0 (*p0)
diff --git a/gcc/testsuite/gcc.c-torture/compile/QIcmp.c b/gcc/testsuite/gcc.c-torture/compile/QIcmp.c
index c5161646f2c..a4dba2487e4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/QIcmp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/QIcmp.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define type signed char
 
 type glob0, glob1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/QIset.c b/gcc/testsuite/gcc.c-torture/compile/QIset.c
index 212609dc864..e2fde2bda7e 100644
--- a/gcc/testsuite/gcc.c-torture/compile/QIset.c
+++ b/gcc/testsuite/gcc.c-torture/compile/QIset.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define E0 ((type *)10000000)
 #define reg0 r0
 #define indreg0 (*p0)
diff --git a/gcc/testsuite/gcc.c-torture/compile/SFset.c b/gcc/testsuite/gcc.c-torture/compile/SFset.c
index dc7f48dd2dd..a7efecf9717 100644
--- a/gcc/testsuite/gcc.c-torture/compile/SFset.c
+++ b/gcc/testsuite/gcc.c-torture/compile/SFset.c
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target int32plus } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 #define E0 ((type *)10000000)
 #define reg0 r0
diff --git a/gcc/testsuite/gcc.c-torture/compile/SIcmp.c b/gcc/testsuite/gcc.c-torture/compile/SIcmp.c
index 4a9e0d57fd7..ce1281b6093 100644
--- a/gcc/testsuite/gcc.c-torture/compile/SIcmp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/SIcmp.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define type int
 
 type glob0, glob1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/SIset.c b/gcc/testsuite/gcc.c-torture/compile/SIset.c
index 5fb93579f4b..b200a264b95 100644
--- a/gcc/testsuite/gcc.c-torture/compile/SIset.c
+++ b/gcc/testsuite/gcc.c-torture/compile/SIset.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define E0 ((type *)10000000)
 #define reg0 r0
 #define indreg0 (*p0)
diff --git a/gcc/testsuite/gcc.c-torture/compile/UHIcmp.c b/gcc/testsuite/gcc.c-torture/compile/UHIcmp.c
index 529e3a33fd3..b0029d23ea4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/UHIcmp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/UHIcmp.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define type unsigned short
 
 type glob0, glob1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/UQIcmp.c b/gcc/testsuite/gcc.c-torture/compile/UQIcmp.c
index 3e9cdebc903..e28d13b03ab 100644
--- a/gcc/testsuite/gcc.c-torture/compile/UQIcmp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/UQIcmp.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define type unsigned char
 
 type glob0, glob1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/USIcmp.c b/gcc/testsuite/gcc.c-torture/compile/USIcmp.c
index 69788a45b2e..27e5503bd4d 100644
--- a/gcc/testsuite/gcc.c-torture/compile/USIcmp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/USIcmp.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 #define type unsigned int
 
 type glob0, glob1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/consec.c b/gcc/testsuite/gcc.c-torture/compile/consec.c
index 01fa25b009b..b8c376d7076 100644
--- a/gcc/testsuite/gcc.c-torture/compile/consec.c
+++ b/gcc/testsuite/gcc.c-torture/compile/consec.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 int glob;
 
 conseq (a, b, c, d)
diff --git a/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c b/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c
index 0bd8f6af995..53204735493 100644
--- a/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c
+++ b/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c
@@ -1,5 +1,6 @@
 /* { dg-skip-if "too complex for avr" { avr-*-* } } */
 /* { dg-skip-if "ptxas times out" { nvptx-*-* } } */
+/* { dg-skip-if "no chance for bpf" { bpf-*-* } } */
 /* { dg-timeout-factor 4.0 } */
 #define LIM1(x) x##0, x##1, x##2, x##3, x##4, x##5, x##6, x##7, x##8, x##9,
 #define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \
diff --git a/gcc/testsuite/gcc.c-torture/compile/lll.c b/gcc/testsuite/gcc.c-torture/compile/lll.c
index dee9dc37d15..ea09c871c6b 100644
--- a/gcc/testsuite/gcc.c-torture/compile/lll.c
+++ b/gcc/testsuite/gcc.c-torture/compile/lll.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 byte_match_count2 (buf, n, xm, m1, m2, m3, m4)
      unsigned *buf;
diff --git a/gcc/testsuite/gcc.c-torture/compile/parms.c b/gcc/testsuite/gcc.c-torture/compile/parms.c
index 8205a9c1454..1bfc93d2abb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/parms.c
+++ b/gcc/testsuite/gcc.c-torture/compile/parms.c
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target alloca } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 #define alloca __builtin_alloca
 
 x (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, x, y)
diff --git a/gcc/testsuite/gcc.c-torture/compile/pass.c b/gcc/testsuite/gcc.c-torture/compile/pass.c
index 4e028393feb..529a01dac85 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pass.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pass.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 int
 foo (a, b, c)
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/poor.c b/gcc/testsuite/gcc.c-torture/compile/poor.c
index 66d584aff43..20287ef2354 100644
--- a/gcc/testsuite/gcc.c-torture/compile/poor.c
+++ b/gcc/testsuite/gcc.c-torture/compile/poor.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
+
 typedef struct
 {
 	char	c[510];
diff --git a/gcc/testsuite/gcc.c-torture/compile/pp.c b/gcc/testsuite/gcc.c-torture/compile/pp.c
index 7d38d53de0f..c1e09eab407 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pp.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pp.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 foo (a, b, c, d, e, i0, f, i1)
      double a, b, c, d, e, f;
      int i0, i1;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr25311.c b/gcc/testsuite/gcc.c-torture/compile/pr25311.c
index 26c5bc37b83..43ef3fd9523 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr25311.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr25311.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 struct w
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr32399.c b/gcc/testsuite/gcc.c-torture/compile/pr32399.c
index cc2b1b18984..b29dbd7986a 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr32399.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr32399.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 void f(unsigned char *src, unsigned char *dst, int num, unsigned char *pos, unsigned char *diffuse, int hasdiffuse, unsigned char *specular, int hasspecular) {
     int i;
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34091.c b/gcc/testsuite/gcc.c-torture/compile/pr34091.c
index 0b8549132e6..a623a383fd0 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr34091.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr34091.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef unsigned int GLenum;
 typedef unsigned char GLboolean;
 typedef int GLint;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34688.c b/gcc/testsuite/gcc.c-torture/compile/pr34688.c
index 60e0f3c9f15..ec890cb8f15 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr34688.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr34688.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef __SIZE_TYPE__ size_t;
          typedef struct {
         }
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37258.c b/gcc/testsuite/gcc.c-torture/compile/pr37258.c
index 286f2fc4427..41801781e3a 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37258.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37258.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef signed char int8_t;
 typedef short int int16_t;
 typedef int int32_t;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37327.c b/gcc/testsuite/gcc.c-torture/compile/pr37327.c
index 79946b7522d..5ca9d1d45b6 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37327.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37327.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef signed char int8_t;
 typedef short int int16_t;
 typedef int int32_t;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37381.c b/gcc/testsuite/gcc.c-torture/compile/pr37381.c
index a2fed66c4ee..d8cd47d329d 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37381.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37381.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 extern unsigned int __invalid_size_argument_for_IOC;
 typedef unsigned int __u32;
 struct video_window
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37669-2.c b/gcc/testsuite/gcc.c-torture/compile/pr37669-2.c
index abeae7a2f32..2170dda67f0 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37669-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37669-2.c
@@ -1,4 +1,5 @@
 /* PR middle-end/37669 */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 #define FMT10 "%d%d%d%d%d%d%d%d%d%d"
 #define FMT100 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37669.c b/gcc/testsuite/gcc.c-torture/compile/pr37669.c
index a2eafc75cb3..36e4c39d8ed 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37669.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37669.c
@@ -1,6 +1,7 @@
 /* This testcase used to fail because a miscompiled execute_fold_all_builtins. */
 /* { dg-options "-fgnu89-inline" } */
 /* { dg-require-effective-target int32plus } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 typedef __SIZE_TYPE__ size_t;
 extern __inline __attribute__ ((__always_inline__)) int __attribute__
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37742-3.c b/gcc/testsuite/gcc.c-torture/compile/pr37742-3.c
index 541bd42ad5d..9e7b10fb7a3 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37742-3.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37742-3.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 void matmul_i4 (int * __restrict dest_y,
 		const int * __restrict abase,
 		const int * __restrict bbase_y,
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c b/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c
index 1abb5ccb505..ae6a63b24b8 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c
@@ -1,4 +1,6 @@
 /* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
 extern __m128 _mm_sub_ps (__m128 __A, __m128 __B);
 extern __m128 _mm_mul_ps (__m128 __A, __m128 __B);
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44063.c b/gcc/testsuite/gcc.c-torture/compile/pr44063.c
index 596e1dc991f..32208f610f9 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr44063.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr44063.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
+
 typedef signed char int8_t;
 typedef short int16_t;
 typedef unsigned char uint8_t;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr48596.c b/gcc/testsuite/gcc.c-torture/compile/pr48596.c
index 382a152413e..743bd82e868 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr48596.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr48596.c
@@ -1,4 +1,6 @@
 /* PR target/48596  */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 enum { nrrdCenterUnknown, nrrdCenterNode, nrrdCenterCell, nrrdCenterLast };
 typedef struct { int size; int center; }  NrrdAxis;
 typedef struct { int dim; NrrdAxis axis[10]; } Nrrd;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr51856.c b/gcc/testsuite/gcc.c-torture/compile/pr51856.c
index 6644c7fdc14..823a0bed073 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr51856.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr51856.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 struct B { int b1; long long b2, b3; int b4; };
 struct C { char c1[40], c2, c3[96]; long long c4[5], c5; char c6[596]; };
 void fn1 (long long), fn2 (char *, int), fn4 (void);
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54428.c b/gcc/testsuite/gcc.c-torture/compile/pr54428.c
index 84a5dbd82bd..d783337cfdb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr54428.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr54428.c
@@ -1,4 +1,5 @@
 /* PR c/54428 */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 typedef double _Complex C;
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54713-1.c b/gcc/testsuite/gcc.c-torture/compile/pr54713-1.c
index f042ea2fc6c..0d4172a576b 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr54713-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr54713-1.c
@@ -1,4 +1,5 @@
 /* PR tree-optimization/54713 */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 #ifndef N
 #define N 8
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c b/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c
index c3910373111..f7d2364e197 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c
@@ -1,4 +1,5 @@
 /* PR tree-optimization/54713 */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 #define N 16
 #define ONE 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c b/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c
index 6164a5eec0e..76a35b067c5 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c
@@ -1,4 +1,5 @@
 /* PR tree-optimization/54713 */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 #define N 32
 #define ONE 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr55921.c b/gcc/testsuite/gcc.c-torture/compile/pr55921.c
index de0635d66ad..cf9084e33f0 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr55921.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr55921.c
@@ -1,5 +1,6 @@
 /* PR tree-optimization/55921 */
 /* { dg-skip-if "Not enough registers" { "pdp11-*-*" } } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 typedef union
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr70061.c b/gcc/testsuite/gcc.c-torture/compile/pr70061.c
index a7ebcfc99f8..aabfddad43f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr70061.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr70061.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef int v8si __attribute__ ((vector_size (32)));
 
 int
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr70240.c b/gcc/testsuite/gcc.c-torture/compile/pr70240.c
index 830d4ddcc93..466d3a7c961 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr70240.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr70240.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 typedef short v16hi __attribute__ ((vector_size (32)));
 typedef int v8si __attribute__ ((vector_size (32)));
 typedef long long v4di __attribute__ ((vector_size (32)));
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr70355.c b/gcc/testsuite/gcc.c-torture/compile/pr70355.c
index 474942715f8..f7114208005 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr70355.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr70355.c
@@ -1,5 +1,7 @@
 /* { dg-require-effective-target int128 } */
 /* { dg-additional-options "-g" } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
+
 
 typedef unsigned __int128 v2ti __attribute__ ((vector_size (32)));
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr82052.c b/gcc/testsuite/gcc.c-torture/compile/pr82052.c
index 3763161e350..09fac5edb1e 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr82052.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr82052.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
+
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
 typedef unsigned uint32_t;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr83487.c b/gcc/testsuite/gcc.c-torture/compile/pr83487.c
index 9effb1eef03..9de0e17939f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr83487.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr83487.c
@@ -1,4 +1,5 @@
 /* PR middle-end/83487 */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 struct __attribute__ ((aligned)) A {};
 struct A a;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr86122.c b/gcc/testsuite/gcc.c-torture/compile/pr86122.c
index 0a4fd144ae6..1bd46733183 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr86122.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr86122.c
@@ -1,4 +1,5 @@
 /* PR middle-end/86122 */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 _Complex int
 foo (_Complex int x)
diff --git a/gcc/testsuite/gcc.c-torture/compile/pret-arg.c b/gcc/testsuite/gcc.c-torture/compile/pret-arg.c
index a7fa8562830..d86d135dc4b 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pret-arg.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pret-arg.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 foo (a, b, c, d, e, f, g, h, i, j, xx)
      double xx;
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
index f5f01116eda..77518866d3f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
+++ b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
+
 int foo;
 typedef long unsigned int size_t;
 typedef short unsigned int wchar_t;
diff --git a/gcc/testsuite/gcc.c-torture/compile/structret.c b/gcc/testsuite/gcc.c-torture/compile/structret.c
index 9c705d4c0a2..d99eaa630bb 100644
--- a/gcc/testsuite/gcc.c-torture/compile/structret.c
+++ b/gcc/testsuite/gcc.c-torture/compile/structret.c
@@ -1,3 +1,5 @@
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 struct foo
 {
   int a, b, c, d;
diff --git a/gcc/testsuite/gcc.c-torture/compile/uuarg.c b/gcc/testsuite/gcc.c-torture/compile/uuarg.c
index 930dd8ab5f6..875c7c3b50f 100644
--- a/gcc/testsuite/gcc.c-torture/compile/uuarg.c
+++ b/gcc/testsuite/gcc.c-torture/compile/uuarg.c
@@ -1,4 +1,6 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
+
 foo (a, b, c, d, e, f, g, h, i)
 {
   return foo () + i;
diff --git a/gcc/testsuite/gcc.dg/20001009-1.c b/gcc/testsuite/gcc.dg/20001009-1.c
index 1a5567779b5..580e4b4d307 100644
--- a/gcc/testsuite/gcc.dg/20001009-1.c
+++ b/gcc/testsuite/gcc.dg/20001009-1.c
@@ -1,5 +1,6 @@
 /* { dg-do compile { target fpic } } */
 /* { dg-options "-O2 -fpic" } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 extern void foo (void *a, double x, double y);
 void
diff --git a/gcc/testsuite/gcc.dg/20020418-1.c b/gcc/testsuite/gcc.dg/20020418-1.c
index 7314ec000ef..456967fdd36 100644
--- a/gcc/testsuite/gcc.dg/20020418-1.c
+++ b/gcc/testsuite/gcc.dg/20020418-1.c
@@ -2,6 +2,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
 /* { dg-options "-O2 -msse -ffast-math" { target i?86-*-* x86_64-*-* } } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 void bar (float *a, float *b);
 
diff --git a/gcc/testsuite/gcc.dg/20020426-2.c b/gcc/testsuite/gcc.dg/20020426-2.c
index 9ad7a54f601..96517f7b840 100644
--- a/gcc/testsuite/gcc.dg/20020426-2.c
+++ b/gcc/testsuite/gcc.dg/20020426-2.c
@@ -3,6 +3,7 @@
 /* { dg-do run } */
 /* { dg-options "-O2" } */
 /* { dg-options "-O2 -frename-registers -fomit-frame-pointer -fPIC -mtune=i686" { target { { i?86-*-* x86_64-*-* } && { ia32 && fpic } } } } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 extern void exit (int);
 
diff --git a/gcc/testsuite/gcc.dg/20020430-1.c b/gcc/testsuite/gcc.dg/20020430-1.c
index 63915a24b17..f48bb672aaf 100644
--- a/gcc/testsuite/gcc.dg/20020430-1.c
+++ b/gcc/testsuite/gcc.dg/20020430-1.c
@@ -6,6 +6,7 @@
 
 /* { dg-do compile { target fpic } } */
 /* { dg-options "-O2 -frename-registers -fpic" } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 typedef unsigned long XID;
 typedef XID Window;
diff --git a/gcc/testsuite/gcc.dg/20040306-1.c b/gcc/testsuite/gcc.dg/20040306-1.c
index 903d20ac256..8cac8697d99 100644
--- a/gcc/testsuite/gcc.dg/20040306-1.c
+++ b/gcc/testsuite/gcc.dg/20040306-1.c
@@ -2,7 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
-
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 typedef struct test
 {
diff --git a/gcc/testsuite/gcc.dg/20040622-2.c b/gcc/testsuite/gcc.dg/20040622-2.c
index 0be320fa4e2..e62ec36d43a 100644
--- a/gcc/testsuite/gcc.dg/20040622-2.c
+++ b/gcc/testsuite/gcc.dg/20040622-2.c
@@ -1,5 +1,6 @@
 /* { dg-do link } */
 /* { dg-require-effective-target ptr32plus } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 /* This validates codegen for [r1+32760] on Darwin. */
 void f(char x[32688], double *y, double *z) __attribute__((noinline));
 void f(char x[32688], double *y, double *z) {}
diff --git a/gcc/testsuite/gcc.dg/20050603-2.c b/gcc/testsuite/gcc.dg/20050603-2.c
index 8c8e58e1b4d..a135e3ea1a0 100644
--- a/gcc/testsuite/gcc.dg/20050603-2.c
+++ b/gcc/testsuite/gcc.dg/20050603-2.c
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-O2" } */
+/* { dg-skip-if "no stdlib.h in eBPF" { bpf-*-* } } */
 #include <stdlib.h>
 struct s {
   unsigned short f: 16;
diff --git a/gcc/testsuite/gcc.dg/20050629-1.c b/gcc/testsuite/gcc.dg/20050629-1.c
index 0dd47f7024b..99d9ce823b0 100644
--- a/gcc/testsuite/gcc.dg/20050629-1.c
+++ b/gcc/testsuite/gcc.dg/20050629-1.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -w" } */
+/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 /* This file was automatically reduced from tree-ssa-operands.c.  It
    contains many warnings, but it exposes a copy propagation bug that
diff --git a/gcc/testsuite/gcc.dg/20061026.c b/gcc/testsuite/gcc.dg/20061026.c
index 741ea2eb3b8..fa8069ce4cf 100644
--- a/gcc/testsuite/gcc.dg/20061026.c
+++ b/gcc/testsuite/gcc.dg/20061026.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O1" } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 /* This testcase failed on s390.  The frame size for function f will be
    exactly 32768 bytes.  The back end has to recognize that this is to
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-3.c b/gcc/testsuite/gcc.dg/Warray-bounds-3.c
index 773f4633dc7..f119502f025 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-3.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-3.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -Warray-bounds" } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 /* based on PR 31227 */
 
 typedef __SIZE_TYPE__ size_t;
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-30.c b/gcc/testsuite/gcc.dg/Warray-bounds-30.c
index ac7e9a6e8fb..b9965682101 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-30.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-30.c
@@ -1,7 +1,8 @@
 /* PR tree-optimization/84047 - missing -Warray-bounds on an out-of-bounds
    index into an array
    { dg-do compile }
-   { dg-options "-O2 -Warray-bounds=2 -ftrack-macro-expansion=0" } */
+   { dg-options "-O2 -Warray-bounds=2 -ftrack-macro-expansion=0" }
+   { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 #include "range.h"
 
diff --git a/gcc/testsuite/gcc.dg/Wframe-larger-than-2.c b/gcc/testsuite/gcc.dg/Wframe-larger-than-2.c
index 1a5402f8120..d7068d04aef 100644
--- a/gcc/testsuite/gcc.dg/Wframe-larger-than-2.c
+++ b/gcc/testsuite/gcc.dg/Wframe-larger-than-2.c
@@ -1,6 +1,7 @@
 /* Exercise -Wframe-larger-than= with a byte-size suffix.
    { dg-do compile }
-   { dg-options "-O -Wframe-larger-than=1KB" } */
+   { dg-options "-O -Wframe-larger-than=1KB" }
+   { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 extern void f (void*, ...);
 
diff --git a/gcc/testsuite/gcc.dg/Wframe-larger-than.c b/gcc/testsuite/gcc.dg/Wframe-larger-than.c
index fab0adf37ee..8a40cf36df8 100644
--- a/gcc/testsuite/gcc.dg/Wframe-larger-than.c
+++ b/gcc/testsuite/gcc.dg/Wframe-larger-than.c
@@ -4,6 +4,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-Wframe-larger-than=2048" } */
+/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */
 
 extern void func(char *);
 
diff --git a/gcc/testsuite/gcc.dg/Wrestrict-11.c b/gcc/testsuite/gcc.dg/Wrestrict-11.c
index 7b4b5aa2527..07b9cddad4b 100644
--- a/gcc/testsuite/gcc.dg/Wrestrict-11.c
+++ b/gcc/testsuite/gcc.dg/Wrestrict-11.c
@@ -3,7 +3,8 @@
    that calls to strncpy involving multidimensional arrays of structs don't
    trigger false positive -Wrestrict warnings.
    { dg-do compile }
-   { dg-options "-O2 -Wrestrict -ftrack-macro-expansion=0" } */
+   { dg-options "-O2 -Wrestrict -ftrack-macro-expansion=0" }
+   { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
 
 typedef __SIZE_TYPE__ size_t;
 
diff --git a/gcc/testsuite/gcc.dg/builtins-config.h b/gcc/testsuite/gcc.dg/builtins-config.h
index f00e91a750f..5e27c1deb33 100644
--- a/gcc/testsuite/gcc.dg/builtins-config.h
+++ b/gcc/testsuite/gcc.dg/builtins-config.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004, 2005, 2006, 2009, 2011, 2012
+/* Copyright (C) 2003, 2004, 2005, 2006, 2009, 2011, 2012, 2019
    Free Software Foundation.
 
    Define macros useful in tests for bulitin functions.  */
@@ -20,6 +20,8 @@
 /* FreeBSD up to version 8 lacks support for cexp and friends.  */
 #elif defined(__vxworks)
 /* VxWorks doesn't have a full C99 time.  (cabs is missing, for example.)  */
+#elif defined (__BPF__)
+/* No chance for eBPF to support C99 functions.  */
 #elif defined(_WIN32) && !defined(__CYGWIN__)
 /* Windows doesn't have the entire C99 runtime.  */
 #elif (defined(__APPLE__) && defined(__ppc__) \
-- 
2.11.0

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

* [PATCH V6 06/11] bpf: new libgcc port
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (7 preceding siblings ...)
  2019-08-29 15:21 ` [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations Jose E. Marchesi
@ 2019-08-29 15:21 ` Jose E. Marchesi
  2019-08-29 15:34 ` [PATCH V6 02/11] opt-functions.awk: fix comparison of limit, begin and end Jose E. Marchesi
  2019-08-29 15:36 ` [PATCH V6 05/11] bpf: new GCC port Jose E. Marchesi
  10 siblings, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:21 UTC (permalink / raw)
  To: gcc-patches

This patch adds an eBPF port to libgcc.

As of today, compiled eBPF programs do not support a single-entry
point schema.  Instead, a BPF "executable" is a relocatable ELF object
file containing multiple entry points, in certain named sections.

Also, the BPF loaders in the kernel do not execute .ini/.fini
constructors/destructors.  Therefore, this patch provides empty crtn.S
and cri.S files.

libgcc/ChangeLog:

	* config.host: Set cpu_type for bpf-*-* targets.
	* config/bpf/t-bpf: Likewise.
	* config/bpf/crtn.S: Likewise.
	* config/bpf/crti.S: New file.
---
 libgcc/ChangeLog         |  7 +++++++
 libgcc/config.host       |  7 +++++++
 libgcc/config/bpf/crti.S |  0
 libgcc/config/bpf/crtn.S |  0
 libgcc/config/bpf/t-bpf  | 23 +++++++++++++++++++++++
 5 files changed, 37 insertions(+)
 create mode 100644 libgcc/config/bpf/crti.S
 create mode 100644 libgcc/config/bpf/crtn.S
 create mode 100644 libgcc/config/bpf/t-bpf

diff --git a/libgcc/config.host b/libgcc/config.host
index 503ebb6be20..2e9fbc35482 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -107,6 +107,9 @@ avr-*-*)
 bfin*-*)
 	cpu_type=bfin
 	;;
+bpf-*-*)
+        cpu_type=bpf
+        ;;
 cr16-*-*)
 	;;
 crisv32-*-*)
@@ -526,6 +529,10 @@ bfin*-*)
 	tmake_file="$tmake_file bfin/t-bfin t-fdpbit"
 	extra_parts="crtbegin.o crtend.o crti.o crtn.o"
         ;;
+bpf-*-*)
+        tmake_file="$tmake_file ${cpu_type}/t-${cpu_type}"
+        extra_parts="crti.o crtn.o"
+	;;
 cr16-*-elf)
 	tmake_file="${tmake_file} cr16/t-cr16 cr16/t-crtlibid t-fdpbit"
 	extra_parts="$extra_parts crti.o crtn.o crtlibid.o"
diff --git a/libgcc/config/bpf/crti.S b/libgcc/config/bpf/crti.S
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/libgcc/config/bpf/crtn.S b/libgcc/config/bpf/crtn.S
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/libgcc/config/bpf/t-bpf b/libgcc/config/bpf/t-bpf
new file mode 100644
index 00000000000..88129a78f61
--- /dev/null
+++ b/libgcc/config/bpf/t-bpf
@@ -0,0 +1,23 @@
+LIB2ADDEH = 
+
+crti.o: $(srcdir)/config/bpf/crti.S
+	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $<
+
+crtn.o: $(srcdir)/config/bpf/crtn.S
+	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $<
+
+# Some of the functions defined in libgcc2 exceed the eBPF stack
+# limit, or other restrictions imposed by this peculiar target.
+# Therefore we have to exclude them here.
+#
+# Patterns in bpf.md must guarantee that no calls to the excluded
+# functions are ever generated, and compiler tests should make sure
+# this holds.
+#
+# Note that the modes in the function names below are misleading: di
+# means TImode.
+LIB2FUNCS_EXCLUDE = _mulvdi3 _divdi3 _moddi3 _divmoddi4 _udivdi3 _umoddi3 \
+                    _udivmoddi4
+
+# Prevent building "advanced" stuff (for example, gcov support).
+INHIBIT_LIBC_CFLAGS = -Dinhibit_libc
-- 
2.11.0

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

* [PATCH V6 00/11] eBPF support for GCC
@ 2019-08-29 15:32 Jose E. Marchesi
  2019-08-29 15:14 ` [PATCH V6 04/11] testsuite: new require effective target indirect_calls Jose E. Marchesi
                   ` (10 more replies)
  0 siblings, 11 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:32 UTC (permalink / raw)
  To: gcc-patches

[Differences from V5:
. Use TARGET_BIG_ENDIAN instead of TARGET_LITTLE_ENDIAN, and make sure
  ASM_SPEC always passes an endianness selector argument to the
  assembler.
. De-obfuscate the usage of arg.type_size_in_bytes and
  arg_aggregate-type_p.
. Increase the cummulative argument unconditionally in
  bpf_function_arg_advance.
. Simplify conditional in bpf_print_operand_address.
. Remove predicates reg_or_memory_operand and mov_dst_operand, because
  they became the same than nonimmediate_operand.
. The kernel helper get_current_task() doesn't accept arguments.
  Adjust the helper definition accordingly, and the corresponding
  test.]

Hi people!

This patch series introduces a port of GCC to eBPF, which is a virtual
machine that resides in the Linux kernel.  Initially intended for
user-level packet capture and filtering, eBPF is nowadays generalized
to serve as a general-purpose infrastructure also for non-networking
purposes.

The binutils support is already upstream.  See
https://sourceware.org/ml/binutils/2019-05/msg00306.html.

eBPF architecture and ABI
=========================
   
Documentation for eBPF can be found in the linux kernel source tree,
file Documentation/networking/filter.txt.  It covers the instructions
set, the way the interpreter works and the many restrictions imposed
by the kernel verifier.
   
As for the ABI, att this moment compiled eBPF doesn't have very well
established conventions.  The details on what is expected to be in an
ELF file containing eBPF is determined, in practice, by what the llvm
BPF backend generates and what is expected by the the two existing
kernel loaders: bpf_load.c and libbpf.

We hope that the addition of this port to the GNU toolchain will help
to mature this domain.

Overview of the patch series
============================
   
The first few patches are preparatory:

. The first patch updates config.guess and config.sub from the
  'config' upstream project, in order to recognize bpf-*-* triplets.

. The second patch fixes an integrity check in opt-functions.awk.

. The third patch annotates many tests in the gcc.c-torture/compile
  testsuite with their requirements in terms of stack frame size,
  using the existing dg-require-stack-size machinery.

. The fourth patch introduces a new effective target flag called
  indirect_call, and annotates the tests in gcc.c-torture/compile
  accordingly.

The rest of the patches are BPF specific:

The fifth patch adds the new GCC port proper.  Machine description,
implementation of target hooks and macros, command-line options and
the like.

The sixth patch adds a libgcc port for eBPF.  At the moment, it is
minimal and it basically addresses the limitations imposed by the
target, by excluding a few functions in libgcc2 (all of them related
to TImodes) whose default implementations exceed the eBPF stack limit.

The seventh, eight and ninth patches deal with testing the new
port. The gcc.target testsuite is extended with eBPF-specific tests,
covering the backend-specific built-in functions and diagnostics.  The
check-effective-target functions are made aware of eBPF targets. Many
tests in the gcc.c-torture/compile testsuite are annotated to be
skipped in bpf-*-* targets, since they violate some restriction
imposed by the hardware (such as surpassing the stack limit.)  The
resulting testsuite doesn't have unexpected failures, and is currently
the principal way to check for regressions in the port.  Likewise,
many tests in the gcc.dg testsuite are annotated to be skipped in
bpf-*-* targets.

The tenth patch adds documentation updates to the GCC manual,
including information on the new command line options and compiler
built-ins.

Finally, the last patch adds myself as the maintainer of the BPF port.
I personally commit to evolve and maintain the port for as long as
necessary, and to find a suitable replacement in case I have to step
down for whatever reason.

Some notes on the port
======================

As a compilation target, eBPF is rather peculiar.  This is mainly due
to the quite hard restrictions imposed by the kernel verifier, and
also due to the security-driven design of the architecture itself.

To list a few examples:

. The stack is disjoint, and each stack frame corresponding to a
  function activation is isolated: it is not possible for a callee to
  access the stack frame of the caller, nor for a caller to access the
  stack frame of it's callees.  The frame pointer register is
  read-only.

. Therefore it is not possible to pass arguments in the stack.

. Argument passing is restricted to 5 arguments.

. Each stack frame is limited to 512 bytes by default.

. The instruction set doesn't support indirect jumps.

. The instruction set doesn't support indirect calls.

. The architecture doesn't provide an explicit stack pointer.
  Instead, the eBPF "hardware" (in this case the kernel verifier)
  examines the compiled program and, by looking at the way the stack
  is accessed, estimates the size of the stack frame for each
  function.

. eBPF "programs" are not ELF executables, but relocatable ELF
  objects.  This is because the kernel loaders need access to certain
  relocations, and each object contains several entry points, which
  are different kind of eBPF kernel programs hooked to different parts
  of the kernel.  We are working on a more "Elf conventional"
  alternative load model for eBPF programs, but that's a tangent at
  this point.

Restrictions like the above impact the port in several ways, some of
which are good to keep in mind while reviewing the patches:

. Only (a subset of) C is supported at the moment.  It should be
  possible to add more languages in the future, as the eBPF kernel
  verifier gets smarter and therefore more sophisticated programs are
  allowed.

. The back end tries to issue errors when an eBPF restriction is
  violated.  This is to increase the chances of the resulting objects
  to be palatable to the kernel verifier, shortening the development
  cycle.

. Dynamic stack allocation (alloca and VLAs) is achieved by using what
  otherwise would be a perfectly normal general register, %r9, as a
  pseudo stack pointer.  This has the disadvantage of making the
  register "fixed" and therefore not available for general register
  allocation.  Hopefully there is a way to conditionalize this, since
  both alloca and VLAs are relatively uncommon; I haven't found it
  yet.

. The restrictions imposed by the kernel verifier, the characteristics
  of the virtual architecture, the available kernel helpers, and the
  behavior of the loaders, all change from one version of the kernel
  to another. Therefore, the GCC backend provides a -mkernel command
  line option that specifies the minimum kernel version in which the
  program is to be executed.  This is conceptually similar to the
  -mcpu option provided by most ports.

I am preparing a white paper on "compiled eBPF" that will be available
at the Cauldron next month, addressing the points above, and many
others, in depth.

I am really eager to discuss with you people, how to best compile eBPF
:)

Present and future work
=======================

This port provides a rough equivalence of what the llvm port does [1]
and, along with the binutils support, it can be used to develop
compiled eBPF applications.

However, it is in no way finished.

There are a lot of further refinements and additions to the port on
our radar: how to translate more C, CO-RE capabilities (compile-once,
run-everywhere), generation of BTF, and much more...  the eBPF field
moves very fast!

Also, a simulator and GDB support is on the works.  Once completed, it
will emulate the different kernel contexts where eBPF programs
execute.  Once the simulator works, a suitable board description will
be added to dejagnu, making it possible to run the GCC testsuites on
it.

Now that GCC is entering the play, there will be two C compilers able
to generate eBPF, the other being clang/llvm.  Interoperability
between programs generated by both compilers becomes an important
concern, and keeping it will be an an on-going task, requiring
communication between the compilers communities and the kernel
community.

[1] modulus the very recently added CO-RE stuff added in llvm upstream
    a few weeks ago.
   
Testing
=======
   
The following test suites have been executed for target
bpf-unknown-none in a x86-64-pc-linux-gnu host, using the latest
binutils from master, and a board description containin the following
definitions:

    set_board_info mathlib ""
    set_board_info gcc,stack_size 512
    set_board_info cflags "-mframe-limit=32767"

Running /home/jemarch/gnu/src/gcc-git/gcc/testsuite/gcc.target/bpf/bpf.exp ...

		=== gcc Summary ===

   # of expected passes		230
   # of expected failures	1
   # of unresolved testcases	3

Running /home/jemarch/gnu/src/gcc-git/gcc/testsuite/gcc.c-torture/compile/compile.exp ...

		=== gcc Summary ===

   # of expected passes		11743
   # of unresolved testcases	28
   # of unsupported tests	1482

Running /home/jemarch/gnu/src/gcc-git/gcc/testsuite/gcc.dg/dg.exp ...

		=== gcc Summary ===

   # of expected passes		23062
   # of unexpected failures	819
   # of unexpected successes	3
   # of expected failures	267
   # of unresolved testcases	559
   # of unsupported tests	649
   
Most of the failures running the gcc-dg tests are due to linker errors
like undefined references to `exit' and other standard functions,
which are not available for the target.

Jose E. Marchesi (11):
  Update config.sub and config.guess.
  opt-functions.awk: fix comparison of limit, begin and end
  testsuite: annotate c-torture/compile tests with dg-require-stack-size
  testsuite: new require effective target indirect_calls
  bpf: new GCC port
  bpf: new libgcc port
  bpf: gcc.target eBPF testsuite
  bpf: make target-supports.exp aware of eBPF
  bpf: adjust GCC testsuite to eBPF limitations
  bpf: manual updates for eBPF
  bpf: add myself as the maintainer for the eBPF port

 ChangeLog                                          |  15 +
 MAINTAINERS                                        |   2 +-
 config.guess                                       | 264 ++++--
 config.sub                                         |  50 +-
 configure                                          |  54 +-
 configure.ac                                       |  54 +-
 contrib/ChangeLog                                  |   4 +
 contrib/config-list.mk                             |   3 +-
 gcc/ChangeLog                                      |  33 +
 gcc/common/config/bpf/bpf-common.c                 |  55 ++
 gcc/config.gcc                                     |   9 +
 gcc/config/bpf/bpf-helpers.def                     | 194 +++++
 gcc/config/bpf/bpf-helpers.h                       | 327 +++++++
 gcc/config/bpf/bpf-opts.h                          |  56 ++
 gcc/config/bpf/bpf-protos.h                        |  33 +
 gcc/config/bpf/bpf.c                               | 948 +++++++++++++++++++++
 gcc/config/bpf/bpf.h                               | 539 ++++++++++++
 gcc/config/bpf/bpf.md                              | 497 +++++++++++
 gcc/config/bpf/bpf.opt                             | 123 +++
 gcc/config/bpf/constraints.md                      |  32 +
 gcc/config/bpf/predicates.md                       |  64 ++
 gcc/config/bpf/t-bpf                               |   0
 gcc/doc/extend.texi                                | 171 ++++
 gcc/doc/invoke.texi                                |  37 +
 gcc/doc/sourcebuild.texi                           |   4 +
 gcc/opt-functions.awk                              |   7 +-
 gcc/testsuite/ChangeLog                            | 305 +++++++
 gcc/testsuite/gcc.c-torture/compile/20000211-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20000403-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20000609-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20000804-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20001226-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20010102-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20010107-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20011109-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20011218-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20011229-1.c   |   3 +
 gcc/testsuite/gcc.c-torture/compile/20020129-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20020304-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20020320-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20020604-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20020706-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20020706-2.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20021015-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20021205-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20030903-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20030921-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20031023-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20031023-2.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20031023-3.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20031023-4.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20031125-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20040101-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20040317-2.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20040614-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20040726-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20040909-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20050122-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20050202-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20050303-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20051216-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20060208-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20060421-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20071207-1.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/20080903-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20081108-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20101217-1.c   |   4 +-
 gcc/testsuite/gcc.c-torture/compile/20121027-1.c   |   2 +
 gcc/testsuite/gcc.c-torture/compile/20150327.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/20151204.c     |   1 +
 gcc/testsuite/gcc.c-torture/compile/900313-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/920428-2.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/920501-12.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/920501-4.c     |   1 +
 gcc/testsuite/gcc.c-torture/compile/920501-7.c     |   1 +
 gcc/testsuite/gcc.c-torture/compile/920625-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/920723-1.c     |   1 +
 gcc/testsuite/gcc.c-torture/compile/920928-5.c     |   3 +
 gcc/testsuite/gcc.c-torture/compile/921202-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/930117-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/930421-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/930607-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/930623-1.c     |   1 +
 gcc/testsuite/gcc.c-torture/compile/931003-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/931004-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/950719-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/951222-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/961004-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/980504-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/980816-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/990517-1.c     |   3 +
 gcc/testsuite/gcc.c-torture/compile/990625-1.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/991213-2.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/DFcmp.c        |   2 +
 gcc/testsuite/gcc.c-torture/compile/HIcmp.c        |   2 +
 gcc/testsuite/gcc.c-torture/compile/HIset.c        |   2 +
 gcc/testsuite/gcc.c-torture/compile/QIcmp.c        |   2 +
 gcc/testsuite/gcc.c-torture/compile/QIset.c        |   2 +
 gcc/testsuite/gcc.c-torture/compile/SFset.c        |   1 +
 gcc/testsuite/gcc.c-torture/compile/SIcmp.c        |   2 +
 gcc/testsuite/gcc.c-torture/compile/SIset.c        |   2 +
 gcc/testsuite/gcc.c-torture/compile/UHIcmp.c       |   2 +
 gcc/testsuite/gcc.c-torture/compile/UQIcmp.c       |   2 +
 gcc/testsuite/gcc.c-torture/compile/USIcmp.c       |   2 +
 gcc/testsuite/gcc.c-torture/compile/bcopy.c        |   1 +
 gcc/testsuite/gcc.c-torture/compile/callind.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/calls-void.c   |   1 +
 gcc/testsuite/gcc.c-torture/compile/calls.c        |   1 +
 gcc/testsuite/gcc.c-torture/compile/consec.c       |   2 +
 .../gcc.c-torture/compile/limits-fndefn.c          |   1 +
 gcc/testsuite/gcc.c-torture/compile/lll.c          |   1 +
 gcc/testsuite/gcc.c-torture/compile/parms.c        |   1 +
 gcc/testsuite/gcc.c-torture/compile/pass.c         |   2 +
 gcc/testsuite/gcc.c-torture/compile/poor.c         |   2 +
 gcc/testsuite/gcc.c-torture/compile/pp.c           |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr21840.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr23929.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr25310.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr25311.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr32139.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr32399.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr34091.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr34458.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr34688.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr35607.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr37258.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr37327.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr37381.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr37433-1.c    |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr37433.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr37669-2.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr37669.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr37742-3.c    |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr39928-1.c    |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr39937.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr39941.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr40080.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr41181.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr41634.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr43415.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr43417.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr43635.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr43791.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr43845.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr44043.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr44063.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr44788.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr48596.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr51694.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr51856.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr54428.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr54713-1.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr54713-2.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr54713-3.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr55921.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr70061.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr70240.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr70355.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr77754-2.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr77754-3.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr77754-4.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr82052.c      |   2 +
 gcc/testsuite/gcc.c-torture/compile/pr83487.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr86122.c      |   1 +
 gcc/testsuite/gcc.c-torture/compile/pr89663-2.c    |   1 +
 gcc/testsuite/gcc.c-torture/compile/pret-arg.c     |   2 +
 gcc/testsuite/gcc.c-torture/compile/pta-1.c        |   2 +
 .../gcc.c-torture/compile/regs-arg-size.c          |   2 +
 gcc/testsuite/gcc.c-torture/compile/sound.c        |   1 +
 .../gcc.c-torture/compile/stack-check-1.c          |   1 +
 gcc/testsuite/gcc.c-torture/compile/structret.c    |   2 +
 gcc/testsuite/gcc.c-torture/compile/uuarg.c        |   2 +
 gcc/testsuite/gcc.dg/20001009-1.c                  |   1 +
 gcc/testsuite/gcc.dg/20020418-1.c                  |   1 +
 gcc/testsuite/gcc.dg/20020426-2.c                  |   1 +
 gcc/testsuite/gcc.dg/20020430-1.c                  |   1 +
 gcc/testsuite/gcc.dg/20040306-1.c                  |   2 +-
 gcc/testsuite/gcc.dg/20040622-2.c                  |   1 +
 gcc/testsuite/gcc.dg/20050603-2.c                  |   1 +
 gcc/testsuite/gcc.dg/20050629-1.c                  |   1 +
 gcc/testsuite/gcc.dg/20061026.c                    |   1 +
 gcc/testsuite/gcc.dg/Walloc-size-larger-than-18.c  |   1 +
 gcc/testsuite/gcc.dg/Warray-bounds-3.c             |   1 +
 gcc/testsuite/gcc.dg/Warray-bounds-30.c            |   3 +-
 gcc/testsuite/gcc.dg/Wframe-larger-than-2.c        |   3 +-
 gcc/testsuite/gcc.dg/Wframe-larger-than.c          |   1 +
 gcc/testsuite/gcc.dg/Wrestrict-11.c                |   3 +-
 gcc/testsuite/gcc.dg/builtins-config.h             |   4 +-
 gcc/testsuite/gcc.target/bpf/bpf.exp               |  41 +
 gcc/testsuite/gcc.target/bpf/builtin-load.c        |  20 +
 gcc/testsuite/gcc.target/bpf/constant-calls.c      |  20 +
 gcc/testsuite/gcc.target/bpf/diag-funargs-2.c      |  26 +
 gcc/testsuite/gcc.target/bpf/diag-funargs-3.c      |  26 +
 gcc/testsuite/gcc.target/bpf/diag-funargs.c        |  15 +
 gcc/testsuite/gcc.target/bpf/diag-indcalls.c       |  11 +
 gcc/testsuite/gcc.target/bpf/helper-bind.c         |  15 +
 gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c |  15 +
 .../gcc.target/bpf/helper-clone-redirect.c         |  16 +
 gcc/testsuite/gcc.target/bpf/helper-csum-diff.c    |  16 +
 gcc/testsuite/gcc.target/bpf/helper-csum-update.c  |  15 +
 .../bpf/helper-current-task-under-cgroup.c         |  15 +
 gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c   |  16 +
 .../gcc.target/bpf/helper-get-cgroup-classid.c     |  14 +
 .../gcc.target/bpf/helper-get-current-cgroup-id.c  |  13 +
 .../gcc.target/bpf/helper-get-current-comm.c       |  15 +
 .../gcc.target/bpf/helper-get-current-pid-tgid.c   |  13 +
 .../gcc.target/bpf/helper-get-current-task.c       |  13 +
 .../gcc.target/bpf/helper-get-current-uid-gid.c    |  13 +
 .../gcc.target/bpf/helper-get-hash-recalc.c        |  14 +
 .../gcc.target/bpf/helper-get-listener-sock.c      |  13 +
 .../gcc.target/bpf/helper-get-local-storage.c      |  14 +
 .../gcc.target/bpf/helper-get-numa-node-id.c       |  13 +
 .../gcc.target/bpf/helper-get-prandom-u32.c        |  13 +
 .../gcc.target/bpf/helper-get-route-realm.c        |  14 +
 .../gcc.target/bpf/helper-get-smp-processor-id.c   |  13 +
 .../gcc.target/bpf/helper-get-socket-cookie.c      |  14 +
 .../gcc.target/bpf/helper-get-socket-uid.c         |  14 +
 gcc/testsuite/gcc.target/bpf/helper-get-stack.c    |  16 +
 gcc/testsuite/gcc.target/bpf/helper-get-stackid.c  |  15 +
 gcc/testsuite/gcc.target/bpf/helper-getsockopt.c   |  17 +
 gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c |  12 +
 .../gcc.target/bpf/helper-l3-csum-replace.c        |  16 +
 .../gcc.target/bpf/helper-l4-csum-replace.c        |  16 +
 .../gcc.target/bpf/helper-lwt-push-encap.c         |  15 +
 .../gcc.target/bpf/helper-lwt-seg6-action.c        |  16 +
 .../gcc.target/bpf/helper-lwt-seg6-adjust-srh.c    |  16 +
 .../gcc.target/bpf/helper-lwt-seg6-store-bytes.c   |  16 +
 .../gcc.target/bpf/helper-map-delete-elem.c        |  14 +
 .../gcc.target/bpf/helper-map-lookup-elem.c        |  12 +
 .../gcc.target/bpf/helper-map-peek-elem.c          |  14 +
 gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c |  14 +
 .../gcc.target/bpf/helper-map-push-elem.c          |  16 +
 .../gcc.target/bpf/helper-map-update-elem.c        |  16 +
 .../gcc.target/bpf/helper-msg-apply-bytes.c        |  15 +
 .../gcc.target/bpf/helper-msg-cork-bytes.c         |  15 +
 gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c |  16 +
 .../gcc.target/bpf/helper-msg-pull-data.c          |  16 +
 .../gcc.target/bpf/helper-msg-push-data.c          |  16 +
 .../gcc.target/bpf/helper-msg-redirect-hash.c      |  16 +
 .../gcc.target/bpf/helper-msg-redirect-map.c       |  17 +
 .../gcc.target/bpf/helper-override-return.c        |  15 +
 .../gcc.target/bpf/helper-perf-event-output.c      |  17 +
 .../gcc.target/bpf/helper-perf-event-read-value.c  |  16 +
 .../gcc.target/bpf/helper-perf-event-read.c        |  15 +
 .../gcc.target/bpf/helper-perf-prog-read-value.c   |  15 +
 .../gcc.target/bpf/helper-probe-read-str.c         |  16 +
 gcc/testsuite/gcc.target/bpf/helper-probe-read.c   |  15 +
 .../gcc.target/bpf/helper-probe-write-user.c       |  15 +
 gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c   |  17 +
 .../gcc.target/bpf/helper-rc-pointer-rel.c         |  15 +
 gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c    |  14 +
 gcc/testsuite/gcc.target/bpf/helper-redirect-map.c |  16 +
 .../gcc.target/bpf/helper-set-hash-invalid.c       |  13 +
 gcc/testsuite/gcc.target/bpf/helper-set-hash.c     |  15 +
 gcc/testsuite/gcc.target/bpf/helper-setsockopt.c   |  19 +
 gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c  |  13 +
 .../gcc.target/bpf/helper-sk-lookup-tcp.c          |  19 +
 .../gcc.target/bpf/helper-sk-lookup-upd.c          |  19 +
 .../gcc.target/bpf/helper-sk-redirect-hash.c       |  16 +
 .../gcc.target/bpf/helper-sk-redirect-map.c        |  16 +
 gcc/testsuite/gcc.target/bpf/helper-sk-release.c   |  14 +
 .../gcc.target/bpf/helper-sk-select-reuseport.c    |  16 +
 .../gcc.target/bpf/helper-sk-storage-delete.c      |  14 +
 .../gcc.target/bpf/helper-sk-storage-get.c         |  16 +
 .../gcc.target/bpf/helper-skb-adjust-room.c        |  17 +
 .../gcc.target/bpf/helper-skb-cgroup-id.c          |  14 +
 .../gcc.target/bpf/helper-skb-change-head.c        |  16 +
 .../gcc.target/bpf/helper-skb-change-proto.c       |  16 +
 .../gcc.target/bpf/helper-skb-change-tail.c        |  16 +
 .../gcc.target/bpf/helper-skb-change-type.c        |  15 +
 .../gcc.target/bpf/helper-skb-ecn-set-ce.c         |  14 +
 .../gcc.target/bpf/helper-skb-get-tunnel-key.c     |  16 +
 .../gcc.target/bpf/helper-skb-get-tunnel-opt.c     |  16 +
 .../gcc.target/bpf/helper-skb-get-xfrm-state.c     |  17 +
 .../bpf/helper-skb-load-bytes-relative.c           |  17 +
 .../gcc.target/bpf/helper-skb-load-bytes.c         |  15 +
 .../gcc.target/bpf/helper-skb-pull-data.c          |  15 +
 .../gcc.target/bpf/helper-skb-set-tunnel-key.c     |  16 +
 .../gcc.target/bpf/helper-skb-set-tunnel-opt.c     |  16 +
 .../gcc.target/bpf/helper-skb-store-bytes.c        |  18 +
 .../gcc.target/bpf/helper-skb-under-cgroup.c       |  15 +
 gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c |  14 +
 .../gcc.target/bpf/helper-skb-vlan-push.c          |  16 +
 .../gcc.target/bpf/helper-skc-lookup-tcp.c         |  17 +
 .../gcc.target/bpf/helper-sock-hash-update.c       |  16 +
 .../gcc.target/bpf/helper-sock-map-update.c        |  16 +
 .../gcc.target/bpf/helper-sock-ops-cb-flags-set.c  |  16 +
 gcc/testsuite/gcc.target/bpf/helper-spin-lock.c    |  13 +
 gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c  |  13 +
 gcc/testsuite/gcc.target/bpf/helper-strtol.c       |  18 +
 gcc/testsuite/gcc.target/bpf/helper-strtoul.c      |  18 +
 .../bpf/helper-sysctl-get-current-value.c          |  17 +
 .../gcc.target/bpf/helper-sysctl-get-name.c        |  18 +
 .../gcc.target/bpf/helper-sysctl-get-new-value.c   |  17 +
 .../gcc.target/bpf/helper-sysctl-set-new-value.c   |  17 +
 gcc/testsuite/gcc.target/bpf/helper-tail-call.c    |  14 +
 .../gcc.target/bpf/helper-tcp-check-syncookie.c    |  17 +
 gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c     |  13 +
 gcc/testsuite/gcc.target/bpf/helper-trace-printk.c |  13 +
 .../gcc.target/bpf/helper-xdp-adjust-head.c        |  15 +
 .../gcc.target/bpf/helper-xdp-adjust-meta.c        |  15 +
 .../gcc.target/bpf/helper-xdp-adjust-tail.c        |  15 +
 .../gcc.target/bpf/skb-ancestor-cgroup-id.c        |  16 +
 gcc/testsuite/gcc.target/bpf/sync-fetch-and-add.c  |  14 +
 gcc/testsuite/lib/target-supports.exp              |  26 +-
 libgcc/ChangeLog                                   |   7 +
 libgcc/config.host                                 |   7 +
 libgcc/config/bpf/crti.S                           |   0
 libgcc/config/bpf/crtn.S                           |   0
 libgcc/config/bpf/t-bpf                            |  23 +
 310 files changed, 5949 insertions(+), 99 deletions(-)
 create mode 100644 gcc/common/config/bpf/bpf-common.c
 create mode 100644 gcc/config/bpf/bpf-helpers.def
 create mode 100644 gcc/config/bpf/bpf-helpers.h
 create mode 100644 gcc/config/bpf/bpf-opts.h
 create mode 100644 gcc/config/bpf/bpf-protos.h
 create mode 100644 gcc/config/bpf/bpf.c
 create mode 100644 gcc/config/bpf/bpf.h
 create mode 100644 gcc/config/bpf/bpf.md
 create mode 100644 gcc/config/bpf/bpf.opt
 create mode 100644 gcc/config/bpf/constraints.md
 create mode 100644 gcc/config/bpf/predicates.md
 create mode 100644 gcc/config/bpf/t-bpf
 create mode 100644 gcc/testsuite/gcc.target/bpf/bpf.exp
 create mode 100644 gcc/testsuite/gcc.target/bpf/builtin-load.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/constant-calls.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-funargs-2.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-funargs-3.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-funargs.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/diag-indcalls.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-bind.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-clone-redirect.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-csum-diff.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-csum-update.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-current-task-under-cgroup.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-cgroup-classid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-cgroup-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-comm.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-pid-tgid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-task.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-current-uid-gid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-hash-recalc.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-listener-sock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-local-storage.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-numa-node-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-prandom-u32.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-route-realm.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-smp-processor-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-socket-cookie.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-socket-uid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-stack.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-get-stackid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-getsockopt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-l3-csum-replace.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-l4-csum-replace.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-push-encap.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-action.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-adjust-srh.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-store-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-delete-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-lookup-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-peek-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-push-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-map-update-elem.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-apply-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-cork-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-pull-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-push-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-redirect-hash.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-msg-redirect-map.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-override-return.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-event-output.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-event-read-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-event-read.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-perf-prog-read-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-probe-read-str.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-probe-read.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-probe-write-user.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-rc-pointer-rel.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-redirect-map.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-set-hash-invalid.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-set-hash.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-setsockopt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-lookup-tcp.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-lookup-upd.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-redirect-hash.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-redirect-map.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-release.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-select-reuseport.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-storage-delete.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sk-storage-get.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-adjust-room.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-cgroup-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-head.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-proto.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-tail.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-change-type.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-ecn-set-ce.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-key.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-opt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-get-xfrm-state.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes-relative.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-pull-data.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-key.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-opt.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-store-bytes.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-under-cgroup.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skb-vlan-push.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-skc-lookup-tcp.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sock-hash-update.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sock-map-update.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sock-ops-cb-flags-set.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-spin-lock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-strtol.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-strtoul.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-get-current-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-get-name.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-get-new-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-sysctl-set-new-value.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-tail-call.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-tcp-check-syncookie.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-trace-printk.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-head.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-meta.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-tail.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/skb-ancestor-cgroup-id.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/sync-fetch-and-add.c
 create mode 100644 libgcc/config/bpf/crti.S
 create mode 100644 libgcc/config/bpf/crtn.S
 create mode 100644 libgcc/config/bpf/t-bpf

-- 
2.11.0

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

* [PATCH V6 02/11] opt-functions.awk: fix comparison of limit, begin and end
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (8 preceding siblings ...)
  2019-08-29 15:21 ` [PATCH V6 06/11] bpf: new libgcc port Jose E. Marchesi
@ 2019-08-29 15:34 ` Jose E. Marchesi
  2019-09-09  9:47   ` Jose E. Marchesi
  2019-08-29 15:36 ` [PATCH V6 05/11] bpf: new GCC port Jose E. Marchesi
  10 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:34 UTC (permalink / raw)
  To: gcc-patches

The function integer_range_info makes sure that, if provided, the
initial value fills in the especified range.  However, it is necessary
to convert the values to a numerical context before comparing, to make
sure awk is using arithmetical order and not lexicographical order.

gcc/ChangeLog:

	* opt-functions.awk (integer_range_info): Make sure values are in
	numeric context before operating with them.
---
 gcc/ChangeLog         | 5 +++++
 gcc/opt-functions.awk | 7 ++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index 1190e6d6b66..c1da80c648c 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -346,9 +346,10 @@ function search_var_name(name, opt_numbers, opts, flags, n_opts)
 function integer_range_info(range_option, init, option)
 {
     if (range_option != "") {
-	start = nth_arg(0, range_option);
-	end = nth_arg(1, range_option);
-	if (init != "" && init != "-1" && (init < start || init > end))
+	ival = init + 0;
+	start = nth_arg(0, range_option) + 0;
+	end = nth_arg(1, range_option) + 0;
+	if (init != "" && init != "-1" && (ival < start || ival > end))
 	  print "#error initial value " init " of '" option "' must be in range [" start "," end "]"
 	return start ", " end
     }
-- 
2.11.0

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

* [PATCH V6 05/11] bpf: new GCC port
  2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
                   ` (9 preceding siblings ...)
  2019-08-29 15:34 ` [PATCH V6 02/11] opt-functions.awk: fix comparison of limit, begin and end Jose E. Marchesi
@ 2019-08-29 15:36 ` Jose E. Marchesi
  2019-08-30  8:38   ` Richard Sandiford
  10 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-29 15:36 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc-patches


This patch adds a port for the Linux kernel eBPF architecture to GCC.

ChangeLog:

  * configure.ac: Support for bpf-*-* targets.
  * configure: Regenerate.

contrib/ChangeLog:

  * config-list.mk (LIST): Disable go in bpf-*-* targets.

gcc/ChangeLog:

  * config.gcc: Support for bpf-*-* targets.
  * common/config/bpf/bpf-common.c: New file.
  * config/bpf/t-bpf: Likewise.
  * config/bpf/predicates.md: Likewise.
  * config/bpf/constraints.md: Likewise.
  * config/bpf/bpf.opt: Likewise.
  * config/bpf/bpf.md: Likewise.
  * config/bpf/bpf.h: Likewise.
  * config/bpf/bpf.c: Likewise.
  * config/bpf/bpf-protos.h: Likewise.
  * config/bpf/bpf-opts.h: Likewise.
  * config/bpf/bpf-helpers.h: Likewise.
  * config/bpf/bpf-helpers.def: Likewise.
---
 ChangeLog                          |   5 +
 configure                          |  54 ++-
 configure.ac                       |  54 ++-
 contrib/ChangeLog                  |   4 +
 contrib/config-list.mk             |   3 +-
 gcc/ChangeLog                      |  16 +
 gcc/common/config/bpf/bpf-common.c |  55 +++
 gcc/config.gcc                     |   9 +
 gcc/config/bpf/bpf-helpers.def     | 194 ++++++++
 gcc/config/bpf/bpf-helpers.h       | 327 +++++++++++++
 gcc/config/bpf/bpf-opts.h          |  56 +++
 gcc/config/bpf/bpf-protos.h        |  33 ++
 gcc/config/bpf/bpf.c               | 948 +++++++++++++++++++++++++++++++++++++
 gcc/config/bpf/bpf.h               | 539 +++++++++++++++++++++
 gcc/config/bpf/bpf.md              | 497 +++++++++++++++++++
 gcc/config/bpf/bpf.opt             | 123 +++++
 gcc/config/bpf/constraints.md      |  32 ++
 gcc/config/bpf/predicates.md       |  64 +++
 gcc/config/bpf/t-bpf               |   0
 19 files changed, 3010 insertions(+), 3 deletions(-)
 create mode 100644 gcc/common/config/bpf/bpf-common.c
 create mode 100644 gcc/config/bpf/bpf-helpers.def
 create mode 100644 gcc/config/bpf/bpf-helpers.h
 create mode 100644 gcc/config/bpf/bpf-opts.h
 create mode 100644 gcc/config/bpf/bpf-protos.h
 create mode 100644 gcc/config/bpf/bpf.c
 create mode 100644 gcc/config/bpf/bpf.h
 create mode 100644 gcc/config/bpf/bpf.md
 create mode 100644 gcc/config/bpf/bpf.opt
 create mode 100644 gcc/config/bpf/constraints.md
 create mode 100644 gcc/config/bpf/predicates.md
 create mode 100644 gcc/config/bpf/t-bpf

diff --git a/configure.ac b/configure.ac
index 1fe97c001cc..b8ce2ad20b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -638,6 +638,9 @@ case "${target}" in
     # No hosted I/O support.
     noconfigdirs="$noconfigdirs target-libssp"
     ;;
+  bpf-*-*)
+    noconfigdirs="$noconfigdirs target-libssp"
+    ;;
   powerpc-*-aix* | rs6000-*-aix*)
     noconfigdirs="$noconfigdirs target-libssp"
     ;;
@@ -672,12 +675,43 @@ if test "${ENABLE_LIBSTDCXX}" = "default" ; then
     avr-*-*)
       noconfigdirs="$noconfigdirs target-libstdc++-v3"
       ;;
+    bpf-*-*)
+      noconfigdirs="$noconfigdirs target-libstdc++-v3"
+      ;;
     ft32-*-*)
       noconfigdirs="$noconfigdirs target-libstdc++-v3"
       ;;
   esac
 fi
 
+# Disable C++ on systems where it is known to not work.
+# For testing, you can override this with --enable-languages=c++.
+case ,${enable_languages}, in
+  *,c++,*)
+    ;;
+  *)
+      case "${target}" in
+        bpf-*-*)
+          unsupported_languages="$unsupported_languages c++"
+          ;;
+      esac
+      ;;
+esac
+
+# Disable Objc on systems where it is known to not work.
+# For testing, you can override this with --enable-languages=objc.
+case ,${enable_languages}, in
+  *,objc,*)
+    ;;
+  *)
+      case "${target}" in
+        bpf-*-*)
+          unsupported_languages="$unsupported_languages objc"
+          ;;
+      esac
+      ;;
+esac
+
 # Disable D on systems where it is known to not work.
 # For testing, you can override this with --enable-languages=d.
 case ,${enable_languages}, in
@@ -687,6 +721,9 @@ case ,${enable_languages}, in
     case "${target}" in
       *-*-darwin*)
 	unsupported_languages="$unsupported_languages d"
+        ;;
+      bpf-*-*)
+	unsupported_languages="$unsupported_languages d"
 	;;
     esac
     ;;
@@ -715,6 +752,9 @@ case "${target}" in
     # See <http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00572.html>.
     unsupported_languages="$unsupported_languages fortran"
     ;;
+  bpf-*-*)
+    unsupported_languages="$unsupported_languages fortran"
+    ;;
 esac
 
 # Disable libffi for some systems.
@@ -761,6 +801,9 @@ case "${target}" in
   arm*-*-symbianelf*)
     noconfigdirs="$noconfigdirs target-libffi"
     ;;
+  bpf-*-*)
+    noconfigdirs="$noconfigdirs target-libffi"
+    ;;
   cris-*-* | crisv32-*-*)
     case "${target}" in
       *-*-linux*)
@@ -807,7 +850,7 @@ esac
 # Disable the go frontend on systems where it is known to not work. Please keep
 # this in sync with contrib/config-list.mk.
 case "${target}" in
-*-*-darwin* | *-*-cygwin* | *-*-mingw*)
+*-*-darwin* | *-*-cygwin* | *-*-mingw* | bpf-* )
     unsupported_languages="$unsupported_languages go"
     ;;
 esac
@@ -823,6 +866,9 @@ if test x$enable_libgo = x; then
     *-*-cygwin* | *-*-mingw*)
 	noconfigdirs="$noconfigdirs target-libgo"
 	;;
+    bpf-*-*)
+        noconfigdirs="$noconfigdirs target-libgo"
+        ;;
     esac
 fi
 
@@ -894,6 +940,9 @@ case "${target}" in
   sparc-*-sunos4*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
+  bpf-*-*)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    ;;
   *-*-aix*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
@@ -1007,6 +1056,9 @@ case "${target}" in
     # newlib is not 64 bit ready
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
+  bpf-*-*)
+    noconfigdirs="$noconfigdirs target-libobjc target-libbacktrace"
+    ;;
   sh*-*-pe|mips*-*-pe|*arm-wince-pe)
     noconfigdirs="$noconfigdirs tcl tk itcl libgui sim"
     ;;
diff --git a/contrib/config-list.mk b/contrib/config-list.mk
index 69c826e649a..61e38bf0e50 100644
--- a/contrib/config-list.mk
+++ b/contrib/config-list.mk
@@ -40,6 +40,7 @@ LIST = aarch64-elf aarch64-linux-gnu aarch64-rtems \
   arm-linux-androideabi arm-uclinux_eabi arm-eabi arm-rtems \
   arm-symbianelf avr-elf \
   bfin-elf bfin-uclinux bfin-linux-uclibc bfin-rtems bfin-openbsd \
+  bpf-unknown-none \
   c6x-elf c6x-uclinux cr16-elf cris-elf cris-linux crisv32-elf crisv32-linux \
   csky-elf csky-linux-gnu \
   epiphany-elf epiphany-elfOPT-with-stack-offset=16 fido-elf \
@@ -123,7 +124,7 @@ $(LIST): make-log-dir
 		TGT=`echo $@ | awk 'BEGIN { FS = "OPT" }; { print $$1 }'` &&			\
 		TGT=`$(GCC_SRC_DIR)/config.sub $$TGT` &&					\
 		case $$TGT in									\
-			*-*-darwin* | *-*-cygwin* | *-*-mingw* | *-*-aix*)			\
+			*-*-darwin* | *-*-cygwin* | *-*-mingw* | *-*-aix* | bpf-*-*)			\
 				ADDITIONAL_LANGUAGES="";					\
 				;;								\
 			*)									\
diff --git a/gcc/common/config/bpf/bpf-common.c b/gcc/common/config/bpf/bpf-common.c
new file mode 100644
index 00000000000..0d04f21b8f9
--- /dev/null
+++ b/gcc/common/config/bpf/bpf-common.c
@@ -0,0 +1,55 @@
+/* Common hooks for eBPF.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "common/common-target.h"
+#include "common/common-target-def.h"
+#include "config/bpf/bpf-protos.h"
+
+#undef TARGET_DEFAULT_TARGET_FLAGS
+#define TARGET_DEFAULT_TARGET_FLAGS 0
+
+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
+static const struct default_options bpf_option_optimization_table[] =
+  {
+    /* Enable -funroll-all-loops by default.  */
+    { OPT_LEVELS_ALL, OPT_funroll_all_loops, NULL, 1 },
+    { OPT_LEVELS_NONE, 0, NULL, 0 }
+  };
+
+#undef TARGET_OPTION_OPTIMIZATION_TABLE
+#define TARGET_OPTION_OPTIMIZATION_TABLE bpf_option_optimization_table
+
+/* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
+
+static void
+bpf_option_default_params (void)
+{
+  /* XXX large-stack-frame = 512 bytes */
+  /* XXX max-unrolled-insns */
+  /* XXX max-unroll-times */
+}
+
+#undef TARGET_OPTION_DEFAULT_PARAMS
+#define TARGET_OPTION_DEFAULT_PARAMS bpf_option_default_params
+
+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 11a8ac73e12..b579aa09bc4 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -360,6 +360,9 @@ avr-*-*)
 bfin*-*)
 	cpu_type=bfin
 	;;
+bpf-*-*)
+	cpu_type=bpf
+	;;
 crisv32-*)
 	cpu_type=cris
 	;;
@@ -1311,6 +1314,12 @@ bfin*-*)
 	use_collect2=no
 	use_gcc_stdint=wrap
 	;;
+bpf-*-*)
+        tmake_file="${tmake_file} bpf/t-bpf"
+        use_collect2=no
+        extra_headers="bpf-helpers.h"
+        use_gcc_stdint=provide
+        ;;
 cr16-*-elf)
         tm_file="elfos.h ${tm_file} newlib-stdint.h"
         tmake_file="${tmake_file} cr16/t-cr16 "
diff --git a/gcc/config/bpf/bpf-helpers.def b/gcc/config/bpf/bpf-helpers.def
new file mode 100644
index 00000000000..cd0640297d0
--- /dev/null
+++ b/gcc/config/bpf/bpf-helpers.def
@@ -0,0 +1,194 @@
+/* Kernel helpers database.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* This file contains the definition of the kernel helpers that are
+   available to eBPF programs.
+
+   The primary source for information on kernel helpers is the
+   linux/include/uapi/linux/bpf.h file in the Linux source tree.
+   Please keep this database in sync.
+
+   The first column is the first kernel version featuring the helper
+   function.  This should be an enumerate from bpf_kernel_version,
+   defined in bpf-opts.h.  Note that the backend assumes that helpers
+   never get deprecated in the kernel.  If that eventually happens,
+   then we will need to use a bitmask here instead of an enumerate.
+
+   The second column is the constant-name for the helper.
+   The third column is the program-name of the helper.
+
+   The fourth column is a list of names describing the types of the
+   values returned and accepted by the helper, in one of these forms:
+
+     TYPES (type1, type2, ..., 0)
+     VTYPES (type1, type2, ..., 0)
+
+   VTYPES should be used should the helper accept a variable number of
+   arguments, TYPES otherwise.  The valid type names are:
+
+     `vt' for void.
+     `it' for signed int.
+     `ut' for unsigned int.
+     `pt' for void*.
+     `cpt' for const void*.
+     `st' for short int.
+     `ust' for unsigned short int.
+     `cst' for const char *.
+     `ullt' for unsigned long long.
+     `llt' for long long.
+     `u32t' for uint32.
+     `u64t' for uint64.
+  
+   In types descriptions, the firt entry corresponds to the value
+   returned by the helper.  Subsequent names correspond to the helper
+   arguments.  Finally, a 0 should close the list.
+
+   VERY IMPORTANT: the helper entries should be listed in the same
+   order than in the definition of __BPF_FUNC_MAPPER in
+   linux/include/uapi/linux/bpf.h!  */
+
+DEF_HELPER (LINUX_V4_0, MAP_LOOKUP_ELEM, map_lookup_elem, TYPES (pt, pt, pt, 0))
+DEF_HELPER (LINUX_V4_0, MAP_UPDATE_ELEM, map_update_elem, TYPES (it, pt, pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V4_0, MAP_DELETE_ELEM, map_delete_elem, TYPES (it, pt, pt, 0))
+DEF_HELPER (LINUX_V4_1, PROBE_READ, probe_read, TYPES (it, pt, ut, cpt, 0))
+DEF_HELPER (LINUX_V4_1, KTIME_GET_NS, ktime_get_ns, TYPES (ullt, 0))
+DEF_HELPER (LINUX_V4_1, TRACE_PRINTK, trace_printk, VTYPES (it, cst, it, 0))
+DEF_HELPER (LINUX_V4_1, GET_PRANDOM_U32, get_prandom_u32, TYPES (ullt, 0))
+DEF_HELPER (LINUX_V4_1, GET_SMP_PROCESSOR_ID, get_smp_processor_id, TYPES (ullt, 0))
+DEF_HELPER (LINUX_V4_1, SKB_STORE_BYTES, skb_store_bytes, TYPES (it, pt, it, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_1, L3_CSUM_REPLACE, l3_csum_replace, TYPES (it, pt, it, it ,it ,it, 0))
+DEF_HELPER (LINUX_V4_1, L4_CSUM_REPLACE, l4_csum_replace, TYPES (it, pt, it, it, it, it, 0))
+DEF_HELPER (LINUX_V4_2, TAIL_CALL, tail_call, TYPES (vt, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_2, CLONE_REDIRECT, clone_redirect, TYPES (it, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_2, GET_CURRENT_PID_TGID, get_current_pid_tgid, TYPES (ullt, 0))
+DEF_HELPER (LINUX_V4_2, GET_CURRENT_UID_GID, get_current_uid_gid, TYPES (ullt, 0))
+DEF_HELPER (LINUX_V4_2, GET_CURRENT_COMM, get_current_comm, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_3, GET_CGROUP_CLASSID, get_cgroup_classid, TYPES (it, pt, 0))
+DEF_HELPER (LINUX_V4_3, SKB_VLAN_PUSH, skb_vlan_push, TYPES (it, pt, st, ust, 0))
+DEF_HELPER (LINUX_V4_3, SKB_VLAN_POP, skb_vlan_pop, TYPES (it, pt, 0))
+DEF_HELPER (LINUX_V4_3, SKB_GET_TUNNEL_KEY, skb_get_tunnel_key, TYPES (it, pt, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_3, SKB_SET_TUNNEL_KEY, skb_set_tunnel_key, TYPES (it, pt, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_3, PERF_EVENT_READ, perf_event_read, TYPES (ullt, pt, ullt, 0))
+DEF_HELPER (LINUX_V4_4, REDIRECT, redirect, TYPES (it, it, it, 0))
+DEF_HELPER (LINUX_V4_4, GET_ROUTE_REALM, get_route_realm, TYPES (ut, pt, 0))
+DEF_HELPER (LINUX_V4_4, PERF_EVENT_OUTPUT, perf_event_output, \
+	    TYPES (it, pt, pt, ullt, pt, it, 0))
+DEF_HELPER (LINUX_V4_5, SKB_LOAD_BYTES, skb_load_bytes, TYPES (it, pt, it, pt, it, 0))
+DEF_HELPER (LINUX_V4_6, GET_STACKID, get_stackid, TYPES (it, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_6, CSUM_DIFF, csum_diff, TYPES (it, pt, it, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_6, SKB_GET_TUNNEL_OPT, skb_get_tunnel_opt, TYPES (it, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_6, SKB_SET_TUNNEL_OPT, skb_set_tunnel_opt, TYPES (it, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_8, SKB_CHANGE_PROTO, skb_change_proto, TYPES (it, pt, st, u64t, 0))
+DEF_HELPER (LINUX_V4_8, SKB_CHANGE_TYPE, skb_change_type, TYPES (it, pt, u32t, 0))
+DEF_HELPER (LINUX_V4_8, SKB_UNDER_CGROUP, skb_under_cgroup, TYPES (it, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_8, GET_HASH_RECALC, get_hash_recalc, TYPES (ut, pt, 0))
+DEF_HELPER (LINUX_V4_8, GET_CURRENT_TASK, get_current_task, TYPES (ullt, 0))
+DEF_HELPER (LINUX_V4_8, PROBE_WRITE_USER, probe_write_user, TYPES (it, pt, cpt, ut, 0))
+DEF_HELPER (LINUX_V4_9, CURRENT_TASK_UNDER_CGROUP, current_task_under_cgroup, \
+	    TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_9, SKB_CHANGE_TAIL, skb_change_tail, TYPES (it, pt, ut, u64t, 0))
+DEF_HELPER (LINUX_V4_9, SKB_PULL_DATA, skb_pull_data, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_9, CSUM_UPDATE, csum_update, TYPES (llt, pt, u32t, 0))
+DEF_HELPER (LINUX_V4_9, SET_HASH_INVALID, set_hash_invalid, TYPES (vt, pt, 0))
+DEF_HELPER (LINUX_V4_10, GET_NUMA_NODE_ID, get_numa_node_id, TYPES (it, 0))
+DEF_HELPER (LINUX_V4_10, SKB_CHANGE_HEAD, skb_change_head, TYPES (it, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_10, XDP_ADJUST_HEAD, xdp_adjust_head, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_11, PROBE_READ_STR, probe_read_str, TYPES (it, pt, u32t, cpt, 0))
+DEF_HELPER (LINUX_V4_12, GET_SOCKET_COOKIE, get_socket_cookie, TYPES (it, pt, 0))
+DEF_HELPER (LINUX_V4_12, GET_SOCKET_UID, get_socket_uid, TYPES (ut, pt, 0))
+DEF_HELPER (LINUX_V4_13, SET_HASH, set_hash, TYPES (ut, pt, u32t, 0))
+DEF_HELPER (LINUX_V4_13, SETSOCKOPT, setsockopt, TYPES (it, pt, it, it, pt, it, 0))
+DEF_HELPER (LINUX_V4_13, SKB_ADJUST_ROOM, skb_adjust_room, TYPES (it, pt, st, u32t, ullt, 0))
+DEF_HELPER (LINUX_V4_14, REDIRECT_MAP, redirect_map, TYPES (it, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_14, SK_REDIRECT_MAP, sk_redirect_map, TYPES (it, pt, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_14, SOCK_MAP_UPDATE, sock_map_update, TYPES (it, pt, pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V4_15, XDP_ADJUST_META, xdp_adjust_meta, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_15, PERF_EVENT_READ_VALUE, perf_event_read_value,
+	    TYPES (it, pt, ullt, pt, ut, 0))
+DEF_HELPER (LINUX_V4_15, PERF_PROG_READ_VALUE, perf_prog_read_value,
+	    TYPES (it, pt, pt, ut, 0))
+DEF_HELPER (LINUX_V4_15, GETSOCKOPT, getsockopt, TYPES (it, pt, it, it, pt, it, 0))
+
+DEF_HELPER (LINUX_V4_16, OVERRIDE_RETURN, override_return, TYPES (it, pt, ult, 0))
+DEF_HELPER (LINUX_V4_16, SOCK_OPS_CB_FLAGS_SET, sock_ops_cb_flags_set, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_17, MSG_REDIRECT_MAP, msg_redirect_map, TYPES (it, pt, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_17, MSG_APPLY_BYTES, msg_apply_bytes, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_17, MSG_CORK_BYTES, msg_cork_bytes, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_17, MSG_PULL_DATA, msg_pull_data, TYPES (it, pt, it, it, it, 0))
+DEF_HELPER (LINUX_V4_17, BIND, bind, TYPES (it, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_18, XDP_ADJUST_TAIL, xdp_adjust_tail, TYPES (it, pt, it, 0))
+DEF_HELPER (LINUX_V4_18, SKB_GET_XFRM_STATE,
+	    skb_get_xfrm_state, TYPES (it, pt, it, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_18, GET_STACK, get_stack, TYPES (it, pt, pt, it, it, 0))
+DEF_HELPER (LINUX_V4_18, SKB_LOAD_BYTES_RELATIVE, skb_load_bytes_relative,
+	    TYPES (it, pt, it, pt, it, ut, 0))
+DEF_HELPER (LINUX_V4_18, FIB_LOOKUP, fib_lookup, TYPES (it, pt, pt, it, ut, 0))
+DEF_HELPER (LINUX_V4_18, SOCK_HASH_UPDATE, sock_hash_update, TYPES (it, pt, pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V4_18, MSG_REDIRECT_HASH, msg_redirect_hash, TYPES (it, pt, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_18, SK_REDIRECT_HASH, sk_redirect_hash, TYPES (it, pt, pt, pt, it, 0))
+DEF_HELPER (LINUX_V4_18, LWT_PUSH_ENCAP, lwt_push_encap, TYPES (it, pt, ut, pt, ut, 0))
+DEF_HELPER (LINUX_V4_18, LWT_SEG6_STORE_BYTES, lwt_seg6_store_bytes,
+	    TYPES (it, pt, ut, pt, ut, 0))
+DEF_HELPER (LINUX_V4_18, LWT_SEG6_ADJUST_SRH, lwt_seg6_adjust_srh, TYPES (it, pt, ut, ut, 0))
+DEF_HELPER (LINUX_V4_18, LWT_SEG6_ACTION, lwt_seg6_action, TYPES (it, pt, ut, pt, ut, 0))
+DEF_HELPER (LINUX_V4_18, RC_REPEAT, rc_repeat, TYPES (it, pt, 0))
+DEF_HELPER (LINUX_V4_18, RC_KEYDOWN, rc_keydown, TYPES (it, pt, ut, ullt, ut, 0))
+DEF_HELPER (LINUX_V4_18, SKB_CGROUP_ID, skb_cgroup_id, TYPES (ullt, pt, 0))
+DEF_HELPER (LINUX_V4_18, GET_CURRENT_CGROUP_ID, get_current_cgroup_id, TYPES (ullt, 0))
+DEF_HELPER (LINUX_V4_19, GET_LOCAL_STORAGE, get_local_storage, TYPES (pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V4_19, SK_SELECT_REUSEPORT, sk_select_reuseport,
+	    TYPES (it, pt, pt, pt, ut, 0))
+DEF_HELPER (LINUX_V4_19, SKB_ANCESTOR_CGROUP_ID, skb_ancestor_cgroup_id,
+	    TYPES (ullt, pt, it, 0))
+DEF_HELPER (LINUX_V4_20, SK_LOOKUP_TCP, sk_lookup_tcp, TYPES (pt, pt, pt, it, ullt, ullt, 0))
+DEF_HELPER (LINUX_V4_20, SK_LOOKUP_UDP, sk_lookup_udp, TYPES (pt, pt, pt, it, ullt, ullt, 0))
+DEF_HELPER (LINUX_V4_20, SK_RELEASE, sk_release, TYPES (it, pt, 0))
+DEF_HELPER (LINUX_V4_20, MAP_PUSH_ELEM, map_push_elem, TYPES (it, pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V4_20, MAP_POP_ELEM, map_pop_elem, TYPES (it, pt, pt, 0))
+DEF_HELPER (LINUX_V4_20, MAP_PEEK_ELEM, map_peek_elem, TYPES (it, pt, pt, 0))
+DEF_HELPER (LINUX_V4_20, MSG_PUSH_DATA, msg_push_data, TYPES (it, pt, it, it, it, 0))
+DEF_HELPER (LINUX_V5_0, MSG_POP_DATA, msg_pop_data, TYPES (it, pt, it, it, it, 0))
+DEF_HELPER (LINUX_V5_0, RC_POINTER_REL, rc_pointer_rel, TYPES (it, pt, it, it, 0))
+DEF_HELPER (LINUX_V5_1, SPIN_LOCK, spin_lock, TYPES (vt, pt, 0))
+DEF_HELPER (LINUX_V5_1, SPIN_UNLOCK, spin_unlock, TYPES (vt, pt, 0))
+DEF_HELPER (LINUX_V5_1, SK_FULLSOCK, sk_fullsock, TYPES (pt, pt, 0))
+DEF_HELPER (LINUX_V5_1, TCP_SOCK, tcp_sock, TYPES (pt, pt, 0))
+DEF_HELPER (LINUX_V5_1, SKB_ECN_SET_CE, skb_ecn_set_ce, TYPES (it, pt, 0))
+DEF_HELPER (LINUX_V5_1, GET_LISTENER_SOCK, get_listener_sock, TYPES (pt, pt, 0))
+DEF_HELPER (LINUX_V5_2, SKC_LOOKUP_TCP, skc_lookup_tcp,
+	    TYPES (pt, pt, pt, u32t, u64t, u64t, 0))
+DEF_HELPER (LINUX_V5_2, TCP_CHECK_SYNCOOKIE, tcp_check_syncookie,
+	    TYPES (it, pt, pt, u32t, pt, u32t, 0))
+DEF_HELPER (LINUX_V5_2, SYSCTL_GET_NAME, sysctl_get_name, TYPES (it, pt, pt, ullt, u64t, 0))
+DEF_HELPER (LINUX_V5_2, SYSCTL_GET_CURRENT_VALUE, sysctl_get_current_value,
+	    TYPES (it, pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V5_2, SYSCTL_GET_NEW_VALUE, sysctl_get_new_value,
+	    TYPES (it, pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V5_2, SYSCTL_SET_NEW_VALUE, sysctl_set_new_value,
+	    TYPES (it, pt, pt, ullt, 0))
+DEF_HELPER (LINUX_V5_2, STRTOL, strtol, TYPES (it, cst, ullt, u64t, pt, 0))
+DEF_HELPER (LINUX_V5_2, STRTOUL, strtoul, TYPES (it, pt, ullt, u64t, pt, 0))
+DEF_HELPER (LINUX_V5_2, SK_STORAGE_GET, sk_storage_get, TYPES (pt, pt, pt, pt, u64t, 0))
+DEF_HELPER (LINUX_V5_2, SK_STORAGE_DELETE, sk_storage_delete, TYPES (it, pt, pt, 0))
+
+/*
+Local variables:
+mode:c
+End:
+*/
diff --git a/gcc/config/bpf/bpf-helpers.h b/gcc/config/bpf/bpf-helpers.h
new file mode 100644
index 00000000000..14275439446
--- /dev/null
+++ b/gcc/config/bpf/bpf-helpers.h
@@ -0,0 +1,327 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* The purpose of this file is to provide a compatiblity layer with
+   the Linux kernel bpf_helpers.h header that is located in
+   linux/tools/testing/selftests/bpf/bpf_helpers.h.  That file is
+   currently llvm-specific.  */
+
+#ifndef __BPF_HELPERS_H
+#define __BPF_HELPERS_H
+
+#define SEC(NAME) __attribute__((section(NAME), used))
+
+/* Flags used in some kernel helpers.  */
+
+#define BPF_ANY     0
+#define BPF_NOEXIST 1
+#define BPF_EXIST   2
+
+#define BPF_F_LOCK 4
+#define BPF_F_NO_COMMON_LRU (1U << 1)
+#define BPF_F_NUMA_NODE (1U << 2)
+
+/* Functions to call kernel helpers.  We provide the "standard" bpf_*
+   names as synonyms of the corresponding GCC builtins.  In some
+   cases, where non-void pointers are passed to the helper, inline
+   functions are used to achieve proper type checking.  */
+
+#ifndef KERNEL_VERSION
+# define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,0,0)
+
+#define bpf_map_lookup_elem	__builtin_bpf_helper_map_lookup_elem
+#define bpf_map_update_elem	__builtin_bpf_helper_map_update_elem
+#define bpf_map_delete_elem	__builtin_bpf_helper_map_delete_elem
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,1,0)
+
+#define bpf_probe_read		__builtin_bpf_helper_probe_read
+#define bpf_ktime_get_ns	__builtin_bpf_helper_ktime_get_ns
+#define bpf_trace_printk	__builtin_bpf_helper_trace_printk
+#define bpf_get_prandom_u32	__builtin_bpf_helper_get_prandom_u32
+#define bpf_get_smp_processor_id __builtin_bpf_helper_get_smp_processor_id
+#define bpf_skb_store_bytes	__builtin_bpf_helper_skb_store_bytes
+#define bpf_l3_csum_replace	__builtin_bpf_helper_l3_csum_replace
+#define bpf_l4_csum_replace	__builtin_bpf_helper_l4_csum_replace
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,2,0)
+
+#define bpf_tail_call		__builtin_bpf_helper_tail_call
+#define bpf_clone_redirect	__builtin_bpf_helper_clone_redirect
+#define bpf_get_current_pid_tgid __builtin_bpf_helper_get_current_pid_tgid
+#define bpf_get_current_uid_gid  __builtin_bpf_helper_get_current_uid_gid
+#define bpf_get_current_comm	__builtin_bpf_helper_get_current_comm
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,3,0)
+
+#define bpf_get_cgroup_classid	__builtin_bpf_helper_get_cgroup_classid
+#define bpf_skb_vlan_push	__builtin_bpf_helper_skb_vlan_push
+#define bpf_skb_vlan_pop	__builtin_bpf_helper_skb_vlan_pop
+#define bpf_skb_get_tunnel_key	__builtin_bpf_helper_skb_get_tunnel_key
+#define bpf_skb_set_tunnel_key	__builtin_bpf_helper_skb_set_tunnel_key
+#define bpf_perf_event_read	__builtin_bpf_helper_perf_event_read
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,4,0)
+
+#define bpf_redirect		__builtin_bpf_helper_redirect
+#define bpf_get_route_realm	__builtin_bpf_helper_get_route_realm
+#define bpf_perf_event_output	__builtin_bpf_helper_perf_event_output
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,5,0)
+
+#define bpf_skb_load_bytes	__builtin_bpf_helper_skb_load_bytes
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,6,0)
+
+#define bpf_get_stackid		__builtin_bpf_helper_get_stackid
+#define bpf_csum_diff		__builtin_bpf_helper_csum_diff
+#define bpf_skb_get_tunnel_opt	__builtin_bpf_helper_skb_get_tunnel_opt
+#define bpf_skb_set_tunnel_opt	__builtin_bpf_helper_skb_set_tunnel_opt
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,8,0)
+
+#define bpf_skb_change_proto	__builtin_bpf_helper_skb_change_proto
+#define bpf_skb_change_type	__builtin_bpf_helper_skb_change_type
+#define bpf_skb_under_cgroup	__builtin_bpf_helper_skb_under_cgroup
+#define bpf_get_hash_recalc	__builtin_bpf_helper_get_hash_recalc
+#define bpf_get_current_task	__builtin_bpf_helper_get_current_task
+#define bpf_probe_write_user	__builtin_bpf_helper_probe_write_user
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,9,0)
+
+#define bpf_current_task_under_cgroup __builtin_bpf_helper_current_task_under_cgroup
+#define bpf_skb_change_tail	__builtin_bpf_helper_skb_change_tail
+#define bpf_skb_pull_data	__builtin_bpf_helper_skb_pull_data
+#define bpf_csum_update		__builtin_bpf_helper_csum_update
+#define bpf_set_hash_invalid	__builtin_bpf_helper_set_hash_invalid
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,10,0)
+
+#define bpf_get_numa_node_id	__builtin_bpf_helper_get_numa_node_id
+#define bpf_skb_change_head	__builtin_bpf_helper_skb_change_head
+#define bpf_xdp_adjust_head	__builtin_bpf_helper_xdp_adjust_head
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,11,0)
+
+#define bpf_probe_read_str	__builtin_bpf_helper_probe_read_str
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,12,0)
+
+#define bpf_get_socket_cookie	__builtin_bpf_helper_get_socket_cookie
+#define bpf_get_socket_uid	__builtin_bpf_helper_get_socket_uid
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,13,0)
+
+#define bpf_set_hash		__builtin_bpf_helper_set_hash
+#define bpf_setsockopt		__builtin_bpf_helper_setsockopt
+#define bpf_skb_adjust_room	__builtin_bpf_helper_skb_adjust_room
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,14,0)
+
+#define bpf_redirect_map	__builtin_bpf_helper_redirect_map
+#define bpf_sk_redirect_map	__builtin_bpf_helper_sk_redirect_map
+#define bpf_sock_map_update	__builtin_bpf_helper_sock_map_update
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,15,0)
+
+#define bpf_perf_event_read_value __builtin_bpf_helper_perf_event_read_value
+#define bpf_perf_prog_read_value  __builtin_bpf_helper_perf_prog_read_value
+#define bpf_getsockopt		  __builtin_bpf_helper_getsockopt
+#define bpf_xdp_adjust_meta	__builtin_bpf_helper_xdp_adjust_meta
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,16,0)
+
+#define bpf_override_return	__builtin_bpf_helper_override_return
+#define bpf_sock_ops_cb_flags_set __builtin_bpf_helper_sock_ops_cb_flags_set
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,17,0)
+
+#define bpf_msg_redirect_map	__builtin_bpf_helper_msg_redirect_map
+#define bpf_msg_apply_bytes	__builtin_bpf_helper_msg_apply_bytes
+#define bpf_msg_cork_bytes	__builtin_bpf_helper_msg_cork_bytes
+#define bpf_pull_data		__builtin_bpf_helper_pull_data
+#define bpf_bind		__builtin_bpf_helper_bpf_bind
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,18,0)
+
+#define bpf_xdp_adjust_tail	__builtin_bpf_helper_xdp_adjust_tail
+#define bpf_skb_get_xfrm_state	__builtin_bpf_helper_skb_get_xfrm_state
+#define bpf_get_stack		__builtin_bpf_helper_get_stack
+#define bpf_skb_load_bytes_relative __builtin_bpf_helper_skb_load_bytes_relative
+#define bpf_sock_hash_update	__builtin_bpf_helper_sock_hash_update
+#define bpf_msg_redirect_hash	__builtin_bpf_helper_msg_redirect_hash
+#define bpf_sk_redirect_hash	__builtin_bpf_helper_sk_redirect_hash
+#define bpf_lwt_push_encap		__builtin_bpf_helper_lwt_push_encap
+#define bpf_lwt_seg6_store_bytes	__builtin_bpf_helper_lwt_seg6_store_bytes
+#define bpf_lwt_seg6_adjust_srh		__builtin_bpf_helper_lwt_seg6_adjust_srh
+#define bpf_lwt_seg6_action		__builtin_bpf_helper_lwt_seg6_action
+#define bpf_rc_repeat			__builtin_bpf_helper_rc_repeat
+#define bpf_rc_keydown			__builtin_bpf_helper_rc_keydown
+#define bpf_skb_cgroup_id		__builtin_bpf_helper_skb_cgroup_id
+#define bpf_get_current_cgroup_id	__builtin_bpf_helper_get_current_cgroup_id
+
+static inline int
+bpf_fib_lookup (void *ctx, struct bpf_fib_lookup *param, int plen,
+		unsigned int flags)
+{
+  return __builtin_bpf_helper_fib_lookup (ctx, (void *) param, plen, flags);
+}
+
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,19,0)
+
+#define bpf_get_local_storage	__builtin_bpf_helper_get_local_storage
+#define bpf_sk_select_reuseport	__builtin_bpf_helper_sk_select_reuseport
+#define bpf_skb_ancestor_cgroup_id	__builtin_bpf_helper_skb_ancestor_cgroup_id
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,20,0)
+
+#define bpf_sk_release		__builtin_bpf_helper_sk_release
+#define bpf_map_push_elem	__builtin_bpf_helper_map_push_elem
+#define bpf_map_pop_elem	__builtin_bpf_helper_map_pop_elem
+#define bpf_map_peek_elem	__builtin_bpf_helper_map_peek_elem
+#define bpf_msg_push_data	__builtin_bpf_helper_msg_push_data
+
+static inline struct bpf_sock *
+bpf_sk_lookup_tcp (void *ctx, struct bpf_sock_tuple *tuple,
+		   int size, unsigned long long netns_id,
+		   unsigned long long flags)
+{
+  return
+    (struct bpf_sock *) __builtin_bpf_helper_sk_lookup_tcp (ctx,
+							    (void *) tuple,
+							    size,
+							    netns_id, flags);
+}
+
+static inline struct bpf_sock *
+bpf_sk_lookup_udp (void *ctx, struct bpf_sock_tuple *tuple,
+		   int size, unsigned long long netns_id,
+		   unsigned long long flags)
+{
+  return
+    (struct bpf_sock *) __builtin_bpf_helper_sk_lookup_udp (ctx,
+							    (void *) tuple,
+							    size,
+							    netns_id, flags);
+}
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (5,0,0)
+
+#define bpf_msg_pop_data	__builtin_bpf_helper_pop_data
+#define bpf_rc_pointer_rel	__builtin_bpf_helper_rc_pointer_rel
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (5,1,0)
+
+#define bpf_spin_lock		__builtin_bpf_helper_spin_lock
+#define bpf_spin_unlock		__builtin_bpf_helper_spin_unlock
+#define bpf_skb_ecn_set_ce	__builtin_bpf_helper_skb_ecn_set_ce
+
+static inline struct bpf_sock *
+bpf_sk_fullsock (struct bpf_sock *sk)
+{
+  return
+    (struct bpf_sock *) __builtin_bpf_helper_sk_fullsock ((void *) sk);
+}
+
+static inline struct bpf_sock *
+bpf_tcp_sock (struct bpf_sock *sk)
+{
+  return
+    (struct bpf_sock *) __builtin_bpf_helper_tcp_sock ((void *) sk);
+}
+
+static inline struct bpf_sock *
+bpf_get_listener_sock (struct bpf_sock *sk)
+{
+  return
+    (struct bpf_sock *) __builtin_bpf_helper_get_listener_sock ((void *) sk);
+}
+
+#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (5,2,0)
+
+
+#endif /* 5.2 */
+#endif /* 5.1 */
+#endif /* 5.0 */
+#endif /* 4.20 */
+#endif /* 4.19 */
+#endif /* 4.18 */
+#endif /* 4.17 */
+#endif /* 4.16 */
+#endif /* 4.15 */
+#endif /* 4.14 */
+#endif /* 4.13 */
+#endif /* 4.12 */
+#endif /* 4.11 */
+#endif /* 4.10 */
+#endif /* 4.9 */
+#endif /* 4.8 */
+#endif /* 4.6 */
+#endif /* 4.5 */
+#endif /* 4.4 */
+#endif /* 4.3 */
+#endif /* 4.2 */
+#endif /* 4.1 */
+#endif /* 4.0 */
+
+/* Functions to emit BPF_LD_ABS and BPF_LD_IND instructions.  We
+   provide the "standard" names as synonyms of the corresponding GCC
+   builtins.  Note how the SKB argument is ignored.  */
+
+static inline long long
+load_byte (void *skb __attribute__ ((unused)),
+	   unsigned long long off)
+{
+  return __builtin_bpf_load_byte (off);
+}
+
+static inline long long
+load_half (void *skb __attribute__ ((unused)),
+	   unsigned long long off)
+{
+  return __builtin_bpf_load_half (off);
+}
+
+static inline long long
+load_word (void *skb __attribute__ ((unused)),
+	   unsigned long long off)
+{
+  return __builtin_bpf_load_word (off);
+}
+
+struct bpf_map_def
+{
+  unsigned int type;
+  unsigned int key_size;
+  unsigned int value_size;
+  unsigned int max_entries;
+  unsigned int map_flags;
+  unsigned int inner_map_idx;
+  unsigned int numa_node;
+};
+
+#endif /* ! __BPF_HELPERS_H */
diff --git a/gcc/config/bpf/bpf-opts.h b/gcc/config/bpf/bpf-opts.h
new file mode 100644
index 00000000000..9f210a19c4a
--- /dev/null
+++ b/gcc/config/bpf/bpf-opts.h
@@ -0,0 +1,56 @@
+/* Definitions for option handling for eBPF.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef BPF_OPTS_H
+#define BPF_OPTS_H
+
+/* Supported versions of the Linux kernel.  */
+enum bpf_kernel_version
+{
+  /* Linux 4.x */
+  LINUX_V4_0,
+  LINUX_V4_1,
+  LINUX_V4_2,
+  LINUX_V4_3,
+  LINUX_V4_4,
+  LINUX_V4_5,
+  LINUX_V4_6,
+  LINUX_V4_7,
+  LINUX_V4_8,
+  LINUX_V4_9,
+  LINUX_V4_10,
+  LINUX_V4_11,
+  LINUX_V4_12,
+  LINUX_V4_13,
+  LINUX_V4_14,
+  LINUX_V4_15,
+  LINUX_V4_16,
+  LINUX_V4_17,
+  LINUX_V4_18,
+  LINUX_V4_19,
+  LINUX_V4_20,
+  /* Linux 5.x  */
+  LINUX_V5_0,
+  LINUX_V5_1,
+  LINUX_V5_2,
+  LINUX_LATEST = LINUX_V5_2,
+  LINUX_NATIVE,
+};
+
+#endif /* ! BPF_OPTS_H */
diff --git a/gcc/config/bpf/bpf-protos.h b/gcc/config/bpf/bpf-protos.h
new file mode 100644
index 00000000000..3a835f4f12e
--- /dev/null
+++ b/gcc/config/bpf/bpf-protos.h
@@ -0,0 +1,33 @@
+/* Definition of eBPF target for GNU compiler.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_BPF_PROTOS_H
+#define GCC_BPF_PROTOS_H
+
+/* Routines implemented in bpf.c.  */
+
+extern HOST_WIDE_INT bpf_initial_elimination_offset (int, int);
+extern const char *bpf_output_call (rtx);
+extern void bpf_target_macros (cpp_reader *);
+extern void bpf_print_operand (FILE *, rtx, int);
+extern void bpf_print_operand_address (FILE *, rtx);
+extern void bpf_expand_prologue (void);
+extern void bpf_expand_epilogue (void);
+
+#endif /* ! GCC_BPF_PROTOS_H */
diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c
new file mode 100644
index 00000000000..8b2a59273fe
--- /dev/null
+++ b/gcc/config/bpf/bpf.c
@@ -0,0 +1,948 @@
+/* Subroutines used for code generation for eBPF.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#define IN_TARGET_CODE 1
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "regs.h"
+#include "insn-config.h"
+#include "insn-attr.h"
+#include "recog.h"
+#include "output.h"
+#include "alias.h"
+#include "tree.h"
+#include "stringpool.h"
+#include "attribs.h"
+#include "varasm.h"
+#include "stor-layout.h"
+#include "calls.h"
+#include "function.h"
+#include "explow.h"
+#include "memmodel.h"
+#include "emit-rtl.h"
+#include "reload.h"
+#include "tm_p.h"
+#include "target.h"
+#include "target-def.h"
+#include "basic-block.h"
+#include "expr.h"
+#include "optabs.h"
+#include "bitmap.h"
+#include "df.h"
+#include "c-family/c-common.h"
+#include "diagnostic.h"
+#include "builtins.h"
+#include "predict.h"
+#include "langhooks.h"
+
+/* Per-function machine data.  */
+struct GTY(()) machine_function
+{
+  /* Number of bytes saved on the stack for local variables.  */
+  int local_vars_size;
+
+  /* Number of bytes saved on the stack for callee-saved
+     registers.  */
+  int callee_saved_reg_size;
+};
+
+/* Data structures for the eBPF specific built-ins.  */
+
+/* Maximum number of arguments taken by a builtin function, plus
+   one.  */
+#define BPF_BUILTIN_MAX_ARGS 5
+
+enum bpf_builtins
+{
+  BPF_BUILTIN_UNUSED = 0,
+  /* Built-ins for kernel helpers.  */
+#define DEF_HELPER(V,D,N,T) BPF_BUILTIN_HELPER_##D,
+#  include "bpf-helpers.def"
+#undef DEF_HELPER
+  BPF_BUILTIN_HELPER_MAX,
+  /* Built-ins for non-generic loads and stores.  */
+  BPF_BUILTIN_LOAD_BYTE = BPF_BUILTIN_HELPER_MAX,
+  BPF_BUILTIN_LOAD_HALF,
+  BPF_BUILTIN_LOAD_WORD,
+  BPF_BUILTIN_MAX,
+};
+
+/* This table is indexed by an enum bpf_builtin.  */
+static const char *bpf_helper_names[] =
+{
+  NULL,
+#define DEF_HELPER(V,D,N,T) #N,
+#  include "bpf-helpers.def"
+#undef DEF_HELPER
+  NULL,
+  NULL,
+  NULL,
+  NULL
+};
+
+/* Return the builtin code corresponding to the kernel helper builtin
+   __builtin_NAME, or 0 if the name doesn't correspond to a kernel
+   helper builtin.  */
+
+static inline int
+bpf_helper_code (const char *name)
+{
+  int i;
+
+  for (i = 1; i < BPF_BUILTIN_HELPER_MAX; ++i)
+    if (strcmp (name, bpf_helper_names[i]) == 0)
+      return i;
+
+  return 0;
+}
+
+static GTY (()) tree bpf_builtins[(int) BPF_BUILTIN_MAX];
+
+/* Initialize the per-function machine status.  */
+
+static struct machine_function *
+bpf_init_machine_status (void)
+{
+  /* Note this initializes all fields to 0, which is just OK for
+     us.  */
+  return ggc_cleared_alloc<machine_function> ();
+}
+
+/* Override options and do some other initialization.  */
+
+static void
+bpf_option_override (void)
+{
+  /* Set the initializer for the per-function status structure.  */
+  init_machine_status = bpf_init_machine_status;
+}
+
+#undef TARGET_OPTION_OVERRIDE
+#define TARGET_OPTION_OVERRIDE bpf_option_override
+
+/* Define target-specific CPP macros.  This function in used in the
+   definition of TARGET_CPU_CPP_BUILTINS in bpf.h */
+
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+
+void
+bpf_target_macros (cpp_reader *pfile)
+{
+  builtin_define ("__BPF__");
+  
+  if (TARGET_BIG_ENDIAN)
+    builtin_define ("__BPF_BIG_ENDIAN__");
+  else
+    builtin_define ("__BPF_LITTLE_ENDIAN__");
+
+  /* Define BPF_KERNEL_VERSION_CODE */
+  {
+    const char *version_code;
+    char *kernel_version_code;
+
+    switch (bpf_kernel)
+      {
+      case LINUX_V4_0: version_code = "0x40000"; break;
+      case LINUX_V4_1: version_code = "0x40100"; break;
+      case LINUX_V4_2: version_code = "0x40200"; break;
+      case LINUX_V4_3: version_code = "0x40300"; break;
+      case LINUX_V4_4: version_code = "0x40400"; break;
+      case LINUX_V4_5: version_code = "0x40500"; break;
+      case LINUX_V4_6: version_code = "0x40600"; break;
+      case LINUX_V4_7: version_code = "0x40700"; break;
+      case LINUX_V4_8: version_code = "0x40800"; break;
+      case LINUX_V4_9: version_code = "0x40900"; break;
+      case LINUX_V4_10: version_code = "0x40a00"; break;
+      case LINUX_V4_11: version_code = "0x40b00"; break;
+      case LINUX_V4_12: version_code = "0x40c00"; break;
+      case LINUX_V4_13: version_code = "0x40d00"; break;
+      case LINUX_V4_14: version_code = "0x40e00"; break;
+      case LINUX_V4_15: version_code = "0x40f00"; break;
+      case LINUX_V4_16: version_code = "0x41000"; break;
+      case LINUX_V4_17: version_code = "0x42000"; break;
+      case LINUX_V4_18: version_code = "0x43000"; break;
+      case LINUX_V4_19: version_code = "0x44000"; break;
+      case LINUX_V4_20: version_code = "0x45000"; break;
+      case LINUX_V5_0: version_code = "0x50000"; break;
+      case LINUX_V5_1: version_code = "0x50100"; break;
+      case LINUX_V5_2: version_code = "0x50200"; break;
+      default:
+	gcc_unreachable ();      
+      }
+
+    kernel_version_code = ACONCAT (("__BPF_KERNEL_VERSION_CODE__=",
+				    version_code, NULL));
+    builtin_define (kernel_version_code);
+  }
+}
+
+/* Output assembly directives to switch to section NAME.  The section
+   should have attributes as specified by FLAGS, which is a bit mask
+   of the 'SECTION_*' flags defined in 'output.h'.  If DECL is
+   non-NULL, it is the 'VAR_DECL' or 'FUNCTION_DECL' with which this
+   section is associated.  */
+
+static void
+bpf_asm_named_section (const char *name,
+		       unsigned int flags ATTRIBUTE_UNUSED,
+		       tree decl ATTRIBUTE_UNUSED)
+{
+  fprintf (asm_out_file, "\t.section\t%s\n", name);
+}
+
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION bpf_asm_named_section
+
+/* Return an RTX representing the place where a function returns or
+   receives a value of data type RET_TYPE, a tree node representing a
+   data type.  */
+
+static rtx
+bpf_function_value (const_tree ret_type,
+		    const_tree fntype_or_decl,
+		    bool outgoing ATTRIBUTE_UNUSED)
+{
+  enum machine_mode mode;
+  int unsignedp;
+
+  mode = TYPE_MODE (ret_type);
+  if (INTEGRAL_TYPE_P (ret_type))
+    mode = promote_function_mode (ret_type, mode, &unsignedp,
+				  fntype_or_decl, 1);
+
+  return gen_rtx_REG (mode, BPF_R0);
+}
+
+#undef TARGET_FUNCTION_VALUE
+#define TARGET_FUNCTION_VALUE bpf_function_value
+
+/* Return true if REGNO is the number of a hard register in which the
+   values of called function may come back.  */
+
+static bool
+bpf_function_value_regno_p (const unsigned int regno)
+{
+  return (regno == BPF_R0);
+}
+
+#undef TARGET_FUNCTION_VALUE_REGNO_P
+#define TARGET_FUNCTION_VALUE_REGNO_P bpf_function_value_regno_p
+
+/* Compute the size of the function's stack frame, including the local
+   area and the register-save area.  */
+
+static void
+bpf_compute_frame_layout (void)
+{
+  int stack_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
+  int padding_locals, regno;
+
+  /* Set the space used in the stack by local variables.  This is
+     rounded up to respect the minimum stack alignment.  */
+  cfun->machine->local_vars_size = get_frame_size ();
+
+  padding_locals = cfun->machine->local_vars_size % stack_alignment;
+  if (padding_locals)
+    padding_locals = stack_alignment - padding_locals;
+
+  cfun->machine->local_vars_size += padding_locals;
+
+  /* Set the space used in the stack by callee-saved used registers in
+     the current function.  There is no need to round up, since the
+     registers are all 8 bytes wide.  */
+  for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
+    if ((!fixed_regs[regno]
+	 && df_regs_ever_live_p (regno)
+	 && !call_used_regs[regno])
+	|| (cfun->calls_alloca
+	    && regno == STACK_POINTER_REGNUM))
+      cfun->machine->callee_saved_reg_size += 8;
+
+  /* Check that the total size of the frame doesn't exceed the limit
+     imposed by eBPF.  */
+  if ((cfun->machine->local_vars_size
+       + cfun->machine->callee_saved_reg_size) > bpf_frame_limit)
+    {
+      static int stack_limit_exceeded = 0;
+
+      if (!stack_limit_exceeded)
+	error ("eBPF stack limit exceeded");
+      stack_limit_exceeded = 1;
+    }
+}
+
+#undef TARGET_COMPUTE_FRAME_LAYOUT
+#define TARGET_COMPUTE_FRAME_LAYOUT bpf_compute_frame_layout
+
+/* Expand to the instructions in a function prologue.  This function
+   is called when expanding the 'prologue' pattern in bpf.md.  */
+
+void
+bpf_expand_prologue (void)
+{
+  int regno, fp_offset;
+  rtx insn;
+  HOST_WIDE_INT size;
+
+  size = (cfun->machine->local_vars_size
+	  + cfun->machine->callee_saved_reg_size);
+  fp_offset = -cfun->machine->local_vars_size;
+
+  /* Save callee-saved hard registes.  The register-save-area starts
+     right after the local variables.  */
+  for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
+    {
+      if ((!fixed_regs[regno]
+	   && df_regs_ever_live_p (regno)
+	   && !call_used_regs[regno])
+	  || (cfun->calls_alloca
+	      && regno == STACK_POINTER_REGNUM))
+	{
+	  rtx mem;
+
+	  if (!IN_RANGE (fp_offset, -1 - 0x7fff, 0x7fff))
+	    /* This has been already reported as an error in
+	       bpf_compute_frame_layout. */
+	    break;
+	  else
+	    {
+	      mem = gen_frame_mem (DImode,
+				   plus_constant (DImode,
+						  hard_frame_pointer_rtx,
+						  fp_offset - 8));
+	      insn = emit_move_insn (mem, gen_rtx_REG (DImode, regno));
+	      RTX_FRAME_RELATED_P (insn) = 1;
+	      fp_offset -= 8;
+	    }
+	}
+    }
+
+  /* Set the stack pointer, if the function allocates space
+     dynamically.  Note that the value of %sp should be directly
+     derived from %fp, for the kernel verifier to track it as a stack
+     accessor.  */
+  if (cfun->calls_alloca)
+    {
+      insn = emit_move_insn (stack_pointer_rtx,
+			     hard_frame_pointer_rtx);
+      RTX_FRAME_RELATED_P (insn) = 1;
+      
+      if (size > 0)
+	{
+	  insn = emit_insn (gen_rtx_SET (stack_pointer_rtx,
+					 gen_rtx_PLUS (Pmode,
+						       stack_pointer_rtx,
+						       GEN_INT (-size))));
+	  RTX_FRAME_RELATED_P (insn) = 1;
+	}
+    }
+}
+
+/* Expand to the instructions in a function epilogue.  This function
+   is called when expanding the 'epilogue' pattern in bpf.md.  */
+
+void
+bpf_expand_epilogue (void)
+{
+  int regno, fp_offset;
+  rtx insn;
+
+  fp_offset = -cfun->machine->local_vars_size;
+
+  /* Restore callee-saved hard registes from the stack.  */
+  for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
+    {
+      if ((!fixed_regs[regno]
+	   && df_regs_ever_live_p (regno)
+	   && !call_used_regs[regno])
+	  || (cfun->calls_alloca
+	      && regno == STACK_POINTER_REGNUM))
+	{
+	  rtx mem;
+
+	  if (!IN_RANGE (fp_offset, -1 - 0x7fff, 0x7fff))
+	    /* This has been already reported as an error in
+	       bpf_compute_frame_layout. */
+	    break;
+	  else
+	    {
+	      mem = gen_frame_mem (DImode,
+				   plus_constant (DImode,
+						  hard_frame_pointer_rtx,
+						  fp_offset - 8));
+	      insn = emit_move_insn (gen_rtx_REG (DImode, regno), mem);
+	      RTX_FRAME_RELATED_P (insn) = 1;
+	      fp_offset -= 8;
+	    }
+	}
+    }
+
+  emit_jump_insn (gen_exit ());
+}
+
+/* Return the initial difference between the specified pair of
+   registers.  The registers that can figure in FROM, and TO, are
+   specified by ELIMINABLE_REGS in bpf.h.
+
+   This function is used in the definition of
+   INITIAL_ELIMINATION_OFFSET in bpf.h  */
+
+HOST_WIDE_INT
+bpf_initial_elimination_offset (int from, int to)
+{
+  HOST_WIDE_INT ret;
+
+  if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
+    ret = (cfun->machine->local_vars_size
+	   + cfun->machine->callee_saved_reg_size);
+  else if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM)
+    ret = 0;
+  else
+    gcc_unreachable ();
+
+  return ret;
+}
+
+/* Return the number of consecutive hard registers, starting at
+   register number REGNO, required to hold a value of mode MODE.  */
+
+static unsigned int
+bpf_hard_regno_nregs (unsigned int regno ATTRIBUTE_UNUSED,
+		      enum machine_mode mode)
+{
+  return CEIL (GET_MODE_SIZE (mode), UNITS_PER_WORD);
+}
+
+#undef TARGET_HARD_REGNO_NREGS
+#define TARGET_HARD_REGNO_NREGS bpf_hard_regno_nregs
+
+/* Return true if it is permissible to store a value of mode MODE in
+   hard register number REGNO, or in several registers starting with
+   that one.  */
+
+static bool
+bpf_hard_regno_mode_ok (unsigned int regno ATTRIBUTE_UNUSED,
+			enum machine_mode mode)
+{
+  switch (mode)
+    {
+    case E_SImode:
+    case E_DImode:
+    case E_HImode:
+    case E_QImode:
+    case E_TImode:
+    case E_SFmode:
+    case E_DFmode:
+      return true;
+    default:
+      return false;
+    }
+}
+
+#undef TARGET_HARD_REGNO_MODE_OK
+#define TARGET_HARD_REGNO_MODE_OK bpf_hard_regno_mode_ok
+
+/* Return true if a function must have and use a frame pointer.  */
+
+static bool
+bpf_frame_pointer_required (void)
+{
+  /* We do not have a stack pointer, so we absolutely depend on the
+     frame-pointer in order to access the stack... and fishes walk and
+     pigs fly glglgl */
+  return true;
+}
+
+#undef TARGET_FRAME_POINTER_REQUIRED
+#define TARGET_FRAME_POINTER_REQUIRED bpf_frame_pointer_required
+
+/* Return `true' if the given RTX X is a valid base for an indirect
+   memory access.  STRICT has the same meaning than in
+   bpf_legitimate_address_p.  */
+
+static inline bool
+bpf_address_base_p (rtx x, bool strict)
+{
+  return (GET_CODE (x) == REG
+	  && (REGNO (x) < 11
+	      || (!strict && REGNO (x) >= FIRST_PSEUDO_REGISTER)));
+}
+
+/* Return true if X (a RTX) is a legitimate memory address on the
+   target machine for a memory operand of mode MODE.  */
+
+static bool
+bpf_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
+			  rtx x,
+			  bool strict)
+{
+  switch (GET_CODE (x))
+    {
+    case REG:
+      return bpf_address_base_p (x, strict);
+
+    case PLUS:
+      {
+	/* Accept (PLUS ADDR_BASE CONST_INT), provided CONST_INT fits
+	   in a signed 16-bit.
+
+	   Note that LABEL_REF and SYMBOL_REF are not allowed in
+	   REG+IMM addresses, because it is almost certain they will
+	   overload the offset field.  */
+
+	rtx x0 = XEXP (x, 0);
+	rtx x1 = XEXP (x, 1);
+	
+	if (bpf_address_base_p (x0, strict) && GET_CODE (x1) == CONST_INT)
+	  return IN_RANGE (INTVAL (x1), -1 - 0x7fff, 0x7fff);
+
+	break;
+      }
+    default:
+      break;
+    }
+
+  return false;
+}
+
+#undef TARGET_LEGITIMATE_ADDRESS_P
+#define TARGET_LEGITIMATE_ADDRESS_P bpf_legitimate_address_p
+
+/* Describe the relative costs of RTL expressions.  Return true when
+   all subexpressions of X have been processed, and false when
+   `rtx_cost' should recurse.  */
+
+static bool
+bpf_rtx_costs (rtx x ATTRIBUTE_UNUSED,
+	       enum machine_mode mode ATTRIBUTE_UNUSED,
+	       int outer_code ATTRIBUTE_UNUSED,
+	       int opno ATTRIBUTE_UNUSED,
+               int *total ATTRIBUTE_UNUSED,
+	       bool speed ATTRIBUTE_UNUSED)
+{
+  /* To be written.  */
+  return false;
+}
+
+#undef TARGET_RTX_COSTS
+#define TARGET_RTX_COSTS bpf_rtx_costs
+
+/* Return true if an argument at the position indicated by CUM should
+   be passed by reference.  If the hook returns true, a copy of that
+   argument is made in memory and a pointer to the argument is passed
+   instead of the argument itself.  */
+
+static bool
+bpf_pass_by_reference (cumulative_args_t cum ATTRIBUTE_UNUSED,
+		       const function_arg_info &arg)
+{
+  unsigned num_bytes = arg.type_size_in_bytes ();
+
+  /* Pass aggregates and values bigger than 5 words by reference.
+     Everything else is passed by copy.  */
+  return (arg.aggregate_type_p () || (num_bytes > 8*5));
+}
+
+#undef TARGET_PASS_BY_REFERENCE
+#define TARGET_PASS_BY_REFERENCE bpf_pass_by_reference
+
+/* Return a RTX indicating whether a function argument is passed in a
+   register and if so, which register.  */
+
+static rtx
+bpf_function_arg (cumulative_args_t ca, const function_arg_info &arg)
+{
+  CUMULATIVE_ARGS *cum = get_cumulative_args (ca);
+
+  if (*cum < 5)
+    return gen_rtx_REG (arg.mode, *cum + 1);
+  else
+    /* An error will be emitted for this in
+       bpf_function_arg_advance.  */
+    return NULL_RTX;
+}
+
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG bpf_function_arg
+
+/* Update the summarizer variable pointed by CA to advance past an
+   argument in the argument list.  */
+
+static void
+bpf_function_arg_advance (cumulative_args_t ca,
+			  const function_arg_info &arg)
+{
+  CUMULATIVE_ARGS *cum = get_cumulative_args (ca);
+  unsigned num_bytes = arg.type_size_in_bytes ();
+  unsigned num_words = CEIL (num_bytes, UNITS_PER_WORD);
+
+  if (*cum <= 5 && *cum + num_words > 5)
+    error ("too many function arguments for eBPF");
+
+  *cum += num_words;
+}
+
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE bpf_function_arg_advance
+
+/* Output the assembly code for a constructor.  Since eBPF doesn't
+   support indirect calls, constructors are not supported.  */
+
+static void
+bpf_output_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
+{
+  tree decl = SYMBOL_REF_DECL (symbol);
+
+  if (decl)
+    sorry_at (DECL_SOURCE_LOCATION (decl),
+	      "no constructors");
+  else
+    sorry ("no constructors");
+}
+
+#undef TARGET_ASM_CONSTRUCTOR
+#define TARGET_ASM_CONSTRUCTOR bpf_output_constructor
+
+/* Output the assembly code for a destructor.  Since eBPF doesn't
+   support indirect calls, destructors are not supported.  */
+
+static void
+bpf_output_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
+{
+  tree decl = SYMBOL_REF_DECL (symbol);
+
+  if (decl)
+    sorry_at (DECL_SOURCE_LOCATION (decl),
+	      "no destructors");
+  else
+    sorry ("no destructors");
+}
+
+#undef TARGET_ASM_DESTRUCTOR
+#define TARGET_ASM_DESTRUCTOR bpf_output_destructor
+
+/* Return the appropriate instruction to CALL to a function.  TARGET
+   is an RTX denoting the address of the called function.
+
+   The main purposes of this function are:
+   - To reject indirect CALL instructions, which are not supported by
+     eBPF.
+   - To recognize calls to kernel helper functions and emit the
+     corresponding CALL N instruction.
+
+   This function is called from the expansion of the 'call' pattern in
+   bpf.md.  */
+
+const char *
+bpf_output_call (rtx target)
+{
+  rtx xops[1];
+
+  switch (GET_CODE (target))
+    {
+    case CONST_INT:
+      output_asm_insn ("call\t%0", &target);
+      break;
+    case SYMBOL_REF:
+      {
+	const char *function_name = XSTR (target, 0);
+	int code;
+      
+	if (strncmp (function_name, "__builtin_bpf_helper_", 21) == 0
+	    && ((code = bpf_helper_code (function_name + 21)) != 0))
+	  {
+	    xops[0] = GEN_INT (code);
+	    output_asm_insn ("call\t%0", xops);
+	  }
+	else
+	  output_asm_insn ("call\t%0", &target);
+
+	break;
+      }
+    default:
+      error ("indirect call in function, which are not supported by eBPF");
+      output_asm_insn ("call 0", NULL);
+      break;
+    }
+
+  return "";
+}
+
+/* Print an instruction operand.  This function is called in the macro
+   PRINT_OPERAND defined in bpf.h */
+
+void
+bpf_print_operand (FILE *file, rtx op, int code ATTRIBUTE_UNUSED)
+{
+  switch (GET_CODE (op))
+    {
+    case REG:
+      fprintf (file, "%s", reg_names[REGNO (op)]);
+      break;
+    case MEM:
+      output_address (GET_MODE (op), XEXP (op, 0));
+      break;
+    case CONST_DOUBLE:
+      if (CONST_DOUBLE_HIGH (op))
+	fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
+		 CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
+      else if (CONST_DOUBLE_LOW (op) < 0)
+	fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
+      else
+	fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
+      break;
+    default:
+      output_addr_const (file, op);
+    }
+}
+
+/* Print an operand which is an address.  This function should handle
+   any legit address, as accepted by bpf_legitimate_address_p, and
+   also addresses that are valid in CALL instructions.
+
+   This function is called in the PRINT_OPERAND_ADDRESS macro defined
+   in bpf.h */
+
+void
+bpf_print_operand_address (FILE *file, rtx addr)
+{
+  switch (GET_CODE (addr))
+    {
+    case REG:
+      fprintf (file, "[%s+0]", reg_names[REGNO (addr)]);
+      break;
+    case PLUS:
+      {
+	rtx op0 = XEXP (addr, 0);
+	rtx op1 = XEXP (addr, 1);
+
+	if (GET_CODE (op0) == REG && GET_CODE (op1) == CONST_INT)
+	  {
+	    fprintf (file, "[%s+", reg_names[REGNO (op0)]);
+	    output_addr_const (file, op1);
+	    fputs ("]", file);
+	  }
+	else
+	  fatal_insn ("invalid address in operand", addr);
+	break;
+      }
+    case MEM:
+      /* Fallthrough.  */
+    case LABEL_REF:
+      /* Fallthrough.  */
+      fatal_insn ("unsupported operand", addr);
+      break;
+    default:
+      output_addr_const (file, addr);
+      break;
+    }
+}
+
+/* Add a BPF builtin function with NAME, CODE and TYPE.  Return
+   the function decl or NULL_TREE if the builtin was not added.  */
+
+static tree
+def_builtin (const char *name, enum bpf_builtins code, tree type)
+{
+  tree t
+    = add_builtin_function (name, type, code, BUILT_IN_MD, NULL, NULL_TREE);
+
+  bpf_builtins[code] = t;
+  return t;
+}
+
+/* Define machine-specific built-in functions.  */
+
+static void
+bpf_init_builtins (void)
+{
+  /* Built-ins for calling kernel helpers.  */
+
+  tree pt = build_pointer_type (void_type_node);
+  tree const_void_type
+    = build_qualified_type (void_type_node, TYPE_QUAL_CONST);
+  tree cpt = build_pointer_type (const_void_type);
+  tree st = short_integer_type_node;
+  tree ust = uint16_type_node;
+  tree it = integer_type_node;
+  tree ut = unsigned_type_node;
+  tree const_char_type
+    = build_qualified_type (char_type_node, TYPE_QUAL_CONST);
+  tree cst = build_pointer_type (const_char_type);
+  tree vt = void_type_node;
+  tree ult = long_unsigned_type_node;
+  tree u32t = uint32_type_node;
+  tree u64t = uint64_type_node;
+  tree llt = long_long_integer_type_node;
+  tree ullt = long_long_unsigned_type_node;
+  
+#define TYPES build_function_type_list
+#define VTYPES build_varargs_function_type_list
+#define DEF_HELPER(V,D,N,T)				\
+  do							\
+    {							\
+      if (bpf_kernel >= (V))				\
+	def_builtin ("__builtin_bpf_helper_" #N,	\
+		     BPF_BUILTIN_HELPER_##D,		\
+		     T);				\
+    } while (0);
+#  include "bpf-helpers.def"
+#undef TYPES
+#undef VTYPES
+#undef DEF_HELPER
+
+  /* Built-ins for BPF_LD_ABS and BPF_LD_IND instructions.  */
+
+  def_builtin ("__builtin_bpf_load_byte", BPF_BUILTIN_LOAD_BYTE,
+	       build_function_type_list (ullt, ullt, 0));
+  def_builtin ("__builtin_bpf_load_half", BPF_BUILTIN_LOAD_HALF,
+	       build_function_type_list (ullt, ullt, 0));
+  def_builtin ("__builtin_bpf_load_word", BPF_BUILTIN_LOAD_WORD,
+	       build_function_type_list (ullt, ullt, 0));
+}
+
+#undef TARGET_INIT_BUILTINS
+#define TARGET_INIT_BUILTINS bpf_init_builtins
+
+/* Expand a call to a BPF-specific built-in function that was set up
+   with bpf_init_builtins.  */
+
+static rtx
+bpf_expand_builtin (tree exp, rtx target,
+		    rtx subtarget ATTRIBUTE_UNUSED,
+		    machine_mode mode ATTRIBUTE_UNUSED,
+		    int ignore)
+{
+  tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
+  int code = DECL_MD_FUNCTION_CODE (fndecl);
+
+  if (code >= 1 && code < BPF_BUILTIN_HELPER_MAX)
+    {
+      /* This is a builtin to call a kernel helper function.
+
+	 For these builtins, we just expand the function call normally
+	 with expand_call like we would do for a libcall. The function
+	 bpf_output_call below will then do The Right Thing (TM),
+	 recognizing the name of the called __builtin_helper_* symbol
+	 and emitting the corresponding CALL N instruction whenever
+	 necessary.  */
+
+      return expand_call (exp, target, ignore);
+    }
+  else if (code == BPF_BUILTIN_LOAD_BYTE
+	   || code == BPF_BUILTIN_LOAD_HALF
+	   || code == BPF_BUILTIN_LOAD_WORD)
+    {
+      /* Expand an indirect load from the sk_buff in the context.
+	 There is just one argument to the builtin, which is the
+	 offset.
+
+	 We try first to expand a ldabs* instruction.  In case this
+	 fails, we try a ldind* instruction.  */
+
+      enum insn_code abs_icode
+	= (code == BPF_BUILTIN_LOAD_BYTE ? CODE_FOR_ldabsb
+	   : code == BPF_BUILTIN_LOAD_HALF ? CODE_FOR_ldabsh
+	   : CODE_FOR_ldabsw);
+
+      enum insn_code ind_icode
+	= (code == BPF_BUILTIN_LOAD_BYTE ? CODE_FOR_ldindb
+	   : code == BPF_BUILTIN_LOAD_HALF ? CODE_FOR_ldindh
+	   : CODE_FOR_ldindw);
+
+      tree offset_arg = CALL_EXPR_ARG (exp, 0);
+      struct expand_operand ops[2];
+
+      create_input_operand (&ops[0], expand_normal (offset_arg),
+			    TYPE_MODE (TREE_TYPE (offset_arg)));
+      create_input_operand (&ops[1], const0_rtx, SImode);
+
+      if (!maybe_expand_insn (abs_icode, 2, ops)
+	  && !maybe_expand_insn (ind_icode, 2, ops))
+	{
+	  error ("invalid argument to built-in function");
+	  return gen_rtx_REG (ops[0].mode, BPF_R0);
+	}
+
+      /* The result of the load is in R0.  */
+      return gen_rtx_REG (ops[0].mode, BPF_R0);
+    }
+
+  gcc_unreachable ();
+}
+
+#undef TARGET_EXPAND_BUILTIN
+#define TARGET_EXPAND_BUILTIN bpf_expand_builtin
+
+/* Initialize target-specific function library calls.  This is mainly
+   used to call library-provided soft-fp operations, since eBPF
+   doesn't support floating-point in "hardware".  */
+
+static void
+bpf_init_libfuncs (void)
+{
+  set_conv_libfunc (sext_optab, DFmode, SFmode,
+		    "__bpf_extendsfdf2");
+  set_conv_libfunc (trunc_optab, SFmode, DFmode,
+		    "__bpf_truncdfsf2");
+  set_conv_libfunc (sfix_optab, SImode, DFmode,
+		    "__bpf_fix_truncdfsi");
+  set_conv_libfunc (sfloat_optab, DFmode, SImode,
+		    "__bpf_floatsidf");
+  set_conv_libfunc (ufloat_optab, DFmode, SImode,
+		    "__bpf_floatunsidf");
+}
+
+#undef TARGET_INIT_LIBFUNCS
+#define TARGET_INIT_LIBFUNCS bpf_init_libfuncs
+
+/* Define the mechanism that will be used for describing frame unwind
+   information to the debugger.  In eBPF it is not possible to unwind
+   frames.  */
+
+static enum unwind_info_type
+bpf_debug_unwind_info ()
+{
+  return UI_NONE;
+}
+
+#undef TARGET_DEBUG_UNWIND_INFO
+#define TARGET_DEBUG_UNWIND_INFO bpf_debug_unwind_info
+
+/* Output assembly directives to assemble data of various sized and
+   alignments.  */
+
+#undef TARGET_ASM_BYTE_OP
+#define TARGET_ASM_BYTE_OP "\t.byte\t"
+#undef TARGET_ASM_ALIGNED_HI_OP
+#define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
+#undef TARGET_ASM_ALIGNED_SI_OP
+#define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
+#undef TARGET_ASM_ALIGNED_DI_OP
+#define TARGET_ASM_ALIGNED_DI_OP "\t.dword\t"
+
+/* Finally, build the GCC target.  */
+
+struct gcc_target targetm = TARGET_INITIALIZER;
+
+#include "gt-bpf.h"
diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h
new file mode 100644
index 00000000000..70ad818ccf8
--- /dev/null
+++ b/gcc/config/bpf/bpf.h
@@ -0,0 +1,539 @@
+/* Definition of the eBPF target for GCC.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_BPF_H
+#define GCC_BPF_H
+
+/**** Controlling the Compilation Driver.  */
+
+#define ASM_SPEC "%{mbig-endian:-EB} %{!mbig-endian:-EL}"
+#define LINK_SPEC "%{mbig-endian:-EB} %{!mbig-endian:-EL}"
+#define LIB_SPEC ""
+#define STARTFILE_SPEC ""
+
+/**** Run-time Target Specification.  */
+
+#define TARGET_CPU_CPP_BUILTINS() bpf_target_macros (pfile)
+
+/**** Storage Layout.  */
+
+/* Endianness and word size.  */
+#define BITS_BIG_ENDIAN 0
+#define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
+#define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
+#define BITS_PER_WORD 64
+#define UNITS_PER_WORD 8
+
+/* When storing an integer whose size is less than 64-bit in a
+   register, promote it to a DImode.  */
+#define PROMOTE_MODE(M, UNSIGNEDP, TYPE)	\
+  do						\
+    {						\
+      if (GET_MODE_CLASS (M) == MODE_INT	\
+	  && GET_MODE_SIZE (M) < 8)		\
+	M = DImode;				\
+    } while (0)
+
+/* Biggest alignment supported by the object file format of this
+   machine.  In this case this is ELF.  Use the same definition than
+   in elfos.h */
+#define MAX_OFILE_ALIGNMENT (((unsigned int) 1 << 28) * 8)
+
+/* Align argument parameters on the stack to 64-bit, at a minimum.  */
+#define PARM_BOUNDARY 64
+
+/* The hardware enforces that the stack pointer should be aligned to
+   64-bit at any time.  */
+#define STACK_BOUNDARY 64
+
+/* Function entry points are aligned to 128 bits.  */
+#define FUNCTION_BOUNDARY 128
+
+/* Maximum alignment required by data of any type.  */
+#define BIGGEST_ALIGNMENT 64
+
+/* The best alignment to use in cases where we have a choice.  */
+#define FASTEST_ALIGNMENT 64
+
+/* Use a fast alignment when storing arrays of chars in a local.  */
+#define LOCAL_ALIGNMENT(TYPE, ALIGN)					\
+  (TREE_CODE (TYPE) == ARRAY_TYPE					\
+   && TYPE_MODE (TREE_TYPE (TYPE)) == QImode				\
+   && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
+
+/* The load and store instructions won't work if the data is not in
+   it's expected alignment.  */
+#define STRICT_ALIGNMENT 1
+
+/* We use Pmode as the mode of the size increment operand in an
+   `allocate_stack' pattern.  */
+#define STACK_SIZE_MODE Pmode
+
+/**** Layout of Source Language Data Types.  */
+
+#define INT_TYPE_SIZE         32
+#define SHORT_TYPE_SIZE       16
+#define LONG_TYPE_SIZE        64
+#define LONG_LONG_TYPE_SIZE   64
+#define CHAR_TYPE_SIZE         8
+#define FLOAT_TYPE_SIZE       32
+#define DOUBLE_TYPE_SIZE      64
+#define LONG_DOUBLE_TYPE_SIZE 64
+
+#define INTPTR_TYPE	"long int"
+#define UINTPTR_TYPE	"long unsigned int"
+#define SIZE_TYPE	"long unsigned int"
+#define PTRDIFF_TYPE "long int"
+
+#define SIG_ATOMIC_TYPE "char"
+
+#define INT8_TYPE "char"
+#define INT16_TYPE "short int"
+#define INT32_TYPE "int"
+#define INT64_TYPE "long int"
+#define UINT8_TYPE "unsigned char"
+#define UINT16_TYPE "short unsigned int"
+#define UINT32_TYPE "unsigned int"
+#define UINT64_TYPE "long unsigned int"
+
+#define INT_LEAST8_TYPE INT8_TYPE
+#define INT_LEAST16_TYPE INT16_TYPE
+#define INT_LEAST32_TYPE INT32_TYPE
+#define INT_LEAST64_TYPE INT64_TYPE
+#define UINT_LEAST8_TYPE UINT8_TYPE
+#define UINT_LEAST16_TYPE UINT16_TYPE
+#define UINT_LEAST32_TYPE UINT32_TYPE
+#define UINT_LEAST64_TYPE UINT64_TYPE
+
+#define INT_FAST8_TYPE INT8_TYPE
+#define INT_FAST16_TYPE INT16_TYPE
+#define INT_FAST32_TYPE INT32_TYPE
+#define INT_FAST64_TYPE INT64_TYPE
+#define UINT_FAST8_TYPE UINT8_TYPE
+#define UINT_FAST16_TYPE UINT16_TYPE
+#define UINT_FAST32_TYPE UINT32_TYPE
+#define UINT_FAST64_TYPE UINT64_TYPE
+
+/* `char' is signed by default, like in x86.  */
+#define DEFAULT_SIGNED_CHAR 1
+
+/* `wchar_t' is a signed 32-bit type.  The second constant is used by
+   cpp, which can't use WCHAR_TYPE.  */
+#define WCHAR_TYPE "int"
+#define WCHAR_TYPE_SIZE 32
+
+/* `wint_t' is a signed 32-bit type.  */
+#define WINT_TYPE "int"
+#define WINT_TYPE_SIZE 32
+
+/**** Register Usage.  */
+
+/*** Basic Characteristics of Registers.  */
+
+#define BPF_R0	0
+#define BPF_R1	1
+#define BPF_R2	2
+#define BPF_R3	3
+#define BPF_R4	4
+#define BPF_R5	5
+#define BPF_R6	6
+#define BPF_CTX BPF_R6
+#define BPF_R7	7
+#define BPF_R8	8
+#define BPF_R9	9
+#define BPF_SP BPF_R9
+#define BPF_R10	10
+#define BPF_FP  BPF_R10
+/* 11 is not a real eBPF hard register and is eliminated or not used
+   in the final assembler.  See below.  */
+
+#define FIRST_PSEUDO_REGISTER 12
+
+/* The registers %r0..%r8 are available for general allocation.
+   %r9 is the pseudo-stack pointer.
+   %r10 is the stack frame, which is read-only.
+   %r11 (__arg__) is a fake register that always gets eliminated.  */
+#define FIXED_REGISTERS				\
+  {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1}
+
+/* %r0..%r5 are clobbered by function calls.  */
+#define CALL_USED_REGISTERS				\
+  {1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1}
+
+/**** Register Classes.  */
+
+enum reg_class
+{
+  NO_REGS,		/* no registers in set.  */
+  ALL_REGS,		/* all registers.  */
+  LIM_REG_CLASSES	/* max value + 1.  */
+};
+
+#define N_REG_CLASSES (int) LIM_REG_CLASSES
+#define GENERAL_REGS ALL_REGS
+
+/* An initializer containing the names of the register classes as C
+   string constants.  These names are used in writing some of the
+   debugging dumps.  */
+#define REG_CLASS_NAMES				\
+{						\
+  "NO_REGS",					\
+  "ALL_REGS"					\
+}
+
+/* An initializer containing the contents of the register classes, as
+   integers which are bit masks.  The Nth integer specifies the
+   contents of class N.  The way the integer MASK is interpreted is
+   that register R is in the class if `MASK & (1 << R)' is 1.
+
+   In eBPF all the hard registers are considered general-purpose
+   integer registers.  */
+#define REG_CLASS_CONTENTS			\
+{						\
+   0x00000000, /* NO_REGS */			\
+   0x00000fff, /* ALL_REGS */		        \
+}
+
+/* A C expression whose value is a register class containing hard
+   register REGNO.  In general there is more that one such class;
+   choose a class which is "minimal", meaning that no smaller class
+   also contains the register.  */
+#define REGNO_REG_CLASS(REGNO) GENERAL_REGS
+
+/* 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).  */
+#define INDEX_REG_CLASS NO_REGS
+
+/* C expression which is nonzero if register number REGNO is suitable
+   for use as a base register in operand addresses.  In eBPF every
+   hard register can be used for this purpose.  */
+#define REGNO_OK_FOR_BASE_P(REGNO) 			\
+  ((REGNO) < FIRST_PSEUDO_REGISTER)
+
+/* C expression which is nonzero if register number REGNO is suitable
+   for use as an index register in operand addresses.  */
+#define REGNO_OK_FOR_INDEX_P(REGNO) false
+
+/**** Debugging Info ****/
+
+/* We cannot support DWARF2 because of the limitations of eBPF.  */
+#define DBX_DEBUGGING_INFO
+
+/**** Stack Layout and Calling Conventions.  */
+
+/*** Basic Stack Layout.  */
+
+#define STACK_GROWS_DOWNWARD 1
+#define FRAME_GROWS_DOWNWARD 1
+
+/* The argument pointer always points to the first argument.  */
+#define FIRST_PARM_OFFSET(FNDECL) 0
+
+/* Unsupported.  */
+#define RETURN_ADDR_RTX(count, frame) const0_rtx
+
+/*** Registers That Address the Stack Frame.  */
+
+#define FRAME_POINTER_REGNUM 10
+#define STACK_POINTER_REGNUM 9
+#define ARG_POINTER_REGNUM 11
+#define STATIC_CHAIN_REGNUM 8
+
+/*** Registers elimination.  */
+
+#define ELIMINABLE_REGS					\
+  {{ ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM },	\
+   { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }}
+
+/* Define the offset between two registers, one to be eliminated, and
+   the other its replacement, at the start of a routine.  */
+#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)		\
+  do								\
+    {								\
+      (OFFSET) = bpf_initial_elimination_offset ((FROM), (TO));	\
+    } while (0)
+
+/*** Passing Function Arguments on the Stack.  */
+
+/* The eBPF ABI doesn't support passing arguments on the stack.  Only
+   in the first five registers.  Code in bpf.c assures the stack is
+   never used when passing arguments.  However, we still have to
+   define the constants below.  */
+
+/* If nonzero, push insns will be used to pass outgoing arguments.  */
+#define PUSH_ARGS 0
+
+/* If nonzero, function arguments will be evaluated from last to
+   first, rather than from first to last.  */
+#define PUSH_ARGS_REVERSED 1
+
+/* Allocate stack space for arguments at the beginning of each
+   function.  */
+#define ACCUMULATE_OUTGOING_ARGS 1
+
+/*** Passing Arguments in Registers.  */
+
+/* Use an integer in order to keep track of the number of arguments
+   passed to a function in integer registers, up to
+   MAX_ARGS_IN_REGISTERS.  */
+#define CUMULATIVE_ARGS int
+
+/* INIT_CUMULATIVE_ARGS initializes a variable CUM of type
+   CUMULATIVE_ARGS for a call to a function whose data type is FNTYPE.
+   For a library call, FNTYPE is 0.  */
+#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,FNDECL,N_NAMED_ARGS) \
+  memset (&(CUM), 0, sizeof (CUM))
+
+/* Nonzero if N is the number of a hard register in which function
+   arguments are sometimes passed.  */
+#define FUNCTION_ARG_REGNO_P(N) ((N) >= 1 && (N) <= 5)
+
+/*** How Scalar Function Values are Returned.  */
+
+/* Define how to find the value returned by a library function
+   assuming the value has mode MODE.  This is always %r0 for eBPF.  */
+#define LIBCALL_VALUE(MODE)  \
+  gen_rtx_REG ((MODE), 0)
+
+/*** Generating Code for Profiling.  */
+
+/* We do not support profiling yet, so do not call `mcount'.  */
+#define FUNCTION_PROFILER(FILE, LABELNO) do { } while (0)
+
+/*** Function Entry and Exit.  */
+
+/* We do not require an accurate stack pointer at function return.
+   This is because the stack pointer's original value is initialized
+   from the frame pointer, rather than decreased, to satisfy the
+   kernel's verifier.  Thus, we have to save the stack pointer in
+   function prologue and restore it in function epilogue.  If
+   EXIT_IGNORE_STACK is not set, then superfluous instructions are
+   generated to save and restore the stack pointer after and before
+   the function epilogue, respectively.  */
+#define EXIT_IGNORE_STACK 1
+
+/**** Support for Nested Functions.  */
+
+/* We have to define TRAMPOLINE_SIZE even if we don't ever generate
+   them.  Set to 64 arbitrarily.  */
+#define TRAMPOLINE_SIZE 64
+
+/**** Addressing Modes.  */
+
+/* Maximum number of registers that can appear in a valid memory
+   address.  */
+#define MAX_REGS_PER_ADDRESS 1
+
+/* 1 if X is an rtx for a constant that is a valid address.  */
+
+#define CONSTANT_ADDRESS_P(X) 0
+
+/**** Describing Relative Costs of Operations.  */
+
+/* Cost of a branch instruction.  A value of 1 is the default.  */
+#define BRANCH_COST(SPEED_P,PREDICTABLE_P) 1
+
+/* The SPARC port says: Nonzero if access to memory by bytes is slow
+   and undesirable.  For RISC chips, it means that access to memory by
+   bytes is no better than access by words when possible, so grab a
+   whole word and maybe make use of that.  */
+#define SLOW_BYTE_ACCESS 1
+
+/* Threshold of number of scalar memory-to-memory move instructions,
+   _below_ which a sequence of insns should be generated instead of a
+   string move insn or a library call.  */
+#define MOVE_RATIO(speed) 128
+
+/* Threshold of number of scalar move instructions, _below_ which a
+   sequence of insns should be generated to clear memory instead of a
+   string clear insn or a library call.  */
+#define CLEAR_RATIO(speed) 128
+
+/* Threshold of number of scalar move instructions, _below_ which a
+   sequence of insns should be generated to set memory to a constant
+   value, instead of a block set insn or a library call.  */
+#define SET_RATIO(speed) 128
+
+/* True if it is as good or better to call a constant function address
+   than to call an address kept in a register.  */
+#define NO_FUNCTION_CSE 1
+
+/**** Dividing the Output into Sections.  */
+
+#define TEXT_SECTION_ASM_OP "\t.text"
+#define DATA_SECTION_ASM_OP "\t.data"
+#define BSS_SECTION_ASM_OP "\t.bss"
+#define COMMON_ASM_OP "\t.common\t"
+
+/**** Defining the Output Assembler Language.  */
+
+/*** The Overall Framework of an Assembler File.  */
+
+#define ASM_COMMENT_START ";"
+
+/* Output to assembler file text saying following lines
+   may contain character constants, extra white space, comments, etc.  */
+
+#ifndef ASM_APP_ON
+#define ASM_APP_ON " #APP\n"
+#endif
+
+/* Output to assembler file text saying following lines
+   no longer contain unusual constructs.  */
+
+#ifndef ASM_APP_OFF
+#define ASM_APP_OFF " #NO_APP\n"
+#endif
+
+/*** Output of Data.  */
+
+/*** Output of Uninitialized Variables.  */
+
+/* How to output an assembler line to define a local common
+   symbol.  */
+
+#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
+  do									\
+    {									\
+      fprintf ((FILE), "%s", COMMON_ASM_OP);				\
+      assemble_name ((FILE), (NAME));					\
+      fprintf ((FILE), ",%u,%u\n", (int)(SIZE), (ALIGN) / (BITS_PER_UNIT)); \
+    }									\
+  while (0)
+
+/* A C statement (sans semicolon) to output to the stdio stream
+   FILE the assembler definition of uninitialized global DECL named
+   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
+   Try to use asm_output_aligned_bss to implement this macro.  */
+
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)	\
+  do {								\
+    ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN);		\
+  } while (0)
+
+/* This says how to output an assembler line to define a local common
+   symbol.  */
+
+#define ASM_OUTPUT_ALIGNED_LOCAL(FILE,NAME,SIZE,ALIGN)			\
+  ( fputs ("\t.lcomm ", (FILE)),					\
+    assemble_name ((FILE), (NAME)),					\
+    fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED "\n",		\
+	     (SIZE), ((ALIGN) / BITS_PER_UNIT)))
+
+/*** Output and Generation of Labels.  */
+
+/* Globalizing directive for a label.  */
+#define GLOBAL_ASM_OP "\t.global\t"
+
+/* This is how to store into the string LABEL
+   the symbol_ref name of an internal numbered label where
+   PREFIX is the class of label and NUM is the number within the class.
+   This is suitable for output with `assemble_name'.  */
+
+#undef ASM_GENERATE_INTERNAL_LABEL
+#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)			\
+  sprintf ((LABEL), "*%s%s%ld", (LOCAL_LABEL_PREFIX), (PREFIX), (long)(NUM))
+
+/*** Macros Controlling Initialization Routines.  */
+
+#define INIT_SECTION_ASM_OP "\t.init"
+#define FINI_SECTION_ASM_OP "\t.fini"
+
+/*** Output of Assembler Instructions.  */
+
+#define REGISTER_NAMES						\
+  { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",	\
+    "%r8", "%r9", "%fp", "__arg__" }
+
+#define ADDITIONAL_REGISTER_NAMES		\
+  { { "%a", 0 }, { "%ctx", 6 }, { "%r10" , 10 } }
+
+#define LOCAL_LABEL_PREFIX "."
+#define USER_LABEL_PREFIX  ""
+
+#define PRINT_OPERAND(STREAM,X,CODE)		\
+  bpf_print_operand ((STREAM),(X),(CODE))
+
+#define PRINT_OPERAND_ADDRESS(STREAM,X)		\
+  bpf_print_operand_address ((STREAM), (X))
+
+/*** Assembler Commands for Alignment.  */
+
+/* This is how to output an assembler line that says to advance the
+   location counter to a multiple of 2**LOG bytes.  */
+#define ASM_OUTPUT_ALIGN(STREAM,LOG)		\
+  fprintf (STREAM, "\t.align\t%d\n", (LOG))
+
+/* This is how to output an assembler line
+   that says to advance the location counter by SIZE bytes.  */
+#define ASM_OUTPUT_SKIP(FILE,SIZE)		\
+  fprintf (FILE, "\t.skip\t" HOST_WIDE_INT_PRINT_UNSIGNED "\n", (SIZE))
+
+/**** Miscellaneous Parameters.  */
+
+/* Specify the machine mode that this machine uses for the index in
+   the tablejump instruction.  */
+#define CASE_VECTOR_MODE DImode
+
+/* Define if operations between registers with integral mode smaller
+   than a word are always performed on the entire register.  */
+#define WORD_REGISTER_OPERATIONS 1
+
+/* C expression indicating when insns that read memory in MEM_MODE, an
+   integral mode narrower than a word, set the bits outsize of
+   MEM_MODE to be either the sign-extension or the zero-extension of
+   the data read.  */
+#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
+
+/* The maximum number of bytes that a single instruction can move
+   quickly between memory and registers or between two memory
+   locations.  */
+#define MOVE_MAX 8
+
+/* An alias for the machine mode for pointers.  */
+#define Pmode DImode
+
+/* An alias for the machine mode used for memory references to
+   functions being called, in 'call' RTL expressions.  */
+#define FUNCTION_MODE Pmode
+
+/* No libm on eBPF (for now.)  */
+#define MATH_LIBRARY ""
+
+/**** libgcc settings.  */
+
+/* Iterating over the global constructors and destructors and
+   executing them requires the ability of doing indirect calls.
+
+   eBPF doesn't support indirect calls, so no chance of supporting
+   constructors and destructors.  */
+#define DO_GLOBAL_CTORS_BODY			\
+  do { } while (0)
+#define DO_GLOBAL_DTORS_BODY			\
+  do { } while (0)
+
+#endif /* ! GCC_BPF_H */
diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md
new file mode 100644
index 00000000000..4c79522babf
--- /dev/null
+++ b/gcc/config/bpf/bpf.md
@@ -0,0 +1,497 @@
+;; Machine description for eBPF.
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; This file is part of GCC.
+
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; <http://www.gnu.org/licenses/>.
+
+(include "predicates.md")
+(include "constraints.md")
+
+;;;; Unspecs
+
+(define_c_enum "unspec" [
+  UNSPEC_LDINDABS
+  UNSPEC_XADD
+])
+
+;;;; Constants
+
+(define_constants
+  [(R0_REGNUM		0)
+   (R1_REGNUM		1)
+   (R2_REGNUM		2)
+   (R3_REGNUM		3)
+   (R4_REGNUM		4)
+   (R5_REGNUM		5)
+   (R6_REGNUM		6)
+   (R7_REGNUM		7)
+   (R8_REGNUM		8)
+   (R9_REGNUM		9)
+   (R10_REGNUM		10)
+   (R11_REGNUM		11)
+])
+
+;;;; Attributes
+
+;; Instruction classes.
+;; alu		64-bit arithmetic.
+;; alu32	32-bit arithmetic.
+;; end		endianness conversion instructions.
+;; ld		load instructions.
+;; lddx		load 64-bit immediate instruction.
+;; ldx		generic load instructions.
+;; st		generic store instructions for immediates.
+;; stx		generic store instructions.
+;; jmp		jump instructions.
+;; xadd		atomic exchange-and-add instructions.
+;; multi	multiword sequence (or user asm statements).
+
+(define_attr "type"
+  "unknown,alu,alu32,end,ld,lddw,ldx,st,stx,jmp,xadd,multi"
+  (const_string "unknown"))
+
+;; Length of instruction in bytes.
+(define_attr "length" ""
+  (cond [
+         (eq_attr "type" "lddw") (const_int 16)
+         ] (const_int 8)))
+
+;; Describe a user's asm statement.
+(define_asm_attributes
+  [(set_attr "type" "multi")])
+
+;;;; Mode attributes and iterators
+
+(define_mode_attr mop [(QI "b") (HI "h") (SI "w") (DI "dw")
+                       (SF "w") (DF "dw")])
+(define_mode_attr mtype [(SI "alu32") (DI "alu")])
+(define_mode_attr msuffix [(SI "32") (DI "")])
+
+;;;; NOPs
+
+(define_insn "nop"
+  [(const_int 0)]
+  ""
+  "mov\t%%r0,%%r0"
+  [(set_attr "type" "alu")])
+
+;;;; Arithmetic/Logical
+
+;; The arithmetic and logic operations below are defined for SI and DI
+;; modes.  The mode iterator AM is used in order to expand to two
+;; insns, with the proper modes.
+;;
+;; 32-bit arithmetic (for SI modes) is implemented using the alu32
+;; instructions.
+
+(define_mode_iterator AM [SI DI])
+
+;;; Addition
+(define_insn "add<AM:mode>3"
+  [(set (match_operand:AM          0 "register_operand"   "=r,r")
+        (plus:AM (match_operand:AM 1 "register_operand"   " 0,0")
+                 (match_operand:AM 2 "reg_or_imm_operand" " r,I")))]
+  "1"
+  "add<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;; Subtraction
+
+;; Note that subtractions of constants become additions, so there is
+;; no need to handle immediate operands in the subMODE3 insns.
+
+(define_insn "sub<AM:mode>3"
+  [(set (match_operand:AM          0 "register_operand" "=r")
+        (minus:AM (match_operand:AM 1 "register_operand" " 0")
+                  (match_operand:AM 2 "register_operand" " r")))]
+  ""
+  "sub<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;; Negation
+(define_insn "neg<AM:mode>2"
+  [(set (match_operand:AM 0 "register_operand" "=r")
+        (neg:AM (match_operand:AM 1 "register_operand" " 0")))]
+  ""
+  "neg<msuffix>\t%0"
+  [(set_attr "type" "<mtype>")])
+
+;;; Multiplication
+(define_insn "mul<AM:mode>3"
+  [(set (match_operand:AM          0 "register_operand"   "=r,r")
+        (mult:AM (match_operand:AM 1 "register_operand"   " 0,0")
+                 (match_operand:AM 2 "reg_or_imm_operand" " r,I")))]
+  ""
+  "mul<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+(define_insn "*mulsidi3_zeroextend"
+  [(set (match_operand:DI	   0 "register_operand" "=r,r")
+        (zero_extend:DI
+         (mult:SI (match_operand:SI 1 "register_operand" "0,0")
+                  (match_operand:SI 2 "reg_or_imm_operand" "r,I"))))]
+  ""
+  "mul32\t%0,%2"
+  [(set_attr "type" "alu32")])
+
+;;; Division
+
+;; Note that eBPF doesn't provide instructions for signed integer
+;; division.
+
+(define_insn "udiv<AM:mode>3"
+  [(set (match_operand:AM 0 "register_operand" "=r,r")
+        (udiv:AM (match_operand:AM 1 "register_operand" " 0,0")
+                 (match_operand:AM 2 "reg_or_imm_operand" "r,I")))]
+  ""
+  "div<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;; Modulus
+
+;; Note that eBPF doesn't provide instructions for signed integer
+;; remainder.
+
+(define_insn "umod<AM:mode>3"
+  [(set (match_operand:AM 0 "register_operand" "=r,r")
+        (umod:AM (match_operand:AM 1 "register_operand" " 0,0")
+                 (match_operand:AM 2 "reg_or_imm_operand" "r,I")))]
+  ""
+  "mod<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;; Logical AND
+(define_insn "and<AM:mode>3"
+  [(set (match_operand:AM 0 "register_operand" "=r,r")
+        (and:AM (match_operand:AM 1 "register_operand" " 0,0")
+                (match_operand:AM 2 "reg_or_imm_operand" "r,I")))]
+  ""
+  "and<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;; Logical inclusive-OR
+(define_insn "ior<AM:mode>3"
+  [(set (match_operand:AM 0 "register_operand" "=r,r")
+        (ior:AM (match_operand:AM 1 "register_operand" " 0,0")
+                (match_operand:AM 2 "reg_or_imm_operand" "r,I")))]
+  ""
+  "or<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;; Logical exclusive-OR
+(define_insn "xor<AM:mode>3"
+  [(set (match_operand:AM 0 "register_operand" "=r,r")
+        (xor:AM (match_operand:AM 1 "register_operand" " 0,0")
+                (match_operand:AM 2 "reg_or_imm_operand" "r,I")))]
+  ""
+  "xor<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;;; Conversions
+
+;;; Zero-extensions
+
+;; For register operands smaller than 32-bit zero-extending is
+;; achieved ANDing the value in the source register to a suitable
+;; mask.
+;;
+;; For register operands bigger or equal than 32-bit, we generate a
+;; mov32 instruction to zero the high 32-bits of the destination
+;; register.
+;;
+;; For memory operands, of any width, zero-extending is achieved using
+;; the ldx{bhwdw} instructions to load the values in registers.
+
+(define_insn "zero_extendhidi2"
+  [(set (match_operand:DI 0 "register_operand" "=r,r")
+	(zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
+  ""
+  "@
+   and\t%0,0xffff
+   ldxh\t%0,%1"
+  [(set_attr "type" "alu,ldx")])
+
+(define_insn "zero_extendqidi2"
+  [(set (match_operand:DI 0 "register_operand" "=r,r")
+	(zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
+  ""
+  "@
+   and\t%0,0xff
+   ldxb\t%0,%1"
+  [(set_attr "type" "alu,ldx")])
+
+(define_insn "zero_extendsidi2"
+  [(set (match_operand:DI 0 "register_operand" "=r,r")
+	(zero_extend:DI
+	  (match_operand:SI 1 "nonimmediate_operand" "r,m")))]
+  ""
+  "@
+   mov32\t%0,%1
+   ldxw\t%0,%1"
+  [(set_attr "type" "alu,ldx")])
+
+;;; Sign-extension
+
+;; Sign-extending a 32-bit value into a 64-bit value is achieved using
+;; shifting, with instructions generated by the expand below.
+
+(define_expand "extendsidi2"
+  [(set (match_operand:DI 0 "register_operand")
+	(sign_extend:DI (match_operand:SI 1 "register_operand")))]
+  ""
+{
+  operands[1] = gen_lowpart (DImode, operands[1]);
+  emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (32)));
+  emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
+  DONE;
+})
+
+;;;; Data movement
+
+(define_mode_iterator MM [QI HI SI DI SF DF])
+
+(define_expand "mov<MM:mode>"
+  [(set (match_operand:MM 0 "general_operand")
+        (match_operand:MM 1 "general_operand"))]
+        ""
+        "
+{
+  if (!register_operand(operands[0], <MM:MODE>mode)
+      && !register_operand(operands[1], <MM:MODE>mode))
+    operands[1] = force_reg (<MM:MODE>mode, operands[1]); 
+}")
+
+(define_insn "*mov<MM:mode>"
+  [(set (match_operand:MM 0 "nonimmediate_operand" "=r, r,r,m,m")
+        (match_operand:MM 1 "mov_src_operand"      " m,rI,B,r,I"))]
+  ""
+  "@
+   ldx<mop>\t%0,%1
+   mov\t%0,%1
+   lddw\t%0,%1
+   stx<mop>\t%0,%1
+   st<mop>\t%0,%1"
+[(set_attr "type" "ldx,alu,alu,stx,st")])
+
+;;;; Shifts
+
+(define_mode_iterator SIM [SI DI])
+
+(define_insn "ashr<SIM:mode>3"
+  [(set (match_operand:SIM 0 "register_operand"                 "=r,r")
+        (ashiftrt:SIM (match_operand:SIM 1 "register_operand"   " 0,0")
+                      (match_operand:SIM 2 "reg_or_imm_operand" " r,I")))]
+  ""
+  "arsh<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+(define_insn "ashl<SIM:mode>3"
+  [(set (match_operand:SIM 0 "register_operand"               "=r,r")
+        (ashift:SIM (match_operand:SIM 1 "register_operand"   " 0,0")
+                    (match_operand:SIM 2 "reg_or_imm_operand" " r,I")))]
+  ""
+  "lsh<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+(define_insn "lshr<SIM:mode>3"
+  [(set (match_operand:SIM 0 "register_operand"                 "=r,r")
+        (lshiftrt:SIM (match_operand:SIM 1 "register_operand"   " 0,0")
+                      (match_operand:SIM 2 "reg_or_imm_operand" " r,I")))]
+  ""
+  "rsh<msuffix>\t%0,%2"
+  [(set_attr "type" "<mtype>")])
+
+;;;; Conditional branches
+
+;; The eBPF jump instructions use 64-bit arithmetic when evaluating
+;; the jump conditions.  Therefore we use DI modes below.
+
+(define_expand "cbranchdi4"
+  [(set (pc)
+	(if_then_else (match_operator 0 "comparison_operator"
+			[(match_operand:DI 1 "register_operand")
+			 (match_operand:DI 2 "reg_or_imm_operand")])
+		      (label_ref (match_operand 3 "" ""))
+		      (pc)))]
+  ""
+{
+  if (!ordered_comparison_operator (operands[0], VOIDmode))
+    FAIL;
+})
+
+(define_insn "*branch_on_di"
+  [(set (pc)
+	(if_then_else (match_operator 3 "ordered_comparison_operator"
+			 [(match_operand:DI 0 "register_operand" "r")
+			  (match_operand:DI 1 "reg_or_imm_operand" "rI")])
+		      (label_ref (match_operand 2 "" ""))
+		      (pc)))]
+  ""
+{
+  int code = GET_CODE (operands[3]);
+
+  switch (code)
+  {
+  case EQ: return "jeq\t%0,%1,%2"; break;
+  case NE: return "jne\t%0,%1,%2"; break;
+  case LT: return "jslt\t%0,%1,%2"; break;
+  case LE: return "jsle\t%0,%1,%2"; break;
+  case GT: return "jsgt\t%0,%1,%2"; break;
+  case GE: return "jsge\t%0,%1,%2"; break;
+  case LTU: return "jlt\t%0,%1,%2"; break;
+  case LEU: return "jle\t%0,%1,%2"; break;
+  case GTU: return "jgt\t%0,%1,%2"; break;
+  case GEU: return "jge\t%0,%1,%2"; break;
+  default:
+    gcc_unreachable ();
+    return "";
+  }
+}
+  [(set_attr "type" "jmp")])
+
+;;;; Unconditional branches
+
+(define_insn "jump"
+  [(set (pc)
+        (label_ref (match_operand 0 "" "")))]
+  ""
+  "ja\t%0"
+[(set_attr "type" "jmp")])
+
+;;;; Function prologue/epilogue
+
+(define_insn "exit"
+  [(simple_return)]
+  ""
+  "exit"
+  [(set_attr "type" "jmp")])
+
+(define_expand "prologue"
+  [(const_int 0)]
+  ""
+{
+  bpf_expand_prologue ();
+  DONE;
+})
+
+(define_expand "epilogue"
+  [(const_int 0)]
+  ""
+{
+  bpf_expand_epilogue ();
+  DONE;
+})
+
+;;;; Function calls
+
+(define_expand "call"
+  [(parallel [(call (match_operand 0 "")
+		    (match_operand 1 ""))
+	      (use (match_operand 2 ""))	;; next_arg_reg
+	      (use (match_operand 3 ""))])]	;; struct_value_size_rtx
+  ""
+{
+  rtx target = XEXP (operands[0], 0);
+  emit_call_insn (gen_call_internal (target, operands[1]));
+  DONE;
+})
+
+(define_insn "call_internal"
+  [(call (mem:DI (match_operand:DI 0 "call_operand" "Sr"))
+         (match_operand:SI 1 "general_operand" ""))]
+  ;; operands[2] is next_arg_register
+  ;; operands[3] is struct_value_size_rtx.
+  ""
+  { return bpf_output_call (operands[0]); }
+  [(set_attr "type" "jmp")])
+
+(define_expand "call_value"
+  [(parallel [(set (match_operand 0 "")
+		   (call (match_operand 1 "")
+			 (match_operand 2 "")))
+	      (use (match_operand 3 ""))])]		;; next_arg_reg
+  ""
+{
+  rtx target = XEXP (operands[1], 0);
+  emit_call_insn (gen_call_value_internal (operands[0], target,
+                                           operands[2]));
+  DONE;
+})
+
+(define_insn "call_value_internal"
+  [(set (match_operand 0 "register_operand" "")
+	(call (mem:DI (match_operand:DI 1 "call_operand" "Sr"))
+	      (match_operand:SI 2 "general_operand" "")))]
+  ;; operands[3] is next_arg_register
+  ;; operands[4] is struct_value_size_rtx.
+  ""
+  { return bpf_output_call (operands[1]); }
+  [(set_attr "type" "jmp")])
+
+(define_insn "sibcall"
+  [(call (label_ref (match_operand 0 "" ""))
+	 (match_operand:SI 1 "general_operand" ""))]
+  ;; operands[2] is next_arg_register
+  ;; operands[3] is struct_value_size_rtx.
+  ""
+  "ja\t%0"
+  [(set_attr "type" "jmp")])
+
+;;;; Non-generic load instructions
+
+(define_mode_iterator LDM [QI HI SI DI])
+(define_mode_attr ldop [(QI "b") (HI "h") (SI "w") (DI "dw")])
+
+(define_insn "ldind<ldop>"
+  [(set (reg:LDM R0_REGNUM)
+        (unspec:LDM [(match_operand:DI 0 "register_operand" "r")
+                    (match_operand:SI 1 "imm32_operand" "I")]
+                    UNSPEC_LDINDABS))
+   (clobber (reg:DI R1_REGNUM))
+   (clobber (reg:DI R2_REGNUM))
+   (clobber (reg:DI R3_REGNUM))
+   (clobber (reg:DI R4_REGNUM))]
+  ""
+  "ldind<ldop>\t%0,%1"
+  [(set_attr "type" "ld")])
+
+(define_insn "ldabs<ldop>"
+  [(set (reg:LDM R0_REGNUM)
+        (unspec:LDM [(match_operand:SI 0 "imm32_operand" "I")
+                    (match_operand:SI 1 "imm32_operand" "I")]
+                    UNSPEC_LDINDABS))
+   (clobber (reg:DI R1_REGNUM))
+   (clobber (reg:DI R2_REGNUM))
+   (clobber (reg:DI R3_REGNUM))
+   (clobber (reg:DI R4_REGNUM))]
+  ""
+  "ldabs<ldop>\t%0"
+  [(set_attr "type" "ld")])
+
+;;;; Atomic increments
+
+(define_mode_iterator AMO [SI DI])
+
+(define_insn "atomic_add<AMO:mode>"
+  [(set (match_operand:AMO 0 "memory_operand" "+m")
+        (unspec_volatile:AMO
+         [(plus:AMO (match_dup 0)
+                    (match_operand:AMO 1 "register_operand" "r"))
+          (match_operand:SI 2 "const_int_operand")] ;; Memory model.
+         UNSPEC_XADD))]
+  ""
+  "xadd<mop>\t%0,%1"
+  [(set_attr "type" "xadd")])
diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt
new file mode 100644
index 00000000000..e61cf953c15
--- /dev/null
+++ b/gcc/config/bpf/bpf.opt
@@ -0,0 +1,123 @@
+; Options for the eBPF compiler port.
+
+; Copyright (C) 2019 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+HeaderInclude
+config/bpf/bpf-opts.h
+
+; Selecting the kind of kernel the eBPF will be running on.
+
+mkernel=
+Target RejectNegative Joined Var(bpf_kernel) Enum(bpf_kernel) Init(LINUX_LATEST)
+Generate eBPF for the given Linux kernel version.
+
+Enum
+Name(bpf_kernel) Type(enum bpf_kernel_version)
+
+EnumValue
+Enum(bpf_kernel) String(native) Value(LINUX_NATIVE) DriverOnly
+
+EnumValue
+Enum(bpf_kernel) String(latest) Value(LINUX_LATEST) DriverOnly
+
+EnumValue
+Enum(bpf_kernel) String(4.0) Value(LINUX_V4_0)
+
+EnumValue
+Enum(bpf_kernel) String(4.1) Value(LINUX_V4_1)
+
+EnumValue
+Enum(bpf_kernel) String(4.2) Value(LINUX_V4_2)
+
+EnumValue
+Enum(bpf_kernel) String(4.3) Value(LINUX_V4_3)
+
+EnumValue
+Enum(bpf_kernel) String(4.4) Value(LINUX_V4_4)
+
+EnumValue
+Enum(bpf_kernel) String(4.5) Value(LINUX_V4_5)
+
+EnumValue
+Enum(bpf_kernel) String(4.6) Value(LINUX_V4_6)
+
+EnumValue
+Enum(bpf_kernel) String(4.7) Value(LINUX_V4_7)
+
+EnumValue
+Enum(bpf_kernel) String(4.8) Value(LINUX_V4_8)
+
+EnumValue
+Enum(bpf_kernel) String(4.9) Value(LINUX_V4_9)
+
+EnumValue
+Enum(bpf_kernel) String(4.10) Value(LINUX_V4_10)
+
+EnumValue
+Enum(bpf_kernel) String(4.11) Value(LINUX_V4_11)
+
+EnumValue
+Enum(bpf_kernel) String(4.12) Value(LINUX_V4_12)
+
+EnumValue
+Enum(bpf_kernel) String(4.13) Value(LINUX_V4_13)
+
+EnumValue
+Enum(bpf_kernel) String(4.14) Value(LINUX_V4_14)
+
+EnumValue
+Enum(bpf_kernel) String(4.15) Value(LINUX_V4_15)
+
+EnumValue
+Enum(bpf_kernel) String(4.16) Value(LINUX_V4_16)
+
+EnumValue
+Enum(bpf_kernel) String(4.17) Value(LINUX_V4_17)
+
+EnumValue
+Enum(bpf_kernel) String(4.18) Value(LINUX_V4_18)
+
+EnumValue
+Enum(bpf_kernel) String(4.19) Value(LINUX_V4_19)
+
+EnumValue
+Enum(bpf_kernel) String(4.20) Value(LINUX_V4_20)
+
+EnumValue
+Enum(bpf_kernel) String(5.0) Value(LINUX_V5_0)
+
+EnumValue
+Enum(bpf_kernel) String(5.1) Value(LINUX_V5_1)
+
+EnumValue
+Enum(bpf_kernel) String(5.2) Value(LINUX_V5_2)
+
+; Selecting big endian or little endian targets.
+
+mbig-endian
+Target RejectNegative Report Mask(BIG_ENDIAN)
+Generate big-endian eBPF.
+
+mlittle-endian
+Target RejectNegative Report InverseMask(BIG_ENDIAN)
+Generate little-endian eBPF.
+
+mframe-limit=
+Target Joined RejectNegative UInteger IntegerRange(0, 32767) Var(bpf_frame_limit) Init(512)
+Set a hard limit for the size of each stack frame, in bytes.
diff --git a/gcc/config/bpf/constraints.md b/gcc/config/bpf/constraints.md
new file mode 100644
index 00000000000..f27b785d9ce
--- /dev/null
+++ b/gcc/config/bpf/constraints.md
@@ -0,0 +1,32 @@
+;; Constraint definitions for eBPF.
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+;;
+;; This file is part of GCC.
+;;
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; <http://www.gnu.org/licenses/>.
+
+(define_constraint "I"
+  "A 32-bit signed immediate."
+  (and (match_code "const_int")
+       (match_test "IN_RANGE (ival, -1 - 0x7fffffff, 0x7fffffff)")))
+
+(define_constraint "B"
+  "A constant argument for LDDW."
+  (match_code "const,symbol_ref,label_ref,const_double,const_int"))
+
+(define_constraint "S"
+  "A constant call address."
+  (match_code "const,symbol_ref,label_ref,const_int"))
+
diff --git a/gcc/config/bpf/predicates.md b/gcc/config/bpf/predicates.md
new file mode 100644
index 00000000000..9ba0e785082
--- /dev/null
+++ b/gcc/config/bpf/predicates.md
@@ -0,0 +1,64 @@
+;; Predicate definitions for eBPF.
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+;;
+;; This file is part of GCC.
+;;
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; <http://www.gnu.org/licenses/>.
+
+(define_predicate "reg_or_imm_operand"
+  (ior (and (match_code "const_int")
+            (match_test "IN_RANGE (INTVAL (op), -1 - 0x7fffffff, 0x7fffffff)"))
+       (match_operand 0 "register_operand")))
+
+(define_predicate "imm32_operand"
+  (ior (and (match_code "const_int")
+            (match_test "IN_RANGE (INTVAL (op), 0, 0xffffffff)"))
+       (match_code "symbol_ref,label_ref,const")))
+
+(define_predicate "lddw_operand"
+  (match_code "symbol_ref,label_ref,const,const_double,const_int"))
+
+(define_predicate "call_operand"
+  (match_code "reg,symbol_ref,const_int,const")
+{
+  if (GET_CODE (op) == CONST)
+    {
+      op = XEXP (op, 0);
+
+      switch (GET_CODE (op))
+	{
+	case SYMBOL_REF:
+	case LABEL_REF:
+	case CONST_INT:
+	  return true;
+	  break;
+	default:
+	  break;
+	}
+
+      return false;
+    }
+
+  return true;
+})
+
+(define_predicate "mov_src_operand"
+  (ior (match_operand 0 "memory_operand")
+       (match_operand 0 "reg_or_imm_operand")
+       (match_operand 0 "lddw_operand")))
+
+(define_predicate "register_compare_operator"
+  (match_code "eq,ne,geu,gtu,ge,gt"))
+
diff --git a/gcc/config/bpf/t-bpf b/gcc/config/bpf/t-bpf
new file mode 100644
index 00000000000..e69de29bb2d
-- 
2.11.0

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-08-29 15:36 ` [PATCH V6 05/11] bpf: new GCC port Jose E. Marchesi
@ 2019-08-30  8:38   ` Richard Sandiford
  2019-08-30 10:11     ` Jose E. Marchesi
  0 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2019-08-30  8:38 UTC (permalink / raw)
  To: Jose E. Marchesi, law; +Cc: Jose E. Marchesi, gcc-patches

jemarch@gnu.org (Jose E. Marchesi) writes:
> This patch adds a port for the Linux kernel eBPF architecture to GCC.
>
> ChangeLog:
>
>   * configure.ac: Support for bpf-*-* targets.
>   * configure: Regenerate.
>
> contrib/ChangeLog:
>
>   * config-list.mk (LIST): Disable go in bpf-*-* targets.
>
> gcc/ChangeLog:
>
>   * config.gcc: Support for bpf-*-* targets.
>   * common/config/bpf/bpf-common.c: New file.
>   * config/bpf/t-bpf: Likewise.
>   * config/bpf/predicates.md: Likewise.
>   * config/bpf/constraints.md: Likewise.
>   * config/bpf/bpf.opt: Likewise.
>   * config/bpf/bpf.md: Likewise.
>   * config/bpf/bpf.h: Likewise.
>   * config/bpf/bpf.c: Likewise.
>   * config/bpf/bpf-protos.h: Likewise.
>   * config/bpf/bpf-opts.h: Likewise.
>   * config/bpf/bpf-helpers.h: Likewise.
>   * config/bpf/bpf-helpers.def: Likewise.

Looks good to me, thanks.  Jeff also had detailed comments, so please
wait for an ack from him too.

Richard

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-08-30  8:38   ` Richard Sandiford
@ 2019-08-30 10:11     ` Jose E. Marchesi
  2019-09-03 18:46       ` Jeff Law
  0 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-08-30 10:11 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: law, gcc-patches, richard.sandiford


    > This patch adds a port for the Linux kernel eBPF architecture to GCC.
    >
    > ChangeLog:
    >
    >   * configure.ac: Support for bpf-*-* targets.
    >   * configure: Regenerate.
    >
    > contrib/ChangeLog:
    >
    >   * config-list.mk (LIST): Disable go in bpf-*-* targets.
    >
    > gcc/ChangeLog:
    >
    >   * config.gcc: Support for bpf-*-* targets.
    >   * common/config/bpf/bpf-common.c: New file.
    >   * config/bpf/t-bpf: Likewise.
    >   * config/bpf/predicates.md: Likewise.
    >   * config/bpf/constraints.md: Likewise.
    >   * config/bpf/bpf.opt: Likewise.
    >   * config/bpf/bpf.md: Likewise.
    >   * config/bpf/bpf.h: Likewise.
    >   * config/bpf/bpf.c: Likewise.
    >   * config/bpf/bpf-protos.h: Likewise.
    >   * config/bpf/bpf-opts.h: Likewise.
    >   * config/bpf/bpf-helpers.h: Likewise.
    >   * config/bpf/bpf-helpers.def: Likewise.
    
    Looks good to me, thanks.

Thanks to you for the throughful, super useful review.

    Jeff also had detailed comments, so please wait for an ack from him
    too.
    
Sure.

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-08-30 10:11     ` Jose E. Marchesi
@ 2019-09-03 18:46       ` Jeff Law
  2019-09-05 22:50         ` Jose E. Marchesi
  2019-09-09 10:23         ` Jose E. Marchesi
  0 siblings, 2 replies; 35+ messages in thread
From: Jeff Law @ 2019-09-03 18:46 UTC (permalink / raw)
  To: Jose E. Marchesi, Jose E. Marchesi; +Cc: gcc-patches, richard.sandiford

On 8/30/19 3:40 AM, Jose E. Marchesi wrote:
> 
>     > This patch adds a port for the Linux kernel eBPF architecture to GCC.
>     >
>     > ChangeLog:
>     >
>     >   * configure.ac: Support for bpf-*-* targets.
>     >   * configure: Regenerate.
>     >
>     > contrib/ChangeLog:
>     >
>     >   * config-list.mk (LIST): Disable go in bpf-*-* targets.
>     >
>     > gcc/ChangeLog:
>     >
>     >   * config.gcc: Support for bpf-*-* targets.
>     >   * common/config/bpf/bpf-common.c: New file.
>     >   * config/bpf/t-bpf: Likewise.
>     >   * config/bpf/predicates.md: Likewise.
>     >   * config/bpf/constraints.md: Likewise.
>     >   * config/bpf/bpf.opt: Likewise.
>     >   * config/bpf/bpf.md: Likewise.
>     >   * config/bpf/bpf.h: Likewise.
>     >   * config/bpf/bpf.c: Likewise.
>     >   * config/bpf/bpf-protos.h: Likewise.
>     >   * config/bpf/bpf-opts.h: Likewise.
>     >   * config/bpf/bpf-helpers.h: Likewise.
>     >   * config/bpf/bpf-helpers.def: Likewise.
>     
>     Looks good to me, thanks.
> 
> Thanks to you for the throughful, super useful review.
> 
>     Jeff also had detailed comments, so please wait for an ack from him
>     too.
>     
> Sure.
I think the bits are in good enough shape they can go in now.

jeff

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-09-03 18:46       ` Jeff Law
@ 2019-09-05 22:50         ` Jose E. Marchesi
  2019-09-11 19:09           ` Mike Stump
  2019-09-09 10:23         ` Jose E. Marchesi
  1 sibling, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-05 22:50 UTC (permalink / raw)
  To: Jeff Law; +Cc: Jose E. Marchesi, gcc-patches, richard.sandiford


[Resending this email, because for some reason it seems it didn't reach
 the list a couple of days ago.]

    I think the bits are in good enough shape they can go in now.
    
Thanks!

I guess I should wait for acceptance of the remaining patches not having
an explicit ack?

To my recollection, and to summarize, the accepted patches are:

- [PATCH V6 01/11] Update config.sub and config.guess.
- [PATCH V6 05/11] bpf: new GCC port
- [PATCH V6 06/11] bpf: new libgcc port
- [PATCH V6 07/11] bpf: gcc.target eBPF testsuite
- [PATCH V6 10/11] bpf: manual updates for eBPF

This leaves the following patches that still need explicit approval:

- [PATCH V6 02/11] opt-functions.awk: fix comparison of limit, begin and end
- [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size
- [PATCH V6 04/11] testsuite: new require effective target indirect_calls
- [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF
- [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations
- [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port

Also, you mentioned this requires steering committee approval:

- [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port

How to get it?

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

* Re: [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port
  2019-08-29 15:18 ` [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port Jose E. Marchesi
@ 2019-09-08 11:36   ` Gerald Pfeifer
  2019-09-08 16:39     ` Jose E. Marchesi
  2019-10-07 18:52     ` Thomas Schwinge
  0 siblings, 2 replies; 35+ messages in thread
From: Gerald Pfeifer @ 2019-09-08 11:36 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc-patches

On Thu, 29 Aug 2019, Jose E. Marchesi wrote:
> ChangeLog:
> 
> 	* MAINTAINERS: Add myself as the maintainer of the eBPF port.
> 	Remove myself from Write After Approval section.

Approved.

As in: Approved by the steering committed assuming the patchset passes
technical review. :-)

Thanks for working on this, Joe, and congrats to the new hat!

Gerald

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

* Re: [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port
  2019-09-08 11:36   ` Gerald Pfeifer
@ 2019-09-08 16:39     ` Jose E. Marchesi
  2019-10-07 18:52     ` Thomas Schwinge
  1 sibling, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-08 16:39 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: gcc-patches


    > ChangeLog:
    > 
    > 	* MAINTAINERS: Add myself as the maintainer of the eBPF port.
    > 	Remove myself from Write After Approval section.
    
    Approved.
    
    As in: Approved by the steering committed assuming the patchset passes
    technical review. :-)
    
    Thanks for working on this, Joe, and congrats to the new hat!
    
Thank you! :)

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

* Re: [PATCH V6 01/11] Update config.sub and config.guess.
  2019-08-29 15:20 ` [PATCH V6 01/11] Update config.sub and config.guess Jose E. Marchesi
@ 2019-09-09  9:17   ` Jose E. Marchesi
  0 siblings, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-09  9:17 UTC (permalink / raw)
  To: gcc-patches


    	* config.sub: Import upstream version 2019-06-30.
    	* config.guess: Import upstream version 2019-07-24.

Just installed this in svn trunk.

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

* Re: [PATCH V6 02/11] opt-functions.awk: fix comparison of limit, begin and end
  2019-08-29 15:34 ` [PATCH V6 02/11] opt-functions.awk: fix comparison of limit, begin and end Jose E. Marchesi
@ 2019-09-09  9:47   ` Jose E. Marchesi
  0 siblings, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-09  9:47 UTC (permalink / raw)
  To: gcc-patches


    The function integer_range_info makes sure that, if provided, the
    initial value fills in the especified range.  However, it is necessary
    to convert the values to a numerical context before comparing, to make
    sure awk is using arithmetical order and not lexicographical order.
    
    gcc/ChangeLog:
    
    	* opt-functions.awk (integer_range_info): Make sure values are in
    	numeric context before operating with them.

I just installed this in svn trunk.
Salud!

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

* Re: [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size
  2019-08-29 15:14 ` [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size Jose E. Marchesi
@ 2019-09-09  9:52   ` Jose E. Marchesi
  2019-09-11 18:42   ` Mike Stump
  1 sibling, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-09  9:52 UTC (permalink / raw)
  To: gcc-patches


    This patch annotates tests that make use of a significant a mount of
    stack space.  Embedded and other restricted targets may have problems
    compiling and running these tests.  Note that the annotations are in
    many cases not exact.

As this implements a solution proposed by Jeff Law and I got no further
comments, I just installed it in its own commit in svn trunk.

Salud!

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

* Re: [PATCH V6 04/11] testsuite: new require effective target indirect_calls
  2019-08-29 15:14 ` [PATCH V6 04/11] testsuite: new require effective target indirect_calls Jose E. Marchesi
@ 2019-09-09  9:56   ` Jose E. Marchesi
  2019-09-11 18:55   ` Mike Stump
  1 sibling, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-09  9:56 UTC (permalink / raw)
  To: gcc-patches


    This patch adds a new dg_require_effective_target procedure to the
    testsuite infrastructure: indirect_calls.  This new function tells
    whether a target supports calls to non-constant call targets.
    
    This patch also annotates the tests in the gcc.c-torture testuite that
    require support for indirect calls.

As this implements a solution proposed by a global maintainer and I
didn't get any further comments on it, I just installed it in its own
commit in svn trunk.

Salud!

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-09-03 18:46       ` Jeff Law
  2019-09-05 22:50         ` Jose E. Marchesi
@ 2019-09-09 10:23         ` Jose E. Marchesi
  2019-10-20 19:51           ` Gerald Pfeifer
  1 sibling, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-09 10:23 UTC (permalink / raw)
  To: Jeff Law; +Cc: Jose E. Marchesi, gcc-patches, richard.sandiford


    I think the bits are in good enough shape they can go in now.
    
I just committed the port to svn trunk, in a single commit, yay!

Many thanks to you, richard, seguer and the other reviewers for the
great feedback and suggestions.  What got committed is certainly WAY
better than what I submitted initially.

Now the real fun starts :))

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

* Re: [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size
  2019-08-29 15:14 ` [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size Jose E. Marchesi
  2019-09-09  9:52   ` Jose E. Marchesi
@ 2019-09-11 18:42   ` Mike Stump
  2019-09-11 20:49     ` Jose E. Marchesi
  1 sibling, 1 reply; 35+ messages in thread
From: Mike Stump @ 2019-09-11 18:42 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc-patches

On Aug 29, 2019, at 8:13 AM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> 
> This patch annotates tests that make use of a significant a mount of
> stack space.

Ok.  Future changes like this are now obvious to you and you can just maintain them as you see fit.

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

* Re: [PATCH V6 04/11] testsuite: new require effective target indirect_calls
  2019-08-29 15:14 ` [PATCH V6 04/11] testsuite: new require effective target indirect_calls Jose E. Marchesi
  2019-09-09  9:56   ` Jose E. Marchesi
@ 2019-09-11 18:55   ` Mike Stump
  2019-09-11 20:47     ` Jose E. Marchesi
  1 sibling, 1 reply; 35+ messages in thread
From: Mike Stump @ 2019-09-11 18:55 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc-patches

On Aug 29, 2019, at 8:13 AM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> 
> This patch adds a new dg_require_effective_target procedure to the
> testsuite infrastructure: indirect_calls.  This new function tells
> whether a target supports calls to non-constant call targets.

Ok.  I'll let people contemplate some comments...

I'm torn between targets that can't support C and gooping up the test suite and approving.  I'll error on the side of approving this, but, would like to hear from folks if I go to far.

Since they are easy to identify, maintain and ignore...  I went with approval.

People can contemplate other ways to do this, like introduce a fake marker for when the feature is used and when running a program with such a marker, then mark it as unsupported.  This way, no test need be marked, and all future test cases that use the feature, just flip to unsupported, no maintenance required.

We do this sort of thing with programs that overflow the RAM, by using a stylized error message from ld, and noticing that in dejagnu, and then not expecting it to work.

If you can find a way to tally stack space, and check it before running it, the other change to tightly track stack space then would not be as necessary.  I think you might be able to do this on your target.  Having the stack space marked is generally useful for other targets, as most won't have a nice way to  sort out small stacks, so my general comment apply less to the stack size, but, things that can cause you less maintenance burden are likely good in any event.

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

* Re: [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF
  2019-08-29 15:16 ` [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF Jose E. Marchesi
@ 2019-09-11 18:58   ` Mike Stump
  2019-09-12  0:35     ` Mike Stump
  0 siblings, 1 reply; 35+ messages in thread
From: Mike Stump @ 2019-09-11 18:58 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc-patches

On Aug 29, 2019, at 8:13 AM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> 
> This patch makes the several effective target checks in
> target-supports.exp to be aware of eBPF targets.

Ok.

These sort of updates will now be obvious to you, now that you have gotten your feet wet.  This applies to the indirect calls style changes as well.

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

* Re: [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations
  2019-08-29 15:21 ` [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations Jose E. Marchesi
@ 2019-09-11 19:04   ` Mike Stump
  0 siblings, 0 replies; 35+ messages in thread
From: Mike Stump @ 2019-09-11 19:04 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc-patches

On Aug 29, 2019, at 8:13 AM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> 
> This patch makes many tests in gcc.dg and gcc.c-torture to be skipped
> in bpf-*-* targets.  This is due to the many limitations imposed by
> eBPF

Ok.

So, see my other comments about marking and automatically skipping tests in the indirect calls patch.  All of that applies to this one as well.

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-09-05 22:50         ` Jose E. Marchesi
@ 2019-09-11 19:09           ` Mike Stump
  0 siblings, 0 replies; 35+ messages in thread
From: Mike Stump @ 2019-09-11 19:09 UTC (permalink / raw)
  To: Jose E. Marchesi
  Cc: Jeff Law, Jose E. Marchesi, gcc-patches, richard.sandiford

On Sep 5, 2019, at 3:50 PM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> I guess I should wait for acceptance of the remaining patches not having
> an explicit ack?
> 
> This leaves the following patches that still need explicit approval:
> 
> - [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size
> - [PATCH V6 04/11] testsuite: new require effective target indirect_calls
> - [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF
> - [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations

I think I've responded to these now.

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

* Re: [PATCH V6 04/11] testsuite: new require effective target indirect_calls
  2019-09-11 18:55   ` Mike Stump
@ 2019-09-11 20:47     ` Jose E. Marchesi
  2019-09-12  0:43       ` Mike Stump
  0 siblings, 1 reply; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-11 20:47 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc-patches


Hi Mike.
Thanks for the review.

    On Aug 29, 2019, at 8:13 AM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
    > 
    > This patch adds a new dg_require_effective_target procedure to the
    > testsuite infrastructure: indirect_calls.  This new function tells
    > whether a target supports calls to non-constant call targets.
    
    Ok.  I'll let people contemplate some comments...
    
    I'm torn between targets that can't support C and gooping up the test
    suite and approving.  I'll error on the side of approving this, but,
    would like to hear from folks if I go to far.
    
    Since they are easy to identify, maintain and ignore...  I went with
    approval.
    
    People can contemplate other ways to do this, like introduce a fake
    marker for when the feature is used and when running a program with
    such a marker, then mark it as unsupported.  This way, no test need be
    marked, and all future test cases that use the feature, just flip to
    unsupported, no maintenance required.
    
    We do this sort of thing with programs that overflow the RAM, by using
    a stylized error message from ld, and noticing that in dejagnu, and
    then not expecting it to work.
    
    If you can find a way to tally stack space, and check it before
    running it, the other change to tightly track stack space then would
    not be as necessary.  I think you might be able to do this on your
    target.  Having the stack space marked is generally useful for other
    targets, as most won't have a nice way to sort out small stacks, so my
    general comment apply less to the stack size, but, things that can
    cause you less maintenance burden are likely good in any event.

I am working on a new compilation mode for what I call xbpf, which is
basically eBPF plus extensions to eliminate the current restrictions to
C.  The purpose of -mxbpf is mainly to test the compiler.  Once the
support is in, I will revert this and similar other patches.

J.

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

* Re: [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size
  2019-09-11 18:42   ` Mike Stump
@ 2019-09-11 20:49     ` Jose E. Marchesi
  0 siblings, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-09-11 20:49 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc-patches


    On Aug 29, 2019, at 8:13 AM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
    > 
    > This patch annotates tests that make use of a significant a mount of
    > stack space.
    
    Ok.  Future changes like this are now obvious to you and you can
    just maintain them as you see fit.

Ok thanks.

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

* [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF
  2019-09-11 18:58   ` Mike Stump
@ 2019-09-12  0:35     ` Mike Stump
  0 siblings, 0 replies; 35+ messages in thread
From: Mike Stump @ 2019-09-12  0:35 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: GCC Patches

On Aug 29, 2019, at 8:13 AM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> 
> This patch makes the several effective target checks in
> target-supports.exp to be aware of eBPF targets.

Ok.

These sort of updates will now be obvious to you, now that you have gotten your feet wet.  This applies to the indirect calls style changes as well.

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

* Re: [PATCH V6 04/11] testsuite: new require effective target indirect_calls
  2019-09-11 20:47     ` Jose E. Marchesi
@ 2019-09-12  0:43       ` Mike Stump
  0 siblings, 0 replies; 35+ messages in thread
From: Mike Stump @ 2019-09-12  0:43 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc-patches

On Sep 11, 2019, at 1:47 PM, Jose E. Marchesi <jose.marchesi@oracle.com> wrote:
> 
> I am working on a new compilation mode for what I call xbpf, which is
> basically eBPF plus extensions to eliminate the current restrictions to
> C.  The purpose of -mxbpf is mainly to test the compiler.  Once the
> support is in, I will revert this and similar other patches.

Yeah, not a bad way to do it.  I have a machine with limits on certain memories in hardware that trip up gcc's testsuite, and in my simulator, I have a special gcc testing mode that simply gives me a ton more memory (17 MB) that on real hardware, I don't have.  This let's me easily test under simulation without worrying about the limits.  I can also have my simulator select the small mode to reflect what hardware does, and everything else uses this.  Best of both world.

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

* Re: [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port
  2019-09-08 11:36   ` Gerald Pfeifer
  2019-09-08 16:39     ` Jose E. Marchesi
@ 2019-10-07 18:52     ` Thomas Schwinge
  1 sibling, 0 replies; 35+ messages in thread
From: Thomas Schwinge @ 2019-10-07 18:52 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gcc, gcc-patches, Gerald Pfeifer

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

Hi!

On 2019-09-08T19:35:52+0800, Gerald Pfeifer <gerald@pfeifer.com> wrote:
> On Thu, 29 Aug 2019, Jose E. Marchesi wrote:
>> ChangeLog:
>> 
>> 	* MAINTAINERS: Add myself as the maintainer of the eBPF port.
>
> Approved.
>
> As in: Approved by the steering committed assuming the patchset passes
> technical review. :-)
>
> Thanks for working on this, Joe, and congrats to the new hat!

Indeed -- I'm always happy when people/companies demonstrate that good
ol' GCC is still viable for the latest craze, the new shiny thing, like
adding a not-your-standard-CPU-architecture back end!  ;-D


I think, using the "as obvious" rule, you should add a "News" item on
<https://gcc.gnu.org/>, like done for other new back ends etc.


Grüße
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-09-09 10:23         ` Jose E. Marchesi
@ 2019-10-20 19:51           ` Gerald Pfeifer
  2019-10-24  8:45             ` Jose E. Marchesi
  0 siblings, 1 reply; 35+ messages in thread
From: Gerald Pfeifer @ 2019-10-20 19:51 UTC (permalink / raw)
  To: Jose E. Marchesi
  Cc: Jeff Law, Jose E. Marchesi, gcc-patches, richard.sandiford

On Mon, 9 Sep 2019, Jose E. Marchesi wrote:
> I just committed the port to svn trunk, in a single commit, yay!

Congratulations!

> Many thanks to you, richard, seguer and the other reviewers for the
> great feedback and suggestions.  What got committed is certainly WAY
> better than what I submitted initially.

Happy to hear. :-)

> Now the real fun starts :))

I noticed that https://gcc.gnu.org does not have a news item related
to this contribution.  Would you mind adding one?  (Our web pages are
now in GIT, cf. https://gcc.gnu.org/about.html - let me know if you need
help.)

Also gcc/doc/contrib.texi doesn't know anyone by your name yet.  Happy
to change this; let's sync off list?

Gerald

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

* Re: [PATCH V6 05/11] bpf: new GCC port
  2019-10-20 19:51           ` Gerald Pfeifer
@ 2019-10-24  8:45             ` Jose E. Marchesi
  0 siblings, 0 replies; 35+ messages in thread
From: Jose E. Marchesi @ 2019-10-24  8:45 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: Jeff Law, Jose E. Marchesi, gcc-patches, richard.sandiford


Hi Gerald.

    I noticed that https://gcc.gnu.org does not have a news item related
    to this contribution.  Would you mind adding one?  (Our web pages are
    now in GIT, cf. https://gcc.gnu.org/about.html - let me know if you need
    help.)

Done! :)

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

end of thread, other threads:[~2019-10-24  8:39 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-29 15:32 [PATCH V6 00/11] eBPF support for GCC Jose E. Marchesi
2019-08-29 15:14 ` [PATCH V6 04/11] testsuite: new require effective target indirect_calls Jose E. Marchesi
2019-09-09  9:56   ` Jose E. Marchesi
2019-09-11 18:55   ` Mike Stump
2019-09-11 20:47     ` Jose E. Marchesi
2019-09-12  0:43       ` Mike Stump
2019-08-29 15:14 ` [PATCH V6 03/11] testsuite: annotate c-torture/compile tests with dg-require-stack-size Jose E. Marchesi
2019-09-09  9:52   ` Jose E. Marchesi
2019-09-11 18:42   ` Mike Stump
2019-09-11 20:49     ` Jose E. Marchesi
2019-08-29 15:16 ` [PATCH V6 07/11] bpf: gcc.target eBPF testsuite Jose E. Marchesi
2019-08-29 15:16 ` [PATCH V6 08/11] bpf: make target-supports.exp aware of eBPF Jose E. Marchesi
2019-09-11 18:58   ` Mike Stump
2019-09-12  0:35     ` Mike Stump
2019-08-29 15:18 ` [PATCH V6 11/11] bpf: add myself as the maintainer for the eBPF port Jose E. Marchesi
2019-09-08 11:36   ` Gerald Pfeifer
2019-09-08 16:39     ` Jose E. Marchesi
2019-10-07 18:52     ` Thomas Schwinge
2019-08-29 15:18 ` [PATCH V6 10/11] bpf: manual updates for eBPF Jose E. Marchesi
2019-08-29 15:20 ` [PATCH V6 01/11] Update config.sub and config.guess Jose E. Marchesi
2019-09-09  9:17   ` Jose E. Marchesi
2019-08-29 15:21 ` [PATCH V6 09/11] bpf: adjust GCC testsuite to eBPF limitations Jose E. Marchesi
2019-09-11 19:04   ` Mike Stump
2019-08-29 15:21 ` [PATCH V6 06/11] bpf: new libgcc port Jose E. Marchesi
2019-08-29 15:34 ` [PATCH V6 02/11] opt-functions.awk: fix comparison of limit, begin and end Jose E. Marchesi
2019-09-09  9:47   ` Jose E. Marchesi
2019-08-29 15:36 ` [PATCH V6 05/11] bpf: new GCC port Jose E. Marchesi
2019-08-30  8:38   ` Richard Sandiford
2019-08-30 10:11     ` Jose E. Marchesi
2019-09-03 18:46       ` Jeff Law
2019-09-05 22:50         ` Jose E. Marchesi
2019-09-11 19:09           ` Mike Stump
2019-09-09 10:23         ` Jose E. Marchesi
2019-10-20 19:51           ` Gerald Pfeifer
2019-10-24  8:45             ` Jose E. Marchesi

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).