Permalink
Browse files

BPF backend for GCC

Change-Id: I4f469e0157f5eda2a06388ccf2acfc01691ddad3
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
  • Loading branch information...
1 parent a52240e commit 9e7223f8f09c822ecc6e18309e89a574a23dbf63 Alexei Starovoitov committed Sep 10, 2013
Showing with 2,922 additions and 3 deletions.
  1. +3 −0 config.me
  2. +9 −3 config.sub
  3. +39 −0 gcc/common/config/bpf/bpf-common.c
  4. +18 −0 gcc/config.gcc
  5. +22 −0 gcc/config/bpf/bpf-modes.def
  6. +60 −0 gcc/config/bpf/bpf-protos.h
  7. +1,063 −0 gcc/config/bpf/bpf.c
  8. +746 −0 gcc/config/bpf/bpf.h
  9. +895 −0 gcc/config/bpf/bpf.md
  10. +67 −0 gcc/config/bpf/linux.h
View
@@ -0,0 +1,3 @@
+mkdir bld
+cd bld
+../configure --prefix=/opt/local/bpf_gcc --with-as=/usr/bin/gcc --with-ld=/usr/bin/gcc --target=bpf-unknown-linux --disable-lto --enable-languages=c
View
@@ -219,6 +219,9 @@ case $os in
-clix*)
basic_machine=clipper-intergraph
;;
+ -bpf*)
+ basic_machine=bpf-unknown-linux
+ ;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
@@ -261,7 +264,7 @@ case $basic_machine in
| avr | avr32 \
| be32 | be64 \
| bfin \
- | c4x | clipper \
+ | c4x | clipper | bpf \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
@@ -376,7 +379,7 @@ case $basic_machine in
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
- | clipper-* | craynv-* | cydra-* \
+ | clipper-* | bpf-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@@ -1287,7 +1290,10 @@ case $basic_machine in
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
- cydra)
+ bpf)
+ basic_machine=bpf-unknown
+ ;;
+ cydra)
basic_machine=cydra-cydrome
;;
orion)
@@ -0,0 +1,39 @@
+/* Common hooks for BPF.
+ Copyright (C) 2013, PLUMgrid 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"
+
+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
+static const struct default_options bpf_option_optimization_table[] =
+ {
+ { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
+ { OPT_LEVELS_NONE, 0, NULL, 0 }
+ };
+
+#undef TARGET_DEFAULT_TARGET_FLAGS
+#define TARGET_DEFAULT_TARGET_FLAGS 0
+#undef TARGET_OPTION_OPTIMIZATION_TABLE
+#define TARGET_OPTION_OPTIMIZATION_TABLE bpf_option_optimization_table
+
+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
View
@@ -482,6 +482,10 @@ tilepro-*-*)
cpu_type=tilepro
need_64bit_hwint=yes
;;
+bpf*-*-*)
+ cpu_type=bpf
+ need_64bit_hwint=yes
+ ;;
esac
tm_file=${cpu_type}/${cpu_type}.h
@@ -2289,6 +2293,14 @@ rl78-*-elf*)
c_target_objs="rl78-c.o"
cxx_target_objs="rl78-c.o"
tmake_file="${tmake_file} rl78/t-rl78"
+ ;;
+bpf-*-*)
+ tm_file="bpf/linux.h"
+ xm_defines="USG POSIX"
+ tmake_file=""
+ extra_parts=""
+ extra_objs=""
+ c_target_objs="default-c.o"
;;
rx-*-elf*)
tm_file="dbxelf.h elfos.h newlib-stdint.h ${tm_file}"
@@ -3440,6 +3452,10 @@ case "${target}" in
;;
esac
;;
+ bpf-*-*)
+ supported_defaults="cpu"
+ with_cpu=unknown
+ ;;
fido-*-* | m68k*-*-*)
supported_defaults="arch cpu"
@@ -3961,6 +3977,8 @@ do
fi
done
+configure_default_options="{ { NULL, NULL} }"
+
if test "x$t" = x
then
configure_default_options="{ { NULL, NULL} }"
@@ -0,0 +1,22 @@
+/* Definitions of target machine for GCC for BPF.
+ Copyright (C) 2013 PLUMgrid 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/>. */
+
+/* 128-bit floating point */
+FLOAT_MODE (TF, 16, ieee_quad_format);
+
@@ -0,0 +1,60 @@
+/* Definitions of target machine for GCC for BPF.
+ Copyright (C) 2013 PLUMgrid 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/>. */
+
+#ifndef __BPF_PROTOS_H__
+#define __BPF_PROTOS_H__
+
+#ifdef RTX_CODE
+extern void output_call_value (struct rtx_def** op,int is_value, int cheat_num);
+extern char * bpf_output_compare (rtx * operands, rtx insn, bpf_cc_opcode_type opcode);
+extern char * bpf_output_jump (rtx code_label, rtx insn);
+extern void bpf_print_operand (FILE *f, struct rtx_def* X, char code);
+extern void print_operand_address (FILE * file, struct rtx_def* addr);
+
+extern void bpf_output_symbol_ref (FILE * file, struct rtx_def * addr);
+
+#ifdef TREE_CODE
+extern rtx bpf_function_value (const_tree, const_tree);
+extern void bpf_output_section_name (FILE * file, tree decl, const char * name, int reloc);
+#endif
+
+#endif
+
+extern void bpf_output_vars_end (FILE* f);
+extern void bpf_output_vars_start (FILE* f);
+extern void bpf_output_source_filename (FILE*, const char*);
+extern void bpf_output_internal_label (FILE*, const char*);
+extern void bpf_asm_file_start (FILE * f);
+extern void bpf_asm_file_end (FILE * f);
+extern void bpf_output_common (FILE * f, const char * , int , int );
+extern void bpf_output_local (FILE * f, const char * , int , int );
+extern void bpf_output_skip (FILE*, int size);
+extern void bpf_output_align (FILE*, int align);
+extern void bpf_output_label (FILE*, const char*);
+extern void bpf_output_labelref (FILE*, const char*);
+extern void bpf_output_label_ref (FILE*, const char*);
+extern void bpf_output_ascii (FILE*,const char *,int);
+
+#endif /* __BPF_PROTOS_H__ */
+
Oops, something went wrong.

0 comments on commit 9e7223f

Please sign in to comment.