sim port for OpenRISC
v3 cover sim port for OpenRISC
Hello Again,
Please find attached the sim patches that allow to get a basic OpenRISC system running. This was used to verify the OpenRISC gdb port.
The main author is Peter Gavin who should have his FSF copyright in place.
Request for comments on:
- The testcase has a few tests commented out. I do not plan to fix now, but hopefully be addressed after upstreaming.
- Openrisc supports a l.rem instruction which has been implemented here using the drem() function from libmath. It seems no other functions use libmath now, I hope this is ok.
Sim dejagnu tests were added specifically for openrisc and used to test this. Please see the details of running the testsuite for sim below:
=== sim Summary ===
# of expected passes 17 /home/shorne/work/openrisc/build-gdb/sim/or1k/run 0.5
Thanks,
-Stafford
Changes since v2
* Removed 64-bit implementation (reduced files)
* Removed cgen suffix patch
* Removed different builds for linux
* Removed unused macros
* Fixed gnu style issues pointed out by Mike
* Fixed copyrights (not Cygnus, added to each file)
Changes since v1
* Squashed sim patches into single sim patch
* Put Generated files in separate patch
* I have my sim/gdb copyright assignment complete
Peter Gavin (3):
sim: cgen: add rem (remainder) function (needed for OR1K lf.rem.[sd])
sim: cgen: add mul-o1flag, mul-o2flag RTL functions to CGEN
sim: testsuite: add testsuite for or1k sim
Stafford Horne (2):
sim: or1k: add or1k target to sim
sim: or1k: Add generated files.
PATCH v3 1/5 sim: cgen: add rem (remainder) function (needed for OR1K lf.rem.[sd])
From: Peter Gavin <[email protected]>
* sim/common/ChangeLog-OR1K:
2012-03-14 Peter Gavin <[email protected]>
* cgen-accfp.c: add rem (remainder) function (needed for OR1K lf.rem.[sd]) (remsf) new function
(remdf) ditto
(struct cgen_fp_ops) add fields for rem[sdxt]f functions
--- sim/common/cgen-accfp.c | 40 ++++++++++++++++++++++++++++++ sim/common/cgen-fpu.h | 4 +++ sim/common/sim-fpu.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ sim/common/sim-fpu.h | 3 +++ 4 files changed, 113 insertions(+)
sim/common/cgen-accfp.c +40 -0
@@ -93,6 +93,25 @@ divsf (CGEN_FPU* fpu, SF x, SF y) }static SF +remsf (CGEN_FPU * fpu,SF x,SF y) +{ +sim_fpu op1; +sim_fpu op2; +sim_fpu ans; +unsigned32 res; +sim_fpu_status status; + +sim_fpu_32to (&op1, x); +sim_fpu_32to (&op2, y); + status =sim_fpu_rem (&ans, &op1, &op2); +if (status !=0 ) + (*fpu->ops->error) (fpu, status); +sim_fpu_to32 (&res, &ans); + +return res; +} + +static SF negsf (CGEN_FPU * fpu,SF x) {sim_fpu op1;
@@ -452,6 +471,25 @@ divdf (CGEN_FPU* fpu, DF x, DF y)return res; } +static SF +remdf (CGEN_FPU * fpu,DF x,DF y) +{ +sim_fpu op1; +sim_fpu op2; +sim_fpu ans; +unsigned64 res; +sim_fpu_status status; + +sim_fpu_64to (&op1, x); +sim_fpu_64to (&op2, y); + status =sim_fpu_rem (&ans, &op1, &op2); +if (status !=0 ) + (*fpu->ops->error) (fpu, status); +sim_fpu_to64 (&res, &ans); + +return res; +} +static DF negdf (CGEN_FPU * fpu,DF x) {
@@ -664,6 +702,7 @@ cgen_init_accurate_fpu (SIM_CPU* cpu, CGEN_FPU* fpu, CGEN_FPU_ERROR_FN* error) o->subsf = subsf; o->mulsf = mulsf; o->divsf = divsf; + o->remsf = remsf; o->negsf = negsf; o->abssf = abssf; o->sqrtsf = sqrtsf;
@@ -682,6 +721,7 @@ cgen_init_accurate_fpu (SIM_CPU* cpu, CGEN_FPU* fpu, CGEN_FPU_ERROR_FN* error) o->subdf = subdf; o->muldf = muldf; o->divdf = divdf; + o->remdf = remdf; o->negdf = negdf; o->absdf = absdf; o->sqrtdf = sqrtdf;
sim/common/cgen-fpu.h +4 -0
@@ -69,6 +69,7 @@ struct cgen_fp_ops {SF (*subsf) (CGEN_FPU *,SF ,SF );SF (*mulsf) (CGEN_FPU *,SF ,SF );SF (*divsf) (CGEN_FPU *,SF ,SF ); +SF (*remsf) (CGEN_FPU *,SF ,SF );SF (*negsf) (CGEN_FPU *,SF );SF (*abssf) (CGEN_FPU *,SF );SF (*sqrtsf) (CGEN_FPU *,SF );
@@ -93,6 +94,7 @@ struct cgen_fp_ops {DF (*subdf) (CGEN_FPU *,DF ,DF );DF (*muldf) (CGEN_FPU *,DF ,DF );DF (*divdf) (CGEN_FPU *,DF ,DF ); +DF (*remdf) (CGEN_FPU *,DF ,DF );DF (*negdf) (CGEN_FPU *,DF );DF (*absdf) (CGEN_FPU *,DF );DF (*sqrtdf) (CGEN_FPU *,DF );
@@ -142,6 +144,7 @@ struct cgen_fp_ops {XF (*subxf) (CGEN_FPU *,XF ,XF );XF (*mulxf) (CGEN_FPU *,XF ,XF );XF (*divxf) (CGEN_FPU *,XF ,XF ); +XF (*remxf) (CGEN_FPU *,XF ,XF );XF (*negxf) (CGEN_FPU *,XF );XF (*absxf) (CGEN_FPU *,XF );XF (*sqrtxf) (CGEN_FPU *,XF );
@@ -180,6 +183,7 @@ struct cgen_fp_ops {TF (*subtf) (CGEN_FPU *,TF ,TF );TF (*multf) (CGEN_FPU *,TF ,TF );TF (*divtf) (CGEN_FPU *,TF ,TF ); +TF (*remtf) (CGEN_FPU *,TF ,TF );TF (*negtf) (CGEN_FPU *,TF );TF (*abstf) (CGEN_FPU *,TF );TF (*sqrttf) (CGEN_FPU *,TF );
sim/common/sim-fpu.c +66 -0
78 lines not on this page · raw message
sim/common/sim-fpu.h +3 -0
@@ -151,6 +151,7 @@ typedef enum sim_fpu_status_overflow =4096 , sim_fpu_status_underflow =8192 , sim_fpu_status_denorm =16384 , + sim_fpu_status_invalid_irx =32768 ,/* (inf % X) */ } sim_fpu_status;
@@ -230,6 +231,8 @@ INLINE_SIM_FPU (int) sim_fpu_mul (sim_fpu *f, const sim_fpu *l, const sim_fpu *r);INLINE_SIM_FPU (int )sim_fpu_div (sim_fpu *f,const sim_fpu *l,const sim_fpu *r); +INLINE_SIM_FPU (int )sim_fpu_rem (sim_fpu *f, +const sim_fpu *l,const sim_fpu *r);INLINE_SIM_FPU (int )sim_fpu_max (sim_fpu *f,const sim_fpu *l,const sim_fpu *r); INLINE_SIM_FPU (int) sim_fpu_min (sim_fpu *f,
Signature · 1 line
2.9.3
PATCH v3 2/5 sim: cgen: add mul-o1flag, mul-o2flag RTL functions to CGEN
In reply to Stafford HorneFrom: Peter Gavin <[email protected]>
* sim/common/ChangeLog
2012-03-14 Peter Gavin <[email protected]>
* add mul-o1flag (1's complement unsigned multiply overflow flag) and mul-o2flag (2's complement signed multiply overflow flag)
* cgen-ops.h:
(MUL1OFSI) new function: 1's complement
(MUL2OFSI) new function: 2's complement
--- sim/common/cgen-ops.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
sim/common/cgen-ops.h +18 -0
@@ -631,6 +631,22 @@ SUBOFQI (QI a, QI b, BI c)return res; } +SEMOPS_INLINE BI +MUL2OFSI (SI a,SI b) +{ +DI tmp =MULDI (EXTSIDI (a),EXTSIDI (b)); +BI res = tmp <-0x80000000LL || tmp >0x7fffffffLL ; +return res; +} + +SEMOPS_INLINE BI +MUL1OFSI (USI a,USI b) +{ +UDI tmp =MULDI (ZEXTSIDI (a),ZEXTSIDI (b)); +BI res = (tmp >0xFFFFFFFFULL ); +return res; +} +#else SI ADDCSI (SI ,SI ,BI );
@@ -651,6 +667,8 @@ UBI ADDOFQI (QI, QI, BI);QI SUBCQI (QI ,QI ,BI );UBI SUBCFQI (QI ,QI ,BI );UBI SUBOFQI (QI ,QI ,BI ); +BI MUL1OFSI (SI a,SI b); +BI MUL2OFSI (SI a,SI b);#endif
Signature · 1 line
2.9.3
PATCH v3 3/5 sim: or1k: add or1k target to sim
In reply to Stafford Hornesim/ChangeLog:
2017-03-03 Stafford Horne <[email protected]>
Peter Gavin <[email protected]>
* configure.tgt: Add or1k sim.
* or1k/Makefile.in: New file.
* or1k/configure.ac: New file.
* or1k/mloop.in: New file.
* or1k/or1k-sim.h: New file.
* or1k/or1k.c: New file.
* or1k/sim-if.c: New file.
* or1k/sim-main.h: New file.
* or1k/traps.c: New file.
--- sim/configure.tgt | 4 + sim/or1k/Makefile.in | 142 ++++++++++++++++++++++ sim/or1k/configure.ac | 17 +++ sim/or1k/mloop.in | 242 +++++++++++++++++++++++++++++++++++++ sim/or1k/or1k-sim.h | 94 +++++++++++++++ sim/or1k/or1k.c | 328 ++++++++++++++++++++++++++++++++++++++++++++++++++ sim/or1k/sim-if.c | 270 +++++++++++++++++++++++++++++++++++++++++ sim/or1k/sim-main.h | 80 ++++++++++++ sim/or1k/traps.c | 208 ++++++++++++++++++++++++++++++++ 9 files changed, 1385 insertions(+) create mode 100644 sim/or1k/Makefile.in create mode 100644 sim/or1k/configure.ac create mode 100644 sim/or1k/mloop.in create mode 100644 sim/or1k/or1k-sim.h create mode 100644 sim/or1k/or1k.c create mode 100644 sim/or1k/sim-if.c create mode 100644 sim/or1k/sim-main.h create mode 100644 sim/or1k/traps.c
sim/configure.tgt +4 -0
@@ -76,6 +76,10 @@ case "${target}" in msp430*-*-*) SIM_ARCH(msp430) ;; + or1k-*-* | or1knd-*-*) + SIM_ARCH(or1k) + sim_testsuite=yes + ;; rl78-*-*) SIM_ARCH(rl78) ;;
sim/or1k/Makefile.in new file +142 -0
142 lines not on this page · raw message
sim/or1k/configure.ac new file +17 -0
@@ -0,0 +1,17 @@ +dnl Process this file with autoconf to produce a configure script. +AC_PREREQ(2.64)dnl +AC_INIT(Makefile.in) +sinclude(../common/acinclude.m4) + +SIM_AC_COMMON + +SIM_AC_OPTION_ENDIAN(BIG) +SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT) +SIM_AC_OPTION_BITSIZE([32], [31], [32]) +SIM_AC_OPTION_SCACHE(16384) +SIM_AC_OPTION_DEFAULT_MODEL([or1200]) +SIM_AC_OPTION_ENVIRONMENT +SIM_AC_OPTION_INLINE() +SIM_AC_OPTION_CGEN_MAINT + +SIM_AC_OUTPUT
sim/or1k/mloop.in new file +242 -0
242 lines not on this page · raw message
sim/or1k/or1k-sim.h new file +94 -0
94 lines not on this page · raw message
sim/or1k/or1k.c new file +328 -0
328 lines not on this page · raw message
sim/or1k/sim-if.c new file +270 -0
270 lines not on this page · raw message
sim/or1k/sim-main.h new file +80 -0
80 lines not on this page · raw message
sim/or1k/traps.c new file +208 -0
208 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v3 4/5 sim: or1k: Add generated files.
In reply to Stafford HorneThese are separted out to make the patch easier to read and smaller.
sim/ChangeLog:
2017-01-20 Stafford Horne <[email protected]>
Peter Gavin <[email protected]>
* configure: Regenerated.
* testsuite/configure: Regenerated.
* or1k/aclocal.m4: Generated.
* or1k/arch.c: Generated.
* or1k/arch.h: Generated.
* or1k/config.in: Generated.
* or1k/configure: Generated.
* or1k/cpu.c: Generated.
* or1k/cpu.h: Generated.
* or1k/cpuall.h: Generated.
* or1k/decode.c: Generated.
* or1k/decode.h: Generated.
* or1k/model.c: Generated.
* or1k/sem-switch.c: Generated.
* or1k/sem.c: Generated.
--- sim/configure | 9 + sim/or1k/aclocal.m4 | 119 + sim/or1k/arch.c | 38 + sim/or1k/arch.h | 50 + sim/or1k/config.in | 248 + sim/or1k/configure | 16043 ++++++++++++++++++++++++++++++++++++++++++++++ sim/or1k/cpu.c | 10181 +++++++++++++++++++++++++++++ sim/or1k/cpu.h | 5024 +++++++++++++++ sim/or1k/cpuall.h | 66 + sim/or1k/decode.c | 2559 ++++++++ sim/or1k/decode.h | 94 + sim/or1k/eng.h | 34 + sim/or1k/model.c | 3809 +++++++++++ sim/or1k/sem-switch.c | 2748 ++++++++ sim/or1k/sem.c | 2953 +++++++++ sim/testsuite/configure | 4 + 16 files changed, 43979 insertions(+) create mode 100644 sim/or1k/aclocal.m4 create mode 100644 sim/or1k/arch.c create mode 100644 sim/or1k/arch.h create mode 100644 sim/or1k/config.in create mode 100755 sim/or1k/configure create mode 100644 sim/or1k/cpu.c create mode 100644 sim/or1k/cpu.h create mode 100644 sim/or1k/cpuall.h create mode 100644 sim/or1k/decode.c create mode 100644 sim/or1k/decode.h create mode 100644 sim/or1k/eng.h create mode 100644 sim/or1k/model.c create mode 100644 sim/or1k/sem-switch.c create mode 100644 sim/or1k/sem.c
sim/configure +9 -0
@@ -653,6 +653,7 @@ microblaze mips mn10300 moxie +or1k msp430 rl78 rx
@@ -3768,6 +3769,14 @@ subdirs="$subdirs aarch64" ;; + or1k-*-* | or1knd-*-*) + + sim_arch=or1k + subdirs="$subdirs or1k" + + + sim_testsuite=yes + ;; rl78-*-*) sim_arch=rl78
sim/or1k/aclocal.m4 new file +119 -0
119 lines not on this page · raw message
sim/or1k/arch.c new file +38 -0
@@ -0,0 +1,38 @@ +/* Simulator support for or1k. + +THIS FILE IS MACHINE GENERATED WITH CGEN. + +Copyright 1996-2010 Free Software Foundation, Inc. + +This file is part of the GNU simulators. + +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. + +It 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 this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#include "sim-main.h" +#include "bfd.h" + +const SIM_MACH *sim_machs[] = +{ +#ifdef HAVE_CPU_OR1K32BF + & or32_mach, +#endif +#ifdef HAVE_CPU_OR1K32BF + & or32nd_mach, +#endif +0 +}; +
sim/or1k/arch.h new file +50 -0
50 lines not on this page · raw message
sim/or1k/config.in new file +248 -0
248 lines not on this page · raw message
sim/or1k/configure new file +16043 -0
2,524 lines not on this page · raw message
sim/or1k/cpu.c new file +10181 -0
10,181 lines not on this page · raw message
sim/or1k/cpu.h new file +5024 -0
5,024 lines not on this page · raw message
sim/or1k/cpuall.h new file +66 -0
66 lines not on this page · raw message
sim/or1k/decode.c new file +2559 -0
2,559 lines not on this page · raw message
sim/or1k/decode.h new file +94 -0
94 lines not on this page · raw message
sim/or1k/model.c new file +3809 -0
3,809 lines not on this page · raw message
sim/or1k/sem-switch.c new file +2748 -0
2,748 lines not on this page · raw message
sim/or1k/sem.c new file +2953 -0
2,953 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.9.3
Part of the diff is not shown here. View the raw message.
PATCH v3 5/5 sim: testsuite: add testsuite for or1k sim
In reply to Stafford HorneFrom: Peter Gavin <[email protected]>
* sim/testsuite/ChangeLog-OR1K:
* add testsuite for or1k
--- sim/testsuite/sim/or1k/add.S | 546 +++++++++++++++++ sim/testsuite/sim/or1k/alltests.exp | 19 + sim/testsuite/sim/or1k/and.S | 208 +++++++ sim/testsuite/sim/or1k/basic.S | 535 +++++++++++++++++ sim/testsuite/sim/or1k/div.S | 198 +++++++ sim/testsuite/sim/or1k/ext.S | 251 ++++++++ sim/testsuite/sim/or1k/find.S | 119 ++++ sim/testsuite/sim/or1k/flag.S | 405 +++++++++++++ sim/testsuite/sim/or1k/jump.S | 121 ++++ sim/testsuite/sim/or1k/load.S | 373 ++++++++++++ sim/testsuite/sim/or1k/mac.S | 785 +++++++++++++++++++++++++ sim/testsuite/sim/or1k/mfspr.S | 196 ++++++ sim/testsuite/sim/or1k/mul.S | 277 +++++++++ sim/testsuite/sim/or1k/or.S | 207 +++++++ sim/testsuite/sim/or1k/or1k-asm-test-env.h | 61 ++ sim/testsuite/sim/or1k/or1k-asm-test-helpers.h | 134 +++++ sim/testsuite/sim/or1k/or1k-asm-test.h | 258 ++++++++ sim/testsuite/sim/or1k/or1k-asm.h | 20 + sim/testsuite/sim/or1k/or1k-test.ld | 57 ++ sim/testsuite/sim/or1k/ror.S | 186 ++++++ sim/testsuite/sim/or1k/shift.S | 572 ++++++++++++++++++ sim/testsuite/sim/or1k/spr-defs.h | 590 +++++++++++++++++++ sim/testsuite/sim/or1k/sub.S | 176 ++++++ sim/testsuite/sim/or1k/xor.S | 210 +++++++ 24 files changed, 6504 insertions(+) create mode 100644 sim/testsuite/sim/or1k/add.S create mode 100644 sim/testsuite/sim/or1k/alltests.exp create mode 100644 sim/testsuite/sim/or1k/and.S create mode 100644 sim/testsuite/sim/or1k/basic.S create mode 100644 sim/testsuite/sim/or1k/div.S create mode 100644 sim/testsuite/sim/or1k/ext.S create mode 100644 sim/testsuite/sim/or1k/find.S create mode 100644 sim/testsuite/sim/or1k/flag.S create mode 100644 sim/testsuite/sim/or1k/jump.S create mode 100644 sim/testsuite/sim/or1k/load.S create mode 100644 sim/testsuite/sim/or1k/mac.S create mode 100644 sim/testsuite/sim/or1k/mfspr.S create mode 100644 sim/testsuite/sim/or1k/mul.S create mode 100644 sim/testsuite/sim/or1k/or.S create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test-env.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm.h create mode 100644 sim/testsuite/sim/or1k/or1k-test.ld create mode 100644 sim/testsuite/sim/or1k/ror.S create mode 100644 sim/testsuite/sim/or1k/shift.S create mode 100644 sim/testsuite/sim/or1k/spr-defs.h create mode 100644 sim/testsuite/sim/or1k/sub.S create mode 100644 sim/testsuite/sim/or1k/xor.S
sim/testsuite/sim/or1k/add.S new file +546 -0
@@ -0,0 +1,546 @@ +/* Tests instructions l.add, l.addc, l.addi and l.addic + * + * This is not a comprehensive test of any instruction (yet). + * Of course what is really needed is a comprehensive instruction test... + * + * + * Copyright (C) 1999-2006 OpenCores + * Contributors various OpenCores participants + * Copyright (C) 2010 Embecosm Limited + * Contributor Jeremy Bennett <[email protected]> + * Copyright (C) 2012 R. Diez + * + * 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ +# mach: or1k +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x3fffffff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x40000000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xc0000000);\n +# output: report(0xc0000000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xbfffffff);\n +# output: report(0xbfffffff);\n +# output: report(0x7ffffffe);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x3fffffff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x3fffffff);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x40000000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xc0000000);\n +# output: report(0xc0000000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xc0000000);\n +# output: report(0xbfffffff);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xbfffffff);\n +# output: report(0xbfffffff);\n +# output: report(0x7ffffffe);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fff8000);\n +# output: report(0x00007fff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fffc000);\n +# output: report(0x00004000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80008000);\n +# output: report(0x00008000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80007fff);\n +# output: report(0x00008000);\n +# output: report(0x7fffffff);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fff8000);\n +# output: report(0x00007fff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fff8000);\n +# output: report(0x00007fff);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fffc000);\n +# output: report(0x00004000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0x0000ffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80008000);\n +# output: report(0x00008000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80007fff);\n +# output: report(0x00008000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80007fff);\n +# output: report(0x00008000);\n +# output: report(0x7fffffff);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0x0000ffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: exit(0)\n + +#include "or1k-asm-test-helpers.h" + + + STANDARD_TEST_ENVIRONMENT + + .section .exception_vectors + + // Alignment exception. + .org 0x600 + // TODO: print out address of instruction that caused the problem + + // Range exception. + .org 0xb00 + + // TODO: The stack safety zone is not taken into consideration. + + // The handling is a bit dubious at present. We just patch the instruction with l.nop and + // restart. This will go wrong in branch delay slots. Really we need to single + + // step past and then continue. + + + // TODO: do we need to patch the instruction? Can we not skip it somehow? + + PUSH r2 + PUSH r3 + + MOVE_FROM_SPR r2, SPR_EPCR_BASE // Address of the instruction that caused the problem. + + LOAD_IMMEDIATE r3, 0x15000000 // Opcode for l.nop + l.sw -4(r2), r3 // TODO: temporary, remove at the end + l.sw 0(r2), r3 + l.sw +4(r2), r3 // TODO: temporary, remove at the end + + POP r3 + POP r2 + + l.rfe + + + .section .text +start_tests: + PUSH LINK_REGISTER_R9 + + + // ----------- Test l.add ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 1, 2 + + // The carry flag should be ignored. + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.add, 1, 2 + + // Add two small negative numbers, which should set the carry flag but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, -1, -2 + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0x40000000, 0x3fffffff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0x40000000, 0x40000000 + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, -1073741824, -1073741824 // -1073741824 = 0xC0000000 + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0xbfffffff, 0xbfffffff + + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that an overflow alone causes a RANGE Exception. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0x40000000, 0x40000000 + + // Check that a carry alone does not cause a RANGE Exception. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0xffffffff, 0xfffffffe + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0xbfffffff, 0xbfffffff + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + // ----------- Test l.addc ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 1, 2 + + // Add two small negative numbers. Sets the carry flag but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, -1, -2 + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0x40000000, 0x3fffffff + + // Add two quite large positive numbers with a carry in. Should set the overflow but not the carry flag. + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0x40000000, 0x3fffffff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0x40000000, 0x40000000 + + // Add the largest unsigned value to zero with a carry. This potentially can break a + // simplistic test for carry that does not consider the carry flag properly. Do it both ways around. + // TODO: investigate why this test is failing + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, -1, 0 + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0, -1 + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, -1073741824, -1073741824 // -1073741824 = 0xC0000000 + + // Add two quite large negative numbers that would overflow, with a carry that just avoids + // the overflow. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, -1073741824, -1073741825 // -1073741824 = 0xC0000000, -1073741825 = 0xBFFFFFFF + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, -1073741825, -1073741825 + + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that an overflow alone causes a RANGE Exception, even when it + // is the carry that causes the overflow. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0x40000000, 0x40000000 + // TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0x40000000, 0x3fffffff + + // Check that a carry alone does not cause a RANGE Exception, even when it is the carry that causes the overflow. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0xffffffff, 0xfffffffe + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0x00000000, 0xffffffff + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0xbfffffff, 0xbfffffff + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + // ----------- Test l.addi ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 1, 2 + + // Check carry in is ignored. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addi, 1, 2 + + // Add two small negative numbers. Sets the carry flag but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0xffffffff, 0xfffe + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x7fff8000, 0x7fff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x7fffc000, 0x4000 + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x80008000, 0x8000 + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x80007fff, 0x8000 + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that an overflow alone causes a RANGE Exception. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x7fffc000, 0x4000 + + // Check that a carry alone does not cause a RANGE Exception. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0xffffffff, 0xfffe + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x80007fff, 0x8000 + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + // ----------- Test l.addi ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 1, 2 + + // Add two small negative numbers. Sets the carry flag but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0xffffffff, 0xfffe + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x7fff8000, 0x7fff + + // Add two quite large positive numbers with a carry in. Should set the overflow but not the carry flag. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x7fff8000, 0x7fff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x7fffc000, 0x4000 + + // Add the largest unsigned value to zero with a carry. This potentially can break a simplistic + // test for carry that does not consider the carry flag properly. Do it both ways around. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0xffffffff, 0x0000 + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x00000000, 0xffff + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x80008000, 0x8000 + + // Add two quite large negative numbers that would overflow, with a carry that just avoids the overflow. + // Should set the carry, but not the overflow flag. flag. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x80007fff, 0x8000 + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x80007fff, 0x8000 + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // Check that an overflow alone causes a RANGE Exception, even when it + // is the carry that causes the overflow. + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x7fffc000, 0x4000 + // TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x7fffc000, 0x3fff + + // Check that a carry alone does not cause a RANGE Exception, even + // when it is the carry that causes the overflow. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0xffffffff, 0xfffe + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x00000000, 0xffff + + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x80007fff, 0x8000 + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + POP LINK_REGISTER_R9 + RETURN_TO_LINK_REGISTER_R9
sim/testsuite/sim/or1k/alltests.exp new file +19 -0
@@ -0,0 +1,19 @@ +# OR1K simulator testsuite. + +if [istarget or1k*-*-*] { + + set all_machs "or1k" + + global global_ld_options + set global_ld_options "-T $srcdir/$subdir/or1k-test.ld" + + foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.S]] { + + if ![runtest_file_p $runtests $src] { + continue + } + + run_sim_test $src $all_machs + } + +}
sim/testsuite/sim/or1k/and.S new file +208 -0
208 lines not on this page · raw message
sim/testsuite/sim/or1k/basic.S new file +535 -0
535 lines not on this page · raw message
sim/testsuite/sim/or1k/div.S new file +198 -0
198 lines not on this page · raw message
sim/testsuite/sim/or1k/ext.S new file +251 -0
251 lines not on this page · raw message
sim/testsuite/sim/or1k/find.S new file +119 -0
119 lines not on this page · raw message
sim/testsuite/sim/or1k/flag.S new file +405 -0
405 lines not on this page · raw message
sim/testsuite/sim/or1k/jump.S new file +121 -0
121 lines not on this page · raw message
sim/testsuite/sim/or1k/load.S new file +373 -0
373 lines not on this page · raw message
sim/testsuite/sim/or1k/mac.S new file +785 -0
224 lines not on this page · raw message
sim/testsuite/sim/or1k/mfspr.S new file +196 -0
196 lines not on this page · raw message
sim/testsuite/sim/or1k/mul.S new file +277 -0
277 lines not on this page · raw message
sim/testsuite/sim/or1k/or.S new file +207 -0
207 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm-test-env.h new file +61 -0
61 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm-test-helpers.h new file +134 -0
134 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm-test.h new file +258 -0
258 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm.h new file +20 -0
Lines of this file are not shown. View the raw message.
sim/testsuite/sim/or1k/or1k-test.ld new file +57 -0
57 lines not on this page · raw message
sim/testsuite/sim/or1k/ror.S new file +186 -0
186 lines not on this page · raw message
sim/testsuite/sim/or1k/shift.S new file +572 -0
572 lines not on this page · raw message
sim/testsuite/sim/or1k/spr-defs.h new file +590 -0
590 lines not on this page · raw message
sim/testsuite/sim/or1k/sub.S new file +176 -0
176 lines not on this page · raw message
sim/testsuite/sim/or1k/xor.S new file +210 -0
210 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.9.3
Part of the diff is not shown here. View the raw message.
v3 cover sim port for OpenRISC
In reply to Stafford HorneNote,
Some of these patches for generated files are too big for the mail servers, if you want to see them all, please see:
The following changes since commitb4fcfd3b4d173129207f804f5eee4557c788d66b:
Automatic date update in version.in (2017-03-17 00:00:34 +0000)
are available in the git repository at:
https://github.com/stffrdhrn/binutils-gdb.git tags/for-upstream
for you to fetch changes up to 26010e6737eddb5704d87494930f09afebc517ab:
sim: testsuite: add testsuite for or1k sim (2017-03-17 14:22:43 +0900)
Quoted 48 lines · Stafford Horne
Hello Again,
Please find attached the sim patches that allow to get a basic OpenRISC system running. This was used to verify the OpenRISC gdb port.
The main author is Peter Gavin who should have his FSF copyright in place.
Request for comments on:
- The testcase has a few tests commented out. I do not plan to fix now, but hopefully be addressed after upstreaming.
- Openrisc supports a l.rem instruction which has been implemented here using thedrem()function from libmath. It seems no other functions use libmath now, I hope this is ok.Sim dejagnu tests were added specifically for openrisc and used to test this. Please see the details of running the testsuite for sim below:
=== sim Summary ===
# of expected passes 17 /home/shorne/work/openrisc/build-gdb/sim/or1k/run 0.5Thanks,
-StaffordChanges since v2
* Removed 64-bit implementation (reduced files)
* Removed cgen suffix patch
* Removed different builds for linux
* Removed unused macros
* Fixed gnu style issues pointed out by Mike
* Fixed copyrights (not Cygnus, added to each file)Changes since v1
* Squashed sim patches into single sim patch
* Put Generated files in separate patch
* I have my sim/gdb copyright assignment completePeter Gavin (3):
sim: cgen: add rem (remainder) function (needed for OR1K lf.rem.[sd])
sim: cgen: add mul-o1flag, mul-o2flag RTL functions to CGEN
sim: testsuite: add testsuite for or1k simStafford Horne (2):
sim: or1k: add or1k target to sim
sim: or1k: Add generated files.