Skip to contentSkip to conversation

sim port for OpenRISC

PATCH Superseded Stafford Horne 2 participants 20 messages May 29, 2017 – Sep 5, 2017

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover sim port for OpenRISC

Hello,

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:
- Openrisc supports a l.rem instruction which has been implemented here using the remainder() 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

-Stafford

--

Changes since v3
* Cleaned up indentation and style of sim testsuite
* Cleaned up TODOs in testsuite
* Implemented range exception

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 remainder functions (needed for OR1K lf.rem.[sd])
sim: cgen: add MUL2OFSI and MUL1OFSI macros (needed for OR1K l.mul[u])
sim: testsuite: add testsuite for or1k sim

Stafford Horne (2):
sim: or1k: add or1k target to sim
sim: or1k: Add generated files.

 sim/common/cgen-accfp.c                        |    40 +
 sim/common/cgen-fpu.h                          |     4 +
 sim/common/cgen-ops.h                          |    18 +
 sim/common/sim-fpu.c                           |    63 +
 sim/common/sim-fpu.h                           |     3 +
 sim/configure                                  |     9 +
 sim/configure.tgt                              |     4 +
 sim/or1k/Makefile.in                           |   142 +
 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/configure.ac                          |    17 +
 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/mloop.in                              |   242 +
 sim/or1k/model.c                               |  3809 ++++++
 sim/or1k/or1k-sim.h                            |    94 +
 sim/or1k/or1k.c                                |   328 +
 sim/or1k/sem-switch.c                          |  2748 ++++
 sim/or1k/sem.c                                 |  2953 +++++
 sim/or1k/sim-if.c                              |   270 +
 sim/or1k/sim-main.h                            |    80 +
 sim/or1k/traps.c                               |   209 +
 sim/testsuite/configure                        |     4 +
 sim/testsuite/sim/or1k/add.S                   |   606 +
 sim/testsuite/sim/or1k/alltests.exp            |    34 +
 sim/testsuite/sim/or1k/and.S                   |   198 +
 sim/testsuite/sim/or1k/basic.S                 |   522 +
 sim/testsuite/sim/or1k/div.S                   |   290 +
 sim/testsuite/sim/or1k/ext.S                   |   236 +
 sim/testsuite/sim/or1k/find.S                  |   100 +
 sim/testsuite/sim/or1k/flag.S                  |   378 +
 sim/testsuite/sim/or1k/jump.S                  |   104 +
 sim/testsuite/sim/or1k/load.S                  |   358 +
 sim/testsuite/sim/or1k/mac.S                   |   778 ++
 sim/testsuite/sim/or1k/mfspr.S                 |   171 +
 sim/testsuite/sim/or1k/mul.S                   |   573 +
 sim/testsuite/sim/or1k/or.S                    |   199 +
 sim/testsuite/sim/or1k/or1k-asm-test-env.h     |    59 +
 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h |   121 +
 sim/testsuite/sim/or1k/or1k-asm-test.h         |   225 +
 sim/testsuite/sim/or1k/or1k-asm.h              |    37 +
 sim/testsuite/sim/or1k/or1k-test.ld            |    75 +
 sim/testsuite/sim/or1k/ror.S                   |   159 +
 sim/testsuite/sim/or1k/shift.S                 |   541 +
 sim/testsuite/sim/or1k/spr-defs.h              |   120 +
 sim/testsuite/sim/or1k/sub.S                   |   201 +
 sim/testsuite/sim/or1k/xor.S                   |   200 +
 54 files changed, 51778 insertions(+)
 create mode 100644 sim/or1k/Makefile.in
 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/configure.ac
 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/mloop.in
 create mode 100644 sim/or1k/model.c
 create mode 100644 sim/or1k/or1k-sim.h
 create mode 100644 sim/or1k/or1k.c
 create mode 100644 sim/or1k/sem-switch.c
 create mode 100644 sim/or1k/sem.c
 create mode 100644 sim/or1k/sim-if.c
 create mode 100644 sim/or1k/sim-main.h
 create mode 100644 sim/or1k/traps.c
 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
Signature · 1 line
2.9.4
#1 lore raw

PATCH v4 1/5 sim: cgen: add remainder functions (needed for OR1K lf.rem.[sd])

From: Peter Gavin <[email protected]>

* sim/common/ChangeLog:

2016-05-21 Peter Gavin <[email protected]>
Stafford Horne <[email protected]>

* cgen-accfp.c (remsf, remdf): New function. (cgen_init_accurate_fpu): Add remsf and remdf.
* cgen-fpu.h (cgen_fp_ops): Add remsf, remdf, remxf and remtf.
* sim-fpu.c (sim_fpu_rem): New function.
* sim-fpu.h (sim_fpu_status_invalid_irx): New enum. (sim_fpu_rem): New function.

---
 sim/common/cgen-accfp.c | 40 +++++++++++++++++++++++++++++++
 sim/common/cgen-fpu.h   |  4 ++++
 sim/common/sim-fpu.c    | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
 sim/common/sim-fpu.h    |  3 +++
 4 files changed, 110 insertions(+)
sim/common/cgen-accfp.c +40 -0
index afbca6d..d7124fe 100644
@@ -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
index 134b4d0..5f9b55d 100644
@@ -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 +63 -0

75 lines not on this page · raw message

sim/common/sim-fpu.h +3 -0
index d27d80a..c108f1f 100644
@@ -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.4
#6 lore raw

PATCH v4 2/5 sim: cgen: add MUL2OFSI and MUL1OFSI macros (needed for OR1K l.mul[u])

In reply to Stafford Horne

From: Peter Gavin <[email protected]>

sim/common/ChangeLog:

2012-03-14 Peter Gavin <[email protected]>

* cgen-ops.h (MUL2OFSI): New macro, 1's complement. (MUL1OFSI): New macro, 2's complement.

---
 sim/common/cgen-ops.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
sim/common/cgen-ops.h +18 -0
index 97585d7..ffbdf3f 100644
@@ -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.4
#9 lore raw

PATCH v4 3/5 sim: or1k: add or1k target to sim

In reply to Stafford Horne

sim/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      | 209 ++++++++++++++++++++++++++++++++
 9 files changed, 1386 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
index c958fb3..82b0e89 100644
@@ -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
new file mode 100644
index 0000000..8873a1d
@@ -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 +209 -0

209 lines not on this page · raw message

Signature · 1 line
2.9.4
#13 lore raw

PATCH v4 4/5 sim: or1k: Add generated files.

In reply to Stafford Horne

These 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
index 2729e69..ae2f6964 100755
@@ -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
new file mode 100644
index 0000000..83a9815
@@ -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/eng.h new file +34 -0
new file mode 100644
index 0000000..c5f5969

Lines of this file are not shown. View the 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

sim/testsuite/configure +4 -0
index bbc3bea..e37bdbd 100755

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

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

#14 lore raw

PATCH v4 5/5 sim: testsuite: add testsuite for or1k sim

In reply to Stafford Horne

From: Peter Gavin <[email protected]>

sim/testsuite/sim/or1k/ChangeLog:

2016-05-21 Peter Gavin <[email protected]>
Stafford Horne <[email protected]>

* add.S: New file.
* alltests.exp: New file.
* and.S: New file.
* basic.S: New file.
* div.S: New file.
* ext.S: New file.
* find.S: New file.
* flag.S: New file.
* jump.S: New file.
* load.S: New file.
* mac.S: New file.
* mfspr.S: New file.
* mul.S: New file.
* or.S: New file.
* or1k-asm-test-env.h: New file.
* or1k-asm-test-helpers.h: New file.
* or1k-asm-test.h: New file.
* or1k-asm.h: New file.
* or1k-test.ld: New file.
* ror.S: New file.
* shift.S: New file.
* spr-defs.h: New file.
* sub.S: New file.
* xor.S: New file.

---
 sim/testsuite/sim/or1k/add.S                   | 606 +++++++++++++++++++
 sim/testsuite/sim/or1k/alltests.exp            |  34 ++
 sim/testsuite/sim/or1k/and.S                   | 198 +++++++
 sim/testsuite/sim/or1k/basic.S                 | 522 +++++++++++++++++
 sim/testsuite/sim/or1k/div.S                   | 290 +++++++++
 sim/testsuite/sim/or1k/ext.S                   | 236 ++++++++
 sim/testsuite/sim/or1k/find.S                  | 100 ++++
 sim/testsuite/sim/or1k/flag.S                  | 378 ++++++++++++
 sim/testsuite/sim/or1k/jump.S                  | 104 ++++
 sim/testsuite/sim/or1k/load.S                  | 358 ++++++++++++
 sim/testsuite/sim/or1k/mac.S                   | 778 +++++++++++++++++++++++++
 sim/testsuite/sim/or1k/mfspr.S                 | 171 ++++++
 sim/testsuite/sim/or1k/mul.S                   | 573 ++++++++++++++++++
 sim/testsuite/sim/or1k/or.S                    | 199 +++++++
 sim/testsuite/sim/or1k/or1k-asm-test-env.h     |  59 ++
 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h | 121 ++++
 sim/testsuite/sim/or1k/or1k-asm-test.h         | 225 +++++++
 sim/testsuite/sim/or1k/or1k-asm.h              |  37 ++
 sim/testsuite/sim/or1k/or1k-test.ld            |  75 +++
 sim/testsuite/sim/or1k/ror.S                   | 159 +++++
 sim/testsuite/sim/or1k/shift.S                 | 541 +++++++++++++++++
 sim/testsuite/sim/or1k/spr-defs.h              | 120 ++++
 sim/testsuite/sim/or1k/sub.S                   | 201 +++++++
 sim/testsuite/sim/or1k/xor.S                   | 200 +++++++
 24 files changed, 6285 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 +606 -0
new file mode 100644
index 0000000..63dd17e
@@ -0,0 +1,606 @@
+/* Tests instructions l.add, l.addc, l.addi and l.addic.
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with 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(0x40000000);\n
+# output: report(0x40000000);\n
+# output: report(0x80000000);\n
+# output: report(0x00000000);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\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(0xbfffffff);\n
+# output: report(0xbfffffff);\n
+# output: report(0x7ffffffe);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\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(0x40000000);\n
+# output: report(0x40000000);\n
+# output: report(0x80000000);\n
+# output: report(0x00000000);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\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(0x00000001);\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(0xbfffffff);\n
+# output: report(0xbfffffff);\n
+# output: report(0x7ffffffe);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\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(0x7fffc000);\n
+# output: report(0x00004000);\n
+# output: report(0x80000000);\n
+# output: report(0x00000000);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\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(0x80007fff);\n
+# output: report(0x00008000);\n
+# output: report(0x7fffffff);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\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(0x7fffc000);\n
+# output: report(0x00004000);\n
+# output: report(0x80000000);\n
+# output: report(0x00000000);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\n
+# output: \n
+# output: report(0x7fffc000);\n
+# output: report(0x00003fff);\n
+# output: report(0x80000000);\n
+# output: report(0x00000000);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\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: report(0x80007fff);\n
+# output: report(0x00008000);\n
+# output: report(0x7fffffff);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\n
+# output: report(0x00000001);\n
+# output: \n
+# output: exit(0)\n
+
+#include "or1k-asm-test-helpers.h"
+
+	STANDARD_TEST_ENVIRONMENT
+
+	.section .exception_vectors
+
+	/* Range exception.  */
+	.org	0xb00
+
+	/* 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.  But we don't have those in this test.  */
+	l.addi r1, r1, -EXCEPTION_STACK_SKIP_SIZE
+	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	0(r2), r3
+	POP r3
+	POP r2
+	l.addi r1, r1, EXCEPTION_STACK_SKIP_SIZE
+	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
+
+	/* 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
+
+	/* 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.  */
+	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
+
+	/* 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
+
+	/* 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
+
+	/* 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
+
+	/* 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.  This should set the carry,
+	   but not the overflow 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.  */
+	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 +34 -0
new file mode 100644
index 0000000..4480590
@@ -0,0 +1,34 @@
+# OR1K simulator testsuite.
+#
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+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 +198 -0

198 lines not on this page · raw message

sim/testsuite/sim/or1k/basic.S new file +522 -0

522 lines not on this page · raw message

sim/testsuite/sim/or1k/div.S new file +290 -0

290 lines not on this page · raw message

sim/testsuite/sim/or1k/ext.S new file +236 -0

236 lines not on this page · raw message

sim/testsuite/sim/or1k/find.S new file +100 -0

100 lines not on this page · raw message

sim/testsuite/sim/or1k/flag.S new file +378 -0

378 lines not on this page · raw message

sim/testsuite/sim/or1k/jump.S new file +104 -0

104 lines not on this page · raw message

sim/testsuite/sim/or1k/load.S new file +358 -0

358 lines not on this page · raw message

sim/testsuite/sim/or1k/mac.S new file +778 -0

174 lines not on this page · raw message

sim/testsuite/sim/or1k/mfspr.S new file +171 -0

171 lines not on this page · raw message

sim/testsuite/sim/or1k/mul.S new file +573 -0

573 lines not on this page · raw message

sim/testsuite/sim/or1k/or.S new file +199 -0

199 lines not on this page · raw message

sim/testsuite/sim/or1k/or1k-asm-test-env.h new file +59 -0

59 lines not on this page · raw message

sim/testsuite/sim/or1k/or1k-asm-test-helpers.h new file +121 -0

121 lines not on this page · raw message

sim/testsuite/sim/or1k/or1k-asm-test.h new file +225 -0

225 lines not on this page · raw message

sim/testsuite/sim/or1k/or1k-asm.h new file +37 -0
new file mode 100644
index 0000000..a4f05d8

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

sim/testsuite/sim/or1k/or1k-test.ld new file +75 -0

75 lines not on this page · raw message

sim/testsuite/sim/or1k/ror.S new file +159 -0

159 lines not on this page · raw message

sim/testsuite/sim/or1k/shift.S new file +541 -0

541 lines not on this page · raw message

sim/testsuite/sim/or1k/spr-defs.h new file +120 -0

120 lines not on this page · raw message

sim/testsuite/sim/or1k/sub.S new file +201 -0

201 lines not on this page · raw message

sim/testsuite/sim/or1k/xor.S new file +200 -0

200 lines not on this page · raw message

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

Signature · 1 line
2.9.4

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

#15 lore raw

v4 cover sim port for OpenRISC

In reply to Stafford Horne

Hi Mike,

Sorry to bother you,
Did you have a chance to look at this?

-Stafford

Quoted 158 lines · Stafford Horne

Hello,

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:
- Openrisc supports a l.rem instruction which has been implemented here using the remainder() 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

-Stafford

--

Changes since v3
* Cleaned up indentation and style of sim testsuite
* Cleaned up TODOs in testsuite
* Implemented range exception

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 remainder functions (needed for OR1K lf.rem.[sd])
sim: cgen: add MUL2OFSI and MUL1OFSI macros (needed for OR1K l.mul[u])
sim: testsuite: add testsuite for or1k sim

Stafford Horne (2):
sim: or1k: add or1k target to sim
sim: or1k: Add generated files.

 sim/common/cgen-accfp.c                        |    40 +
 sim/common/cgen-fpu.h                          |     4 +
 sim/common/cgen-ops.h                          |    18 +
 sim/common/sim-fpu.c                           |    63 +
 sim/common/sim-fpu.h                           |     3 +
 sim/configure                                  |     9 +
 sim/configure.tgt                              |     4 +
 sim/or1k/Makefile.in                           |   142 +
 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/configure.ac                          |    17 +
 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/mloop.in                              |   242 +
 sim/or1k/model.c                               |  3809 ++++++
 sim/or1k/or1k-sim.h                            |    94 +
 sim/or1k/or1k.c                                |   328 +
 sim/or1k/sem-switch.c                          |  2748 ++++
 sim/or1k/sem.c                                 |  2953 +++++
 sim/or1k/sim-if.c                              |   270 +
 sim/or1k/sim-main.h                            |    80 +
 sim/or1k/traps.c                               |   209 +
 sim/testsuite/configure                        |     4 +
 sim/testsuite/sim/or1k/add.S                   |   606 +
 sim/testsuite/sim/or1k/alltests.exp            |    34 +
 sim/testsuite/sim/or1k/and.S                   |   198 +
 sim/testsuite/sim/or1k/basic.S                 |   522 +
 sim/testsuite/sim/or1k/div.S                   |   290 +
 sim/testsuite/sim/or1k/ext.S                   |   236 +
 sim/testsuite/sim/or1k/find.S                  |   100 +
 sim/testsuite/sim/or1k/flag.S                  |   378 +
 sim/testsuite/sim/or1k/jump.S                  |   104 +
 sim/testsuite/sim/or1k/load.S                  |   358 +
 sim/testsuite/sim/or1k/mac.S                   |   778 ++
 sim/testsuite/sim/or1k/mfspr.S                 |   171 +
 sim/testsuite/sim/or1k/mul.S                   |   573 +
 sim/testsuite/sim/or1k/or.S                    |   199 +
 sim/testsuite/sim/or1k/or1k-asm-test-env.h     |    59 +
 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h |   121 +
 sim/testsuite/sim/or1k/or1k-asm-test.h         |   225 +
 sim/testsuite/sim/or1k/or1k-asm.h              |    37 +
 sim/testsuite/sim/or1k/or1k-test.ld            |    75 +
 sim/testsuite/sim/or1k/ror.S                   |   159 +
 sim/testsuite/sim/or1k/shift.S                 |   541 +
 sim/testsuite/sim/or1k/spr-defs.h              |   120 +
 sim/testsuite/sim/or1k/sub.S                   |   201 +
 sim/testsuite/sim/or1k/xor.S                   |   200 +
 54 files changed, 51778 insertions(+)
 create mode 100644 sim/or1k/Makefile.in
 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/configure.ac
 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/mloop.in
 create mode 100644 sim/or1k/model.c
 create mode 100644 sim/or1k/or1k-sim.h
 create mode 100644 sim/or1k/or1k.c
 create mode 100644 sim/or1k/sem-switch.c
 create mode 100644 sim/or1k/sem.c
 create mode 100644 sim/or1k/sim-if.c
 create mode 100644 sim/or1k/sim-main.h
 create mode 100644 sim/or1k/traps.c
 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
Signature · 1 line
2.9.4
#16 lore raw

v4 cover sim port for OpenRISC

Hello Again,

Would anyone be willing to review these sim changes? Last reviewr was Mike, please let me know.

Quoted 166 lines · Stafford Horne

Hi Mike,

Sorry to bother you,
Did you have a chance to look at this?

-Stafford

Quoted 158 lines · Stafford Horne

Hello,

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:
- Openrisc supports a l.rem instruction which has been implemented here using the remainder() 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

-Stafford

--

Changes since v3
* Cleaned up indentation and style of sim testsuite
* Cleaned up TODOs in testsuite
* Implemented range exception

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 remainder functions (needed for OR1K lf.rem.[sd])
sim: cgen: add MUL2OFSI and MUL1OFSI macros (needed for OR1K l.mul[u])
sim: testsuite: add testsuite for or1k sim

Stafford Horne (2):
sim: or1k: add or1k target to sim
sim: or1k: Add generated files.

 sim/common/cgen-accfp.c                        |    40 +
 sim/common/cgen-fpu.h                          |     4 +
 sim/common/cgen-ops.h                          |    18 +
 sim/common/sim-fpu.c                           |    63 +
 sim/common/sim-fpu.h                           |     3 +
 sim/configure                                  |     9 +
 sim/configure.tgt                              |     4 +
 sim/or1k/Makefile.in                           |   142 +
 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/configure.ac                          |    17 +
 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/mloop.in                              |   242 +
 sim/or1k/model.c                               |  3809 ++++++
 sim/or1k/or1k-sim.h                            |    94 +
 sim/or1k/or1k.c                                |   328 +
 sim/or1k/sem-switch.c                          |  2748 ++++
 sim/or1k/sem.c                                 |  2953 +++++
 sim/or1k/sim-if.c                              |   270 +
 sim/or1k/sim-main.h                            |    80 +
 sim/or1k/traps.c                               |   209 +
 sim/testsuite/configure                        |     4 +
 sim/testsuite/sim/or1k/add.S                   |   606 +
 sim/testsuite/sim/or1k/alltests.exp            |    34 +
 sim/testsuite/sim/or1k/and.S                   |   198 +
 sim/testsuite/sim/or1k/basic.S                 |   522 +
 sim/testsuite/sim/or1k/div.S                   |   290 +
 sim/testsuite/sim/or1k/ext.S                   |   236 +
 sim/testsuite/sim/or1k/find.S                  |   100 +
 sim/testsuite/sim/or1k/flag.S                  |   378 +
 sim/testsuite/sim/or1k/jump.S                  |   104 +
 sim/testsuite/sim/or1k/load.S                  |   358 +
 sim/testsuite/sim/or1k/mac.S                   |   778 ++
 sim/testsuite/sim/or1k/mfspr.S                 |   171 +
 sim/testsuite/sim/or1k/mul.S                   |   573 +
 sim/testsuite/sim/or1k/or.S                    |   199 +
 sim/testsuite/sim/or1k/or1k-asm-test-env.h     |    59 +
 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h |   121 +
 sim/testsuite/sim/or1k/or1k-asm-test.h         |   225 +
 sim/testsuite/sim/or1k/or1k-asm.h              |    37 +
 sim/testsuite/sim/or1k/or1k-test.ld            |    75 +
 sim/testsuite/sim/or1k/ror.S                   |   159 +
 sim/testsuite/sim/or1k/shift.S                 |   541 +
 sim/testsuite/sim/or1k/spr-defs.h              |   120 +
 sim/testsuite/sim/or1k/sub.S                   |   201 +
 sim/testsuite/sim/or1k/xor.S                   |   200 +
 54 files changed, 51778 insertions(+)
 create mode 100644 sim/or1k/Makefile.in
 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/configure.ac
 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/mloop.in
 create mode 100644 sim/or1k/model.c
 create mode 100644 sim/or1k/or1k-sim.h
 create mode 100644 sim/or1k/or1k.c
 create mode 100644 sim/or1k/sem-switch.c
 create mode 100644 sim/or1k/sem.c
 create mode 100644 sim/or1k/sim-if.c
 create mode 100644 sim/or1k/sim-main.h
 create mode 100644 sim/or1k/traps.c
 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
Signature · 1 line
2.9.4
#17 lore raw

v4 cover sim port for OpenRISC

Hello Global Maintainers,

Its been about a week since I sent the last ping Mike. It looks like he hasnt been active on the list since April. This is my patch series for the OpenRISC sim implementation needed to test and verify gdb. If possible I would like to have it reviewed so I commit this and gdb to upstream.

At the moment it appears Mike may not be about to continue with the review.

If someone knows more details please let us know.

-Stafford

Quoted 172 lines · Stafford Horne

Hello Again,

Would anyone be willing to review these sim changes? Last reviewr was Mike, please let me know.

Quoted 166 lines · Stafford Horne

Hi Mike,

Sorry to bother you,
Did you have a chance to look at this?

-Stafford

Quoted 158 lines · Stafford Horne

Hello,

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:
- Openrisc supports a l.rem instruction which has been implemented here using the remainder() 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

-Stafford

--

Changes since v3
* Cleaned up indentation and style of sim testsuite
* Cleaned up TODOs in testsuite
* Implemented range exception

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 remainder functions (needed for OR1K lf.rem.[sd])
sim: cgen: add MUL2OFSI and MUL1OFSI macros (needed for OR1K l.mul[u])
sim: testsuite: add testsuite for or1k sim

Stafford Horne (2):
sim: or1k: add or1k target to sim
sim: or1k: Add generated files.

 sim/common/cgen-accfp.c                        |    40 +
 sim/common/cgen-fpu.h                          |     4 +
 sim/common/cgen-ops.h                          |    18 +
 sim/common/sim-fpu.c                           |    63 +
 sim/common/sim-fpu.h                           |     3 +
 sim/configure                                  |     9 +
 sim/configure.tgt                              |     4 +
 sim/or1k/Makefile.in                           |   142 +
 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/configure.ac                          |    17 +
 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/mloop.in                              |   242 +
 sim/or1k/model.c                               |  3809 ++++++
 sim/or1k/or1k-sim.h                            |    94 +
 sim/or1k/or1k.c                                |   328 +
 sim/or1k/sem-switch.c                          |  2748 ++++
 sim/or1k/sem.c                                 |  2953 +++++
 sim/or1k/sim-if.c                              |   270 +
 sim/or1k/sim-main.h                            |    80 +
 sim/or1k/traps.c                               |   209 +
 sim/testsuite/configure                        |     4 +
 sim/testsuite/sim/or1k/add.S                   |   606 +
 sim/testsuite/sim/or1k/alltests.exp            |    34 +
 sim/testsuite/sim/or1k/and.S                   |   198 +
 sim/testsuite/sim/or1k/basic.S                 |   522 +
 sim/testsuite/sim/or1k/div.S                   |   290 +
 sim/testsuite/sim/or1k/ext.S                   |   236 +
 sim/testsuite/sim/or1k/find.S                  |   100 +
 sim/testsuite/sim/or1k/flag.S                  |   378 +
 sim/testsuite/sim/or1k/jump.S                  |   104 +
 sim/testsuite/sim/or1k/load.S                  |   358 +
 sim/testsuite/sim/or1k/mac.S                   |   778 ++
 sim/testsuite/sim/or1k/mfspr.S                 |   171 +
 sim/testsuite/sim/or1k/mul.S                   |   573 +
 sim/testsuite/sim/or1k/or.S                    |   199 +
 sim/testsuite/sim/or1k/or1k-asm-test-env.h     |    59 +
 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h |   121 +
 sim/testsuite/sim/or1k/or1k-asm-test.h         |   225 +
 sim/testsuite/sim/or1k/or1k-asm.h              |    37 +
 sim/testsuite/sim/or1k/or1k-test.ld            |    75 +
 sim/testsuite/sim/or1k/ror.S                   |   159 +
 sim/testsuite/sim/or1k/shift.S                 |   541 +
 sim/testsuite/sim/or1k/spr-defs.h              |   120 +
 sim/testsuite/sim/or1k/sub.S                   |   201 +
 sim/testsuite/sim/or1k/xor.S                   |   200 +
 54 files changed, 51778 insertions(+)
 create mode 100644 sim/or1k/Makefile.in
 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/configure.ac
 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/mloop.in
 create mode 100644 sim/or1k/model.c
 create mode 100644 sim/or1k/or1k-sim.h
 create mode 100644 sim/or1k/or1k.c
 create mode 100644 sim/or1k/sem-switch.c
 create mode 100644 sim/or1k/sem.c
 create mode 100644 sim/or1k/sim-if.c
 create mode 100644 sim/or1k/sim-main.h
 create mode 100644 sim/or1k/traps.c
 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
Signature · 1 line
2.9.4
#18 lore raw

v4 cover sim port for OpenRISC

Quoted 10 lines · Stafford Horne

Hello Global Maintainers,

Its been about a week since I sent the last ping Mike. It looks like he
hasnt been active on the list since April. This is my patch series for the
OpenRISC sim implementation needed to test and verify gdb. If possible I
would like to have it reviewed so I commit this and gdb to upstream.

Quoted 6 lines

At the moment it appears Mike may not be about to continue with the review.

If someone knows more details please let us know.

-Stafford

Hi Stafford,

I'll start getting familiar with the patch series and the previous versions. However, it seems like patch 4/5, "sim: or1k: Add generated files.", didn't go through. I don't see it in the archive either:

https://sourceware.org/ml/gdb-patches/2017-05/threads.html#00594

Is it possible that it was too big and bounced? If so, is it possible to split it? If not, we'll need to find some other way, maybe you can compress it and send it as an attachment?

Simon

#2 lore raw

PATCH v4 1/5 sim: cgen: add remainder functions (needed for OR1K lf.rem.[sd])

In reply to Stafford Horne
Quoted 66 lines · Stafford Horne
sim/common/sim-fpu.c +0 -0
index 0d4d08a..1a79e71 100644
@@ -41,6 +41,7 @@ along with this program.  If not, see

<http://www.gnu.org/licenses/>. */
#include "sim-io.h"
#include "sim-assert.h"

+#include <math.h> /* for drem, remove when soft-float version is implemented */

/* Debugging support.
If digits is -1, then print all digits. */

sim/common/sim-fpu.c +48 -0
@@ -1551,6 +1552,68 @@ sim_fpu_div (sim_fpu *f,
 
 
 INLINE_SIM_FPU (int)
+sim_fpu_rem (sim_fpu *f,
+	     const sim_fpu *l,
+	     const sim_fpu *r)
+{
+  if (sim_fpu_is_snan (l))
+    {
+      *f = *l;
+      f->class = sim_fpu_class_qnan;
+      return sim_fpu_status_invalid_snan;
+    }
+  if (sim_fpu_is_snan (r))
+    {
+      *f = *r;
+      f->class = sim_fpu_class_qnan;
+      return sim_fpu_status_invalid_snan;
+    }
+  if (sim_fpu_is_qnan (l))
+    {
+      *f = *l;
+      f->class = sim_fpu_class_qnan;
+      return 0;
+    }
+  if (sim_fpu_is_qnan (r))
+    {
+      *f = *r;
+      f->class = sim_fpu_class_qnan;
+      return 0;
+    }
+  if (sim_fpu_is_infinity (l))
+    {
+      *f = sim_fpu_qnan;
+      return sim_fpu_status_invalid_irx;
+    }
+  if (sim_fpu_is_zero (r))
+    {
+      *f = sim_fpu_qnan;
+      return sim_fpu_status_invalid_div0;
+    }
+  if (sim_fpu_is_zero (l))
+    {
+      *f = *l;
+      return 0;
+    }
+  if (sim_fpu_is_infinity (r))
+    {
+      *f = *l;
+      return 0;
+    }

sim/common/sim-fpu.c sim_fpu_div (sim_fpu *f, · line 1612

Quoted 10 lines
sim/common/sim-fpu.c +10 -0
+  {
+    /* TODO: Implement remainder here.  */
+
+    sim_fpu_map lval, rval, fval;
+    lval.i = pack_fpu(l, 1);
+    rval.i = pack_fpu(r, 1);
+    fval.d = remainder(lval.d, rval.d);
+    unpack_fpu(f, fval.i, 1);
+    return 0;
+  }

I can't tell for sure because I'm not maintainer of sim/, but I suppose that we would need a proper implementation that doesn't use the host fpu here.

Quoted 12 lines
sim/common/sim-fpu.c +4 -0
+}
+
+
+INLINE_SIM_FPU (int)
 sim_fpu_max (sim_fpu *f,
 	     const sim_fpu *l,
 	     const sim_fpu *r)
sim/common/sim-fpu.h +0 -0
index d27d80a..c108f1f 100644

sim/common/sim-fpu.h typedef enum · line 155

Quoted 5 lines
sim/common/sim-fpu.h +1 -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;

I think it would make sense to put the new entry with the other "invalid" ones and shift the others.

Simon

#19 lore raw

v4 cover sim port for OpenRISC

In reply to Simon Marchi
Quoted 23 lines · Simon Marchi
Quoted 9 lines · Stafford Horne

Hello Global Maintainers,

Its been about a week since I sent the last ping Mike. It looks like he hasnt been active on the list since April. This is my patch series for the
OpenRISC sim implementation needed to test and verify gdb. If possible I
would like to have it reviewed so I commit this and gdb to upstream.

Quoted 6 lines

At the moment it appears Mike may not be about to continue with the review.

If someone knows more details please let us know.

-Stafford

Hi Stafford,

I'll start getting familiar with the patch series and the previous versions. However, it seems like patch 4/5, "sim: or1k: Add generated files.", didn't go through. I don't see it in the archive either:

Quoted 5 lines

https://sourceware.org/ml/gdb-patches/2017-05/threads.html#00594

Is it possible that it was too big and bounced? If so, is it possible to split it? If not, we'll need to find some other way, maybe you can compress it and send it as an attachment?

Hello,

Thanks for having a look at this.

That is right this one file was too large to make it through the list filters. I had mentioned that on the v3 series but not here, sorry.

One way to have a look is via my git repo the signed tag here:

~~~
The following changes since commit dbb2bcd0059f8d91de5a792f8684c8908c316720:

Revert "[AArch64] Allow COPY relocation elimination" (2017-06-09 12:04:44 +0100)

are available in the git repository at:

https://github.com/stffrdhrn/binutils-gdb.git tags/for-upstream

for you to fetch changes up to c30a4b8ddf8f133d556a4ce5486b9a95e0544720:

sim: testsuite: add testsuite for or1k sim (2017-06-13 19:17:58 +0900)
~~~

Otherwise, Please find attached as well.

-Stafford
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-sim-or1k-Add-generated-files.patch.bz2
Type: application/x-bzip2
Size: 124467 bytes
Desc: not available
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20170901/55af987d/attachment-0001.bin>

#3 lore raw

PATCH v4 1/5 sim: cgen: add remainder functions (needed for OR1K lf.rem.[sd])

In reply to Simon Marchi
Quoted 72 lines · Simon Marchi
Quoted 71 lines · Stafford Horne
sim/common/sim-fpu.c +0 -0
index 0d4d08a..1a79e71 100644
@@ -41,6 +41,7 @@ along with this program.  If not, see

<http://www.gnu.org/licenses/>. */
#include "sim-io.h"
#include "sim-assert.h"

+#include <math.h> /* for drem, remove when soft-float version is implemented */

/* Debugging support.
If digits is -1, then print all digits. */

sim/common/sim-fpu.c +53 -0
@@ -1551,6 +1552,68 @@ sim_fpu_div (sim_fpu *f,
 
 
 INLINE_SIM_FPU (int)
+sim_fpu_rem (sim_fpu *f,
+	     const sim_fpu *l,
+	     const sim_fpu *r)
+{
+  if (sim_fpu_is_snan (l))
+    {
+      *f = *l;
+      f->class = sim_fpu_class_qnan;
+      return sim_fpu_status_invalid_snan;
+    }
+  if (sim_fpu_is_snan (r))
+    {
+      *f = *r;
+      f->class = sim_fpu_class_qnan;
+      return sim_fpu_status_invalid_snan;
+    }
+  if (sim_fpu_is_qnan (l))
+    {
+      *f = *l;
+      f->class = sim_fpu_class_qnan;
+      return 0;
+    }
+  if (sim_fpu_is_qnan (r))
+    {
+      *f = *r;
+      f->class = sim_fpu_class_qnan;
+      return 0;
+    }
+  if (sim_fpu_is_infinity (l))
+    {
+      *f = sim_fpu_qnan;
+      return sim_fpu_status_invalid_irx;
+    }
+  if (sim_fpu_is_zero (r))
+    {
+      *f = sim_fpu_qnan;
+      return sim_fpu_status_invalid_div0;
+    }
+  if (sim_fpu_is_zero (l))
+    {
+      *f = *l;
+      return 0;
+    }
+  if (sim_fpu_is_infinity (r))
+    {
+      *f = *l;
+      return 0;
+    }
+  {
+    /* TODO: Implement remainder here.  */
+
+    sim_fpu_map lval, rval, fval;
+    lval.i = pack_fpu(l, 1);
Quoted 8 lines

sim/common/sim-fpu.c sim_fpu_div (sim_fpu *f, · line 1612

Quoted 5 lines
sim/common/sim-fpu.c +5 -0
+    rval.i = pack_fpu(r, 1);
+    fval.d = remainder(lval.d, rval.d);
+    unpack_fpu(f, fval.i, 1);
+    return 0;
+  }

I can't tell for sure because I'm not maintainer of sim/, but I suppose that we would need a proper implementation that doesn't use the host fpu here.

Right, as mentioned in the summary, this is the one place that is a bit controversial.

I was thinking its kind of strange to not allow using libmath, since integer math runs on the host system, why not FPU as well? (probably to implement this I would just copy from libmath in the end:)

https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/ieee754/dbl-64/e_remainder.c;hb=HEAD

There are actually no OpenRISC cores that implement the remainder instruction (as its a bit complicated to do in hardware and not really used much). I could remove it if the implementation is beyond the scope of this series.

Quoted 12 lines
Quoted 12 lines
sim/common/sim-fpu.c +4 -0
+}
+
+
+INLINE_SIM_FPU (int)
 sim_fpu_max (sim_fpu *f,
 	     const sim_fpu *l,
 	     const sim_fpu *r)
sim/common/sim-fpu.h +0 -0
index d27d80a..c108f1f 100644
@@ -151,6 +151,7 @@ typedef enum
Quoted 8 lines

sim/common/sim-fpu.h typedef enum · line 155

Quoted 5 lines
sim/common/sim-fpu.h +1 -0
   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;

I think it would make sense to put the new entry with the other "invalid" ones and shift the others.

OK.

Thanks for the review and picking this up.

-Stafford

Quoted 2 lines

Simon

#4 lore raw

PATCH v4 1/5 sim: cgen: add remainder functions (needed for OR1K lf.rem.[sd])

Quoted 11 lines · Stafford Horne
Quoted 4 lines

I can't tell for sure because I'm not maintainer of sim/, but I suppose that
we would need a proper implementation that doesn't use the host fpu here.

Right, as mentioned in the summary, this is the one place that is a bit controversial.

I was thinking its kind of strange to not allow using libmath, since integer math runs on the host system, why not FPU as well? (probably to implement this I would just copy from libmath in the end:)

That was just my conclusion after reading the comment in sim-fpu.h:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=sim/common/sim-fpu.h;h=d27d80a513aa8d996a7b4c6af53fde31dcb8dad7;hb=HEAD#l54

It is easy for floating point unit implementations to return wrong or slightly different results. Integer math is more consistent.

Quoted 8 lines

https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/ieee754/dbl-64/e_remainder.c;hb=HEAD

There are actually no OpenRISC cores that implement the remainder instruction (as its a bit complicated to do in hardware and not really used
much). I could remove it if the implementation is beyond the scope of this
series.

Indeed, it can always be contributed later.

Simon

#5 lore raw

PATCH v4 1/5 sim: cgen: add remainder functions (needed for OR1K lf.rem.[sd])

Quoted 22 lines · Simon Marchi
Quoted 11 lines · Stafford Horne
Quoted 4 lines

I can't tell for sure because I'm not maintainer of sim/, but I suppose that
we would need a proper implementation that doesn't use the host fpu here.

Right, as mentioned in the summary, this is the one place that is a bit controversial.

I was thinking its kind of strange to not allow using libmath, since integer math runs on the host system, why not FPU as well? (probably to implement this I would just copy from libmath in the end:)

That was just my conclusion after reading the comment in sim-fpu.h:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=sim/common/sim-fpu.h;h=d27d80a513aa8d996a7b4c6af53fde31dcb8dad7;hb=HEAD#l54

It is easy for floating point unit implementations to return wrong or slightly different results. Integer math is more consistent.

Quoted 2 lines

https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/ieee754/dbl-64/e_remainder.c;hb=HEAD

Quoted 8 lines
Quoted 6 lines

There are actually no OpenRISC cores that implement the remainder instruction (as its a bit complicated to do in hardware and not really used
much). I could remove it if the implementation is beyond the scope of this
series.

Indeed, it can always be contributed later.

Right, I think thats the easiest route. Ill resubmit the series in a few days after I receive other comments from you.

-Stafford

#7 lore raw

PATCH v4 2/5 sim: cgen: add MUL2OFSI and MUL1OFSI macros (needed for OR1K l.mul[u])

In reply to Stafford Horne
Quoted 11 lines
sim/common/cgen-ops.h +5 -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;

sim/common/cgen-ops.h SUBOFQI (QI a, QI b, BI c) · line 648

Quoted 10 lines
sim/common/cgen-ops.h +10 -0
+  return res;
+}
+
+SEMOPS_INLINE BI
+MUL1OFSI (USI a, USI b)
+{
+  UDI tmp = MULDI (ZEXTSIDI(a), ZEXTSIDI(b));
+  BI res = (tmp > 0xFFFFFFFFULL);
+  return res;
+}

What are these functions expected to return? They seem to return 1 when the result would overflow 32-bits, but just to be sure.

Simon

#8 lore raw

PATCH v4 2/5 sim: cgen: add MUL2OFSI and MUL1OFSI macros (needed for OR1K l.mul[u])

Quoted 17 lines · Simon Marchi
Quoted 17 lines
sim/common/cgen-ops.h +11 -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)
+{
Quoted 8 lines

sim/common/cgen-ops.h SUBOFQI (QI a, QI b, BI c) · line 648

Quoted 4 lines
sim/common/cgen-ops.h +4 -0
+  UDI tmp = MULDI (ZEXTSIDI(a), ZEXTSIDI(b));
+  BI res = (tmp > 0xFFFFFFFFULL);
+  return res;
+}

What are these functions expected to return? They seem to return 1 when the result would overflow 32-bits, but just to be sure.

They do just return 1 when there is overflow.

They are used in:
cpu/or1korbis.cpu

To calculate the overflow and carry flags.

; 2's complement overflow
(set sys-sr-ov (mul-o2flag WI rA (ext WI simm16))) ; 1's complement overflow
(set sys-sr-cy (mul-o1flag UWI rA (ext UWI simm16)))

Thanks for pointing this out though the ChangeLog says "New macro, 1's complement." I think it should mention "New macro, 1's complement _overflow_."

#10 lore raw

PATCH v4 3/5 sim: or1k: add or1k target to sim

In reply to Stafford Horne

Hi Stafford,

I started to look at this patch, and I have to say that it's quite difficult for an outsider like me to follow. I can see what the code is doing, and can correlate some parts with the openrisc spec. But since there are no comments at all, I have no idea what the intents are, so I can't really tell whether the code is right or wrong wrt the intent. Maybe it's just because of my lack of experience in the area, and somebody familiar with the sim code would find it obvious. Still, I think adding some comments would help future contributors.

For example, in or1k_cpu_init:

Quoted 36 lines
(quoted diff) +13 -0
+void
+or1k_cpu_init (SIM_DESC sd, sim_cpu * current_cpu, const USI or1k_vr,
+	       const USI or1k_upr, const USI or1k_cpucfgr)
+{
+  SET_H_SYS_VR (or1k_vr);
+  SET_H_SYS_UPR (or1k_upr);
+  SET_H_SYS_CPUCFGR (or1k_cpucfgr);
+
+#define CHECK_SPR_FIELD(GROUP, INDEX, FIELD, test)                     
 \
+  do {                                                                 
 \
+    USI field = GET_H_##SYS##_##INDEX##_##FIELD ();                    
 \
+    if (!(test)) {                                                     
 \
+      sim_io_eprintf(sd, "WARNING: unsupported %s field in %s

register: 0x%x\n", \

sim/or1k/or1k.c new file +16 -0
+                     #FIELD, #INDEX, field);                           
 \
+    }                                                                  
 \
+  } while (0)
+
+  current_cpu->next_delay_slot = 0;
+  current_cpu->delay_slot = 0;
+
+  CHECK_SPR_FIELD (SYS, UPR, UP, field == 1);
+  CHECK_SPR_FIELD (SYS, UPR, DCP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, ICP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, DMP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, MP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, IMP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, DUP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, PCUP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, PICP, field == 0);

sim/or1k/or1k.c line 176

Quoted 10 lines
sim/or1k/or1k.c new file +10 -0
+  CHECK_SPR_FIELD (SYS, UPR, PMP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, TTP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, CUP, field == 0);
+
+  CHECK_SPR_FIELD (SYS, CPUCFGR, NSGR, field == 0);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, CGF, field == 0);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OB32S, field == 1);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OB64S, field == 0);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OF64S, field == 0);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OV64S, field == 0);

Here, I think a comment should explain what these checks are about. I understand they are checking for CPU features, making sure they are or aren't there, but why?

sim/or1k/or1k.c line 180

Quoted 4 lines
sim/or1k/or1k.c new file +4 -0
+
+#undef CHECK_SPR_FIELD
+
+  SET_H_SYS_UPR_UP (1);

This, looks fishy to me, but maybe there's a good reason for it to be there? In the checks above we made sure that the UP bit of the UPR register was set. Why do we need to set it here?

I understand that there can't be (and we don't want) a comment for each source line, but at least some high level ones.

Thanks,

Simon

#11 lore raw

PATCH v4 3/5 sim: or1k: add or1k target to sim

Quoted 10 lines · Simon Marchi

Hi Stafford,

I started to look at this patch, and I have to say that it's quite difficult for an outsider like me to follow. I can see what the code is doing, and can correlate some parts with the openrisc spec. But since there are no comments at all, I have no idea what the intents are, so I can't really tell whether the code is right or wrong wrt the intent. Maybe it's just because of my lack of experience in the area, and somebody familiar with the sim code would find it obvious. Still, I think adding some comments would help future contributors.

Fair enough, to me I am also an outsider having inherited this. It took me some time to figure this all out as well.

I will try to add some comments.

Quoted 44 lines

For example, in or1k_cpu_init:

Quoted 42 lines
sim/or1k/or1k.c new file +9 -0
+void
+or1k_cpu_init (SIM_DESC sd, sim_cpu * current_cpu, const USI or1k_vr,
+	       const USI or1k_upr, const USI or1k_cpucfgr)
+{
+  SET_H_SYS_VR (or1k_vr);
+  SET_H_SYS_UPR (or1k_upr);
+  SET_H_SYS_CPUCFGR (or1k_cpucfgr);
+
+#define CHECK_SPR_FIELD(GROUP, INDEX, FIELD, test)

\
+ do {
\
+ USI field = GET_H_##SYS##_##INDEX##_##FIELD ();
\
+ if (!(test)) {
\
+ sim_io_eprintf(sd, "WARNING: unsupported %s field in %s
register: 0x%x\n", \
+ #FIELD, #INDEX, field);
\
+ }
\

sim/or1k/or1k.c new file +20 -0
+  } while (0)
+
+  current_cpu->next_delay_slot = 0;
+  current_cpu->delay_slot = 0;
+
+  CHECK_SPR_FIELD (SYS, UPR, UP, field == 1);
+  CHECK_SPR_FIELD (SYS, UPR, DCP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, ICP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, DMP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, MP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, IMP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, DUP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, PCUP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, PICP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, PMP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, TTP, field == 0);
+  CHECK_SPR_FIELD (SYS, UPR, CUP, field == 0);
+
+  CHECK_SPR_FIELD (SYS, CPUCFGR, NSGR, field == 0);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, CGF, field == 0);
Quoted 8 lines

sim/or1k/or1k.c line 176

Quoted 4 lines
sim/or1k/or1k.c new file +4 -0
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OB32S, field == 1);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OB64S, field == 0);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OF64S, field == 0);
+  CHECK_SPR_FIELD (SYS, CPUCFGR, OV64S, field == 0);

Here, I think a comment should explain what these checks are about. I understand they are checking for CPU features, making sure they are or aren't there, but why?

These registers it checks, the UPR (unit present register) and CPUCFGR (CPU configuration register), specify how the system has been configured. I.e. which features are available.

Here we do some sanity checks to make sure its not configured to enable modules that are not available in the sim. Some flags can be configurable, but the ones checked above cannot be. The configuration of the sim can be passed in the by user as we can see in sim_open(), thats why these validations are needed.

Quoted 8 lines

sim/or1k/or1k.c line 180

Quoted 4 lines
sim/or1k/or1k.c new file +4 -0
+
+#undef CHECK_SPR_FIELD
+
+  SET_H_SYS_UPR_UP (1);

This, looks fishy to me, but maybe there's a good reason for it to be there? In the checks above we made sure that the UP bit of the UPR register was set. Why do we need to set it here?

This is here to configure the UPR[UP] (UPR is present flag) to 1, even in case we didnt set it above when we do:

  SET_H_SYS_UPR (or1k_upr);

The call to SET_H_SYS_UPR() sets all of the flags in the UPR as sent in from the user arguments. If they didn't set UPR[UP] we make sure it gets set.

Quoted 3 lines

I understand that there can't be (and we don't want) a comment for each source line, but at least some high level ones.

Understood, Ill try to make the major points commented. Especially where some of the more complicated code generation macros are used.

-Stafford

#12 lore raw

PATCH v4 3/5 sim: or1k: add or1k target to sim

Quoted 10 lines · Stafford Horne

This is here to configure the UPR[UP] (UPR is present flag) to 1, even in
case we didnt set it above when we do:

  SET_H_SYS_UPR (or1k_upr);

The call to SET_H_SYS_UPR() sets all of the flags in the UPR as sent in from the user arguments. If they didn't set UPR[UP] we make sure it gets
set.

Oh ok for some reason I though that CHECK_SPR_FIELD was throwing an error when a check failed, but actually it just prints a warning. That's why I thought that the UP bit would necessarily already be set at this point.

Sorry about that.

Simon