Skip to content

Commit 221d90a

Browse files
author
Dimitar Dimitrov
committed
Merge branch 'wip-ti-abi'
Publish the new branch with improved TI ABI compatibility. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 parents 974d610 + 7e45e38 commit 221d90a

File tree

87 files changed

+47424
-24542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+47424
-24542
lines changed

README.md

+13-11
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ This is an unofficial GCC/Binutils port for the PRU I/O CPU core that is present
55

66
The release is ready for cautious usage. A simulator is used to execute the GCC C regression test suite. Results for this release are:
77

8-
# of expected passes 87486
9-
# of unexpected failures 17
10-
# of unexpected successes 3
11-
# of expected failures 151
12-
# of unsupported tests 2621
8+
# of expected passes 90967
9+
# of unexpected failures 73
10+
# of unexpected successes 9
11+
# of expected failures 200
12+
# of unsupported tests 2917
13+
14+
Results from the GCC ABI test suite:
15+
16+
# of expected passes 686
17+
# of unexpected failures 7
18+
# of unresolved testcases 38
19+
# of unsupported tests 18
1320

1421
There are several examples to get started:
1522
* Assorted small examples: https://github.com/dinuxbg/pru-gcc-examples
@@ -27,7 +34,7 @@ If you are running Beaglebone Debian Jessie image, then installation is simple:
2734

2835
For other Debian Jessie images, you'll need to add Robert Nelson's package repository. Open /etc/apt/sources.list and add the following line:
2936

30-
deb [arch=armhf] http://repos.rcn-ee.com/debian/ stretch main
37+
deb [arch=armhf] http://repos.rcn-ee.com/debian/ jessie main
3138

3239
## Building From Sources
3340
The toolchain is published as a series of patches inside the patches subdirectory. The build scripts are tested on a Debian host, but should work on any recent distro.
@@ -64,8 +71,3 @@ Testing the output:
6471

6572
## Acknowledgements
6673
* GCC/Binutils Nios2 port was taken as a base for the PRU port.
67-
68-
## TODO
69-
A few long term tasks:
70-
* Need to review the GCC function prologue handling. Current code is a direct copy of the Nios2 code. It should be correct but is not efficient for PRU.
71-
* Investigate feasibility of "packed" register support in GCC. PRU port may have to be rewritten to use "virtual" 8-bit registers in order to allow more efficient variable packing.

download-and-patch.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
# On which upstream commits to apply patches. I frequently rebase so
77
# expect these to be somewhat random.
8-
GCC_BASECOMMIT=1b144f1382f9ce9f65527340cf4d29703c95949d
9-
BINUTILS_BASECOMMIT=8c65b54f18c03ffb844e1cbaa3b46b43444ff9e7
10-
NEWLIB_BASECOMMIT=780503f6acf9e0795c3b7a686a2815620098f8da
8+
GCC_BASECOMMIT=deba768879cc39f754b9f2fdd7f8f8f5fafd8972
9+
BINUTILS_BASECOMMIT=7d4f13635fd26bceb34ba5002ee9008463755bbe
10+
NEWLIB_BASECOMMIT=8b6804b8a8816be67843d694851331d97909998e
1111

1212
# You can export your (local) repositories to speed up
1313
# compilation.

g++.sum

+11,095-1,925
Large diffs are not rendered by default.

gcc-abi.sum

+769
Large diffs are not rendered by default.

gcc.sum

+5,808-1,638
Large diffs are not rendered by default.

packaging/binutils-pru/debian/changelog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
binutils-pru (2.30.51.20180310) stretch; urgency=medium
2+
3+
* ld: Switched relocations to be more compatible with TI's toolchain. YOU MUST RECOMPILE ALL YOUR SOURCE FILES - object files from old and new binutils cannot be linked together.
4+
* Rebased to latest baseline.
5+
6+
-- Dimitar Dimitrov <dinux@tpdeb> Mon, 12 Mar 2018 20:54:12 +0200
7+
18
binutils-pru (2.28.51.20170530) stretch; urgency=medium
29

310
* Rebased to upstream.

packaging/gcc-pru/debian/changelog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
gcc-pru (8.0.1.20180310) stretch; urgency=medium
2+
3+
* GCC PRU port has been overhauled to better support TI ABI.
4+
* When linking object files from GCC and TI toolchains, you must use the -mabi=ti option.
5+
6+
-- Dimitar Dimitrov <dinux@tpdeb> Mon, 12 Mar 2018 20:59:11 +0200
7+
18
gcc-pru (8.0.0.20170530) stretch; urgency=medium
29

310
* Optimized arithmetic shift right. Fixes github issue #25.

packaging/gcc-pru/debian/control

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Section: devel
33
Priority: extra
44
Maintainer: Dimitar Dimitrov <dinuxbg@gmail.com>
55
Standards-Version: 3.9.5
6-
Build-Depends: m4, autoconf2.64, libtool, bzip2, binutils-pru (>= 2.28.51.20170530), bison, flex, gettext, texinfo, zlib1g-dev, debhelper (>= 4.2.10), tar (>= 1.13.18), libmpfr-dev, lsb-release, patchutils, libmpc-dev, dpkg (>= 1.16.2), dh-autoreconf
6+
Build-Depends: m4, autoconf2.64, libtool, bzip2, binutils-pru (>= 2.30.51.20180310), bison, flex, gettext, texinfo, zlib1g-dev, debhelper (>= 4.2.10), tar (>= 1.13.18), libmpfr-dev, lsb-release, patchutils, libmpc-dev, dpkg (>= 1.16.2), dh-autoreconf
77
Build-Conflicts: libgcc0, libgcc300
88

99
Package: gcc-pru
1010
Architecture: any
1111
Section: devel
1212
Priority: extra
13-
Depends: ${shlibs:Depends}, ${misc:Depends}, binutils-pru (>= 2.28.51.20170530)
13+
Depends: ${shlibs:Depends}, ${misc:Depends}, binutils-pru (>= 2.30.51.20180310)
1414
Provides: c-compiler-pru
1515
Suggests: task-c-devel, gcc-doc (>= 4:4.8), gcc (>= 4:4.8)
1616
Description: GNU C compiler (cross compiler for pru)

patches/binutils-gdb/0001-PRU-Simulator-port.patch

+74-46
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From d6480a1d01cfabf0324d8d4cd3e852cb36f8a476 Mon Sep 17 00:00:00 2001
1+
From e3246656cf3031921a86c438bb73670a92d9921f Mon Sep 17 00:00:00 2001
22
From: Dimitar Dimitrov <dimitar@dinux.eu>
33
Date: Mon, 24 Oct 2016 22:37:01 +0300
4-
Subject: [PATCH 1/7] PRU Simulator port
4+
Subject: [PATCH 01/12] PRU Simulator port
55

66
The corresponding libgloss changes have not yet been mainlined.
77
The PRU patches are available here:
@@ -45,14 +45,14 @@ Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4545
sim/configure | 8 +
4646
sim/configure.tgt | 3 +
4747
sim/pru/Makefile.in | 29 ++
48-
sim/pru/aclocal.m4 | 129 +++++++++
48+
sim/pru/aclocal.m4 | 129 ++++++++
4949
sim/pru/config.in | 248 ++++++++++++++++
5050
sim/pru/configure.ac | 12 +
51-
sim/pru/interp.c | 729 +++++++++++++++++++++++++++++++++++++++++++++++
51+
sim/pru/interp.c | 752 +++++++++++++++++++++++++++++++++++++++++++++++
5252
sim/pru/pru.h | 101 +++++++
5353
sim/pru/pru.isa | 249 ++++++++++++++++
54-
sim/pru/sim-main.h | 75 +++++
55-
13 files changed, 1619 insertions(+)
54+
sim/pru/sim-main.h | 80 +++++
55+
13 files changed, 1647 insertions(+)
5656
create mode 100644 sim/pru/Makefile.in
5757
create mode 100644 sim/pru/aclocal.m4
5858
create mode 100644 sim/pru/config.in
@@ -63,11 +63,11 @@ Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
6363
create mode 100644 sim/pru/sim-main.h
6464

6565
diff --git a/sim/MAINTAINERS b/sim/MAINTAINERS
66-
index 62887d4bb1..875661da26 100644
66+
index 0991bfe9a6..08064230ff 100644
6767
--- a/sim/MAINTAINERS
6868
+++ b/sim/MAINTAINERS
69-
@@ -29,6 +29,7 @@ microblaze Michael Eager <eager@eagercon.com>
70-
mips Maciej W. Rozycki <macro@imgtec.com>
69+
@@ -30,6 +30,7 @@ microblaze Michael Eager <eager@eagercon.com>
70+
mips Maciej W. Rozycki <macro@mips.com>
7171
moxie Anthony Green <green@moxielogic.com>
7272
msp430 Nick Clifton <nickc@redhat.com>
7373
+pru Dimitar Dimitrov <dimitar@dinux.eu>
@@ -126,20 +126,20 @@ index 3f82d47b6b..92ccc9aded 100644
126126
+#endif
127127
+#endif
128128
diff --git a/sim/configure b/sim/configure
129-
index 2729e69817..f92d310a2c 100755
129+
index b90152e7fb..39d6700a1f 100755
130130
--- a/sim/configure
131131
+++ b/sim/configure
132-
@@ -654,6 +654,7 @@ mips
133-
mn10300
132+
@@ -655,6 +655,7 @@ mn10300
134133
moxie
134+
or1k
135135
msp430
136136
+pru
137137
rl78
138138
rx
139139
sh64
140-
@@ -3768,6 +3769,13 @@ subdirs="$subdirs aarch64"
141-
140+
@@ -3779,6 +3780,13 @@ subdirs="$subdirs aarch64"
142141

142+
sim_testsuite=yes
143143
;;
144144
+ pru*-*-*)
145145
+
@@ -152,12 +152,12 @@ index 2729e69817..f92d310a2c 100755
152152

153153
sim_arch=rl78
154154
diff --git a/sim/configure.tgt b/sim/configure.tgt
155-
index c958fb3174..357d7ac337 100644
155+
index a6dbd1af83..8a8e03d96f 100644
156156
--- a/sim/configure.tgt
157157
+++ b/sim/configure.tgt
158-
@@ -76,6 +76,9 @@ case "${target}" in
159-
msp430*-*-*)
160-
SIM_ARCH(msp430)
158+
@@ -79,6 +79,9 @@ case "${target}" in
159+
or1k-*-* | or1knd-*-*)
160+
SIM_ARCH(or1k)
161161
;;
162162
+ pru*-*-*)
163163
+ SIM_ARCH(pru)
@@ -609,10 +609,10 @@ index 0000000000..54ac06f48e
609609
+SIM_AC_OUTPUT
610610
diff --git a/sim/pru/interp.c b/sim/pru/interp.c
611611
new file mode 100644
612-
index 0000000000..099b9c1d42
612+
index 0000000000..539a8ec1a2
613613
--- /dev/null
614614
+++ b/sim/pru/interp.c
615-
@@ -0,0 +1,729 @@
615+
@@ -0,0 +1,752 @@
616616
+/* Simulator for the Texas Instruments PRU processor
617617
+ Copyright 2014-2017 Free Software Foundation, Inc.
618618
+ Inspired by the Microblase simulator
@@ -930,16 +930,6 @@ index 0000000000..099b9c1d42
930930
+ sim_io_error (sd, "XIN MAC: invalid transfer regn=%u.%u, length=%u\n",
931931
+ rd_regn, rdb, length);
932932
+
933-
+ if ((CPU.macregs[PRU_MACREG_MODE] & MAC_R25_MAC_MODE_MASK) == 0)
934-
+ {
935-
+ /* Per TRM, PRU auto-samples R28/R29 on every cycle. But in fact we
936-
+ calculate only when interested in the product. */
937-
+ uint64_t prod;
938-
+ prod = (uint64_t)CPU.regs[28] * (uint64_t)CPU.regs[29];
939-
+ CPU.macregs[PRU_MACREG_PROD_L] = prod & 0xfffffffful;
940-
+ CPU.macregs[PRU_MACREG_PROD_H] = prod >> 32;
941-
+ }
942-
+
943933
+ /* Copy from MAC to PRU regs. Ranges have been validated above. */
944934
+ while (length--)
945935
+ {
@@ -986,7 +976,7 @@ index 0000000000..099b9c1d42
986976
+pru_sim_xout (SIM_DESC sd, SIM_CPU *cpu, unsigned int wba,
987977
+ unsigned int rd_regn, unsigned int rdb, unsigned int length)
988978
+{
989-
+ const int modereg_accessed = (rd_regn == 25); /* revise! */
979+
+ const int modereg_accessed = (rd_regn == 25);
990980
+
991981
+ if (wba != 0)
992982
+ sim_io_error (sd, "XOUT: XFR device %d not supported.\n", wba);
@@ -1010,27 +1000,38 @@ index 0000000000..099b9c1d42
10101000
+ }
10111001
+
10121002
+ if (modereg_accessed
1013-
+ && (CPU.macregs[PRU_MACREG_MODE] & MAC_R25_ACC_CARRY_MASK))
1014-
+ {
1015-
+ /* store 1 to clear. */
1016-
+ CPU.macregs[PRU_MACREG_MODE] &= ~MAC_R25_ACC_CARRY_MASK;
1017-
+ }
1018-
+
1019-
+ if (modereg_accessed
10201003
+ && (CPU.macregs[PRU_MACREG_MODE] & MAC_R25_MAC_MODE_MASK))
10211004
+ {
1005+
+ /* MUL/MAC operands are sampled every XOUT in multiply and
1006+
+ accumulate mode. */
10221007
+ uint64_t prod, oldsum, sum;
1023-
+ prod = (uint64_t)CPU.regs[28] * (uint64_t)CPU.regs[29];
1024-
+ oldsum = CPU.macregs[PRU_MACREG_PROD_L];
1025-
+ oldsum += (uint64_t)CPU.macregs[PRU_MACREG_PROD_H] << 32;
1008+
+ CPU.macregs[PRU_MACREG_OP_0] = CPU.regs[28];
1009+
+ CPU.macregs[PRU_MACREG_OP_1] = CPU.regs[29];
1010+
+
1011+
+ prod = CPU.macregs[PRU_MACREG_OP_0];
1012+
+ prod *= (uint64_t)CPU.macregs[PRU_MACREG_OP_1];
1013+
+
1014+
+ oldsum = CPU.macregs[PRU_MACREG_ACC_L];
1015+
+ oldsum += (uint64_t)CPU.macregs[PRU_MACREG_ACC_H] << 32;
10261016
+ sum = oldsum + prod;
10271017
+
10281018
+ CPU.macregs[PRU_MACREG_PROD_L] = sum & 0xfffffffful;
10291019
+ CPU.macregs[PRU_MACREG_PROD_H] = sum >> 32;
1020+
+ CPU.macregs[PRU_MACREG_ACC_L] = CPU.macregs[PRU_MACREG_PROD_L];
1021+
+ CPU.macregs[PRU_MACREG_ACC_H] = CPU.macregs[PRU_MACREG_PROD_H];
10301022
+
10311023
+ if (oldsum > sum)
10321024
+ CPU.macregs[PRU_MACREG_MODE] |= MAC_R25_ACC_CARRY_MASK;
10331025
+ }
1026+
+ if (modereg_accessed
1027+
+ && (CPU.macregs[PRU_MACREG_MODE] & MAC_R25_ACC_CARRY_MASK))
1028+
+ {
1029+
+ /* store 1 to clear. */
1030+
+ CPU.macregs[PRU_MACREG_MODE] &= ~MAC_R25_ACC_CARRY_MASK;
1031+
+ CPU.macregs[PRU_MACREG_ACC_L] = 0;
1032+
+ CPU.macregs[PRU_MACREG_ACC_H] = 0;
1033+
+ }
1034+
+
10341035
+}
10351036
+
10361037
+static void
@@ -1068,6 +1069,14 @@ index 0000000000..099b9c1d42
10681069
+ {
10691070
+ TRACE_DISASM (cpu, PC_byteaddr);
10701071
+
1072+
+ /* In multiply-only mode, R28/R29 operands are sampled on every clock
1073+
+ cycle. */
1074+
+ if ((CPU.macregs[PRU_MACREG_MODE] & MAC_R25_MAC_MODE_MASK) == 0)
1075+
+ {
1076+
+ CPU.macregs[PRU_MACREG_OP_0] = CPU.regs[28];
1077+
+ CPU.macregs[PRU_MACREG_OP_1] = CPU.regs[29];
1078+
+ }
1079+
+
10711080
+ switch (op->type)
10721081
+ {
10731082
+/* Helper macro to improve clarity of pru.isa. The empty while is a
@@ -1102,6 +1111,20 @@ index 0000000000..099b9c1d42
11021111
+ PC = LOOPTOP;
11031112
+ }
11041113
+
1114+
+ /* In multiply-only mode, MAC does multiplication every cycle. */
1115+
+ if ((CPU.macregs[PRU_MACREG_MODE] & MAC_R25_MAC_MODE_MASK) == 0)
1116+
+ {
1117+
+ uint64_t prod;
1118+
+ prod = CPU.macregs[PRU_MACREG_OP_0];
1119+
+ prod *= (uint64_t)CPU.macregs[PRU_MACREG_OP_1];
1120+
+ CPU.macregs[PRU_MACREG_PROD_L] = prod & 0xfffffffful;
1121+
+ CPU.macregs[PRU_MACREG_PROD_H] = prod >> 32;
1122+
+
1123+
+ /* Clear the MAC accumulator when in normal mode. */
1124+
+ CPU.macregs[PRU_MACREG_ACC_L] = 0;
1125+
+ CPU.macregs[PRU_MACREG_ACC_H] = 0;
1126+
+ }
1127+
+
11051128
+ /* Update cycle counts. */
11061129
+ CPU.insts += 1; /* One instructions completed ... */
11071130
+ CPU.cycles += 1; /* and it takes a single cycle. */
@@ -1706,10 +1729,10 @@ index 0000000000..af72cf30c7
17061729
+ })
17071730
diff --git a/sim/pru/sim-main.h b/sim/pru/sim-main.h
17081731
new file mode 100644
1709-
index 0000000000..5bd9742df0
1732+
index 0000000000..12396743db
17101733
--- /dev/null
17111734
+++ b/sim/pru/sim-main.h
1712-
@@ -0,0 +1,75 @@
1735+
@@ -0,0 +1,80 @@
17131736
+/* Copyright 2014-2017 Free Software Foundation, Inc.
17141737
+ Contributed by Dimitar Dimitrov <dimitar@dinux.eu>
17151738
+
@@ -1746,10 +1769,15 @@ index 0000000000..5bd9742df0
17461769
+ the performance of the simulator. Simulation speed is deemed more
17471770
+ important. */
17481771
+
1772+
+/* Please keep the same order as the GP registers. */
17491773
+enum pru_macreg_id {
1750-
+ PRU_MACREG_MODE,
1751-
+ PRU_MACREG_PROD_L,
1752-
+ PRU_MACREG_PROD_H,
1774+
+ PRU_MACREG_MODE, /* r25 */
1775+
+ PRU_MACREG_PROD_L, /* r26 */
1776+
+ PRU_MACREG_PROD_H, /* r27 */
1777+
+ PRU_MACREG_OP_0, /* r28 */
1778+
+ PRU_MACREG_OP_1, /* r29 */
1779+
+ PRU_MACREG_ACC_L, /* N/A */
1780+
+ PRU_MACREG_ACC_H, /* N/A */
17531781
+ PRU_MAC_NREGS
17541782
+};
17551783
+

0 commit comments

Comments
 (0)