OpenRISC port
v2 cover OpenRISC port
Hello,
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
- 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-20180730
# Building
To build this requires some of the latest binutils patches submitted here:
- https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01506.html
- git tree: https://github.com/stffrdhrn/binutils-gdb/tree/or1k-6
-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 | 44 + gcc/config/or1k/or1k-protos.h | 38 + gcc/config/or1k/or1k.c | 2186 +++++++++++++++++ gcc/config/or1k/or1k.h | 392 +++ gcc/config/or1k/or1k.md | 894 +++++++ gcc/config/or1k/or1k.opt | 62 + gcc/config/or1k/predicates.md | 84 + gcc/config/or1k/t-or1k | 22 + gcc/configure | 12 + gcc/configure.ac | 12 + gcc/doc/install.texi | 19 + gcc/doc/invoke.texi | 62 + 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/sibcall-1.c | 18 + gcc/testsuite/lib/target-supports.exp | 1 + libgcc/config.host | 13 + libgcc/config/or1k/crti.S | 33 + libgcc/config/or1k/crtn.S | 1 + libgcc/config/or1k/lib1funcs.S | 223 ++ libgcc/config/or1k/linux-unwind.h | 87 + libgcc/config/or1k/sfp-machine.h | 54 + libgcc/config/or1k/t-or1k | 22 + 49 files changed, 4713 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/t-or1k 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/sibcall-1.c create mode 100644 libgcc/config/or1k/crti.S create mode 100644 libgcc/config/or1k/crtn.S 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.1
PATCH v2 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.
---
Changes since v1:
- Use __or1k_cmov__ in *.S to conditionally use l.cmov insn
- Use init/fini array making the crti/crtn basically blank
libgcc/config.host | 13 ++ libgcc/config/or1k/crti.S | 33 +++++ libgcc/config/or1k/crtn.S | 1 + libgcc/config/or1k/lib1funcs.S | 223 ++++++++++++++++++++++++++++++ libgcc/config/or1k/linux-unwind.h | 87 ++++++++++++ libgcc/config/or1k/sfp-machine.h | 54 ++++++++ libgcc/config/or1k/t-or1k | 22 +++ 7 files changed, 433 insertions(+) create mode 100644 libgcc/config/or1k/crti.S create mode 100644 libgcc/config/or1k/crtn.S 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 +13 -0
@@ -165,6 +165,9 @@ nds32*-*) nios2*-*-*) cpu_type=nios2 ;; +or1k*-*-*) + cpu_type=or1k + ;; powerpc*-*-*) cpu_type=rs6000 ;;
@@ -1039,6 +1042,16 @@ 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-excl 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-excl t-softfp" + extra_parts="$extra_parts crti.o crtn.o" + ;; pdp11-*-*) tmake_file="pdp11/t-pdp11 t-fdpbit" ;;
libgcc/config/or1k/crti.S new file +33 -0
@@ -0,0 +1,33 @@ +/* Copyright (C) 2012-2018 Free Software Foundation, Inc. + +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 the +Free Software Foundation; either version 3, or (at your option) any +later version. + +This file 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/>. */ + +/* Here _init and _fini are empty because .init_array/.fini_array are used + exclusively. However, the functions are still needed as required when + linking. */ + .align 4 + .global _init + .type _init, at function +_init: + .global _fini + .type _fini, at function +_fini: + l.jr r9 + l.nop
libgcc/config/or1k/crtn.S new file +1 -0
@@ -0,0 +1 @@ +/* crtn.S is empty because .init_array/.fini_array are used exclusively. */
libgcc/config/or1k/lib1funcs.S new file +223 -0
223 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
@@ -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.1
PATCH v2 1/3 or1k: libgcc: initial support for openrisc
libgcc/config.host nios2-*-*) · line 1054
Quoted 10 lines · Stafford Horne
libgcc/config.host +10
-0+or1k-*-linux*) + tmake_file="$tmake_file or1k/t-or1k" + tmake_file="$tmake_file t-softfp-sfdf t-softfp-excl 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-excl t-softfp" + extra_parts="$extra_parts crti.o crtn.o" + ;;
Could you clarify why you are using t-softfp-excl?
In general, for soft-float configurations it's best not to use t-softfp-excl - meaning the floating-point operations from libgcc2.c get implemented directly in soft-fp, rather than through libgcc2.c wrapping other soft-fp operations. While for hard-float configurations it's best not to use soft-fp at all.
If you have hard-float configurations using a soft-float ABI, that thus need to provide all the functions in question so soft-float objects / programs can be linked with hard-float libgcc, t-hardfp should be used instead when building a hard-float multilib. (It's possible to have more complicated mixtures in cases where some operations or types come from hardfp and others from softfp; some mips and powerpcspe configurations do.)
Signature · 2 lines
Joseph S. Myers joseph at codesourcery.com
PATCH v2 1/3 or1k: libgcc: initial support for openrisc
Quoted 21 lines · Joseph Myers
libgcc/config.host nios2-*-*) · line 1054
Quoted 10 lines · Stafford Horne
libgcc/config.host +10
-0+or1k-*-linux*) + tmake_file="$tmake_file or1k/t-or1k" + tmake_file="$tmake_file t-softfp-sfdf t-softfp-excl 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-excl t-softfp" + extra_parts="$extra_parts crti.o crtn.o" + ;;Could you clarify why you are using t-softfp-excl?
In general, for soft-float configurations it's best not to use t-softfp-excl - meaning the floating-point operations from
libgcc2.cget implemented directly in soft-fp, rather than throughlibgcc2.cwrapping other soft-fp operations. While for hard-float configurations it's best not to use soft-fp at all.
Quoted 7 lines
If you have hard-float configurations using a soft-float ABI, that thus need to provide all the functions in question so soft-float objects / programs can be linked with hard-float libgcc, t-hardfp should be used instead when building a hard-float multilib. (It's possible to have more complicated mixtures in cases where some operations or types come from hardfp and others from softfp; some mips and powerpcspe configurations do.)
Hello,
I don't know of a reason for using t-softfp-excl, I think Richard or I was just copying from what we saw similar targets do. I just removed it and reran some of the tests and don't see any regressions.
We will be patching in hardfp post upstreaming, so the notes above are very helpful.
-Stafford
PATCH v2 2/3 or1k: testsuite: initial support for openrisc
In reply to Stafford Horneyyyy-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.
---
Changes since v1:
- Add cmov-* test which uses multilib -mcmov flag
.../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/sibcall-1.c | 18 ++++++++ gcc/testsuite/lib/target-supports.exp | 1 + 24 files changed, 212 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/sibcall-1.c
gcc/testsuite/gcc.c-torture/execute/20101011-1.c +3 -0
@@ -97,6 +97,9 @@ __aeabi_idiv0 (int return_value)/* This presently doesn't raise SIGFPE even on csky-linux-gnu, much less bare metal. See the implementation of __divsi3 in libgcc. */ # 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
@@ -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
@@ -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*-*-* 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*-*-* 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*-*-* powerpc*-*-* sparc*-*-* s390*-*-* visium-*-* or1k*-*-* } } } } */ +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*-*-* powerpc*-*-* sparc*-*-* s390x-*-* visium-*-* or1k*-*-* } } } } */ 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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/sibcall-1.c new file +18 -0
@@ -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
@@ -8856,6 +8856,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.1
PATCH v2 2/3 or1k: testsuite: initial support for openrisc
Quoted 6 lines · Stafford Horne
yyyy-mm-dd Stafford Horne <[email protected]>
Richard Henderson <[email protected]>gcc/testsuite/ChangeLog:
Quoted 14 lines
* 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.
Not sure this needs any extra review, but I did, so, Ok.
PATCH v2 3/3 or1k: gcc: initial support for openrisc
In reply to Stafford Horneyyyy-mm-dd Stafford Horne <[email protected]>
Richard Henderson <[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.
---
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.
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 | 44 + gcc/config/or1k/or1k-protos.h | 38 + gcc/config/or1k/or1k.c | 2186 ++++++++++++++++++++++++++ gcc/config/or1k/or1k.h | 392 +++++ gcc/config/or1k/or1k.md | 894 +++++++++++ gcc/config/or1k/or1k.opt | 62 + gcc/config/or1k/predicates.md | 84 + gcc/config/or1k/t-or1k | 22 + gcc/configure | 12 + gcc/configure.ac | 12 + gcc/doc/install.texi | 19 + gcc/doc/invoke.texi | 62 + gcc/doc/md.texi | 25 + 18 files changed, 4068 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/t-or1k
gcc/common/config/or1k/or1k-common.c new file +41 -0
@@ -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
@@ -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 +44 -0
44 lines not on this page · raw message
gcc/config/or1k/or1k-protos.h new file +38 -0
@@ -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 +2186 -0
2,186 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 +894 -0
112 lines not on this page · raw message
gcc/config/or1k/or1k.opt new file +62 -0
62 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/doc/invoke.texi +62 -0
62 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.