summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gcc/gcc-11
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@xilinx.com>2021-12-01 12:48:37 -0800
committerMark Hatle <mark.hatle@xilinx.com>2022-01-14 11:21:32 -0800
commit945ff460fdc5b68b67e0edd11e91976feb0fb4b6 (patch)
treece9a125a75c7736cde8c7039ab7977cad6e8088c /meta-microblaze/recipes-devtools/gcc/gcc-11
parent5054124be6bce449516c91b98e9960216f0abd65 (diff)
downloadmeta-xilinx-945ff460fdc5b68b67e0edd11e91976feb0fb4b6.tar.gz
Revert "gcc: convert away from bbappend"
This reverts commit b56b1562c129fd12b486fd6666315afd4644ce6a. Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
Diffstat (limited to 'meta-microblaze/recipes-devtools/gcc/gcc-11')
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch35
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch31
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch35
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch35
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch43
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch67
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch28
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0008-Patch-microblaze-Fix-atomic-side-effects.patch68
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch40
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch33
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch48
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch26
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0013-Patch-microblaze-Removed-moddi3-routinue.patch157
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0014-Patch-microblaze-Add-INIT_PRIORITY-support.patch101
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0015-Patch-microblaze-Add-optimized-lshrsi3.patch81
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0016-Patch-microblaze-Add-cbranchsi4_reg.patch147
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch58
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch63
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch72
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch178
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0021-Patch-microblaze-Correct-the-const-high-double-immed.patch58
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch36
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch45
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0024-Patch-microblaze-Add-new-bit-field-instructions.patch162
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0025-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch247
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0026-Fixing-the-issue-with-the-builtin_alloc.patch44
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0027-Patch-Microblaze-update-in-constraints-for-bitfield-.patch84
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0028-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch38
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0029-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch845
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0030-Intial-commit-for-64bit-MB-sources.patch2459
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0031-re-arrangement-of-the-compare-branches.patch268
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0032-Patch-Microblaze-previous-commit-broke-the-handling-.patch28
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0033-Patch-Microblaze-Support-of-multilibs-with-m64.patch73
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0034-Fixed-issues-like.patch70
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0035-Fixed-below-issues.patch307
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0036-Added-double-arith-instructions.patch135
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0037-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch37
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0038-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch256
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0039-extending-the-Dwarf-support-to-64bit-Microblaze.patch25
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0040-fixing-the-typo-errors-in-umodsi3-file.patch29
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0041-fixing-the-32bit-LTO-related-issue9-1014024.patch68
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0042-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch25
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0043-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch29
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0044-fixing-the-long-long-long-mingw-toolchain-issue.patch59
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0045-Fix-the-MB-64-bug-of-handling-QI-objects.patch47
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0046-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch87
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0047-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch466
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0048-Author-Nagaraju-nmekala-xilinx.com.patch479
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0049-Added-new-MB-64-single-register-arithmetic-instructi.patch107
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0050-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch44
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0051-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch86
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0052-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch45
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0053-Patch-microblaze-Reducing-Stack-space-for-arguments.patch198
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0054-Patch-MicroBlaze-Typo-in-the-previous-commits.bsefi-.patch49
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/0055-Patch-MicroBlaze.patch71
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-11/microblaze-mulitlib-hack.patch58
56 files changed, 8510 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch
new file mode 100644
index 00000000..e0f7b12e
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch
@@ -0,0 +1,35 @@
1From e3f148dff6d6d926d1f39802f54abd59bd9e887c Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 13:13:57 +0530
4Subject: [PATCH 01/54] LOCAL]: Testsuite - builtins tests require fpic
5 Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
6
7Conflicts:
8
9 gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
10---
11 gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp | 8 ++++++++
12 1 file changed, 8 insertions(+)
13
14diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
15index 594c9297958..8350d9401d2 100644
16--- a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
17+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
18@@ -48,6 +48,14 @@ if { [istarget *-*-eabi*]
19 lappend additional_flags "-Wl,--allow-multiple-definition"
20 }
21
22+<<<<<<< HEAD
23+=======
24+if [istarget "microblaze*-*-linux*"] {
25+ lappend additional_flags "-Wl,-zmuldefs"
26+ lappend additional_flags "-fPIC"
27+}
28+
29+>>>>>>> 6ef6e5b... [LOCAL]: Testsuite - builtins tests require fpic
30 foreach src [lsort [find $srcdir/$subdir *.c]] {
31 if {![string match *-lib.c $src] && [runtest_file_p $runtests $src]} {
32 c-torture-execute [list $src \
33--
342.17.1
35
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch
new file mode 100644
index 00000000..431dc7ef
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch
@@ -0,0 +1,31 @@
1From bef1a4116efded9972e693ded5152f1d8670862e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 14:31:10 +0530
4Subject: [PATCH 02/54] [LOCAL]: Quick fail g++.dg/opt/memcpy1.C This
5 particular testcase fails with a timeout. Instead, fail it at compile-time
6 for microblaze. This speeds up the testsuite without removing it from the
7 FAIL reports.
8
9Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10---
11 gcc/testsuite/g++.dg/opt/memcpy1.C | 4 ++++
12 1 file changed, 4 insertions(+)
13
14diff --git a/gcc/testsuite/g++.dg/opt/memcpy1.C b/gcc/testsuite/g++.dg/opt/memcpy1.C
15index 3862756083d..db9f990f781 100644
16--- a/gcc/testsuite/g++.dg/opt/memcpy1.C
17+++ b/gcc/testsuite/g++.dg/opt/memcpy1.C
18@@ -4,6 +4,10 @@
19 // { dg-do compile }
20 // { dg-options "-O" }
21
22+#if defined (__MICROBLAZE__)
23+#error "too slow on mb. Investigate."
24+#endif
25+
26 typedef unsigned char uint8_t;
27 typedef uint8_t uint8;
28 __extension__ typedef __SIZE_TYPE__ size_t;
29--
302.17.1
31
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch
new file mode 100644
index 00000000..a2dc7ccc
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch
@@ -0,0 +1,35 @@
1From a063597f875142af49003e2f28b6c0f56e3b914d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 15:46:28 +0530
4Subject: [PATCH 03/54] [LOCAL]: For dejagnu static testing on qemu, suppress
5 warnings about multiple definitions from the test function and libc in line
6 with method used by powerpc. Dynamic linking and using a qemu binary which
7 understands sysroot resolves all test failures with builtins
8
9Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
10---
11 gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp | 4 ----
12 1 file changed, 4 deletions(-)
13
14diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
15index 8350d9401d2..d7c9b281d01 100644
16--- a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
17+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
18@@ -48,14 +48,10 @@ if { [istarget *-*-eabi*]
19 lappend additional_flags "-Wl,--allow-multiple-definition"
20 }
21
22-<<<<<<< HEAD
23-=======
24 if [istarget "microblaze*-*-linux*"] {
25 lappend additional_flags "-Wl,-zmuldefs"
26- lappend additional_flags "-fPIC"
27 }
28
29->>>>>>> 6ef6e5b... [LOCAL]: Testsuite - builtins tests require fpic
30 foreach src [lsort [find $srcdir/$subdir *.c]] {
31 if {![string match *-lib.c $src] && [runtest_file_p $runtests $src]} {
32 c-torture-execute [list $src \
33--
342.17.1
35
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch
new file mode 100644
index 00000000..661417d7
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch
@@ -0,0 +1,35 @@
1From c1028bcb40ccd8d61afc1ab798198948fbf74aa0 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 15:50:35 +0530
4Subject: [PATCH 04/54] [Patch, testsuite]: Add MicroBlaze to target-supports
5 for atomic buil. .tin tests
6
7MicroBlaze added to supported targets for atomic builtin tests.
8
9Changelog/testsuite
10
112014-02-14 David Holsgrove <david.holsgrove@xilinx.com>
12
13 * gcc/testsuite/lib/target-supports.exp: Add microblaze to
14 check_effective_target_sync_int_long.
15
16Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
17---
18 gcc/testsuite/lib/target-supports.exp | 1 +
19 1 file changed, 1 insertion(+)
20
21diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
22index 0dfe3ae0651..86caf6db9a9 100644
23--- a/gcc/testsuite/lib/target-supports.exp
24+++ b/gcc/testsuite/lib/target-supports.exp
25@@ -7468,6 +7468,7 @@ proc check_effective_target_sync_int_long { } {
26 && [check_effective_target_arm_acq_rel])
27 || [istarget bfin*-*linux*]
28 || [istarget hppa*-*linux*]
29+ || [istarget microblaze*-*linux*]
30 || [istarget s390*-*-*]
31 || [istarget powerpc*-*-*]
32 || [istarget crisv32-*-*] || [istarget cris-*-*]
33--
342.17.1
35
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch
new file mode 100644
index 00000000..d34988c5
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch
@@ -0,0 +1,43 @@
1From ae5ce07a67df89dabba61414ba7dabbdabc1ee1b Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 16:20:01 +0530
4Subject: [PATCH 05/54] [Patch, testsuite]: Update MicroBlaze strings test for
5 new scan-assembly output resulting in use of $LC label
6
7ChangeLog/testsuite
8
92014-02-14 David Holsgrove <david.holsgrove@xilinx.com>
10
11 * gcc/testsuite/gcc.target/microblaze/others/strings1.c: Update
12 to include $LC label.
13
14Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
15---
16 gcc/testsuite/gcc.target/microblaze/others/strings1.c | 6 ++++--
17 1 file changed, 4 insertions(+), 2 deletions(-)
18
19diff --git a/gcc/testsuite/gcc.target/microblaze/others/strings1.c b/gcc/testsuite/gcc.target/microblaze/others/strings1.c
20index 7a63faf79f2..0403b7bdca9 100644
21--- a/gcc/testsuite/gcc.target/microblaze/others/strings1.c
22+++ b/gcc/testsuite/gcc.target/microblaze/others/strings1.c
23@@ -1,13 +1,15 @@
24 /* { dg-options "-O3" } */
25
26+/* { dg-final { scan-assembler "\.rodata*" } } */
27+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),\\\$LC.*" } } */
28+/* { dg-final { scan-assembler "\lwi\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),*" } } */
29+
30 #include <string.h>
31
32-/* { dg-final { scan-assembler "\.rodata*" } } */
33 extern void somefunc (char *);
34 int testfunc ()
35 {
36 char string2[80];
37-/* { dg-final { scan-assembler "\lwi\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,.LC*" } } */
38 strcpy (string2, "hello");
39 somefunc (string2);
40 }
41--
422.17.1
43
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch
new file mode 100644
index 00000000..4b45fcf1
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch
@@ -0,0 +1,67 @@
1From 49cf9cd3fedce80a63e9d03d42482dd4596c27a7 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:14:15 +0530
4Subject: [PATCH 06/54] [Patch, testsuite]: Allow MicroBlaze .weakext pattern
5 in regex match Extend regex pattern to include optional ext at the end of
6 .weak to match the MicroBlaze weak label .weakext
7
8ChangeLog/testsuite
9
102014-02-14 David Holsgrove <david.holsgrove@xilinx.com>
11
12 * gcc/testsuite/g++.dg/abi/rtti3.C: Extend scan-assembler
13 pattern to take optional ext after .weak.
14 * gcc/testsuite/g++.dg/abi/thunk4.C: Likewise.
15
16Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
17
18Conflicts:
19
20 gcc/testsuite/g++.dg/abi/rtti3.C
21---
22 gcc/testsuite/g++.dg/abi/rtti3.C | 4 ++--
23 gcc/testsuite/g++.dg/abi/thunk3.C | 2 +-
24 gcc/testsuite/g++.dg/abi/thunk4.C | 2 +-
25 3 files changed, 4 insertions(+), 4 deletions(-)
26
27diff --git a/gcc/testsuite/g++.dg/abi/rtti3.C b/gcc/testsuite/g++.dg/abi/rtti3.C
28index 0cc7d3e79d0..f284cd9255c 100644
29--- a/gcc/testsuite/g++.dg/abi/rtti3.C
30+++ b/gcc/testsuite/g++.dg/abi/rtti3.C
31@@ -3,8 +3,8 @@
32
33 // { dg-require-weak "" }
34 // { dg-skip-if "Linkonce not weak" { *-*-mingw* *-*-cygwin } }
35-// { dg-final { scan-assembler ".weak\[ \t\]_?_ZTSPP1A" { target { ! { *-*-darwin* hppa*-*-hpux* } } } } }
36-// { dg-final { scan-assembler-not ".weak\[ \t\]_?_ZTIPP1A" { target { ! { *-*-darwin* } } } } }
37+// { dg-final { scan-assembler ".weak(ext)?\[ \t\]_?_ZTSPP1A" { target { ! { *-*-darwin* } } } } }
38+// { dg-final { scan-assembler-not ".weak(ext)?\[ \t\]_?_ZTIPP1A" { target { ! { *-*-darwin* } } } } }
39 // { dg-final { scan-assembler ".weak_definition\[ \t\]_?_ZTSPP1A" { target { *-*-darwin* } } } }
40 // { dg-final { scan-assembler-not ".weak_definition\[ \t\]_?_ZTIPP1A" { target { *-*-darwin* } } } }
41
42diff --git a/gcc/testsuite/g++.dg/abi/thunk3.C b/gcc/testsuite/g++.dg/abi/thunk3.C
43index f2347f79ecd..dcec8a771a1 100644
44--- a/gcc/testsuite/g++.dg/abi/thunk3.C
45+++ b/gcc/testsuite/g++.dg/abi/thunk3.C
46@@ -1,5 +1,5 @@
47 // { dg-require-weak "" }
48-// { dg-final { scan-assembler-not ".weak\[\t \]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
49+// { dg-final { scan-assembler-not ".weak(ext)?\[\t \]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
50 // { dg-final { scan-assembler-not ".weak_definition\[\t \]_?_ZThn._N7Derived3FooEv" { target { *-*-darwin* } } } }
51
52 struct Base
53diff --git a/gcc/testsuite/g++.dg/abi/thunk4.C b/gcc/testsuite/g++.dg/abi/thunk4.C
54index 6e8f124bc5e..d1d34fe1e4a 100644
55--- a/gcc/testsuite/g++.dg/abi/thunk4.C
56+++ b/gcc/testsuite/g++.dg/abi/thunk4.C
57@@ -1,6 +1,6 @@
58 // { dg-require-weak "" }
59 // { dg-skip-if "Linkonce not weak" { *-*-mingw* *-*-cygwin } }
60-// { dg-final { scan-assembler ".weak\[ \t\]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
61+// { dg-final { scan-assembler ".weak(ext)?\[ \t\]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
62 // { dg-final { scan-assembler ".weak_definition\[ \t\]_?_ZThn._N7Derived3FooEv" { target { *-*-darwin* } } } }
63
64 struct Base
65--
662.17.1
67
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch
new file mode 100644
index 00000000..8fa324ad
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch
@@ -0,0 +1,28 @@
1From dc6cbb4e18a3f31441403146b8f159554c329897 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:34:27 +0530
4Subject: [PATCH 07/54] [Patch, testsuite]: Add MicroBlaze to
5 check_profiling_available Testsuite, add microblaze*-*-* target in
6 check_profiling_available inline with other archs setting
7 profiling_available_saved to 0
8
9Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
10---
11 gcc/testsuite/lib/target-supports.exp | 1 +
12 1 file changed, 1 insertion(+)
13
14diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
15index 86caf6db9a9..cbd9024ece9 100644
16--- a/gcc/testsuite/lib/target-supports.exp
17+++ b/gcc/testsuite/lib/target-supports.exp
18@@ -707,6 +707,7 @@ proc check_profiling_available { test_what } {
19 || [istarget m68k-*-elf]
20 || [istarget m68k-*-uclinux*]
21 || [istarget mips*-*-elf*]
22+ || [istarget microblaze*-*-*]
23 || [istarget mmix-*-*]
24 || [istarget mn10300-*-elf*]
25 || [istarget moxie-*-elf*]
26--
272.17.1
28
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0008-Patch-microblaze-Fix-atomic-side-effects.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0008-Patch-microblaze-Fix-atomic-side-effects.patch
new file mode 100644
index 00000000..1fa55729
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0008-Patch-microblaze-Fix-atomic-side-effects.patch
@@ -0,0 +1,68 @@
1From 602713d07d2e1b3a33a7f097baff270266aa4254 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:41:43 +0530
4Subject: [PATCH 08/54] [Patch, microblaze]: Fix atomic side effects. In
5 atomic_compare_and_swapsi, add side effects to prevent incorrect assumptions
6 during optimization. Previously, the outputs were considered unused; this
7 generated assembly code with undefined side effects after invocation of the
8 atomic.
9
10Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com>
11Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
12
13Conflicts:
14 gcc/config/microblaze/microblaze.md
15---
16 gcc/config/microblaze/microblaze.md | 3 +++
17 gcc/config/microblaze/sync.md | 21 +++++++++++++--------
18 2 files changed, 16 insertions(+), 8 deletions(-)
19
20diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
21index 7049acd1dcd..eba2776ae56 100644
22--- a/gcc/config/microblaze/microblaze.md
23+++ b/gcc/config/microblaze/microblaze.md
24@@ -43,6 +43,9 @@
25 (UNSPEC_TLS 106) ;; jump table
26 (UNSPEC_SET_TEXT 107) ;; set text start
27 (UNSPEC_TEXT 108) ;; data text relative
28+ (UNSPECV_CAS_BOOL 201) ;; compare and swap (bool)
29+ (UNSPECV_CAS_VAL 202) ;; compare and swap (val)
30+ (UNSPECV_CAS_MEM 203) ;; compare and swap (mem)
31 ])
32
33 (define_c_enum "unspec" [
34diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md
35index 76f530b9d3b..24cd67e1fdb 100644
36--- a/gcc/config/microblaze/sync.md
37+++ b/gcc/config/microblaze/sync.md
38@@ -18,14 +18,19 @@
39 ;; <http://www.gnu.org/licenses/>.
40
41 (define_insn "atomic_compare_and_swapsi"
42- [(match_operand:SI 0 "register_operand" "=&d") ;; bool output
43- (match_operand:SI 1 "register_operand" "=&d") ;; val output
44- (match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
45- (match_operand:SI 3 "register_operand" "d") ;; expected value
46- (match_operand:SI 4 "register_operand" "d") ;; desired value
47- (match_operand:SI 5 "const_int_operand" "") ;; is_weak
48- (match_operand:SI 6 "const_int_operand" "") ;; mod_s
49- (match_operand:SI 7 "const_int_operand" "") ;; mod_f
50+ [(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output
51+ (unspec_volatile:SI
52+ [(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
53+ (match_operand:SI 3 "register_operand" "d") ;; expected value
54+ (match_operand:SI 4 "register_operand" "d")] ;; desired value
55+ UNSPECV_CAS_BOOL))
56+ (set (match_operand:SI 1 "register_operand" "=&d") ;; val output
57+ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_VAL))
58+ (set (match_dup 2)
59+ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_MEM))
60+ (match_operand:SI 5 "const_int_operand" "") ;; is_weak
61+ (match_operand:SI 6 "const_int_operand" "") ;; mod_s
62+ (match_operand:SI 7 "const_int_operand" "") ;; mod_f
63 (clobber (match_scratch:SI 8 "=&d"))]
64 ""
65 {
66--
672.17.1
68
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch
new file mode 100644
index 00000000..666d344f
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch
@@ -0,0 +1,40 @@
1From d3d065c9645d795e03dab6db827c08231e011a1f Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:45:45 +0530
4Subject: [PATCH 09/54] [Patch, microblaze]: Fix atomic boolean return value.
5 In atomic_compare_and_swapsi, fix boolean return value. Previously, it
6 contained zero if successful and non-zero if unsuccessful.
7
8Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com>
9Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
10---
11 gcc/config/microblaze/sync.md | 7 ++++---
12 1 file changed, 4 insertions(+), 3 deletions(-)
13
14diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md
15index 24cd67e1fdb..76c3616c992 100644
16--- a/gcc/config/microblaze/sync.md
17+++ b/gcc/config/microblaze/sync.md
18@@ -34,15 +34,16 @@
19 (clobber (match_scratch:SI 8 "=&d"))]
20 ""
21 {
22- output_asm_insn ("addc \tr0,r0,r0", operands);
23+ output_asm_insn ("add \t%0,r0,r0", operands);
24 output_asm_insn ("lwx \t%1,%y2,r0", operands);
25 output_asm_insn ("addic\t%8,r0,0", operands);
26 output_asm_insn ("bnei \t%8,.-8", operands);
27- output_asm_insn ("cmp \t%0,%1,%3", operands);
28- output_asm_insn ("bnei \t%0,.+16", operands);
29+ output_asm_insn ("cmp \t%8,%1,%3", operands);
30+ output_asm_insn ("bnei \t%8,.+20", operands);
31 output_asm_insn ("swx \t%4,%y2,r0", operands);
32 output_asm_insn ("addic\t%8,r0,0", operands);
33 output_asm_insn ("bnei \t%8,.-28", operands);
34+ output_asm_insn ("addi \t%0,r0,1", operands);
35 return "";
36 }
37 )
38--
392.17.1
40
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch
new file mode 100644
index 00000000..22bf521d
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch
@@ -0,0 +1,33 @@
1From 8d9d1f457e1e270250d8a6700d4a1e1fa09465df Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:50:17 +0530
4Subject: [PATCH 10/54] [Patch, microblaze]: Fix the Microblaze crash with
5 msmall-divides flag Compiler is crashing when we use msmall-divides and
6 mxl-barrel-shift flag. This is because when use above flags
7 microblaze_expand_divide function will be called for division operation. In
8 microblaze_expand_divide function we are using sub_reg but MicroBlaze doesn't
9 have subreg register due to this compiler was crashing. Changed the logic to
10 avoid sub_reg call
11
12Signed-off-by:Nagaraju Mekala <nmekala@xilix.com>
13---
14 gcc/config/microblaze/microblaze.c | 3 +--
15 1 file changed, 1 insertion(+), 2 deletions(-)
16
17diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
18index a0f81b71391..0186171c04c 100644
19--- a/gcc/config/microblaze/microblaze.c
20+++ b/gcc/config/microblaze/microblaze.c
21@@ -3709,8 +3709,7 @@ microblaze_expand_divide (rtx operands[])
22 mem_rtx = gen_rtx_MEM (QImode,
23 gen_rtx_PLUS (Pmode, regt1, div_table_rtx));
24
25- insn = emit_insn (gen_movqi (regqi, mem_rtx));
26- insn = emit_insn (gen_movsi (operands[0], gen_rtx_SUBREG (SImode, regqi, 0)));
27+ insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
28 jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
29 JUMP_LABEL (jump) = div_end_label;
30 LABEL_NUSES (div_end_label) = 1;
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch
new file mode 100644
index 00000000..cce812bb
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch
@@ -0,0 +1,48 @@
1From 03429c91d1db134e1deda4c8e58bc0939d5fedf9 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:52:56 +0530
4Subject: [PATCH 11/54] [Patch, microblaze]: Added ashrsi3_with_size_opt Added
5 ashrsi3_with_size_opt pattern to optimize the sra instructions when the -Os
6 optimization is used. lshrsi3_with_size_opt is being removed as it has
7 conflicts with unsigned int variables
8
9Signed-off-by:Nagaraju Mekala <nmekala@xilix.com>
10---
11 gcc/config/microblaze/microblaze.md | 21 +++++++++++++++++++++
12 1 file changed, 21 insertions(+)
13
14diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
15index eba2776ae56..187ad522dcc 100644
16--- a/gcc/config/microblaze/microblaze.md
17+++ b/gcc/config/microblaze/microblaze.md
18@@ -1508,6 +1508,27 @@
19 (set_attr "length" "4,4")]
20 )
21
22+(define_insn "*ashrsi3_with_size_opt"
23+ [(set (match_operand:SI 0 "register_operand" "=&d")
24+ (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
25+ (match_operand:SI 2 "immediate_operand" "I")))]
26+ "(INTVAL (operands[2]) > 5 && optimize_size)"
27+ {
28+ operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
29+
30+ output_asm_insn ("ori\t%3,r0,%2", operands);
31+ if (REGNO (operands[0]) != REGNO (operands[1]))
32+ output_asm_insn ("addk\t%0,%1,r0", operands);
33+
34+ output_asm_insn ("addik\t%3,%3,-1", operands);
35+ output_asm_insn ("bneid\t%3,.-4", operands);
36+ return "sra\t%0,%0";
37+ }
38+ [(set_attr "type" "arith")
39+ (set_attr "mode" "SI")
40+ (set_attr "length" "20")]
41+)
42+
43 (define_insn "*ashrsi_inline"
44 [(set (match_operand:SI 0 "register_operand" "=&d")
45 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
46--
472.17.1
48
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch
new file mode 100644
index 00000000..e393f0fe
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch
@@ -0,0 +1,26 @@
1From 6803fbc540db39865037994daa122cf10c0eb33a Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 10:57:19 +0530
4Subject: [PATCH 12/54] [Patch, microblaze]: Use bralid for profiler calls
5 Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
6
7---
8 gcc/config/microblaze/microblaze.h | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
12index dc112f5301f..8aa3f155790 100644
13--- a/gcc/config/microblaze/microblaze.h
14+++ b/gcc/config/microblaze/microblaze.h
15@@ -486,7 +486,7 @@ typedef struct microblaze_args
16
17 #define FUNCTION_PROFILER(FILE, LABELNO) { \
18 { \
19- fprintf (FILE, "\tbrki\tr16,_mcount\n"); \
20+ fprintf (FILE, "\tbralid\tr15,_mcount\nnop\n"); \
21 } \
22 }
23
24--
252.17.1
26
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0013-Patch-microblaze-Removed-moddi3-routinue.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0013-Patch-microblaze-Removed-moddi3-routinue.patch
new file mode 100644
index 00000000..b601c98a
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0013-Patch-microblaze-Removed-moddi3-routinue.patch
@@ -0,0 +1,157 @@
1From 5de3888c460a341667150d569548b3309188e7e8 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 17:36:16 +0530
4Subject: [PATCH 13/54] [Patch, microblaze]: Removed moddi3 routinue Using the
5 default moddi3 function as the existing implementation has many bugs
6
7Signed-off-by:Nagaraju <nmekala@xilix.com>
8---
9 libgcc/config/microblaze/moddi3.S | 121 --------------------------
10 libgcc/config/microblaze/t-microblaze | 3 +-
11 2 files changed, 1 insertion(+), 123 deletions(-)
12 delete mode 100644 libgcc/config/microblaze/moddi3.S
13
14diff --git a/libgcc/config/microblaze/moddi3.S b/libgcc/config/microblaze/moddi3.S
15deleted file mode 100644
16index d0e24fdb89d..00000000000
17--- a/libgcc/config/microblaze/moddi3.S
18+++ /dev/null
19@@ -1,121 +0,0 @@
20-###################################
21-#
22-# Copyright (C) 2009-2020 Free Software Foundation, Inc.
23-#
24-# Contributed by Michael Eager <eager@eagercon.com>.
25-#
26-# This file is free software; you can redistribute it and/or modify it
27-# under the terms of the GNU General Public License as published by the
28-# Free Software Foundation; either version 3, or (at your option) any
29-# later version.
30-#
31-# GCC is distributed in the hope that it will be useful, but WITHOUT
32-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
33-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
34-# License for more details.
35-#
36-# Under Section 7 of GPL version 3, you are granted additional
37-# permissions described in the GCC Runtime Library Exception, version
38-# 3.1, as published by the Free Software Foundation.
39-#
40-# You should have received a copy of the GNU General Public License and
41-# a copy of the GCC Runtime Library Exception along with this program;
42-# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
43-# <http://www.gnu.org/licenses/>.
44-#
45-# modsi3.S
46-#
47-# modulo operation for 64 bit integers.
48-#
49-#######################################
50-
51-
52-/* An executable stack is *not* required for these functions. */
53-#ifdef __linux__
54-.section .note.GNU-stack,"",%progbits
55-.previous
56-#endif
57-
58- .globl __moddi3
59- .ent __moddi3
60-__moddi3:
61- .frame r1,0,r15
62-
63-#Change the stack pointer value and Save callee saved regs
64- addik r1,r1,-24
65- swi r25,r1,0
66- swi r26,r1,4
67- swi r27,r1,8 # used for sign
68- swi r28,r1,12 # used for loop count
69- swi r29,r1,16 # Used for div value High
70- swi r30,r1,20 # Used for div value Low
71-
72-#Check for Zero Value in the divisor/dividend
73- OR r9,r5,r6 # Check for the op1 being zero
74- BEQID r9,$LaResult_Is_Zero # Result is zero
75- OR r9,r7,r8 # Check for the dividend being zero
76- BEQI r9,$LaDiv_By_Zero # Div_by_Zero # Division Error
77- BGEId r5,$La1_Pos
78- XOR r27,r5,r7 # Get the sign of the result
79- RSUBI r6,r6,0 # Make dividend positive
80- RSUBIC r5,r5,0 # Make dividend positive
81-$La1_Pos:
82- BGEI r7,$La2_Pos
83- RSUBI r8,r8,0 # Make Divisor Positive
84- RSUBIC r9,r9,0 # Make Divisor Positive
85-$La2_Pos:
86- ADDIK r4,r0,0 # Clear mod low
87- ADDIK r3,r0,0 # Clear mod high
88- ADDIK r29,r0,0 # clear div high
89- ADDIK r30,r0,0 # clear div low
90- ADDIK r28,r0,64 # Initialize the loop count
91- # First part try to find the first '1' in the r5/r6
92-$LaDIV1:
93- ADD r6,r6,r6
94- ADDC r5,r5,r5 # left shift logical r5
95- BGEID r5,$LaDIV1
96- ADDIK r28,r28,-1
97-$LaDIV2:
98- ADD r6,r6,r6
99- ADDC r5,r5,r5 # left shift logical r5/r6 get the '1' into the Carry
100- ADDC r4,r4,r4 # Move that bit into the Mod register
101- ADDC r3,r3,r3 # Move carry into high mod register
102- rsub r18,r7,r3 # Compare the High Parts of Mod and Divisor
103- bnei r18,$L_High_EQ
104- rsub r18,r6,r4 # Compare Low Parts only if Mod[h] == Divisor[h]
105-$L_High_EQ:
106- rSUB r26,r8,r4 # Subtract divisor[L] from Mod[L]
107- rsubc r25,r7,r3 # Subtract divisor[H] from Mod[H]
108- BLTi r25,$LaMOD_TOO_SMALL
109- OR r3,r0,r25 # move r25 to mod [h]
110- OR r4,r0,r26 # move r26 to mod [l]
111- ADDI r30,r30,1
112- ADDC r29,r29,r0
113-$LaMOD_TOO_SMALL:
114- ADDIK r28,r28,-1
115- BEQi r28,$LaLOOP_END
116- ADD r30,r30,r30 # Shift in the '1' into div [low]
117- ADDC r29,r29,r29 # Move the carry generated into high
118- BRI $LaDIV2 # Div2
119-$LaLOOP_END:
120- BGEI r27,$LaRETURN_HERE
121- rsubi r30,r30,0
122- rsubc r29,r29,r0
123- BRI $LaRETURN_HERE
124-$LaDiv_By_Zero:
125-$LaResult_Is_Zero:
126- or r29,r0,r0 # set result to 0 [High]
127- or r30,r0,r0 # set result to 0 [Low]
128-$LaRETURN_HERE:
129-# Restore values of CSRs and that of r29 and the divisor and the dividend
130-
131- lwi r25,r1,0
132- lwi r26,r1,4
133- lwi r27,r1,8
134- lwi r28,r1,12
135- lwi r29,r1,16
136- lwi r30,r1,20
137- rtsd r15,8
138- addik r1,r1,24
139- .end __moddi3
140-
141diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
142index 96959f0292b..8d954a49575 100644
143--- a/libgcc/config/microblaze/t-microblaze
144+++ b/libgcc/config/microblaze/t-microblaze
145@@ -1,8 +1,7 @@
146-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _moddi3 _mulsi3 _udivsi3 _umodsi3
147+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
148
149 LIB2ADD += \
150 $(srcdir)/config/microblaze/divsi3.S \
151- $(srcdir)/config/microblaze/moddi3.S \
152 $(srcdir)/config/microblaze/modsi3.S \
153 $(srcdir)/config/microblaze/muldi3_hard.S \
154 $(srcdir)/config/microblaze/mulsi3.S \
155--
1562.17.1
157
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0014-Patch-microblaze-Add-INIT_PRIORITY-support.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0014-Patch-microblaze-Add-INIT_PRIORITY-support.patch
new file mode 100644
index 00000000..3bd6efd5
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0014-Patch-microblaze-Add-INIT_PRIORITY-support.patch
@@ -0,0 +1,101 @@
1From b9a9e8f9d0994c76819ec605a0b7cd113f3b2cf0 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 14:41:58 +0530
4Subject: [PATCH 14/54] [Patch, microblaze]: Add INIT_PRIORITY support Added
5 TARGET_ASM_CONSTRUCTOR and TARGET_ASM_DESTRUCTOR macros.
6
7These macros allows users to control the order of initialization
8of objects defined at namespace scope with the init_priority
9attribute by specifying a relative priority, a constant integral
10expression currently bounded between 101 and 65535 inclusive.
11
12Lower numbers indicate a higher priority.
13
14Changelog
15
162013-11-26 Nagaraju Mekala <nagaraju.mekala@xilinx.com>
17
18 * gcc/config/microblaze/microblaze.c: Add microblaze_asm_constructor,
19 microblaze_asm_destructor. Define TARGET_ASM_CONSTRUCTOR and
20 TARGET_ASM_DESTRUCTOR.
21
22Signed-off-by:nagaraju <nmekala@xilix.com>
23Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
24---
25 gcc/config/microblaze/microblaze.c | 53 ++++++++++++++++++++++++++++++
26 1 file changed, 53 insertions(+)
27
28diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
29index 0186171c04c..9eae5515c60 100644
30--- a/gcc/config/microblaze/microblaze.c
31+++ b/gcc/config/microblaze/microblaze.c
32@@ -2634,6 +2634,53 @@ print_operand_address (FILE * file, rtx addr)
33 }
34 }
35
36+/* Output an element in the table of global constructors. */
37+void
38+microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority)
39+{
40+ const char *section = ".ctors";
41+ char buf[16];
42+
43+ if (priority != DEFAULT_INIT_PRIORITY)
44+ {
45+ sprintf (buf, ".ctors.%.5u",
46+ /* Invert the numbering so the linker puts us in the proper
47+ order; constructors are run from right to left, and the
48+ linker sorts in increasing order. */
49+ MAX_INIT_PRIORITY - priority);
50+ section = buf;
51+ }
52+
53+ switch_to_section (get_section (section, 0, NULL));
54+ assemble_align (POINTER_SIZE);
55+ fputs ("\t.word\t", asm_out_file);
56+ output_addr_const (asm_out_file, symbol);
57+ fputs ("\n", asm_out_file);
58+}
59+
60+/* Output an element in the table of global destructors. */
61+void
62+microblaze_asm_destructor (rtx symbol, int priority)
63+{
64+ const char *section = ".dtors";
65+ char buf[16];
66+ if (priority != DEFAULT_INIT_PRIORITY)
67+ {
68+ sprintf (buf, ".dtors.%.5u",
69+ /* Invert the numbering so the linker puts us in the proper
70+ order; constructors are run from right to left, and the
71+ linker sorts in increasing order. */
72+ MAX_INIT_PRIORITY - priority);
73+ section = buf;
74+ }
75+
76+ switch_to_section (get_section (section, 0, NULL));
77+ assemble_align (POINTER_SIZE);
78+ fputs ("\t.word\t", asm_out_file);
79+ output_addr_const (asm_out_file, symbol);
80+ fputs ("\n", asm_out_file);
81+}
82+
83 /* Emit either a label, .comm, or .lcomm directive, and mark that the symbol
84 is used, so that we don't emit an .extern for it in
85 microblaze_asm_file_end. */
86@@ -3975,6 +4022,12 @@ microblaze_starting_frame_offset (void)
87 #undef TARGET_ATTRIBUTE_TABLE
88 #define TARGET_ATTRIBUTE_TABLE microblaze_attribute_table
89
90+#undef TARGET_ASM_CONSTRUCTOR
91+#define TARGET_ASM_CONSTRUCTOR microblaze_asm_constructor
92+
93+#undef TARGET_ASM_DESTRUCTOR
94+#define TARGET_ASM_DESTRUCTOR microblaze_asm_destructor
95+
96 #undef TARGET_IN_SMALL_DATA_P
97 #define TARGET_IN_SMALL_DATA_P microblaze_elf_in_small_data_p
98
99--
1002.17.1
101
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0015-Patch-microblaze-Add-optimized-lshrsi3.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0015-Patch-microblaze-Add-optimized-lshrsi3.patch
new file mode 100644
index 00000000..ba20cf07
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0015-Patch-microblaze-Add-optimized-lshrsi3.patch
@@ -0,0 +1,81 @@
1From f448485f5e0507a7ab8be7f83c08f807200a3501 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 15:23:57 +0530
4Subject: [PATCH 15/54] [Patch, microblaze]: Add optimized lshrsi3 When barrel
5 shifter is not present, the immediate value is greater than #5 and
6 optimization is -OS, the compiler will generate shift operation using loop.
7
8Changelog
9
102013-11-26 David Holsgrove <david.holsgrove@xilinx.com>
11
12 * gcc/config/microblaze/microblaze.md: Add size optimized lshrsi3 insn
13
14ChangeLog/testsuite
15
162014-02-12 David Holsgrove <david.holsgrove@xilinx.com>
17
18 * gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c: New test.
19
20Signed-off-by:Nagaraju <nmekala@xilix.com>
21Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
22---
23 gcc/config/microblaze/microblaze.md | 21 +++++++++++++++++++
24 .../microblaze/others/lshrsi_Os_1.c | 13 ++++++++++++
25 2 files changed, 34 insertions(+)
26 create mode 100644 gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c
27
28diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
29index 187ad522dcc..8f9baec826b 100644
30--- a/gcc/config/microblaze/microblaze.md
31+++ b/gcc/config/microblaze/microblaze.md
32@@ -1618,6 +1618,27 @@
33 (set_attr "length" "4,4")]
34 )
35
36+(define_insn "*lshrsi3_with_size_opt"
37+ [(set (match_operand:SI 0 "register_operand" "=&d")
38+ (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
39+ (match_operand:SI 2 "immediate_operand" "I")))]
40+ "(INTVAL (operands[2]) > 5 && optimize_size)"
41+ {
42+ operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
43+
44+ output_asm_insn ("ori\t%3,r0,%2", operands);
45+ if (REGNO (operands[0]) != REGNO (operands[1]))
46+ output_asm_insn ("addk\t%0,%1,r0", operands);
47+
48+ output_asm_insn ("addik\t%3,%3,-1", operands);
49+ output_asm_insn ("bneid\t%3,.-4", operands);
50+ return "srl\t%0,%0";
51+ }
52+ [(set_attr "type" "multi")
53+ (set_attr "mode" "SI")
54+ (set_attr "length" "20")]
55+)
56+
57 (define_insn "*lshrsi_inline"
58 [(set (match_operand:SI 0 "register_operand" "=&d")
59 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
60diff --git a/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c b/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c
61new file mode 100644
62index 00000000000..32a3be7c76a
63--- /dev/null
64+++ b/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c
65@@ -0,0 +1,13 @@
66+/* { dg-options "-Os -mno-xl-barrel-shift" } */
67+
68+void testfunc(void)
69+{
70+ unsigned volatile int z = 8192;
71+ z >>= 8;
72+}
73+/* { dg-final { scan-assembler-not "\bsrli" } } */
74+/* { dg-final { scan-assembler "\ori\tr18,r0" } } */
75+/* { dg-final { scan-assembler "addk\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0" } } */
76+/* { dg-final { scan-assembler "addik\tr18,r18,-1" } } */
77+/* { dg-final { scan-assembler "bneid\tr18,.-4" } } */
78+/* { dg-final { scan-assembler "\srl\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])" } } */
79--
802.17.1
81
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0016-Patch-microblaze-Add-cbranchsi4_reg.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0016-Patch-microblaze-Add-cbranchsi4_reg.patch
new file mode 100644
index 00000000..0c865224
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0016-Patch-microblaze-Add-cbranchsi4_reg.patch
@@ -0,0 +1,147 @@
1From 386b8dcef2d774e9138515814be0fd579ade5af5 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 17:04:37 +0530
4Subject: [PATCH 16/54] [Patch, microblaze]: Add cbranchsi4_reg This patch
5 optimizes the generation of pcmpne/pcmpeq instruction if the compare
6 instruction has no immediate values.For the immediate values the xor
7 instruction is generated
8
9Signed-off-by: Nagaraju Mekala <nmekala@xilix.com>
10Signed-off-by: Ajit Agarwal <ajitkum@xilinx.com>
11
12ChangeLog:
132015-01-13 Nagaraju Mekala <nmekala@xilix.com>
14 Ajit Agarwal <ajitkum@xilinx.com>
15
16 *microblaze.md (cbranchsi4_reg): New
17 *microblaze.c (microblaze_expand_conditional_branch_reg): New
18
19Conflicts:
20
21 gcc/config/microblaze/microblaze-protos.h
22---
23 gcc/config/microblaze/microblaze-protos.h | 2 +-
24 gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c | 2 +-
25 gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c | 2 +-
26 gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c | 2 +-
27 gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c | 2 +-
28 gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c | 14 +++++++-------
29 gcc/testsuite/gcc.target/microblaze/isa/vanilla.c | 12 ++++++------
30 7 files changed, 18 insertions(+), 18 deletions(-)
31
32diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
33index 982b2abd2d4..c2f88813a8d 100644
34--- a/gcc/config/microblaze/microblaze-protos.h
35+++ b/gcc/config/microblaze/microblaze-protos.h
36@@ -33,7 +33,7 @@ extern int microblaze_expand_shift (rtx *);
37 extern bool microblaze_expand_move (machine_mode, rtx *);
38 extern bool microblaze_expand_block_move (rtx, rtx, rtx, rtx);
39 extern void microblaze_expand_divide (rtx *);
40-extern void microblaze_expand_conditional_branch (machine_mode, rtx *);
41+extern void microblaze_expand_conditional_branch (enum machine_mode, rtx *);
42 extern void microblaze_expand_conditional_branch_reg (machine_mode, rtx *);
43 extern void microblaze_expand_conditional_branch_sf (rtx *);
44 extern int microblaze_can_use_return_insn (void);
45diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c
46index 4041a241391..ccc6a461cd9 100644
47--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c
48+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c
49@@ -6,5 +6,5 @@ void float_func ()
50 {
51 /* { dg-final { scan-assembler "fcmp\.(le|gt)\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
52 if (f2 <= f3)
53- print ("le");
54+ f2 = f3;
55 }
56diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c
57index 3902b839db9..1dd5fe6c539 100644
58--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c
59+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c
60@@ -6,5 +6,5 @@ void float_func ()
61 {
62 /* { dg-final { scan-assembler "fcmp\.(lt|ge)\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
63 if (f2 < f3)
64- print ("lt");
65+ f2 = f3;
66 }
67diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c
68index 8555974dda5..d6f80fb0ec3 100644
69--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c
70+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c
71@@ -6,5 +6,5 @@ void float_func ()
72 {
73 /* { dg-final { scan-assembler "fcmp\.(eq|ne)\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
74 if (f2 == f3)
75- print ("eq");
76+ f1 = f2 + f3;
77 }
78diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c
79index 79cc5f9dd8e..d1177249552 100644
80--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c
81+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c
82@@ -5,5 +5,5 @@ void float_func(float f1, float f2, float f3)
83 /* { dg-final { scan-assembler "fcmp\.eq\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
84 /* { dg-final { scan-assembler "fcmp\.le\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
85 if(f1==f2 && f1<=f3)
86- print ("f1 eq f2 && f1 le f3");
87+ f2 = f3;
88 }
89diff --git a/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c b/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c
90index ebfb170ecee..75822977ef8 100644
91--- a/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c
92+++ b/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c
93@@ -5,17 +5,17 @@ volatile float f1, f2, f3;
94 void float_func ()
95 {
96 /* { dg-final { scan-assembler-not "fcmp" } } */
97- if (f2 <= f3)
98- print ("le");
99+ if (f2 <= f3)
100+ f1 = f3;
101 else if (f2 == f3)
102- print ("eq");
103+ f1 = f3;
104 else if (f2 < f3)
105- print ("lt");
106+ f1 = f3;
107 else if (f2 > f3)
108- print ("gt");
109+ f1 = f3;
110 else if (f2 >= f3)
111- print ("ge");
112+ f1 = f3;
113 else if (f2 != f3)
114- print ("ne");
115+ f1 = f3;
116
117 }
118diff --git a/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c b/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c
119index 1d6ba807b12..532c035adfd 100644
120--- a/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c
121+++ b/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c
122@@ -74,16 +74,16 @@ void float_cmp_func ()
123 {
124 /* { dg-final { scan-assembler-not "fcmp" } } */
125 if (f2 <= f3)
126- print ("le");
127+ f1 = f3;
128 else if (f2 == f3)
129- print ("eq");
130+ f1 = f3;
131 else if (f2 < f3)
132- print ("lt");
133+ f1 = f3;
134 else if (f2 > f3)
135- print ("gt");
136+ f1 = f3;
137 else if (f2 >= f3)
138- print ("ge");
139+ f1 = f3;
140 else if (f2 != f3)
141- print ("ne");
142+ f1 = f3;
143
144 }
145--
1462.17.1
147
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch
new file mode 100644
index 00000000..504083f3
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch
@@ -0,0 +1,58 @@
1From b6298861681965533c9b6dac5e26fbd62b52839d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 17:11:04 +0530
4Subject: [PATCH 17/54] [Patch,microblaze]: Inline Expansion of fsqrt builtin.
5 The changes are made in the patch for the inline expansion of the fsqrt
6 builtin with fqrt instruction. The sqrt math function takes double as
7 argument and return double as argument. The pattern is selected while
8 expanding the unary op through expand_unop which passes DFmode and the DFmode
9 pattern was not there returning zero. Thus the sqrt math function is not
10 inlined and expanded. The pattern with DFmode argument is added. Also the
11 source and destination argument is not same the DF through two different
12 consecutive registers with lower 32 bit is the argument passed to sqrt and
13 the higher 32 bit is zero. If the source and destinations are different the
14 DFmode 64 bits registers is not set properly giving the problem in runtime.
15 Such changes are taken care in the implementation of the pattern for DFmode
16 for inline expansion of the sqrt.
17
18ChangeLog:
192015-06-16 Ajit Agarwal <ajitkum@xilinx.com>
20 Nagaraju Mekala <nmekala@xilinx.com>
21
22 * config/microblaze/microblaze.md (sqrtdf2): New
23 pattern.
24
25Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
26 Nagaraju Mekala nmekala@xilinx.com
27---
28 gcc/config/microblaze/microblaze.md | 14 ++++++++++++++
29 1 file changed, 14 insertions(+)
30
31diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
32index 8f9baec826b..986d9c3aa25 100644
33--- a/gcc/config/microblaze/microblaze.md
34+++ b/gcc/config/microblaze/microblaze.md
35@@ -451,6 +451,20 @@
36 (set_attr "mode" "SF")
37 (set_attr "length" "4")])
38
39+(define_insn "sqrtdf2"
40+ [(set (match_operand:DF 0 "register_operand" "=d")
41+ (sqrt:DF (match_operand:DF 1 "register_operand" "dG")))]
42+ "TARGET_HARD_FLOAT && TARGET_FLOAT_SQRT"
43+ {
44+ if (REGNO (operands[0]) == REGNO (operands[1]))
45+ return "fsqrt\t%0,%1";
46+ else
47+ return "fsqrt\t%0,%1\n\taddk\t%D0,%D1,r0";
48+ }
49+ [(set_attr "type" "fsqrt")
50+ (set_attr "mode" "SF")
51+ (set_attr "length" "4")])
52+
53 (define_insn "fix_truncsfsi2"
54 [(set (match_operand:SI 0 "register_operand" "=d")
55 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
56--
572.17.1
58
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch
new file mode 100644
index 00000000..14095d83
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch
@@ -0,0 +1,63 @@
1From a8c6c13cc322ecc300bb2cdf22e3d6f1680e56be Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 18:07:24 +0530
4Subject: [PATCH 18/54] [PATCH] microblaze.md: Improve 'adddi3' and 'subdi3'
5 insn definitions Change adddi3 to handle DI immediates as the second operand,
6 this requires modification to the output template however reduces the need to
7 specify seperate templates for 16-bit positive/negative immediate operands.
8 The use of 32-bit immediates for the addi and addic instructions is handled
9 by the assembler, which will emit the imm instructions when required. This
10 conveniently handles the optimizable cases where the immediate constant value
11 does not need the higher half words of the operands upper/lower words.
12
13Change the constraints of the subdi3 instruction definition such that it
14does not match the second operand as an immediate value. This is because
15there is no definition to handle this case nor is it possible to
16implement purely with instructions as microblaze does not provide an
17instruction to perform a forward arithmetic subtraction (it only
18provides reverse 'rD = IMM - rA').
19
20Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
21---
22 gcc/config/microblaze/microblaze.md | 13 ++++++-------
23 1 file changed, 6 insertions(+), 7 deletions(-)
24
25diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
26index 986d9c3aa25..efd2c34e0b7 100644
27--- a/gcc/config/microblaze/microblaze.md
28+++ b/gcc/config/microblaze/microblaze.md
29@@ -502,17 +502,16 @@
30 ;; Adding 2 DI operands in register or reg/imm
31
32 (define_insn "adddi3"
33- [(set (match_operand:DI 0 "register_operand" "=d,d,d")
34- (plus:DI (match_operand:DI 1 "register_operand" "%d,d,d")
35- (match_operand:DI 2 "arith_operand32" "d,P,N")))]
36+ [(set (match_operand:DI 0 "register_operand" "=d,d")
37+ (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
38+ (match_operand:DI 2 "arith_operand" "d,i")))]
39 ""
40 "@
41 add\t%L0,%L1,%L2\;addc\t%M0,%M1,%M2
42- addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0
43- addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0\;addi\t%M0,%M0,-1"
44+ addi\t%L0,%L1,%j2\;addic\t%M0,%M1,%h2"
45 [(set_attr "type" "darith")
46 (set_attr "mode" "DI")
47- (set_attr "length" "8,8,12")])
48+ (set_attr "length" "8,8")])
49
50 ;;----------------------------------------------------------------
51 ;; Subtraction
52@@ -549,7 +548,7 @@
53 (define_insn "subdi3"
54 [(set (match_operand:DI 0 "register_operand" "=&d")
55 (minus:DI (match_operand:DI 1 "register_operand" "d")
56- (match_operand:DI 2 "arith_operand32" "d")))]
57+ (match_operand:DI 2 "register_operand" "d")))]
58 ""
59 "rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1"
60 [(set_attr "type" "darith")
61--
622.17.1
63
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch
new file mode 100644
index 00000000..4a490119
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch
@@ -0,0 +1,72 @@
1From 3a9ee185eb462f880ceb4ddd125d4a98e0759873 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 18:18:41 +0530
4Subject: [PATCH 19/54] [Patch, microblaze]: Update ashlsi3 & movsf patterns
5 This patch removes the use of HOST_WIDE_INT_PRINT_HEX macro in print_operand
6 of ashlsi3_with_mul_nodelay,ashlsi3_with_mul_delay and movsf_internal
7 patterns beacuse HOST_WIDE_INT_PRINT_HEX is generating 64-bit value which our
8 instruction doesn't support so using gen_int_mode function
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 :Ajit Agarwal <ajitkum@xilinx.com>
12
13ChangeLog:
142016-01-07 Nagaraju Mekala <nmekala@xilix.com>
15 Ajit Agarwal <ajitkum@xilinx.com>
16
17 *microblaze.md (ashlsi3_with_mul_nodelay,
18 ashlsi3_with_mul_delay,
19 movsf_internal):
20 Updated the patterns to use gen_int_mode function
21 *microblaze.c (print_operand):
22 updated the 'F' case to use "unsinged int" instead
23 of HOST_WIDE_INT_PRINT_HEX
24---
25 gcc/config/microblaze/microblaze.c | 2 +-
26 gcc/config/microblaze/microblaze.md | 10 ++++++++--
27 2 files changed, 9 insertions(+), 3 deletions(-)
28
29diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
30index 9eae5515c60..0a4619eec0c 100644
31--- a/gcc/config/microblaze/microblaze.c
32+++ b/gcc/config/microblaze/microblaze.c
33@@ -2468,7 +2468,7 @@ print_operand (FILE * file, rtx op, int letter)
34 unsigned long value_long;
35 REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (op),
36 value_long);
37- fprintf (file, "0x%lx", value_long);
38+ fprintf (file, "0x%08x", (unsigned int) value_long);
39 }
40 else
41 {
42diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
43index efd2c34e0b7..be8bbda2bfb 100644
44--- a/gcc/config/microblaze/microblaze.md
45+++ b/gcc/config/microblaze/microblaze.md
46@@ -1368,7 +1368,10 @@
47 (match_operand:SI 2 "immediate_operand" "I")))]
48 "!TARGET_SOFT_MUL
49 && ((1 << INTVAL (operands[2])) <= 32767 && (1 << INTVAL (operands[2])) >= -32768)"
50- "muli\t%0,%1,%m2"
51+ {
52+ operands[2] = gen_int_mode (1 << INTVAL (operands[2]), SImode);
53+ return "muli\t%0,%1,%2";
54+ }
55 ;; This MUL will not generate an imm. Can go into a delay slot.
56 [(set_attr "type" "arith")
57 (set_attr "mode" "SI")
58@@ -1380,7 +1383,10 @@
59 (ashift:SI (match_operand:SI 1 "register_operand" "d")
60 (match_operand:SI 2 "immediate_operand" "I")))]
61 "!TARGET_SOFT_MUL"
62- "muli\t%0,%1,%m2"
63+ {
64+ operands[2] = gen_int_mode (1 << INTVAL (operands[2]), SImode);
65+ return "muli\t%0,%1,%2";
66+ }
67 ;; This MUL will generate an IMM. Cannot go into a delay slot
68 [(set_attr "type" "no_delay_arith")
69 (set_attr "mode" "SI")
70--
712.17.1
72
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch
new file mode 100644
index 00000000..07cf635d
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch
@@ -0,0 +1,178 @@
1From bfdb38133201f7df01d09dc7e7ee3043a35c1d3e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 9 Nov 2020 19:54:39 +0530
4Subject: [PATCH 20/54] [Patch, microblaze]: 8-stage pipeline for microblaze
5
6This patch adds the support for the 8-stage pipeline. The new 8-stage
7pipeline reduces the latencies of float & integer division drastically
8
9Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10---
11 gcc/config/microblaze/microblaze.c | 11 ++++
12 gcc/config/microblaze/microblaze.h | 3 +-
13 gcc/config/microblaze/microblaze.md | 79 +++++++++++++++++++++++++++-
14 gcc/config/microblaze/microblaze.opt | 4 ++
15 4 files changed, 94 insertions(+), 3 deletions(-)
16
17diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
18index 0a4619eec0c..0dc96e481b7 100644
19--- a/gcc/config/microblaze/microblaze.c
20+++ b/gcc/config/microblaze/microblaze.c
21@@ -1840,6 +1840,17 @@ microblaze_option_override (void)
22 "%<-mcpu=v8.30.a%>");
23 TARGET_REORDER = 0;
24 }
25+ ver = microblaze_version_to_int("v10.0");
26+ if (ver < 0)
27+ {
28+ if (TARGET_AREA_OPTIMIZED_2)
29+ warning (0, "-mxl-frequency can be used only with -mcpu=v10.0 or greater");
30+ }
31+ else
32+ {
33+ if (TARGET_AREA_OPTIMIZED_2)
34+ microblaze_pipe = MICROBLAZE_PIPE_8;
35+ }
36
37 if (TARGET_MULTIPLY_HIGH && TARGET_SOFT_MUL)
38 error ("%<-mxl-multiply-high%> requires %<-mno-xl-soft-mul%>");
39diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
40index 8aa3f155790..8a668278337 100644
41--- a/gcc/config/microblaze/microblaze.h
42+++ b/gcc/config/microblaze/microblaze.h
43@@ -27,7 +27,8 @@
44 enum pipeline_type
45 {
46 MICROBLAZE_PIPE_3 = 0,
47- MICROBLAZE_PIPE_5 = 1
48+ MICROBLAZE_PIPE_5 = 1,
49+ MICROBLAZE_PIPE_8 = 2
50 };
51
52 #define MICROBLAZE_MASK_NO_UNSAFE_DELAY 0x00000001
53diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
54index be8bbda2bfb..c407a81c51e 100644
55--- a/gcc/config/microblaze/microblaze.md
56+++ b/gcc/config/microblaze/microblaze.md
57@@ -35,6 +35,7 @@
58 (R_GOT 20) ;; GOT ptr reg
59 (MB_PIPE_3 0) ;; Microblaze 3-stage pipeline
60 (MB_PIPE_5 1) ;; Microblaze 5-stage pipeline
61+ (MB_PIPE_8 2) ;; Microblaze 8-stage pipeline
62 (UNSPEC_SET_GOT 101) ;;
63 (UNSPEC_GOTOFF 102) ;; GOT offset
64 (UNSPEC_PLT 103) ;; jump table
65@@ -82,7 +83,7 @@
66 ;; bshift Shift operations
67
68 (define_attr "type"
69- "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,trap"
70+ "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,fint,trap"
71 (const_string "unknown"))
72
73 ;; Main data type used by the insn
74@@ -224,6 +225,80 @@
75 ;;-----------------------------------------------------------------
76
77
78+
79+;;----------------------------------------------------------------
80+;; Microblaze 8-stage pipeline description (v10.0 and later)
81+;;----------------------------------------------------------------
82+
83+(define_automaton "mbpipe_8")
84+(define_cpu_unit "mb8_issue,mb8_iu,mb8_wb,mb8_fpu,mb8_fpu_2,mb8_mul,mb8_mul_2,mb8_div,mb8_div_2,mb8_bs,mb8_bs_2" "mbpipe_8")
85+
86+(define_insn_reservation "mb8-integer" 1
87+ (and (eq_attr "type" "branch,jump,call,arith,darith,icmp,nop,no_delay_arith")
88+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
89+ "mb8_issue,mb8_iu,mb8_wb")
90+
91+(define_insn_reservation "mb8-special-move" 2
92+ (and (eq_attr "type" "move")
93+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
94+ "mb8_issue,mb8_iu*2,mb8_wb")
95+
96+(define_insn_reservation "mb8-mem-load" 3
97+ (and (eq_attr "type" "load,no_delay_load")
98+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
99+ "mb8_issue,mb8_iu,mb8_wb")
100+
101+(define_insn_reservation "mb8-mem-store" 1
102+ (and (eq_attr "type" "store,no_delay_store")
103+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
104+ "mb8_issue,mb8_iu,mb8_wb")
105+
106+(define_insn_reservation "mb8-mul" 3
107+ (and (eq_attr "type" "imul,no_delay_imul")
108+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
109+ "mb8_issue,mb8_mul,mb8_mul_2*2,mb8_wb")
110+
111+(define_insn_reservation "mb8-div" 30
112+ (and (eq_attr "type" "idiv")
113+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
114+ "mb8_issue,mb8_div,mb8_div_2*29,mb8_wb")
115+
116+(define_insn_reservation "mb8-bs" 2
117+ (and (eq_attr "type" "bshift")
118+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
119+ "mb8_issue,mb8_bs,mb8_bs_2,mb8_wb")
120+
121+(define_insn_reservation "mb8-fpu-add-sub-mul" 1
122+ (and (eq_attr "type" "fadd,frsub,fmul")
123+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
124+ "mb8_issue,mb8_fpu,mb8_wb")
125+
126+(define_insn_reservation "mb8-fpu-fcmp" 3
127+ (and (eq_attr "type" "fcmp")
128+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
129+ "mb8_issue,mb8_fpu,mb8_fpu*2,mb8_wb")
130+
131+(define_insn_reservation "mb8-fpu-div" 24
132+ (and (eq_attr "type" "fdiv")
133+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
134+ "mb8_issue,mb8_fpu,mb8_fpu_2*23,mb8_wb")
135+
136+(define_insn_reservation "mb8-fpu-sqrt" 23
137+ (and (eq_attr "type" "fsqrt")
138+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
139+ "mb8_issue,mb8_fpu,mb8_fpu_2*22,mb8_wb")
140+
141+(define_insn_reservation "mb8-fpu-fcvt" 1
142+ (and (eq_attr "type" "fcvt")
143+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
144+ "mb8_issue,mb8_fpu,mb8_wb")
145+
146+(define_insn_reservation "mb8-fpu-fint" 2
147+ (and (eq_attr "type" "fint")
148+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
149+ "mb8_issue,mb8_fpu,mb8_wb")
150+
151+
152 ;;----------------------------------------------------------------
153 ;; Microblaze 5-stage pipeline description (v5.00.a and later)
154 ;;----------------------------------------------------------------
155@@ -470,7 +545,7 @@
156 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
157 "TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
158 "fint\t%0,%1"
159- [(set_attr "type" "fcvt")
160+ [(set_attr "type" "fint")
161 (set_attr "mode" "SF")
162 (set_attr "length" "4")])
163
164diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
165index 725c2fab52a..a29c6f8df90 100644
166--- a/gcc/config/microblaze/microblaze.opt
167+++ b/gcc/config/microblaze/microblaze.opt
168@@ -133,3 +133,7 @@ Data referenced by offset from start of text instead of GOT (with -fPIC/-fPIE).
169
170 mxl-mode-xilkernel
171 Target
172+
173+mxl-frequency
174+Target Mask(AREA_OPTIMIZED_2)
175+Use 8 stage pipeline (frequency optimization)
176--
1772.17.1
178
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0021-Patch-microblaze-Correct-the-const-high-double-immed.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0021-Patch-microblaze-Correct-the-const-high-double-immed.patch
new file mode 100644
index 00000000..f362cea8
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0021-Patch-microblaze-Correct-the-const-high-double-immed.patch
@@ -0,0 +1,58 @@
1From af01da22797795408d45dcf03076dc8153c7029e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 9 Nov 2020 21:14:54 +0530
4Subject: [PATCH 21/54] [Patch, microblaze]: Correct the const high double
5 immediate value with this patch the loading of the DI mode immediate values
6 will be using REAL_VALUE_FROM_CONST_DOUBLE and REAL_VALUE_TO_TARGET_DOUBLE
7 functions, as CONST_DOUBLE_HIGH was returning the sign extension value even
8 of the unsigned long long constants also
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 Ajit Agarwal <ajitkum@xilinx.com>
12---
13 gcc/config/microblaze/microblaze.c | 6 ++++--
14 gcc/testsuite/gcc.target/microblaze/others/long.c | 9 +++++++++
15 2 files changed, 13 insertions(+), 2 deletions(-)
16 create mode 100644 gcc/testsuite/gcc.target/microblaze/others/long.c
17
18diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
19index 0dc96e481b7..5d395f047f7 100644
20--- a/gcc/config/microblaze/microblaze.c
21+++ b/gcc/config/microblaze/microblaze.c
22@@ -2452,14 +2452,16 @@ print_operand (FILE * file, rtx op, int letter)
23 else if (letter == 'h' || letter == 'j')
24 {
25 long val[2];
26+ long l[2];
27 if (code == CONST_DOUBLE)
28 {
29 if (GET_MODE (op) == DFmode)
30 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
31 else
32 {
33- val[0] = CONST_DOUBLE_HIGH (op);
34- val[1] = CONST_DOUBLE_LOW (op);
35+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
36+ val[1] = l[WORDS_BIG_ENDIAN == 0];
37+ val[0] = l[WORDS_BIG_ENDIAN != 0];
38 }
39 }
40 else if (code == CONST_INT)
41diff --git a/gcc/testsuite/gcc.target/microblaze/others/long.c b/gcc/testsuite/gcc.target/microblaze/others/long.c
42new file mode 100644
43index 00000000000..b6b55d5ad65
44--- /dev/null
45+++ b/gcc/testsuite/gcc.target/microblaze/others/long.c
46@@ -0,0 +1,9 @@
47+#define BASEADDR 0xF0000000ULL
48+int main ()
49+{
50+ unsigned long long start;
51+ start = (unsigned long long) BASEADDR;
52+ return 0;
53+}
54+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0x00000000" } } */
55+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0xf0000000" } } */
56--
572.17.1
58
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch
new file mode 100644
index 00000000..3faef052
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch
@@ -0,0 +1,36 @@
1From 7349def8102c09fd09e735daa9fc890bee323e79 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 11:49:58 +0530
4Subject: [PATCH 22/54] [Fix, microblaze]: Fix internal compiler error with
5 msmall-divides This patch will fix the internal error
6 microblaze_expand_divide function which comes because of rtx PLUS where the
7 mem_rtx is of type SI and the operand is of type QImode. This patch modifies
8 the mem_rtx as QImode and Plus as QImode to fix the error.
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 Ajit Agarwal <ajitkum@xilinx.com>
12ChangeLog:
13 2016-02-23 Nagaraju Mekala <nmekala@xilix.com>
14 Ajit Agarwal <ajitkum@xilinx.com>
15
16 *microblaze.c (microblaze_expand_divide): Update
17---
18 gcc/config/microblaze/microblaze.c | 2 +-
19 1 file changed, 1 insertion(+), 1 deletion(-)
20
21diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
22index 5d395f047f7..29b2f6b016b 100644
23--- a/gcc/config/microblaze/microblaze.c
24+++ b/gcc/config/microblaze/microblaze.c
25@@ -3767,7 +3767,7 @@ microblaze_expand_divide (rtx operands[])
26 emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
27 emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
28 mem_rtx = gen_rtx_MEM (QImode,
29- gen_rtx_PLUS (Pmode, regt1, div_table_rtx));
30+ gen_rtx_PLUS (QImode, regt1, div_table_rtx));
31
32 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
33 jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
34--
352.17.1
36
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch
new file mode 100644
index 00000000..1c4f8ca9
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch
@@ -0,0 +1,45 @@
1From ad3d0a29a4895351008ce959138c13b8f5924464 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 12:03:39 +0530
4Subject: [PATCH 23/54] [patch,microblaze]: Fix the calculation of high word in
5 a long long 6. .4-bit
6
7This patch will change the calculation of high word in a long long 64-bit.
8Earlier to this patch the high word of long long word (0xF0000000ULL) is
9coming to be 0xFFFFFFFF and low word is 0xF0000000. Instead the high word
10should be 0x00000000 and the low word should be 0xF0000000. This patch
11removes the condition of checking high word = 0 & low word < 0.
12This check is not required for the correctness of calculating 32-bit high
13and low words in a 64-bit long long.
14
15Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
16 Ajit Agarwal <ajitkum@xilinx.com>
17
18ChangeLog:
192016-03-01 Nagaraju Mekala <nmekala@xilix.com>
20 Ajit Agarwal <ajitkum@xilinx.com>
21
22 *config/microblaze/microblaze.c (print_operand): Remove the condition of checking
23 high word = 0 & low word < 0.
24 *testsuite/gcc.target/microblaze/others/long.c: Add -O0 option.
25---
26 gcc/config/microblaze/microblaze.c | 3 ---
27 1 file changed, 3 deletions(-)
28
29diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
30index 29b2f6b016b..4710def18cf 100644
31--- a/gcc/config/microblaze/microblaze.c
32+++ b/gcc/config/microblaze/microblaze.c
33@@ -2468,9 +2468,6 @@ print_operand (FILE * file, rtx op, int letter)
34 {
35 val[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
36 val[1] = INTVAL (op) & 0x00000000ffffffffLL;
37- if (val[0] == 0 && val[1] < 0)
38- val[0] = -1;
39-
40 }
41 fprintf (file, "0x%8.8lx", (letter == 'h') ? val[0] : val[1]);
42 }
43--
442.17.1
45
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0024-Patch-microblaze-Add-new-bit-field-instructions.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0024-Patch-microblaze-Add-new-bit-field-instructions.patch
new file mode 100644
index 00000000..590cb38c
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0024-Patch-microblaze-Add-new-bit-field-instructions.patch
@@ -0,0 +1,162 @@
1From 50f5f8341ba39f2e12eef4a149e59f71f032f7d3 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 10 Nov 2020 09:51:24 +0530
4Subject: [PATCH 24/54] [Patch, microblaze]: Add new bit-field instructions
5
6This patches adds new bsefi and bsifi instructions.
7BSEFI- The instruction shall extract a bit field from a
8register and place it right-adjusted in the destination register.
9The other bits in the destination register shall be set to zero
10BSIFI- The instruction shall insert a right-adjusted bit field
11from a register at another position in the destination register.
12The rest of the bits in the destination register shall be unchanged
13
14Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
15---
16 gcc/config/microblaze/microblaze.c | 5 ++
17 gcc/config/microblaze/microblaze.h | 2 +
18 gcc/config/microblaze/microblaze.md | 73 +++++++++++++++++++++++++++++
19 3 files changed, 80 insertions(+)
20
21diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
22index 4710def18cf..14c652325a8 100644
23--- a/gcc/config/microblaze/microblaze.c
24+++ b/gcc/config/microblaze/microblaze.c
25@@ -164,6 +164,9 @@ int microblaze_no_unsafe_delay;
26 /* Set to one if the targeted core has the CLZ insn. */
27 int microblaze_has_clz = 0;
28
29+/* Set to one if the targeted core has barrel-shift and cpu > 10.0 */
30+int microblaze_has_bitfield = 0;
31+
32 /* Which CPU pipeline do we use. We haven't really standardized on a CPU
33 version having only a particular type of pipeline. There can still be
34 options on the CPU to scale pipeline features up or down. :(
35@@ -1850,6 +1853,8 @@ microblaze_option_override (void)
36 {
37 if (TARGET_AREA_OPTIMIZED_2)
38 microblaze_pipe = MICROBLAZE_PIPE_8;
39+ if (TARGET_BARREL_SHIFT)
40+ microblaze_has_bitfield = 1;
41 }
42
43 if (TARGET_MULTIPLY_HIGH && TARGET_SOFT_MUL)
44diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
45index 8a668278337..857cb1cd9d0 100644
46--- a/gcc/config/microblaze/microblaze.h
47+++ b/gcc/config/microblaze/microblaze.h
48@@ -44,6 +44,7 @@ extern int microblaze_dbx_regno[];
49
50 extern int microblaze_no_unsafe_delay;
51 extern int microblaze_has_clz;
52+extern int microblaze_has_bitfield;
53 extern enum pipeline_type microblaze_pipe;
54
55 #define OBJECT_FORMAT_ELF
56@@ -63,6 +64,7 @@ extern enum pipeline_type microblaze_pipe;
57 /* Do we have CLZ? */
58 #define TARGET_HAS_CLZ (TARGET_PATTERN_COMPARE && microblaze_has_clz)
59
60+#define TARGET_HAS_BITFIELD (TARGET_BARREL_SHIFT && microblaze_has_bitfield)
61 /* The default is to support PIC. */
62 #define TARGET_SUPPORTS_PIC 1
63
64diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
65index c407a81c51e..3e6e2b9276d 100644
66--- a/gcc/config/microblaze/microblaze.md
67+++ b/gcc/config/microblaze/microblaze.md
68@@ -982,6 +982,8 @@
69 (set_attr "mode" "DI")
70 (set_attr "length" "20,20,20")])
71
72+
73+
74 ;;----------------------------------------------------------------
75 ;; Data movement
76 ;;----------------------------------------------------------------
77@@ -1776,6 +1778,7 @@
78 (set_attr "length" "28")]
79 )
80
81+
82 ;;----------------------------------------------------------------
83 ;; Setting a register from an integer comparison.
84 ;;----------------------------------------------------------------
85@@ -2489,4 +2492,74 @@
86 DONE;
87 }")
88
89+(define_expand "extvsi"
90+ [(set (match_operand:SI 0 "register_operand" "r")
91+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
92+ (match_operand:SI 2 "immediate_operand" "I")
93+ (match_operand:SI 3 "immediate_operand" "I")))]
94+""
95+"
96+{
97+ unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
98+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
99+
100+ if ((len == 0) || (pos + len > 32) )
101+ FAIL;
102+
103+ ;;if (!register_operand (operands[1], VOIDmode))
104+ ;; FAIL;
105+ if (operands[0] == operands[1])
106+ FAIL;
107+ if (GET_CODE (operands[1]) == ASHIFT)
108+ FAIL;
109+;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
110+ emit_insn (gen_extv_32 (operands[0], operands[1],
111+ operands[2], operands[3]));
112+ DONE;
113+}")
114+
115+(define_insn "extv_32"
116+ [(set (match_operand:SI 0 "register_operand" "=r")
117+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
118+ (match_operand:SI 2 "immediate_operand" "I")
119+ (match_operand:SI 3 "immediate_operand" "I")))]
120+ "TARGET_BARREL_SHIFT && (UINTVAL (operands[2]) > 0)
121+ && ((UINTVAL (operands[2]) + UINTVAL (operands[3])) <= 32)"
122+ "bsefi %0,%1,%2,%3"
123+ [(set_attr "type" "bshift")
124+ (set_attr "length" "4")])
125+
126+(define_expand "insvsi"
127+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
128+ (match_operand:SI 1 "immediate_operand" "I")
129+ (match_operand:SI 2 "immediate_operand" "I"))
130+ (match_operand:SI 3 "register_operand" "r"))]
131+ ""
132+ "
133+{
134+ unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
135+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
136+
137+ if (len <= 0 || pos + len > 32)
138+ FAIL;
139+
140+ ;;if (!register_operand (operands[0], VOIDmode))
141+ ;; FAIL;
142+
143+ emit_insn (gen_insv_32 (operands[0], operands[1],
144+ operands[2], operands[3]));
145+ DONE;
146+}")
147+
148+(define_insn "insv_32"
149+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
150+ (match_operand:SI 1 "immediate_operand" "I")
151+ (match_operand:SI 2 "immediate_operand" "I"))
152+ (match_operand:SI 3 "register_operand" "r"))]
153+ "TARGET_BARREL_SHIFT && UINTVAL (operands[1]) > 0
154+ && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
155+ "bsifi %0, %3, %1, %2"
156+ [(set_attr "type" "bshift")
157+ (set_attr "length" "4")])
158+
159 (include "sync.md")
160--
1612.17.1
162
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0025-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0025-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch
new file mode 100644
index 00000000..da24f113
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0025-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch
@@ -0,0 +1,247 @@
1From cb67b2e64c0d5bd32d36cb32def5f889122fc37a Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 12:42:10 +0530
4Subject: [PATCH 25/54] [Patch, microblaze]: Fix bug in MB version calculation
5 This patch fixes the bug in microblaze_version_to_int function. Earlier the
6 conversion of vXX.YY.Z to int has a bug which is fixed now.
7
8Signed-off-by : Mahesh Bodapati <mbodapat@xilinx.com>
9 Nagaraju Mekala <nmekala@xilix.com>
10---
11 gcc/config/microblaze/microblaze.c | 147 ++++++++++++++---------------
12 1 file changed, 70 insertions(+), 77 deletions(-)
13
14diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
15index 14c652325a8..451db9c79b0 100644
16--- a/gcc/config/microblaze/microblaze.c
17+++ b/gcc/config/microblaze/microblaze.c
18@@ -242,6 +242,63 @@ section *sdata2_section;
19 #define TARGET_HAVE_TLS true
20 #endif
21
22+/* Convert a version number of the form "vX.YY.Z" to an integer encoding
23+ for easier range comparison. */
24+static int
25+microblaze_version_to_int (const char *version)
26+{
27+ const char *p, *v;
28+ const char *tmpl = "vXX.YY.Z";
29+ int iver1 =0, iver2 =0, iver3 =0;
30+
31+ p = version;
32+ v = tmpl;
33+
34+ while (*p)
35+ {
36+ if (*v == 'X')
37+ { /* Looking for major */
38+ if (*p == '.')
39+ {
40+ *v++;
41+ }
42+ else
43+ {
44+ if (!(*p >= '0' && *p <= '9'))
45+ return -1;
46+ iver1 += (int) (*p - '0');
47+ iver1 *= 1000;
48+ }
49+ }
50+ else if (*v == 'Y')
51+ { /* Looking for minor */
52+ if (!(*p >= '0' && *p <= '9'))
53+ return -1;
54+ iver2 += (int) (*p - '0');
55+ iver2 *= 10;
56+ }
57+ else if (*v == 'Z')
58+ { /* Looking for compat */
59+ if (!(*p >= 'a' && *p <= 'z'))
60+ return -1;
61+ iver3 = ((int) (*p)) - 96;
62+ }
63+ else
64+ {
65+ if (*p != *v)
66+ return -1;
67+ }
68+
69+ v++;
70+ p++;
71+ }
72+
73+ if (*p)
74+ return -1;
75+
76+ return iver1 + iver2 + iver3;
77+}
78+
79 /* Return truth value if a CONST_DOUBLE is ok to be a legitimate constant. */
80 static bool
81 microblaze_const_double_ok (rtx op, machine_mode mode)
82@@ -1341,8 +1398,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
83 {
84 if (TARGET_BARREL_SHIFT)
85 {
86- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
87- >= 0)
88+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
89 *total = COSTS_N_INSNS (1);
90 else
91 *total = COSTS_N_INSNS (2);
92@@ -1403,8 +1459,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
93 }
94 else if (!TARGET_SOFT_MUL)
95 {
96- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
97- >= 0)
98+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
99 *total = COSTS_N_INSNS (1);
100 else
101 *total = COSTS_N_INSNS (3);
102@@ -1677,72 +1732,13 @@ function_arg_partial_bytes (cumulative_args_t cum_v,
103 return 0;
104 }
105
106-/* Convert a version number of the form "vX.YY.Z" to an integer encoding
107- for easier range comparison. */
108-static int
109-microblaze_version_to_int (const char *version)
110-{
111- const char *p, *v;
112- const char *tmpl = "vXX.YY.Z";
113- int iver = 0;
114-
115- p = version;
116- v = tmpl;
117-
118- while (*p)
119- {
120- if (*v == 'X')
121- { /* Looking for major */
122- if (*p == '.')
123- {
124- v++;
125- }
126- else
127- {
128- if (!(*p >= '0' && *p <= '9'))
129- return -1;
130- iver += (int) (*p - '0');
131- iver *= 10;
132- }
133- }
134- else if (*v == 'Y')
135- { /* Looking for minor */
136- if (!(*p >= '0' && *p <= '9'))
137- return -1;
138- iver += (int) (*p - '0');
139- iver *= 10;
140- }
141- else if (*v == 'Z')
142- { /* Looking for compat */
143- if (!(*p >= 'a' && *p <= 'z'))
144- return -1;
145- iver *= 10;
146- iver += (int) (*p - 'a');
147- }
148- else
149- {
150- if (*p != *v)
151- return -1;
152- }
153-
154- v++;
155- p++;
156- }
157-
158- if (*p)
159- return -1;
160-
161- return iver;
162-}
163-
164-
165 static void
166 microblaze_option_override (void)
167 {
168 register int i, start;
169 register int regno;
170 register machine_mode mode;
171- int ver;
172+ int ver,ver_int;
173
174 microblaze_section_threshold = (global_options_set.x_g_switch_value
175 ? g_switch_value
176@@ -1763,13 +1759,13 @@ microblaze_option_override (void)
177 /* Check the MicroBlaze CPU version for any special action to be done. */
178 if (microblaze_select_cpu == NULL)
179 microblaze_select_cpu = MICROBLAZE_DEFAULT_CPU;
180- ver = microblaze_version_to_int (microblaze_select_cpu);
181- if (ver == -1)
182+ ver_int = microblaze_version_to_int (microblaze_select_cpu);
183+ if (ver_int == -1)
184 {
185 error ("%qs is an invalid argument to %<-mcpu=%>", microblaze_select_cpu);
186 }
187
188- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v3.00.a");
189+ ver = ver_int - microblaze_version_to_int("v3.00.a");
190 if (ver < 0)
191 {
192 /* No hardware exceptions in earlier versions. So no worries. */
193@@ -1780,8 +1776,7 @@ microblaze_option_override (void)
194 microblaze_pipe = MICROBLAZE_PIPE_3;
195 }
196 else if (ver == 0
197- || (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v4.00.b")
198- == 0))
199+ || (ver_int == microblaze_version_to_int("v4.00.b")))
200 {
201 #if 0
202 microblaze_select_flags |= (MICROBLAZE_MASK_NO_UNSAFE_DELAY);
203@@ -1798,11 +1793,9 @@ microblaze_option_override (void)
204 #endif
205 microblaze_no_unsafe_delay = 0;
206 microblaze_pipe = MICROBLAZE_PIPE_5;
207- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a") == 0
208- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
209- "v5.00.b") == 0
210- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
211- "v5.00.c") == 0)
212+ if ((ver_int == microblaze_version_to_int("v5.00.a"))
213+ || (ver_int == microblaze_version_to_int("v5.00.b"))
214+ || (ver_int == microblaze_version_to_int("v5.00.c")))
215 {
216 /* Pattern compares are to be turned on by default only when
217 compiling for MB v5.00.'z'. */
218@@ -1810,7 +1803,7 @@ microblaze_option_override (void)
219 }
220 }
221
222- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v6.00.a");
223+ ver = ver_int - microblaze_version_to_int("v6.00.a");
224 if (ver < 0)
225 {
226 if (TARGET_MULTIPLY_HIGH)
227@@ -1819,7 +1812,7 @@ microblaze_option_override (void)
228 "%<-mcpu=v6.00.a%> or greater");
229 }
230
231- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.10.a");
232+ ver = ver_int - microblaze_version_to_int("v8.10.a");
233 microblaze_has_clz = 1;
234 if (ver < 0)
235 {
236@@ -1828,7 +1821,7 @@ microblaze_option_override (void)
237 }
238
239 /* TARGET_REORDER defaults to 2 if -mxl-reorder not specified. */
240- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.30.a");
241+ ver = ver_int - microblaze_version_to_int("v8.30.a");
242 if (ver < 0)
243 {
244 if (TARGET_REORDER == 1)
245--
2462.17.1
247
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0026-Fixing-the-issue-with-the-builtin_alloc.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0026-Fixing-the-issue-with-the-builtin_alloc.patch
new file mode 100644
index 00000000..c0719f6e
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0026-Fixing-the-issue-with-the-builtin_alloc.patch
@@ -0,0 +1,44 @@
1From fdb2f23a69182da516c7bf89a9e0011e55120f94 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 23 Feb 2017 17:09:04 +0530
4Subject: [PATCH 26/54] Fixing the issue with the builtin_alloc. register r18
5 was not properly handling the stack pattern which was resolved by using free
6 available register
7
8signed-off-by:nagaraju mekala <nmekala@xilinx.com>
9---
10 gcc/config/microblaze/microblaze.md | 8 ++++----
11 1 file changed, 4 insertions(+), 4 deletions(-)
12
13diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
14index 3e6e2b9276d..d938efcd762 100644
15--- a/gcc/config/microblaze/microblaze.md
16+++ b/gcc/config/microblaze/microblaze.md
17@@ -2078,10 +2078,10 @@
18 ""
19 {
20 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
21- rtx rtmp = gen_rtx_REG (SImode, R_TMP);
22+ rtx reg = gen_reg_rtx (Pmode);
23 rtx neg_op0;
24
25- emit_move_insn (rtmp, retaddr);
26+ emit_move_insn (reg, retaddr);
27 if (GET_CODE (operands[1]) != CONST_INT)
28 {
29 neg_op0 = gen_reg_rtx (Pmode);
30@@ -2090,9 +2090,9 @@
31 neg_op0 = GEN_INT (- INTVAL (operands[1]));
32
33 emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
34- emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), rtmp);
35+ emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), reg);
36 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
37- emit_insn (gen_rtx_CLOBBER (SImode, rtmp));
38+ emit_insn (gen_rtx_CLOBBER (SImode, reg));
39 DONE;
40 }
41 )
42--
432.17.1
44
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0027-Patch-Microblaze-update-in-constraints-for-bitfield-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0027-Patch-Microblaze-update-in-constraints-for-bitfield-.patch
new file mode 100644
index 00000000..7627b765
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0027-Patch-Microblaze-update-in-constraints-for-bitfield-.patch
@@ -0,0 +1,84 @@
1From 336d984c580345eccdeb889af8ef8c986afc1dad Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 19 Feb 2018 18:06:16 +0530
4Subject: [PATCH 27/54] [Patch,Microblaze]: update in constraints for bitfield
5 insert and extract instructions.
6
7Conflicts:
8 gcc/config/microblaze/microblaze.md
9---
10 gcc/config/microblaze/microblaze.md | 45 +++++------------------------
11 1 file changed, 8 insertions(+), 37 deletions(-)
12
13diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
14index d938efcd762..63ad94b972f 100644
15--- a/gcc/config/microblaze/microblaze.md
16+++ b/gcc/config/microblaze/microblaze.md
17@@ -2492,33 +2492,17 @@
18 DONE;
19 }")
20
21-(define_expand "extvsi"
22+(define_expand "extzvsi"
23 [(set (match_operand:SI 0 "register_operand" "r")
24 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
25 (match_operand:SI 2 "immediate_operand" "I")
26 (match_operand:SI 3 "immediate_operand" "I")))]
27+"TARGET_HAS_BITFIELD"
28 ""
29-"
30-{
31- unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
32- unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
33-
34- if ((len == 0) || (pos + len > 32) )
35- FAIL;
36-
37- ;;if (!register_operand (operands[1], VOIDmode))
38- ;; FAIL;
39- if (operands[0] == operands[1])
40- FAIL;
41- if (GET_CODE (operands[1]) == ASHIFT)
42- FAIL;
43-;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
44- emit_insn (gen_extv_32 (operands[0], operands[1],
45- operands[2], operands[3]));
46- DONE;
47-}")
48+)
49
50-(define_insn "extv_32"
51+
52+(define_insn "extzv_32"
53 [(set (match_operand:SI 0 "register_operand" "=r")
54 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
55 (match_operand:SI 2 "immediate_operand" "I")
56@@ -2534,22 +2518,9 @@
57 (match_operand:SI 1 "immediate_operand" "I")
58 (match_operand:SI 2 "immediate_operand" "I"))
59 (match_operand:SI 3 "register_operand" "r"))]
60- ""
61- "
62-{
63- unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
64- unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
65-
66- if (len <= 0 || pos + len > 32)
67- FAIL;
68-
69- ;;if (!register_operand (operands[0], VOIDmode))
70- ;; FAIL;
71-
72- emit_insn (gen_insv_32 (operands[0], operands[1],
73- operands[2], operands[3]));
74- DONE;
75-}")
76+ "TARGET_HAS_BITFIELD"
77+""
78+)
79
80 (define_insn "insv_32"
81 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
82--
832.17.1
84
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0028-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0028-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch
new file mode 100644
index 00000000..f12cea24
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0028-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch
@@ -0,0 +1,38 @@
1From e4f5435e6e77afe0150bf36ec9d3d055cf25a089 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 4 Jun 2018 10:10:18 +0530
4Subject: [PATCH 28/54] [Patch,Microblaze] : Removed fsqrt generation for
5 double values.
6
7---
8 gcc/config/microblaze/microblaze.md | 14 --------------
9 1 file changed, 14 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index 63ad94b972f..7695b105baa 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -526,20 +526,6 @@
16 (set_attr "mode" "SF")
17 (set_attr "length" "4")])
18
19-(define_insn "sqrtdf2"
20- [(set (match_operand:DF 0 "register_operand" "=d")
21- (sqrt:DF (match_operand:DF 1 "register_operand" "dG")))]
22- "TARGET_HARD_FLOAT && TARGET_FLOAT_SQRT"
23- {
24- if (REGNO (operands[0]) == REGNO (operands[1]))
25- return "fsqrt\t%0,%1";
26- else
27- return "fsqrt\t%0,%1\n\taddk\t%D0,%D1,r0";
28- }
29- [(set_attr "type" "fsqrt")
30- (set_attr "mode" "SF")
31- (set_attr "length" "4")])
32-
33 (define_insn "fix_truncsfsi2"
34 [(set (match_operand:SI 0 "register_operand" "=d")
35 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
36--
372.17.1
38
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0029-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0029-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch
new file mode 100644
index 00000000..d9603721
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0029-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch
@@ -0,0 +1,845 @@
1From 1a7fda96cb247bad0a4df61cd8fd3e65c0e6f35d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 10 Nov 2020 12:52:54 +0530
4Subject: [PATCH 29/54] [Patch,MicroBlaze]: Intial commit of 64-bit Microblaze
5
6---
7 gcc/config/microblaze/constraints.md | 6 +
8 gcc/config/microblaze/microblaze-protos.h | 1 +
9 gcc/config/microblaze/microblaze.c | 109 ++++--
10 gcc/config/microblaze/microblaze.h | 4 +-
11 gcc/config/microblaze/microblaze.md | 395 +++++++++++++++++++++-
12 gcc/config/microblaze/microblaze.opt | 7 +-
13 gcc/config/microblaze/t-microblaze | 7 +-
14 7 files changed, 492 insertions(+), 37 deletions(-)
15
16diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
17index b9fc6e3fae2..123395717e0 100644
18--- a/gcc/config/microblaze/constraints.md
19+++ b/gcc/config/microblaze/constraints.md
20@@ -52,6 +52,12 @@
21 (and (match_code "const_int")
22 (match_test "ival > 0 && ival < 0x10000")))
23
24+(define_constraint "K"
25+ "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
26+ (and (match_code "const_int")
27+ (match_test "ival > (long)0xffffff8000000000L && ival < (long)0x0000007fffffffffL")))
28+
29+
30 ;; Define floating point constraints
31
32 (define_constraint "G"
33diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
34index c2f88813a8d..460feac4ac5 100644
35--- a/gcc/config/microblaze/microblaze-protos.h
36+++ b/gcc/config/microblaze/microblaze-protos.h
37@@ -36,6 +36,7 @@ extern void microblaze_expand_divide (rtx *);
38 extern void microblaze_expand_conditional_branch (enum machine_mode, rtx *);
39 extern void microblaze_expand_conditional_branch_reg (machine_mode, rtx *);
40 extern void microblaze_expand_conditional_branch_sf (rtx *);
41+extern void microblaze_expand_conditional_branch_df (rtx *);
42 extern int microblaze_can_use_return_insn (void);
43 extern void print_operand (FILE *, rtx, int);
44 extern void print_operand_address (FILE *, rtx);
45diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
46index 451db9c79b0..99a1cd5c0be 100644
47--- a/gcc/config/microblaze/microblaze.c
48+++ b/gcc/config/microblaze/microblaze.c
49@@ -3432,11 +3432,11 @@ microblaze_expand_move (machine_mode mode, rtx operands[])
50 op0 = operands[0];
51 op1 = operands[1];
52
53- if (!register_operand (op0, SImode)
54- && !register_operand (op1, SImode)
55+ if (!register_operand (op0, mode)
56+ && !register_operand (op1, mode)
57 && (GET_CODE (op1) != CONST_INT || INTVAL (op1) != 0))
58 {
59- rtx temp = force_reg (SImode, op1);
60+ rtx temp = force_reg (mode, op1);
61 emit_move_insn (op0, temp);
62 return true;
63 }
64@@ -3501,12 +3501,12 @@ microblaze_expand_move (machine_mode mode, rtx operands[])
65 && (flag_pic == 2 || microblaze_tls_symbol_p (p0)
66 || !SMALL_INT (p1)))))
67 {
68- rtx temp = force_reg (SImode, p0);
69+ rtx temp = force_reg (mode, p0);
70 rtx temp2 = p1;
71
72 if (flag_pic && reload_in_progress)
73 df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
74- emit_move_insn (op0, gen_rtx_PLUS (SImode, temp, temp2));
75+ emit_move_insn (op0, gen_rtx_PLUS (mode, temp, temp2));
76 return true;
77 }
78 }
79@@ -3637,7 +3637,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
80 rtx cmp_op0 = operands[1];
81 rtx cmp_op1 = operands[2];
82 rtx label1 = operands[3];
83- rtx comp_reg = gen_reg_rtx (SImode);
84+ rtx comp_reg = gen_reg_rtx (mode);
85 rtx condition;
86
87 gcc_assert ((GET_CODE (cmp_op0) == REG) || (GET_CODE (cmp_op0) == SUBREG));
88@@ -3646,23 +3646,36 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
89 if (cmp_op1 == const0_rtx)
90 {
91 comp_reg = cmp_op0;
92- condition = gen_rtx_fmt_ee (signed_condition (code), SImode, comp_reg, const0_rtx);
93- emit_jump_insn (gen_condjump (condition, label1));
94+ condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
95+ if (mode == SImode)
96+ emit_jump_insn (gen_condjump (condition, label1));
97+ else
98+ emit_jump_insn (gen_long_condjump (condition, label1));
99+
100 }
101
102 else if (code == EQ || code == NE)
103 {
104 /* Use xor for equal/not-equal comparison. */
105- emit_insn (gen_xorsi3 (comp_reg, cmp_op0, cmp_op1));
106- condition = gen_rtx_fmt_ee (signed_condition (code), SImode, comp_reg, const0_rtx);
107- emit_jump_insn (gen_condjump (condition, label1));
108+ if (mode == SImode)
109+ emit_insn (gen_xorsi3 (comp_reg, cmp_op0, cmp_op1));
110+ else
111+ emit_insn (gen_xordi3 (comp_reg, cmp_op0, cmp_op1));
112+ condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
113+ if (mode == SImode)
114+ emit_jump_insn (gen_condjump (condition, label1));
115+ else
116+ emit_jump_insn (gen_long_condjump (condition, label1));
117 }
118 else
119 {
120 /* Generate compare and branch in single instruction. */
121 cmp_op1 = force_reg (mode, cmp_op1);
122 condition = gen_rtx_fmt_ee (code, mode, cmp_op0, cmp_op1);
123- emit_jump_insn (gen_branch_compare(condition, cmp_op0, cmp_op1, label1));
124+ if (mode == SImode)
125+ emit_jump_insn (gen_branch_compare(condition, cmp_op0, cmp_op1, label1));
126+ else
127+ emit_jump_insn (gen_long_branch_compare(condition, cmp_op0, cmp_op1, label1));
128 }
129 }
130
131@@ -3673,7 +3686,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
132 rtx cmp_op0 = operands[1];
133 rtx cmp_op1 = operands[2];
134 rtx label1 = operands[3];
135- rtx comp_reg = gen_reg_rtx (SImode);
136+ rtx comp_reg = gen_reg_rtx (mode);
137 rtx condition;
138
139 gcc_assert ((GET_CODE (cmp_op0) == REG)
140@@ -3684,30 +3697,63 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
141 {
142 comp_reg = cmp_op0;
143 condition = gen_rtx_fmt_ee (signed_condition (code),
144- SImode, comp_reg, const0_rtx);
145- emit_jump_insn (gen_condjump (condition, label1));
146+ mode, comp_reg, const0_rtx);
147+ if (mode == SImode)
148+ emit_jump_insn (gen_condjump (condition, label1));
149+ else
150+ emit_jump_insn (gen_long_condjump (condition, label1));
151 }
152 else if (code == EQ)
153 {
154- emit_insn (gen_seq_internal_pat (comp_reg,
155- cmp_op0, cmp_op1));
156- condition = gen_rtx_EQ (SImode, comp_reg, const0_rtx);
157- emit_jump_insn (gen_condjump (condition, label1));
158+ if (mode == SImode)
159+ {
160+ emit_insn (gen_seq_internal_pat (comp_reg, cmp_op0,
161+ cmp_op1));
162+ }
163+ else
164+ {
165+ emit_insn (gen_seq_internal_pat (comp_reg, cmp_op0,
166+ cmp_op1));
167+ }
168+ condition = gen_rtx_EQ (mode, comp_reg, const0_rtx);
169+ if (mode == SImode)
170+ emit_jump_insn (gen_condjump (condition, label1));
171+ else
172+ emit_jump_insn (gen_long_condjump (condition, label1));
173+
174 }
175 else if (code == NE)
176 {
177- emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
178- cmp_op1));
179- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
180- emit_jump_insn (gen_condjump (condition, label1));
181+ if (mode == SImode)
182+ {
183+ emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
184+ cmp_op1));
185+ }
186+ else
187+ {
188+ emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
189+ cmp_op1));
190+ }
191+ condition = gen_rtx_NE (mode, comp_reg, const0_rtx);
192+ if (mode == SImode)
193+ emit_jump_insn (gen_condjump (condition, label1));
194+ else
195+ emit_jump_insn (gen_long_condjump (condition, label1));
196 }
197 else
198 {
199 /* Generate compare and branch in single instruction. */
200 cmp_op1 = force_reg (mode, cmp_op1);
201 condition = gen_rtx_fmt_ee (code, mode, cmp_op0, cmp_op1);
202- emit_jump_insn (gen_branch_compare (condition, cmp_op0,
203- cmp_op1, label1));
204+ if (mode == SImode)
205+ emit_jump_insn (gen_branch_compare (condition, cmp_op0,
206+ cmp_op1, label1));
207+ else
208+ {
209+ emit_jump_insn (gen_long_branch_compare (condition, cmp_op0,
210+ cmp_op1, label1));
211+ }
212+
213 }
214 }
215
216@@ -3724,6 +3770,19 @@ microblaze_expand_conditional_branch_sf (rtx operands[])
217 emit_jump_insn (gen_condjump (condition, operands[3]));
218 }
219
220+void
221+microblaze_expand_conditional_branch_df (rtx operands[])
222+{
223+ rtx condition;
224+ rtx cmp_op0 = XEXP (operands[0], 0);
225+ rtx cmp_op1 = XEXP (operands[0], 1);
226+ rtx comp_reg = gen_reg_rtx (DImode);
227+
228+ emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
229+ condition = gen_rtx_NE (DImode, comp_reg, const0_rtx);
230+ emit_jump_insn (gen_long_condjump (condition, operands[3]));
231+}
232+
233 /* Implement TARGET_FRAME_POINTER_REQUIRED. */
234
235 static bool
236diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
237index 857cb1cd9d0..c0358603380 100644
238--- a/gcc/config/microblaze/microblaze.h
239+++ b/gcc/config/microblaze/microblaze.h
240@@ -102,6 +102,7 @@ extern enum pipeline_type microblaze_pipe;
241 #define ASM_SPEC "\
242 %(target_asm_spec) \
243 %{mbig-endian:-EB} \
244+%{m64:-m64} \
245 %{mlittle-endian:-EL}"
246
247 /* Extra switches sometimes passed to the linker. */
248@@ -110,6 +111,7 @@ extern enum pipeline_type microblaze_pipe;
249 #define LINK_SPEC "%{shared:-shared} -N -relax \
250 %{mbig-endian:-EB --oformat=elf32-microblaze} \
251 %{mlittle-endian:-EL --oformat=elf32-microblazeel} \
252+ %{m64:-EL --oformat=elf64-microblazeel} \
253 %{Zxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
254 %{mxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
255 %{mxl-gp-opt:%{G*}} %{!mxl-gp-opt: -G 0} \
256@@ -217,7 +219,7 @@ extern enum pipeline_type microblaze_pipe;
257 #define MIN_UNITS_PER_WORD 4
258 #define INT_TYPE_SIZE 32
259 #define SHORT_TYPE_SIZE 16
260-#define LONG_TYPE_SIZE 32
261+#define LONG_TYPE_SIZE 64
262 #define LONG_LONG_TYPE_SIZE 64
263 #define FLOAT_TYPE_SIZE 32
264 #define DOUBLE_TYPE_SIZE 64
265diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
266index 7695b105baa..4d8429d9a90 100644
267--- a/gcc/config/microblaze/microblaze.md
268+++ b/gcc/config/microblaze/microblaze.md
269@@ -497,7 +497,6 @@
270 (set_attr "mode" "SF")
271 (set_attr "length" "4")])
272
273-
274 (define_insn "divsf3"
275 [(set (match_operand:SF 0 "register_operand" "=d")
276 (div:SF (match_operand:SF 1 "register_operand" "d")
277@@ -508,6 +507,7 @@
278 (set_attr "mode" "SF")
279 (set_attr "length" "4")])
280
281+
282 (define_insn "sqrtsf2"
283 [(set (match_operand:SF 0 "register_operand" "=d")
284 (sqrt:SF (match_operand:SF 1 "register_operand" "d")))]
285@@ -562,6 +562,18 @@
286
287 ;; Adding 2 DI operands in register or reg/imm
288
289+(define_insn "adddi3_long"
290+ [(set (match_operand:DI 0 "register_operand" "=d,d")
291+ (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%dJ,dJ")
292+ (match_operand:DI 2 "arith_plus_operand" "d,K")))]
293+ "TARGET_MB_64"
294+ "@
295+ addlk\t%0,%z1,%2
296+ addlik\t%0,%z1,%2"
297+ [(set_attr "type" "arith,arith")
298+ (set_attr "mode" "DI,DI")
299+ (set_attr "length" "4,4")])
300+
301 (define_insn "adddi3"
302 [(set (match_operand:DI 0 "register_operand" "=d,d")
303 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
304@@ -606,6 +618,18 @@
305 ;; Double Precision Subtraction
306 ;;----------------------------------------------------------------
307
308+(define_insn "subdi3_long"
309+ [(set (match_operand:DI 0 "register_operand" "=d,d")
310+ (minus:DI (match_operand:DI 1 "register_operand" "d,d")
311+ (match_operand:DI 2 "register_operand" "d,n")))]
312+ "TARGET_MB_64"
313+ "@
314+ rsubl\t%0,%2,%1
315+ addlik\t%0,%z1,-%2"
316+ [(set_attr "type" "darith")
317+ (set_attr "mode" "DI,DI")
318+ (set_attr "length" "4,4")])
319+
320 (define_insn "subdi3"
321 [(set (match_operand:DI 0 "register_operand" "=&d")
322 (minus:DI (match_operand:DI 1 "register_operand" "d")
323@@ -795,6 +819,15 @@
324 (set_attr "mode" "SI")
325 (set_attr "length" "4")])
326
327+(define_insn "negdi2_long"
328+ [(set (match_operand:DI 0 "register_operand" "=d")
329+ (neg:DI (match_operand:DI 1 "register_operand" "d")))]
330+ "TARGET_MB_64"
331+ "rsubl\t%0,%1,r0"
332+ [(set_attr "type" "darith")
333+ (set_attr "mode" "DI")
334+ (set_attr "length" "4")])
335+
336 (define_insn "negdi2"
337 [(set (match_operand:DI 0 "register_operand" "=d")
338 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
339@@ -814,6 +847,15 @@
340 (set_attr "mode" "SI")
341 (set_attr "length" "4")])
342
343+(define_insn "one_cmpldi2_long"
344+ [(set (match_operand:DI 0 "register_operand" "=d")
345+ (not:DI (match_operand:DI 1 "register_operand" "d")))]
346+ "TARGET_MB_64"
347+ "xorli\t%0,%1,-1"
348+ [(set_attr "type" "arith")
349+ (set_attr "mode" "DI")
350+ (set_attr "length" "4")])
351+
352 (define_insn "*one_cmpldi2"
353 [(set (match_operand:DI 0 "register_operand" "=d")
354 (not:DI (match_operand:DI 1 "register_operand" "d")))]
355@@ -840,6 +882,20 @@
356 ;; Logical
357 ;;----------------------------------------------------------------
358
359+(define_insn "anddi3"
360+ [(set (match_operand:DI 0 "register_operand" "=d,d")
361+ (and:DI (match_operand:DI 1 "arith_operand" "d,d")
362+ (match_operand:DI 2 "arith_operand" "d,K")))]
363+ "TARGET_MB_64"
364+ "@
365+ andl\t%0,%1,%2
366+ andli\t%0,%1,%2 #andl1"
367+ ;; andli\t%0,%1,%2 #andl3
368+ ;; andli\t%0,%1,%2 #andl2
369+ [(set_attr "type" "arith,arith")
370+ (set_attr "mode" "DI,DI")
371+ (set_attr "length" "4,4")])
372+
373 (define_insn "andsi3"
374 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
375 (and:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d")
376@@ -855,6 +911,18 @@
377 (set_attr "length" "4,8,8,8")])
378
379
380+(define_insn "iordi3"
381+ [(set (match_operand:DI 0 "register_operand" "=d,d")
382+ (ior:DI (match_operand:DI 1 "arith_operand" "d,d")
383+ (match_operand:DI 2 "arith_operand" "d,K")))]
384+ "TARGET_MB_64"
385+ "@
386+ orl\t%0,%1,%2
387+ orli\t%0,%1,%2 #andl1"
388+ [(set_attr "type" "arith,arith")
389+ (set_attr "mode" "DI,DI")
390+ (set_attr "length" "4,4")])
391+
392 (define_insn "iorsi3"
393 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
394 (ior:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d")
395@@ -869,6 +937,19 @@
396 (set_attr "mode" "SI,SI,SI,SI")
397 (set_attr "length" "4,8,8,8")])
398
399+(define_insn "xordi3"
400+ [(set (match_operand:DI 0 "register_operand" "=d,d")
401+ (xor:DI (match_operand:DI 1 "arith_operand" "%d,d")
402+ (match_operand:DI 2 "arith_operand" "d,K")))]
403+ "TARGET_MB_64"
404+ "@
405+ xorl\t%0,%1,%2
406+ xorli\t%0,%1,%2 #andl1"
407+ [(set_attr "type" "arith,arith")
408+ (set_attr "mode" "DI,DI")
409+ (set_attr "length" "4,4")])
410+
411+
412 (define_insn "xorsi3"
413 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
414 (xor:SI (match_operand:SI 1 "arith_operand" "%d,d,d")
415@@ -937,6 +1018,26 @@
416 (set_attr "mode" "SI")
417 (set_attr "length" "4")])
418
419+;;(define_expand "extendqidi2"
420+;; [(set (match_operand:DI 0 "register_operand" "=d")
421+;; (sign_extend:DI (match_operand:QI 1 "general_operand" "d")))]
422+;; "TARGET_MB_64"
423+;; {
424+;; if (GET_CODE (operands[1]) != REG)
425+;; FAIL;
426+;; }
427+;;)
428+
429+
430+;;(define_insn "extendqidi2"
431+;; [(set (match_operand:DI 0 "register_operand" "=d")
432+;; (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
433+;; "TARGET_MB_64"
434+;; "sextl8\t%0,%1"
435+;; [(set_attr "type" "arith")
436+;; (set_attr "mode" "DI")
437+;; (set_attr "length" "4")])
438+
439 (define_insn "extendhisi2"
440 [(set (match_operand:SI 0 "register_operand" "=d")
441 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
442@@ -946,6 +1047,16 @@
443 (set_attr "mode" "SI")
444 (set_attr "length" "4")])
445
446+(define_insn "extendhidi2"
447+ [(set (match_operand:DI 0 "register_operand" "=d")
448+ (sign_extend:DI (match_operand:HI 1 "register_operand" "d")))]
449+ "TARGET_MB_64"
450+ "sextl16\t%0,%1"
451+ [(set_attr "type" "arith")
452+ (set_attr "mode" "DI")
453+ (set_attr "length" "4")])
454+
455+
456 ;; Those for integer source operand are ordered
457 ;; widest source type first.
458
459@@ -1011,6 +1122,32 @@
460 )
461
462
463+(define_insn "*movdi_internal_64"
464+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
465+ (match_operand:DI 1 "general_operand" " d,K,J,R,o,d,d"))]
466+ "TARGET_MB_64 && (INTVAL(operands[1]) < 0x7fffffffff) && (INTVAL(operands[1]) > 0xffffff8000000000)"
467+ {
468+ switch (which_alternative)
469+ {
470+ case 0:
471+ return "addlk\t%0,%1";
472+ case 1:
473+ return "addlik\t%0,r0,%1";
474+ case 2:
475+ return "addlk\t%0,r0,r0";
476+ case 3:
477+ case 4:
478+ return "lli\t%0,%1";
479+ case 5:
480+ case 6:
481+ return "sli\t%1,%0";
482+ }
483+ return "unreachable";
484+ }
485+ [(set_attr "type" "no_delay_move,no_delay_arith,no_delay_arith,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
486+ (set_attr "mode" "DI")
487+ (set_attr "length" "8,8,8,8,12,8,12")])
488+
489
490 (define_insn "*movdi_internal"
491 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
492@@ -1423,6 +1560,36 @@
493 (set_attr "length" "4,4")]
494 )
495
496+;; Barrel shift left
497+(define_expand "ashldi3"
498+ [(set (match_operand:DI 0 "register_operand" "=&d")
499+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
500+ (match_operand:DI 2 "arith_operand" "")))]
501+"TARGET_MB_64"
502+{
503+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
504+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
505+ {
506+ emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
507+ DONE;
508+ }
509+else
510+ FAIL;
511+}
512+)
513+
514+(define_insn "ashldi3_long"
515+ [(set (match_operand:DI 0 "register_operand" "=d,d")
516+ (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
517+ (match_operand:DI 2 "arith_operand" "I,d")))]
518+ "TARGET_MB_64"
519+ "@
520+ bsllli\t%0,%1,%2
521+ bslll\t%0,%1,%2"
522+ [(set_attr "type" "bshift,bshift")
523+ (set_attr "mode" "DI,DI")
524+ (set_attr "length" "4,4")]
525+)
526 ;; The following patterns apply when there is no barrel shifter present
527
528 (define_insn "*ashlsi3_with_mul_delay"
529@@ -1548,6 +1715,36 @@
530 ;;----------------------------------------------------------------
531 ;; 32-bit right shifts
532 ;;----------------------------------------------------------------
533+;; Barrel shift left
534+(define_expand "ashrdi3"
535+ [(set (match_operand:DI 0 "register_operand" "=&d")
536+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
537+ (match_operand:DI 2 "arith_operand" "")))]
538+"TARGET_MB_64"
539+{
540+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
541+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
542+ {
543+ emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
544+ DONE;
545+ }
546+else
547+ FAIL;
548+}
549+)
550+
551+(define_insn "ashrdi3_long"
552+ [(set (match_operand:DI 0 "register_operand" "=d,d")
553+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
554+ (match_operand:DI 2 "arith_operand" "I,d")))]
555+ "TARGET_MB_64"
556+ "@
557+ bslrai\t%0,%1,%2
558+ bslra\t%0,%1,%2"
559+ [(set_attr "type" "bshift,bshift")
560+ (set_attr "mode" "DI,DI")
561+ (set_attr "length" "4,4")]
562+ )
563 (define_expand "ashrsi3"
564 [(set (match_operand:SI 0 "register_operand" "=&d")
565 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
566@@ -1657,6 +1854,36 @@
567 ;;----------------------------------------------------------------
568 ;; 32-bit right shifts (logical)
569 ;;----------------------------------------------------------------
570+;; Barrel shift left
571+(define_expand "lshrdi3"
572+ [(set (match_operand:DI 0 "register_operand" "=&d")
573+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
574+ (match_operand:DI 2 "arith_operand" "")))]
575+"TARGET_MB_64"
576+{
577+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
578+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
579+ {
580+ emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
581+ DONE;
582+ }
583+else
584+ FAIL;
585+}
586+)
587+
588+(define_insn "lshrdi3_long"
589+ [(set (match_operand:DI 0 "register_operand" "=d,d")
590+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
591+ (match_operand:DI 2 "arith_operand" "I,d")))]
592+ "TARGET_MB_64"
593+ "@
594+ bslrli\t%0,%1,%2
595+ bslrl\t%0,%1,%2"
596+ [(set_attr "type" "bshift,bshift")
597+ (set_attr "mode" "DI,DI")
598+ (set_attr "length" "4,4")]
599+ )
600
601 (define_expand "lshrsi3"
602 [(set (match_operand:SI 0 "register_operand" "=&d")
603@@ -1803,6 +2030,8 @@
604 (set_attr "length" "4")]
605 )
606
607+
608+
609 ;;----------------------------------------------------------------
610 ;; Setting a register from an floating point comparison.
611 ;;----------------------------------------------------------------
612@@ -1818,6 +2047,18 @@
613 (set_attr "length" "4")]
614 )
615
616+(define_insn "cstoredf4"
617+ [(set (match_operand:DI 0 "register_operand" "=r")
618+ (match_operator:DI 1 "ordered_comparison_operator"
619+ [(match_operand:DF 2 "register_operand" "r")
620+ (match_operand:DF 3 "register_operand" "r")]))]
621+ "TARGET_MB_64"
622+ "dcmp.%C1\t%0,%3,%2"
623+ [(set_attr "type" "fcmp")
624+ (set_attr "mode" "DF")
625+ (set_attr "length" "4")]
626+)
627+
628 ;;----------------------------------------------------------------
629 ;; Conditional branches
630 ;;----------------------------------------------------------------
631@@ -1930,6 +2171,115 @@
632 (set_attr "length" "12")]
633 )
634
635+
636+(define_expand "cbranchdi4"
637+ [(set (pc)
638+ (if_then_else (match_operator 0 "ordered_comparison_operator"
639+ [(match_operand:DI 1 "register_operand")
640+ (match_operand:DI 2 "arith_operand" "I,i")])
641+ (label_ref (match_operand 3 ""))
642+ (pc)))]
643+ "TARGET_MB_64"
644+{
645+ microblaze_expand_conditional_branch (DImode, operands);
646+ DONE;
647+})
648+
649+(define_expand "cbranchdi4_reg"
650+ [(set (pc)
651+ (if_then_else (match_operator 0 "ordered_comparison_operator"
652+ [(match_operand:DI 1 "register_operand")
653+ (match_operand:DI 2 "register_operand")])
654+ (label_ref (match_operand 3 ""))
655+ (pc)))]
656+ "TARGET_MB_64"
657+{
658+ microblaze_expand_conditional_branch_reg (DImode, operands);
659+ DONE;
660+})
661+
662+(define_expand "cbranchdf4"
663+ [(set (pc)
664+ (if_then_else (match_operator 0 "ordered_comparison_operator"
665+ [(match_operand:DF 1 "register_operand")
666+ (match_operand:DF 2 "register_operand")])
667+ (label_ref (match_operand 3 ""))
668+ (pc)))]
669+ "TARGET_MB_64"
670+{
671+ microblaze_expand_conditional_branch_df (operands);
672+ DONE;
673+
674+})
675+
676+;; Used to implement comparison instructions
677+(define_expand "long_condjump"
678+ [(set (pc)
679+ (if_then_else (match_operand 0)
680+ (label_ref (match_operand 1))
681+ (pc)))])
682+
683+(define_insn "long_branch_zero"
684+ [(set (pc)
685+ (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
686+ [(match_operand:DI 1 "register_operand" "d")
687+ (const_int 0)])
688+ (match_operand:DI 2 "pc_or_label_operand" "")
689+ (match_operand:DI 3 "pc_or_label_operand" "")))
690+ ]
691+ "TARGET_MB_64"
692+ {
693+ if (operands[3] == pc_rtx)
694+ return "beal%C0i%?\t%z1,%2";
695+ else
696+ return "beal%N0i%?\t%z1,%3";
697+ }
698+ [(set_attr "type" "branch")
699+ (set_attr "mode" "none")
700+ (set_attr "length" "4")]
701+)
702+
703+(define_insn "long_branch_compare"
704+ [(set (pc)
705+ (if_then_else (match_operator:DI 0 "cmp_op"
706+ [(match_operand:DI 1 "register_operand" "d")
707+ (match_operand:DI 2 "register_operand" "d")
708+ ])
709+ (label_ref (match_operand 3))
710+ (pc)))
711+ (clobber(reg:DI R_TMP))]
712+ "TARGET_MB_64"
713+ {
714+ operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
715+ enum rtx_code code = GET_CODE (operands[0]);
716+
717+ if (code == GT || code == LE)
718+ {
719+ output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
720+ code = swap_condition (code);
721+ }
722+ else if (code == GTU || code == LEU)
723+ {
724+ output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
725+ code = swap_condition (code);
726+ }
727+ else if (code == GE || code == LT)
728+ {
729+ output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
730+ }
731+ else if (code == GEU || code == LTU)
732+ {
733+ output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
734+ }
735+
736+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
737+ return "beal%C0i%?\tr18,%3";
738+ }
739+ [(set_attr "type" "branch")
740+ (set_attr "mode" "none")
741+ (set_attr "length" "12")]
742+)
743+
744 ;;----------------------------------------------------------------
745 ;; Unconditional branches
746 ;;----------------------------------------------------------------
747@@ -2478,17 +2828,33 @@
748 DONE;
749 }")
750
751-(define_expand "extzvsi"
752+(define_expand "extvsi"
753 [(set (match_operand:SI 0 "register_operand" "r")
754 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
755 (match_operand:SI 2 "immediate_operand" "I")
756 (match_operand:SI 3 "immediate_operand" "I")))]
757 "TARGET_HAS_BITFIELD"
758-""
759-)
760-
761+"
762+{
763+ unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
764+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
765+
766+ if ((len == 0) || (pos + len > 32) )
767+ FAIL;
768+
769+ ;;if (!register_operand (operands[1], VOIDmode))
770+ ;; FAIL;
771+ if (operands[0] == operands[1])
772+ FAIL;
773+ if (GET_CODE (operands[1]) == ASHIFT)
774+ FAIL;
775+;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
776+ emit_insn (gen_extv_32 (operands[0], operands[1],
777+ operands[2], operands[3]));
778+ DONE;
779+}")
780
781-(define_insn "extzv_32"
782+(define_insn "extv_32"
783 [(set (match_operand:SI 0 "register_operand" "=r")
784 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
785 (match_operand:SI 2 "immediate_operand" "I")
786@@ -2505,8 +2871,21 @@
787 (match_operand:SI 2 "immediate_operand" "I"))
788 (match_operand:SI 3 "register_operand" "r"))]
789 "TARGET_HAS_BITFIELD"
790-""
791-)
792+ "
793+{
794+ unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
795+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
796+
797+ if (len <= 0 || pos + len > 32)
798+ FAIL;
799+
800+ ;;if (!register_operand (operands[0], VOIDmode))
801+ ;; FAIL;
802+
803+ emit_insn (gen_insv_32 (operands[0], operands[1],
804+ operands[2], operands[3]));
805+ DONE;
806+}")
807
808 (define_insn "insv_32"
809 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
810diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
811index a29c6f8df90..bbe48b06da6 100644
812--- a/gcc/config/microblaze/microblaze.opt
813+++ b/gcc/config/microblaze/microblaze.opt
814@@ -136,4 +136,9 @@ Target
815
816 mxl-frequency
817 Target Mask(AREA_OPTIMIZED_2)
818-Use 8 stage pipeline (frequency optimization)
819+Use 8 stage pipeline (frequency optimization).
820+
821+m64
822+Target Mask(MB_64)
823+MicroBlaze 64-bit mode.
824+
825diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
826index 41fa9a92081..e9a1921ae26 100644
827--- a/gcc/config/microblaze/t-microblaze
828+++ b/gcc/config/microblaze/t-microblaze
829@@ -1,8 +1,11 @@
830-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian
831-MULTILIB_DIRNAMES = bs m mh le
832+MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian m64
833+MULTILIB_DIRNAMES = bs m mh le m64
834 MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
835 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
836+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64
837 MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
838+MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
839+MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
840
841 # Extra files
842 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
843--
8442.17.1
845
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0030-Intial-commit-for-64bit-MB-sources.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0030-Intial-commit-for-64bit-MB-sources.patch
new file mode 100644
index 00000000..88a0d0ba
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0030-Intial-commit-for-64bit-MB-sources.patch
@@ -0,0 +1,2459 @@
1From 53799d63bd26a04265a55f68ca57e3462ed6eeb7 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 27 Jul 2018 15:23:41 +0530
4Subject: [PATCH 30/54] Intial commit for 64bit-MB sources. Need to cleanup the
5 code later.
6
7---
8 gcc/config/microblaze/constraints.md | 2 +-
9 gcc/config/microblaze/microblaze-c.c | 6 +
10 gcc/config/microblaze/microblaze.c | 218 ++++++---
11 gcc/config/microblaze/microblaze.h | 63 ++-
12 gcc/config/microblaze/microblaze.md | 606 ++++++++++++++++++------
13 gcc/config/microblaze/t-microblaze | 3 +-
14 libgcc/config/microblaze/crti.S | 4 +-
15 libgcc/config/microblaze/crtn.S | 4 +-
16 libgcc/config/microblaze/divdi3.S | 98 ++++
17 libgcc/config/microblaze/divdi3_table.c | 62 +++
18 libgcc/config/microblaze/moddi3.S | 97 ++++
19 libgcc/config/microblaze/muldi3.S | 73 +++
20 libgcc/config/microblaze/t-microblaze | 11 +-
21 libgcc/config/microblaze/udivdi3.S | 107 +++++
22 libgcc/config/microblaze/umoddi3.S | 110 +++++
23 15 files changed, 1230 insertions(+), 234 deletions(-)
24 create mode 100644 libgcc/config/microblaze/divdi3.S
25 create mode 100644 libgcc/config/microblaze/divdi3_table.c
26 create mode 100644 libgcc/config/microblaze/moddi3.S
27 create mode 100644 libgcc/config/microblaze/muldi3.S
28 create mode 100644 libgcc/config/microblaze/udivdi3.S
29 create mode 100644 libgcc/config/microblaze/umoddi3.S
30
31diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
32index 123395717e0..b8ef1650f92 100644
33--- a/gcc/config/microblaze/constraints.md
34+++ b/gcc/config/microblaze/constraints.md
35@@ -55,7 +55,7 @@
36 (define_constraint "K"
37 "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
38 (and (match_code "const_int")
39- (match_test "ival > (long)0xffffff8000000000L && ival < (long)0x0000007fffffffffL")))
40+ (match_test "ival > (long)-549755813888 && ival < (long)549755813887")))
41
42
43 ;; Define floating point constraints
44diff --git a/gcc/config/microblaze/microblaze-c.c b/gcc/config/microblaze/microblaze-c.c
45index d8c88e510e5..dbcd21fc6ee 100644
46--- a/gcc/config/microblaze/microblaze-c.c
47+++ b/gcc/config/microblaze/microblaze-c.c
48@@ -100,4 +100,10 @@ microblaze_cpp_define (cpp_reader *pfile)
49 builtin_define ("HAVE_HW_FPU_SQRT");
50 builtin_define ("__HAVE_HW_FPU_SQRT__");
51 }
52+ if (TARGET_MB_64)
53+ {
54+ builtin_define ("__arch64__");
55+ builtin_define ("__microblaze64__");
56+ builtin_define ("__MICROBLAZE64__");
57+ }
58 }
59diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
60index 99a1cd5c0be..3c815444574 100644
61--- a/gcc/config/microblaze/microblaze.c
62+++ b/gcc/config/microblaze/microblaze.c
63@@ -383,10 +383,10 @@ simple_memory_operand (rtx op, machine_mode mode ATTRIBUTE_UNUSED)
64 {
65 return 1;
66 }
67- else if (GET_CODE (plus0) == REG && GET_CODE (plus1) == REG)
68+ /*else if (GET_CODE (plus0) == REG && GET_CODE (plus1) == REG)
69 {
70 return 1;
71- }
72+ }*/
73 else
74 return 0;
75
76@@ -434,7 +434,7 @@ double_memory_operand (rtx op, machine_mode mode)
77 return 1;
78
79 return memory_address_p ((GET_MODE_CLASS (mode) == MODE_INT
80- ? E_SImode : E_SFmode),
81+ ? Pmode : E_SFmode),
82 plus_constant (Pmode, addr, 4));
83 }
84
85@@ -681,7 +681,7 @@ microblaze_legitimize_tls_address(rtx x, rtx reg)
86 /* Load the addend. */
87 addend = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, x, GEN_INT (TLS_DTPREL)),
88 UNSPEC_TLS);
89- addend = force_reg (SImode, gen_rtx_CONST (SImode, addend));
90+ addend = force_reg (Pmode, gen_rtx_CONST (Pmode, addend));
91 dest = gen_rtx_PLUS (Pmode, dest, addend);
92 break;
93
94@@ -699,7 +699,7 @@ microblaze_classify_unspec (struct microblaze_address_info *info, rtx x)
95
96 if (XINT (x, 1) == UNSPEC_GOTOFF)
97 {
98- info->regA = gen_rtx_REG (SImode, PIC_OFFSET_TABLE_REGNUM);
99+ info->regA = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
100 info->type = ADDRESS_GOTOFF;
101 }
102 else if (XINT (x, 1) == UNSPEC_PLT)
103@@ -1302,8 +1302,16 @@ microblaze_block_move_loop (rtx dest, rtx src, HOST_WIDE_INT length)
104 emit_move_insn (dest_reg, plus_constant (Pmode, dest_reg, MAX_MOVE_BYTES));
105
106 /* Emit the test & branch. */
107- emit_insn (gen_cbranchsi4 (gen_rtx_NE (SImode, src_reg, final_src),
108+
109+ if (TARGET_MB_64) {
110+ emit_insn (gen_cbranchdi4 (gen_rtx_NE (Pmode, src_reg, final_src),
111+ src_reg, final_src, label));
112+ }
113+ else {
114+ emit_insn (gen_cbranchsi4 (gen_rtx_NE (Pmode, src_reg, final_src),
115 src_reg, final_src, label));
116+
117+ }
118
119 /* Mop up any left-over bytes. */
120 if (leftover)
121@@ -1633,14 +1641,20 @@ microblaze_function_arg_advance (cumulative_args_t cum_v,
122 break;
123
124 case E_DFmode:
125- cum->arg_words += 2;
126+ if (TARGET_MB_64)
127+ cum->arg_words++;
128+ else
129+ cum->arg_words += 2;
130 if (!cum->gp_reg_found && cum->arg_number <= 2)
131 cum->fp_code += 2 << ((cum->arg_number - 1) * 2);
132 break;
133
134 case E_DImode:
135 cum->gp_reg_found = 1;
136- cum->arg_words += 2;
137+ if (TARGET_MB_64)
138+ cum->arg_words++;
139+ else
140+ cum->arg_words += 2;
141 break;
142
143 case E_QImode:
144@@ -2155,7 +2169,7 @@ compute_frame_size (HOST_WIDE_INT size)
145
146 if (regno != MB_ABI_SUB_RETURN_ADDR_REGNUM)
147 /* Don't account for link register. It is accounted specially below. */
148- gp_reg_size += GET_MODE_SIZE (SImode);
149+ gp_reg_size += GET_MODE_SIZE (Pmode);
150
151 mask |= (1L << (regno - GP_REG_FIRST));
152 }
153@@ -2424,7 +2438,7 @@ print_operand (FILE * file, rtx op, int letter)
154
155 if ((letter == 'M' && !WORDS_BIG_ENDIAN)
156 || (letter == 'L' && WORDS_BIG_ENDIAN) || letter == 'D')
157- regnum++;
158+ regnum++;
159
160 fprintf (file, "%s", reg_names[regnum]);
161 }
162@@ -2450,6 +2464,7 @@ print_operand (FILE * file, rtx op, int letter)
163 else if (letter == 'h' || letter == 'j')
164 {
165 long val[2];
166+ int val1[2];
167 long l[2];
168 if (code == CONST_DOUBLE)
169 {
170@@ -2462,12 +2477,12 @@ print_operand (FILE * file, rtx op, int letter)
171 val[0] = l[WORDS_BIG_ENDIAN != 0];
172 }
173 }
174- else if (code == CONST_INT)
175+ else if (code == CONST_INT || code == CONST)// || code == SYMBOL_REF ||code == LABEL_REF)
176 {
177- val[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
178- val[1] = INTVAL (op) & 0x00000000ffffffffLL;
179+ val1[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
180+ val1[1] = INTVAL (op) & 0x00000000ffffffffLL;
181 }
182- fprintf (file, "0x%8.8lx", (letter == 'h') ? val[0] : val[1]);
183+ fprintf (file, "0x%8.8lx", (letter == 'h') ? val1[0] : val1[1]);
184 }
185 else if (code == CONST_DOUBLE)
186 {
187@@ -2661,7 +2676,10 @@ microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority)
188
189 switch_to_section (get_section (section, 0, NULL));
190 assemble_align (POINTER_SIZE);
191- fputs ("\t.word\t", asm_out_file);
192+ if (TARGET_MB_64)
193+ fputs ("\t.dword\t", asm_out_file);
194+ else
195+ fputs ("\t.word\t", asm_out_file);
196 output_addr_const (asm_out_file, symbol);
197 fputs ("\n", asm_out_file);
198 }
199@@ -2684,7 +2702,10 @@ microblaze_asm_destructor (rtx symbol, int priority)
200
201 switch_to_section (get_section (section, 0, NULL));
202 assemble_align (POINTER_SIZE);
203- fputs ("\t.word\t", asm_out_file);
204+ if (TARGET_MB_64)
205+ fputs ("\t.dword\t", asm_out_file);
206+ else
207+ fputs ("\t.word\t", asm_out_file);
208 output_addr_const (asm_out_file, symbol);
209 fputs ("\n", asm_out_file);
210 }
211@@ -2750,7 +2771,7 @@ save_restore_insns (int prologue)
212 /* For interrupt_handlers, need to save/restore the MSR. */
213 if (microblaze_is_interrupt_variant ())
214 {
215- isr_mem_rtx = gen_rtx_MEM (SImode,
216+ isr_mem_rtx = gen_rtx_MEM (Pmode,
217 gen_rtx_PLUS (Pmode, base_reg_rtx,
218 GEN_INT (current_frame_info.
219 gp_offset -
220@@ -2758,8 +2779,8 @@ save_restore_insns (int prologue)
221
222 /* Do not optimize in flow analysis. */
223 MEM_VOLATILE_P (isr_mem_rtx) = 1;
224- isr_reg_rtx = gen_rtx_REG (SImode, MB_ABI_MSR_SAVE_REG);
225- isr_msr_rtx = gen_rtx_REG (SImode, ST_REG);
226+ isr_reg_rtx = gen_rtx_REG (Pmode, MB_ABI_MSR_SAVE_REG);
227+ isr_msr_rtx = gen_rtx_REG (Pmode, ST_REG);
228 }
229
230 if (microblaze_is_interrupt_variant () && !prologue)
231@@ -2767,8 +2788,8 @@ save_restore_insns (int prologue)
232 emit_move_insn (isr_reg_rtx, isr_mem_rtx);
233 emit_move_insn (isr_msr_rtx, isr_reg_rtx);
234 /* Do not optimize in flow analysis. */
235- emit_insn (gen_rtx_USE (SImode, isr_reg_rtx));
236- emit_insn (gen_rtx_USE (SImode, isr_msr_rtx));
237+ emit_insn (gen_rtx_USE (Pmode, isr_reg_rtx));
238+ emit_insn (gen_rtx_USE (Pmode, isr_msr_rtx));
239 }
240
241 for (regno = GP_REG_FIRST; regno <= GP_REG_LAST; regno++)
242@@ -2779,9 +2800,9 @@ save_restore_insns (int prologue)
243 /* Don't handle here. Already handled as the first register. */
244 continue;
245
246- reg_rtx = gen_rtx_REG (SImode, regno);
247+ reg_rtx = gen_rtx_REG (Pmode, regno);
248 insn = gen_rtx_PLUS (Pmode, base_reg_rtx, GEN_INT (gp_offset));
249- mem_rtx = gen_rtx_MEM (SImode, insn);
250+ mem_rtx = gen_rtx_MEM (Pmode, insn);
251 if (microblaze_is_interrupt_variant () || save_volatiles)
252 /* Do not optimize in flow analysis. */
253 MEM_VOLATILE_P (mem_rtx) = 1;
254@@ -2796,7 +2817,7 @@ save_restore_insns (int prologue)
255 insn = emit_move_insn (reg_rtx, mem_rtx);
256 }
257
258- gp_offset += GET_MODE_SIZE (SImode);
259+ gp_offset += GET_MODE_SIZE (Pmode);
260 }
261 }
262
263@@ -2806,8 +2827,8 @@ save_restore_insns (int prologue)
264 emit_move_insn (isr_mem_rtx, isr_reg_rtx);
265
266 /* Do not optimize in flow analysis. */
267- emit_insn (gen_rtx_USE (SImode, isr_reg_rtx));
268- emit_insn (gen_rtx_USE (SImode, isr_msr_rtx));
269+ emit_insn (gen_rtx_USE (Pmode, isr_reg_rtx));
270+ emit_insn (gen_rtx_USE (Pmode, isr_msr_rtx));
271 }
272
273 /* Done saving and restoring */
274@@ -2897,7 +2918,10 @@ microblaze_elf_asm_cdtor (rtx symbol, int priority, bool is_ctor)
275
276 switch_to_section (s);
277 assemble_align (POINTER_SIZE);
278- fputs ("\t.word\t", asm_out_file);
279+ if (TARGET_MB_64)
280+ fputs ("\t.dword\t", asm_out_file);
281+ else
282+ fputs ("\t.word\t", asm_out_file);
283 output_addr_const (asm_out_file, symbol);
284 fputs ("\n", asm_out_file);
285 }
286@@ -3041,10 +3065,10 @@ microblaze_expand_prologue (void)
287 {
288 if (offset != 0)
289 ptr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offset));
290- emit_move_insn (gen_rtx_MEM (SImode, ptr),
291- gen_rtx_REG (SImode, regno));
292+ emit_move_insn (gen_rtx_MEM (Pmode, ptr),
293+ gen_rtx_REG (Pmode, regno));
294
295- offset += GET_MODE_SIZE (SImode);
296+ offset += GET_MODE_SIZE (Pmode);
297 }
298 }
299
300@@ -3053,15 +3077,23 @@ microblaze_expand_prologue (void)
301 rtx fsiz_rtx = GEN_INT (fsiz);
302
303 rtx_insn *insn = NULL;
304- insn = emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
305+ if (TARGET_MB_64)
306+ {
307+
308+ insn = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
309 fsiz_rtx));
310+ }
311+ else {
312+ insn = emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
313+ fsiz_rtx));
314+ }
315 if (insn)
316 RTX_FRAME_RELATED_P (insn) = 1;
317
318 /* Handle SUB_RETURN_ADDR_REGNUM specially at first. */
319 if (!crtl->is_leaf || interrupt_handler)
320 {
321- mem_rtx = gen_rtx_MEM (SImode,
322+ mem_rtx = gen_rtx_MEM (Pmode,
323 gen_rtx_PLUS (Pmode, stack_pointer_rtx,
324 const0_rtx));
325
326@@ -3069,7 +3101,7 @@ microblaze_expand_prologue (void)
327 /* Do not optimize in flow analysis. */
328 MEM_VOLATILE_P (mem_rtx) = 1;
329
330- reg_rtx = gen_rtx_REG (SImode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
331+ reg_rtx = gen_rtx_REG (Pmode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
332 insn = emit_move_insn (mem_rtx, reg_rtx);
333 RTX_FRAME_RELATED_P (insn) = 1;
334 }
335@@ -3179,12 +3211,12 @@ microblaze_expand_epilogue (void)
336 if (!crtl->is_leaf || interrupt_handler)
337 {
338 mem_rtx =
339- gen_rtx_MEM (SImode,
340+ gen_rtx_MEM (Pmode,
341 gen_rtx_PLUS (Pmode, stack_pointer_rtx, const0_rtx));
342 if (interrupt_handler)
343 /* Do not optimize in flow analysis. */
344 MEM_VOLATILE_P (mem_rtx) = 1;
345- reg_rtx = gen_rtx_REG (SImode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
346+ reg_rtx = gen_rtx_REG (Pmode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
347 emit_move_insn (reg_rtx, mem_rtx);
348 }
349
350@@ -3200,15 +3232,25 @@ microblaze_expand_epilogue (void)
351 /* _restore_ registers for epilogue. */
352 save_restore_insns (0);
353 emit_insn (gen_blockage ());
354- emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
355+ if (TARGET_MB_64)
356+ emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
357+ else
358+ emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
359 }
360
361 if (crtl->calls_eh_return)
362- emit_insn (gen_addsi3 (stack_pointer_rtx,
363+ if (TARGET_MB_64) {
364+ emit_insn (gen_adddi3 (stack_pointer_rtx,
365 stack_pointer_rtx,
366- gen_raw_REG (SImode,
367+ gen_raw_REG (Pmode,
368 MB_EH_STACKADJ_REGNUM)));
369-
370+ }
371+ else {
372+ emit_insn (gen_addsi3 (stack_pointer_rtx,
373+ stack_pointer_rtx,
374+ gen_raw_REG (Pmode,
375+ MB_EH_STACKADJ_REGNUM)));
376+ }
377 emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, GP_REG_FIRST +
378 MB_ABI_SUB_RETURN_ADDR_REGNUM)));
379 }
380@@ -3375,9 +3417,14 @@ microblaze_asm_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
381 else
382 this_rtx = gen_rtx_REG (Pmode, MB_ABI_FIRST_ARG_REGNUM);
383
384- /* Apply the constant offset, if required. */
385+ /* Apply the constant offset, if required. */
386 if (delta)
387- emit_insn (gen_addsi3 (this_rtx, this_rtx, GEN_INT (delta)));
388+ {
389+ if (TARGET_MB_64)
390+ emit_insn (gen_adddi3 (this_rtx, this_rtx, GEN_INT (delta)));
391+ else
392+ emit_insn (gen_addsi3 (this_rtx, this_rtx, GEN_INT (delta)));
393+ }
394
395 /* Apply the offset from the vtable, if required. */
396 if (vcall_offset)
397@@ -3390,7 +3437,10 @@ microblaze_asm_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
398 rtx loc = gen_rtx_PLUS (Pmode, temp1, vcall_offset_rtx);
399 emit_move_insn (temp1, gen_rtx_MEM (Pmode, loc));
400
401- emit_insn (gen_addsi3 (this_rtx, this_rtx, temp1));
402+ if (TARGET_MB_64)
403+ emit_insn (gen_adddi3 (this_rtx, this_rtx, temp1));
404+ else
405+ emit_insn (gen_addsi3 (this_rtx, this_rtx, temp1));
406 }
407
408 /* Generate a tail call to the target function. */
409@@ -3566,7 +3616,7 @@ microblaze_eh_return (rtx op0)
410 /* Queue an .ident string in the queue of top-level asm statements.
411 If the string size is below the threshold, put it into .sdata2.
412 If the front-end is done, we must be being called from toplev.c.
413- In that case, do nothing. */
414+ In that case, do nothing. */
415 void
416 microblaze_asm_output_ident (const char *string)
417 {
418@@ -3621,9 +3671,9 @@ microblaze_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
419 emit_block_move (m_tramp, assemble_trampoline_template (),
420 GEN_INT (6*UNITS_PER_WORD), BLOCK_OP_NORMAL);
421
422- mem = adjust_address (m_tramp, SImode, 16);
423+ mem = adjust_address (m_tramp, Pmode, 16);
424 emit_move_insn (mem, chain_value);
425- mem = adjust_address (m_tramp, SImode, 20);
426+ mem = adjust_address (m_tramp, Pmode, 20);
427 emit_move_insn (mem, fnaddr);
428 }
429
430@@ -3647,7 +3697,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
431 {
432 comp_reg = cmp_op0;
433 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
434- if (mode == SImode)
435+ if (mode == Pmode)
436 emit_jump_insn (gen_condjump (condition, label1));
437 else
438 emit_jump_insn (gen_long_condjump (condition, label1));
439@@ -3766,7 +3816,7 @@ microblaze_expand_conditional_branch_sf (rtx operands[])
440 rtx comp_reg = gen_reg_rtx (SImode);
441
442 emit_insn (gen_cstoresf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
443- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
444+ condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
445 emit_jump_insn (gen_condjump (condition, operands[3]));
446 }
447
448@@ -3776,10 +3826,10 @@ microblaze_expand_conditional_branch_df (rtx operands[])
449 rtx condition;
450 rtx cmp_op0 = XEXP (operands[0], 0);
451 rtx cmp_op1 = XEXP (operands[0], 1);
452- rtx comp_reg = gen_reg_rtx (DImode);
453+ rtx comp_reg = gen_reg_rtx (Pmode);
454
455 emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
456- condition = gen_rtx_NE (DImode, comp_reg, const0_rtx);
457+ condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
458 emit_jump_insn (gen_long_condjump (condition, operands[3]));
459 }
460
461@@ -3800,8 +3850,8 @@ microblaze_expand_divide (rtx operands[])
462 {
463 /* Table lookup software divides. Works for all (nr/dr) where (0 <= nr,dr <= 15). */
464
465- rtx regt1 = gen_reg_rtx (SImode);
466- rtx reg18 = gen_rtx_REG (SImode, R_TMP);
467+ rtx regt1 = gen_reg_rtx (Pmode);
468+ rtx reg18 = gen_rtx_REG (Pmode, R_TMP);
469 rtx regqi = gen_reg_rtx (QImode);
470 rtx_code_label *div_label = gen_label_rtx ();
471 rtx_code_label *div_end_label = gen_label_rtx ();
472@@ -3809,17 +3859,31 @@ microblaze_expand_divide (rtx operands[])
473 rtx mem_rtx;
474 rtx ret;
475 rtx_insn *jump, *cjump, *insn;
476-
477- insn = emit_insn (gen_iorsi3 (regt1, operands[1], operands[2]));
478- cjump = emit_jump_insn_after (gen_cbranchsi4 (
479- gen_rtx_GTU (SImode, regt1, GEN_INT (15)),
480+
481+ if (TARGET_MB_64) {
482+ insn = emit_insn (gen_iordi3 (regt1, operands[1], operands[2]));
483+ cjump = emit_jump_insn_after (gen_cbranchdi4 (
484+ gen_rtx_GTU (Pmode, regt1, GEN_INT (15)),
485+ regt1, GEN_INT (15), div_label), insn);
486+ }
487+ else {
488+ insn = emit_insn (gen_iorsi3 (regt1, operands[1], operands[2]));
489+ cjump = emit_jump_insn_after (gen_cbranchsi4 (
490+ gen_rtx_GTU (Pmode, regt1, GEN_INT (15)),
491 regt1, GEN_INT (15), div_label), insn);
492+ }
493 LABEL_NUSES (div_label) = 1;
494 JUMP_LABEL (cjump) = div_label;
495- emit_insn (gen_rtx_CLOBBER (SImode, reg18));
496+ emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
497
498- emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
499- emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
500+ if (TARGET_MB_64) {
501+ emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
502+ emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
503+ }
504+ else {
505+ emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
506+ emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
507+ }
508 mem_rtx = gen_rtx_MEM (QImode,
509 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
510
511@@ -3966,7 +4030,7 @@ insert_wic_for_ilb_runout (rtx_insn *first)
512 {
513 insn =
514 emit_insn_before (gen_iprefetch
515- (gen_int_mode (addr_offset, SImode)),
516+ (gen_int_mode (addr_offset, Pmode)),
517 before_4);
518 recog_memoized (insn);
519 INSN_LOCATION (insn) = INSN_LOCATION (before_4);
520@@ -3976,7 +4040,27 @@ insert_wic_for_ilb_runout (rtx_insn *first)
521 }
522 }
523 }
524-
525+
526+/* Set the names for various arithmetic operations according to the
527+ * MICROBLAZE ABI. */
528+static void
529+microblaze_init_libfuncs (void)
530+{
531+ set_optab_libfunc (smod_optab, SImode, "__modsi3");
532+ set_optab_libfunc (sdiv_optab, SImode, "__divsi3");
533+ set_optab_libfunc (smul_optab, SImode, "__mulsi3");
534+ set_optab_libfunc (umod_optab, SImode, "__umodsi3");
535+ set_optab_libfunc (udiv_optab, SImode, "__udivsi3");
536+
537+ if (TARGET_MB_64)
538+ {
539+ set_optab_libfunc (smod_optab, DImode, "__moddi3");
540+ set_optab_libfunc (sdiv_optab, DImode, "__divdi3");
541+ set_optab_libfunc (smul_optab, DImode, "__muldi3");
542+ set_optab_libfunc (umod_optab, DImode, "__umoddi3");
543+ set_optab_libfunc (udiv_optab, DImode, "__udivdi3");
544+ }
545+}
546 /* Insert instruction prefetch instruction at the fall
547 through path of the function call. */
548
549@@ -4129,6 +4213,17 @@ microblaze_starting_frame_offset (void)
550 #undef TARGET_LRA_P
551 #define TARGET_LRA_P hook_bool_void_false
552
553+#ifdef TARGET_MB_64
554+#undef TARGET_ASM_ALIGNED_DI_OP
555+#define TARGET_ASM_ALIGNED_DI_OP "\t.dword\t"
556+
557+#undef TARGET_ASM_ALIGNED_HI_OP
558+#define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"
559+
560+#undef TARGET_ASM_ALIGNED_SI_OP
561+#define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
562+#endif
563+
564 #undef TARGET_FRAME_POINTER_REQUIRED
565 #define TARGET_FRAME_POINTER_REQUIRED microblaze_frame_pointer_required
566
567@@ -4138,6 +4233,9 @@ microblaze_starting_frame_offset (void)
568 #undef TARGET_TRAMPOLINE_INIT
569 #define TARGET_TRAMPOLINE_INIT microblaze_trampoline_init
570
571+#undef TARGET_INIT_LIBFUNCS
572+#define TARGET_INIT_LIBFUNCS microblaze_init_libfuncs
573+
574 #undef TARGET_PROMOTE_FUNCTION_MODE
575 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
576
577diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
578index c0358603380..f6ad4d9fc21 100644
579--- a/gcc/config/microblaze/microblaze.h
580+++ b/gcc/config/microblaze/microblaze.h
581@@ -173,7 +173,6 @@ extern enum pipeline_type microblaze_pipe;
582
583 /* Generate DWARF exception handling info. */
584 #define DWARF2_UNWIND_INFO 1
585-
586 /* Don't generate .loc operations. */
587 #define DWARF2_ASM_LINE_DEBUG_INFO 0
588
589@@ -206,38 +205,51 @@ extern enum pipeline_type microblaze_pipe;
590 ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
591
592 /* Use DWARF 2 debugging information by default. */
593-#define DWARF2_DEBUGGING_INFO
594+#define DWARF2_DEBUGGING_INFO 1
595 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
596+#define DWARF2_ADDR_SIZE 4
597
598 /* Target machine storage layout */
599
600 #define BITS_BIG_ENDIAN 0
601 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
602 #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)
603-#define BITS_PER_WORD 32
604-#define UNITS_PER_WORD 4
605+//#define BITS_PER_WORD 64
606+//Revisit
607+#define MAX_BITS_PER_WORD 64
608+#define UNITS_PER_WORD (TARGET_MB_64 ? 8 : 4)
609+//#define MIN_UNITS_PER_WORD (TARGET_MB_64 ? 8 : 4)
610+//#define UNITS_PER_WORD 4
611 #define MIN_UNITS_PER_WORD 4
612 #define INT_TYPE_SIZE 32
613 #define SHORT_TYPE_SIZE 16
614-#define LONG_TYPE_SIZE 64
615+#define LONG_TYPE_SIZE (TARGET_MB_64 ? 64 : 32)
616 #define LONG_LONG_TYPE_SIZE 64
617 #define FLOAT_TYPE_SIZE 32
618 #define DOUBLE_TYPE_SIZE 64
619 #define LONG_DOUBLE_TYPE_SIZE 64
620-#define POINTER_SIZE 32
621-#define PARM_BOUNDARY 32
622-#define FUNCTION_BOUNDARY 32
623-#define EMPTY_FIELD_BOUNDARY 32
624+#define POINTER_SIZE (TARGET_MB_64 ? 64 : 32)
625+//#define WIDEST_HARDWARE_FP_SIZE 64
626+//#define POINTERS_EXTEND_UNSIGNED 1
627+#define PARM_BOUNDARY (TARGET_MB_64 ? 64 : 32)
628+#define FUNCTION_BOUNDARY (TARGET_MB_64 ? 64 : 32)
629+#define EMPTY_FIELD_BOUNDARY (TARGET_MB_64 ? 64 : 32)
630 #define STRUCTURE_SIZE_BOUNDARY 8
631-#define BIGGEST_ALIGNMENT 32
632+#define BIGGEST_ALIGNMENT (TARGET_MB_64 ? 64 : 32)
633 #define STRICT_ALIGNMENT 1
634 #define PCC_BITFIELD_TYPE_MATTERS 1
635
636+//#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_MB_64 ? TImode : DImode)
637 #undef SIZE_TYPE
638-#define SIZE_TYPE "unsigned int"
639+#define SIZE_TYPE (TARGET_MB_64 ? "long unsigned int" : "unsigned int")
640
641 #undef PTRDIFF_TYPE
642-#define PTRDIFF_TYPE "int"
643+#define PTRDIFF_TYPE (TARGET_MB_64 ? "long int" : "int")
644+
645+/*#undef INTPTR_TYPE
646+#define INTPTR_TYPE (TARGET_MB_64 ? "long int" : "int")*/
647+#undef UINTPTR_TYPE
648+#define UINTPTR_TYPE (TARGET_MB_64 ? "long unsigned int" : "unsigned int")
649
650 #define DATA_ALIGNMENT(TYPE, ALIGN) \
651 ((((ALIGN) < BITS_PER_WORD) \
652@@ -253,12 +265,12 @@ extern enum pipeline_type microblaze_pipe;
653 #define WORD_REGISTER_OPERATIONS 1
654
655 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
656-
657+/*
658 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
659 if (GET_MODE_CLASS (MODE) == MODE_INT \
660- && GET_MODE_SIZE (MODE) < 4) \
661- (MODE) = SImode;
662-
663+ && GET_MODE_SIZE (MODE) < (TARGET_MB_64 ? 8 : 4)) \
664+ (MODE) = TARGET_MB_64 ? DImode : SImode;
665+*/
666 /* Standard register usage. */
667
668 /* On the MicroBlaze, we have 32 integer registers */
669@@ -438,13 +450,16 @@ extern struct microblaze_frame_info current_frame_info;
670 #define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
671
672 #define ARG_POINTER_CFA_OFFSET(FNDECL) 0
673+#define DWARF_CIE_DATA_ALIGNMENT -1
674
675 #define REG_PARM_STACK_SPACE(FNDECL) (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD)
676
677 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
678
679-#define STACK_BOUNDARY 32
680+#define STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
681
682+#define PREFERRED_STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
683+
684 #define NUM_OF_ARGS 6
685
686 #define GP_RETURN (GP_REG_FIRST + MB_ABI_INT_RETURN_VAL_REGNUM)
687@@ -455,12 +470,15 @@ extern struct microblaze_frame_info current_frame_info;
688 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
689
690 #define LIBCALL_VALUE(MODE) \
691+ gen_rtx_REG (MODE,GP_RETURN)
692+
693+/*#define LIBCALL_VALUE(MODE) \
694 gen_rtx_REG ( \
695 ((GET_MODE_CLASS (MODE) != MODE_INT \
696 || GET_MODE_SIZE (MODE) >= 4) \
697 ? (MODE) \
698 : SImode), GP_RETURN)
699-
700+*/
701 /* 1 if N is a possible register number for a function value.
702 On the MicroBlaze, R2 R3 are the only register thus used.
703 Currently, R2 are only implemented here (C has no complex type) */
704@@ -500,7 +518,7 @@ typedef struct microblaze_args
705 /* 4 insns + 2 words of data. */
706 #define TRAMPOLINE_SIZE (6 * 4)
707
708-#define TRAMPOLINE_ALIGNMENT 32
709+#define TRAMPOLINE_ALIGNMENT 64
710
711 #define REGNO_OK_FOR_BASE_P(regno) microblaze_regno_ok_for_base_p ((regno), 1)
712
713@@ -529,13 +547,13 @@ typedef struct microblaze_args
714 addresses which require two reload registers. */
715 #define LEGITIMATE_PIC_OPERAND_P(X) microblaze_legitimate_pic_operand (X)
716
717-#define CASE_VECTOR_MODE (SImode)
718+#define CASE_VECTOR_MODE (TARGET_MB_64? DImode:SImode)
719
720 #ifndef DEFAULT_SIGNED_CHAR
721 #define DEFAULT_SIGNED_CHAR 1
722 #endif
723
724-#define MOVE_MAX 4
725+#define MOVE_MAX (TARGET_MB_64 ? 8 : 4)
726 #define MAX_MOVE_MAX 8
727
728 #define SLOW_BYTE_ACCESS 1
729@@ -545,7 +563,7 @@ typedef struct microblaze_args
730
731 #define SHIFT_COUNT_TRUNCATED 1
732
733-#define Pmode SImode
734+#define Pmode (TARGET_MB_64? DImode:SImode)
735
736 #define FUNCTION_MODE SImode
737
738@@ -707,6 +725,7 @@ do { \
739
740 #undef TARGET_ASM_OUTPUT_IDENT
741 #define TARGET_ASM_OUTPUT_IDENT microblaze_asm_output_ident
742+//#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
743
744 /* Default to -G 8 */
745 #ifndef MICROBLAZE_DEFAULT_GVALUE
746diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
747index 4d8429d9a90..33a8b12ef3b 100644
748--- a/gcc/config/microblaze/microblaze.md
749+++ b/gcc/config/microblaze/microblaze.md
750@@ -26,6 +26,7 @@
751 ;; Constants
752 ;;----------------------------------------------------
753 (define_constants [
754+ (R_Z 0) ;; For reg r0
755 (R_SP 1) ;; Stack pointer reg
756 (R_SR 15) ;; Sub-routine return addr reg
757 (R_IR 14) ;; Interrupt return addr reg
758@@ -541,6 +542,7 @@
759
760 ;; Add 2 SImode integers [ src1 = reg ; src2 = arith ; dest = reg ]
761 ;; Leave carry as is
762+
763 (define_insn "addsi3"
764 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
765 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%dJ,dJ,dJ")
766@@ -562,23 +564,38 @@
767
768 ;; Adding 2 DI operands in register or reg/imm
769
770-(define_insn "adddi3_long"
771+(define_expand "adddi3"
772+ [(set (match_operand:DI 0 "register_operand" "")
773+ (plus:DI (match_operand:DI 1 "register_operand" "")
774+ (match_operand:DI 2 "arith_plus_operand" "")))]
775+""
776+{
777+ if (TARGET_MB_64)
778+ {
779+ if (GET_CODE (operands[2]) == CONST_INT &&
780+ INTVAL(operands[2]) < (long)-549755813888 &&
781+ INTVAL(operands[2]) > (long)549755813887)
782+ FAIL;
783+ }
784+})
785+
786+(define_insn "*adddi3_long"
787 [(set (match_operand:DI 0 "register_operand" "=d,d")
788- (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%dJ,dJ")
789+ (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
790 (match_operand:DI 2 "arith_plus_operand" "d,K")))]
791 "TARGET_MB_64"
792 "@
793- addlk\t%0,%z1,%2
794- addlik\t%0,%z1,%2"
795- [(set_attr "type" "arith,arith")
796- (set_attr "mode" "DI,DI")
797+ addlk\t%0,%1,%2
798+ addlik\t%0,%1,%2 #N10"
799+ [(set_attr "type" "darith,no_delay_arith")
800+ (set_attr "mode" "DI")
801 (set_attr "length" "4,4")])
802
803-(define_insn "adddi3"
804+(define_insn "*adddi3_all"
805 [(set (match_operand:DI 0 "register_operand" "=d,d")
806 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
807 (match_operand:DI 2 "arith_operand" "d,i")))]
808- ""
809+ "!TARGET_MB_64"
810 "@
811 add\t%L0,%L1,%L2\;addc\t%M0,%M1,%M2
812 addi\t%L0,%L1,%j2\;addic\t%M0,%M1,%h2"
813@@ -605,7 +622,7 @@
814 (define_insn "iprefetch"
815 [(unspec [(match_operand:SI 0 "const_int_operand" "n")] UNSPEC_IPREFETCH)
816 (clobber (mem:BLK (scratch)))]
817- "TARGET_PREFETCH"
818+ "TARGET_PREFETCH && !TARGET_MB_64"
819 {
820 operands[2] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
821 return "mfs\t%2,rpc\n\twic\t%2,r0";
822@@ -618,23 +635,33 @@
823 ;; Double Precision Subtraction
824 ;;----------------------------------------------------------------
825
826-(define_insn "subdi3_long"
827- [(set (match_operand:DI 0 "register_operand" "=d,d")
828- (minus:DI (match_operand:DI 1 "register_operand" "d,d")
829- (match_operand:DI 2 "register_operand" "d,n")))]
830+(define_expand "subdi3"
831+ [(set (match_operand:DI 0 "register_operand" "")
832+ (minus:DI (match_operand:DI 1 "register_operand" "")
833+ (match_operand:DI 2 "arith_operand" "")))]
834+""
835+"
836+{
837+}")
838+
839+(define_insn "subsidi3"
840+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
841+ (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
842+ (match_operand:DI 2 "arith_operand" "d,K,n")))]
843 "TARGET_MB_64"
844 "@
845 rsubl\t%0,%2,%1
846- addlik\t%0,%z1,-%2"
847- [(set_attr "type" "darith")
848- (set_attr "mode" "DI,DI")
849- (set_attr "length" "4,4")])
850+ addik\t%0,%z1,-%2
851+ addik\t%0,%z1,-%2"
852+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
853+ (set_attr "mode" "DI")
854+ (set_attr "length" "4,4,4")])
855
856-(define_insn "subdi3"
857+(define_insn "subdi3_small"
858 [(set (match_operand:DI 0 "register_operand" "=&d")
859 (minus:DI (match_operand:DI 1 "register_operand" "d")
860 (match_operand:DI 2 "register_operand" "d")))]
861- ""
862+ "!TARGET_MB_64"
863 "rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1"
864 [(set_attr "type" "darith")
865 (set_attr "mode" "DI")
866@@ -663,7 +690,7 @@
867 (mult:DI
868 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
869 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
870- "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH"
871+ "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH && !TARGET_MB_64"
872 "mul\t%L0,%1,%2\;mulh\t%M0,%1,%2"
873 [(set_attr "type" "no_delay_arith")
874 (set_attr "mode" "DI")
875@@ -674,7 +701,7 @@
876 (mult:DI
877 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
878 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
879- "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH"
880+ "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH && !TARGET_MB_64"
881 "mul\t%L0,%1,%2\;mulhu\t%M0,%1,%2"
882 [(set_attr "type" "no_delay_arith")
883 (set_attr "mode" "DI")
884@@ -685,7 +712,7 @@
885 (mult:DI
886 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
887 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
888- "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH"
889+ "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH && !TARGET_MB_64"
890 "mul\t%L0,%1,%2\;mulhsu\t%M0,%2,%1"
891 [(set_attr "type" "no_delay_arith")
892 (set_attr "mode" "DI")
893@@ -789,7 +816,7 @@
894 (match_operand:SI 4 "arith_operand")])
895 (label_ref (match_operand 5))
896 (pc)))]
897- "TARGET_HARD_FLOAT"
898+ "TARGET_HARD_FLOAT && !TARGET_MB_64"
899 [(set (match_dup 1) (match_dup 3))]
900
901 {
902@@ -819,6 +846,15 @@
903 (set_attr "mode" "SI")
904 (set_attr "length" "4")])
905
906+(define_insn "negsi_long"
907+ [(set (match_operand:SI 0 "register_operand" "=d")
908+ (neg:SI (match_operand:DI 1 "register_operand" "d")))]
909+ ""
910+ "rsubk\t%0,%1,r0"
911+ [(set_attr "type" "arith")
912+ (set_attr "mode" "SI")
913+ (set_attr "length" "4")])
914+
915 (define_insn "negdi2_long"
916 [(set (match_operand:DI 0 "register_operand" "=d")
917 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
918@@ -847,16 +883,24 @@
919 (set_attr "mode" "SI")
920 (set_attr "length" "4")])
921
922-(define_insn "one_cmpldi2_long"
923+(define_expand "one_cmpldi2"
924+ [(set (match_operand:DI 0 "register_operand" "")
925+ (not:DI (match_operand:DI 1 "register_operand" "")))]
926+ ""
927+ "
928+{
929+}")
930+
931+(define_insn ""
932 [(set (match_operand:DI 0 "register_operand" "=d")
933- (not:DI (match_operand:DI 1 "register_operand" "d")))]
934+ (not:DI (match_operand:DI 1 "arith_operand" "d")))]
935 "TARGET_MB_64"
936 "xorli\t%0,%1,-1"
937- [(set_attr "type" "arith")
938+ [(set_attr "type" "no_delay_arith")
939 (set_attr "mode" "DI")
940 (set_attr "length" "4")])
941
942-(define_insn "*one_cmpldi2"
943+(define_insn ""
944 [(set (match_operand:DI 0 "register_operand" "=d")
945 (not:DI (match_operand:DI 1 "register_operand" "d")))]
946 ""
947@@ -871,7 +915,8 @@
948 (not:DI (match_operand:DI 1 "register_operand" "")))]
949 "reload_completed
950 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
951- && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
952+ && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
953+ && !TARGET_MB_64"
954
955 [(set (subreg:SI (match_dup 0) 0) (not:SI (subreg:SI (match_dup 1) 0)))
956 (set (subreg:SI (match_dup 0) 4) (not:SI (subreg:SI (match_dup 1) 4)))]
957@@ -883,18 +928,17 @@
958 ;;----------------------------------------------------------------
959
960 (define_insn "anddi3"
961- [(set (match_operand:DI 0 "register_operand" "=d,d")
962- (and:DI (match_operand:DI 1 "arith_operand" "d,d")
963- (match_operand:DI 2 "arith_operand" "d,K")))]
964+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
965+ (and:DI (match_operand:DI 1 "arith_operand" "d,d,d")
966+ (match_operand:DI 2 "arith_operand" "d,K,I")))]
967 "TARGET_MB_64"
968 "@
969 andl\t%0,%1,%2
970- andli\t%0,%1,%2 #andl1"
971- ;; andli\t%0,%1,%2 #andl3
972- ;; andli\t%0,%1,%2 #andl2
973- [(set_attr "type" "arith,arith")
974- (set_attr "mode" "DI,DI")
975- (set_attr "length" "4,4")])
976+ andli\t%0,%1,%2 #andl2
977+ andli\t%0,%1,%2 #andl3"
978+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
979+ (set_attr "mode" "DI,DI,DI")
980+ (set_attr "length" "4,4,4")])
981
982 (define_insn "andsi3"
983 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
984@@ -919,7 +963,7 @@
985 "@
986 orl\t%0,%1,%2
987 orli\t%0,%1,%2 #andl1"
988- [(set_attr "type" "arith,arith")
989+ [(set_attr "type" "arith,no_delay_arith")
990 (set_attr "mode" "DI,DI")
991 (set_attr "length" "4,4")])
992
993@@ -945,7 +989,7 @@
994 "@
995 xorl\t%0,%1,%2
996 xorli\t%0,%1,%2 #andl1"
997- [(set_attr "type" "arith,arith")
998+ [(set_attr "type" "arith,no_delay_arith")
999 (set_attr "mode" "DI,DI")
1000 (set_attr "length" "4,4")])
1001
1002@@ -1018,26 +1062,6 @@
1003 (set_attr "mode" "SI")
1004 (set_attr "length" "4")])
1005
1006-;;(define_expand "extendqidi2"
1007-;; [(set (match_operand:DI 0 "register_operand" "=d")
1008-;; (sign_extend:DI (match_operand:QI 1 "general_operand" "d")))]
1009-;; "TARGET_MB_64"
1010-;; {
1011-;; if (GET_CODE (operands[1]) != REG)
1012-;; FAIL;
1013-;; }
1014-;;)
1015-
1016-
1017-;;(define_insn "extendqidi2"
1018-;; [(set (match_operand:DI 0 "register_operand" "=d")
1019-;; (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
1020-;; "TARGET_MB_64"
1021-;; "sextl8\t%0,%1"
1022-;; [(set_attr "type" "arith")
1023-;; (set_attr "mode" "DI")
1024-;; (set_attr "length" "4")])
1025-
1026 (define_insn "extendhisi2"
1027 [(set (match_operand:SI 0 "register_operand" "=d")
1028 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
1029@@ -1060,6 +1084,27 @@
1030 ;; Those for integer source operand are ordered
1031 ;; widest source type first.
1032
1033+(define_insn "extendsidi2_long"
1034+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1035+ (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
1036+ "TARGET_MB_64"
1037+ {
1038+ switch (which_alternative)
1039+ {
1040+ case 0:
1041+ return "sextl32\t%0,%1";
1042+ case 1:
1043+ case 2:
1044+ {
1045+ output_asm_insn ("ll%i1\t%0,%1", operands);
1046+ return "sextl32\t%0,%0";
1047+ }
1048+ }
1049+ }
1050+ [(set_attr "type" "multi,multi,multi")
1051+ (set_attr "mode" "DI")
1052+ (set_attr "length" "4,8,8")])
1053+
1054 (define_insn "extendsidi2"
1055 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1056 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
1057@@ -1090,69 +1135,118 @@
1058 ;; Unlike most other insns, the move insns can't be split with
1059 ;; different predicates, because register spilling and other parts of
1060 ;; the compiler, have memoized the insn number already.
1061+;; //}
1062
1063 (define_expand "movdi"
1064 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1065 (match_operand:DI 1 "general_operand" ""))]
1066 ""
1067 {
1068- /* If operands[1] is a constant address illegal for pic, then we need to
1069- handle it just like microblaze_legitimize_address does. */
1070- if (flag_pic && pic_address_needs_scratch (operands[1]))
1071+ if (TARGET_MB_64)
1072+ {
1073+ if (microblaze_expand_move (DImode, operands)) DONE;
1074+ }
1075+ else
1076 {
1077+ /* If operands[1] is a constant address illegal for pic, then we need to
1078+ handle it just like microblaze_legitimize_address does. */
1079+ if (flag_pic && pic_address_needs_scratch (operands[1]))
1080+ {
1081 rtx temp = force_reg (DImode, XEXP (XEXP (operands[1], 0), 0));
1082 rtx temp2 = XEXP (XEXP (operands[1], 0), 1);
1083 emit_move_insn (operands[0], gen_rtx_PLUS (DImode, temp, temp2));
1084 DONE;
1085- }
1086-
1087-
1088- if ((reload_in_progress | reload_completed) == 0
1089- && !register_operand (operands[0], DImode)
1090- && !register_operand (operands[1], DImode)
1091- && (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
1092- && operands[1] != CONST0_RTX (DImode))))
1093- {
1094+ }
1095
1096- rtx temp = force_reg (DImode, operands[1]);
1097- emit_move_insn (operands[0], temp);
1098- DONE;
1099+ if ((reload_in_progress | reload_completed) == 0
1100+ && !register_operand (operands[0], DImode)
1101+ && !register_operand (operands[1], DImode)
1102+ && (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
1103+ && operands[1] != CONST0_RTX (DImode))))
1104+ {
1105+ rtx temp = force_reg (DImode, operands[1]);
1106+ emit_move_insn (operands[0], temp);
1107+ DONE;
1108+ }
1109 }
1110 }
1111 )
1112
1113+;; Added for status registers
1114+(define_insn "movdi_status"
1115+ [(set (match_operand:DI 0 "register_operand" "=d,d,z")
1116+ (match_operand:DI 1 "register_operand" "z,d,d"))]
1117+ "microblaze_is_interrupt_variant () && TARGET_MB_64"
1118+ "@
1119+ mfs\t%0,%1 #mfs
1120+ addlk\t%0,%1,r0 #add movdi
1121+ mts\t%0,%1 #mts"
1122+ [(set_attr "type" "move")
1123+ (set_attr "mode" "DI")
1124+ (set_attr "length" "12")])
1125
1126-(define_insn "*movdi_internal_64"
1127- [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
1128- (match_operand:DI 1 "general_operand" " d,K,J,R,o,d,d"))]
1129- "TARGET_MB_64 && (INTVAL(operands[1]) < 0x7fffffffff) && (INTVAL(operands[1]) > 0xffffff8000000000)"
1130+;; This move will be not be moved to delay slot.
1131+(define_insn "*movdi_internal3"
1132+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d")
1133+ (match_operand:DI 1 "immediate_operand" "J,I,Mnis"))]
1134+ "TARGET_MB_64 && (register_operand (operands[0], DImode) &&
1135+ (GET_CODE (operands[1]) == CONST_INT &&
1136+ (INTVAL (operands[1]) <= (long)549755813887 && INTVAL (operands[1]) >= (long)-549755813888)))"
1137+ "@
1138+ addlk\t%0,r0,r0\t
1139+ addlik\t%0,r0,%1\t #N1 %X1
1140+ addlik\t%0,r0,%1\t #N2 %X1"
1141+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
1142+ (set_attr "mode" "DI")
1143+ (set_attr "length" "4")])
1144+
1145+;; This move may be used for PLT label operand
1146+(define_insn "*movdi_internal5_pltop"
1147+ [(set (match_operand:DI 0 "register_operand" "=d,d")
1148+ (match_operand:DI 1 "call_insn_operand" ""))]
1149+ "TARGET_MB_64 && (register_operand (operands[0], Pmode) &&
1150+ PLT_ADDR_P (operands[1]))"
1151+ {
1152+ gcc_unreachable ();
1153+ }
1154+ [(set_attr "type" "load")
1155+ (set_attr "mode" "DI")
1156+ (set_attr "length" "4")])
1157+
1158+(define_insn "*movdi_internal2"
1159+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
1160+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
1161+ "TARGET_MB_64"
1162 {
1163 switch (which_alternative)
1164 {
1165 case 0:
1166- return "addlk\t%0,%1";
1167- case 1:
1168- return "addlik\t%0,r0,%1";
1169- case 2:
1170- return "addlk\t%0,r0,r0";
1171- case 3:
1172- case 4:
1173- return "lli\t%0,%1";
1174- case 5:
1175- case 6:
1176- return "sli\t%1,%0";
1177- }
1178- return "unreachable";
1179- }
1180- [(set_attr "type" "no_delay_move,no_delay_arith,no_delay_arith,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
1181+ return "addlk\t%0,%1,r0";
1182+ case 1:
1183+ case 2:
1184+ if (GET_CODE (operands[1]) == CONST_INT &&
1185+ (INTVAL (operands[1]) > (long)549755813887 || INTVAL (operands[1]) < (long)-549755813888))
1186+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
1187+ else
1188+ return "addlik\t%0,r0,%1";
1189+ case 3:
1190+ case 4:
1191+ return "ll%i1\t%0,%1";
1192+ case 5:
1193+ case 6:
1194+ return "sl%i0\t%z1,%0";
1195+ }
1196+ }
1197+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
1198 (set_attr "mode" "DI")
1199- (set_attr "length" "8,8,8,8,12,8,12")])
1200+ (set_attr "length" "4,4,12,4,8,4,8")])
1201+
1202
1203
1204 (define_insn "*movdi_internal"
1205 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
1206 (match_operand:DI 1 "general_operand" " d,i,J,R,o,d,d"))]
1207- ""
1208+ "!TARGET_MB_64"
1209 {
1210 switch (which_alternative)
1211 {
1212@@ -1184,7 +1278,8 @@
1213 "reload_completed
1214 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1215 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1216- && (REGNO(operands[0]) == (REGNO(operands[1]) + 1))"
1217+ && (REGNO(operands[0]) == (REGNO(operands[1]) + 1))
1218+ && !(TARGET_MB_64)"
1219
1220 [(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))
1221 (set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))]
1222@@ -1196,12 +1291,22 @@
1223 "reload_completed
1224 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1225 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1226- && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))"
1227+ && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))
1228+ && !(TARGET_MB_64)"
1229
1230 [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1231 (set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))]
1232 "")
1233
1234+(define_insn "movdi_long_int"
1235+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1236+ (match_operand:DI 1 "general_operand" "i"))]
1237+ ""
1238+ "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
1239+ [(set_attr "type" "no_delay_arith")
1240+ (set_attr "mode" "DI")
1241+ (set_attr "length" "12")])
1242+
1243 ;; Unlike most other insns, the move insns can't be split with
1244 ;; different predicates, because register spilling and other parts of
1245 ;; the compiler, have memoized the insn number already.
1246@@ -1273,6 +1378,8 @@
1247 (set_attr "length" "4,4,8,4,8,4,8")])
1248
1249
1250+
1251+
1252 ;; 16-bit Integer moves
1253
1254 ;; Unlike most other insns, the move insns can't be split with
1255@@ -1305,8 +1412,8 @@
1256 "@
1257 addik\t%0,r0,%1\t# %X1
1258 addk\t%0,%1,r0
1259- lhui\t%0,%1
1260- lhui\t%0,%1
1261+ lhu%i1\t%0,%1
1262+ lhu%i1\t%0,%1
1263 sh%i0\t%z1,%0
1264 sh%i0\t%z1,%0"
1265 [(set_attr "type" "arith,move,load,no_delay_load,store,no_delay_store")
1266@@ -1349,7 +1456,7 @@
1267 lbu%i1\t%0,%1
1268 lbu%i1\t%0,%1
1269 sb%i0\t%z1,%0
1270- sbi\t%z1,%0"
1271+ sb%i0\t%z1,%0"
1272 [(set_attr "type" "arith,arith,move,load,no_delay_load,store,no_delay_store")
1273 (set_attr "mode" "QI")
1274 (set_attr "length" "4,4,8,4,8,4,8")])
1275@@ -1422,7 +1529,7 @@
1276 addik\t%0,r0,%F1
1277 lw%i1\t%0,%1
1278 sw%i0\t%z1,%0
1279- swi\t%z1,%0"
1280+ sw%i0\t%z1,%0"
1281 [(set_attr "type" "move,no_delay_load,load,no_delay_load,no_delay_load,store,no_delay_store")
1282 (set_attr "mode" "SF")
1283 (set_attr "length" "4,4,4,4,4,4,4")])
1284@@ -1461,6 +1568,33 @@
1285 ;; movdf_internal
1286 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
1287 ;;
1288+(define_insn "*movdf_internal_64"
1289+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
1290+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
1291+ "TARGET_MB_64"
1292+ {
1293+ switch (which_alternative)
1294+ {
1295+ case 0:
1296+ return "addlk\t%0,%1,r0";
1297+ case 1:
1298+ return "addlk\t%0,r0,r0";
1299+ case 2:
1300+ case 4:
1301+ return "ll%i1\t%0,%1";
1302+ case 3:
1303+ {
1304+ return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
1305+ }
1306+ case 5:
1307+ return "sl%i0\t%1,%0";
1308+ }
1309+ gcc_unreachable ();
1310+ }
1311+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
1312+ (set_attr "mode" "DF")
1313+ (set_attr "length" "4,4,4,16,4,4")])
1314+
1315 (define_insn "*movdf_internal"
1316 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,o")
1317 (match_operand:DF 1 "general_operand" "dG,o,F,T,d"))]
1318@@ -1495,7 +1629,8 @@
1319 "reload_completed
1320 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1321 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1322- && (REGNO (operands[0]) == (REGNO (operands[1]) + 1))"
1323+ && (REGNO (operands[0]) == (REGNO (operands[1]) + 1))
1324+ && !TARGET_MB_64"
1325 [(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))
1326 (set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))]
1327 "")
1328@@ -1506,7 +1641,8 @@
1329 "reload_completed
1330 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1331 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1332- && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))"
1333+ && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))
1334+ && !TARGET_MB_64"
1335 [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1336 (set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))]
1337 "")
1338@@ -2006,6 +2142,31 @@ else
1339 "
1340 )
1341
1342+
1343+(define_insn "seq_internal_pat_long"
1344+ [(set (match_operand:DI 0 "register_operand" "=d")
1345+ (eq:DI
1346+ (match_operand:DI 1 "register_operand" "d")
1347+ (match_operand:DI 2 "register_operand" "d")))]
1348+ "TARGET_MB_64"
1349+ "pcmpleq\t%0,%1,%2"
1350+ [(set_attr "type" "arith")
1351+ (set_attr "mode" "DI")
1352+ (set_attr "length" "4")]
1353+)
1354+
1355+(define_insn "sne_internal_pat_long"
1356+ [(set (match_operand:DI 0 "register_operand" "=d")
1357+ (ne:DI
1358+ (match_operand:DI 1 "register_operand" "d")
1359+ (match_operand:DI 2 "register_operand" "d")))]
1360+ "TARGET_MB_64"
1361+ "pcmplne\t%0,%1,%2"
1362+ [(set_attr "type" "arith")
1363+ (set_attr "mode" "DI")
1364+ (set_attr "length" "4")]
1365+)
1366+
1367 (define_insn "seq_internal_pat"
1368 [(set (match_operand:SI 0 "register_operand" "=d")
1369 (eq:SI
1370@@ -2066,8 +2227,8 @@ else
1371 (define_expand "cbranchsi4"
1372 [(set (pc)
1373 (if_then_else (match_operator 0 "ordered_comparison_operator"
1374- [(match_operand:SI 1 "register_operand")
1375- (match_operand:SI 2 "arith_operand" "I,i")])
1376+ [(match_operand 1 "register_operand")
1377+ (match_operand 2 "arith_operand" "I,i")])
1378 (label_ref (match_operand 3 ""))
1379 (pc)))]
1380 ""
1381@@ -2079,13 +2240,13 @@ else
1382 (define_expand "cbranchsi4_reg"
1383 [(set (pc)
1384 (if_then_else (match_operator 0 "ordered_comparison_operator"
1385- [(match_operand:SI 1 "register_operand")
1386- (match_operand:SI 2 "register_operand")])
1387+ [(match_operand 1 "register_operand")
1388+ (match_operand 2 "register_operand")])
1389 (label_ref (match_operand 3 ""))
1390 (pc)))]
1391 ""
1392 {
1393- microblaze_expand_conditional_branch_reg (SImode, operands);
1394+ microblaze_expand_conditional_branch_reg (Pmode, operands);
1395 DONE;
1396 })
1397
1398@@ -2110,6 +2271,26 @@ else
1399 (label_ref (match_operand 1))
1400 (pc)))])
1401
1402+(define_insn "branch_zero64"
1403+ [(set (pc)
1404+ (if_then_else (match_operator 0 "ordered_comparison_operator"
1405+ [(match_operand 1 "register_operand" "d")
1406+ (const_int 0)])
1407+ (match_operand 2 "pc_or_label_operand" "")
1408+ (match_operand 3 "pc_or_label_operand" "")))
1409+ ]
1410+ "TARGET_MB_64"
1411+ {
1412+ if (operands[3] == pc_rtx)
1413+ return "bea%C0i%?\t%z1,%2";
1414+ else
1415+ return "bea%N0i%?\t%z1,%3";
1416+ }
1417+ [(set_attr "type" "branch")
1418+ (set_attr "mode" "none")
1419+ (set_attr "length" "4")]
1420+)
1421+
1422 (define_insn "branch_zero"
1423 [(set (pc)
1424 (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
1425@@ -2130,6 +2311,47 @@ else
1426 (set_attr "length" "4")]
1427 )
1428
1429+(define_insn "branch_compare64"
1430+ [(set (pc)
1431+ (if_then_else (match_operator 0 "cmp_op"
1432+ [(match_operand 1 "register_operand" "d")
1433+ (match_operand 2 "register_operand" "d")
1434+ ])
1435+ (label_ref (match_operand 3))
1436+ (pc)))
1437+ (clobber(reg:SI R_TMP))]
1438+ "TARGET_MB_64"
1439+ {
1440+ operands[4] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
1441+ enum rtx_code code = GET_CODE (operands[0]);
1442+
1443+ if (code == GT || code == LE)
1444+ {
1445+ output_asm_insn ("cmp\tr18,%z1,%z2", operands);
1446+ code = swap_condition (code);
1447+ }
1448+ else if (code == GTU || code == LEU)
1449+ {
1450+ output_asm_insn ("cmpu\tr18,%z1,%z2", operands);
1451+ code = swap_condition (code);
1452+ }
1453+ else if (code == GE || code == LT)
1454+ {
1455+ output_asm_insn ("cmp\tr18,%z2,%z1", operands);
1456+ }
1457+ else if (code == GEU || code == LTU)
1458+ {
1459+ output_asm_insn ("cmpu\tr18,%z2,%z1", operands);
1460+ }
1461+
1462+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), SImode, operands[4], const0_rtx);
1463+ return "bea%C0i%?\tr18,%3";
1464+ }
1465+ [(set_attr "type" "branch")
1466+ (set_attr "mode" "none")
1467+ (set_attr "length" "12")]
1468+)
1469+
1470 (define_insn "branch_compare"
1471 [(set (pc)
1472 (if_then_else (match_operator:SI 0 "cmp_op"
1473@@ -2313,7 +2535,7 @@ else
1474 ;; Indirect jumps. Jump to register values. Assuming absolute jumps
1475
1476 (define_insn "indirect_jump_internal1"
1477- [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
1478+ [(set (pc) (match_operand 0 "register_operand" "d"))]
1479 ""
1480 "bra%?\t%0"
1481 [(set_attr "type" "jump")
1482@@ -2326,7 +2548,7 @@ else
1483 (use (label_ref (match_operand 1 "" "")))]
1484 ""
1485 {
1486- gcc_assert (GET_MODE (operands[0]) == Pmode);
1487+ //gcc_assert (GET_MODE (operands[0]) == Pmode);
1488
1489 if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
1490 emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
1491@@ -2338,7 +2560,7 @@ else
1492
1493 (define_insn "tablejump_internal1"
1494 [(set (pc)
1495- (match_operand:SI 0 "register_operand" "d"))
1496+ (match_operand 0 "register_operand" "d"))
1497 (use (label_ref (match_operand 1 "" "")))]
1498 ""
1499 "bra%?\t%0 "
1500@@ -2348,9 +2570,9 @@ else
1501
1502 (define_expand "tablejump_internal3"
1503 [(parallel [(set (pc)
1504- (plus:SI (match_operand:SI 0 "register_operand" "d")
1505- (label_ref:SI (match_operand:SI 1 "" ""))))
1506- (use (label_ref:SI (match_dup 1)))])]
1507+ (plus (match_operand 0 "register_operand" "d")
1508+ (label_ref (match_operand:SI 1 "" ""))))
1509+ (use (label_ref (match_dup 1)))])]
1510 ""
1511 ""
1512 )
1513@@ -2411,7 +2633,7 @@ else
1514 (minus (reg 1) (match_operand 1 "register_operand" "")))
1515 (set (reg 1)
1516 (minus (reg 1) (match_dup 1)))]
1517- ""
1518+ "!TARGET_MB_64"
1519 {
1520 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1521 rtx reg = gen_reg_rtx (Pmode);
1522@@ -2436,7 +2658,7 @@ else
1523 (define_expand "save_stack_block"
1524 [(match_operand 0 "register_operand" "")
1525 (match_operand 1 "register_operand" "")]
1526- ""
1527+ "!TARGET_MB_64"
1528 {
1529 emit_move_insn (operands[0], operands[1]);
1530 DONE;
1531@@ -2446,7 +2668,7 @@ else
1532 (define_expand "restore_stack_block"
1533 [(match_operand 0 "register_operand" "")
1534 (match_operand 1 "register_operand" "")]
1535- ""
1536+ "!TARGET_MB_64"
1537 {
1538 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1539 rtx rtmp = gen_rtx_REG (SImode, R_TMP);
1540@@ -2493,7 +2715,7 @@ else
1541
1542 (define_insn "<optab>_internal"
1543 [(any_return)
1544- (use (match_operand:SI 0 "register_operand" ""))]
1545+ (use (match_operand 0 "register_operand" ""))]
1546 ""
1547 {
1548 if (microblaze_is_break_handler ())
1549@@ -2526,7 +2748,7 @@ else
1550 (define_expand "call"
1551 [(parallel [(call (match_operand 0 "memory_operand" "m")
1552 (match_operand 1 "" "i"))
1553- (clobber (reg:SI R_SR))
1554+ (clobber (reg R_SR))
1555 (use (match_operand 2 "" ""))
1556 (use (match_operand 3 "" ""))])]
1557 ""
1558@@ -2547,12 +2769,12 @@ else
1559
1560 if (GET_CODE (XEXP (operands[0], 0)) == UNSPEC)
1561 emit_call_insn (gen_call_internal_plt0 (operands[0], operands[1],
1562- gen_rtx_REG (SImode,
1563+ gen_rtx_REG (Pmode,
1564 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM),
1565 pic_offset_table_rtx));
1566 else
1567 emit_call_insn (gen_call_internal0 (operands[0], operands[1],
1568- gen_rtx_REG (SImode,
1569+ gen_rtx_REG (Pmode,
1570 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)));
1571
1572 DONE;
1573@@ -2562,7 +2784,7 @@ else
1574 (define_expand "call_internal0"
1575 [(parallel [(call (match_operand 0 "" "")
1576 (match_operand 1 "" ""))
1577- (clobber (match_operand:SI 2 "" ""))])]
1578+ (clobber (match_operand 2 "" ""))])]
1579 ""
1580 {
1581 }
1582@@ -2571,18 +2793,34 @@ else
1583 (define_expand "call_internal_plt0"
1584 [(parallel [(call (match_operand 0 "" "")
1585 (match_operand 1 "" ""))
1586- (clobber (match_operand:SI 2 "" ""))
1587- (use (match_operand:SI 3 "" ""))])]
1588+ (clobber (match_operand 2 "" ""))
1589+ (use (match_operand 3 "" ""))])]
1590 ""
1591 {
1592 }
1593 )
1594
1595+(define_insn "call_internal_plt_64"
1596+ [(call (mem (match_operand 0 "call_insn_plt_operand" ""))
1597+ (match_operand 1 "" "i"))
1598+ (clobber (reg R_SR))
1599+ (use (reg R_GOT))]
1600+ "flag_pic && TARGET_MB_64"
1601+ {
1602+ register rtx target2 = gen_rtx_REG (Pmode,
1603+ GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1604+ gen_rtx_CLOBBER (VOIDmode, target2);
1605+ return "brealid\tr15,%0\;%#";
1606+ }
1607+ [(set_attr "type" "call")
1608+ (set_attr "mode" "none")
1609+ (set_attr "length" "4")])
1610+
1611 (define_insn "call_internal_plt"
1612- [(call (mem (match_operand:SI 0 "call_insn_plt_operand" ""))
1613- (match_operand:SI 1 "" "i"))
1614- (clobber (reg:SI R_SR))
1615- (use (reg:SI R_GOT))]
1616+ [(call (mem (match_operand 0 "call_insn_plt_operand" ""))
1617+ (match_operand 1 "" "i"))
1618+ (clobber (reg R_SR))
1619+ (use (reg R_GOT))]
1620 "flag_pic"
1621 {
1622 register rtx target2 = gen_rtx_REG (Pmode,
1623@@ -2594,10 +2832,41 @@ else
1624 (set_attr "mode" "none")
1625 (set_attr "length" "4")])
1626
1627+(define_insn "call_internal1_64"
1628+ [(call (mem (match_operand:VOID 0 "call_insn_simple_operand" "ri"))
1629+ (match_operand 1 "" "i"))
1630+ (clobber (reg R_SR))]
1631+ "TARGET_MB_64"
1632+ {
1633+ register rtx target = operands[0];
1634+ register rtx target2 = gen_rtx_REG (Pmode,
1635+ GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1636+ if (GET_CODE (target) == SYMBOL_REF) {
1637+ if (microblaze_break_function_p (SYMBOL_REF_DECL (target))) {
1638+ gen_rtx_CLOBBER (VOIDmode, target2);
1639+ return "breaki\tr16,%0\;%#";
1640+ }
1641+ else {
1642+ gen_rtx_CLOBBER (VOIDmode, target2);
1643+ return "brealid\tr15,%0\;%#";
1644+ }
1645+ } else if (GET_CODE (target) == CONST_INT)
1646+ return "la\t%@,r0,%0\;brald\tr15,%@\;%#";
1647+ else if (GET_CODE (target) == REG)
1648+ return "brald\tr15,%0\;%#";
1649+ else {
1650+ fprintf (stderr,"Unsupported call insn\n");
1651+ return NULL;
1652+ }
1653+ }
1654+ [(set_attr "type" "call")
1655+ (set_attr "mode" "none")
1656+ (set_attr "length" "4")])
1657+
1658 (define_insn "call_internal1"
1659 [(call (mem (match_operand:VOID 0 "call_insn_simple_operand" "ri"))
1660- (match_operand:SI 1 "" "i"))
1661- (clobber (reg:SI R_SR))]
1662+ (match_operand 1 "" "i"))
1663+ (clobber (reg R_SR))]
1664 ""
1665 {
1666 register rtx target = operands[0];
1667@@ -2631,7 +2900,7 @@ else
1668 [(parallel [(set (match_operand 0 "register_operand" "=d")
1669 (call (match_operand 1 "memory_operand" "m")
1670 (match_operand 2 "" "i")))
1671- (clobber (reg:SI R_SR))
1672+ (clobber (reg R_SR))
1673 (use (match_operand 3 "" ""))])] ;; next_arg_reg
1674 ""
1675 {
1676@@ -2652,13 +2921,13 @@ else
1677 if (GET_CODE (XEXP (operands[1], 0)) == UNSPEC)
1678 emit_call_insn (gen_call_value_intern_plt0 (operands[0], operands[1],
1679 operands[2],
1680- gen_rtx_REG (SImode,
1681+ gen_rtx_REG (Pmode,
1682 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM),
1683 pic_offset_table_rtx));
1684 else
1685 emit_call_insn (gen_call_value_internal (operands[0], operands[1],
1686 operands[2],
1687- gen_rtx_REG (SImode,
1688+ gen_rtx_REG (Pmode,
1689 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)));
1690
1691 DONE;
1692@@ -2670,7 +2939,7 @@ else
1693 [(parallel [(set (match_operand 0 "" "")
1694 (call (match_operand 1 "" "")
1695 (match_operand 2 "" "")))
1696- (clobber (match_operand:SI 3 "" ""))
1697+ (clobber (match_operand 3 "" ""))
1698 ])]
1699 ""
1700 {}
1701@@ -2680,18 +2949,35 @@ else
1702 [(parallel[(set (match_operand 0 "" "")
1703 (call (match_operand 1 "" "")
1704 (match_operand 2 "" "")))
1705- (clobber (match_operand:SI 3 "" ""))
1706- (use (match_operand:SI 4 "" ""))])]
1707+ (clobber (match_operand 3 "" ""))
1708+ (use (match_operand 4 "" ""))])]
1709 "flag_pic"
1710 {}
1711 )
1712
1713+(define_insn "call_value_intern_plt_64"
1714+ [(set (match_operand:VOID 0 "register_operand" "=d")
1715+ (call (mem (match_operand 1 "call_insn_plt_operand" ""))
1716+ (match_operand 2 "" "i")))
1717+ (clobber (match_operand 3 "register_operand" "=d"))
1718+ (use (match_operand 4 "register_operand"))]
1719+ "flag_pic && TARGET_MB_64"
1720+ {
1721+ register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1722+
1723+ gen_rtx_CLOBBER (VOIDmode,target2);
1724+ return "brealid\tr15,%1\;%#";
1725+ }
1726+ [(set_attr "type" "call")
1727+ (set_attr "mode" "none")
1728+ (set_attr "length" "4")])
1729+
1730 (define_insn "call_value_intern_plt"
1731 [(set (match_operand:VOID 0 "register_operand" "=d")
1732- (call (mem (match_operand:SI 1 "call_insn_plt_operand" ""))
1733- (match_operand:SI 2 "" "i")))
1734- (clobber (match_operand:SI 3 "register_operand" "=d"))
1735- (use (match_operand:SI 4 "register_operand"))]
1736+ (call (mem (match_operand 1 "call_insn_plt_operand" ""))
1737+ (match_operand 2 "" "i")))
1738+ (clobber (match_operand 3 "register_operand" "=d"))
1739+ (use (match_operand 4 "register_operand"))]
1740 "flag_pic"
1741 {
1742 register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1743@@ -2703,11 +2989,46 @@ else
1744 (set_attr "mode" "none")
1745 (set_attr "length" "4")])
1746
1747+(define_insn "call_value_intern_64"
1748+ [(set (match_operand:VOID 0 "register_operand" "=d")
1749+ (call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
1750+ (match_operand 2 "" "i")))
1751+ (clobber (match_operand 3 "register_operand" "=d"))]
1752+ "TARGET_MB_64"
1753+ {
1754+ register rtx target = operands[1];
1755+ register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1756+
1757+ if (GET_CODE (target) == SYMBOL_REF)
1758+ {
1759+ gen_rtx_CLOBBER (VOIDmode,target2);
1760+ if (microblaze_break_function_p (SYMBOL_REF_DECL (target)))
1761+ return "breaki\tr16,%1\;%#";
1762+ else if (SYMBOL_REF_FLAGS (target) & SYMBOL_FLAG_FUNCTION)
1763+ {
1764+ return "brealid\tr15,%1\;%#";
1765+ }
1766+ else
1767+ {
1768+ return "bralid\tr15,%1\;%#";
1769+ }
1770+ }
1771+ else if (GET_CODE (target) == CONST_INT)
1772+ return "la\t%@,r0,%1\;brald\tr15,%@\;%#";
1773+ else if (GET_CODE (target) == REG)
1774+ return "brald\tr15,%1\;%#";
1775+ else
1776+ return "Unsupported call insn\n";
1777+ }
1778+ [(set_attr "type" "call")
1779+ (set_attr "mode" "none")
1780+ (set_attr "length" "4")])
1781+
1782 (define_insn "call_value_intern"
1783 [(set (match_operand:VOID 0 "register_operand" "=d")
1784 (call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
1785- (match_operand:SI 2 "" "i")))
1786- (clobber (match_operand:SI 3 "register_operand" "=d"))]
1787+ (match_operand 2 "" "i")))
1788+ (clobber (match_operand 3 "register_operand" "=d"))]
1789 ""
1790 {
1791 register rtx target = operands[1];
1792@@ -2881,7 +3202,6 @@ else
1793
1794 ;;if (!register_operand (operands[0], VOIDmode))
1795 ;; FAIL;
1796-
1797 emit_insn (gen_insv_32 (operands[0], operands[1],
1798 operands[2], operands[3]));
1799 DONE;
1800diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
1801index e9a1921ae26..9fc80b142ce 100644
1802--- a/gcc/config/microblaze/t-microblaze
1803+++ b/gcc/config/microblaze/t-microblaze
1804@@ -2,7 +2,8 @@ MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-en
1805 MULTILIB_DIRNAMES = bs m mh le m64
1806 MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
1807 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
1808-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64
1809+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian/m64
1810+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64 mxl-multiply-high
1811 MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
1812 MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
1813 MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
1814diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
1815index d0146083db6..005825f1ec5 100644
1816--- a/libgcc/config/microblaze/crti.S
1817+++ b/libgcc/config/microblaze/crti.S
1818@@ -40,7 +40,7 @@
1819
1820 .align 2
1821 __init:
1822- addik r1, r1, -8
1823+ addik r1, r1, -16
1824 sw r15, r0, r1
1825 la r11, r0, _stack
1826 mts rshr, r11
1827@@ -51,5 +51,5 @@ __init:
1828 .global __fini
1829 .align 2
1830 __fini:
1831- addik r1, r1, -8
1832+ addik r1, r1, -16
1833 sw r15, r0, r1
1834diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
1835index 2fff5ac04c7..5705eff9a4a 100644
1836--- a/libgcc/config/microblaze/crtn.S
1837+++ b/libgcc/config/microblaze/crtn.S
1838@@ -33,9 +33,9 @@
1839 .section .init, "ax"
1840 lw r15, r0, r1
1841 rtsd r15, 8
1842- addik r1, r1, 8
1843+ addik r1, r1, 16
1844
1845 .section .fini, "ax"
1846 lw r15, r0, r1
1847 rtsd r15, 8
1848- addik r1, r1, 8
1849+ addik r1, r1, 16
1850diff --git a/libgcc/config/microblaze/divdi3.S b/libgcc/config/microblaze/divdi3.S
1851new file mode 100644
1852index 00000000000..d37bf5165c6
1853--- /dev/null
1854+++ b/libgcc/config/microblaze/divdi3.S
1855@@ -0,0 +1,98 @@
1856+###################################-
1857+#
1858+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
1859+#
1860+# Contributed by Michael Eager <eager@eagercon.com>.
1861+#
1862+# This file is free software; you can redistribute it and/or modify it
1863+# under the terms of the GNU General Public License as published by the
1864+# Free Software Foundation; either version 3, or (at your option) any
1865+# later version.
1866+#
1867+# GCC is distributed in the hope that it will be useful, but WITHOUT
1868+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1869+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1870+# License for more details.
1871+#
1872+# Under Section 7 of GPL version 3, you are granted additional
1873+# permissions described in the GCC Runtime Library Exception, version
1874+# 3.1, as published by the Free Software Foundation.
1875+#
1876+# You should have received a copy of the GNU General Public License and
1877+# a copy of the GCC Runtime Library Exception along with this program;
1878+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1879+# <http://www.gnu.org/licenses/>.
1880+#
1881+# divdi3.S
1882+#
1883+# Divide operation for 32 bit integers.
1884+# Input : Dividend in Reg r5
1885+# Divisor in Reg r6
1886+# Output: Result in Reg r3
1887+#
1888+#######################################
1889+
1890+#ifdef __arch64__
1891+ .globl __divdi3
1892+ .ent __divdi3
1893+ .type __divdi3,@function
1894+__divdi3:
1895+ .frame r1,0,r15
1896+
1897+ ADDLIK r1,r1,-32
1898+ SLI r28,r1,0
1899+ SLI r29,r1,8
1900+ SLI r30,r1,16
1901+ SLI r31,r1,24
1902+
1903+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
1904+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
1905+ XORL r28,r5,r6 # Get the sign of the result
1906+ BEALGEI r5,$LaR5_Pos
1907+ RSUBLI r5,r5,0 # Make r5 positive
1908+$LaR5_Pos:
1909+ BEALGEI r6,$LaR6_Pos
1910+ RSUBLI r6,r6,0 # Make r6 positive
1911+$LaR6_Pos:
1912+ ADDLIK r30,r0,0 # Clear mod
1913+ ADDLIK r3,r0,0 # clear div
1914+ ADDLIK r29,r0,64 # Initialize the loop count
1915+
1916+ # First part try to find the first '1' in the r5
1917+$LaDIV0:
1918+ BEALLTI r5,$LaDIV2 # This traps r5 == 0x80000000
1919+$LaDIV1:
1920+ ADDL r5,r5,r5 # left shift logical r5
1921+ ADDLIK r29,r29,-1
1922+ BEALGTI r5,$LaDIV1
1923+$LaDIV2:
1924+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
1925+ ADDLC r30,r30,r30 # Move that bit into the Mod register
1926+ RSUBL r31,r6,r30 # Try to subtract (r30 a r6)
1927+ BEALLTI r31,$LaMOD_TOO_SMALL
1928+ ORL r30,r0,r31 # Move the r31 to mod since the result was positive
1929+ ADDLIK r3,r3,1
1930+$LaMOD_TOO_SMALL:
1931+ ADDLIK r29,r29,-1
1932+ BEALEQi r29,$LaLOOP_END
1933+ ADDL r3,r3,r3 # Shift in the '1' into div
1934+ BREAI $LaDIV2 # Div2
1935+$LaLOOP_END:
1936+ BEALGEI r28,$LaRETURN_HERE
1937+ RSUBLI r3,r3,0 # Negate the result
1938+ BREAI $LaRETURN_HERE
1939+$LaDiv_By_Zero:
1940+$LaResult_Is_Zero:
1941+ ORL r3,r0,r0 # set result to 0
1942+$LaRETURN_HERE:
1943+# Restore values of CSRs and that of r3 and the divisor and the dividend
1944+ LLI r28,r1,0
1945+ LLI r29,r1,8
1946+ LLI r30,r1,16
1947+ LLI r31,r1,24
1948+ ADDLIK r1,r1,32
1949+ RTSD r15,8
1950+ nop
1951+.end __divdi3
1952+ .size __divdi3, . - __divdi3
1953+#endif
1954diff --git a/libgcc/config/microblaze/divdi3_table.c b/libgcc/config/microblaze/divdi3_table.c
1955new file mode 100644
1956index 00000000000..80962597ea5
1957--- /dev/null
1958+++ b/libgcc/config/microblaze/divdi3_table.c
1959@@ -0,0 +1,62 @@
1960+/* Table for software lookup divide for Xilinx MicroBlaze.
1961+
1962+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
1963+
1964+ Contributed by Michael Eager <eager@eagercon.com>.
1965+
1966+ This file is free software; you can redistribute it and/or modify it
1967+ under the terms of the GNU General Public License as published by the
1968+ Free Software Foundation; either version 3, or (at your option) any
1969+ later version.
1970+
1971+ GCC is distributed in the hope that it will be useful, but WITHOUT
1972+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1973+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1974+ License for more details.
1975+
1976+ Under Section 7 of GPL version 3, you are granted additional
1977+ permissions described in the GCC Runtime Library Exception, version
1978+ 3.1, as published by the Free Software Foundation.
1979+
1980+ You should have received a copy of the GNU General Public License and
1981+ a copy of the GCC Runtime Library Exception along with this program;
1982+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1983+ <http://www.gnu.org/licenses/>. */
1984+
1985+
1986+unsigned char _divdi3_table[] =
1987+{
1988+ 0, 0/1, 0/2, 0/3, 0/4, 0/5, 0/6, 0/7,
1989+ 0/8, 0/9, 0/10, 0/11, 0/12, 0/13, 0/14, 0/15,
1990+ 0, 1/1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7,
1991+ 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15,
1992+ 0, 2/1, 2/2, 2/3, 2/4, 2/5, 2/6, 2/7,
1993+ 2/8, 2/9, 2/10, 2/11, 2/12, 2/13, 2/14, 2/15,
1994+ 0, 3/1, 3/2, 3/3, 3/4, 3/5, 3/6, 3/7,
1995+ 3/8, 3/9, 3/10, 3/11, 3/12, 3/13, 3/14, 3/15,
1996+ 0, 4/1, 4/2, 4/3, 4/4, 4/5, 4/6, 4/7,
1997+ 4/8, 4/9, 4/10, 4/11, 4/12, 4/13, 4/14, 4/15,
1998+ 0, 5/1, 5/2, 5/3, 5/4, 5/5, 5/6, 5/7,
1999+ 5/8, 5/9, 5/10, 5/11, 5/12, 5/13, 5/14, 5/15,
2000+ 0, 6/1, 6/2, 6/3, 6/4, 6/5, 6/6, 6/7,
2001+ 6/8, 6/9, 6/10, 6/11, 6/12, 6/13, 6/14, 6/15,
2002+ 0, 7/1, 7/2, 7/3, 7/4, 7/5, 7/6, 7/7,
2003+ 7/8, 7/9, 7/10, 7/11, 7/12, 7/13, 7/14, 7/15,
2004+ 0, 8/1, 8/2, 8/3, 8/4, 8/5, 8/6, 8/7,
2005+ 8/8, 8/9, 8/10, 8/11, 8/12, 8/13, 8/14, 8/15,
2006+ 0, 9/1, 9/2, 9/3, 9/4, 9/5, 9/6, 9/7,
2007+ 9/8, 9/9, 9/10, 9/11, 9/12, 9/13, 9/14, 9/15,
2008+ 0, 10/1, 10/2, 10/3, 10/4, 10/5, 10/6, 10/7,
2009+ 10/8, 10/9, 10/10, 10/11, 10/12, 10/13, 10/14, 10/15,
2010+ 0, 11/1, 11/2, 11/3, 11/4, 11/5, 11/6, 11/7,
2011+ 11/8, 11/9, 11/10, 11/11, 11/12, 11/13, 11/14, 11/15,
2012+ 0, 12/1, 12/2, 12/3, 12/4, 12/5, 12/6, 12/7,
2013+ 12/8, 12/9, 12/10, 12/11, 12/12, 12/13, 12/14, 12/15,
2014+ 0, 13/1, 13/2, 13/3, 13/4, 13/5, 13/6, 13/7,
2015+ 13/8, 13/9, 13/10, 13/11, 13/12, 13/13, 13/14, 13/15,
2016+ 0, 14/1, 14/2, 14/3, 14/4, 14/5, 14/6, 14/7,
2017+ 14/8, 14/9, 14/10, 14/11, 14/12, 14/13, 14/14, 14/15,
2018+ 0, 15/1, 15/2, 15/3, 15/4, 15/5, 15/6, 15/7,
2019+ 15/8, 15/9, 15/10, 15/11, 15/12, 15/13, 15/14, 15/15,
2020+};
2021+
2022diff --git a/libgcc/config/microblaze/moddi3.S b/libgcc/config/microblaze/moddi3.S
2023new file mode 100644
2024index 00000000000..5d3f7c03fc8
2025--- /dev/null
2026+++ b/libgcc/config/microblaze/moddi3.S
2027@@ -0,0 +1,97 @@
2028+###################################
2029+#
2030+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2031+#
2032+# Contributed by Michael Eager <eager@eagercon.com>.
2033+#
2034+# This file is free software; you can redistribute it and/or modify it
2035+# under the terms of the GNU General Public License as published by the
2036+# Free Software Foundation; either version 3, or (at your option) any
2037+# later version.
2038+#
2039+# GCC is distributed in the hope that it will be useful, but WITHOUT
2040+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2041+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2042+# License for more details.
2043+#
2044+# Under Section 7 of GPL version 3, you are granted additional
2045+# permissions described in the GCC Runtime Library Exception, version
2046+# 3.1, as published by the Free Software Foundation.
2047+#
2048+# You should have received a copy of the GNU General Public License and
2049+# a copy of the GCC Runtime Library Exception along with this program;
2050+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2051+# <http://www.gnu.org/licenses/>.
2052+#
2053+# moddi3.S
2054+#
2055+# modulo operation for 32 bit integers.
2056+# Input : op1 in Reg r5
2057+# op2 in Reg r6
2058+# Output: op1 mod op2 in Reg r3
2059+#
2060+#######################################
2061+
2062+#ifdef __arch64__
2063+ .globl __moddi3
2064+ .ent __moddi3
2065+ .type __moddi3,@function
2066+__moddi3:
2067+ .frame r1,0,r15
2068+
2069+ addlik r1,r1,-32
2070+ sli r28,r1,0
2071+ sli r29,r1,8
2072+ sli r30,r1,16
2073+ sli r31,r1,32
2074+
2075+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2076+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2077+ ADDL r28,r5,r0 # Get the sign of the result [ Depends only on the first arg]
2078+ BEALGEI r5,$LaR5_Pos
2079+ RSUBLI r5,r5,0 # Make r5 positive
2080+$LaR5_Pos:
2081+ BEALGEI r6,$LaR6_Pos
2082+ RSUBLI r6,r6,0 # Make r6 positive
2083+$LaR6_Pos:
2084+ ADDLIK r3,r0,0 # Clear mod
2085+ ADDLIK r30,r0,0 # clear div
2086+ ADDLIK r29,r0,64 # Initialize the loop count
2087+ BEALLTI r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
2088+ # the first bit search.
2089+ # First part try to find the first '1' in the r5
2090+$LaDIV1:
2091+ ADDL r5,r5,r5 # left shift logical r5
2092+ ADDLIK r29,r29,-1
2093+ BEALGEI r5,$LaDIV1 #
2094+$LaDIV2:
2095+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2096+ ADDLC r3,r3,r3 # Move that bit into the Mod register
2097+ rSUBL r31,r6,r3 # Try to subtract (r30 a r6)
2098+ BEALLTi r31,$LaMOD_TOO_SMALL
2099+ ORL r3,r0,r31 # Move the r31 to mod since the result was positive
2100+ ADDLIK r30,r30,1
2101+$LaMOD_TOO_SMALL:
2102+ ADDLIK r29,r29,-1
2103+ BEALEQi r29,$LaLOOP_END
2104+ ADDL r30,r30,r30 # Shift in the '1' into div
2105+ BREAI $LaDIV2 # Div2
2106+$LaLOOP_END:
2107+ BEALGEI r28,$LaRETURN_HERE
2108+ rsubli r3,r3,0 # Negate the result
2109+ BREAI $LaRETURN_HERE
2110+$LaDiv_By_Zero:
2111+$LaResult_Is_Zero:
2112+ orl r3,r0,r0 # set result to 0 [Both mod as well as div are 0]
2113+$LaRETURN_HERE:
2114+# Restore values of CSRs and that of r3 and the divisor and the dividend
2115+ lli r28,r1,0
2116+ lli r29,r1,8
2117+ lli r30,r1,16
2118+ lli r31,r1,24
2119+ addlik r1,r1,32
2120+ rtsd r15,8
2121+ nop
2122+ .end __moddi3
2123+ .size __moddi3, . - __moddi3
2124+#endif
2125diff --git a/libgcc/config/microblaze/muldi3.S b/libgcc/config/microblaze/muldi3.S
2126new file mode 100644
2127index 00000000000..567784197d3
2128--- /dev/null
2129+++ b/libgcc/config/microblaze/muldi3.S
2130@@ -0,0 +1,73 @@
2131+/*###################################-*-asm*-
2132+#
2133+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2134+#
2135+# Contributed by Michael Eager <eager@eagercon.com>.
2136+#
2137+# This file is free software; you can redistribute it and/or modify it
2138+# under the terms of the GNU General Public License as published by the
2139+# Free Software Foundation; either version 3, or (at your option) any
2140+# later version.
2141+#
2142+# GCC is distributed in the hope that it will be useful, but WITHOUT
2143+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2144+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2145+# License for more details.
2146+#
2147+# Under Section 7 of GPL version 3, you are granted additional
2148+# permissions described in the GCC Runtime Library Exception, version
2149+# 3.1, as published by the Free Software Foundation.
2150+#
2151+# You should have received a copy of the GNU General Public License and
2152+# a copy of the GCC Runtime Library Exception along with this program;
2153+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2154+# <http://www.gnu.org/licenses/>.
2155+#
2156+# muldi3.S
2157+#
2158+# Multiply operation for 32 bit integers.
2159+# Input : Operand1 in Reg r5
2160+# Operand2 in Reg r6
2161+# Output: Result [op1 * op2] in Reg r3
2162+#
2163+#######################################*/
2164+
2165+#ifdef __arch64__
2166+ .globl __muldi3
2167+ .ent __muldi3
2168+ .type __muldi3,@function
2169+__muldi3:
2170+ .frame r1,0,r15
2171+ addl r3,r0,r0
2172+ BEALEQI r5,$L_Result_Is_Zero # Multiply by Zero
2173+ BEALEQI r6,$L_Result_Is_Zero # Multiply by Zero
2174+ XORL r4,r5,r6 # Get the sign of the result
2175+ BEALGEI r5,$L_R5_Pos
2176+ RSUBLI r5,r5,0 # Make r5 positive
2177+$L_R5_Pos:
2178+ BEALGEI r6,$L_R6_Pos
2179+ RSUBLI r6,r6,0 # Make r6 positive
2180+$L_R6_Pos:
2181+ breai $L1
2182+$L2:
2183+ addl r5,r5,r5
2184+$L1:
2185+ srll r6,r6
2186+ addlc r7,r0,r0
2187+ bealeqi r7,$L2
2188+ addl r3,r3,r5
2189+ bealnei r6,$L2
2190+ beallti r4,$L_NegateResult
2191+ rtsd r15,8
2192+ nop
2193+$L_NegateResult:
2194+ rsubl r3,r3,r0
2195+ rtsd r15,8
2196+ nop
2197+$L_Result_Is_Zero:
2198+ addli r3,r0,0
2199+ rtsd r15,8
2200+ nop
2201+ .end __muldi3
2202+ .size __muldi3, . - __muldi3
2203+#endif
2204diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
2205index 8d954a49575..35021b24b7d 100644
2206--- a/libgcc/config/microblaze/t-microblaze
2207+++ b/libgcc/config/microblaze/t-microblaze
2208@@ -1,11 +1,16 @@
2209-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
2210+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3 \
2211+ _divdi3 _moddi3 _muldi3 _udivdi3 _umoddi3
2212
2213 LIB2ADD += \
2214 $(srcdir)/config/microblaze/divsi3.S \
2215+ $(srcdir)/config/microblaze/divdi3.S \
2216 $(srcdir)/config/microblaze/modsi3.S \
2217- $(srcdir)/config/microblaze/muldi3_hard.S \
2218+ $(srcdir)/config/microblaze/moddi3.S \
2219 $(srcdir)/config/microblaze/mulsi3.S \
2220+ $(srcdir)/config/microblaze/muldi3.S \
2221 $(srcdir)/config/microblaze/stack_overflow_exit.S \
2222 $(srcdir)/config/microblaze/udivsi3.S \
2223+ $(srcdir)/config/microblaze/udivdi3.S \
2224 $(srcdir)/config/microblaze/umodsi3.S \
2225- $(srcdir)/config/microblaze/divsi3_table.c
2226+ $(srcdir)/config/microblaze/umoddi3.S \
2227+ $(srcdir)/config/microblaze/divsi3_table.c \
2228diff --git a/libgcc/config/microblaze/udivdi3.S b/libgcc/config/microblaze/udivdi3.S
2229new file mode 100644
2230index 00000000000..c210fbc7128
2231--- /dev/null
2232+++ b/libgcc/config/microblaze/udivdi3.S
2233@@ -0,0 +1,107 @@
2234+###################################-
2235+#
2236+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2237+#
2238+# Contributed by Michael Eager <eager@eagercon.com>.
2239+#
2240+# This file is free software; you can redistribute it and/or modify it
2241+# under the terms of the GNU General Public License as published by the
2242+# Free Software Foundation; either version 3, or (at your option) any
2243+# later version.
2244+#
2245+# GCC is distributed in the hope that it will be useful, but WITHOUT
2246+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2247+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2248+# License for more details.
2249+#
2250+# Under Section 7 of GPL version 3, you are granted additional
2251+# permissions described in the GCC Runtime Library Exception, version
2252+# 3.1, as published by the Free Software Foundation.
2253+#
2254+# You should have received a copy of the GNU General Public License and
2255+# a copy of the GCC Runtime Library Exception along with this program;
2256+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2257+# <http://www.gnu.org/licenses/>.
2258+#
2259+# udivdi3.S
2260+#
2261+# Unsigned divide operation.
2262+# Input : Divisor in Reg r5
2263+# Dividend in Reg r6
2264+# Output: Result in Reg r3
2265+#
2266+#######################################
2267+
2268+#ifdef __arch64__
2269+ .globl __udivdi3
2270+ .ent __udivdi3
2271+ .type __udivdi3,@function
2272+__udivdi3:
2273+ .frame r1,0,r15
2274+
2275+ ADDlIK r1,r1,-24
2276+ SLI r29,r1,0
2277+ SLI r30,r1,8
2278+ SLI r31,r1,16
2279+
2280+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2281+ ADDLIK r30,r0,0 # Clear mod
2282+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2283+ ADDLIK r29,r0,64 # Initialize the loop count
2284+
2285+ # Check if r6 and r5 are equal # if yes, return 1
2286+ RSUBL r18,r5,r6
2287+ ADDLIK r3,r0,1
2288+ BEALEQI r18,$LaRETURN_HERE
2289+
2290+ # Check if (uns)r6 is greater than (uns)r5. In that case, just return 0
2291+ XORL r18,r5,r6
2292+ ADDL r3,r0,r0 # We would anyways clear r3
2293+ BEALGEI r18,$LRSUBL
2294+ BEALLTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
2295+ BREAI $LCheckr6
2296+$LRSUBL:
2297+ RSUBL r18,r6,r5 # MICROBLAZEcmp
2298+ BEALLTI r18,$LaRETURN_HERE
2299+
2300+ # If r6 [bit 31] is set, then return result as 1
2301+$LCheckr6:
2302+ BEALGTI r6,$LaDIV0
2303+ ADDLIK r3,r0,1
2304+ BREAI $LaRETURN_HERE
2305+
2306+ # First part try to find the first '1' in the r5
2307+$LaDIV0:
2308+ BEALLTI r5,$LaDIV2
2309+$LaDIV1:
2310+ ADDL r5,r5,r5 # left shift logical r5
2311+ ADDLIK r29,r29,-1
2312+ BEALGTI r5,$LaDIV1
2313+$LaDIV2:
2314+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2315+ ADDLC r30,r30,r30 # Move that bit into the Mod register
2316+ RSUBL r31,r6,r30 # Try to subtract (r30 a r6)
2317+ BEALLTI r31,$LaMOD_TOO_SMALL
2318+ ORL r30,r0,r31 # Move the r31 to mod since the result was positive
2319+ ADDLIK r3,r3,1
2320+$LaMOD_TOO_SMALL:
2321+ ADDLIK r29,r29,-1
2322+ BEALEQi r29,$LaLOOP_END
2323+ ADDL r3,r3,r3 # Shift in the '1' into div
2324+ BREAI $LaDIV2 # Div2
2325+$LaLOOP_END:
2326+ BREAI $LaRETURN_HERE
2327+$LaDiv_By_Zero:
2328+$LaResult_Is_Zero:
2329+ ORL r3,r0,r0 # set result to 0
2330+$LaRETURN_HERE:
2331+ # Restore values of CSRs and that of r3 and the divisor and the dividend
2332+ LLI r29,r1,0
2333+ LLI r30,r1,8
2334+ LLI r31,r1,16
2335+ ADDLIK r1,r1,24
2336+ RTSD r15,8
2337+ NOP
2338+ .end __udivdi3
2339+ .size __udivdi3, . - __udivdi3
2340+#endif
2341diff --git a/libgcc/config/microblaze/umoddi3.S b/libgcc/config/microblaze/umoddi3.S
2342new file mode 100644
2343index 00000000000..7f5cd23f9a1
2344--- /dev/null
2345+++ b/libgcc/config/microblaze/umoddi3.S
2346@@ -0,0 +1,110 @@
2347+###################################
2348+#
2349+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2350+#
2351+# Contributed by Michael Eager <eager@eagercon.com>.
2352+#
2353+# This file is free software; you can redistribute it and/or modify it
2354+# under the terms of the GNU General Public License as published by the
2355+# Free Software Foundation; either version 3, or (at your option) any
2356+# later version.
2357+#
2358+# GCC is distributed in the hope that it will be useful, but WITHOUT
2359+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2360+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2361+# License for more details.
2362+#
2363+# Under Section 7 of GPL version 3, you are granted additional
2364+# permissions described in the GCC Runtime Library Exception, version
2365+# 3.1, as published by the Free Software Foundation.
2366+#
2367+# You should have received a copy of the GNU General Public License and
2368+# a copy of the GCC Runtime Library Exception along with this program;
2369+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2370+# <http://www.gnu.org/licenses/>.
2371+#
2372+# umoddi3.S
2373+#
2374+# Unsigned modulo operation for 32 bit integers.
2375+# Input : op1 in Reg r5
2376+# op2 in Reg r6
2377+# Output: op1 mod op2 in Reg r3
2378+#
2379+#######################################
2380+
2381+#ifdef __arch64__
2382+ .globl __umoddi3
2383+ .ent __umoddi3
2384+ .type __umoddi3,@function
2385+__umoddi3:
2386+ .frame r1,0,r15
2387+
2388+ addlik r1,r1,-24
2389+ sli r29,r1,0
2390+ sli r30,r1,8
2391+ sli r31,r1,16
2392+
2393+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2394+ ADDLIK r3,r0,0 # Clear div
2395+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2396+ ADDLIK r30,r0,0 # clear mod
2397+ ADDLIK r29,r0,64 # Initialize the loop count
2398+
2399+# Check if r6 and r5 are equal # if yes, return 0
2400+ rsubl r18,r5,r6
2401+ bealeqi r18,$LaRETURN_HERE
2402+
2403+# Check if (uns)r6 is greater than (uns)r5. In that case, just return r5
2404+ xorl r18,r5,r6
2405+ addlik r3,r5,0
2406+ bealgei r18,$LRSUB
2407+ beallti r6,$LaRETURN_HERE
2408+ breai $LCheckr6
2409+$LRSUB:
2410+ rsubl r18,r5,r6 # MICROBLAZEcmp
2411+ bealgti r18,$LaRETURN_HERE
2412+
2413+# If r6 [bit 31] is set, then return result as r5-r6
2414+$LCheckr6:
2415+ addlik r3,r0,0
2416+ bealgti r6,$LaDIV0
2417+ addlik r18,r0,0x7fffffff
2418+ andl r5,r5,r18
2419+ andl r6,r6,r18
2420+ breaid $LaRETURN_HERE
2421+ rsubl r3,r6,r5
2422+# First part: try to find the first '1' in the r5
2423+$LaDIV0:
2424+ BEALLTI r5,$LaDIV2
2425+$LaDIV1:
2426+ ADDL r5,r5,r5 # left shift logical r5
2427+ ADDLIK r29,r29,-1
2428+ BEALGEI r5,$LaDIV1 #
2429+$LaDIV2:
2430+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2431+ ADDLC r3,r3,r3 # Move that bit into the Mod register
2432+ rSUBL r31,r6,r3 # Try to subtract (r3 a r6)
2433+ BEALLTi r31,$LaMOD_TOO_SMALL
2434+ ORL r3,r0,r31 # Move the r31 to mod since the result was positive
2435+ ADDLIK r30,r30,1
2436+$LaMOD_TOO_SMALL:
2437+ ADDLIK r29,r29,-1
2438+ BEALEQi r29,$LaLOOP_END
2439+ ADDL r30,r30,r30 # Shift in the '1' into div
2440+ BREAI $LaDIV2 # Div2
2441+$LaLOOP_END:
2442+ BREAI $LaRETURN_HERE
2443+$LaDiv_By_Zero:
2444+$LaResult_Is_Zero:
2445+ orl r3,r0,r0 # set result to 0
2446+$LaRETURN_HERE:
2447+# Restore values of CSRs and that of r3 and the divisor and the dividend
2448+ lli r29,r1,0
2449+ lli r30,r1,8
2450+ lli r31,r1,16
2451+ addlik r1,r1,24
2452+ rtsd r15,8
2453+ nop
2454+.end __umoddi3
2455+ .size __umoddi3, . - __umoddi3
2456+#endif
2457--
24582.17.1
2459
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0031-re-arrangement-of-the-compare-branches.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0031-re-arrangement-of-the-compare-branches.patch
new file mode 100644
index 00000000..0113c65d
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0031-re-arrangement-of-the-compare-branches.patch
@@ -0,0 +1,268 @@
1From 67d89be9ace8f658354fb1378e986451ef435d60 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 3 Aug 2018 15:41:39 +0530
4Subject: [PATCH 31/54] re-arrangement of the compare branches
5
6---
7 gcc/config/microblaze/microblaze.c | 28 ++----
8 gcc/config/microblaze/microblaze.md | 141 +++++++++++++---------------
9 2 files changed, 73 insertions(+), 96 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
12index 3c815444574..046bfd05558 100644
13--- a/gcc/config/microblaze/microblaze.c
14+++ b/gcc/config/microblaze/microblaze.c
15@@ -3697,11 +3697,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
16 {
17 comp_reg = cmp_op0;
18 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
19- if (mode == Pmode)
20- emit_jump_insn (gen_condjump (condition, label1));
21- else
22- emit_jump_insn (gen_long_condjump (condition, label1));
23-
24+ emit_jump_insn (gen_condjump (condition, label1));
25 }
26
27 else if (code == EQ || code == NE)
28@@ -3712,10 +3708,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
29 else
30 emit_insn (gen_xordi3 (comp_reg, cmp_op0, cmp_op1));
31 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
32- if (mode == SImode)
33- emit_jump_insn (gen_condjump (condition, label1));
34- else
35- emit_jump_insn (gen_long_condjump (condition, label1));
36+ emit_jump_insn (gen_condjump (condition, label1));
37 }
38 else
39 {
40@@ -3748,10 +3741,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
41 comp_reg = cmp_op0;
42 condition = gen_rtx_fmt_ee (signed_condition (code),
43 mode, comp_reg, const0_rtx);
44- if (mode == SImode)
45- emit_jump_insn (gen_condjump (condition, label1));
46- else
47- emit_jump_insn (gen_long_condjump (condition, label1));
48+ emit_jump_insn (gen_condjump (condition, label1));
49 }
50 else if (code == EQ)
51 {
52@@ -3766,10 +3756,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
53 cmp_op1));
54 }
55 condition = gen_rtx_EQ (mode, comp_reg, const0_rtx);
56- if (mode == SImode)
57- emit_jump_insn (gen_condjump (condition, label1));
58- else
59- emit_jump_insn (gen_long_condjump (condition, label1));
60+ emit_jump_insn (gen_condjump (condition, label1));
61
62 }
63 else if (code == NE)
64@@ -3785,10 +3772,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
65 cmp_op1));
66 }
67 condition = gen_rtx_NE (mode, comp_reg, const0_rtx);
68- if (mode == SImode)
69- emit_jump_insn (gen_condjump (condition, label1));
70- else
71- emit_jump_insn (gen_long_condjump (condition, label1));
72+ emit_jump_insn (gen_condjump (condition, label1));
73 }
74 else
75 {
76@@ -3830,7 +3814,7 @@ microblaze_expand_conditional_branch_df (rtx operands[])
77
78 emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
79 condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
80- emit_jump_insn (gen_long_condjump (condition, operands[3]));
81+ emit_jump_insn (gen_condjump (condition, operands[3]));
82 }
83
84 /* Implement TARGET_FRAME_POINTER_REQUIRED. */
85diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
86index 33a8b12ef3b..cfe9e5312d1 100644
87--- a/gcc/config/microblaze/microblaze.md
88+++ b/gcc/config/microblaze/microblaze.md
89@@ -2271,7 +2271,27 @@ else
90 (label_ref (match_operand 1))
91 (pc)))])
92
93-(define_insn "branch_zero64"
94+(define_insn "branch_zero_64"
95+ [(set (pc)
96+ (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
97+ [(match_operand:SI 1 "register_operand" "d")
98+ (const_int 0)])
99+ (match_operand:SI 2 "pc_or_label_operand" "")
100+ (match_operand:SI 3 "pc_or_label_operand" "")))
101+ ]
102+ "TARGET_MB_64"
103+ {
104+ if (operands[3] == pc_rtx)
105+ return "bea%C0i%?\t%z1,%2";
106+ else
107+ return "bea%N0i%?\t%z1,%3";
108+ }
109+ [(set_attr "type" "branch")
110+ (set_attr "mode" "none")
111+ (set_attr "length" "4")]
112+)
113+
114+(define_insn "long_branch_zero"
115 [(set (pc)
116 (if_then_else (match_operator 0 "ordered_comparison_operator"
117 [(match_operand 1 "register_operand" "d")
118@@ -2282,9 +2302,9 @@ else
119 "TARGET_MB_64"
120 {
121 if (operands[3] == pc_rtx)
122- return "bea%C0i%?\t%z1,%2";
123+ return "beal%C0i%?\t%z1,%2";
124 else
125- return "bea%N0i%?\t%z1,%3";
126+ return "beal%N0i%?\t%z1,%3";
127 }
128 [(set_attr "type" "branch")
129 (set_attr "mode" "none")
130@@ -2313,9 +2333,9 @@ else
131
132 (define_insn "branch_compare64"
133 [(set (pc)
134- (if_then_else (match_operator 0 "cmp_op"
135- [(match_operand 1 "register_operand" "d")
136- (match_operand 2 "register_operand" "d")
137+ (if_then_else (match_operator:SI 0 "cmp_op"
138+ [(match_operand:SI 1 "register_operand" "d")
139+ (match_operand:SI 2 "register_operand" "d")
140 ])
141 (label_ref (match_operand 3))
142 (pc)))
143@@ -2352,6 +2372,47 @@ else
144 (set_attr "length" "12")]
145 )
146
147+(define_insn "long_branch_compare"
148+ [(set (pc)
149+ (if_then_else (match_operator 0 "cmp_op"
150+ [(match_operand 1 "register_operand" "d")
151+ (match_operand 2 "register_operand" "d")
152+ ])
153+ (label_ref (match_operand 3))
154+ (pc)))
155+ (clobber(reg:DI R_TMP))]
156+ "TARGET_MB_64"
157+ {
158+ operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
159+ enum rtx_code code = GET_CODE (operands[0]);
160+
161+ if (code == GT || code == LE)
162+ {
163+ output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
164+ code = swap_condition (code);
165+ }
166+ else if (code == GTU || code == LEU)
167+ {
168+ output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
169+ code = swap_condition (code);
170+ }
171+ else if (code == GE || code == LT)
172+ {
173+ output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
174+ }
175+ else if (code == GEU || code == LTU)
176+ {
177+ output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
178+ }
179+
180+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
181+ return "beal%C0i%?\tr18,%3";
182+ }
183+ [(set_attr "type" "branch")
184+ (set_attr "mode" "none")
185+ (set_attr "length" "12")]
186+)
187+
188 (define_insn "branch_compare"
189 [(set (pc)
190 (if_then_else (match_operator:SI 0 "cmp_op"
191@@ -2434,74 +2495,6 @@ else
192
193 })
194
195-;; Used to implement comparison instructions
196-(define_expand "long_condjump"
197- [(set (pc)
198- (if_then_else (match_operand 0)
199- (label_ref (match_operand 1))
200- (pc)))])
201-
202-(define_insn "long_branch_zero"
203- [(set (pc)
204- (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
205- [(match_operand:DI 1 "register_operand" "d")
206- (const_int 0)])
207- (match_operand:DI 2 "pc_or_label_operand" "")
208- (match_operand:DI 3 "pc_or_label_operand" "")))
209- ]
210- "TARGET_MB_64"
211- {
212- if (operands[3] == pc_rtx)
213- return "beal%C0i%?\t%z1,%2";
214- else
215- return "beal%N0i%?\t%z1,%3";
216- }
217- [(set_attr "type" "branch")
218- (set_attr "mode" "none")
219- (set_attr "length" "4")]
220-)
221-
222-(define_insn "long_branch_compare"
223- [(set (pc)
224- (if_then_else (match_operator:DI 0 "cmp_op"
225- [(match_operand:DI 1 "register_operand" "d")
226- (match_operand:DI 2 "register_operand" "d")
227- ])
228- (label_ref (match_operand 3))
229- (pc)))
230- (clobber(reg:DI R_TMP))]
231- "TARGET_MB_64"
232- {
233- operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
234- enum rtx_code code = GET_CODE (operands[0]);
235-
236- if (code == GT || code == LE)
237- {
238- output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
239- code = swap_condition (code);
240- }
241- else if (code == GTU || code == LEU)
242- {
243- output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
244- code = swap_condition (code);
245- }
246- else if (code == GE || code == LT)
247- {
248- output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
249- }
250- else if (code == GEU || code == LTU)
251- {
252- output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
253- }
254-
255- operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
256- return "beal%C0i%?\tr18,%3";
257- }
258- [(set_attr "type" "branch")
259- (set_attr "mode" "none")
260- (set_attr "length" "12")]
261-)
262-
263 ;;----------------------------------------------------------------
264 ;; Unconditional branches
265 ;;----------------------------------------------------------------
266--
2672.17.1
268
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0032-Patch-Microblaze-previous-commit-broke-the-handling-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0032-Patch-Microblaze-previous-commit-broke-the-handling-.patch
new file mode 100644
index 00000000..b74c79ec
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0032-Patch-Microblaze-previous-commit-broke-the-handling-.patch
@@ -0,0 +1,28 @@
1From 410348f4fd9b641afa24e6c6b6a62a4c74d18862 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 8 Aug 2018 17:37:26 +0530
4Subject: [PATCH 32/54] [Patch,Microblaze] : previous commit broke the
5 handling of SI Branch compare for Microblaze 32-bit..
6
7---
8 gcc/config/microblaze/microblaze.md | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index cfe9e5312d1..592757baf2f 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -2227,8 +2227,8 @@ else
16 (define_expand "cbranchsi4"
17 [(set (pc)
18 (if_then_else (match_operator 0 "ordered_comparison_operator"
19- [(match_operand 1 "register_operand")
20- (match_operand 2 "arith_operand" "I,i")])
21+ [(match_operand:SI 1 "register_operand")
22+ (match_operand:SI 2 "arith_operand" "I,i")])
23 (label_ref (match_operand 3 ""))
24 (pc)))]
25 ""
26--
272.17.1
28
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0033-Patch-Microblaze-Support-of-multilibs-with-m64.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0033-Patch-Microblaze-Support-of-multilibs-with-m64.patch
new file mode 100644
index 00000000..353bfa90
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0033-Patch-Microblaze-Support-of-multilibs-with-m64.patch
@@ -0,0 +1,73 @@
1From 802c136f1a41ebfed3b25419e48331038f284e2b Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 11 Sep 2018 13:43:48 +0530
4Subject: [PATCH 33/54] [Patch, Microblaze] : Support of multilibs with m64 ...
5
6---
7 gcc/config/microblaze/microblaze-c.c | 1 +
8 gcc/config/microblaze/t-microblaze | 15 ++++++---------
9 libgcc/config/microblaze/t-microblaze | 11 +++--------
10 3 files changed, 10 insertions(+), 17 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze-c.c b/gcc/config/microblaze/microblaze-c.c
13index dbcd21fc6ee..db543edcbe5 100644
14--- a/gcc/config/microblaze/microblaze-c.c
15+++ b/gcc/config/microblaze/microblaze-c.c
16@@ -102,6 +102,7 @@ microblaze_cpp_define (cpp_reader *pfile)
17 }
18 if (TARGET_MB_64)
19 {
20+ builtin_define ("__microblaze64");
21 builtin_define ("__arch64__");
22 builtin_define ("__microblaze64__");
23 builtin_define ("__MICROBLAZE64__");
24diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
25index 9fc80b142ce..35ab9654052 100644
26--- a/gcc/config/microblaze/t-microblaze
27+++ b/gcc/config/microblaze/t-microblaze
28@@ -1,12 +1,9 @@
29-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian m64
30-MULTILIB_DIRNAMES = bs m mh le m64
31-MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
32-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
33-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian/m64
34-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64 mxl-multiply-high
35-MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
36-MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
37-MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
38+MULTILIB_OPTIONS = m64 mxl-barrel-shift mlittle-endian mno-xl-soft-mul mxl-multiply-high
39+MULTILIB_DIRNAMES = m64 bs le m mh
40+MULTILIB_EXCEPTIONS = *m64/mxl-multiply-high mxl-multiply-high
41+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
42+MULTILIB_EXCEPTIONS += *mlittle-endian/mxl-multiply-high mxl-multiply-high
43+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mlittle-endian/mxl-multiply-high
44
45 # Extra files
46 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
47diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
48index 35021b24b7d..8d954a49575 100644
49--- a/libgcc/config/microblaze/t-microblaze
50+++ b/libgcc/config/microblaze/t-microblaze
51@@ -1,16 +1,11 @@
52-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3 \
53- _divdi3 _moddi3 _muldi3 _udivdi3 _umoddi3
54+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
55
56 LIB2ADD += \
57 $(srcdir)/config/microblaze/divsi3.S \
58- $(srcdir)/config/microblaze/divdi3.S \
59 $(srcdir)/config/microblaze/modsi3.S \
60- $(srcdir)/config/microblaze/moddi3.S \
61+ $(srcdir)/config/microblaze/muldi3_hard.S \
62 $(srcdir)/config/microblaze/mulsi3.S \
63- $(srcdir)/config/microblaze/muldi3.S \
64 $(srcdir)/config/microblaze/stack_overflow_exit.S \
65 $(srcdir)/config/microblaze/udivsi3.S \
66- $(srcdir)/config/microblaze/udivdi3.S \
67 $(srcdir)/config/microblaze/umodsi3.S \
68- $(srcdir)/config/microblaze/umoddi3.S \
69- $(srcdir)/config/microblaze/divsi3_table.c \
70+ $(srcdir)/config/microblaze/divsi3_table.c
71--
722.17.1
73
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0034-Fixed-issues-like.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0034-Fixed-issues-like.patch
new file mode 100644
index 00000000..c508b158
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0034-Fixed-issues-like.patch
@@ -0,0 +1,70 @@
1From 2b2c6e96c3aefc86c880be05d93685a4ce97c9f1 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 11 Sep 2018 14:58:00 +0530
4Subject: [PATCH 34/54] Fixed issues like: 1 Interrupt alignment issue 2 Sign
5 extension issue
6
7---
8 gcc/config/microblaze/microblaze.c | 16 ++++++++++------
9 gcc/config/microblaze/microblaze.md | 2 +-
10 2 files changed, 11 insertions(+), 7 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
13index 046bfd05558..498c8ca191f 100644
14--- a/gcc/config/microblaze/microblaze.c
15+++ b/gcc/config/microblaze/microblaze.c
16@@ -2177,9 +2177,14 @@ compute_frame_size (HOST_WIDE_INT size)
17
18 total_size += gp_reg_size;
19
20- /* Add 4 bytes for MSR. */
21+ /* Add 4/8 bytes for MSR. */
22 if (microblaze_is_interrupt_variant ())
23- total_size += 4;
24+ {
25+ if (TARGET_MB_64)
26+ total_size += 8;
27+ else
28+ total_size += 4;
29+ }
30
31 /* No space to be allocated for link register in leaf functions with no other
32 stack requirements. */
33@@ -2464,7 +2469,6 @@ print_operand (FILE * file, rtx op, int letter)
34 else if (letter == 'h' || letter == 'j')
35 {
36 long val[2];
37- int val1[2];
38 long l[2];
39 if (code == CONST_DOUBLE)
40 {
41@@ -2479,10 +2483,10 @@ print_operand (FILE * file, rtx op, int letter)
42 }
43 else if (code == CONST_INT || code == CONST)// || code == SYMBOL_REF ||code == LABEL_REF)
44 {
45- val1[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
46- val1[1] = INTVAL (op) & 0x00000000ffffffffLL;
47+ val[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
48+ val[1] = INTVAL (op) & 0x00000000ffffffffLL;
49 }
50- fprintf (file, "0x%8.8lx", (letter == 'h') ? val1[0] : val1[1]);
51+ fprintf (file, "0x%8.8lx", (letter == 'h') ? val[0] : val[1]);
52 }
53 else if (code == CONST_DOUBLE)
54 {
55diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
56index 592757baf2f..e7c7cf3e8b5 100644
57--- a/gcc/config/microblaze/microblaze.md
58+++ b/gcc/config/microblaze/microblaze.md
59@@ -1096,7 +1096,7 @@
60 case 1:
61 case 2:
62 {
63- output_asm_insn ("ll%i1\t%0,%1", operands);
64+ output_asm_insn ("lw%i1\t%0,%1", operands);
65 return "sextl32\t%0,%0";
66 }
67 }
68--
692.17.1
70
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0035-Fixed-below-issues.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0035-Fixed-below-issues.patch
new file mode 100644
index 00000000..61d35261
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0035-Fixed-below-issues.patch
@@ -0,0 +1,307 @@
1From 051d744c06ed3f11f603e37768eece57784c2583 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 26 Nov 2019 17:26:15 +0530
4Subject: [PATCH 35/54] Fixed below issues:
5
6- Floating point print issues in 64bit mode
7- Dejagnu Jump related issues
8- Added dbl instruction
9
10Conflicts:
11 gcc/config/microblaze/microblaze.md
12---
13 gcc/config/microblaze/microblaze.c | 12 +++-
14 gcc/config/microblaze/microblaze.h | 7 +++
15 gcc/config/microblaze/microblaze.md | 86 ++++++++++++++++++++++++-----
16 libgcc/config/microblaze/crti.S | 24 +++++++-
17 libgcc/config/microblaze/crtn.S | 13 +++++
18 5 files changed, 125 insertions(+), 17 deletions(-)
19
20diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
21index 498c8ca191f..e32de46fa62 100644
22--- a/gcc/config/microblaze/microblaze.c
23+++ b/gcc/config/microblaze/microblaze.c
24@@ -2473,7 +2473,12 @@ print_operand (FILE * file, rtx op, int letter)
25 if (code == CONST_DOUBLE)
26 {
27 if (GET_MODE (op) == DFmode)
28- REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
29+ {
30+ if (TARGET_MB_64)
31+ REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
32+ else
33+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
34+ }
35 else
36 {
37 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
38@@ -3876,7 +3881,10 @@ microblaze_expand_divide (rtx operands[])
39 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
40
41 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
42- jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
43+ if (TARGET_MB_64)
44+ jump = emit_jump_insn_after (gen_jump_64 (div_end_label), insn);
45+ else
46+ jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
47 JUMP_LABEL (jump) = div_end_label;
48 LABEL_NUSES (div_end_label) = 1;
49 emit_barrier ();
50diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
51index f6ad4d9fc21..60c552958b8 100644
52--- a/gcc/config/microblaze/microblaze.h
53+++ b/gcc/config/microblaze/microblaze.h
54@@ -888,10 +888,17 @@ do { \
55 /* We do this to save a few 10s of code space that would be taken up
56 by the call_FUNC () wrappers, used by the generic CRT_CALL_STATIC_FUNCTION
57 definition in crtstuff.c. */
58+#ifdef __arch64__
59+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
60+ asm ( SECTION_OP "\n" \
61+ "\tbrealid r15, " #FUNC "\n\t nop\n" \
62+ TEXT_SECTION_ASM_OP);
63+#else
64 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
65 asm ( SECTION_OP "\n" \
66 "\tbrlid r15, " #FUNC "\n\t nop\n" \
67 TEXT_SECTION_ASM_OP);
68+#endif
69
70 /* We need to group -lm as well, since some Newlib math functions
71 reference __errno! */
72diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
73index e7c7cf3e8b5..74bb30cb9e8 100644
74--- a/gcc/config/microblaze/microblaze.md
75+++ b/gcc/config/microblaze/microblaze.md
76@@ -527,6 +527,15 @@
77 (set_attr "mode" "SF")
78 (set_attr "length" "4")])
79
80+(define_insn "floatdidf2"
81+ [(set (match_operand:DF 0 "register_operand" "=d")
82+ (float:DF (match_operand:DI 1 "register_operand" "d")))]
83+ "TARGET_MB_64"
84+ "dbl\t%0,%1"
85+ [(set_attr "type" "fcvt")
86+ (set_attr "mode" "DF")
87+ (set_attr "length" "4")])
88+
89 (define_insn "fix_truncsfsi2"
90 [(set (match_operand:SI 0 "register_operand" "=d")
91 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
92@@ -1301,7 +1310,7 @@
93 (define_insn "movdi_long_int"
94 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
95 (match_operand:DI 1 "general_operand" "i"))]
96- ""
97+ "TARGET_MB_64"
98 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
99 [(set_attr "type" "no_delay_arith")
100 (set_attr "mode" "DI")
101@@ -1584,7 +1593,7 @@
102 return "ll%i1\t%0,%1";
103 case 3:
104 {
105- return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
106+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
107 }
108 case 5:
109 return "sl%i0\t%1,%0";
110@@ -2374,9 +2383,9 @@ else
111
112 (define_insn "long_branch_compare"
113 [(set (pc)
114- (if_then_else (match_operator 0 "cmp_op"
115- [(match_operand 1 "register_operand" "d")
116- (match_operand 2 "register_operand" "d")
117+ (if_then_else (match_operator:DI 0 "cmp_op"
118+ [(match_operand:DI 1 "register_operand" "d")
119+ (match_operand:DI 2 "register_operand" "d")
120 ])
121 (label_ref (match_operand 3))
122 (pc)))
123@@ -2498,6 +2507,20 @@ else
124 ;;----------------------------------------------------------------
125 ;; Unconditional branches
126 ;;----------------------------------------------------------------
127+(define_insn "jump_64"
128+ [(set (pc)
129+ (label_ref (match_operand 0 "" "")))]
130+ "TARGET_MB_64"
131+ {
132+ if (GET_CODE (operands[0]) == REG)
133+ return "brea%?\t%0";
134+ else
135+ return "breai%?\t%l0";
136+ }
137+ [(set_attr "type" "jump")
138+ (set_attr "mode" "none")
139+ (set_attr "length" "4")])
140+
141 (define_insn "jump"
142 [(set (pc)
143 (label_ref (match_operand 0 "" "")))]
144@@ -2543,17 +2566,25 @@ else
145 {
146 //gcc_assert (GET_MODE (operands[0]) == Pmode);
147
148- if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
149- emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
150- else
151- emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
152+ if (!flag_pic || TARGET_PIC_DATA_TEXT_REL) {
153+ if (!TARGET_MB_64)
154+ emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
155+ else
156+ emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
157+ }
158+ else {
159+ if (!TARGET_MB_64)
160+ emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
161+ else
162+ emit_jump_insn (gen_tablejump_internal4 (operands[0], operands[1]));
163+ }
164 DONE;
165 }
166 )
167
168 (define_insn "tablejump_internal1"
169 [(set (pc)
170- (match_operand 0 "register_operand" "d"))
171+ (match_operand:SI 0 "register_operand" "d"))
172 (use (label_ref (match_operand 1 "" "")))]
173 ""
174 "bra%?\t%0 "
175@@ -2561,11 +2592,21 @@ else
176 (set_attr "mode" "none")
177 (set_attr "length" "4")])
178
179+(define_insn "tablejump_internal2"
180+ [(set (pc)
181+ (match_operand:DI 0 "register_operand" "d"))
182+ (use (label_ref (match_operand 1 "" "")))]
183+ "TARGET_MB_64"
184+ "bra%?\t%0 "
185+ [(set_attr "type" "jump")
186+ (set_attr "mode" "none")
187+ (set_attr "length" "4")])
188+
189 (define_expand "tablejump_internal3"
190 [(parallel [(set (pc)
191- (plus (match_operand 0 "register_operand" "d")
192- (label_ref (match_operand:SI 1 "" ""))))
193- (use (label_ref (match_dup 1)))])]
194+ (plus:SI (match_operand:SI 0 "register_operand" "d")
195+ (label_ref:SI (match_operand:SI 1 "" ""))))
196+ (use (label_ref:SI (match_dup 1)))])]
197 ""
198 ""
199 )
200@@ -2596,6 +2637,23 @@ else
201 ""
202 )
203
204+(define_insn ""
205+ [(set (pc)
206+ (plus:DI (match_operand:DI 0 "register_operand" "d")
207+ (label_ref:DI (match_operand 1 "" ""))))
208+ (use (label_ref:DI (match_dup 1)))]
209+ "TARGET_MB_64 && NEXT_INSN (as_a <rtx_insn *> (operands[1])) != 0
210+ && GET_CODE (PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1])))) == ADDR_DIFF_VEC
211+ && flag_pic"
212+ {
213+ output_asm_insn ("addlk\t%0,%0,r20",operands);
214+ return "bra%?\t%0";
215+}
216+ [(set_attr "type" "jump")
217+ (set_attr "mode" "none")
218+ (set_attr "length" "4")])
219+
220+
221 ;;----------------------------------------------------------------
222 ;; Function prologue/epilogue and stack allocation
223 ;;----------------------------------------------------------------
224@@ -3102,7 +3160,7 @@ else
225 ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference
226 ;; between "mfs" and "addik" instructions.
227 (define_insn "set_got"
228- [(set (match_operand:SI 0 "register_operand" "=r")
229+ [(set (match_operand 0 "register_operand" "=r")
230 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))]
231 ""
232 "mfs\t%0,rpc\n\taddik\t%0,%0,_GLOBAL_OFFSET_TABLE_+8"
233diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
234index 005825f1ec5..b7436c7131f 100644
235--- a/libgcc/config/microblaze/crti.S
236+++ b/libgcc/config/microblaze/crti.S
237@@ -33,11 +33,32 @@
238 .section .init, "ax"
239 .global __init
240
241+#ifdef __arch64__
242 .weak _stack
243- .set _stack, 0xffffffff
244+ .set _stack, 0xffffffffffffffff
245 .weak _stack_end
246 .set _stack_end, 0
247
248+ .align 3
249+__init:
250+ addlik r1, r1, -32
251+ sl r15, r0, r1
252+ addlik r11, r0, _stack
253+ mts rshr, r11
254+ addlik r11, r0, _stack_end
255+ mts rslr, r11
256+
257+ .section .fini, "ax"
258+ .global __fini
259+ .align 3
260+__fini:
261+ addlik r1, r1, -32
262+ sl r15, r0, r1
263+#else
264+ .weak _stack
265+ .set _stack, 0xffffffff
266+ .weak _stack_end
267+ .set _stack_end, 0
268 .align 2
269 __init:
270 addik r1, r1, -16
271@@ -53,3 +74,4 @@ __init:
272 __fini:
273 addik r1, r1, -16
274 sw r15, r0, r1
275+#endif
276diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
277index 5705eff9a4a..f1148ffebe4 100644
278--- a/libgcc/config/microblaze/crtn.S
279+++ b/libgcc/config/microblaze/crtn.S
280@@ -29,7 +29,19 @@
281 .section .note.GNU-stack,"",%progbits
282 .previous
283 #endif
284+#ifdef __arch64__
285+ .section .init, "ax"
286+ ll r15, r0, r1
287+ addlik r1, r1, 32
288+ rtsd r15, 8
289+ nop
290
291+ .section .fini, "ax"
292+ ll r15, r0, r1
293+ addlik r1, r1, 32
294+ rtsd r15, 8
295+ nop
296+#else
297 .section .init, "ax"
298 lw r15, r0, r1
299 rtsd r15, 8
300@@ -39,3 +51,4 @@
301 lw r15, r0, r1
302 rtsd r15, 8
303 addik r1, r1, 16
304+#endif
305--
3062.17.1
307
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0036-Added-double-arith-instructions.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0036-Added-double-arith-instructions.patch
new file mode 100644
index 00000000..3f52e879
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0036-Added-double-arith-instructions.patch
@@ -0,0 +1,135 @@
1From 2bb5cef1a85d63ebf155bcb0070492b0ad298dd8 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 9 Oct 2018 10:07:08 +0530
4Subject: [PATCH 36/54] -Added double arith instructions -Fixed prologue stack
5 pointer decrement issue
6
7---
8 gcc/config/microblaze/microblaze.md | 78 +++++++++++++++++++++++++----
9 gcc/config/microblaze/t-microblaze | 7 +++
10 2 files changed, 76 insertions(+), 9 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
13index 74bb30cb9e8..1401d6b77ff 100644
14--- a/gcc/config/microblaze/microblaze.md
15+++ b/gcc/config/microblaze/microblaze.md
16@@ -527,6 +527,66 @@
17 (set_attr "mode" "SF")
18 (set_attr "length" "4")])
19
20+(define_insn "fix_truncsfsi2"
21+ [(set (match_operand:SI 0 "register_operand" "=d")
22+ (fix:SI (match_operand:SF 1 "register_operand" "d")))]
23+ "TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
24+ "fint\t%0,%1"
25+ [(set_attr "type" "fint")
26+ (set_attr "mode" "SF")
27+ (set_attr "length" "4")])
28+
29+
30+(define_insn "adddf3"
31+ [(set (match_operand:DF 0 "register_operand" "=d")
32+ (plus:DF (match_operand:DF 1 "register_operand" "d")
33+ (match_operand:DF 2 "register_operand" "d")))]
34+ "TARGET_MB_64"
35+ "dadd\t%0,%1,%2"
36+ [(set_attr "type" "fadd")
37+ (set_attr "mode" "DF")
38+ (set_attr "length" "4")])
39+
40+(define_insn "subdf3"
41+ [(set (match_operand:DF 0 "register_operand" "=d")
42+ (minus:DF (match_operand:DF 1 "register_operand" "d")
43+ (match_operand:DF 2 "register_operand" "d")))]
44+ "TARGET_MB_64"
45+ "drsub\t%0,%2,%1"
46+ [(set_attr "type" "frsub")
47+ (set_attr "mode" "DF")
48+ (set_attr "length" "4")])
49+
50+(define_insn "muldf3"
51+ [(set (match_operand:DF 0 "register_operand" "=d")
52+ (mult:DF (match_operand:DF 1 "register_operand" "d")
53+ (match_operand:DF 2 "register_operand" "d")))]
54+ "TARGET_MB_64"
55+ "dmul\t%0,%1,%2"
56+ [(set_attr "type" "fmul")
57+ (set_attr "mode" "DF")
58+ (set_attr "length" "4")])
59+
60+(define_insn "divdf3"
61+ [(set (match_operand:DF 0 "register_operand" "=d")
62+ (div:DF (match_operand:DF 1 "register_operand" "d")
63+ (match_operand:DF 2 "register_operand" "d")))]
64+ "TARGET_MB_64"
65+ "ddiv\t%0,%2,%1"
66+ [(set_attr "type" "fdiv")
67+ (set_attr "mode" "DF")
68+ (set_attr "length" "4")])
69+
70+
71+(define_insn "sqrtdf2"
72+ [(set (match_operand:DF 0 "register_operand" "=d")
73+ (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
74+ "TARGET_MB_64"
75+ "dsqrt\t%0,%1"
76+ [(set_attr "type" "fsqrt")
77+ (set_attr "mode" "DF")
78+ (set_attr "length" "4")])
79+
80 (define_insn "floatdidf2"
81 [(set (match_operand:DF 0 "register_operand" "=d")
82 (float:DF (match_operand:DI 1 "register_operand" "d")))]
83@@ -536,13 +596,13 @@
84 (set_attr "mode" "DF")
85 (set_attr "length" "4")])
86
87-(define_insn "fix_truncsfsi2"
88- [(set (match_operand:SI 0 "register_operand" "=d")
89- (fix:SI (match_operand:SF 1 "register_operand" "d")))]
90- "TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
91- "fint\t%0,%1"
92- [(set_attr "type" "fint")
93- (set_attr "mode" "SF")
94+(define_insn "floatdfdi2"
95+ [(set (match_operand:DI 0 "register_operand" "=d")
96+ (float:DI (match_operand:DF 1 "register_operand" "d")))]
97+ "TARGET_MB_64"
98+ "dlong\t%0,%1"
99+ [(set_attr "type" "fcvt")
100+ (set_attr "mode" "DI")
101 (set_attr "length" "4")])
102
103 ;;----------------------------------------------------------------
104@@ -660,8 +720,8 @@
105 "TARGET_MB_64"
106 "@
107 rsubl\t%0,%2,%1
108- addik\t%0,%z1,-%2
109- addik\t%0,%z1,-%2"
110+ addlik\t%0,%z1,-%2
111+ addlik\t%0,%z1,-%2"
112 [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
113 (set_attr "mode" "DI")
114 (set_attr "length" "4,4,4")])
115diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
116index 35ab9654052..dfef45c268e 100644
117--- a/gcc/config/microblaze/t-microblaze
118+++ b/gcc/config/microblaze/t-microblaze
119@@ -1,6 +1,13 @@
120 MULTILIB_OPTIONS = m64 mxl-barrel-shift mlittle-endian mno-xl-soft-mul mxl-multiply-high
121 MULTILIB_DIRNAMES = m64 bs le m mh
122 MULTILIB_EXCEPTIONS = *m64/mxl-multiply-high mxl-multiply-high
123+MULTILIB_EXCEPTIONS += *m64
124+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift
125+MULTILIB_EXCEPTIONS += *m64/mno-xl-soft-mul
126+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mno-xl-soft-mul
127+MULTILIB_EXCEPTIONS += *m64/mno-xl-soft-mul
128+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mno-xl-soft-mul/mxl-multiply-high
129+MULTILIB_EXCEPTIONS += *m64/mno-xl-soft-mul/mxl-multiply-high
130 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
131 MULTILIB_EXCEPTIONS += *mlittle-endian/mxl-multiply-high mxl-multiply-high
132 MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mlittle-endian/mxl-multiply-high
133--
1342.17.1
135
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0037-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0037-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch
new file mode 100644
index 00000000..2253b759
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0037-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch
@@ -0,0 +1,37 @@
1From 2feba7c8902be8d5c4cc99feca0581472c16de0c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 12 Oct 2018 16:07:36 +0530
4Subject: [PATCH 37/54] Fixed the issue in the delay slot with swap
5 instructions
6
7---
8 gcc/config/microblaze/microblaze.md | 6 ++++++
9 1 file changed, 6 insertions(+)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index 1401d6b77ff..a91108cf0e5 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -443,6 +443,9 @@
16 (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
17 "TARGET_REORDER"
18 "swapb %0, %1"
19+ [(set_attr "type" "no_delay_arith")
20+ (set_attr "mode" "SI")
21+ (set_attr "length" "4")]
22 )
23
24 (define_insn "bswaphi2"
25@@ -451,6 +454,9 @@
26 "TARGET_REORDER"
27 "swapb %0, %1
28 swaph %0, %0"
29+ [(set_attr "type" "no_delay_arith")
30+ (set_attr "mode" "SI")
31+ (set_attr "length" "8")]
32 )
33
34 ;;----------------------------------------------------------------
35--
362.17.1
37
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0038-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0038-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch
new file mode 100644
index 00000000..57905e66
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0038-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch
@@ -0,0 +1,256 @@
1From 10d59c50195cff30c4e74959ef4cebc9065808a4 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sat, 13 Oct 2018 21:12:43 +0530
4Subject: [PATCH 38/54] Fixed the load store issue with the 32bit arith
5 libraries
6
7---
8 libgcc/config/microblaze/divsi3.S | 25 ++++++++++++++++++++++++-
9 libgcc/config/microblaze/modsi3.S | 26 +++++++++++++++++++++++++-
10 libgcc/config/microblaze/mulsi3.S | 3 +++
11 libgcc/config/microblaze/udivsi3.S | 24 +++++++++++++++++++++++-
12 libgcc/config/microblaze/umodsi3.S | 24 +++++++++++++++++++++++-
13 5 files changed, 98 insertions(+), 4 deletions(-)
14
15diff --git a/libgcc/config/microblaze/divsi3.S b/libgcc/config/microblaze/divsi3.S
16index bb047094e2f..104243e35fe 100644
17--- a/libgcc/config/microblaze/divsi3.S
18+++ b/libgcc/config/microblaze/divsi3.S
19@@ -41,6 +41,17 @@
20 .globl __divsi3
21 .ent __divsi3
22 .type __divsi3,@function
23+#ifdef __arch64__
24+ .align 3
25+__divsi3:
26+ .frame r1,0,r15
27+
28+ ADDIK r1,r1,-32
29+ SLI r28,r1,0
30+ SLI r29,r1,8
31+ SLI r30,r1,16
32+ SLI r31,r1,24
33+#else
34 __divsi3:
35 .frame r1,0,r15
36
37@@ -49,7 +60,7 @@ __divsi3:
38 SWI r29,r1,4
39 SWI r30,r1,8
40 SWI r31,r1,12
41-
42+#endif
43 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
44 BEQI r5,$LaResult_Is_Zero # Result is Zero
45 BGEID r5,$LaR5_Pos
46@@ -89,6 +100,17 @@ $LaLOOP_END:
47 $LaDiv_By_Zero:
48 $LaResult_Is_Zero:
49 OR r3,r0,r0 # set result to 0
50+#ifdef __arch64__
51+$LaRETURN_HERE:
52+# Restore values of CSRs and that of r3 and the divisor and the dividend
53+ LLI r28,r1,0
54+ LLI r29,r1,8
55+ LLI r30,r1,16
56+ LLI r31,r1,24
57+ ADDLIK r1,r1,32
58+ RTSD r15,8
59+ NOP
60+#else
61 $LaRETURN_HERE:
62 # Restore values of CSRs and that of r3 and the divisor and the dividend
63 LWI r28,r1,0
64@@ -97,6 +119,7 @@ $LaRETURN_HERE:
65 LWI r31,r1,12
66 RTSD r15,8
67 ADDIK r1,r1,16
68+#endif
69 .end __divsi3
70 .size __divsi3, . - __divsi3
71
72diff --git a/libgcc/config/microblaze/modsi3.S b/libgcc/config/microblaze/modsi3.S
73index 9692ff310ff..9500d64bdc0 100644
74--- a/libgcc/config/microblaze/modsi3.S
75+++ b/libgcc/config/microblaze/modsi3.S
76@@ -41,6 +41,17 @@
77 .globl __modsi3
78 .ent __modsi3
79 .type __modsi3,@function
80+#ifdef __arch64__
81+ .align 3
82+__modsi3:
83+ .frame r1,0,r15
84+
85+ addlik r1,r1,-32
86+ sli r28,r1,0
87+ sli r29,r1,8
88+ sli r30,r1,16
89+ sli r31,r1,24
90+#else
91 __modsi3:
92 .frame r1,0,r15
93
94@@ -49,6 +60,7 @@ __modsi3:
95 swi r29,r1,4
96 swi r30,r1,8
97 swi r31,r1,12
98+#endif
99
100 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
101 BEQI r5,$LaResult_Is_Zero # Result is Zero
102@@ -88,6 +100,18 @@ $LaLOOP_END:
103 $LaDiv_By_Zero:
104 $LaResult_Is_Zero:
105 or r3,r0,r0 # set result to 0 [Both mod as well as div are 0]
106+
107+#ifdef __arch64__
108+$LaRETURN_HERE:
109+# Restore values of CSRs and that of r3 and the divisor and the dividend
110+ lli r28,r1,0
111+ lli r29,r1,8
112+ lli r30,r1,16
113+ lli r31,r1,24
114+ addik r1,r1,32
115+ rtsd r15,8
116+ nop
117+#else
118 $LaRETURN_HERE:
119 # Restore values of CSRs and that of r3 and the divisor and the dividend
120 lwi r28,r1,0
121@@ -95,7 +119,7 @@ $LaRETURN_HERE:
122 lwi r30,r1,8
123 lwi r31,r1,12
124 rtsd r15,8
125- addik r1,r1,16
126+#endif
127 .end __modsi3
128 .size __modsi3, . - __modsi3
129
130diff --git a/libgcc/config/microblaze/mulsi3.S b/libgcc/config/microblaze/mulsi3.S
131index cb3b6b8321f..2044399db4a 100644
132--- a/libgcc/config/microblaze/mulsi3.S
133+++ b/libgcc/config/microblaze/mulsi3.S
134@@ -41,6 +41,9 @@
135 .globl __mulsi3
136 .ent __mulsi3
137 .type __mulsi3,@function
138+#ifdef __arch64__
139+ .align 3
140+#endif
141 __mulsi3:
142 .frame r1,0,r15
143 add r3,r0,r0
144diff --git a/libgcc/config/microblaze/udivsi3.S b/libgcc/config/microblaze/udivsi3.S
145index ee2bdd0950d..d2332bcfe62 100644
146--- a/libgcc/config/microblaze/udivsi3.S
147+++ b/libgcc/config/microblaze/udivsi3.S
148@@ -41,6 +41,16 @@
149 .globl __udivsi3
150 .ent __udivsi3
151 .type __udivsi3,@function
152+#ifdef __arch64__
153+ .align 3
154+__udivsi3:
155+ .frame r1,0,r15
156+
157+ ADDLIK r1,r1,-24
158+ SLI r29,r1,0
159+ SLI r30,r1,8
160+ SLI r31,r1,16
161+#else
162 __udivsi3:
163 .frame r1,0,r15
164
165@@ -48,7 +58,7 @@ __udivsi3:
166 SWI r29,r1,0
167 SWI r30,r1,4
168 SWI r31,r1,8
169-
170+#endif
171 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
172 BEQID r5,$LaResult_Is_Zero # Result is Zero
173 ADDIK r30,r0,0 # Clear mod
174@@ -98,6 +108,17 @@ $LaLOOP_END:
175 $LaDiv_By_Zero:
176 $LaResult_Is_Zero:
177 OR r3,r0,r0 # set result to 0
178+
179+#ifdef __arch64__
180+$LaRETURN_HERE:
181+ # Restore values of CSRs and that of r3 and the divisor and the dividend
182+ LLI r29,r1,0
183+ LLI r30,r1,8
184+ LLI r31,r1,16
185+ ADDIK r1,r1,24
186+ RTSD r15,8
187+ NOP
188+#else
189 $LaRETURN_HERE:
190 # Restore values of CSRs and that of r3 and the divisor and the dividend
191 LWI r29,r1,0
192@@ -105,5 +126,6 @@ $LaRETURN_HERE:
193 LWI r31,r1,8
194 RTSD r15,8
195 ADDIK r1,r1,12
196+#endif
197 .end __udivsi3
198 .size __udivsi3, . - __udivsi3
199diff --git a/libgcc/config/microblaze/umodsi3.S b/libgcc/config/microblaze/umodsi3.S
200index 12c082f6417..30bd8c20b58 100644
201--- a/libgcc/config/microblaze/umodsi3.S
202+++ b/libgcc/config/microblaze/umodsi3.S
203@@ -41,6 +41,16 @@
204 .globl __umodsi3
205 .ent __umodsi3
206 .type __umodsi3,@function
207+#ifdef __arch64__
208+ .align 3
209+__umodsi3:
210+ .frame r1,0,r15
211+
212+ addik r1,r1,-24
213+ swi r29,r1,0
214+ swi r30,r1,8
215+ swi r31,r1,16
216+#else
217 __umodsi3:
218 .frame r1,0,r15
219
220@@ -48,7 +58,7 @@ __umodsi3:
221 swi r29,r1,0
222 swi r30,r1,4
223 swi r31,r1,8
224-
225+#endif
226 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
227 BEQId r5,$LaResult_Is_Zero # Result is Zero
228 ADDIK r3,r0,0 # Clear div
229@@ -101,6 +111,17 @@ $LaLOOP_END:
230 $LaDiv_By_Zero:
231 $LaResult_Is_Zero:
232 or r3,r0,r0 # set result to 0
233+
234+#ifdef __arch64__
235+$LaRETURN_HERE:
236+# Restore values of CSRs and that of r3 and the divisor and the dividend
237+ lli r29,r1,0
238+ lli r30,r1,8
239+ lli r31,r1,16
240+ addlik r1,r1,24
241+ rtsd r15,8
242+ nop
243+#else
244 $LaRETURN_HERE:
245 # Restore values of CSRs and that of r3 and the divisor and the dividend
246 lwi r29,r1,0
247@@ -108,5 +129,6 @@ $LaRETURN_HERE:
248 lwi r31,r1,8
249 rtsd r15,8
250 addik r1,r1,12
251+#endif
252 .end __umodsi3
253 .size __umodsi3, . - __umodsi3
254--
2552.17.1
256
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0039-extending-the-Dwarf-support-to-64bit-Microblaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0039-extending-the-Dwarf-support-to-64bit-Microblaze.patch
new file mode 100644
index 00000000..8f46859a
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0039-extending-the-Dwarf-support-to-64bit-Microblaze.patch
@@ -0,0 +1,25 @@
1From e51fb2d87f412d1f7045050c5c2df664766de706 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 15 Oct 2018 12:00:10 +0530
4Subject: [PATCH 39/54] extending the Dwarf support to 64bit Microblaze
5
6---
7 gcc/config/microblaze/microblaze.h | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
11index 60c552958b8..747adcc7a70 100644
12--- a/gcc/config/microblaze/microblaze.h
13+++ b/gcc/config/microblaze/microblaze.h
14@@ -207,7 +207,7 @@ extern enum pipeline_type microblaze_pipe;
15 /* Use DWARF 2 debugging information by default. */
16 #define DWARF2_DEBUGGING_INFO 1
17 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
18-#define DWARF2_ADDR_SIZE 4
19+#define DWARF2_ADDR_SIZE (TARGET_MB_64 ? 8 : 4)
20
21 /* Target machine storage layout */
22
23--
242.17.1
25
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0040-fixing-the-typo-errors-in-umodsi3-file.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0040-fixing-the-typo-errors-in-umodsi3-file.patch
new file mode 100644
index 00000000..e7e581e3
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0040-fixing-the-typo-errors-in-umodsi3-file.patch
@@ -0,0 +1,29 @@
1From 61be4b342d470aeb7ad1c0cc5e90f5afdc906c00 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 16 Oct 2018 07:55:46 +0530
4Subject: [PATCH 40/54] fixing the typo errors in umodsi3 file
5
6---
7 libgcc/config/microblaze/umodsi3.S | 6 +++---
8 1 file changed, 3 insertions(+), 3 deletions(-)
9
10diff --git a/libgcc/config/microblaze/umodsi3.S b/libgcc/config/microblaze/umodsi3.S
11index 30bd8c20b58..2dd72aef68e 100644
12--- a/libgcc/config/microblaze/umodsi3.S
13+++ b/libgcc/config/microblaze/umodsi3.S
14@@ -47,9 +47,9 @@ __umodsi3:
15 .frame r1,0,r15
16
17 addik r1,r1,-24
18- swi r29,r1,0
19- swi r30,r1,8
20- swi r31,r1,16
21+ sli r29,r1,0
22+ sli r30,r1,8
23+ sli r31,r1,16
24 #else
25 __umodsi3:
26 .frame r1,0,r15
27--
282.17.1
29
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0041-fixing-the-32bit-LTO-related-issue9-1014024.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0041-fixing-the-32bit-LTO-related-issue9-1014024.patch
new file mode 100644
index 00000000..9f9afdb9
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0041-fixing-the-32bit-LTO-related-issue9-1014024.patch
@@ -0,0 +1,68 @@
1From b1eb7b1f6c33246ded3501364279a5f002cd8de0 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Wed, 17 Oct 2018 16:56:14 +0530
4Subject: [PATCH 41/54] fixing the 32bit LTO related issue9(1014024)
5
6---
7 gcc/config/microblaze/microblaze.h | 24 ++++++++++++++----------
8 1 file changed, 14 insertions(+), 10 deletions(-)
9
10diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
11index 747adcc7a70..bfa7bc9a01c 100644
12--- a/gcc/config/microblaze/microblaze.h
13+++ b/gcc/config/microblaze/microblaze.h
14@@ -265,12 +265,14 @@ extern enum pipeline_type microblaze_pipe;
15 #define WORD_REGISTER_OPERATIONS 1
16
17 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
18-/*
19-#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
20- if (GET_MODE_CLASS (MODE) == MODE_INT \
21- && GET_MODE_SIZE (MODE) < (TARGET_MB_64 ? 8 : 4)) \
22- (MODE) = TARGET_MB_64 ? DImode : SImode;
23-*/
24+
25+#ifndef __arch64__
26+#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
27+ if (GET_MODE_CLASS (MODE) == MODE_INT \
28+ && GET_MODE_SIZE (MODE) < 4) \
29+ (MODE) = SImode;
30+#endif
31+
32 /* Standard register usage. */
33
34 /* On the MicroBlaze, we have 32 integer registers */
35@@ -469,16 +471,18 @@ extern struct microblaze_frame_info current_frame_info;
36
37 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
38
39+#ifdef __aarch64__
40 #define LIBCALL_VALUE(MODE) \
41 gen_rtx_REG (MODE,GP_RETURN)
42-
43-/*#define LIBCALL_VALUE(MODE) \
44+#else
45+#define LIBCALL_VALUE(MODE) \
46 gen_rtx_REG ( \
47 ((GET_MODE_CLASS (MODE) != MODE_INT \
48 || GET_MODE_SIZE (MODE) >= 4) \
49 ? (MODE) \
50 : SImode), GP_RETURN)
51-*/
52+#endif
53+
54 /* 1 if N is a possible register number for a function value.
55 On the MicroBlaze, R2 R3 are the only register thus used.
56 Currently, R2 are only implemented here (C has no complex type) */
57@@ -518,7 +522,7 @@ typedef struct microblaze_args
58 /* 4 insns + 2 words of data. */
59 #define TRAMPOLINE_SIZE (6 * 4)
60
61-#define TRAMPOLINE_ALIGNMENT 64
62+#define TRAMPOLINE_ALIGNMENT (TARGET_MB_64 ? 64 : 32)
63
64 #define REGNO_OK_FOR_BASE_P(regno) microblaze_regno_ok_for_base_p ((regno), 1)
65
66--
672.17.1
68
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0042-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0042-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch
new file mode 100644
index 00000000..fb31d663
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0042-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch
@@ -0,0 +1,25 @@
1From e0820fe8c8d9b7504595794fe6e65151d22e2acf Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 19 Oct 2018 14:26:25 +0530
4Subject: [PATCH 42/54] Fixed the missing stack adjustment in prologue of
5 modsi3 function
6
7---
8 libgcc/config/microblaze/modsi3.S | 1 +
9 1 file changed, 1 insertion(+)
10
11diff --git a/libgcc/config/microblaze/modsi3.S b/libgcc/config/microblaze/modsi3.S
12index 9500d64bdc0..4dbb25900d9 100644
13--- a/libgcc/config/microblaze/modsi3.S
14+++ b/libgcc/config/microblaze/modsi3.S
15@@ -119,6 +119,7 @@ $LaRETURN_HERE:
16 lwi r30,r1,8
17 lwi r31,r1,12
18 rtsd r15,8
19+ addik r1,r1,16
20 #endif
21 .end __modsi3
22 .size __modsi3, . - __modsi3
23--
242.17.1
25
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0043-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0043-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch
new file mode 100644
index 00000000..ce8b1384
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0043-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch
@@ -0,0 +1,29 @@
1From 1f288ec920d938accb084dc0d1d6f6115950c014 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 24 Oct 2018 18:31:04 +0530
4Subject: [PATCH 43/54] [Patch,Microblaze] : corrected SPN for dlong
5 instruction mapping.
6
7---
8 gcc/config/microblaze/microblaze.md | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index a91108cf0e5..19801f8edcc 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -602,9 +602,9 @@
16 (set_attr "mode" "DF")
17 (set_attr "length" "4")])
18
19-(define_insn "floatdfdi2"
20+(define_insn "fix_truncdfdi2"
21 [(set (match_operand:DI 0 "register_operand" "=d")
22- (float:DI (match_operand:DF 1 "register_operand" "d")))]
23+ (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
24 "TARGET_MB_64"
25 "dlong\t%0,%1"
26 [(set_attr "type" "fcvt")
27--
282.17.1
29
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0044-fixing-the-long-long-long-mingw-toolchain-issue.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0044-fixing-the-long-long-long-mingw-toolchain-issue.patch
new file mode 100644
index 00000000..fec0a2af
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0044-fixing-the-long-long-long-mingw-toolchain-issue.patch
@@ -0,0 +1,59 @@
1From eed2bf4db9bdfc0da1c3f77ce746fb5bfa460b3c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 29 Nov 2018 17:55:08 +0530
4Subject: [PATCH 44/54] fixing the long & long long mingw toolchain issue
5
6---
7 gcc/config/microblaze/constraints.md | 2 +-
8 gcc/config/microblaze/microblaze.md | 8 ++++----
9 2 files changed, 5 insertions(+), 5 deletions(-)
10
11diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
12index b8ef1650f92..89db511c453 100644
13--- a/gcc/config/microblaze/constraints.md
14+++ b/gcc/config/microblaze/constraints.md
15@@ -55,7 +55,7 @@
16 (define_constraint "K"
17 "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
18 (and (match_code "const_int")
19- (match_test "ival > (long)-549755813888 && ival < (long)549755813887")))
20+ (match_test "ival > (long long)-549755813888 && ival < (long long)549755813887")))
21
22
23 ;; Define floating point constraints
24diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
25index 19801f8edcc..8f0ae901b77 100644
26--- a/gcc/config/microblaze/microblaze.md
27+++ b/gcc/config/microblaze/microblaze.md
28@@ -648,8 +648,8 @@
29 if (TARGET_MB_64)
30 {
31 if (GET_CODE (operands[2]) == CONST_INT &&
32- INTVAL(operands[2]) < (long)-549755813888 &&
33- INTVAL(operands[2]) > (long)549755813887)
34+ INTVAL(operands[2]) < (long long)-549755813888 &&
35+ INTVAL(operands[2]) > (long long)549755813887)
36 FAIL;
37 }
38 })
39@@ -1266,7 +1266,7 @@
40 (match_operand:DI 1 "immediate_operand" "J,I,Mnis"))]
41 "TARGET_MB_64 && (register_operand (operands[0], DImode) &&
42 (GET_CODE (operands[1]) == CONST_INT &&
43- (INTVAL (operands[1]) <= (long)549755813887 && INTVAL (operands[1]) >= (long)-549755813888)))"
44+ (INTVAL (operands[1]) <= (long long)549755813887 && INTVAL (operands[1]) >= (long long)-549755813888)))"
45 "@
46 addlk\t%0,r0,r0\t
47 addlik\t%0,r0,%1\t #N1 %X1
48@@ -1300,7 +1300,7 @@
49 case 1:
50 case 2:
51 if (GET_CODE (operands[1]) == CONST_INT &&
52- (INTVAL (operands[1]) > (long)549755813887 || INTVAL (operands[1]) < (long)-549755813888))
53+ (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
54 return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
55 else
56 return "addlik\t%0,r0,%1";
57--
582.17.1
59
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0045-Fix-the-MB-64-bug-of-handling-QI-objects.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0045-Fix-the-MB-64-bug-of-handling-QI-objects.patch
new file mode 100644
index 00000000..15acc1cb
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0045-Fix-the-MB-64-bug-of-handling-QI-objects.patch
@@ -0,0 +1,47 @@
1From 682f65fa3a6b37c207b0d727dd22b6f8cc5d8d3d Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 14 Mar 2019 18:11:04 +0530
4Subject: [PATCH 45/54] Fix the MB-64 bug of handling QI objects
5
6---
7 gcc/config/microblaze/microblaze.md | 14 +++++++-------
8 1 file changed, 7 insertions(+), 7 deletions(-)
9
10diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
11index 8f0ae901b77..207d2bf1b55 100644
12--- a/gcc/config/microblaze/microblaze.md
13+++ b/gcc/config/microblaze/microblaze.md
14@@ -2348,11 +2348,11 @@ else
15
16 (define_insn "branch_zero_64"
17 [(set (pc)
18- (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
19+ (if_then_else (match_operator 0 "ordered_comparison_operator"
20 [(match_operand:SI 1 "register_operand" "d")
21 (const_int 0)])
22- (match_operand:SI 2 "pc_or_label_operand" "")
23- (match_operand:SI 3 "pc_or_label_operand" "")))
24+ (match_operand 2 "pc_or_label_operand" "")
25+ (match_operand 3 "pc_or_label_operand" "")))
26 ]
27 "TARGET_MB_64"
28 {
29@@ -2368,11 +2368,11 @@ else
30
31 (define_insn "long_branch_zero"
32 [(set (pc)
33- (if_then_else (match_operator 0 "ordered_comparison_operator"
34- [(match_operand 1 "register_operand" "d")
35+ (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
36+ [(match_operand:DI 1 "register_operand" "d")
37 (const_int 0)])
38- (match_operand 2 "pc_or_label_operand" "")
39- (match_operand 3 "pc_or_label_operand" "")))
40+ (match_operand:DI 2 "pc_or_label_operand" "")
41+ (match_operand:DI 3 "pc_or_label_operand" "")))
42 ]
43 "TARGET_MB_64"
44 {
45--
462.17.1
47
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0046-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0046-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
new file mode 100644
index 00000000..eebf6ee7
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0046-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
@@ -0,0 +1,87 @@
1From 444a09859149f8d21777a1c859ef2305ff86b211 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Fri, 29 Mar 2019 12:08:39 +0530
4Subject: [PATCH 46/54] [Patch,Microblaze] : We will check the possibility of
5 peephole2 optimization,if we can then we will fix the compiler issue.
6
7---
8 gcc/config/microblaze/microblaze.md | 63 +++++++++++++++++------------
9 1 file changed, 38 insertions(+), 25 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index 207d2bf1b55..9b88666c0a6 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -882,31 +882,44 @@
16 (set_attr "mode" "SI")
17 (set_attr "length" "4")])
18
19-(define_peephole2
20- [(set (match_operand:SI 0 "register_operand")
21- (fix:SI (match_operand:SF 1 "register_operand")))
22- (set (pc)
23- (if_then_else (match_operator 2 "ordered_comparison_operator"
24- [(match_operand:SI 3 "register_operand")
25- (match_operand:SI 4 "arith_operand")])
26- (label_ref (match_operand 5))
27- (pc)))]
28- "TARGET_HARD_FLOAT && !TARGET_MB_64"
29- [(set (match_dup 1) (match_dup 3))]
30-
31- {
32- rtx condition;
33- rtx cmp_op0 = operands[3];
34- rtx cmp_op1 = operands[4];
35- rtx comp_reg = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
36-
37- emit_insn (gen_cstoresf4 (comp_reg, operands[2],
38- gen_rtx_REG (SFmode, REGNO (cmp_op0)),
39- gen_rtx_REG (SFmode, REGNO (cmp_op1))));
40- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
41- emit_jump_insn (gen_condjump (condition, operands[5]));
42- }
43-)
44+;; peephole2 optimization will be done only if fint and if-then-else
45+;; are dependent.added condition for the same.
46+;; if they are dependent then gcc is giving "flow control insn inside a basic block"
47+;; testcase:
48+;; volatile float vec = 1.0;
49+;; volatile int ci = 2;
50+;; register int cj = (int)(vec);
51+;;// ci=cj;
52+;;// if (ci <0) {
53+;; if (cj < 0) {
54+;; ci = 0;
55+;; }
56+;; commenting for now.we will check the possibility of this optimization later
57+
58+;;(define_peephole2
59+;; [(set (match_operand:SI 0 "register_operand")
60+;; (fix:SI (match_operand:SF 1 "register_operand")))
61+;; (set (pc)
62+;; (if_then_else (match_operator 2 "ordered_comparison_operator"
63+;; [(match_operand:SI 3 "register_operand")
64+;; (match_operand:SI 4 "arith_operand")])
65+;; (label_ref (match_operand 5))
66+;; (pc)))]
67+;; "TARGET_HARD_FLOAT && !TARGET_MB_64 && ((REGNO (operands[0])) == (REGNO (operands[3])))"
68+;; [(set (match_dup 1) (match_dup 3))]
69+;; {
70+;; rtx condition;
71+;; rtx cmp_op0 = operands[3];
72+;; rtx cmp_op1 = operands[4];
73+;; rtx comp_reg = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
74+;;
75+;; emit_insn (gen_cstoresf4 (comp_reg, operands[2],
76+;; gen_rtx_REG (SFmode, REGNO (cmp_op0)),
77+;; gen_rtx_REG (SFmode, REGNO (cmp_op1))));
78+;; condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
79+;; emit_jump_insn (gen_condjump (condition, operands[5]));
80+;; }
81+;;)
82
83 ;;----------------------------------------------------------------
84 ;; Negation and one's complement
85--
862.17.1
87
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0047-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0047-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
new file mode 100644
index 00000000..34378812
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0047-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
@@ -0,0 +1,466 @@
1From 7cc6db7ad5bf2fac80a81711c70ac1147ab87b2c Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 17 Apr 2019 12:36:16 +0530
4Subject: [PATCH 47/54] [Patch,MicroBlaze]: fixed typos in mul,div and mod
5 assembly files.
6
7---
8 libgcc/config/microblaze/divsi3.S | 47 ++++++++++++++++++++----
9 libgcc/config/microblaze/modsi3.S | 40 ++++++++++++++++++---
10 libgcc/config/microblaze/mulsi3.S | 33 ++++++++++++++++-
11 libgcc/config/microblaze/udivsi3.S | 54 +++++++++++++++++++++++++---
12 libgcc/config/microblaze/umodsi3.S | 58 +++++++++++++++++++++++++++---
13 5 files changed, 212 insertions(+), 20 deletions(-)
14
15diff --git a/libgcc/config/microblaze/divsi3.S b/libgcc/config/microblaze/divsi3.S
16index 104243e35fe..5755e29fbb6 100644
17--- a/libgcc/config/microblaze/divsi3.S
18+++ b/libgcc/config/microblaze/divsi3.S
19@@ -46,7 +46,7 @@
20 __divsi3:
21 .frame r1,0,r15
22
23- ADDIK r1,r1,-32
24+ ADDLIK r1,r1,-32
25 SLI r28,r1,0
26 SLI r29,r1,8
27 SLI r30,r1,16
28@@ -61,13 +61,23 @@ __divsi3:
29 SWI r30,r1,8
30 SWI r31,r1,12
31 #endif
32- BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
33- BEQI r5,$LaResult_Is_Zero # Result is Zero
34- BGEID r5,$LaR5_Pos
35+#ifdef __arch64__
36+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
37+ BEAEQI r5,$LaResult_Is_Zero # Result is Zero
38+ BEAGEID r5,$LaR5_Pos
39+#else
40+ BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
41+ BEQI r5,$LaResult_Is_Zero # Result is Zero
42+ BGEID r5,$LaR5_Pos
43+#endif
44 XOR r28,r5,r6 # Get the sign of the result
45 RSUBI r5,r5,0 # Make r5 positive
46 $LaR5_Pos:
47- BGEI r6,$LaR6_Pos
48+#ifdef __arch64__
49+ BEAGEI r6,$LaR6_Pos
50+#else
51+ BGEI r6,$LaR6_Pos
52+#endif
53 RSUBI r6,r6,0 # Make r6 positive
54 $LaR6_Pos:
55 ADDIK r30,r0,0 # Clear mod
56@@ -76,26 +86,51 @@ $LaR6_Pos:
57
58 # First part try to find the first '1' in the r5
59 $LaDIV0:
60- BLTI r5,$LaDIV2 # This traps r5 == 0x80000000
61+#ifdef __arch64__
62+ BEALTI r5,$LaDIV2 # This traps r5 == 0x80000000
63+#else
64+ BLTI r5,$LaDIV2 # This traps r5 == 0x80000000
65+#endif
66 $LaDIV1:
67 ADD r5,r5,r5 # left shift logical r5
68+#ifdef __arch64__
69+ BEAGTID r5,$LaDIV1
70+#else
71 BGTID r5,$LaDIV1
72+#endif
73 ADDIK r29,r29,-1
74 $LaDIV2:
75 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
76 ADDC r30,r30,r30 # Move that bit into the Mod register
77 RSUB r31,r6,r30 # Try to subtract (r30 a r6)
78+#ifdef __arch64__
79+ BEALTI r31,$LaMOD_TOO_SMALL
80+#else
81 BLTI r31,$LaMOD_TOO_SMALL
82+#endif
83 OR r30,r0,r31 # Move the r31 to mod since the result was positive
84 ADDIK r3,r3,1
85 $LaMOD_TOO_SMALL:
86 ADDIK r29,r29,-1
87+#ifdef __arch64__
88+ BEAEQi r29,$LaLOOP_END
89+#else
90 BEQi r29,$LaLOOP_END
91+#endif
92 ADD r3,r3,r3 # Shift in the '1' into div
93+#ifdef __arch64__
94+ BREAI $LaDIV2 # Div2
95+#else
96 BRI $LaDIV2 # Div2
97+#endif
98 $LaLOOP_END:
99+#ifdef __arch64__
100+ BEAGEI r28,$LaRETURN_HERE
101+ BREAID $LaRETURN_HERE
102+#else
103 BGEI r28,$LaRETURN_HERE
104 BRID $LaRETURN_HERE
105+#endif
106 RSUBI r3,r3,0 # Negate the result
107 $LaDiv_By_Zero:
108 $LaResult_Is_Zero:
109diff --git a/libgcc/config/microblaze/modsi3.S b/libgcc/config/microblaze/modsi3.S
110index 4dbb25900d9..b6129f5e822 100644
111--- a/libgcc/config/microblaze/modsi3.S
112+++ b/libgcc/config/microblaze/modsi3.S
113@@ -62,40 +62,72 @@ __modsi3:
114 swi r31,r1,12
115 #endif
116
117+#ifdef __arch64__
118+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
119+ BEAEQI r5,$LaResult_Is_Zero # Result is Zero
120+ BEAGEId r5,$LaR5_Pos
121+#else
122 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
123 BEQI r5,$LaResult_Is_Zero # Result is Zero
124 BGEId r5,$LaR5_Pos
125+#endif
126 ADD r28,r5,r0 # Get the sign of the result [ Depends only on the first arg]
127 RSUBI r5,r5,0 # Make r5 positive
128 $LaR5_Pos:
129- BGEI r6,$LaR6_Pos
130+#ifdef __arch64__
131+ BEAGEI r6,$LaR6_Pos
132+#else
133+ BGEI r6,$LaR6_Pos
134+#endif
135 RSUBI r6,r6,0 # Make r6 positive
136 $LaR6_Pos:
137 ADDIK r3,r0,0 # Clear mod
138 ADDIK r30,r0,0 # clear div
139- BLTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
140+#ifdef __arch64__
141+ BEALTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
142 # the first bit search.
143+#else
144+ BLTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
145+ # the first bit search.
146+#endif
147 ADDIK r29,r0,32 # Initialize the loop count
148 # First part try to find the first '1' in the r5
149 $LaDIV1:
150 ADD r5,r5,r5 # left shift logical r5
151- BGEID r5,$LaDIV1 #
152+#ifdef __arch64__
153+ BEAGEID r5,$LaDIV1 #
154+#else
155+ BGEID r5,$LaDIV1 #
156+#endif
157 ADDIK r29,r29,-1
158 $LaDIV2:
159 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
160 ADDC r3,r3,r3 # Move that bit into the Mod register
161 rSUB r31,r6,r3 # Try to subtract (r30 a r6)
162+#ifdef __arch64__
163+ BEALTi r31,$LaMOD_TOO_SMALL
164+#else
165 BLTi r31,$LaMOD_TOO_SMALL
166+#endif
167 OR r3,r0,r31 # Move the r31 to mod since the result was positive
168 ADDIK r30,r30,1
169 $LaMOD_TOO_SMALL:
170 ADDIK r29,r29,-1
171+#ifdef __arch64__
172+ BEAEQi r29,$LaLOOP_END
173+ ADD r30,r30,r30 # Shift in the '1' into div
174+ BREAI $LaDIV2 # Div2
175+$LaLOOP_END:
176+ BEAGEI r28,$LaRETURN_HERE
177+ BREAId $LaRETURN_HERE
178+#else
179 BEQi r29,$LaLOOP_END
180 ADD r30,r30,r30 # Shift in the '1' into div
181 BRI $LaDIV2 # Div2
182 $LaLOOP_END:
183 BGEI r28,$LaRETURN_HERE
184 BRId $LaRETURN_HERE
185+#endif
186 rsubi r3,r3,0 # Negate the result
187 $LaDiv_By_Zero:
188 $LaResult_Is_Zero:
189@@ -108,7 +140,7 @@ $LaRETURN_HERE:
190 lli r29,r1,8
191 lli r30,r1,16
192 lli r31,r1,24
193- addik r1,r1,32
194+ addlik r1,r1,32
195 rtsd r15,8
196 nop
197 #else
198diff --git a/libgcc/config/microblaze/mulsi3.S b/libgcc/config/microblaze/mulsi3.S
199index 2044399db4a..95709d5bb01 100644
200--- a/libgcc/config/microblaze/mulsi3.S
201+++ b/libgcc/config/microblaze/mulsi3.S
202@@ -43,7 +43,37 @@
203 .type __mulsi3,@function
204 #ifdef __arch64__
205 .align 3
206-#endif
207+__mulsi3:
208+ .frame r1,0,r15
209+ add r3,r0,r0
210+ BEAEQI r5,$L_Result_Is_Zero # Multiply by Zero
211+ BEAEQI r6,$L_Result_Is_Zero # Multiply by Zero
212+ BEAGEId r5,$L_R5_Pos
213+ XOR r4,r5,r6 # Get the sign of the result
214+ RSUBI r5,r5,0 # Make r5 positive
215+$L_R5_Pos:
216+ BEAGEI r6,$L_R6_Pos
217+ RSUBI r6,r6,0 # Make r6 positive
218+$L_R6_Pos:
219+ breai $L1
220+$L2:
221+ add r5,r5,r5
222+$L1:
223+ srl r6,r6
224+ addc r7,r0,r0
225+ beaeqi r7,$L2
226+ beaneid r6,$L2
227+ add r3,r3,r5
228+ bealti r4,$L_NegateResult
229+ rtsd r15,8
230+ nop
231+$L_NegateResult:
232+ rtsd r15,8
233+ rsub r3,r3,r0
234+$L_Result_Is_Zero:
235+ rtsd r15,8
236+ addi r3,r0,0
237+#else
238 __mulsi3:
239 .frame r1,0,r15
240 add r3,r0,r0
241@@ -74,5 +104,6 @@ $L_NegateResult:
242 $L_Result_Is_Zero:
243 rtsd r15,8
244 addi r3,r0,0
245+#endif
246 .end __mulsi3
247 .size __mulsi3, . - __mulsi3
248diff --git a/libgcc/config/microblaze/udivsi3.S b/libgcc/config/microblaze/udivsi3.S
249index d2332bcfe62..687d5588801 100644
250--- a/libgcc/config/microblaze/udivsi3.S
251+++ b/libgcc/config/microblaze/udivsi3.S
252@@ -59,52 +59,96 @@ __udivsi3:
253 SWI r30,r1,4
254 SWI r31,r1,8
255 #endif
256+#ifdef __arch64__
257+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
258+ BEAEQID r5,$LaResult_Is_Zero # Result is Zero
259+#else
260 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
261 BEQID r5,$LaResult_Is_Zero # Result is Zero
262+#endif
263 ADDIK r30,r0,0 # Clear mod
264 ADDIK r29,r0,32 # Initialize the loop count
265
266 # Check if r6 and r5 are equal # if yes, return 1
267 RSUB r18,r5,r6
268+#ifdef __arch64__
269+ BEAEQID r18,$LaRETURN_HERE
270+#else
271 BEQID r18,$LaRETURN_HERE
272+#endif
273 ADDIK r3,r0,1
274
275 # Check if (uns)r6 is greater than (uns)r5. In that case, just return 0
276 XOR r18,r5,r6
277- BGEID r18,16
278+#ifdef __arch64__
279+ BEAGEID r18,16
280+#else
281+ BGEID r18,16
282+#endif
283 ADD r3,r0,r0 # We would anyways clear r3
284+#ifdef __arch64__
285+ BEALTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
286+ BREAI $LCheckr6
287+ RSUB r18,r6,r5 # MICROBLAZEcmp
288+ BEALTI r18,$LaRETURN_HERE
289+#else
290 BLTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
291 BRI $LCheckr6
292 RSUB r18,r6,r5 # MICROBLAZEcmp
293 BLTI r18,$LaRETURN_HERE
294-
295+#endif
296 # If r6 [bit 31] is set, then return result as 1
297 $LCheckr6:
298- BGTI r6,$LaDIV0
299- BRID $LaRETURN_HERE
300+#ifdef __arch64__
301+ BEAGTI r6,$LaDIV0
302+ BREAID $LaRETURN_HERE
303+#else
304+ BGTI r6,$LaDIV0
305+ BRID $LaRETURN_HERE
306+#endif
307 ADDIK r3,r0,1
308
309 # First part try to find the first '1' in the r5
310 $LaDIV0:
311+#ifdef __arch64__
312+ BEALTI r5,$LaDIV2
313+#else
314 BLTI r5,$LaDIV2
315+#endif
316 $LaDIV1:
317 ADD r5,r5,r5 # left shift logical r5
318+#ifdef __arch64__
319+ BEAGTID r5,$LaDIV1
320+#else
321 BGTID r5,$LaDIV1
322+#endif
323 ADDIK r29,r29,-1
324 $LaDIV2:
325 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
326 ADDC r30,r30,r30 # Move that bit into the Mod register
327 RSUB r31,r6,r30 # Try to subtract (r30 a r6)
328+#ifdef __arch64__
329+ BEALTI r31,$LaMOD_TOO_SMALL
330+#else
331 BLTI r31,$LaMOD_TOO_SMALL
332+#endif
333 OR r30,r0,r31 # Move the r31 to mod since the result was positive
334 ADDIK r3,r3,1
335 $LaMOD_TOO_SMALL:
336 ADDIK r29,r29,-1
337+#ifdef __arch64__
338+ BEAEQi r29,$LaLOOP_END
339+ ADD r3,r3,r3 # Shift in the '1' into div
340+ BREAI $LaDIV2 # Div2
341+$LaLOOP_END:
342+ BREAI $LaRETURN_HERE
343+#else
344 BEQi r29,$LaLOOP_END
345 ADD r3,r3,r3 # Shift in the '1' into div
346 BRI $LaDIV2 # Div2
347 $LaLOOP_END:
348 BRI $LaRETURN_HERE
349+#endif
350 $LaDiv_By_Zero:
351 $LaResult_Is_Zero:
352 OR r3,r0,r0 # set result to 0
353@@ -115,7 +159,7 @@ $LaRETURN_HERE:
354 LLI r29,r1,0
355 LLI r30,r1,8
356 LLI r31,r1,16
357- ADDIK r1,r1,24
358+ ADDLIK r1,r1,24
359 RTSD r15,8
360 NOP
361 #else
362diff --git a/libgcc/config/microblaze/umodsi3.S b/libgcc/config/microblaze/umodsi3.S
363index 2dd72aef68e..59646ce437f 100644
364--- a/libgcc/config/microblaze/umodsi3.S
365+++ b/libgcc/config/microblaze/umodsi3.S
366@@ -46,7 +46,7 @@
367 __umodsi3:
368 .frame r1,0,r15
369
370- addik r1,r1,-24
371+ addlik r1,r1,-24
372 sli r29,r1,0
373 sli r30,r1,8
374 sli r31,r1,16
375@@ -59,27 +59,77 @@ __umodsi3:
376 swi r30,r1,4
377 swi r31,r1,8
378 #endif
379+#ifdef __arch64__
380+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
381+ BEAEQId r5,$LaResult_Is_Zero # Result is Zero
382+#else
383 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
384 BEQId r5,$LaResult_Is_Zero # Result is Zero
385+#endif
386 ADDIK r3,r0,0 # Clear div
387 ADDIK r30,r0,0 # clear mod
388 ADDIK r29,r0,32 # Initialize the loop count
389
390 # Check if r6 and r5 are equal # if yes, return 0
391 rsub r18,r5,r6
392- beqi r18,$LaRETURN_HERE
393
394+#ifdef __arch64__
395+ beaeqi r18,$LaRETURN_HERE
396+#else
397+ beqi r18,$LaRETURN_HERE
398+#endif
399 # Check if (uns)r6 is greater than (uns)r5. In that case, just return r5
400 xor r18,r5,r6
401+#ifdef __arch64__
402+ beageid r18,16
403+ addik r3,r5,0
404+ bealti r6,$LaRETURN_HERE
405+ breai $LCheckr6
406+ rsub r18,r5,r6 # MICROBLAZEcmp
407+ beagti r18,$LaRETURN_HERE
408+#else
409 bgeid r18,16
410 addik r3,r5,0
411 blti r6,$LaRETURN_HERE
412 bri $LCheckr6
413 rsub r18,r5,r6 # MICROBLAZEcmp
414 bgti r18,$LaRETURN_HERE
415-
416+#endif
417 # If r6 [bit 31] is set, then return result as r5-r6
418 $LCheckr6:
419+#ifdef __arch64__
420+ beagtid r6,$LaDIV0
421+ addik r3,r0,0
422+ addik r18,r0,0x7fffffff
423+ and r5,r5,r18
424+ and r6,r6,r18
425+ breaid $LaRETURN_HERE
426+ rsub r3,r6,r5
427+# First part: try to find the first '1' in the r5
428+$LaDIV0:
429+ BEALTI r5,$LaDIV2
430+$LaDIV1:
431+ ADD r5,r5,r5 # left shift logical r5
432+ BEAGEID r5,$LaDIV1 #
433+ ADDIK r29,r29,-1
434+$LaDIV2:
435+ ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
436+ ADDC r3,r3,r3 # Move that bit into the Mod register
437+ rSUB r31,r6,r3 # Try to subtract (r3 a r6)
438+ BEALTi r31,$LaMOD_TOO_SMALL
439+ OR r3,r0,r31 # Move the r31 to mod since the result was positive
440+ ADDIK r30,r30,1
441+$LaMOD_TOO_SMALL:
442+ ADDIK r29,r29,-1
443+ BEAEQi r29,$LaLOOP_END
444+ ADD r30,r30,r30 # Shift in the '1' into div
445+ BREAI $LaDIV2 # Div2
446+$LaLOOP_END:
447+ BREAI $LaRETURN_HERE
448+$LaDiv_By_Zero:
449+$LaResult_Is_Zero:
450+ or r3,r0,r0 # set result to 0
451+#else
452 bgtid r6,$LaDIV0
453 addik r3,r0,0
454 addik r18,r0,0x7fffffff
455@@ -111,7 +161,7 @@ $LaLOOP_END:
456 $LaDiv_By_Zero:
457 $LaResult_Is_Zero:
458 or r3,r0,r0 # set result to 0
459-
460+#endif
461 #ifdef __arch64__
462 $LaRETURN_HERE:
463 # Restore values of CSRs and that of r3 and the divisor and the dividend
464--
4652.17.1
466
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0048-Author-Nagaraju-nmekala-xilinx.com.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0048-Author-Nagaraju-nmekala-xilinx.com.patch
new file mode 100644
index 00000000..94be6aff
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0048-Author-Nagaraju-nmekala-xilinx.com.patch
@@ -0,0 +1,479 @@
1From f6b896effc198b8d9d1e6f33889f029da5e5d96c Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 18 Apr 2019 16:00:37 +0530
4Subject: [PATCH 48/54] Author: Nagaraju <nmekala@xilinx.com> Date: Wed Apr
5 17 14:11:00 2019 +0530
6
7 [Patch, microblaze]: MB-64 removal of barrel-shift instructions from default
8 By default MB-64 is generatting barrel-shift instructions. It has been
9 removed from default. Barrel-shift instructions will be generated only if
10 barrel-shifter is enabled. Similarly to double instructions as well.
11
12 Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
13---
14 gcc/config/microblaze/microblaze.c | 2 +-
15 gcc/config/microblaze/microblaze.md | 269 ++++++++++++++++++++++++++--
16 2 files changed, 252 insertions(+), 19 deletions(-)
17
18diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
19index e32de46fa62..7b48c011550 100644
20--- a/gcc/config/microblaze/microblaze.c
21+++ b/gcc/config/microblaze/microblaze.c
22@@ -3870,7 +3870,7 @@ microblaze_expand_divide (rtx operands[])
23 emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
24
25 if (TARGET_MB_64) {
26- emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
27+ emit_insn (gen_ashldi3 (regt1, operands[1], GEN_INT(4)));
28 emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
29 }
30 else {
31diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
32index 9b88666c0a6..60afd9be288 100644
33--- a/gcc/config/microblaze/microblaze.md
34+++ b/gcc/config/microblaze/microblaze.md
35@@ -547,7 +547,7 @@
36 [(set (match_operand:DF 0 "register_operand" "=d")
37 (plus:DF (match_operand:DF 1 "register_operand" "d")
38 (match_operand:DF 2 "register_operand" "d")))]
39- "TARGET_MB_64"
40+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
41 "dadd\t%0,%1,%2"
42 [(set_attr "type" "fadd")
43 (set_attr "mode" "DF")
44@@ -557,7 +557,7 @@
45 [(set (match_operand:DF 0 "register_operand" "=d")
46 (minus:DF (match_operand:DF 1 "register_operand" "d")
47 (match_operand:DF 2 "register_operand" "d")))]
48- "TARGET_MB_64"
49+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
50 "drsub\t%0,%2,%1"
51 [(set_attr "type" "frsub")
52 (set_attr "mode" "DF")
53@@ -567,7 +567,7 @@
54 [(set (match_operand:DF 0 "register_operand" "=d")
55 (mult:DF (match_operand:DF 1 "register_operand" "d")
56 (match_operand:DF 2 "register_operand" "d")))]
57- "TARGET_MB_64"
58+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
59 "dmul\t%0,%1,%2"
60 [(set_attr "type" "fmul")
61 (set_attr "mode" "DF")
62@@ -577,7 +577,7 @@
63 [(set (match_operand:DF 0 "register_operand" "=d")
64 (div:DF (match_operand:DF 1 "register_operand" "d")
65 (match_operand:DF 2 "register_operand" "d")))]
66- "TARGET_MB_64"
67+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
68 "ddiv\t%0,%2,%1"
69 [(set_attr "type" "fdiv")
70 (set_attr "mode" "DF")
71@@ -587,7 +587,7 @@
72 (define_insn "sqrtdf2"
73 [(set (match_operand:DF 0 "register_operand" "=d")
74 (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
75- "TARGET_MB_64"
76+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
77 "dsqrt\t%0,%1"
78 [(set_attr "type" "fsqrt")
79 (set_attr "mode" "DF")
80@@ -596,7 +596,7 @@
81 (define_insn "floatdidf2"
82 [(set (match_operand:DF 0 "register_operand" "=d")
83 (float:DF (match_operand:DI 1 "register_operand" "d")))]
84- "TARGET_MB_64"
85+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
86 "dbl\t%0,%1"
87 [(set_attr "type" "fcvt")
88 (set_attr "mode" "DF")
89@@ -605,7 +605,7 @@
90 (define_insn "fix_truncdfdi2"
91 [(set (match_operand:DI 0 "register_operand" "=d")
92 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
93- "TARGET_MB_64"
94+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
95 "dlong\t%0,%1"
96 [(set_attr "type" "fcvt")
97 (set_attr "mode" "DI")
98@@ -1301,6 +1301,34 @@
99 (set_attr "mode" "DI")
100 (set_attr "length" "4")])
101
102+(define_insn "*movdi_internal2_bshift"
103+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
104+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
105+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
106+ {
107+ switch (which_alternative)
108+ {
109+ case 0:
110+ return "addlk\t%0,%1,r0";
111+ case 1:
112+ case 2:
113+ if (GET_CODE (operands[1]) == CONST_INT &&
114+ (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
115+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
116+ else
117+ return "addlik\t%0,r0,%1";
118+ case 3:
119+ case 4:
120+ return "ll%i1\t%0,%1";
121+ case 5:
122+ case 6:
123+ return "sl%i0\t%z1,%0";
124+ }
125+ }
126+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
127+ (set_attr "mode" "DI")
128+ (set_attr "length" "4,4,12,4,8,4,8")])
129+
130 (define_insn "*movdi_internal2"
131 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
132 (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
133@@ -1314,7 +1342,15 @@
134 case 2:
135 if (GET_CODE (operands[1]) == CONST_INT &&
136 (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
137- return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
138+ {
139+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
140+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
141+ output_asm_insn ("addlik\t%2,r0,32", operands);
142+ output_asm_insn ("addlik\t%2,%2,-1", operands);
143+ output_asm_insn ("beaneid\t%2,.-8", operands);
144+ output_asm_insn ("addlk\t%0,%0,%0", operands);
145+ return "addlik\t%0,%0,%j1 #li => la";
146+ }
147 else
148 return "addlik\t%0,r0,%1";
149 case 3:
150@@ -1389,7 +1425,7 @@
151 (define_insn "movdi_long_int"
152 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
153 (match_operand:DI 1 "general_operand" "i"))]
154- "TARGET_MB_64"
155+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
156 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
157 [(set_attr "type" "no_delay_arith")
158 (set_attr "mode" "DI")
159@@ -1656,6 +1692,33 @@
160 ;; movdf_internal
161 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
162 ;;
163+(define_insn "*movdf_internal_64_bshift"
164+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
165+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
166+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
167+ {
168+ switch (which_alternative)
169+ {
170+ case 0:
171+ return "addlk\t%0,%1,r0";
172+ case 1:
173+ return "addlk\t%0,r0,r0";
174+ case 2:
175+ case 4:
176+ return "ll%i1\t%0,%1";
177+ case 3:
178+ {
179+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
180+ }
181+ case 5:
182+ return "sl%i0\t%1,%0";
183+ }
184+ gcc_unreachable ();
185+ }
186+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
187+ (set_attr "mode" "DF")
188+ (set_attr "length" "4,4,4,16,4,4")])
189+
190 (define_insn "*movdf_internal_64"
191 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
192 (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
193@@ -1672,7 +1735,13 @@
194 return "ll%i1\t%0,%1";
195 case 3:
196 {
197- return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
198+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
199+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
200+ output_asm_insn ("addlik\t%2,r0,32", operands);
201+ output_asm_insn ("addlik\t%2,%2,-1", operands);
202+ output_asm_insn ("beaneid\t%2,.-8", operands);
203+ output_asm_insn ("addlk\t%0,%0,%0", operands);
204+ return "addlik\t%0,%0,%j1 #li => la";
205 }
206 case 5:
207 return "sl%i0\t%1,%0";
208@@ -1792,11 +1861,21 @@
209 "TARGET_MB_64"
210 {
211 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
212-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
213+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
214 {
215 emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
216 DONE;
217 }
218+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
219+ {
220+ emit_insn(gen_ashldi3_const (operands[0], operands[1],operands[2]));
221+ DONE;
222+ }
223+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
224+ {
225+ emit_insn(gen_ashldi3_reg (operands[0], operands[1],operands[2]));
226+ DONE;
227+ }
228 else
229 FAIL;
230 }
231@@ -1806,7 +1885,7 @@ else
232 [(set (match_operand:DI 0 "register_operand" "=d,d")
233 (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
234 (match_operand:DI 2 "arith_operand" "I,d")))]
235- "TARGET_MB_64"
236+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
237 "@
238 bsllli\t%0,%1,%2
239 bslll\t%0,%1,%2"
240@@ -1814,6 +1893,51 @@ else
241 (set_attr "mode" "DI,DI")
242 (set_attr "length" "4,4")]
243 )
244+
245+(define_insn "ashldi3_const"
246+ [(set (match_operand:DI 0 "register_operand" "=&d")
247+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
248+ (match_operand:DI 2 "immediate_operand" "I")))]
249+ "TARGET_MB_64"
250+ {
251+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
252+
253+ output_asm_insn ("orli\t%3,r0,%2", operands);
254+ if (REGNO (operands[0]) != REGNO (operands[1]))
255+ output_asm_insn ("addlk\t%0,%1,r0", operands);
256+
257+ output_asm_insn ("addlik\t%3,%3,-1", operands);
258+ output_asm_insn ("beaneid\t%3,.-8", operands);
259+ return "addlk\t%0,%0,%0";
260+ }
261+ [(set_attr "type" "multi")
262+ (set_attr "mode" "DI")
263+ (set_attr "length" "20")]
264+)
265+
266+(define_insn "ashldi3_reg"
267+ [(set (match_operand:DI 0 "register_operand" "=&d")
268+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
269+ (match_operand:DI 2 "register_operand" "d")))]
270+ "TARGET_MB_64"
271+ {
272+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
273+ output_asm_insn ("andli\t%3,%2,31", operands);
274+ if (REGNO (operands[0]) != REGNO (operands[1]))
275+ output_asm_insn ("addlk\t%0,r0,%1", operands);
276+ /* Exit the loop if zero shift. */
277+ output_asm_insn ("beaeqid\t%3,.+24", operands);
278+ /* Emit the loop. */
279+ output_asm_insn ("addlk\t%0,%0,r0", operands);
280+ output_asm_insn ("addlik\t%3,%3,-1", operands);
281+ output_asm_insn ("beaneid\t%3,.-8", operands);
282+ return "addlk\t%0,%0,%0";
283+ }
284+ [(set_attr "type" "multi")
285+ (set_attr "mode" "DI")
286+ (set_attr "length" "28")]
287+)
288+
289 ;; The following patterns apply when there is no barrel shifter present
290
291 (define_insn "*ashlsi3_with_mul_delay"
292@@ -1947,11 +2071,21 @@ else
293 "TARGET_MB_64"
294 {
295 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
296-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
297+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
298 {
299 emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
300 DONE;
301 }
302+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
303+ {
304+ emit_insn(gen_ashrdi3_const (operands[0], operands[1],operands[2]));
305+ DONE;
306+ }
307+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
308+ {
309+ emit_insn(gen_ashrdi3_reg (operands[0], operands[1],operands[2]));
310+ DONE;
311+ }
312 else
313 FAIL;
314 }
315@@ -1961,7 +2095,7 @@ else
316 [(set (match_operand:DI 0 "register_operand" "=d,d")
317 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
318 (match_operand:DI 2 "arith_operand" "I,d")))]
319- "TARGET_MB_64"
320+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
321 "@
322 bslrai\t%0,%1,%2
323 bslra\t%0,%1,%2"
324@@ -1969,6 +2103,51 @@ else
325 (set_attr "mode" "DI,DI")
326 (set_attr "length" "4,4")]
327 )
328+
329+(define_insn "ashrdi3_const"
330+ [(set (match_operand:DI 0 "register_operand" "=&d")
331+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
332+ (match_operand:DI 2 "immediate_operand" "I")))]
333+ "TARGET_MB_64"
334+ {
335+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
336+
337+ output_asm_insn ("orli\t%3,r0,%2", operands);
338+ if (REGNO (operands[0]) != REGNO (operands[1]))
339+ output_asm_insn ("addlk\t%0,%1,r0", operands);
340+
341+ output_asm_insn ("addlik\t%3,%3,-1", operands);
342+ output_asm_insn ("beaneid\t%3,.-8", operands);
343+ return "srla\t%0,%0";
344+ }
345+ [(set_attr "type" "arith")
346+ (set_attr "mode" "DI")
347+ (set_attr "length" "20")]
348+)
349+
350+(define_insn "ashrdi3_reg"
351+ [(set (match_operand:DI 0 "register_operand" "=&d")
352+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
353+ (match_operand:DI 2 "register_operand" "d")))]
354+ "TARGET_MB_64"
355+ {
356+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
357+ output_asm_insn ("andli\t%3,%2,31", operands);
358+ if (REGNO (operands[0]) != REGNO (operands[1]))
359+ output_asm_insn ("addlk\t%0,r0,%1", operands);
360+ /* Exit the loop if zero shift. */
361+ output_asm_insn ("beaeqid\t%3,.+24", operands);
362+ /* Emit the loop. */
363+ output_asm_insn ("addlk\t%0,%0,r0", operands);
364+ output_asm_insn ("addlik\t%3,%3,-1", operands);
365+ output_asm_insn ("beaneid\t%3,.-8", operands);
366+ return "srla\t%0,%0";
367+ }
368+ [(set_attr "type" "multi")
369+ (set_attr "mode" "DI")
370+ (set_attr "length" "28")]
371+)
372+
373 (define_expand "ashrsi3"
374 [(set (match_operand:SI 0 "register_operand" "=&d")
375 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
376@@ -2086,11 +2265,21 @@ else
377 "TARGET_MB_64"
378 {
379 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
380-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
381+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
382 {
383 emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
384 DONE;
385 }
386+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
387+ {
388+ emit_insn(gen_lshrdi3_const (operands[0], operands[1],operands[2]));
389+ DONE;
390+ }
391+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
392+ {
393+ emit_insn(gen_lshrdi3_reg (operands[0], operands[1],operands[2]));
394+ DONE;
395+ }
396 else
397 FAIL;
398 }
399@@ -2100,7 +2289,7 @@ else
400 [(set (match_operand:DI 0 "register_operand" "=d,d")
401 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
402 (match_operand:DI 2 "arith_operand" "I,d")))]
403- "TARGET_MB_64"
404+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
405 "@
406 bslrli\t%0,%1,%2
407 bslrl\t%0,%1,%2"
408@@ -2109,6 +2298,50 @@ else
409 (set_attr "length" "4,4")]
410 )
411
412+(define_insn "lshrdi3_const"
413+ [(set (match_operand:DI 0 "register_operand" "=&d")
414+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
415+ (match_operand:DI 2 "immediate_operand" "I")))]
416+ "TARGET_MB_64"
417+ {
418+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
419+
420+ output_asm_insn ("orli\t%3,r0,%2", operands);
421+ if (REGNO (operands[0]) != REGNO (operands[1]))
422+ output_asm_insn ("addlk\t%0,%1,r0", operands);
423+
424+ output_asm_insn ("addlik\t%3,%3,-1", operands);
425+ output_asm_insn ("beaneid\t%3,.-8", operands);
426+ return "srll\t%0,%0";
427+ }
428+ [(set_attr "type" "multi")
429+ (set_attr "mode" "DI")
430+ (set_attr "length" "20")]
431+)
432+
433+(define_insn "lshrdi3_reg"
434+ [(set (match_operand:DI 0 "register_operand" "=&d")
435+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
436+ (match_operand:DI 2 "register_operand" "d")))]
437+ "TARGET_MB_64"
438+ {
439+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
440+ output_asm_insn ("andli\t%3,%2,31", operands);
441+ if (REGNO (operands[0]) != REGNO (operands[1]))
442+ output_asm_insn ("addlk\t%0,r0,%1", operands);
443+ /* Exit the loop if zero shift. */
444+ output_asm_insn ("beaeqid\t%3,.+24", operands);
445+ /* Emit the loop. */
446+ output_asm_insn ("addlk\t%0,%0,r0", operands);
447+ output_asm_insn ("addlik\t%3,%3,-1", operands);
448+ output_asm_insn ("beaneid\t%3,.-8", operands);
449+ return "srll\t%0,%0";
450+ }
451+ [(set_attr "type" "multi")
452+ (set_attr "mode" "SI")
453+ (set_attr "length" "28")]
454+)
455+
456 (define_expand "lshrsi3"
457 [(set (match_operand:SI 0 "register_operand" "=&d")
458 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
459@@ -2236,7 +2469,7 @@ else
460 (eq:DI
461 (match_operand:DI 1 "register_operand" "d")
462 (match_operand:DI 2 "register_operand" "d")))]
463- "TARGET_MB_64"
464+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
465 "pcmpleq\t%0,%1,%2"
466 [(set_attr "type" "arith")
467 (set_attr "mode" "DI")
468@@ -2248,7 +2481,7 @@ else
469 (ne:DI
470 (match_operand:DI 1 "register_operand" "d")
471 (match_operand:DI 2 "register_operand" "d")))]
472- "TARGET_MB_64"
473+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
474 "pcmplne\t%0,%1,%2"
475 [(set_attr "type" "arith")
476 (set_attr "mode" "DI")
477--
4782.17.1
479
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0049-Added-new-MB-64-single-register-arithmetic-instructi.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0049-Added-new-MB-64-single-register-arithmetic-instructi.patch
new file mode 100644
index 00000000..81ecbf8e
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0049-Added-new-MB-64-single-register-arithmetic-instructi.patch
@@ -0,0 +1,107 @@
1From adb1b8d8cc2a8fb99f474d9166db9f68b8f3f8b4 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Fri, 23 Aug 2019 16:16:53 +0530
4Subject: [PATCH 49/54] Added new MB-64 single register arithmetic instructions
5
6---
7 gcc/config/microblaze/microblaze.md | 56 +++++++++++++++++++++++++++++
8 1 file changed, 56 insertions(+)
9
10diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
11index 60afd9be288..1ad139cbd44 100644
12--- a/gcc/config/microblaze/microblaze.md
13+++ b/gcc/config/microblaze/microblaze.md
14@@ -654,6 +654,18 @@
15 }
16 })
17
18+(define_insn "adddi3_int"
19+ [(set (match_operand:DI 0 "register_operand" "=d")
20+ (plus:DI (match_operand:DI 1 "register_operand" "%0")
21+ (match_operand:DI 2 "immediate_operand" "I")))]
22+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
23+ "@
24+ addlik\t%0,%2"
25+ [(set_attr "type" "darith")
26+ (set_attr "mode" "DI")
27+ (set_attr "length" "4")]
28+)
29+
30 (define_insn "*adddi3_long"
31 [(set (match_operand:DI 0 "register_operand" "=d,d")
32 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
33@@ -719,6 +731,18 @@
34 {
35 }")
36
37+(define_insn "subdi316imm"
38+ [(set (match_operand:DI 0 "register_operand" "=d")
39+ (minus:DI (match_operand:DI 1 "register_operand" "d")
40+ (match_operand:DI 2 "arith_operand" "K")))]
41+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767) && (REGNO (operands[0]) == REGNO (operands[1]))"
42+ "@
43+ addlik\t%0,-%2"
44+ [(set_attr "type" "darith")
45+ (set_attr "mode" "DI")
46+ (set_attr "length" "4")])
47+
48+
49 (define_insn "subsidi3"
50 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
51 (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
52@@ -1015,6 +1039,17 @@
53 ;; Logical
54 ;;----------------------------------------------------------------
55
56+(define_insn "anddi3imm16"
57+ [(set (match_operand:DI 0 "register_operand" "=d")
58+ (and:DI (match_operand:DI 1 "arith_operand" "%0")
59+ (match_operand:DI 2 "arith_operand" "K")))]
60+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
61+ "@
62+ andli\t%0,%2"
63+ [(set_attr "type" "darith")
64+ (set_attr "mode" "DI")
65+ (set_attr "length" "4")])
66+
67 (define_insn "anddi3"
68 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
69 (and:DI (match_operand:DI 1 "arith_operand" "d,d,d")
70@@ -1042,6 +1077,16 @@
71 (set_attr "mode" "SI,SI,SI,SI")
72 (set_attr "length" "4,8,8,8")])
73
74+(define_insn "iordi3imm16"
75+ [(set (match_operand:DI 0 "register_operand" "=d")
76+ (ior:DI (match_operand:DI 1 "arith_operand" "%0")
77+ (match_operand:DI 2 "arith_operand" "K")))]
78+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
79+ "@
80+ orli\t%0,%2"
81+ [(set_attr "type" "darith")
82+ (set_attr "mode" "DI")
83+ (set_attr "length" "4")])
84
85 (define_insn "iordi3"
86 [(set (match_operand:DI 0 "register_operand" "=d,d")
87@@ -1069,6 +1114,17 @@
88 (set_attr "mode" "SI,SI,SI,SI")
89 (set_attr "length" "4,8,8,8")])
90
91+(define_insn "xordi3imm16"
92+ [(set (match_operand:DI 0 "register_operand" "=d")
93+ (xor:DI (match_operand:DI 1 "arith_operand" "%0")
94+ (match_operand:DI 2 "arith_operand" "K")))]
95+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
96+ "@
97+ xorli\t%0,%2"
98+ [(set_attr "type" "darith")
99+ (set_attr "mode" "DI")
100+ (set_attr "length" "4")])
101+
102 (define_insn "xordi3"
103 [(set (match_operand:DI 0 "register_operand" "=d,d")
104 (xor:DI (match_operand:DI 1 "arith_operand" "%d,d")
105--
1062.17.1
107
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0050-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0050-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch
new file mode 100644
index 00000000..d452b988
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0050-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch
@@ -0,0 +1,44 @@
1From 797697692635d4c536181cb007b3b0d63d2431c1 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 26 Aug 2019 15:55:22 +0530
4Subject: [PATCH 50/54] [Patch,MicroBlaze] : Added support for 64 bit Immediate
5 values.
6
7---
8 gcc/config/microblaze/constraints.md | 4 ++--
9 gcc/config/microblaze/microblaze.md | 3 +--
10 2 files changed, 3 insertions(+), 4 deletions(-)
11
12diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
13index 89db511c453..9ad2b099310 100644
14--- a/gcc/config/microblaze/constraints.md
15+++ b/gcc/config/microblaze/constraints.md
16@@ -53,9 +53,9 @@
17 (match_test "ival > 0 && ival < 0x10000")))
18
19 (define_constraint "K"
20- "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
21+ "A constant in the range -9223372036854775808 to 9223372036854775807 (inclusive)."
22 (and (match_code "const_int")
23- (match_test "ival > (long long)-549755813888 && ival < (long long)549755813887")))
24+ (match_test "ival > (long long)-9223372036854775808 && ival < (long long)9223372036854775807")))
25
26
27 ;; Define floating point constraints
28diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
29index 1ad139cbd44..93de8d831fd 100644
30--- a/gcc/config/microblaze/microblaze.md
31+++ b/gcc/config/microblaze/microblaze.md
32@@ -1334,8 +1334,7 @@
33 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d")
34 (match_operand:DI 1 "immediate_operand" "J,I,Mnis"))]
35 "TARGET_MB_64 && (register_operand (operands[0], DImode) &&
36- (GET_CODE (operands[1]) == CONST_INT &&
37- (INTVAL (operands[1]) <= (long long)549755813887 && INTVAL (operands[1]) >= (long long)-549755813888)))"
38+ (GET_CODE (operands[1]) == CONST_INT))"
39 "@
40 addlk\t%0,r0,r0\t
41 addlik\t%0,r0,%1\t #N1 %X1
42--
432.17.1
44
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0051-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0051-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch
new file mode 100644
index 00000000..3e0c483b
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0051-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch
@@ -0,0 +1,86 @@
1From 697db2e2c2519f27011fbd1960cd8860133aaa84 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 9 Jan 2020 12:30:41 +0530
4Subject: [PATCH 51/54] [Patch, microblaze]: Fix Compiler crash with
5 -freg-struct-return This patch fixes a bug in MB GCC regarding the passing
6 struct values in registers. Currently we are only handling SImode With this
7 patch all other modes are handled properly
8
9Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10
11ChangeLog:
122020-01-09 Nagaraju Mekala <nmekala@xilix.com>
13
14 * gcc/config/microblaze/microblaze.h
15 (LIBCALL_Value): Remove macro
16 (PROMOTE_MODE): Remove macro
17 * gcc/config/microblaze/microblaze.c
18 (TARGET_LIBCALL_Value): Added new macro
19 (microblaze_function_value): Updated the return Value
20---
21 gcc/config/microblaze/microblaze.c | 11 ++++++++++-
22 gcc/config/microblaze/microblaze.h | 19 -------------------
23 2 files changed, 10 insertions(+), 20 deletions(-)
24
25diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
26index 7b48c011550..1bba77dab6d 100644
27--- a/gcc/config/microblaze/microblaze.c
28+++ b/gcc/config/microblaze/microblaze.c
29@@ -3908,7 +3908,16 @@ microblaze_function_value (const_tree valtype,
30 const_tree func ATTRIBUTE_UNUSED,
31 bool outgoing ATTRIBUTE_UNUSED)
32 {
33- return LIBCALL_VALUE (TYPE_MODE (valtype));
34+ return gen_rtx_REG (TYPE_MODE (valtype), GP_RETURN);
35+}
36+
37+#undef TARGET_LIBCALL_VALUE
38+#define TARGET_LIBCALL_VALUE microblaze_libcall_value
39+
40+rtx
41+microblaze_libcall_value (machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED)
42+{
43+ return gen_rtx_REG (mode, GP_RETURN);
44 }
45
46 /* Implement TARGET_SCHED_ADJUST_COST. */
47diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
48index bfa7bc9a01c..d467a7ee65d 100644
49--- a/gcc/config/microblaze/microblaze.h
50+++ b/gcc/config/microblaze/microblaze.h
51@@ -266,13 +266,6 @@ extern enum pipeline_type microblaze_pipe;
52
53 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
54
55-#ifndef __arch64__
56-#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
57- if (GET_MODE_CLASS (MODE) == MODE_INT \
58- && GET_MODE_SIZE (MODE) < 4) \
59- (MODE) = SImode;
60-#endif
61-
62 /* Standard register usage. */
63
64 /* On the MicroBlaze, we have 32 integer registers */
65@@ -471,18 +464,6 @@ extern struct microblaze_frame_info current_frame_info;
66
67 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
68
69-#ifdef __aarch64__
70-#define LIBCALL_VALUE(MODE) \
71- gen_rtx_REG (MODE,GP_RETURN)
72-#else
73-#define LIBCALL_VALUE(MODE) \
74- gen_rtx_REG ( \
75- ((GET_MODE_CLASS (MODE) != MODE_INT \
76- || GET_MODE_SIZE (MODE) >= 4) \
77- ? (MODE) \
78- : SImode), GP_RETURN)
79-#endif
80-
81 /* 1 if N is a possible register number for a function value.
82 On the MicroBlaze, R2 R3 are the only register thus used.
83 Currently, R2 are only implemented here (C has no complex type) */
84--
852.17.1
86
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0052-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0052-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
new file mode 100644
index 00000000..91c7c026
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0052-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
@@ -0,0 +1,45 @@
1From d7d6835bd839150e864cbb0d9c9c7a497e93bbb8 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 8 May 2019 14:12:03 +0530
4Subject: [PATCH 52/54] [Patch, microblaze]: Add TARGET_OPTION_OPTIMIZATION and
5 disable fivopts by default
6
7Added TARGET_OPTION_OPTIMIZATIONS and Turn off ivopts by default.
8
9 * gcc/common/config/microblaze/microblaze-common.c
10 (microblaze_option_optimization_table): Disable fivopts by default.
11
12Signed-off-by: Nagaraju Mekala <nmekala@xilinx.com>
13
14Conflicts:
15 gcc/common/config/microblaze/microblaze-common.c
16---
17 gcc/common/config/microblaze/microblaze-common.c | 11 +++++++++++
18 1 file changed, 11 insertions(+)
19
20diff --git a/gcc/common/config/microblaze/microblaze-common.c b/gcc/common/config/microblaze/microblaze-common.c
21index 4391f939626..cf2db8afe36 100644
22--- a/gcc/common/config/microblaze/microblaze-common.c
23+++ b/gcc/common/config/microblaze/microblaze-common.c
24@@ -24,7 +24,18 @@
25 #include "common/common-target.h"
26 #include "common/common-target-def.h"
27
28+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
29+static const struct default_options microblaze_option_optimization_table[] =
30+ {
31+ /* Turn off ivopts by default. It messes up cse.
32+ { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, */
33+ { OPT_LEVELS_ALL, OPT_fivopts, NULL, 0 },
34+ { OPT_LEVELS_NONE, 0, NULL, 0 }
35+ };
36+
37 #undef TARGET_DEFAULT_TARGET_FLAGS
38 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
39
40+#undef TARGET_OPTION_OPTIMIZATION_TABLE
41+#define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
42 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
43--
442.17.1
45
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0053-Patch-microblaze-Reducing-Stack-space-for-arguments.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0053-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
new file mode 100644
index 00000000..377154d7
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0053-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
@@ -0,0 +1,198 @@
1From e146b21e18e51ab6ce77af2c39cdf3375606c1eb Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 24 Nov 2020 12:26:32 +0530
4Subject: [PATCH 53/54] [Patch, microblaze]: Reducing Stack space for arguments
5
6Currently in Microblaze target stack space for arguments in register is being
7allocated even if there are no arguments in the function.
8This patch will optimize the extra 24 bytes that are being allocated.
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 :Ajit Agarwal <ajitkum@xilinx.com>
12---
13 gcc/config/microblaze/microblaze-protos.h | 1 +
14 gcc/config/microblaze/microblaze.c | 132 +++++++++++++++++++++-
15 gcc/config/microblaze/microblaze.h | 4 +-
16 3 files changed, 134 insertions(+), 3 deletions(-)
17
18diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
19index 460feac4ac5..b8a3321dbdf 100644
20--- a/gcc/config/microblaze/microblaze-protos.h
21+++ b/gcc/config/microblaze/microblaze-protos.h
22@@ -60,6 +60,7 @@ extern int symbol_mentioned_p (rtx);
23 extern int label_mentioned_p (rtx);
24 extern bool microblaze_cannot_force_const_mem (machine_mode, rtx);
25 extern void microblaze_eh_return (rtx op0);
26+int microblaze_reg_parm_stack_space(tree fun);
27 #endif /* RTX_CODE */
28
29 /* Declare functions in microblaze-c.c. */
30diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
31index 1bba77dab6d..dac0596bc7d 100644
32--- a/gcc/config/microblaze/microblaze.c
33+++ b/gcc/config/microblaze/microblaze.c
34@@ -2080,6 +2080,136 @@ microblaze_must_save_register (int regno)
35 return 0;
36 }
37
38+static bool
39+microblaze_parm_needs_stack (cumulative_args_t args_so_far, tree type)
40+{
41+ int unsignedp;
42+ rtx entry_parm;
43+
44+ /* Catch errors. */
45+ if (type == NULL || type == error_mark_node)
46+ return true;
47+
48+ if (TREE_CODE (type) == POINTER_TYPE)
49+ return true;
50+
51+ /* Handle types with no storage requirement. */
52+ if (TYPE_MODE (type) == VOIDmode)
53+ return false;
54+
55+ /* Handle complex types. */
56+ if (TREE_CODE (type) == COMPLEX_TYPE)
57+ return (microblaze_parm_needs_stack (args_so_far, TREE_TYPE (type))
58+ || microblaze_parm_needs_stack (args_so_far, TREE_TYPE (type)));
59+
60+ /* Handle transparent aggregates. */
61+ if ((TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == RECORD_TYPE)
62+ && TYPE_TRANSPARENT_AGGR (type))
63+ type = TREE_TYPE (first_field (type));
64+
65+ /* See if this arg was passed by invisible reference. */
66+ function_arg_info arg (type, /*named=*/true);
67+ apply_pass_by_reference_rules (get_cumulative_args (args_so_far), arg);
68+
69+ /* Find mode as it is passed by the ABI. */
70+ unsignedp = TYPE_UNSIGNED (type);
71+ arg.mode = promote_mode (arg.type, arg.mode, &unsignedp);
72+
73+ /* If there is no incoming register, we need a stack. */
74+ entry_parm = microblaze_function_arg (args_so_far, arg);
75+ if (entry_parm == NULL)
76+ return true;
77+
78+ /* Likewise if we need to pass both in registers and on the stack. */
79+ if (GET_CODE (entry_parm) == PARALLEL
80+ && XEXP (XVECEXP (entry_parm, 0, 0), 0) == NULL_RTX)
81+ return true;
82+
83+ /* Also true if we're partially in registers and partially not. */
84+ if (function_arg_partial_bytes (args_so_far, arg) != 0)
85+ return true;
86+
87+ /* Update info on where next arg arrives in registers. */
88+ microblaze_function_arg_advance (args_so_far, arg);
89+ return false;
90+}
91+
92+static bool
93+microblaze_function_parms_need_stack (tree fun, bool incoming)
94+{
95+ tree fntype, result;
96+ CUMULATIVE_ARGS args_so_far_v;
97+ cumulative_args_t args_so_far;
98+ int num_of_args = 0;
99+
100+ /* Must be a libcall, all of which only use reg parms. */
101+ if (!fun)
102+ return true;
103+
104+ fntype = fun;
105+ if (!TYPE_P (fun))
106+ fntype = TREE_TYPE (fun);
107+
108+ /* Varargs functions need the parameter save area. */
109+ if ((!incoming && !prototype_p (fntype)) || stdarg_p (fntype))
110+ return true;
111+
112+ INIT_CUMULATIVE_ARGS(args_so_far_v, fntype, NULL_RTX,0,0);
113+ args_so_far = pack_cumulative_args (&args_so_far_v);
114+
115+ /* When incoming, we will have been passed the function decl.
116+ * * It is necessary to use the decl to handle K&R style functions,
117+ * * where TYPE_ARG_TYPES may not be available. */
118+ if (incoming)
119+ {
120+ gcc_assert (DECL_P (fun));
121+ result = DECL_RESULT (fun);
122+ }
123+ else
124+ result = TREE_TYPE (fntype);
125+
126+ if (result && aggregate_value_p (result, fntype))
127+ {
128+ if (!TYPE_P (result))
129+ result = build_pointer_type (result);
130+ microblaze_parm_needs_stack (args_so_far, result);
131+ }
132+
133+ if (incoming)
134+ {
135+ tree parm;
136+ for (parm = DECL_ARGUMENTS (fun);
137+ parm && parm != void_list_node;
138+ parm = TREE_CHAIN (parm))
139+ if (microblaze_parm_needs_stack (args_so_far, TREE_TYPE (parm)))
140+ return true;
141+ }
142+ else
143+ {
144+ function_args_iterator args_iter;
145+ tree arg_type;
146+
147+ FOREACH_FUNCTION_ARGS (fntype, arg_type, args_iter)
148+ {
149+ num_of_args;
150+ if (microblaze_parm_needs_stack (args_so_far, arg_type))
151+ return true;
152+ }
153+ }
154+
155+ if (num_of_args > 3) return true;
156+
157+ return false;
158+}
159+
160+int microblaze_reg_parm_stack_space(tree fun)
161+{
162+ if (microblaze_function_parms_need_stack (fun,false))
163+ return MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD;
164+ else
165+ return 0;
166+}
167+
168 /* Return the bytes needed to compute the frame pointer from the current
169 stack pointer.
170
171@@ -3470,7 +3600,7 @@ microblaze_asm_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
172 emit_insn (gen_indirect_jump (temp2));
173
174 /* Run just enough of rest_of_compilation. This sequence was
175- "borrowed" from rs6000.c. */
176+ "borrowed" from microblaze.c */
177 insn = get_insns ();
178 shorten_branches (insn);
179 assemble_start_function (thunk_fndecl, fnname);
180diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
181index d467a7ee65d..be6c798c889 100644
182--- a/gcc/config/microblaze/microblaze.h
183+++ b/gcc/config/microblaze/microblaze.h
184@@ -447,9 +447,9 @@ extern struct microblaze_frame_info current_frame_info;
185 #define ARG_POINTER_CFA_OFFSET(FNDECL) 0
186 #define DWARF_CIE_DATA_ALIGNMENT -1
187
188-#define REG_PARM_STACK_SPACE(FNDECL) (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD)
189+#define REG_PARM_STACK_SPACE(FNDECL) microblaze_reg_parm_stack_space(FNDECL)
190
191-#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
192+#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
193
194 #define STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
195
196--
1972.17.1
198
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0054-Patch-MicroBlaze-Typo-in-the-previous-commits.bsefi-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0054-Patch-MicroBlaze-Typo-in-the-previous-commits.bsefi-.patch
new file mode 100644
index 00000000..2d53e4b2
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0054-Patch-MicroBlaze-Typo-in-the-previous-commits.bsefi-.patch
@@ -0,0 +1,49 @@
1From 54aa2bf8d84820071de2670504d2e87cc8231c1e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 31 Mar 2021 17:18:56 +0530
4Subject: [PATCH] [Patch,MicroBlaze] : Typo in the previous commits.bsefi/bsifi
5 should be generated only if mcpu is >= 10.0
6
7---
8 gcc/config/microblaze/microblaze.c | 2 +-
9 gcc/config/microblaze/microblaze.md | 4 ++--
10 2 files changed, 3 insertions(+), 3 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
13index dac0596bc7d..d72eb7d5898 100644
14--- a/gcc/config/microblaze/microblaze.c
15+++ b/gcc/config/microblaze/microblaze.c
16@@ -1850,7 +1850,7 @@ microblaze_option_override (void)
17 "%<-mcpu=v8.30.a%>");
18 TARGET_REORDER = 0;
19 }
20- ver = microblaze_version_to_int("v10.0");
21+ ver = ver_int - microblaze_version_to_int("v10.0");
22 if (ver < 0)
23 {
24 if (TARGET_AREA_OPTIMIZED_2)
25diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
26index 93de8d831fd..71ac46dfb6c 100644
27--- a/gcc/config/microblaze/microblaze.md
28+++ b/gcc/config/microblaze/microblaze.md
29@@ -3598,7 +3598,7 @@ else
30 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
31 (match_operand:SI 2 "immediate_operand" "I")
32 (match_operand:SI 3 "immediate_operand" "I")))]
33- "TARGET_BARREL_SHIFT && (UINTVAL (operands[2]) > 0)
34+ "TARGET_HAS_BITFIELD && (UINTVAL (operands[2]) > 0)
35 && ((UINTVAL (operands[2]) + UINTVAL (operands[3])) <= 32)"
36 "bsefi %0,%1,%2,%3"
37 [(set_attr "type" "bshift")
38@@ -3630,7 +3630,7 @@ else
39 (match_operand:SI 1 "immediate_operand" "I")
40 (match_operand:SI 2 "immediate_operand" "I"))
41 (match_operand:SI 3 "register_operand" "r"))]
42- "TARGET_BARREL_SHIFT && UINTVAL (operands[1]) > 0
43+ "TARGET_HAS_BITFIELD && UINTVAL (operands[1]) > 0
44 && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
45 "bsifi %0, %3, %1, %2"
46 [(set_attr "type" "bshift")
47--
482.17.1
49
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/0055-Patch-MicroBlaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/0055-Patch-MicroBlaze.patch
new file mode 100644
index 00000000..4d6cbae6
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/0055-Patch-MicroBlaze.patch
@@ -0,0 +1,71 @@
1From db280c2d72bb043215b2fdfe7cf959fb50d3ce80 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 28 Apr 2021 16:49:18 +0530
4Subject: [PATCH 55] [Patch,MicroBlaze] : If we use break_handler attribute then
5 interrupt vector call happened to break_handler instead of interrupt_handler.
6 this fix will resolve the issue CR-1081780 This fix will not change the
7 behavior of compiler unless there is a usage of break_handler attribute.
8
9---
10 gcc/config/microblaze/microblaze.c | 13 +++++--------
11 1 file changed, 5 insertions(+), 8 deletions(-)
12
13diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
14index d72eb7d5898..e47eb1cd0fe 100644
15--- a/gcc/config/microblaze/microblaze.c
16+++ b/gcc/config/microblaze/microblaze.c
17@@ -2019,7 +2019,7 @@ microblaze_save_volatiles (tree func)
18 int
19 microblaze_is_interrupt_variant (void)
20 {
21- return (interrupt_handler || fast_interrupt);
22+ return (interrupt_handler || fast_interrupt || break_handler);
23 }
24 int
25 microblaze_is_break_handler (void)
26@@ -2058,7 +2058,7 @@ microblaze_must_save_register (int regno)
27 {
28 if (df_regs_ever_live_p (regno)
29 || regno == MB_ABI_MSR_SAVE_REG
30- || ((interrupt_handler || fast_interrupt)
31+ || ((interrupt_handler || fast_interrupt || break_handler)
32 && (regno == MB_ABI_ASM_TEMP_REGNUM
33 || regno == MB_ABI_EXCEPTION_RETURN_ADDR_REGNUM)))
34 return 1;
35@@ -2274,9 +2274,6 @@ compute_frame_size (HOST_WIDE_INT size)
36 fast_interrupt =
37 microblaze_fast_interrupt_function_p (current_function_decl);
38 save_volatiles = microblaze_save_volatiles (current_function_decl);
39- if (break_handler)
40- interrupt_handler = break_handler;
41-
42 gp_reg_size = 0;
43 mask = 0;
44 var_size = size;
45@@ -3236,7 +3233,7 @@ microblaze_expand_prologue (void)
46 gen_rtx_PLUS (Pmode, stack_pointer_rtx,
47 const0_rtx));
48
49- if (interrupt_handler)
50+ if (interrupt_handler || break_handler)
51 /* Do not optimize in flow analysis. */
52 MEM_VOLATILE_P (mem_rtx) = 1;
53
54@@ -3347,12 +3344,12 @@ microblaze_expand_epilogue (void)
55 a load-use stall cycle :) This is also important to handle alloca.
56 (See comments for if (frame_pointer_needed) below. */
57
58- if (!crtl->is_leaf || interrupt_handler)
59+ if (!crtl->is_leaf || interrupt_handler || break_handler)
60 {
61 mem_rtx =
62 gen_rtx_MEM (Pmode,
63 gen_rtx_PLUS (Pmode, stack_pointer_rtx, const0_rtx));
64- if (interrupt_handler)
65+ if (interrupt_handler || break_handler)
66 /* Do not optimize in flow analysis. */
67 MEM_VOLATILE_P (mem_rtx) = 1;
68 reg_rtx = gen_rtx_REG (Pmode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
69--
702.17.1
71
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-11/microblaze-mulitlib-hack.patch b/meta-microblaze/recipes-devtools/gcc/gcc-11/microblaze-mulitlib-hack.patch
new file mode 100644
index 00000000..af8ebf3b
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-11/microblaze-mulitlib-hack.patch
@@ -0,0 +1,58 @@
1Microblaze Mulitlib hack
2
3Based on the patch:
4
5From c2081c51db589471ea713870c72f13999abda815 Mon Sep 17 00:00:00 2001
6From: Khem Raj <raj.khem@gmail.com>
7Date: Fri, 29 Mar 2013 09:10:06 +0400
8Subject: [PATCH 04/36] 64-bit multilib hack.
9
10GCC has internal multilib handling code but it assumes a very specific rigid directory
11layout. The build system implementation of multilib layout is very generic and allows
12complete customisation of the library directories.
13
14This patch is a partial solution to allow any custom directories to be passed into gcc
15and handled correctly. It forces gcc to use the base_libdir (which is the current
16directory, "."). We need to do this for each multilib that is configured as we don't
17know which compiler options may be being passed into the compiler. Since we have a compiler
18per mulitlib at this point that isn't an issue.
19
20The one problem is the target compiler is only going to work for the default multlilib at
21this point. Ideally we'd figure out which multilibs were being enabled with which paths
22and be able to patch these entries with a complete set of correct paths but this we
23don't have such code at this point. This is something the target gcc recipe should do
24and override these platform defaults in its build config.
25
26Do same for riscv64 and aarch64
27
28RP 15/8/11
29
30Upstream-Status: Inappropriate[OE-Specific]
31
32Signed-off-by: Khem Raj <raj.khem@gmail.com>
33Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com>
34Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
35Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
36
37Index: gcc-9.2.0/gcc/config/microblaze/t-microblaze
38===================================================================
39--- gcc-9.2.0.orig/gcc/config/microblaze/t-microblaze
40+++ gcc-9.2.0/gcc/config/microblaze/t-microblaze
41@@ -1,5 +1,6 @@
42 MULTILIB_OPTIONS = m64 mxl-barrel-shift mlittle-endian mno-xl-soft-mul mxl-multiply-high
43-MULTILIB_DIRNAMES = m64 bs le m mh
44+#MULTILIB_DIRNAMES = m64 bs le m mh
45+MULTILIB_DIRNAMES = . . . . .
46 MULTILIB_EXCEPTIONS = *m64/mxl-multiply-high mxl-multiply-high
47 MULTILIB_EXCEPTIONS += *m64
48 MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift
49Index: gcc-9.2.0/gcc/config/microblaze/t-microblaze-linux
50===================================================================
51--- gcc-9.2.0.orig/gcc/config/microblaze/t-microblaze-linux
52+++ gcc-9.2.0/gcc/config/microblaze/t-microblaze-linux
53@@ -1,3 +1,4 @@
54 MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high
55-MULTILIB_DIRNAMES = bs m mh
56+#MULTILIB_DIRNAMES = bs m mh
57+MULTILIB_DIRNAMES = . . .
58 MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high