Skip to contentSkip to conversation

OpenRISC port

PATCH New Stafford Horne 2 participants 5 messages Nov 6, 2018 – Nov 7, 2018

lore
Share & tools
lore
#0 lore raw

v4 cover OpenRISC port

Hello,

As you can see this is v4 of the OpenRISC port patch series, I just want to mention that there are a few things pointed out during the v3 review that I have not fixed, and do not plan before pushing upstream. These are either because I didn't feel they made the code easier to read or they were things that could wait unil after upstreaming. These include:

(not changed)
- libgcc !cmov 1cyc improvements suggested by Richard
- gcc eliminations refactorings suggested by Segher
- leaving out empty constraint strings suggested by Segher
- implementing TARGET_ISNS_COST suggested by Segher

Please let me know if you have concerns; now onto the patches:

Changes Since v3:
- Fix tabs formatting pointed out by Segher
- Fix comment formatting and typos pointed out by Segher
- Fix for sign/zero extention login in md file from Richard
- Remove usages of ATTRIBUTE_UNUSED suggested by Segher
- Remove need for init/fini, removing crti/n.S files
- Add support for -static-pie in LINK_SPEC suggsted by Szabolcs

Changes Since v2:
- Add RTEMS patches from Joel Sherrill
- Disable t-softfp-excl as suggsted by Joseph Myers
- Add new architecture flags needed to run on real FPGA's found in testing
* -mror - enable l.ror (rotate right)
* -mshftimm - enable shift/rorate by immediate instructions
- Binutils requirements are now in upstream git

Changes Since v1:
- Document options in invoke.texi suggested by Joseph Myers
- Remove obsolete/incorrect macros suggested by Joseph Myers
- Documented or1k.c functions as requested by Jeff Law
- Add epilogue barriers suggested by Jeff Law
- Define SPECULATION_SAFE_VALUE suggested by Jeff Law
- Switch to init/fini array suggested by Richard Henderson
- Define and document multilib flags to enable disable instructions only available on some CPU cores as requested on OpenRISC mailing list.

Since February this year I have been working on an OpenRISC clean room rewrite.

http://stffrdhrn.github.io/software/embedded/openrisc/2018/02/03/openrisc_gcc_rewrite.html

As per the article, the old port had issues with some of the owners signing over FSF copyright. To get around this I discussed options with the group and in the end I opted for a clean room rewrite.

The new code base has been written by me with lots of help from Richard Henderson. I trust that both of us have our FSF GCC copyright's in place.

# Testing

We have been running the GCC testsuite with newlib and musl libc. The results are good. See results published in a test build/release here:

- https://github.com/stffrdhrn/gcc/releases/tag/or1k-9.0.0-20181106

# Building

To build this requires the latest binutils upstream master i.e. 2.31.52. Also, due to removing need for init and fini it requires the latest changes on newlib master.

-Stafford

Stafford Horne (3):
or1k: libgcc: initial support for openrisc
or1k: testsuite: initial support for openrisc
or1k: gcc: initial support for openrisc

 gcc/common/config/or1k/or1k-common.c          |   41 +
 gcc/config.gcc                                |   45 +
 gcc/config/or1k/constraints.md                |   55 +
 gcc/config/or1k/elf.h                         |   42 +
 gcc/config/or1k/elf.opt                       |   33 +
 gcc/config/or1k/linux.h                       |   45 +
 gcc/config/or1k/or1k-protos.h                 |   38 +
 gcc/config/or1k/or1k.c                        | 2183 +++++++++++++++++
 gcc/config/or1k/or1k.h                        |  392 +++
 gcc/config/or1k/or1k.md                       |  897 +++++++
 gcc/config/or1k/or1k.opt                      |   67 +
 gcc/config/or1k/predicates.md                 |   84 +
 gcc/config/or1k/rtems.h                       |   30 +
 gcc/config/or1k/t-or1k                        |   22 +
 gcc/config/or1k/t-rtems                       |    3 +
 gcc/configure                                 |   12 +
 gcc/configure.ac                              |   12 +
 gcc/doc/install.texi                          |   19 +
 gcc/doc/invoke.texi                           |   68 +
 gcc/doc/md.texi                               |   25 +
 .../gcc.c-torture/execute/20101011-1.c        |    3 +
 gcc/testsuite/gcc.dg/20020312-2.c             |    2 +
 gcc/testsuite/gcc.dg/attr-alloc_size-11.c     |    4 +-
 gcc/testsuite/gcc.dg/builtin-apply2.c         |    2 +-
 gcc/testsuite/gcc.dg/nop.h                    |    2 +
 .../torture/stackalign/builtin-apply-2.c      |    2 +-
 gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c    |    2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c    |    2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c    |    2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c    |    2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c    |    2 +-
 gcc/testsuite/gcc.target/or1k/args-1.c        |   19 +
 gcc/testsuite/gcc.target/or1k/args-2.c        |   15 +
 gcc/testsuite/gcc.target/or1k/cmov-1.c        |    8 +
 gcc/testsuite/gcc.target/or1k/cmov-2.c        |    9 +
 gcc/testsuite/gcc.target/or1k/div-mul-1.c     |    9 +
 gcc/testsuite/gcc.target/or1k/div-mul-2.c     |    9 +
 gcc/testsuite/gcc.target/or1k/or1k.exp        |   41 +
 gcc/testsuite/gcc.target/or1k/return-1.c      |   10 +
 gcc/testsuite/gcc.target/or1k/return-2.c      |   19 +
 gcc/testsuite/gcc.target/or1k/return-3.c      |   19 +
 gcc/testsuite/gcc.target/or1k/return-4.c      |   19 +
 gcc/testsuite/gcc.target/or1k/ror-1.c         |    8 +
 gcc/testsuite/gcc.target/or1k/ror-2.c         |    9 +
 gcc/testsuite/gcc.target/or1k/ror-3.c         |    8 +
 gcc/testsuite/gcc.target/or1k/shftimm-1.c     |    8 +
 gcc/testsuite/gcc.target/or1k/shftimm-2.c     |    8 +
 gcc/testsuite/gcc.target/or1k/sibcall-1.c     |   18 +
 gcc/testsuite/lib/target-supports.exp         |    1 +
 libgcc/config.host                            |   12 +
 libgcc/config/or1k/lib1funcs.S                |  222 ++
 libgcc/config/or1k/linux-unwind.h             |   87 +
 libgcc/config/or1k/sfp-machine.h              |   54 +
 libgcc/config/or1k/t-or1k                     |   22 +
 54 files changed, 4763 insertions(+), 9 deletions(-)
 create mode 100644 gcc/common/config/or1k/or1k-common.c
 create mode 100644 gcc/config/or1k/constraints.md
 create mode 100644 gcc/config/or1k/elf.h
 create mode 100644 gcc/config/or1k/elf.opt
 create mode 100644 gcc/config/or1k/linux.h
 create mode 100644 gcc/config/or1k/or1k-protos.h
 create mode 100644 gcc/config/or1k/or1k.c
 create mode 100644 gcc/config/or1k/or1k.h
 create mode 100644 gcc/config/or1k/or1k.md
 create mode 100644 gcc/config/or1k/or1k.opt
 create mode 100644 gcc/config/or1k/predicates.md
 create mode 100644 gcc/config/or1k/rtems.h
 create mode 100644 gcc/config/or1k/t-or1k
 create mode 100644 gcc/config/or1k/t-rtems
 create mode 100644 gcc/testsuite/gcc.target/or1k/args-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/args-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/cmov-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/cmov-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/div-mul-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/div-mul-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/or1k.exp
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-3.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-4.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/ror-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/ror-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/ror-3.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/shftimm-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/shftimm-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/sibcall-1.c
 create mode 100644 libgcc/config/or1k/lib1funcs.S
 create mode 100644 libgcc/config/or1k/linux-unwind.h
 create mode 100644 libgcc/config/or1k/sfp-machine.h
 create mode 100644 libgcc/config/or1k/t-or1k
Signature · 1 line
2.17.2
#1 lore raw

PATCH v4 1/3 or1k: libgcc: initial support for openrisc

yyyy-mm-dd Stafford Horne <[email protected]>
Richard Henderson <[email protected]>

libgcc/ChangeLog:

* config.host: Add OpenRISC support.
* config/or1k/*: New.

---
 libgcc/config.host                |  12 ++
 libgcc/config/or1k/lib1funcs.S    | 222 ++++++++++++++++++++++++++++++
 libgcc/config/or1k/linux-unwind.h |  87 ++++++++++++
 libgcc/config/or1k/sfp-machine.h  |  54 ++++++++
 libgcc/config/or1k/t-or1k         |  22 +++
 5 files changed, 397 insertions(+)
 create mode 100644 libgcc/config/or1k/lib1funcs.S
 create mode 100644 libgcc/config/or1k/linux-unwind.h
 create mode 100644 libgcc/config/or1k/sfp-machine.h
 create mode 100644 libgcc/config/or1k/t-or1k
libgcc/config.host +12 -0
index 029f6569caf..1cbc8aca1cb 100644
@@ -165,6 +165,9 @@ nds32*-*)
 nios2*-*-*)
 	cpu_type=nios2
 	;;
+or1k*-*-*)
+	cpu_type=or1k
+	;;
 powerpc*-*-*)
 	cpu_type=rs6000
 	;;
@@ -1039,6 +1042,15 @@ nios2-*-*)
 	tmake_file="$tmake_file nios2/t-nios2 t-softfp-sfdf t-softfp-excl t-softfp"
 	extra_parts="$extra_parts crti.o crtn.o"
 	;;
+or1k-*-linux*)
+	tmake_file="$tmake_file or1k/t-or1k"
+	tmake_file="$tmake_file t-softfp-sfdf t-softfp"
+	md_unwind_header=or1k/linux-unwind.h
+	;;
+or1k-*-*)
+	tmake_file="$tmake_file or1k/t-or1k"
+	tmake_file="$tmake_file t-softfp-sfdf t-softfp"
+	;;
 pdp11-*-*)
 	tmake_file="pdp11/t-pdp11 t-fdpbit"
 	;;
libgcc/config/or1k/lib1funcs.S new file +222 -0

222 lines not on this page · raw message

libgcc/config/or1k/linux-unwind.h new file +87 -0

87 lines not on this page · raw message

libgcc/config/or1k/sfp-machine.h new file +54 -0

54 lines not on this page · raw message

libgcc/config/or1k/t-or1k new file +22 -0
new file mode 100644
index 00000000000..73a703ac58d
@@ -0,0 +1,22 @@
+# Libgcc Makefile fragment for OpenRISC
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# Contributed by Stafford Horne.
+#
+# 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/>.
+
+LIB1ASMSRC = or1k/lib1funcs.S
+LIB1ASMFUNCS = __mulsi3 __udivsi3 __divsi3 __umodsi3 __modsi3
Signature · 1 line
2.17.2
#2 lore raw

PATCH v4 2/3 or1k: testsuite: initial support for openrisc

In reply to Stafford Horne

yyyy-mm-dd Stafford Horne <[email protected]>
Richard Henderson <[email protected]>

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/20101011-1.c: Adjust for OpenRISC.
* gcc.dg/20020312-2.c: Likewise.
* gcc.dg/attr-alloc_size-11.c: Likewise.
* gcc.dg/builtin-apply2.c: Likewise.
* gcc.dg/nop.h: Likewise.
* gcc.dg/torture/stackalign/builtin-apply-2.c: Likewise.
* gcc.dg/tree-ssa/20040204-1.c: Likewise.
* gcc.dg/tree-ssa/reassoc-33.c: Likewise.
* gcc.dg/tree-ssa/reassoc-34.c: Likewise.
* gcc.dg/tree-ssa/reassoc-35.c: Likewise.
* gcc.dg/tree-ssa/reassoc-36.c: Likewise.
* lib/target-supports.exp (check_effective_target_logical_op_short_circuit): Add or1k*-*-*.
* gcc.target/or1k/*: New.

---
 .../gcc.c-torture/execute/20101011-1.c        |  3 ++
 gcc/testsuite/gcc.dg/20020312-2.c             |  2 +
 gcc/testsuite/gcc.dg/attr-alloc_size-11.c     |  4 +-
 gcc/testsuite/gcc.dg/builtin-apply2.c         |  2 +-
 gcc/testsuite/gcc.dg/nop.h                    |  2 +
 .../torture/stackalign/builtin-apply-2.c      |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c    |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c    |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c    |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c    |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c    |  2 +-
 gcc/testsuite/gcc.target/or1k/args-1.c        | 19 +++++++++
 gcc/testsuite/gcc.target/or1k/args-2.c        | 15 +++++++
 gcc/testsuite/gcc.target/or1k/cmov-1.c        |  8 ++++
 gcc/testsuite/gcc.target/or1k/cmov-2.c        |  9 ++++
 gcc/testsuite/gcc.target/or1k/div-mul-1.c     |  9 ++++
 gcc/testsuite/gcc.target/or1k/div-mul-2.c     |  9 ++++
 gcc/testsuite/gcc.target/or1k/or1k.exp        | 41 +++++++++++++++++++
 gcc/testsuite/gcc.target/or1k/return-1.c      | 10 +++++
 gcc/testsuite/gcc.target/or1k/return-2.c      | 19 +++++++++
 gcc/testsuite/gcc.target/or1k/return-3.c      | 19 +++++++++
 gcc/testsuite/gcc.target/or1k/return-4.c      | 19 +++++++++
 gcc/testsuite/gcc.target/or1k/ror-1.c         |  8 ++++
 gcc/testsuite/gcc.target/or1k/ror-2.c         |  9 ++++
 gcc/testsuite/gcc.target/or1k/ror-3.c         |  8 ++++
 gcc/testsuite/gcc.target/or1k/shftimm-1.c     |  8 ++++
 gcc/testsuite/gcc.target/or1k/shftimm-2.c     |  8 ++++
 gcc/testsuite/gcc.target/or1k/sibcall-1.c     | 18 ++++++++
 gcc/testsuite/lib/target-supports.exp         |  1 +
 29 files changed, 253 insertions(+), 9 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/or1k/args-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/args-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/cmov-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/cmov-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/div-mul-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/div-mul-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/or1k.exp
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-3.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/return-4.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/ror-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/ror-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/ror-3.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/shftimm-1.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/shftimm-2.c
 create mode 100644 gcc/testsuite/gcc.target/or1k/sibcall-1.c
gcc/testsuite/gcc.c-torture/execute/20101011-1.c +3 -0
index 8261b796a47..d2beeb52a0e 100644
@@ -100,6 +100,9 @@ __aeabi_idiv0 (int return_value)
 #elif defined (__moxie__)
   /* Not all moxie configurations may raise exceptions.  */
 # define DO_TEST 0
+#elif defined (__or1k__)
+  /* On OpenRISC division by zero does not trap.  */
+# define DO_TEST 0
 #else
 # define DO_TEST 1
 #endif
gcc/testsuite/gcc.dg/20020312-2.c +2 -0
index 1a8afd81506..e72a5b261ae 100644
@@ -117,6 +117,8 @@ extern void abort (void);
 # if defined (__CK807__) || defined (__CK810__)
 #   define PIC_REG  "r28"
 # endif
+#elif defined (__or1k__)
+/* No pic register.  */
 #else
 # error "Modify the test for your target."
 #endif
gcc/testsuite/gcc.dg/attr-alloc_size-11.c +2 -2
index 301a06fd464..e19f81a7624 100644
@@ -47,8 +47,8 @@ typedef __SIZE_TYPE__    size_t;
 
 /* The following tests fail because of missing range information.  The xfail
    exclusions are PR79356.  */
-TEST (signed char, SCHAR_MIN + 2, ALLOC_MAX);   /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for signed char" { xfail { ! { aarch64*-*-* arm*-*-* avr-*-* alpha*-*-* ia64-*-* mips*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390*-*-* visium-*-* } } } } */
-TEST (short, SHRT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for short" { xfail { ! { aarch64*-*-* arm*-*-* alpha*-*-* avr-*-* ia64-*-* mips*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390x-*-* visium-*-* } } } } */
+TEST (signed char, SCHAR_MIN + 2, ALLOC_MAX);   /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for signed char" { xfail { ! { aarch64*-*-* arm*-*-* avr-*-* alpha*-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390*-*-* visium-*-* } } } } */
+TEST (short, SHRT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for short" { xfail { ! { aarch64*-*-* arm*-*-* alpha*-*-* avr-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390x-*-* visium-*-* } } } } */
 TEST (int, INT_MIN + 2, ALLOC_MAX);    /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
 TEST (int, -3, ALLOC_MAX);             /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
 TEST (int, -2, ALLOC_MAX);             /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
gcc/testsuite/gcc.dg/builtin-apply2.c +1 -1
index 3768caa5d5a..dd521973cae 100644
@@ -1,7 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target untyped_assembly } */
 /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args in registers." { "avr-*-* nds32*-*-*" } } */
-/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs." { "riscv*-*-*" } } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs." { "riscv*-*-* or1k*-*-*" } } */
 /* { dg-skip-if "Variadic funcs use Base AAPCS.  Normal funcs use VFP variant." { arm*-*-* && arm_hf_eabi } } */
 
 /* PR target/12503 */
gcc/testsuite/gcc.dg/nop.h +2 -0
index a0c19a34414..23491a603f5 100644
@@ -2,6 +2,8 @@
 #define NOP "nop 0"
 #elif defined (__MMIX__)
 #define NOP "swym 0"
+#elif defined (__or1k__)
+#define NOP "l.nop"
 #else
 #define NOP "nop"
 #endif
gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c +1 -1
index d033010dc7c..3f8d350ba8f 100644
@@ -9,7 +9,7 @@
 /* arm_hf_eabi: Variadic funcs use Base AAPCS.  Normal funcs use VFP variant.
    avr: Variadic funcs don't pass arguments in registers, while normal funcs
         do.  */
-/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs" { arm_hf_eabi || { avr-*-* riscv*-*-* } } } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs" { arm_hf_eabi || { avr-*-* riscv*-*-* or1k*-*-* } } } */
 /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args in registers." { nds32*-*-* } } */
 /* { dg-require-effective-target untyped_assembly } */
    
gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c +1 -1
index a1237cf839b..bc486e32586 100644
@@ -33,4 +33,4 @@ void test55 (int x, int y)
    that the && should be emitted (based on BRANCH_COST).  Fix this
    by teaching dom to look through && and register all components
    as true.  */
-/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" { xfail { ! "alpha*-*-* arm*-*-* aarch64*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* i?86-*-* mmix-*-* mips*-*-* m68k*-*-* moxie-*-* nds32*-*-* s390*-*-* sh*-*-* sparc*-*-* spu-*-* visium-*-* x86_64-*-* riscv*-*-*" } } } } */
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" { xfail { ! "alpha*-*-* arm*-*-* aarch64*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* i?86-*-* mmix-*-* mips*-*-* m68k*-*-* moxie-*-* nds32*-*-* s390*-*-* sh*-*-* sparc*-*-* spu-*-* visium-*-* x86_64-*-* riscv*-*-* or1k*-*-*" } } } } */
gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c +1 -1
index 5572df4ae24..243508c872c 100644
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k-*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c +1 -1
index 9b45f1cd9be..24070046ef2 100644
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c +1 -1
index 9ee3abca04e..e5ba101e001 100644
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c +1 -1
index ac3a04291b7..4df5840859c 100644
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-* or1k*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
gcc/testsuite/gcc.target/or1k/args-1.c new file +19 -0
new file mode 100644
index 00000000000..7538705d07f
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct a {
+  long x;
+  long y;
+  long z;
+};
+
+int passlibstruct (int b, struct a aa);
+
+int main() {
+  struct a aa = { 55, 66, 77 };
+
+  return passlibstruct(-1, aa);
+}
+
+/* Ensure we pass a stack reference in the second arg.  */
+/* { dg-final { scan-assembler-times "r4, r1, " 1 } } */
gcc/testsuite/gcc.target/or1k/args-2.c new file +15 -0
new file mode 100644
index 00000000000..362f7c0c9e9
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct a {
+  long x;
+  long y;
+  long z;
+};
+
+int passstruct (int b, struct a aa) {
+  return aa.z + aa.y + b;
+}
+
+/* Ensure our struct reads are offset from the address in arg 2.  */
+/* { dg-final { scan-assembler-times "l.lwz\\s+r\\d+, \\d+.r4." 2 } } */
gcc/testsuite/gcc.target/or1k/cmov-1.c new file +8 -0
new file mode 100644
index 00000000000..c66b67c07c7
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mcmov -O2" } */
+
+int cond (int a, int b) {
+  return a > b;
+}
+
+/* { dg-final { scan-assembler "l.cmov" } } */
gcc/testsuite/gcc.target/or1k/cmov-2.c new file +9 -0
new file mode 100644
index 00000000000..9b3b5529740
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-skip-if "" { *-*-* }  { "-mcmov" } { "" } } */
+
+int cond (int a, int b) {
+  return a > b;
+}
+
+/* { dg-final { scan-assembler-not "l.cmov" } } */
gcc/testsuite/gcc.target/or1k/div-mul-1.c new file +9 -0
new file mode 100644
index 00000000000..a5e8d286545
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -msoft-mul -msoft-div" } */
+
+int calc (int a, int b, int c) {
+  return a * b / c;
+}
+
+/* { dg-final { scan-assembler-not "l.mul" } } */
+/* { dg-final { scan-assembler-not "l.div" } } */
gcc/testsuite/gcc.target/or1k/div-mul-2.c new file +9 -0
new file mode 100644
index 00000000000..a567d7d9f50
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -msoft-div" } */
+
+int calc (int a, int b, int c) {
+  return a * b / c;
+}
+
+/* { dg-final { scan-assembler "l.mul" } } */
+/* { dg-final { scan-assembler-not "l.div" } } */
gcc/testsuite/gcc.target/or1k/or1k.exp new file +41 -0

41 lines not on this page · raw message

gcc/testsuite/gcc.target/or1k/return-1.c new file +10 -0
new file mode 100644
index 00000000000..6dd04197164
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+long long calc (long long a, long long b) {
+  return a * b + 5;
+}
+
+/* Ensure our return value is set in the r11, r12 pair.  */
+/* { dg-final { scan-assembler "r11," } } */
+/* { dg-final { scan-assembler "r12," } } */
gcc/testsuite/gcc.target/or1k/return-2.c new file +19 -0
new file mode 100644
index 00000000000..c072ae23142
@@ -0,0 +1,19 @@
+/* Large structs are returned at a memory address passed in r3.  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct a {
+  long x;
+  long y;
+  long z;
+};
+
+struct a getstruct (long aa) {
+  struct a as = { 22, aa, -5 };
+  return as;
+}
+
+/* Ensure our return value is returned on stack.  */
+/* { dg-final { scan-assembler-not "r12," } } */
+/* { dg-final { scan-assembler "l.or\\s+r11, r3, r3" } } */
+/* { dg-final { scan-assembler-times "l.sw\\s+\\d+.r3.," 3 } } */
gcc/testsuite/gcc.target/or1k/return-3.c new file +19 -0
new file mode 100644
index 00000000000..5c2e5f5ad91
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct a {
+  long x;
+  long y;
+  long z;
+};
+
+struct a getlibstruct (long aa);
+
+int main() {
+  struct a rs = getlibstruct(123);
+
+  return rs.x;
+}
+
+/* Ensure our return value is read from memory.  */
+/* { dg-final { scan-assembler "l.lwz\\s+r11," } } */
gcc/testsuite/gcc.target/or1k/return-4.c new file +19 -0
new file mode 100644
index 00000000000..b866f58a307
@@ -0,0 +1,19 @@
+/* Test to ensure small structs are returned in memory too.  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct a {
+  long x;
+  long y;
+};
+
+struct a getlibstruct (long aa);
+
+int main() {
+  struct a rs = getlibstruct(123);
+
+  return rs.x;
+}
+
+/* Ensure our return value is read from memory.  */
+/* { dg-final { scan-assembler "l.lwz\\s+r11," } } */
gcc/testsuite/gcc.target/or1k/ror-1.c new file +8 -0
new file mode 100644
index 00000000000..df55a6adfef
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mror -O2" } */
+
+unsigned int rotate (unsigned int a, int b) {
+  return ( a >> b ) | ( a << ( 32 - b ) );
+}
+
+/* { dg-final { scan-assembler "l.ror" } } */
gcc/testsuite/gcc.target/or1k/ror-2.c new file +9 -0
new file mode 100644
index 00000000000..9cd7f35d285
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-skip-if "" { *-*-* }  { "-mror" } { "" } } */
+
+unsigned int rotate (unsigned int a, int b) {
+  return ( a >> b ) | ( a << ( 32 - b ) );
+}
+
+/* { dg-final { scan-assembler-not "l.ror" } } */
gcc/testsuite/gcc.target/or1k/ror-3.c new file +8 -0
new file mode 100644
index 00000000000..b0a73b3064d
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mror -O2" } */
+
+unsigned int rotate6 (unsigned int a) {
+  return ( a >> 6 ) | ( a << ( 32 - 6 ) );
+}
+
+/* { dg-final { scan-assembler-not "l.rori" } } */
gcc/testsuite/gcc.target/or1k/shftimm-1.c new file +8 -0
new file mode 100644
index 00000000000..be8d9e8b895
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mror -mshftimm -O2" } */
+
+unsigned int rotate6 (unsigned int a) {
+  return ( a >> 6 ) | ( a << ( 32 - 6 ) );
+}
+
+/* { dg-final { scan-assembler "l.rori" } } */
gcc/testsuite/gcc.target/or1k/shftimm-2.c new file +8 -0
new file mode 100644
index 00000000000..ef9b52f2820
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mshftimm -O2" } */
+
+unsigned int shift6 (unsigned int a) {
+  return a >> 6;
+}
+
+/* { dg-final { scan-assembler "l.srli" } } */
gcc/testsuite/gcc.target/or1k/sibcall-1.c new file +18 -0
new file mode 100644
index 00000000000..8134f0cfe35
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* Just create some dummy call that should trigger sibcall, no
+   stack logic.  */
+int calc (int a, int b, int c) {
+  if (c <= 0) return a;
+  return calc (a * b, b, --c);
+}
+
+int main() {
+   return calc (4, 3, 4);
+}
+
+/* Ensure sibcalls do not need to manipulate the stack.  */
+/* { dg-final { scan-assembler-not "r1," } } */
+/* Ensure sibcall maintains the body of the function.  */
+/* { dg-final { scan-assembler "l.mul" } } */
gcc/testsuite/lib/target-supports.exp +1 -0
index 9780e53dfc0..22daaf43a46 100644
@@ -8394,6 +8394,7 @@ proc check_effective_target_logical_op_short_circuit {} {
 	 || [istarget riscv*-*-*]
 	 || [istarget v850*-*-*]
 	 || [istarget visium-*-*]
+	 || [istarget or1k*-*-*]
 	 || [check_effective_target_arm_cortex_m] } {
 	return 1
     }
Signature · 1 line
2.17.2
#3 lore raw

PATCH v4 3/3 or1k: gcc: initial support for openrisc

In reply to Stafford Horne

yyyy-mm-dd Stafford Horne <[email protected]>
Richard Henderson <[email protected]>
Joel Sherrill <[email protected]>

gcc/ChangeLog:

* common/config/or1k/or1k-common.c: New file.
* config/or1k/*: New.
* config.gcc (or1k*-*-*): New.
* configure.ac (or1k*-*-*): New test for openrisc tls.
* configure: Regenerated.
* doc/install.texi: Document OpenRISC triplets.
* doc/invoke.texi: Document OpenRISC arguments.
* doc/md.texi: Document OpenRISC.

---
 gcc/common/config/or1k/or1k-common.c |   41 +
 gcc/config.gcc                       |   45 +
 gcc/config/or1k/constraints.md       |   55 +
 gcc/config/or1k/elf.h                |   42 +
 gcc/config/or1k/elf.opt              |   33 +
 gcc/config/or1k/linux.h              |   45 +
 gcc/config/or1k/or1k-protos.h        |   38 +
 gcc/config/or1k/or1k.c               | 2183 ++++++++++++++++++++++++++
 gcc/config/or1k/or1k.h               |  392 +++++
 gcc/config/or1k/or1k.md              |  897 +++++++++++
 gcc/config/or1k/or1k.opt             |   67 +
 gcc/config/or1k/predicates.md        |   84 +
 gcc/config/or1k/rtems.h              |   30 +
 gcc/config/or1k/t-or1k               |   22 +
 gcc/config/or1k/t-rtems              |    3 +
 gcc/configure                        |   12 +
 gcc/configure.ac                     |   12 +
 gcc/doc/install.texi                 |   19 +
 gcc/doc/invoke.texi                  |   68 +
 gcc/doc/md.texi                      |   25 +
 20 files changed, 4113 insertions(+)
 create mode 100644 gcc/common/config/or1k/or1k-common.c
 create mode 100644 gcc/config/or1k/constraints.md
 create mode 100644 gcc/config/or1k/elf.h
 create mode 100644 gcc/config/or1k/elf.opt
 create mode 100644 gcc/config/or1k/linux.h
 create mode 100644 gcc/config/or1k/or1k-protos.h
 create mode 100644 gcc/config/or1k/or1k.c
 create mode 100644 gcc/config/or1k/or1k.h
 create mode 100644 gcc/config/or1k/or1k.md
 create mode 100644 gcc/config/or1k/or1k.opt
 create mode 100644 gcc/config/or1k/predicates.md
 create mode 100644 gcc/config/or1k/rtems.h
 create mode 100644 gcc/config/or1k/t-or1k
 create mode 100644 gcc/config/or1k/t-rtems
gcc/common/config/or1k/or1k-common.c new file +41 -0
new file mode 100644
index 00000000000..044e843fd19
@@ -0,0 +1,41 @@
+/* Common hooks for OpenRISC
+   Copyright (C) 2018 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 "diagnostic-core.h"
+#include "tm.h"
+#include "common/common-target.h"
+#include "common/common-target-def.h"
+#include "opts.h"
+#include "flags.h"
+
+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
+static const struct default_options or1k_option_optimization_table[] =
+  {
+    /* Enable section anchors by default at -O1 or higher.  */
+    { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 },
+    { OPT_LEVELS_NONE, 0, NULL, 0 }
+  };
+
+#undef TARGET_OPTION_OPTIMIZATION_TABLE
+#define TARGET_OPTION_OPTIMIZATION_TABLE or1k_option_optimization_table
+
+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
gcc/config.gcc +45 -0

57 lines not on this page · raw message

gcc/config/or1k/constraints.md new file +55 -0

55 lines not on this page · raw message

gcc/config/or1k/elf.h new file +42 -0

42 lines not on this page · raw message

gcc/config/or1k/elf.opt new file +33 -0
new file mode 100644
index 00000000000..956d395003d
@@ -0,0 +1,33 @@
+; OpenRISC command line options for newlib binaries
+
+; Copyright (C) 2010-2018 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/>.
+
+; See the GCC internals manual (options.texi) for a description of
+; this file's format.
+
+; Please try to keep this file in ASCII collating order.
+
+mboard=
+Target RejectNegative Joined
+Configure board specific runtime.
+
+mnewlib
+Target RejectNegative
+For compatibility, it's always newlib for elf now.
+
gcc/config/or1k/linux.h new file +45 -0

45 lines not on this page · raw message

gcc/config/or1k/or1k-protos.h new file +38 -0
new file mode 100644
index 00000000000..e18383ae781
@@ -0,0 +1,38 @@
+/* Prototypes for OpenRISC functions used in the md file & elsewhere.
+   Copyright (C) 2018 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/>.  */
+
+extern HOST_WIDE_INT or1k_initial_elimination_offset (int, int);
+extern void or1k_expand_prologue (void);
+extern void or1k_expand_epilogue (void);
+extern void or1k_expand_eh_return (rtx);
+extern rtx  or1k_initial_frame_addr (void);
+extern rtx  or1k_dynamic_chain_addr (rtx);
+extern rtx  or1k_return_addr (int, rtx);
+extern void or1k_expand_move (machine_mode, rtx, rtx);
+extern void or1k_expand_compare (rtx *);
+extern void or1k_expand_call (rtx, rtx, rtx, bool);
+
+#ifdef RTX_CODE
+void or1k_expand_atomic_compare_and_swap (rtx operands[]);
+void or1k_expand_atomic_compare_and_swap_qihi (rtx operands[]);
+void or1k_expand_atomic_exchange (rtx operands[]);
+void or1k_expand_atomic_exchange_qihi (rtx operands[]);
+void or1k_expand_atomic_op (rtx_code, rtx, rtx, rtx, rtx);
+void or1k_expand_atomic_op_qihi (rtx_code, rtx, rtx, rtx, rtx);
+#endif
gcc/config/or1k/or1k.c new file +2183 -0

2,183 lines not on this page · raw message

gcc/config/or1k/or1k.h new file +392 -0

392 lines not on this page · raw message

gcc/config/or1k/or1k.md new file +897 -0

114 lines not on this page · raw message

gcc/config/or1k/or1k.opt new file +67 -0

67 lines not on this page · raw message

gcc/config/or1k/predicates.md new file +84 -0

84 lines not on this page · raw message

gcc/config/or1k/rtems.h new file +30 -0
new file mode 100644
index 00000000000..0c3d39cc9c4

Lines of this file are not shown. View the raw message.

gcc/config/or1k/t-or1k new file +22 -0
new file mode 100644
index 00000000000..6771c82da08

Lines of this file are not shown. View the raw message.

gcc/config/or1k/t-rtems new file +3 -0
new file mode 100644
index 00000000000..e4e5e1dca97

Lines of this file are not shown. View the raw message.

gcc/configure +12 -0
index a24221d580c..65e026b817b 100755

Lines of this file are not shown. View the raw message.

gcc/configure.ac +12 -0
index 59585912556..260d987dadd 100644

Lines of this file are not shown. View the raw message.

gcc/doc/install.texi +19 -0
index 52548995d95..7ccab525622 100644

Lines of this file are not shown. View the raw message.

gcc/doc/invoke.texi +68 -0

68 lines not on this page · raw message

gcc/doc/md.texi +25 -0
index 360b36b862f..46806bbea37 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.2

Part of the diff is not shown here. View the raw message.

#4 lore raw

v4 cover OpenRISC port

In reply to Stafford Horne
Quoted 15 lines · Stafford Horne

As you can see this is v4 of the OpenRISC port patch series, I just want to mention that there are a few things pointed out during the v3 review that I have not fixed, and do not plan before pushing upstream. These are either because I didn't feel they made the code easier to read or they were things that could wait unil after upstreaming. These include:

(not changed)
- libgcc !cmov 1cyc improvements suggested by Richard
- gcc eliminations refactorings suggested by Segher
- leaving out empty constraint strings suggested by Segher
- implementing TARGET_ISNS_COST suggested by Segher

Please let me know if you have concerns; now onto the patches:

Quoted 7 lines

Changes Since v3:
- Fix tabs formatting pointed out by Segher
- Fix comment formatting and typos pointed out by Segher
- Fix for sign/zero extention login in md file from Richard
- Remove usages of ATTRIBUTE_UNUSED suggested by Segher
- Remove need for init/fini, removing crti/n.S files
- Add support for -static-pie in LINK_SPEC suggsted by Szabolcs

All ok. I agree that the other improvements you detail above can be handled via normal development.

r~