summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gcc/gcc-12
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@amd.com>2024-07-24 11:41:48 -0600
committerMark Hatle <mark.hatle@amd.com>2024-07-24 20:55:18 -0600
commit76896af103e13176e7bcbc5e57d5357249c6a0f6 (patch)
tree01ae6bdc5e433243c22c00ee9ad141011c55a62a /meta-microblaze/recipes-devtools/gcc/gcc-12
parenta5ef63d835bc8c12cf7e5a1a82ee547542295738 (diff)
downloadmeta-xilinx-76896af103e13176e7bcbc5e57d5357249c6a0f6.tar.gz
meta-microblaze: Update to gcc 13
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-microblaze/recipes-devtools/gcc/gcc-12')
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch35
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch31
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch35
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch35
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch36
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch67
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch28
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0008-Patch-microblaze-Fix-atomic-side-effects.patch68
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch40
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch36
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch48
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch26
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0013-Patch-microblaze-Removed-moddi3-routinue.patch160
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0014-Patch-microblaze-Add-INIT_PRIORITY-support-Added.patch90
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0015-Patch-microblaze-Add-optimized-lshrsi3.patch81
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0016-Patch-microblaze-Add-cbranchsi4_reg.patch147
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch58
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch63
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch75
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch177
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0021-PATCH-21-53-Patch-microblaze-Correct-the-const-high-.patch58
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch31
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch37
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0024-Patch-MicroBlaze-this-patch-has-1.Fixed-the-bug-in.patch373
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0025-Fixing-the-issue-with-the-builtin_alloc.patch44
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0026-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch38
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0027-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch784
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0028-Intial-commit-for-64bit-MB-sources.patch2442
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0029-Patch-MicroBlaze-re-arrangement-of-the-compare-branc.patch269
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0030-Patch-Microblaze-previous-commit-broke-the-handling-.patch28
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0031-Patch-Microblaze-Support-of-multilibs-with-m64.patch77
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0032-Patch-MicroBlaze-Fixed-issues-like.patch70
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch305
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0034-Added-double-arith-instructions.patch135
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0035-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch37
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0036-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch256
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0037-extending-the-Dwarf-support-to-64bit-Microblaze.patch25
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0038-fixing-the-typo-errors-in-umodsi3-file.patch29
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0039-fixing-the-32bit-LTO-related-issue9-1014024.patch68
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0040-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch25
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0041-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch29
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0042-fixing-the-long-long-long-mingw-toolchain-issue.patch59
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0043-Fix-the-MB-64-bug-of-handling-QI-objects.patch47
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0044-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch87
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0045-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch466
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0046-Patch-microblaze-MB-64-removal-of-barrel-shift-instr.patch477
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0047-Added-new-MB-64-single-register-arithmetic-instructi.patch107
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0048-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch44
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0049-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch76
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0050-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch50
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0051-Patch-microblaze-Reducing-Stack-space-for-arguments.patch189
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0052-Patch-MicroBlaze.patch73
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0053-patch-microblaze64-Add-Zero_extended-instructions.patch58
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/microblaze-mulitlib-hack.patch58
54 files changed, 0 insertions, 8287 deletions
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch
deleted file mode 100644
index 1099a0e8..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From 376b0ee790231a99fe50b50e20070c104bbba0d8 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/53] 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 fb47f51f90c..d9ecf045554 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.37.1 (Apple Git-137.1)
35
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch
deleted file mode 100644
index 061dfc86..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1From b1aea8e71692065497ee3e9be5a9f1fccecf5685 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/53] [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.37.1 (Apple Git-137.1)
31
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch
deleted file mode 100644
index 1b5d428e..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0003-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From af78edb2cb91c55f54ac2d720cee9871da13b845 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/53] [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 d9ecf045554..d6c2b04f286 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.37.1 (Apple Git-137.1)
35
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch
deleted file mode 100644
index 8db33100..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0004-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From 34b7dd28e3fe40f55ec7f6df3f000dd797d6c1cc 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/53] [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 244fe2306f4..c19f251f0d2 100644
23--- a/gcc/testsuite/lib/target-supports.exp
24+++ b/gcc/testsuite/lib/target-supports.exp
25@@ -8639,6 +8639,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 cris-*-*]
33--
342.37.1 (Apple Git-137.1)
35
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch
deleted file mode 100644
index 0fb32850..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0005-Patch-testsuite-Update-MicroBlaze-strings-test.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From 2d0b5d68aff95a95dfb4ed0b207849658502bd53 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/53] [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 | 4 ++++
17 1 file changed, 4 insertions(+)
18
19diff --git a/gcc/testsuite/gcc.target/microblaze/others/strings1.c b/gcc/testsuite/gcc.target/microblaze/others/strings1.c
20index efaf3c660ea..347872360d3 100644
21--- a/gcc/testsuite/gcc.target/microblaze/others/strings1.c
22+++ b/gcc/testsuite/gcc.target/microblaze/others/strings1.c
23@@ -3,6 +3,10 @@
24 /* { 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.*" } } */
25 /* { 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]),*" } } */
26
27+/* { dg-final { scan-assembler "\.rodata*" } } */
28+/* { 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.*" } } */
29+/* { 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]),*" } } */
30+
31 #include <string.h>
32
33 extern void somefunc (char *);
34--
352.37.1 (Apple Git-137.1)
36
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch
deleted file mode 100644
index a82f11cc..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0006-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch
+++ /dev/null
@@ -1,67 +0,0 @@
1From 20b6479f240bfebb46daad06839286a7abcff56c 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/53] [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.37.1 (Apple Git-137.1)
67
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch
deleted file mode 100644
index 736f5cd1..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0007-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch
+++ /dev/null
@@ -1,28 +0,0 @@
1From 0efefd8ac71dd084c745402afdf07319de9774c6 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/53] [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 c19f251f0d2..c136c93e673 100644
16--- a/gcc/testsuite/lib/target-supports.exp
17+++ b/gcc/testsuite/lib/target-supports.exp
18@@ -729,6 +729,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.37.1 (Apple Git-137.1)
28
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0008-Patch-microblaze-Fix-atomic-side-effects.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0008-Patch-microblaze-Fix-atomic-side-effects.patch
deleted file mode 100644
index 451070c0..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0008-Patch-microblaze-Fix-atomic-side-effects.patch
+++ /dev/null
@@ -1,68 +0,0 @@
1From 42ab0f7a2e6834feed456d00b3e2ec0ae2532a41 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/53] [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 0765ff930c6..ea7f74f1dff 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 ae8955ce691..77c3ce8ff27 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.37.1 (Apple Git-137.1)
68
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch
deleted file mode 100644
index c7efbb07..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch
+++ /dev/null
@@ -1,40 +0,0 @@
1From a1b8136a157c549f0f65c14d628e694310ca0d23 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/53] [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 77c3ce8ff27..573ce4765a0 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.37.1 (Apple Git-137.1)
40
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch
deleted file mode 100644
index 1bffafa9..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0010-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From 1ab5b8af098d100a1d7af05cca680b3c7181549d 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/53] [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
14Conflicts:
15 gcc/config/microblaze/microblaze.c
16---
17 gcc/config/microblaze/microblaze.cc | 3 +--
18 1 file changed, 1 insertion(+), 2 deletions(-)
19
20diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
21index f32effecfb6..6922dd94af7 100644
22--- a/gcc/config/microblaze/microblaze.cc
23+++ b/gcc/config/microblaze/microblaze.cc
24@@ -3710,8 +3710,7 @@ microblaze_expand_divide (rtx operands[])
25 mem_rtx = gen_rtx_MEM (QImode,
26 gen_rtx_PLUS (Pmode, regt1, div_table_rtx));
27
28- insn = emit_insn (gen_movqi (regqi, mem_rtx));
29- insn = emit_insn (gen_movsi (operands[0], gen_rtx_SUBREG (SImode, regqi, 0)));
30+ insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
31 jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
32 JUMP_LABEL (jump) = div_end_label;
33 LABEL_NUSES (div_end_label) = 1;
34--
352.37.1 (Apple Git-137.1)
36
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch
deleted file mode 100644
index 1bd73b8a..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0011-Patch-microblaze-Added-ashrsi3_with_size_opt.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From 7dd4ae2ad891094aa85a907b168cbdce744789e9 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/53] [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 ea7f74f1dff..9fbb3113f3c 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.37.1 (Apple Git-137.1)
48
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch
deleted file mode 100644
index f40fff9a..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0012-Patch-microblaze-Use-bralid-for-profiler-calls.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From 12d7e086376916ef61e2c48639671fd0f7c8fbbf 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/53] [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 d28bc766de8..cd544f2030e 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.37.1 (Apple Git-137.1)
26
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0013-Patch-microblaze-Removed-moddi3-routinue.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0013-Patch-microblaze-Removed-moddi3-routinue.patch
deleted file mode 100644
index 5c927264..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0013-Patch-microblaze-Removed-moddi3-routinue.patch
+++ /dev/null
@@ -1,160 +0,0 @@
1From cd8c9f3c43b266628d1585b74fc78f3e34a33c44 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/53] [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
9Conflicts:
10 libgcc/config/microblaze/moddi3.S
11---
12 libgcc/config/microblaze/moddi3.S | 121 --------------------------
13 libgcc/config/microblaze/t-microblaze | 3 +-
14 2 files changed, 1 insertion(+), 123 deletions(-)
15 delete mode 100644 libgcc/config/microblaze/moddi3.S
16
17diff --git a/libgcc/config/microblaze/moddi3.S b/libgcc/config/microblaze/moddi3.S
18deleted file mode 100644
19index 9b77865df38..00000000000
20--- a/libgcc/config/microblaze/moddi3.S
21+++ /dev/null
22@@ -1,121 +0,0 @@
23-###################################
24-#
25-# Copyright (C) 2009-2022 Free Software Foundation, Inc.
26-#
27-# Contributed by Michael Eager <eager@eagercon.com>.
28-#
29-# This file is free software; you can redistribute it and/or modify it
30-# under the terms of the GNU General Public License as published by the
31-# Free Software Foundation; either version 3, or (at your option) any
32-# later version.
33-#
34-# GCC is distributed in the hope that it will be useful, but WITHOUT
35-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
36-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
37-# License for more details.
38-#
39-# Under Section 7 of GPL version 3, you are granted additional
40-# permissions described in the GCC Runtime Library Exception, version
41-# 3.1, as published by the Free Software Foundation.
42-#
43-# You should have received a copy of the GNU General Public License and
44-# a copy of the GCC Runtime Library Exception along with this program;
45-# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
46-# <http://www.gnu.org/licenses/>.
47-#
48-# modsi3.S
49-#
50-# modulo operation for 64 bit integers.
51-#
52-#######################################
53-
54-
55-/* An executable stack is *not* required for these functions. */
56-#ifdef __linux__
57-.section .note.GNU-stack,"",%progbits
58-.previous
59-#endif
60-
61- .globl __moddi3
62- .ent __moddi3
63-__moddi3:
64- .frame r1,0,r15
65-
66-#Change the stack pointer value and Save callee saved regs
67- addik r1,r1,-24
68- swi r25,r1,0
69- swi r26,r1,4
70- swi r27,r1,8 # used for sign
71- swi r28,r1,12 # used for loop count
72- swi r29,r1,16 # Used for div value High
73- swi r30,r1,20 # Used for div value Low
74-
75-#Check for Zero Value in the divisor/dividend
76- OR r9,r5,r6 # Check for the op1 being zero
77- BEQID r9,$LaResult_Is_Zero # Result is zero
78- OR r9,r7,r8 # Check for the dividend being zero
79- BEQI r9,$LaDiv_By_Zero # Div_by_Zero # Division Error
80- BGEId r5,$La1_Pos
81- XOR r27,r5,r7 # Get the sign of the result
82- RSUBI r6,r6,0 # Make dividend positive
83- RSUBIC r5,r5,0 # Make dividend positive
84-$La1_Pos:
85- BGEI r7,$La2_Pos
86- RSUBI r8,r8,0 # Make Divisor Positive
87- RSUBIC r9,r9,0 # Make Divisor Positive
88-$La2_Pos:
89- ADDIK r4,r0,0 # Clear mod low
90- ADDIK r3,r0,0 # Clear mod high
91- ADDIK r29,r0,0 # clear div high
92- ADDIK r30,r0,0 # clear div low
93- ADDIK r28,r0,64 # Initialize the loop count
94- # First part try to find the first '1' in the r5/r6
95-$LaDIV1:
96- ADD r6,r6,r6
97- ADDC r5,r5,r5 # left shift logical r5
98- BGEID r5,$LaDIV1
99- ADDIK r28,r28,-1
100-$LaDIV2:
101- ADD r6,r6,r6
102- ADDC r5,r5,r5 # left shift logical r5/r6 get the '1' into the Carry
103- ADDC r4,r4,r4 # Move that bit into the Mod register
104- ADDC r3,r3,r3 # Move carry into high mod register
105- rsub r18,r7,r3 # Compare the High Parts of Mod and Divisor
106- bnei r18,$L_High_EQ
107- rsub r18,r6,r4 # Compare Low Parts only if Mod[h] == Divisor[h]
108-$L_High_EQ:
109- rSUB r26,r8,r4 # Subtract divisor[L] from Mod[L]
110- rsubc r25,r7,r3 # Subtract divisor[H] from Mod[H]
111- BLTi r25,$LaMOD_TOO_SMALL
112- OR r3,r0,r25 # move r25 to mod [h]
113- OR r4,r0,r26 # move r26 to mod [l]
114- ADDI r30,r30,1
115- ADDC r29,r29,r0
116-$LaMOD_TOO_SMALL:
117- ADDIK r28,r28,-1
118- BEQi r28,$LaLOOP_END
119- ADD r30,r30,r30 # Shift in the '1' into div [low]
120- ADDC r29,r29,r29 # Move the carry generated into high
121- BRI $LaDIV2 # Div2
122-$LaLOOP_END:
123- BGEI r27,$LaRETURN_HERE
124- rsubi r30,r30,0
125- rsubc r29,r29,r0
126- BRI $LaRETURN_HERE
127-$LaDiv_By_Zero:
128-$LaResult_Is_Zero:
129- or r29,r0,r0 # set result to 0 [High]
130- or r30,r0,r0 # set result to 0 [Low]
131-$LaRETURN_HERE:
132-# Restore values of CSRs and that of r29 and the divisor and the dividend
133-
134- lwi r25,r1,0
135- lwi r26,r1,4
136- lwi r27,r1,8
137- lwi r28,r1,12
138- lwi r29,r1,16
139- lwi r30,r1,20
140- rtsd r15,8
141- addik r1,r1,24
142- .end __moddi3
143-
144diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
145index 96959f0292b..8d954a49575 100644
146--- a/libgcc/config/microblaze/t-microblaze
147+++ b/libgcc/config/microblaze/t-microblaze
148@@ -1,8 +1,7 @@
149-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _moddi3 _mulsi3 _udivsi3 _umodsi3
150+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
151
152 LIB2ADD += \
153 $(srcdir)/config/microblaze/divsi3.S \
154- $(srcdir)/config/microblaze/moddi3.S \
155 $(srcdir)/config/microblaze/modsi3.S \
156 $(srcdir)/config/microblaze/muldi3_hard.S \
157 $(srcdir)/config/microblaze/mulsi3.S \
158--
1592.37.1 (Apple Git-137.1)
160
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0014-Patch-microblaze-Add-INIT_PRIORITY-support-Added.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0014-Patch-microblaze-Add-INIT_PRIORITY-support-Added.patch
deleted file mode 100644
index f8bcabe3..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0014-Patch-microblaze-Add-INIT_PRIORITY-support-Added.patch
+++ /dev/null
@@ -1,90 +0,0 @@
1From 30aa7cef2dd076637155384fba539838ddaf0163 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 12 Sep 2022 20:20:00 +0530
4Subject: [PATCH 14/53] [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---
14 gcc/config/microblaze/microblaze.cc | 53 +++++++++++++++++++++++++++++
15 1 file changed, 53 insertions(+)
16
17diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
18index 6922dd94af7..4b0621db168 100644
19--- a/gcc/config/microblaze/microblaze.cc
20+++ b/gcc/config/microblaze/microblaze.cc
21@@ -2635,6 +2635,53 @@ print_operand_address (FILE * file, rtx addr)
22 }
23 }
24
25+/* Output an element in the table of global constructors. */
26+void
27+microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority)
28+{
29+ const char *section = ".ctors";
30+ char buf[16];
31+
32+ if (priority != DEFAULT_INIT_PRIORITY)
33+ {
34+ sprintf (buf, ".ctors.%.5u",
35+ /* Invert the numbering so the linker puts us in the proper
36+ order; constructors are run from right to left, and the
37+ linker sorts in increasing order. */
38+ MAX_INIT_PRIORITY - priority);
39+ section = buf;
40+ }
41+
42+ switch_to_section (get_section (section, 0, NULL));
43+ assemble_align (POINTER_SIZE);
44+ fputs ("\t.word\t", asm_out_file);
45+ output_addr_const (asm_out_file, symbol);
46+ fputs ("\n", asm_out_file);
47+}
48+
49+/* Output an element in the table of global destructors. */
50+void
51+microblaze_asm_destructor (rtx symbol, int priority)
52+{
53+ const char *section = ".dtors";
54+ char buf[16];
55+ if (priority != DEFAULT_INIT_PRIORITY)
56+ {
57+ sprintf (buf, ".dtors.%.5u",
58+ /* Invert the numbering so the linker puts us in the proper
59+ order; constructors are run from right to left, and the
60+ linker sorts in increasing order. */
61+ MAX_INIT_PRIORITY - priority);
62+ section = buf;
63+ }
64+
65+ switch_to_section (get_section (section, 0, NULL));
66+ assemble_align (POINTER_SIZE);
67+ fputs ("\t.word\t", asm_out_file);
68+ output_addr_const (asm_out_file, symbol);
69+ fputs ("\n", asm_out_file);
70+}
71+
72 /* Emit either a label, .comm, or .lcomm directive, and mark that the symbol
73 is used, so that we don't emit an .extern for it in
74 microblaze_asm_file_end. */
75@@ -3976,6 +4023,12 @@ microblaze_starting_frame_offset (void)
76 #undef TARGET_ATTRIBUTE_TABLE
77 #define TARGET_ATTRIBUTE_TABLE microblaze_attribute_table
78
79+#undef TARGET_ASM_CONSTRUCTOR
80+#define TARGET_ASM_CONSTRUCTOR microblaze_asm_constructor
81+
82+#undef TARGET_ASM_DESTRUCTOR
83+#define TARGET_ASM_DESTRUCTOR microblaze_asm_destructor
84+
85 #undef TARGET_IN_SMALL_DATA_P
86 #define TARGET_IN_SMALL_DATA_P microblaze_elf_in_small_data_p
87
88--
892.37.1 (Apple Git-137.1)
90
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0015-Patch-microblaze-Add-optimized-lshrsi3.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0015-Patch-microblaze-Add-optimized-lshrsi3.patch
deleted file mode 100644
index 0f7d356f..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0015-Patch-microblaze-Add-optimized-lshrsi3.patch
+++ /dev/null
@@ -1,81 +0,0 @@
1From b9bb669d9404bd04676f09c793310e1b7f228674 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/53] [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 9fbb3113f3c..52308cce0cb 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.37.1 (Apple Git-137.1)
81
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0016-Patch-microblaze-Add-cbranchsi4_reg.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0016-Patch-microblaze-Add-cbranchsi4_reg.patch
deleted file mode 100644
index 19ae324d..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0016-Patch-microblaze-Add-cbranchsi4_reg.patch
+++ /dev/null
@@ -1,147 +0,0 @@
1From 08d7bb4062024f3e34fbb17d695f8fa2c9e1b305 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/53] [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 d67355697b5..848cd509003 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.37.1 (Apple Git-137.1)
147
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch
deleted file mode 100644
index e3a98a08..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0017-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch
+++ /dev/null
@@ -1,58 +0,0 @@
1From 1593e5a9839b7cade95e9f55ba3cff66d64d0e84 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/53] [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 52308cce0cb..0e5ef4d7649 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.37.1 (Apple Git-137.1)
58
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch
deleted file mode 100644
index 831b8f22..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0018-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch
+++ /dev/null
@@ -1,63 +0,0 @@
1From 9002b7d4c295bef95a3fc28c05f86dde5087dde1 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/53] [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 0e5ef4d7649..effb9774c32 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.37.1 (Apple Git-137.1)
63
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch
deleted file mode 100644
index ab3fa535..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0019-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch
+++ /dev/null
@@ -1,75 +0,0 @@
1From ef94a8b2110f5a3becefb00c1f7c0c3adac6fcac 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/53] [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.cc (print_operand):
22 updated the 'F' case to use "unsinged int" instead
23 of HOST_WIDE_INT_PRINT_HEX
24
25Conflicts:
26 gcc/config/microblaze/microblaze.c
27---
28 gcc/config/microblaze/microblaze.cc | 2 +-
29 gcc/config/microblaze/microblaze.md | 10 ++++++++--
30 2 files changed, 9 insertions(+), 3 deletions(-)
31
32diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
33index 4b0621db168..c23061c4e4a 100644
34--- a/gcc/config/microblaze/microblaze.cc
35+++ b/gcc/config/microblaze/microblaze.cc
36@@ -2469,7 +2469,7 @@ print_operand (FILE * file, rtx op, int letter)
37 unsigned long value_long;
38 REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (op),
39 value_long);
40- fprintf (file, "0x%lx", value_long);
41+ fprintf (file, "0x%08x", (unsigned int) value_long);
42 }
43 else
44 {
45diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
46index effb9774c32..a4d7ea29219 100644
47--- a/gcc/config/microblaze/microblaze.md
48+++ b/gcc/config/microblaze/microblaze.md
49@@ -1368,7 +1368,10 @@
50 (match_operand:SI 2 "immediate_operand" "I")))]
51 "!TARGET_SOFT_MUL
52 && ((1 << INTVAL (operands[2])) <= 32767 && (1 << INTVAL (operands[2])) >= -32768)"
53- "muli\t%0,%1,%m2"
54+ {
55+ operands[2] = gen_int_mode (1 << INTVAL (operands[2]), SImode);
56+ return "muli\t%0,%1,%2";
57+ }
58 ;; This MUL will not generate an imm. Can go into a delay slot.
59 [(set_attr "type" "arith")
60 (set_attr "mode" "SI")
61@@ -1380,7 +1383,10 @@
62 (ashift:SI (match_operand:SI 1 "register_operand" "d")
63 (match_operand:SI 2 "immediate_operand" "I")))]
64 "!TARGET_SOFT_MUL"
65- "muli\t%0,%1,%m2"
66+ {
67+ operands[2] = gen_int_mode (1 << INTVAL (operands[2]), SImode);
68+ return "muli\t%0,%1,%2";
69+ }
70 ;; This MUL will generate an IMM. Cannot go into a delay slot
71 [(set_attr "type" "no_delay_arith")
72 (set_attr "mode" "SI")
73--
742.37.1 (Apple Git-137.1)
75
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch
deleted file mode 100644
index 67eb0893..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0020-Patch-microblaze-8-stage-pipeline-for-microblaze.patch
+++ /dev/null
@@ -1,177 +0,0 @@
1From 65574bdca9006fda7654e33a0081eeecfcd9976b Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 12 Sep 2022 21:05:51 +0530
4Subject: [PATCH 20/53] [Patch, microblaze]: 8-stage pipeline for microblaze
5 This patch adds the support for the 8-stage pipeline. The new 8-stage
6 pipeline reduces the latencies of float & integer division drastically
7
8Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
9---
10 gcc/config/microblaze/microblaze.cc | 11 ++++
11 gcc/config/microblaze/microblaze.h | 3 +-
12 gcc/config/microblaze/microblaze.md | 79 +++++++++++++++++++++++++++-
13 gcc/config/microblaze/microblaze.opt | 4 ++
14 4 files changed, 94 insertions(+), 3 deletions(-)
15
16diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
17index c23061c4e4a..bd394c411b8 100644
18--- a/gcc/config/microblaze/microblaze.cc
19+++ b/gcc/config/microblaze/microblaze.cc
20@@ -1841,6 +1841,17 @@ microblaze_option_override (void)
21 "%<-mcpu=v8.30.a%>");
22 TARGET_REORDER = 0;
23 }
24+ ver = microblaze_version_to_int("v10.0");
25+ if (ver < 0)
26+ {
27+ if (TARGET_AREA_OPTIMIZED_2)
28+ warning (0, "-mxl-frequency can be used only with -mcpu=v10.0 or greater");
29+ }
30+ else
31+ {
32+ if (TARGET_AREA_OPTIMIZED_2)
33+ microblaze_pipe = MICROBLAZE_PIPE_8;
34+ }
35
36 if (TARGET_MULTIPLY_HIGH && TARGET_SOFT_MUL)
37 error ("%<-mxl-multiply-high%> requires %<-mno-xl-soft-mul%>");
38diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
39index cd544f2030e..640ae6ea9a3 100644
40--- a/gcc/config/microblaze/microblaze.h
41+++ b/gcc/config/microblaze/microblaze.h
42@@ -27,7 +27,8 @@
43 enum pipeline_type
44 {
45 MICROBLAZE_PIPE_3 = 0,
46- MICROBLAZE_PIPE_5 = 1
47+ MICROBLAZE_PIPE_5 = 1,
48+ MICROBLAZE_PIPE_8 = 2
49 };
50
51 #define MICROBLAZE_MASK_NO_UNSAFE_DELAY 0x00000001
52diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
53index a4d7ea29219..9e9dfb1ccb0 100644
54--- a/gcc/config/microblaze/microblaze.md
55+++ b/gcc/config/microblaze/microblaze.md
56@@ -35,6 +35,7 @@
57 (R_GOT 20) ;; GOT ptr reg
58 (MB_PIPE_3 0) ;; Microblaze 3-stage pipeline
59 (MB_PIPE_5 1) ;; Microblaze 5-stage pipeline
60+ (MB_PIPE_8 2) ;; Microblaze 8-stage pipeline
61 (UNSPEC_SET_GOT 101) ;;
62 (UNSPEC_GOTOFF 102) ;; GOT offset
63 (UNSPEC_PLT 103) ;; jump table
64@@ -82,7 +83,7 @@
65 ;; bshift Shift operations
66
67 (define_attr "type"
68- "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"
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,fint,trap"
70 (const_string "unknown"))
71
72 ;; Main data type used by the insn
73@@ -224,6 +225,80 @@
74 ;;-----------------------------------------------------------------
75
76
77+
78+;;----------------------------------------------------------------
79+;; Microblaze 8-stage pipeline description (v10.0 and later)
80+;;----------------------------------------------------------------
81+
82+(define_automaton "mbpipe_8")
83+(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")
84+
85+(define_insn_reservation "mb8-integer" 1
86+ (and (eq_attr "type" "branch,jump,call,arith,darith,icmp,nop,no_delay_arith")
87+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
88+ "mb8_issue,mb8_iu,mb8_wb")
89+
90+(define_insn_reservation "mb8-special-move" 2
91+ (and (eq_attr "type" "move")
92+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
93+ "mb8_issue,mb8_iu*2,mb8_wb")
94+
95+(define_insn_reservation "mb8-mem-load" 3
96+ (and (eq_attr "type" "load,no_delay_load")
97+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
98+ "mb8_issue,mb8_iu,mb8_wb")
99+
100+(define_insn_reservation "mb8-mem-store" 1
101+ (and (eq_attr "type" "store,no_delay_store")
102+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
103+ "mb8_issue,mb8_iu,mb8_wb")
104+
105+(define_insn_reservation "mb8-mul" 3
106+ (and (eq_attr "type" "imul,no_delay_imul")
107+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
108+ "mb8_issue,mb8_mul,mb8_mul_2*2,mb8_wb")
109+
110+(define_insn_reservation "mb8-div" 30
111+ (and (eq_attr "type" "idiv")
112+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
113+ "mb8_issue,mb8_div,mb8_div_2*29,mb8_wb")
114+
115+(define_insn_reservation "mb8-bs" 2
116+ (and (eq_attr "type" "bshift")
117+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
118+ "mb8_issue,mb8_bs,mb8_bs_2,mb8_wb")
119+
120+(define_insn_reservation "mb8-fpu-add-sub-mul" 1
121+ (and (eq_attr "type" "fadd,frsub,fmul")
122+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
123+ "mb8_issue,mb8_fpu,mb8_wb")
124+
125+(define_insn_reservation "mb8-fpu-fcmp" 3
126+ (and (eq_attr "type" "fcmp")
127+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
128+ "mb8_issue,mb8_fpu,mb8_fpu*2,mb8_wb")
129+
130+(define_insn_reservation "mb8-fpu-div" 24
131+ (and (eq_attr "type" "fdiv")
132+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
133+ "mb8_issue,mb8_fpu,mb8_fpu_2*23,mb8_wb")
134+
135+(define_insn_reservation "mb8-fpu-sqrt" 23
136+ (and (eq_attr "type" "fsqrt")
137+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
138+ "mb8_issue,mb8_fpu,mb8_fpu_2*22,mb8_wb")
139+
140+(define_insn_reservation "mb8-fpu-fcvt" 1
141+ (and (eq_attr "type" "fcvt")
142+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
143+ "mb8_issue,mb8_fpu,mb8_wb")
144+
145+(define_insn_reservation "mb8-fpu-fint" 2
146+ (and (eq_attr "type" "fint")
147+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
148+ "mb8_issue,mb8_fpu,mb8_wb")
149+
150+
151 ;;----------------------------------------------------------------
152 ;; Microblaze 5-stage pipeline description (v5.00.a and later)
153 ;;----------------------------------------------------------------
154@@ -470,7 +545,7 @@
155 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
156 "TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
157 "fint\t%0,%1"
158- [(set_attr "type" "fcvt")
159+ [(set_attr "type" "fint")
160 (set_attr "mode" "SF")
161 (set_attr "length" "4")])
162
163diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
164index 9f47e67cf2a..cc009363f87 100644
165--- a/gcc/config/microblaze/microblaze.opt
166+++ b/gcc/config/microblaze/microblaze.opt
167@@ -133,3 +133,7 @@ Data referenced by offset from start of text instead of GOT (with -fPIC/-fPIE).
168
169 mxl-mode-xilkernel
170 Target
171+
172+mxl-frequency
173+Target Mask(AREA_OPTIMIZED_2)
174+Use 8 stage pipeline (frequency optimization)
175--
1762.37.1 (Apple Git-137.1)
177
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0021-PATCH-21-53-Patch-microblaze-Correct-the-const-high-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0021-PATCH-21-53-Patch-microblaze-Correct-the-const-high-.patch
deleted file mode 100644
index 96fe4f73..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0021-PATCH-21-53-Patch-microblaze-Correct-the-const-high-.patch
+++ /dev/null
@@ -1,58 +0,0 @@
1From 1d56bfb436b008422b4a7d4d4e3180667130c840 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 11:49:11 +0530
4Subject: [PATCH 21/53] [PATCH 21/53] [Patch, microblaze]: Correct the const
5 high double immediate value with this patch the loading of the DI mode
6 immediate values will be using REAL_VALUE_FROM_CONST_DOUBLE and
7 REAL_VALUE_TO_TARGET_DOUBLE functions, as CONST_DOUBLE_HIGH was returning
8 the sign extension value even 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.cc | 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.cc b/gcc/config/microblaze/microblaze.cc
19index bd394c411b8..7c648cda1b2 100644
20--- a/gcc/config/microblaze/microblaze.cc
21+++ b/gcc/config/microblaze/microblaze.cc
22@@ -2453,14 +2453,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.37.1 (Apple Git-137.1)
58
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch
deleted file mode 100644
index 332db5d3..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0022-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1From cd60ea1bd88ac47856ac66266a0771478ac73bad Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 11:58:14 +0530
4Subject: [PATCH 22/53] [Fix, microblaze]: Fix internal compiler error with
5 msmall-divides This patch will fix the internal error
6 microblaze_expand_divide function which come of rtx PLUS where the
7 mem_rtx is of type SI and the operand is of type QImode. This patch
8 modifies the mem_rtx as QImode and Plus as QImode to fix the error.
9
10 Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 Ajit Agarwal <ajitkum@xilinx.com>
12---
13 gcc/config/microblaze/microblaze.cc | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
17index 7c648cda1b2..907c0afa9b8 100644
18--- a/gcc/config/microblaze/microblaze.cc
19+++ b/gcc/config/microblaze/microblaze.cc
20@@ -3768,7 +3768,7 @@ microblaze_expand_divide (rtx operands[])
21 emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
22 emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
23 mem_rtx = gen_rtx_MEM (QImode,
24- gen_rtx_PLUS (Pmode, regt1, div_table_rtx));
25+ gen_rtx_PLUS (QImode, regt1, div_table_rtx));
26
27 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
28 jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
29--
302.37.1 (Apple Git-137.1)
31
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch
deleted file mode 100644
index 47e13fa6..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0023-patch-microblaze-Fix-the-calculation-of-high-word-in.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From b98cddb206ce84994425ede4b116365977768e37 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 12:03:08 +0530
4Subject: [PATCH 23/53] [patch,microblaze]: Fix the calculation of high word in
5 a long long 64-bit
6
7 This patch will change the calculation of high word in a long long 64-bit.
8 Earlier to this patch the high word of long long word (0xF0000000ULL) is
9 coming to be 0xFFFFFFFF and low word is 0xF0000000. Instead the high word
10 should be 0x00000000 and the low word should be 0xF0000000. This patch
11 removes the condition of checking high word = 0 & low word < 0.
12 This check is not required for the correctness of calculating 32-bit high
13 and low words in a 64-bit long long.
14
15 Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
16 Ajit Agarwal <ajitkum@xilinx.com>
17---
18 gcc/config/microblaze/microblaze.cc | 3 ---
19 1 file changed, 3 deletions(-)
20
21diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
22index 907c0afa9b8..f75eaff4b49 100644
23--- a/gcc/config/microblaze/microblaze.cc
24+++ b/gcc/config/microblaze/microblaze.cc
25@@ -2469,9 +2469,6 @@ print_operand (FILE * file, rtx op, int letter)
26 {
27 val[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
28 val[1] = INTVAL (op) & 0x00000000ffffffffLL;
29- if (val[0] == 0 && val[1] < 0)
30- val[0] = -1;
31-
32 }
33 fprintf (file, "0x%8.8lx", (letter == 'h') ? val[0] : val[1]);
34 }
35--
362.37.1 (Apple Git-137.1)
37
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0024-Patch-MicroBlaze-this-patch-has-1.Fixed-the-bug-in.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0024-Patch-MicroBlaze-this-patch-has-1.Fixed-the-bug-in.patch
deleted file mode 100644
index 8ed5ae83..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0024-Patch-MicroBlaze-this-patch-has-1.Fixed-the-bug-in.patch
+++ /dev/null
@@ -1,373 +0,0 @@
1From 89269c9b8d2047ebbc13e98c45e94746edc63de6 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 12:23:54 +0530
4Subject: [PATCH 24/53] [Patch,MicroBlaze] : this patch has 1.Fixed the bug in
5 version calculation. 2.Add new bitfield instructions.
6
7Signed-off-by :Mahesh Bodapati <mbodapat@xilinx.com>
8---
9 gcc/config/microblaze/microblaze.cc | 154 ++++++++++++++--------------
10 gcc/config/microblaze/microblaze.h | 2 +
11 gcc/config/microblaze/microblaze.md | 69 +++++++++++++
12 3 files changed, 147 insertions(+), 78 deletions(-)
13
14diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
15index f75eaff4b49..3abfc834ff2 100644
16--- a/gcc/config/microblaze/microblaze.cc
17+++ b/gcc/config/microblaze/microblaze.cc
18@@ -165,6 +165,9 @@ int microblaze_no_unsafe_delay;
19 /* Set to one if the targeted core has the CLZ insn. */
20 int microblaze_has_clz = 0;
21
22+/* Set to one if the targeted core has barrel-shift and cpu > 10.0 */
23+int microblaze_has_bitfield = 0;
24+
25 /* Which CPU pipeline do we use. We haven't really standardized on a CPU
26 version having only a particular type of pipeline. There can still be
27 options on the CPU to scale pipeline features up or down. :(
28@@ -240,6 +243,63 @@ section *sdata2_section;
29 #define TARGET_HAVE_TLS true
30 #endif
31
32+/* Convert a version number of the form "vX.YY.Z" to an integer encoding
33+ for easier range comparison. */
34+static int
35+microblaze_version_to_int (const char *version)
36+{
37+ const char *p, *v;
38+ const char *tmpl = "vXX.YY.Z";
39+ int iver1 =0, iver2 =0, iver3 =0;
40+
41+ p = version;
42+ v = tmpl;
43+
44+ while (*p)
45+ {
46+ if (*v == 'X')
47+ { /* Looking for major */
48+ if (*p == '.')
49+ {
50+ *v++;
51+ }
52+ else
53+ {
54+ if (!(*p >= '0' && *p <= '9'))
55+ return -1;
56+ iver1 += (int) (*p - '0');
57+ iver1 *= 1000;
58+ }
59+ }
60+ else if (*v == 'Y')
61+ { /* Looking for minor */
62+ if (!(*p >= '0' && *p <= '9'))
63+ return -1;
64+ iver2 += (int) (*p - '0');
65+ iver2 *= 10;
66+ }
67+ else if (*v == 'Z')
68+ { /* Looking for compat */
69+ if (!(*p >= 'a' && *p <= 'z'))
70+ return -1;
71+ iver3 = ((int) (*p)) - 96;
72+ }
73+ else
74+ {
75+ if (*p != *v)
76+ return -1;
77+ }
78+
79+ v++;
80+ p++;
81+ }
82+
83+ if (*p)
84+ return -1;
85+
86+ return iver1 + iver2 + iver3;
87+}
88+
89 /* Return truth value if a CONST_DOUBLE is ok to be a legitimate constant. */
90 static bool
91 microblaze_const_double_ok (rtx op, machine_mode mode)
92@@ -1339,8 +1399,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
93 {
94 if (TARGET_BARREL_SHIFT)
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 (2);
102@@ -1401,8 +1460,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
103 }
104 else if (!TARGET_SOFT_MUL)
105 {
106- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
107- >= 0)
108+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
109 *total = COSTS_N_INSNS (1);
110 else
111 *total = COSTS_N_INSNS (3);
112@@ -1675,72 +1733,13 @@ function_arg_partial_bytes (cumulative_args_t cum_v,
113 return 0;
114 }
115
116-/* Convert a version number of the form "vX.YY.Z" to an integer encoding
117- for easier range comparison. */
118-static int
119-microblaze_version_to_int (const char *version)
120-{
121- const char *p, *v;
122- const char *tmpl = "vXX.YY.Z";
123- int iver = 0;
124-
125- p = version;
126- v = tmpl;
127-
128- while (*p)
129- {
130- if (*v == 'X')
131- { /* Looking for major */
132- if (*p == '.')
133- {
134- v++;
135- }
136- else
137- {
138- if (!(*p >= '0' && *p <= '9'))
139- return -1;
140- iver += (int) (*p - '0');
141- iver *= 10;
142- }
143- }
144- else if (*v == 'Y')
145- { /* Looking for minor */
146- if (!(*p >= '0' && *p <= '9'))
147- return -1;
148- iver += (int) (*p - '0');
149- iver *= 10;
150- }
151- else if (*v == 'Z')
152- { /* Looking for compat */
153- if (!(*p >= 'a' && *p <= 'z'))
154- return -1;
155- iver *= 10;
156- iver += (int) (*p - 'a');
157- }
158- else
159- {
160- if (*p != *v)
161- return -1;
162- }
163-
164- v++;
165- p++;
166- }
167-
168- if (*p)
169- return -1;
170-
171- return iver;
172-}
173-
174-
175 static void
176 microblaze_option_override (void)
177 {
178 int i, start;
179 int regno;
180 machine_mode mode;
181- int ver;
182+ int ver,ver_int;
183
184 microblaze_section_threshold = (OPTION_SET_P (g_switch_value)
185 ? g_switch_value
186@@ -1761,13 +1760,13 @@ microblaze_option_override (void)
187 /* Check the MicroBlaze CPU version for any special action to be done. */
188 if (microblaze_select_cpu == NULL)
189 microblaze_select_cpu = MICROBLAZE_DEFAULT_CPU;
190- ver = microblaze_version_to_int (microblaze_select_cpu);
191- if (ver == -1)
192+ ver_int = microblaze_version_to_int (microblaze_select_cpu);
193+ if (ver_int == -1)
194 {
195 error ("%qs is an invalid argument to %<-mcpu=%>", microblaze_select_cpu);
196 }
197
198- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v3.00.a");
199+ ver = ver_int - microblaze_version_to_int("v3.00.a");
200 if (ver < 0)
201 {
202 /* No hardware exceptions in earlier versions. So no worries. */
203@@ -1778,8 +1777,7 @@ microblaze_option_override (void)
204 microblaze_pipe = MICROBLAZE_PIPE_3;
205 }
206 else if (ver == 0
207- || (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v4.00.b")
208- == 0))
209+ || (ver_int == microblaze_version_to_int("v4.00.b")))
210 {
211 #if 0
212 microblaze_select_flags |= (MICROBLAZE_MASK_NO_UNSAFE_DELAY);
213@@ -1796,11 +1794,9 @@ microblaze_option_override (void)
214 #endif
215 microblaze_no_unsafe_delay = 0;
216 microblaze_pipe = MICROBLAZE_PIPE_5;
217- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a") == 0
218- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
219- "v5.00.b") == 0
220- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
221- "v5.00.c") == 0)
222+ if ((ver_int == microblaze_version_to_int("v5.00.a"))
223+ || (ver_int == microblaze_version_to_int("v5.00.b"))
224+ || (ver_int == microblaze_version_to_int("v5.00.c")))
225 {
226 /* Pattern compares are to be turned on by default only when
227 compiling for MB v5.00.'z'. */
228@@ -1808,7 +1804,7 @@ microblaze_option_override (void)
229 }
230 }
231
232- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v6.00.a");
233+ ver = ver_int - microblaze_version_to_int("v6.00.a");
234 if (ver < 0)
235 {
236 if (TARGET_MULTIPLY_HIGH)
237@@ -1817,7 +1813,7 @@ microblaze_option_override (void)
238 "%<-mcpu=v6.00.a%> or greater");
239 }
240
241- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.10.a");
242+ ver = ver_int - microblaze_version_to_int("v8.10.a");
243 microblaze_has_clz = 1;
244 if (ver < 0)
245 {
246@@ -1826,7 +1822,7 @@ microblaze_option_override (void)
247 }
248
249 /* TARGET_REORDER defaults to 2 if -mxl-reorder not specified. */
250- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.30.a");
251+ ver = ver_int - microblaze_version_to_int("v8.30.a");
252 if (ver < 0)
253 {
254 if (TARGET_REORDER == 1)
255@@ -1841,7 +1837,7 @@ microblaze_option_override (void)
256 "%<-mcpu=v8.30.a%>");
257 TARGET_REORDER = 0;
258 }
259- ver = microblaze_version_to_int("v10.0");
260+ ver = ver_int - microblaze_version_to_int("v10.0");
261 if (ver < 0)
262 {
263 if (TARGET_AREA_OPTIMIZED_2)
264@@ -1851,6 +1847,8 @@ microblaze_option_override (void)
265 {
266 if (TARGET_AREA_OPTIMIZED_2)
267 microblaze_pipe = MICROBLAZE_PIPE_8;
268+ if (TARGET_BARREL_SHIFT)
269+ microblaze_has_bitfield = 1;
270 }
271
272 if (TARGET_MULTIPLY_HIGH && TARGET_SOFT_MUL)
273diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
274index 640ae6ea9a3..67015058198 100644
275--- a/gcc/config/microblaze/microblaze.h
276+++ b/gcc/config/microblaze/microblaze.h
277@@ -44,6 +44,7 @@ extern int microblaze_dbx_regno[];
278
279 extern int microblaze_no_unsafe_delay;
280 extern int microblaze_has_clz;
281+extern int microblaze_has_bitfield;
282 extern enum pipeline_type microblaze_pipe;
283
284 #define OBJECT_FORMAT_ELF
285@@ -63,6 +64,7 @@ extern enum pipeline_type microblaze_pipe;
286 /* Do we have CLZ? */
287 #define TARGET_HAS_CLZ (TARGET_PATTERN_COMPARE && microblaze_has_clz)
288
289+#define TARGET_HAS_BITFIELD (TARGET_BARREL_SHIFT && microblaze_has_bitfield)
290 /* The default is to support PIC. */
291 #define TARGET_SUPPORTS_PIC 1
292
293diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
294index 9e9dfb1ccb0..dede4d068d3 100644
295--- a/gcc/config/microblaze/microblaze.md
296+++ b/gcc/config/microblaze/microblaze.md
297@@ -2491,4 +2491,73 @@
298 DONE;
299 }")
300
301+(define_expand "extvsi"
302+ [(set (match_operand:SI 0 "register_operand" "r")
303+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
304+ (match_operand:SI 2 "immediate_operand" "I")
305+ (match_operand:SI 3 "immediate_operand" "I")))]
306+"TARGET_HAS_BITFIELD"
307+"
308+{
309+ unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
310+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
311+
312+ if ((len == 0) || (pos + len > 32) )
313+ FAIL;
314+
315+ ;;if (!register_operand (operands[1], VOIDmode))
316+ ;; FAIL;
317+ if (operands[0] == operands[1])
318+ FAIL;
319+ if (GET_CODE (operands[1]) == ASHIFT)
320+ FAIL;
321+;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
322+ emit_insn (gen_extv_32 (operands[0], operands[1],
323+ operands[2], operands[3]));
324+ DONE;
325+}")
326+
327+(define_insn "extv_32"
328+ [(set (match_operand:SI 0 "register_operand" "=r")
329+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
330+ (match_operand:SI 2 "immediate_operand" "I")
331+ (match_operand:SI 3 "immediate_operand" "I")))]
332+ "TARGET_HAS_BITFIELD && (UINTVAL (operands[2]) > 0)
333+ && ((UINTVAL (operands[2]) + UINTVAL (operands[3])) <= 32)"
334+ "bsefi %0,%1,%2,%3"
335+ [(set_attr "type" "bshift")
336+ (set_attr "length" "4")])
337+
338+(define_expand "insvsi"
339+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
340+ (match_operand:SI 1 "immediate_operand" "I")
341+ (match_operand:SI 2 "immediate_operand" "I"))
342+ (match_operand:SI 3 "register_operand" "r"))]
343+ "TARGET_HAS_BITFIELD"
344+ "
345+{
346+ unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
347+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
348+
349+ if (len <= 0 || pos + len > 32)
350+ FAIL;
351+
352+ ;;if (!register_operand (operands[0], VOIDmode))
353+ ;; FAIL;
354+ emit_insn (gen_insv_32 (operands[0], operands[1],
355+ operands[2], operands[3]));
356+ DONE;
357+}")
358+
359+(define_insn "insv_32"
360+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
361+ (match_operand:SI 1 "immediate_operand" "I")
362+ (match_operand:SI 2 "immediate_operand" "I"))
363+ (match_operand:SI 3 "register_operand" "r"))]
364+ "TARGET_HAS_BITFIELD && UINTVAL (operands[1]) > 0
365+ && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
366+ "bsifi %0, %3, %1, %2"
367+ [(set_attr "type" "bshift")
368+ (set_attr "length" "4")])
369+
370 (include "sync.md")
371--
3722.37.1 (Apple Git-137.1)
373
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0025-Fixing-the-issue-with-the-builtin_alloc.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0025-Fixing-the-issue-with-the-builtin_alloc.patch
deleted file mode 100644
index 109e0686..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0025-Fixing-the-issue-with-the-builtin_alloc.patch
+++ /dev/null
@@ -1,44 +0,0 @@
1From 101f47dedd82fc09bcefd5db986e6d6b0a1761ad Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 23 Feb 2017 17:09:04 +0530
4Subject: [PATCH 25/53] 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 dede4d068d3..c6d8a87e9d1 100644
15--- a/gcc/config/microblaze/microblaze.md
16+++ b/gcc/config/microblaze/microblaze.md
17@@ -2075,10 +2075,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@@ -2087,9 +2087,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.37.1 (Apple Git-137.1)
44
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0026-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0026-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch
deleted file mode 100644
index 4f101b96..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0026-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch
+++ /dev/null
@@ -1,38 +0,0 @@
1From b3e51ca34dc4048445b178253051ad4bbdfc5ec4 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 4 Jun 2018 10:10:18 +0530
4Subject: [PATCH 26/53] [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 c6d8a87e9d1..f23a85c7ac7 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.37.1 (Apple Git-137.1)
38
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0027-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0027-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch
deleted file mode 100644
index 2e7106d6..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0027-Patch-MicroBlaze-Intial-commit-of-64-bit-Microblaze.patch
+++ /dev/null
@@ -1,784 +0,0 @@
1From cf9ab9693d02212e1a49465e55d759a01acc507a Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 13:56:52 +0530
4Subject: [PATCH 27/53] [Patch,MicroBlaze]: Intial commit of 64-bit Microblaze
5
6 Conflicts:
7 gcc/config/microblaze/microblaze.md
8---
9 gcc/config/microblaze/constraints.md | 6 +
10 gcc/config/microblaze/microblaze-protos.h | 1 +
11 gcc/config/microblaze/microblaze.cc | 109 +++++--
12 gcc/config/microblaze/microblaze.h | 4 +-
13 gcc/config/microblaze/microblaze.md | 352 +++++++++++++++++++++-
14 gcc/config/microblaze/microblaze.opt | 7 +-
15 gcc/config/microblaze/t-microblaze | 7 +-
16 7 files changed, 456 insertions(+), 30 deletions(-)
17
18diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
19index a8934d305ee..2133650147e 100644
20--- a/gcc/config/microblaze/constraints.md
21+++ b/gcc/config/microblaze/constraints.md
22@@ -52,6 +52,12 @@
23 (and (match_code "const_int")
24 (match_test "ival > 0 && ival < 0x10000")))
25
26+(define_constraint "K"
27+ "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
28+ (and (match_code "const_int")
29+ (match_test "ival > (long)0xffffff8000000000L && ival < (long)0x0000007fffffffffL")))
30+
31+
32 ;; Define floating point constraints
33
34 (define_constraint "G"
35diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
36index 848cd509003..7f575c2adec 100644
37--- a/gcc/config/microblaze/microblaze-protos.h
38+++ b/gcc/config/microblaze/microblaze-protos.h
39@@ -36,6 +36,7 @@ extern void microblaze_expand_divide (rtx *);
40 extern void microblaze_expand_conditional_branch (enum machine_mode, rtx *);
41 extern void microblaze_expand_conditional_branch_reg (machine_mode, rtx *);
42 extern void microblaze_expand_conditional_branch_sf (rtx *);
43+extern void microblaze_expand_conditional_branch_df (rtx *);
44 extern int microblaze_can_use_return_insn (void);
45 extern void print_operand (FILE *, rtx, int);
46 extern void print_operand_address (FILE *, rtx);
47diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
48index 3abfc834ff2..1ac889041b8 100644
49--- a/gcc/config/microblaze/microblaze.cc
50+++ b/gcc/config/microblaze/microblaze.cc
51@@ -3433,11 +3433,11 @@ microblaze_expand_move (machine_mode mode, rtx operands[])
52 op0 = operands[0];
53 op1 = operands[1];
54
55- if (!register_operand (op0, SImode)
56- && !register_operand (op1, SImode)
57+ if (!register_operand (op0, mode)
58+ && !register_operand (op1, mode)
59 && (GET_CODE (op1) != CONST_INT || INTVAL (op1) != 0))
60 {
61- rtx temp = force_reg (SImode, op1);
62+ rtx temp = force_reg (mode, op1);
63 emit_move_insn (op0, temp);
64 return true;
65 }
66@@ -3502,12 +3502,12 @@ microblaze_expand_move (machine_mode mode, rtx operands[])
67 && (flag_pic == 2 || microblaze_tls_symbol_p (p0)
68 || !SMALL_INT (p1)))))
69 {
70- rtx temp = force_reg (SImode, p0);
71+ rtx temp = force_reg (mode, p0);
72 rtx temp2 = p1;
73
74 if (flag_pic && reload_in_progress)
75 df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
76- emit_move_insn (op0, gen_rtx_PLUS (SImode, temp, temp2));
77+ emit_move_insn (op0, gen_rtx_PLUS (mode, temp, temp2));
78 return true;
79 }
80 }
81@@ -3638,7 +3638,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
82 rtx cmp_op0 = operands[1];
83 rtx cmp_op1 = operands[2];
84 rtx label1 = operands[3];
85- rtx comp_reg = gen_reg_rtx (SImode);
86+ rtx comp_reg = gen_reg_rtx (mode);
87 rtx condition;
88
89 gcc_assert ((GET_CODE (cmp_op0) == REG) || (GET_CODE (cmp_op0) == SUBREG));
90@@ -3647,23 +3647,36 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
91 if (cmp_op1 == const0_rtx)
92 {
93 comp_reg = cmp_op0;
94- condition = gen_rtx_fmt_ee (signed_condition (code), SImode, comp_reg, const0_rtx);
95- emit_jump_insn (gen_condjump (condition, label1));
96+ condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
97+ if (mode == SImode)
98+ emit_jump_insn (gen_condjump (condition, label1));
99+ else
100+ emit_jump_insn (gen_long_condjump (condition, label1));
101+
102 }
103
104 else if (code == EQ || code == NE)
105 {
106 /* Use xor for equal/not-equal comparison. */
107- emit_insn (gen_xorsi3 (comp_reg, cmp_op0, cmp_op1));
108- condition = gen_rtx_fmt_ee (signed_condition (code), SImode, comp_reg, const0_rtx);
109- emit_jump_insn (gen_condjump (condition, label1));
110+ if (mode == SImode)
111+ emit_insn (gen_xorsi3 (comp_reg, cmp_op0, cmp_op1));
112+ else
113+ emit_insn (gen_xordi3 (comp_reg, cmp_op0, cmp_op1));
114+ condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
115+ if (mode == SImode)
116+ emit_jump_insn (gen_condjump (condition, label1));
117+ else
118+ emit_jump_insn (gen_long_condjump (condition, label1));
119 }
120 else
121 {
122 /* Generate compare and branch in single instruction. */
123 cmp_op1 = force_reg (mode, cmp_op1);
124 condition = gen_rtx_fmt_ee (code, mode, cmp_op0, cmp_op1);
125- emit_jump_insn (gen_branch_compare(condition, cmp_op0, cmp_op1, label1));
126+ if (mode == SImode)
127+ emit_jump_insn (gen_branch_compare(condition, cmp_op0, cmp_op1, label1));
128+ else
129+ emit_jump_insn (gen_long_branch_compare(condition, cmp_op0, cmp_op1, label1));
130 }
131 }
132
133@@ -3674,7 +3687,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
134 rtx cmp_op0 = operands[1];
135 rtx cmp_op1 = operands[2];
136 rtx label1 = operands[3];
137- rtx comp_reg = gen_reg_rtx (SImode);
138+ rtx comp_reg = gen_reg_rtx (mode);
139 rtx condition;
140
141 gcc_assert ((GET_CODE (cmp_op0) == REG)
142@@ -3685,30 +3698,63 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
143 {
144 comp_reg = cmp_op0;
145 condition = gen_rtx_fmt_ee (signed_condition (code),
146- SImode, comp_reg, const0_rtx);
147- emit_jump_insn (gen_condjump (condition, label1));
148+ mode, comp_reg, const0_rtx);
149+ if (mode == SImode)
150+ emit_jump_insn (gen_condjump (condition, label1));
151+ else
152+ emit_jump_insn (gen_long_condjump (condition, label1));
153 }
154 else if (code == EQ)
155 {
156- emit_insn (gen_seq_internal_pat (comp_reg,
157- cmp_op0, cmp_op1));
158- condition = gen_rtx_EQ (SImode, comp_reg, const0_rtx);
159- emit_jump_insn (gen_condjump (condition, label1));
160+ if (mode == SImode)
161+ {
162+ emit_insn (gen_seq_internal_pat (comp_reg, cmp_op0,
163+ cmp_op1));
164+ }
165+ else
166+ {
167+ emit_insn (gen_seq_internal_pat (comp_reg, cmp_op0,
168+ cmp_op1));
169+ }
170+ condition = gen_rtx_EQ (mode, comp_reg, const0_rtx);
171+ if (mode == SImode)
172+ emit_jump_insn (gen_condjump (condition, label1));
173+ else
174+ emit_jump_insn (gen_long_condjump (condition, label1));
175+
176 }
177 else if (code == NE)
178 {
179- emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
180- cmp_op1));
181- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
182- emit_jump_insn (gen_condjump (condition, label1));
183+ if (mode == SImode)
184+ {
185+ emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
186+ cmp_op1));
187+ }
188+ else
189+ {
190+ emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
191+ cmp_op1));
192+ }
193+ condition = gen_rtx_NE (mode, comp_reg, const0_rtx);
194+ if (mode == SImode)
195+ emit_jump_insn (gen_condjump (condition, label1));
196+ else
197+ emit_jump_insn (gen_long_condjump (condition, label1));
198 }
199 else
200 {
201 /* Generate compare and branch in single instruction. */
202 cmp_op1 = force_reg (mode, cmp_op1);
203 condition = gen_rtx_fmt_ee (code, mode, cmp_op0, cmp_op1);
204- emit_jump_insn (gen_branch_compare (condition, cmp_op0,
205- cmp_op1, label1));
206+ if (mode == SImode)
207+ emit_jump_insn (gen_branch_compare (condition, cmp_op0,
208+ cmp_op1, label1));
209+ else
210+ {
211+ emit_jump_insn (gen_long_branch_compare (condition, cmp_op0,
212+ cmp_op1, label1));
213+ }
214+
215 }
216 }
217
218@@ -3725,6 +3771,19 @@ microblaze_expand_conditional_branch_sf (rtx operands[])
219 emit_jump_insn (gen_condjump (condition, operands[3]));
220 }
221
222+void
223+microblaze_expand_conditional_branch_df (rtx operands[])
224+{
225+ rtx condition;
226+ rtx cmp_op0 = XEXP (operands[0], 0);
227+ rtx cmp_op1 = XEXP (operands[0], 1);
228+ rtx comp_reg = gen_reg_rtx (DImode);
229+
230+ emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
231+ condition = gen_rtx_NE (DImode, comp_reg, const0_rtx);
232+ emit_jump_insn (gen_long_condjump (condition, operands[3]));
233+}
234+
235 /* Implement TARGET_FRAME_POINTER_REQUIRED. */
236
237 static bool
238diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
239index 67015058198..885abc6e5a1 100644
240--- a/gcc/config/microblaze/microblaze.h
241+++ b/gcc/config/microblaze/microblaze.h
242@@ -102,6 +102,7 @@ extern enum pipeline_type microblaze_pipe;
243 #define ASM_SPEC "\
244 %(target_asm_spec) \
245 %{mbig-endian:-EB} \
246+%{m64:-m64} \
247 %{mlittle-endian:-EL}"
248
249 /* Extra switches sometimes passed to the linker. */
250@@ -110,6 +111,7 @@ extern enum pipeline_type microblaze_pipe;
251 #define LINK_SPEC "%{shared:-shared} -N -relax \
252 %{mbig-endian:-EB --oformat=elf32-microblaze} \
253 %{mlittle-endian:-EL --oformat=elf32-microblazeel} \
254+ %{m64:-EL --oformat=elf64-microblazeel} \
255 %{Zxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
256 %{mxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
257 %{mxl-gp-opt:%{G*}} %{!mxl-gp-opt: -G 0} \
258@@ -217,7 +219,7 @@ extern enum pipeline_type microblaze_pipe;
259 #define MIN_UNITS_PER_WORD 4
260 #define INT_TYPE_SIZE 32
261 #define SHORT_TYPE_SIZE 16
262-#define LONG_TYPE_SIZE 32
263+#define LONG_TYPE_SIZE 64
264 #define LONG_LONG_TYPE_SIZE 64
265 #define FLOAT_TYPE_SIZE 32
266 #define DOUBLE_TYPE_SIZE 64
267diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
268index f23a85c7ac7..40711fe224b 100644
269--- a/gcc/config/microblaze/microblaze.md
270+++ b/gcc/config/microblaze/microblaze.md
271@@ -497,7 +497,6 @@
272 (set_attr "mode" "SF")
273 (set_attr "length" "4")])
274
275-
276 (define_insn "divsf3"
277 [(set (match_operand:SF 0 "register_operand" "=d")
278 (div:SF (match_operand:SF 1 "register_operand" "d")
279@@ -508,6 +507,7 @@
280 (set_attr "mode" "SF")
281 (set_attr "length" "4")])
282
283+
284 (define_insn "sqrtsf2"
285 [(set (match_operand:SF 0 "register_operand" "=d")
286 (sqrt:SF (match_operand:SF 1 "register_operand" "d")))]
287@@ -562,6 +562,18 @@
288
289 ;; Adding 2 DI operands in register or reg/imm
290
291+(define_insn "adddi3_long"
292+ [(set (match_operand:DI 0 "register_operand" "=d,d")
293+ (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%dJ,dJ")
294+ (match_operand:DI 2 "arith_plus_operand" "d,K")))]
295+ "TARGET_MB_64"
296+ "@
297+ addlk\t%0,%z1,%2
298+ addlik\t%0,%z1,%2"
299+ [(set_attr "type" "arith,arith")
300+ (set_attr "mode" "DI,DI")
301+ (set_attr "length" "4,4")])
302+
303 (define_insn "adddi3"
304 [(set (match_operand:DI 0 "register_operand" "=d,d")
305 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
306@@ -606,6 +618,18 @@
307 ;; Double Precision Subtraction
308 ;;----------------------------------------------------------------
309
310+(define_insn "subdi3_long"
311+ [(set (match_operand:DI 0 "register_operand" "=d,d")
312+ (minus:DI (match_operand:DI 1 "register_operand" "d,d")
313+ (match_operand:DI 2 "register_operand" "d,n")))]
314+ "TARGET_MB_64"
315+ "@
316+ rsubl\t%0,%2,%1
317+ addlik\t%0,%z1,-%2"
318+ [(set_attr "type" "darith")
319+ (set_attr "mode" "DI,DI")
320+ (set_attr "length" "4,4")])
321+
322 (define_insn "subdi3"
323 [(set (match_operand:DI 0 "register_operand" "=&d")
324 (minus:DI (match_operand:DI 1 "register_operand" "d")
325@@ -795,6 +819,15 @@
326 (set_attr "mode" "SI")
327 (set_attr "length" "4")])
328
329+(define_insn "negdi2_long"
330+ [(set (match_operand:DI 0 "register_operand" "=d")
331+ (neg:DI (match_operand:DI 1 "register_operand" "d")))]
332+ "TARGET_MB_64"
333+ "rsubl\t%0,%1,r0"
334+ [(set_attr "type" "darith")
335+ (set_attr "mode" "DI")
336+ (set_attr "length" "4")])
337+
338 (define_insn "negdi2"
339 [(set (match_operand:DI 0 "register_operand" "=d")
340 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
341@@ -814,6 +847,15 @@
342 (set_attr "mode" "SI")
343 (set_attr "length" "4")])
344
345+(define_insn "one_cmpldi2_long"
346+ [(set (match_operand:DI 0 "register_operand" "=d")
347+ (not:DI (match_operand:DI 1 "register_operand" "d")))]
348+ "TARGET_MB_64"
349+ "xorli\t%0,%1,-1"
350+ [(set_attr "type" "arith")
351+ (set_attr "mode" "DI")
352+ (set_attr "length" "4")])
353+
354 (define_insn "*one_cmpldi2"
355 [(set (match_operand:DI 0 "register_operand" "=d")
356 (not:DI (match_operand:DI 1 "register_operand" "d")))]
357@@ -840,6 +882,20 @@
358 ;; Logical
359 ;;----------------------------------------------------------------
360
361+(define_insn "anddi3"
362+ [(set (match_operand:DI 0 "register_operand" "=d,d")
363+ (and:DI (match_operand:DI 1 "arith_operand" "d,d")
364+ (match_operand:DI 2 "arith_operand" "d,K")))]
365+ "TARGET_MB_64"
366+ "@
367+ andl\t%0,%1,%2
368+ andli\t%0,%1,%2 #andl1"
369+ ;; andli\t%0,%1,%2 #andl3
370+ ;; andli\t%0,%1,%2 #andl2
371+ [(set_attr "type" "arith,arith")
372+ (set_attr "mode" "DI,DI")
373+ (set_attr "length" "4,4")])
374+
375 (define_insn "andsi3"
376 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
377 (and:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d")
378@@ -855,6 +911,18 @@
379 (set_attr "length" "4,8,8,8")])
380
381
382+(define_insn "iordi3"
383+ [(set (match_operand:DI 0 "register_operand" "=d,d")
384+ (ior:DI (match_operand:DI 1 "arith_operand" "d,d")
385+ (match_operand:DI 2 "arith_operand" "d,K")))]
386+ "TARGET_MB_64"
387+ "@
388+ orl\t%0,%1,%2
389+ orli\t%0,%1,%2 #andl1"
390+ [(set_attr "type" "arith,arith")
391+ (set_attr "mode" "DI,DI")
392+ (set_attr "length" "4,4")])
393+
394 (define_insn "iorsi3"
395 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
396 (ior:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d")
397@@ -869,6 +937,19 @@
398 (set_attr "mode" "SI,SI,SI,SI")
399 (set_attr "length" "4,8,8,8")])
400
401+(define_insn "xordi3"
402+ [(set (match_operand:DI 0 "register_operand" "=d,d")
403+ (xor:DI (match_operand:DI 1 "arith_operand" "%d,d")
404+ (match_operand:DI 2 "arith_operand" "d,K")))]
405+ "TARGET_MB_64"
406+ "@
407+ xorl\t%0,%1,%2
408+ xorli\t%0,%1,%2 #andl1"
409+ [(set_attr "type" "arith,arith")
410+ (set_attr "mode" "DI,DI")
411+ (set_attr "length" "4,4")])
412+
413+
414 (define_insn "xorsi3"
415 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
416 (xor:SI (match_operand:SI 1 "arith_operand" "%d,d,d")
417@@ -937,6 +1018,26 @@
418 (set_attr "mode" "SI")
419 (set_attr "length" "4")])
420
421+;;(define_expand "extendqidi2"
422+;; [(set (match_operand:DI 0 "register_operand" "=d")
423+;; (sign_extend:DI (match_operand:QI 1 "general_operand" "d")))]
424+;; "TARGET_MB_64"
425+;; {
426+;; if (GET_CODE (operands[1]) != REG)
427+;; FAIL;
428+;; }
429+;;)
430+
431+
432+;;(define_insn "extendqidi2"
433+;; [(set (match_operand:DI 0 "register_operand" "=d")
434+;; (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
435+;; "TARGET_MB_64"
436+;; "sextl8\t%0,%1"
437+;; [(set_attr "type" "arith")
438+;; (set_attr "mode" "DI")
439+;; (set_attr "length" "4")])
440+
441 (define_insn "extendhisi2"
442 [(set (match_operand:SI 0 "register_operand" "=d")
443 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
444@@ -946,6 +1047,16 @@
445 (set_attr "mode" "SI")
446 (set_attr "length" "4")])
447
448+(define_insn "extendhidi2"
449+ [(set (match_operand:DI 0 "register_operand" "=d")
450+ (sign_extend:DI (match_operand:HI 1 "register_operand" "d")))]
451+ "TARGET_MB_64"
452+ "sextl16\t%0,%1"
453+ [(set_attr "type" "arith")
454+ (set_attr "mode" "DI")
455+ (set_attr "length" "4")])
456+
457+
458 ;; Those for integer source operand are ordered
459 ;; widest source type first.
460
461@@ -1009,6 +1120,32 @@
462 )
463
464
465+(define_insn "*movdi_internal_64"
466+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
467+ (match_operand:DI 1 "general_operand" " d,K,J,R,o,d,d"))]
468+ "TARGET_MB_64 && (INTVAL(operands[1]) < 0x7fffffffff) && (INTVAL(operands[1]) > 0xffffff8000000000)"
469+ {
470+ switch (which_alternative)
471+ {
472+ case 0:
473+ return "addlk\t%0,%1";
474+ case 1:
475+ return "addlik\t%0,r0,%1";
476+ case 2:
477+ return "addlk\t%0,r0,r0";
478+ case 3:
479+ case 4:
480+ return "lli\t%0,%1";
481+ case 5:
482+ case 6:
483+ return "sli\t%1,%0";
484+ }
485+ return "unreachable";
486+ }
487+ [(set_attr "type" "no_delay_move,no_delay_arith,no_delay_arith,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
488+ (set_attr "mode" "DI")
489+ (set_attr "length" "8,8,8,8,12,8,12")])
490+
491
492 (define_insn "*movdi_internal"
493 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
494@@ -1421,6 +1558,36 @@
495 (set_attr "length" "4,4")]
496 )
497
498+;; Barrel shift left
499+(define_expand "ashldi3"
500+ [(set (match_operand:DI 0 "register_operand" "=&d")
501+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
502+ (match_operand:DI 2 "arith_operand" "")))]
503+"TARGET_MB_64"
504+{
505+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
506+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
507+ {
508+ emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
509+ DONE;
510+ }
511+else
512+ FAIL;
513+}
514+)
515+
516+(define_insn "ashldi3_long"
517+ [(set (match_operand:DI 0 "register_operand" "=d,d")
518+ (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
519+ (match_operand:DI 2 "arith_operand" "I,d")))]
520+ "TARGET_MB_64"
521+ "@
522+ bsllli\t%0,%1,%2
523+ bslll\t%0,%1,%2"
524+ [(set_attr "type" "bshift,bshift")
525+ (set_attr "mode" "DI,DI")
526+ (set_attr "length" "4,4")]
527+)
528 ;; The following patterns apply when there is no barrel shifter present
529
530 (define_insn "*ashlsi3_with_mul_delay"
531@@ -1546,6 +1713,36 @@
532 ;;----------------------------------------------------------------
533 ;; 32-bit right shifts
534 ;;----------------------------------------------------------------
535+;; Barrel shift left
536+(define_expand "ashrdi3"
537+ [(set (match_operand:DI 0 "register_operand" "=&d")
538+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
539+ (match_operand:DI 2 "arith_operand" "")))]
540+"TARGET_MB_64"
541+{
542+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
543+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
544+ {
545+ emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
546+ DONE;
547+ }
548+else
549+ FAIL;
550+}
551+)
552+
553+(define_insn "ashrdi3_long"
554+ [(set (match_operand:DI 0 "register_operand" "=d,d")
555+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
556+ (match_operand:DI 2 "arith_operand" "I,d")))]
557+ "TARGET_MB_64"
558+ "@
559+ bslrai\t%0,%1,%2
560+ bslra\t%0,%1,%2"
561+ [(set_attr "type" "bshift,bshift")
562+ (set_attr "mode" "DI,DI")
563+ (set_attr "length" "4,4")]
564+ )
565 (define_expand "ashrsi3"
566 [(set (match_operand:SI 0 "register_operand" "=&d")
567 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
568@@ -1655,6 +1852,36 @@
569 ;;----------------------------------------------------------------
570 ;; 32-bit right shifts (logical)
571 ;;----------------------------------------------------------------
572+;; Barrel shift left
573+(define_expand "lshrdi3"
574+ [(set (match_operand:DI 0 "register_operand" "=&d")
575+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
576+ (match_operand:DI 2 "arith_operand" "")))]
577+"TARGET_MB_64"
578+{
579+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
580+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
581+ {
582+ emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
583+ DONE;
584+ }
585+else
586+ FAIL;
587+}
588+)
589+
590+(define_insn "lshrdi3_long"
591+ [(set (match_operand:DI 0 "register_operand" "=d,d")
592+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
593+ (match_operand:DI 2 "arith_operand" "I,d")))]
594+ "TARGET_MB_64"
595+ "@
596+ bslrli\t%0,%1,%2
597+ bslrl\t%0,%1,%2"
598+ [(set_attr "type" "bshift,bshift")
599+ (set_attr "mode" "DI,DI")
600+ (set_attr "length" "4,4")]
601+ )
602
603 (define_expand "lshrsi3"
604 [(set (match_operand:SI 0 "register_operand" "=&d")
605@@ -1800,6 +2027,8 @@
606 (set_attr "length" "4")]
607 )
608
609+
610+
611 ;;----------------------------------------------------------------
612 ;; Setting a register from an floating point comparison.
613 ;;----------------------------------------------------------------
614@@ -1815,6 +2044,18 @@
615 (set_attr "length" "4")]
616 )
617
618+(define_insn "cstoredf4"
619+ [(set (match_operand:DI 0 "register_operand" "=r")
620+ (match_operator:DI 1 "ordered_comparison_operator"
621+ [(match_operand:DF 2 "register_operand" "r")
622+ (match_operand:DF 3 "register_operand" "r")]))]
623+ "TARGET_MB_64"
624+ "dcmp.%C1\t%0,%3,%2"
625+ [(set_attr "type" "fcmp")
626+ (set_attr "mode" "DF")
627+ (set_attr "length" "4")]
628+)
629+
630 ;;----------------------------------------------------------------
631 ;; Conditional branches
632 ;;----------------------------------------------------------------
633@@ -1927,6 +2168,115 @@
634 (set_attr "length" "12")]
635 )
636
637+
638+(define_expand "cbranchdi4"
639+ [(set (pc)
640+ (if_then_else (match_operator 0 "ordered_comparison_operator"
641+ [(match_operand:DI 1 "register_operand")
642+ (match_operand:DI 2 "arith_operand" "I,i")])
643+ (label_ref (match_operand 3 ""))
644+ (pc)))]
645+ "TARGET_MB_64"
646+{
647+ microblaze_expand_conditional_branch (DImode, operands);
648+ DONE;
649+})
650+
651+(define_expand "cbranchdi4_reg"
652+ [(set (pc)
653+ (if_then_else (match_operator 0 "ordered_comparison_operator"
654+ [(match_operand:DI 1 "register_operand")
655+ (match_operand:DI 2 "register_operand")])
656+ (label_ref (match_operand 3 ""))
657+ (pc)))]
658+ "TARGET_MB_64"
659+{
660+ microblaze_expand_conditional_branch_reg (DImode, operands);
661+ DONE;
662+})
663+
664+(define_expand "cbranchdf4"
665+ [(set (pc)
666+ (if_then_else (match_operator 0 "ordered_comparison_operator"
667+ [(match_operand:DF 1 "register_operand")
668+ (match_operand:DF 2 "register_operand")])
669+ (label_ref (match_operand 3 ""))
670+ (pc)))]
671+ "TARGET_MB_64"
672+{
673+ microblaze_expand_conditional_branch_df (operands);
674+ DONE;
675+
676+})
677+
678+;; Used to implement comparison instructions
679+(define_expand "long_condjump"
680+ [(set (pc)
681+ (if_then_else (match_operand 0)
682+ (label_ref (match_operand 1))
683+ (pc)))])
684+
685+(define_insn "long_branch_zero"
686+ [(set (pc)
687+ (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
688+ [(match_operand:DI 1 "register_operand" "d")
689+ (const_int 0)])
690+ (match_operand:DI 2 "pc_or_label_operand" "")
691+ (match_operand:DI 3 "pc_or_label_operand" "")))
692+ ]
693+ "TARGET_MB_64"
694+ {
695+ if (operands[3] == pc_rtx)
696+ return "beal%C0i%?\t%z1,%2";
697+ else
698+ return "beal%N0i%?\t%z1,%3";
699+ }
700+ [(set_attr "type" "branch")
701+ (set_attr "mode" "none")
702+ (set_attr "length" "4")]
703+)
704+
705+(define_insn "long_branch_compare"
706+ [(set (pc)
707+ (if_then_else (match_operator:DI 0 "cmp_op"
708+ [(match_operand:DI 1 "register_operand" "d")
709+ (match_operand:DI 2 "register_operand" "d")
710+ ])
711+ (label_ref (match_operand 3))
712+ (pc)))
713+ (clobber(reg:DI R_TMP))]
714+ "TARGET_MB_64"
715+ {
716+ operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
717+ enum rtx_code code = GET_CODE (operands[0]);
718+
719+ if (code == GT || code == LE)
720+ {
721+ output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
722+ code = swap_condition (code);
723+ }
724+ else if (code == GTU || code == LEU)
725+ {
726+ output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
727+ code = swap_condition (code);
728+ }
729+ else if (code == GE || code == LT)
730+ {
731+ output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
732+ }
733+ else if (code == GEU || code == LTU)
734+ {
735+ output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
736+ }
737+
738+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
739+ return "beal%C0i%?\tr18,%3";
740+ }
741+ [(set_attr "type" "branch")
742+ (set_attr "mode" "none")
743+ (set_attr "length" "12")]
744+)
745+
746 ;;----------------------------------------------------------------
747 ;; Unconditional branches
748 ;;----------------------------------------------------------------
749diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
750index cc009363f87..10910dbb83f 100644
751--- a/gcc/config/microblaze/microblaze.opt
752+++ b/gcc/config/microblaze/microblaze.opt
753@@ -136,4 +136,9 @@ Target
754
755 mxl-frequency
756 Target Mask(AREA_OPTIMIZED_2)
757-Use 8 stage pipeline (frequency optimization)
758+Use 8 stage pipeline (frequency optimization).
759+
760+m64
761+Target Mask(MB_64)
762+MicroBlaze 64-bit mode.
763+
764diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
765index 7e2fc5dcef8..4c25cfe15e7 100644
766--- a/gcc/config/microblaze/t-microblaze
767+++ b/gcc/config/microblaze/t-microblaze
768@@ -1,8 +1,11 @@
769-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian
770-MULTILIB_DIRNAMES = bs m mh le
771+MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian m64
772+MULTILIB_DIRNAMES = bs m mh le m64
773 MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
774 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
775+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64
776 MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
777+MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
778+MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
779
780 # Extra files
781 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.cc \
782--
7832.37.1 (Apple Git-137.1)
784
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0028-Intial-commit-for-64bit-MB-sources.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0028-Intial-commit-for-64bit-MB-sources.patch
deleted file mode 100644
index 1ffa79cb..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0028-Intial-commit-for-64bit-MB-sources.patch
+++ /dev/null
@@ -1,2442 +0,0 @@
1From da40b160857d0b6a56b6f6c9c81d61dabb5255db Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 14:38:48 +0530
4Subject: [PATCH 28/53] Intial commit for 64bit-MB sources. Need to cleanup
5 the code later.
6
7---
8 gcc/config/microblaze/constraints.md | 2 +-
9 gcc/config/microblaze/microblaze-c.cc | 6 +
10 gcc/config/microblaze/microblaze.cc | 216 ++++++---
11 gcc/config/microblaze/microblaze.h | 63 ++-
12 gcc/config/microblaze/microblaze.md | 605 ++++++++++++++++++------
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, 1229 insertions(+), 232 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 2133650147e..0ced155340d 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.cc b/gcc/config/microblaze/microblaze-c.cc
45index caabe99b993..ef8d2430565 100644
46--- a/gcc/config/microblaze/microblaze-c.cc
47+++ b/gcc/config/microblaze/microblaze-c.cc
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.cc b/gcc/config/microblaze/microblaze.cc
60index 1ac889041b8..9d3628c6816 100644
61--- a/gcc/config/microblaze/microblaze.cc
62+++ b/gcc/config/microblaze/microblaze.cc
63@@ -384,10 +384,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@@ -435,7 +435,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@@ -682,7 +682,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@@ -700,7 +700,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@@ -1303,8 +1303,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@@ -1634,14 +1642,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@@ -2156,7 +2170,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@@ -2425,7 +2439,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@@ -2451,6 +2465,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@@ -2463,12 +2478,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@@ -2662,7 +2677,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@@ -2685,7 +2703,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@@ -2751,7 +2772,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@@ -2759,8 +2780,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@@ -2768,8 +2789,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@@ -2780,9 +2801,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@@ -2797,7 +2818,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@@ -2807,8 +2828,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@@ -2898,7 +2919,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@@ -3042,10 +3066,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@@ -3054,15 +3078,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@@ -3070,7 +3102,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@@ -3180,12 +3212,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@@ -3201,15 +3233,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@@ -3376,9 +3418,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@@ -3391,7 +3438,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@@ -3622,9 +3672,9 @@ microblaze_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
410 emit_block_move (m_tramp, assemble_trampoline_template (),
411 GEN_INT (6*UNITS_PER_WORD), BLOCK_OP_NORMAL);
412
413- mem = adjust_address (m_tramp, SImode, 16);
414+ mem = adjust_address (m_tramp, Pmode, 16);
415 emit_move_insn (mem, chain_value);
416- mem = adjust_address (m_tramp, SImode, 20);
417+ mem = adjust_address (m_tramp, Pmode, 20);
418 emit_move_insn (mem, fnaddr);
419 }
420
421@@ -3648,7 +3698,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
422 {
423 comp_reg = cmp_op0;
424 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
425- if (mode == SImode)
426+ if (mode == Pmode)
427 emit_jump_insn (gen_condjump (condition, label1));
428 else
429 emit_jump_insn (gen_long_condjump (condition, label1));
430@@ -3767,7 +3817,7 @@ microblaze_expand_conditional_branch_sf (rtx operands[])
431 rtx comp_reg = gen_reg_rtx (SImode);
432
433 emit_insn (gen_cstoresf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
434- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
435+ condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
436 emit_jump_insn (gen_condjump (condition, operands[3]));
437 }
438
439@@ -3777,10 +3827,10 @@ microblaze_expand_conditional_branch_df (rtx operands[])
440 rtx condition;
441 rtx cmp_op0 = XEXP (operands[0], 0);
442 rtx cmp_op1 = XEXP (operands[0], 1);
443- rtx comp_reg = gen_reg_rtx (DImode);
444+ rtx comp_reg = gen_reg_rtx (Pmode);
445
446 emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
447- condition = gen_rtx_NE (DImode, comp_reg, const0_rtx);
448+ condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
449 emit_jump_insn (gen_long_condjump (condition, operands[3]));
450 }
451
452@@ -3801,8 +3851,8 @@ microblaze_expand_divide (rtx operands[])
453 {
454 /* Table lookup software divides. Works for all (nr/dr) where (0 <= nr,dr <= 15). */
455
456- rtx regt1 = gen_reg_rtx (SImode);
457- rtx reg18 = gen_rtx_REG (SImode, R_TMP);
458+ rtx regt1 = gen_reg_rtx (Pmode);
459+ rtx reg18 = gen_rtx_REG (Pmode, R_TMP);
460 rtx regqi = gen_reg_rtx (QImode);
461 rtx_code_label *div_label = gen_label_rtx ();
462 rtx_code_label *div_end_label = gen_label_rtx ();
463@@ -3810,17 +3860,31 @@ microblaze_expand_divide (rtx operands[])
464 rtx mem_rtx;
465 rtx ret;
466 rtx_insn *jump, *cjump, *insn;
467-
468- insn = emit_insn (gen_iorsi3 (regt1, operands[1], operands[2]));
469- cjump = emit_jump_insn_after (gen_cbranchsi4 (
470- gen_rtx_GTU (SImode, regt1, GEN_INT (15)),
471+
472+ if (TARGET_MB_64) {
473+ insn = emit_insn (gen_iordi3 (regt1, operands[1], operands[2]));
474+ cjump = emit_jump_insn_after (gen_cbranchdi4 (
475+ gen_rtx_GTU (Pmode, regt1, GEN_INT (15)),
476+ regt1, GEN_INT (15), div_label), insn);
477+ }
478+ else {
479+ insn = emit_insn (gen_iorsi3 (regt1, operands[1], operands[2]));
480+ cjump = emit_jump_insn_after (gen_cbranchsi4 (
481+ gen_rtx_GTU (Pmode, regt1, GEN_INT (15)),
482 regt1, GEN_INT (15), div_label), insn);
483+ }
484 LABEL_NUSES (div_label) = 1;
485 JUMP_LABEL (cjump) = div_label;
486- emit_insn (gen_rtx_CLOBBER (SImode, reg18));
487+ emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
488
489- emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
490- emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
491+ if (TARGET_MB_64) {
492+ emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
493+ emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
494+ }
495+ else {
496+ emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
497+ emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
498+ }
499 mem_rtx = gen_rtx_MEM (QImode,
500 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
501
502@@ -3967,7 +4031,7 @@ insert_wic_for_ilb_runout (rtx_insn *first)
503 {
504 insn =
505 emit_insn_before (gen_iprefetch
506- (gen_int_mode (addr_offset, SImode)),
507+ (gen_int_mode (addr_offset, Pmode)),
508 before_4);
509 recog_memoized (insn);
510 INSN_LOCATION (insn) = INSN_LOCATION (before_4);
511@@ -3977,7 +4041,27 @@ insert_wic_for_ilb_runout (rtx_insn *first)
512 }
513 }
514 }
515-
516+
517+/* Set the names for various arithmetic operations according to the
518+ * MICROBLAZE ABI. */
519+static void
520+microblaze_init_libfuncs (void)
521+{
522+ set_optab_libfunc (smod_optab, SImode, "__modsi3");
523+ set_optab_libfunc (sdiv_optab, SImode, "__divsi3");
524+ set_optab_libfunc (smul_optab, SImode, "__mulsi3");
525+ set_optab_libfunc (umod_optab, SImode, "__umodsi3");
526+ set_optab_libfunc (udiv_optab, SImode, "__udivsi3");
527+
528+ if (TARGET_MB_64)
529+ {
530+ set_optab_libfunc (smod_optab, DImode, "__moddi3");
531+ set_optab_libfunc (sdiv_optab, DImode, "__divdi3");
532+ set_optab_libfunc (smul_optab, DImode, "__muldi3");
533+ set_optab_libfunc (umod_optab, DImode, "__umoddi3");
534+ set_optab_libfunc (udiv_optab, DImode, "__udivdi3");
535+ }
536+}
537 /* Insert instruction prefetch instruction at the fall
538 through path of the function call. */
539
540@@ -4130,6 +4214,17 @@ microblaze_starting_frame_offset (void)
541 #undef TARGET_LRA_P
542 #define TARGET_LRA_P hook_bool_void_false
543
544+#ifdef TARGET_MB_64
545+#undef TARGET_ASM_ALIGNED_DI_OP
546+#define TARGET_ASM_ALIGNED_DI_OP "\t.dword\t"
547+
548+#undef TARGET_ASM_ALIGNED_HI_OP
549+#define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"
550+
551+#undef TARGET_ASM_ALIGNED_SI_OP
552+#define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
553+#endif
554+
555 #undef TARGET_FRAME_POINTER_REQUIRED
556 #define TARGET_FRAME_POINTER_REQUIRED microblaze_frame_pointer_required
557
558@@ -4139,6 +4234,9 @@ microblaze_starting_frame_offset (void)
559 #undef TARGET_TRAMPOLINE_INIT
560 #define TARGET_TRAMPOLINE_INIT microblaze_trampoline_init
561
562+#undef TARGET_INIT_LIBFUNCS
563+#define TARGET_INIT_LIBFUNCS microblaze_init_libfuncs
564+
565 #undef TARGET_PROMOTE_FUNCTION_MODE
566 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
567
568diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
569index 885abc6e5a1..5f30b8ac195 100644
570--- a/gcc/config/microblaze/microblaze.h
571+++ b/gcc/config/microblaze/microblaze.h
572@@ -173,7 +173,6 @@ extern enum pipeline_type microblaze_pipe;
573
574 /* Generate DWARF exception handling info. */
575 #define DWARF2_UNWIND_INFO 1
576-
577 /* Don't generate .loc operations. */
578 #define DWARF2_ASM_LINE_DEBUG_INFO 0
579
580@@ -206,38 +205,51 @@ extern enum pipeline_type microblaze_pipe;
581 ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
582
583 /* Use DWARF 2 debugging information by default. */
584-#define DWARF2_DEBUGGING_INFO
585+#define DWARF2_DEBUGGING_INFO 1
586 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
587+#define DWARF2_ADDR_SIZE 4
588
589 /* Target machine storage layout */
590
591 #define BITS_BIG_ENDIAN 0
592 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
593 #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)
594-#define BITS_PER_WORD 32
595-#define UNITS_PER_WORD 4
596+//#define BITS_PER_WORD 64
597+//Revisit
598+#define MAX_BITS_PER_WORD 64
599+#define UNITS_PER_WORD (TARGET_MB_64 ? 8 : 4)
600+//#define MIN_UNITS_PER_WORD (TARGET_MB_64 ? 8 : 4)
601+//#define UNITS_PER_WORD 4
602 #define MIN_UNITS_PER_WORD 4
603 #define INT_TYPE_SIZE 32
604 #define SHORT_TYPE_SIZE 16
605-#define LONG_TYPE_SIZE 64
606+#define LONG_TYPE_SIZE (TARGET_MB_64 ? 64 : 32)
607 #define LONG_LONG_TYPE_SIZE 64
608 #define FLOAT_TYPE_SIZE 32
609 #define DOUBLE_TYPE_SIZE 64
610 #define LONG_DOUBLE_TYPE_SIZE 64
611-#define POINTER_SIZE 32
612-#define PARM_BOUNDARY 32
613-#define FUNCTION_BOUNDARY 32
614-#define EMPTY_FIELD_BOUNDARY 32
615+#define POINTER_SIZE (TARGET_MB_64 ? 64 : 32)
616+//#define WIDEST_HARDWARE_FP_SIZE 64
617+//#define POINTERS_EXTEND_UNSIGNED 1
618+#define PARM_BOUNDARY (TARGET_MB_64 ? 64 : 32)
619+#define FUNCTION_BOUNDARY (TARGET_MB_64 ? 64 : 32)
620+#define EMPTY_FIELD_BOUNDARY (TARGET_MB_64 ? 64 : 32)
621 #define STRUCTURE_SIZE_BOUNDARY 8
622-#define BIGGEST_ALIGNMENT 32
623+#define BIGGEST_ALIGNMENT (TARGET_MB_64 ? 64 : 32)
624 #define STRICT_ALIGNMENT 1
625 #define PCC_BITFIELD_TYPE_MATTERS 1
626
627+//#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_MB_64 ? TImode : DImode)
628 #undef SIZE_TYPE
629-#define SIZE_TYPE "unsigned int"
630+#define SIZE_TYPE (TARGET_MB_64 ? "long unsigned int" : "unsigned int")
631
632 #undef PTRDIFF_TYPE
633-#define PTRDIFF_TYPE "int"
634+#define PTRDIFF_TYPE (TARGET_MB_64 ? "long int" : "int")
635+
636+/*#undef INTPTR_TYPE
637+#define INTPTR_TYPE (TARGET_MB_64 ? "long int" : "int")*/
638+#undef UINTPTR_TYPE
639+#define UINTPTR_TYPE (TARGET_MB_64 ? "long unsigned int" : "unsigned int")
640
641 #define DATA_ALIGNMENT(TYPE, ALIGN) \
642 ((((ALIGN) < BITS_PER_WORD) \
643@@ -253,12 +265,12 @@ extern enum pipeline_type microblaze_pipe;
644 #define WORD_REGISTER_OPERATIONS 1
645
646 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
647-
648+/*
649 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
650 if (GET_MODE_CLASS (MODE) == MODE_INT \
651- && GET_MODE_SIZE (MODE) < 4) \
652- (MODE) = SImode;
653-
654+ && GET_MODE_SIZE (MODE) < (TARGET_MB_64 ? 8 : 4)) \
655+ (MODE) = TARGET_MB_64 ? DImode : SImode;
656+*/
657 /* Standard register usage. */
658
659 /* On the MicroBlaze, we have 32 integer registers */
660@@ -438,13 +450,16 @@ extern struct microblaze_frame_info current_frame_info;
661 #define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
662
663 #define ARG_POINTER_CFA_OFFSET(FNDECL) 0
664+#define DWARF_CIE_DATA_ALIGNMENT -1
665
666 #define REG_PARM_STACK_SPACE(FNDECL) (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD)
667
668 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
669
670-#define STACK_BOUNDARY 32
671+#define STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
672
673+#define PREFERRED_STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
674+
675 #define NUM_OF_ARGS 6
676
677 #define GP_RETURN (GP_REG_FIRST + MB_ABI_INT_RETURN_VAL_REGNUM)
678@@ -455,12 +470,15 @@ extern struct microblaze_frame_info current_frame_info;
679 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
680
681 #define LIBCALL_VALUE(MODE) \
682+ gen_rtx_REG (MODE,GP_RETURN)
683+
684+/*#define LIBCALL_VALUE(MODE) \
685 gen_rtx_REG ( \
686 ((GET_MODE_CLASS (MODE) != MODE_INT \
687 || GET_MODE_SIZE (MODE) >= 4) \
688 ? (MODE) \
689 : SImode), GP_RETURN)
690-
691+*/
692 /* 1 if N is a possible register number for a function value.
693 On the MicroBlaze, R2 R3 are the only register thus used.
694 Currently, R2 are only implemented here (C has no complex type) */
695@@ -500,7 +518,7 @@ typedef struct microblaze_args
696 /* 4 insns + 2 words of data. */
697 #define TRAMPOLINE_SIZE (6 * 4)
698
699-#define TRAMPOLINE_ALIGNMENT 32
700+#define TRAMPOLINE_ALIGNMENT 64
701
702 #define REGNO_OK_FOR_BASE_P(regno) microblaze_regno_ok_for_base_p ((regno), 1)
703
704@@ -529,13 +547,13 @@ typedef struct microblaze_args
705 addresses which require two reload registers. */
706 #define LEGITIMATE_PIC_OPERAND_P(X) microblaze_legitimate_pic_operand (X)
707
708-#define CASE_VECTOR_MODE (SImode)
709+#define CASE_VECTOR_MODE (TARGET_MB_64? DImode:SImode)
710
711 #ifndef DEFAULT_SIGNED_CHAR
712 #define DEFAULT_SIGNED_CHAR 1
713 #endif
714
715-#define MOVE_MAX 4
716+#define MOVE_MAX (TARGET_MB_64 ? 8 : 4)
717 #define MAX_MOVE_MAX 8
718
719 #define SLOW_BYTE_ACCESS 1
720@@ -545,7 +563,7 @@ typedef struct microblaze_args
721
722 #define SHIFT_COUNT_TRUNCATED 1
723
724-#define Pmode SImode
725+#define Pmode (TARGET_MB_64? DImode:SImode)
726
727 #define FUNCTION_MODE SImode
728
729@@ -707,6 +725,7 @@ do { \
730
731 #undef TARGET_ASM_OUTPUT_IDENT
732 #define TARGET_ASM_OUTPUT_IDENT microblaze_asm_output_ident
733+//#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
734
735 /* Default to -G 8 */
736 #ifndef MICROBLAZE_DEFAULT_GVALUE
737diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
738index 40711fe224b..c99150ff0da 100644
739--- a/gcc/config/microblaze/microblaze.md
740+++ b/gcc/config/microblaze/microblaze.md
741@@ -26,6 +26,7 @@
742 ;; Constants
743 ;;----------------------------------------------------
744 (define_constants [
745+ (R_Z 0) ;; For reg r0
746 (R_SP 1) ;; Stack pointer reg
747 (R_SR 15) ;; Sub-routine return addr reg
748 (R_IR 14) ;; Interrupt return addr reg
749@@ -541,6 +542,7 @@
750
751 ;; Add 2 SImode integers [ src1 = reg ; src2 = arith ; dest = reg ]
752 ;; Leave carry as is
753+
754 (define_insn "addsi3"
755 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
756 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%dJ,dJ,dJ")
757@@ -562,23 +564,38 @@
758
759 ;; Adding 2 DI operands in register or reg/imm
760
761-(define_insn "adddi3_long"
762+(define_expand "adddi3"
763+ [(set (match_operand:DI 0 "register_operand" "")
764+ (plus:DI (match_operand:DI 1 "register_operand" "")
765+ (match_operand:DI 2 "arith_plus_operand" "")))]
766+""
767+{
768+ if (TARGET_MB_64)
769+ {
770+ if (GET_CODE (operands[2]) == CONST_INT &&
771+ INTVAL(operands[2]) < (long)-549755813888 &&
772+ INTVAL(operands[2]) > (long)549755813887)
773+ FAIL;
774+ }
775+})
776+
777+(define_insn "*adddi3_long"
778 [(set (match_operand:DI 0 "register_operand" "=d,d")
779- (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%dJ,dJ")
780+ (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
781 (match_operand:DI 2 "arith_plus_operand" "d,K")))]
782 "TARGET_MB_64"
783 "@
784- addlk\t%0,%z1,%2
785- addlik\t%0,%z1,%2"
786- [(set_attr "type" "arith,arith")
787- (set_attr "mode" "DI,DI")
788+ addlk\t%0,%1,%2
789+ addlik\t%0,%1,%2 #N10"
790+ [(set_attr "type" "darith,no_delay_arith")
791+ (set_attr "mode" "DI")
792 (set_attr "length" "4,4")])
793
794-(define_insn "adddi3"
795+(define_insn "*adddi3_all"
796 [(set (match_operand:DI 0 "register_operand" "=d,d")
797 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
798 (match_operand:DI 2 "arith_operand" "d,i")))]
799- ""
800+ "!TARGET_MB_64"
801 "@
802 add\t%L0,%L1,%L2\;addc\t%M0,%M1,%M2
803 addi\t%L0,%L1,%j2\;addic\t%M0,%M1,%h2"
804@@ -605,7 +622,7 @@
805 (define_insn "iprefetch"
806 [(unspec [(match_operand:SI 0 "const_int_operand" "n")] UNSPEC_IPREFETCH)
807 (clobber (mem:BLK (scratch)))]
808- "TARGET_PREFETCH"
809+ "TARGET_PREFETCH && !TARGET_MB_64"
810 {
811 operands[2] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
812 return "mfs\t%2,rpc\n\twic\t%2,r0";
813@@ -618,23 +635,33 @@
814 ;; Double Precision Subtraction
815 ;;----------------------------------------------------------------
816
817-(define_insn "subdi3_long"
818- [(set (match_operand:DI 0 "register_operand" "=d,d")
819- (minus:DI (match_operand:DI 1 "register_operand" "d,d")
820- (match_operand:DI 2 "register_operand" "d,n")))]
821+(define_expand "subdi3"
822+ [(set (match_operand:DI 0 "register_operand" "")
823+ (minus:DI (match_operand:DI 1 "register_operand" "")
824+ (match_operand:DI 2 "arith_operand" "")))]
825+""
826+"
827+{
828+}")
829+
830+(define_insn "subsidi3"
831+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
832+ (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
833+ (match_operand:DI 2 "arith_operand" "d,K,n")))]
834 "TARGET_MB_64"
835 "@
836 rsubl\t%0,%2,%1
837- addlik\t%0,%z1,-%2"
838- [(set_attr "type" "darith")
839- (set_attr "mode" "DI,DI")
840- (set_attr "length" "4,4")])
841+ addik\t%0,%z1,-%2
842+ addik\t%0,%z1,-%2"
843+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
844+ (set_attr "mode" "DI")
845+ (set_attr "length" "4,4,4")])
846
847-(define_insn "subdi3"
848+(define_insn "subdi3_small"
849 [(set (match_operand:DI 0 "register_operand" "=&d")
850 (minus:DI (match_operand:DI 1 "register_operand" "d")
851 (match_operand:DI 2 "register_operand" "d")))]
852- ""
853+ "!TARGET_MB_64"
854 "rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1"
855 [(set_attr "type" "darith")
856 (set_attr "mode" "DI")
857@@ -663,7 +690,7 @@
858 (mult:DI
859 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
860 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
861- "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH"
862+ "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH && !TARGET_MB_64"
863 "mul\t%L0,%1,%2\;mulh\t%M0,%1,%2"
864 [(set_attr "type" "no_delay_arith")
865 (set_attr "mode" "DI")
866@@ -674,7 +701,7 @@
867 (mult:DI
868 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
869 (zero_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\;mulhu\t%M0,%1,%2"
873 [(set_attr "type" "no_delay_arith")
874 (set_attr "mode" "DI")
875@@ -685,7 +712,7 @@
876 (mult:DI
877 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
878 (sign_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\;mulhsu\t%M0,%2,%1"
882 [(set_attr "type" "no_delay_arith")
883 (set_attr "mode" "DI")
884@@ -789,7 +816,7 @@
885 (match_operand:SI 4 "arith_operand")])
886 (label_ref (match_operand 5))
887 (pc)))]
888- "TARGET_HARD_FLOAT"
889+ "TARGET_HARD_FLOAT && !TARGET_MB_64"
890 [(set (match_dup 1) (match_dup 3))]
891
892 {
893@@ -819,6 +846,15 @@
894 (set_attr "mode" "SI")
895 (set_attr "length" "4")])
896
897+(define_insn "negsi_long"
898+ [(set (match_operand:SI 0 "register_operand" "=d")
899+ (neg:SI (match_operand:DI 1 "register_operand" "d")))]
900+ ""
901+ "rsubk\t%0,%1,r0"
902+ [(set_attr "type" "arith")
903+ (set_attr "mode" "SI")
904+ (set_attr "length" "4")])
905+
906 (define_insn "negdi2_long"
907 [(set (match_operand:DI 0 "register_operand" "=d")
908 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
909@@ -847,16 +883,24 @@
910 (set_attr "mode" "SI")
911 (set_attr "length" "4")])
912
913-(define_insn "one_cmpldi2_long"
914+(define_expand "one_cmpldi2"
915+ [(set (match_operand:DI 0 "register_operand" "")
916+ (not:DI (match_operand:DI 1 "register_operand" "")))]
917+ ""
918+ "
919+{
920+}")
921+
922+(define_insn ""
923 [(set (match_operand:DI 0 "register_operand" "=d")
924- (not:DI (match_operand:DI 1 "register_operand" "d")))]
925+ (not:DI (match_operand:DI 1 "arith_operand" "d")))]
926 "TARGET_MB_64"
927 "xorli\t%0,%1,-1"
928- [(set_attr "type" "arith")
929+ [(set_attr "type" "no_delay_arith")
930 (set_attr "mode" "DI")
931 (set_attr "length" "4")])
932
933-(define_insn "*one_cmpldi2"
934+(define_insn ""
935 [(set (match_operand:DI 0 "register_operand" "=d")
936 (not:DI (match_operand:DI 1 "register_operand" "d")))]
937 ""
938@@ -871,7 +915,8 @@
939 (not:DI (match_operand:DI 1 "register_operand" "")))]
940 "reload_completed
941 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
942- && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
943+ && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
944+ && !TARGET_MB_64"
945
946 [(set (subreg:SI (match_dup 0) 0) (not:SI (subreg:SI (match_dup 1) 0)))
947 (set (subreg:SI (match_dup 0) 4) (not:SI (subreg:SI (match_dup 1) 4)))]
948@@ -883,18 +928,17 @@
949 ;;----------------------------------------------------------------
950
951 (define_insn "anddi3"
952- [(set (match_operand:DI 0 "register_operand" "=d,d")
953- (and:DI (match_operand:DI 1 "arith_operand" "d,d")
954- (match_operand:DI 2 "arith_operand" "d,K")))]
955+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
956+ (and:DI (match_operand:DI 1 "arith_operand" "d,d,d")
957+ (match_operand:DI 2 "arith_operand" "d,K,I")))]
958 "TARGET_MB_64"
959 "@
960 andl\t%0,%1,%2
961- andli\t%0,%1,%2 #andl1"
962- ;; andli\t%0,%1,%2 #andl3
963- ;; andli\t%0,%1,%2 #andl2
964- [(set_attr "type" "arith,arith")
965- (set_attr "mode" "DI,DI")
966- (set_attr "length" "4,4")])
967+ andli\t%0,%1,%2 #andl2
968+ andli\t%0,%1,%2 #andl3"
969+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
970+ (set_attr "mode" "DI,DI,DI")
971+ (set_attr "length" "4,4,4")])
972
973 (define_insn "andsi3"
974 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
975@@ -919,7 +963,7 @@
976 "@
977 orl\t%0,%1,%2
978 orli\t%0,%1,%2 #andl1"
979- [(set_attr "type" "arith,arith")
980+ [(set_attr "type" "arith,no_delay_arith")
981 (set_attr "mode" "DI,DI")
982 (set_attr "length" "4,4")])
983
984@@ -945,7 +989,7 @@
985 "@
986 xorl\t%0,%1,%2
987 xorli\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@@ -1018,26 +1062,6 @@
994 (set_attr "mode" "SI")
995 (set_attr "length" "4")])
996
997-;;(define_expand "extendqidi2"
998-;; [(set (match_operand:DI 0 "register_operand" "=d")
999-;; (sign_extend:DI (match_operand:QI 1 "general_operand" "d")))]
1000-;; "TARGET_MB_64"
1001-;; {
1002-;; if (GET_CODE (operands[1]) != REG)
1003-;; FAIL;
1004-;; }
1005-;;)
1006-
1007-
1008-;;(define_insn "extendqidi2"
1009-;; [(set (match_operand:DI 0 "register_operand" "=d")
1010-;; (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
1011-;; "TARGET_MB_64"
1012-;; "sextl8\t%0,%1"
1013-;; [(set_attr "type" "arith")
1014-;; (set_attr "mode" "DI")
1015-;; (set_attr "length" "4")])
1016-
1017 (define_insn "extendhisi2"
1018 [(set (match_operand:SI 0 "register_operand" "=d")
1019 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
1020@@ -1060,6 +1084,27 @@
1021 ;; Those for integer source operand are ordered
1022 ;; widest source type first.
1023
1024+(define_insn "extendsidi2_long"
1025+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1026+ (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
1027+ "TARGET_MB_64"
1028+ {
1029+ switch (which_alternative)
1030+ {
1031+ case 0:
1032+ return "sextl32\t%0,%1";
1033+ case 1:
1034+ case 2:
1035+ {
1036+ output_asm_insn ("ll%i1\t%0,%1", operands);
1037+ return "sextl32\t%0,%0";
1038+ }
1039+ }
1040+ }
1041+ [(set_attr "type" "multi,multi,multi")
1042+ (set_attr "mode" "DI")
1043+ (set_attr "length" "4,8,8")])
1044+
1045 (define_insn "extendsidi2"
1046 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1047 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
1048@@ -1088,69 +1133,118 @@
1049 ;; Unlike most other insns, the move insns can't be split with
1050 ;; different predicates, because register spilling and other parts of
1051 ;; the compiler, have memoized the insn number already.
1052+;; //}
1053
1054 (define_expand "movdi"
1055 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1056 (match_operand:DI 1 "general_operand" ""))]
1057 ""
1058 {
1059- /* If operands[1] is a constant address illegal for pic, then we need to
1060- handle it just like microblaze_legitimize_address does. */
1061- if (flag_pic && pic_address_needs_scratch (operands[1]))
1062+ if (TARGET_MB_64)
1063 {
1064+ if (microblaze_expand_move (DImode, operands)) DONE;
1065+ }
1066+ else
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+ {
1072 rtx temp = force_reg (DImode, XEXP (XEXP (operands[1], 0), 0));
1073 rtx temp2 = XEXP (XEXP (operands[1], 0), 1);
1074 emit_move_insn (operands[0], gen_rtx_PLUS (DImode, temp, temp2));
1075 DONE;
1076- }
1077-
1078-
1079- if ((reload_in_progress | reload_completed) == 0
1080- && !register_operand (operands[0], DImode)
1081- && !register_operand (operands[1], DImode)
1082- && (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
1083- && operands[1] != CONST0_RTX (DImode))))
1084- {
1085+ }
1086
1087- rtx temp = force_reg (DImode, operands[1]);
1088- emit_move_insn (operands[0], temp);
1089- DONE;
1090+ if ((reload_in_progress | reload_completed) == 0
1091+ && !register_operand (operands[0], DImode)
1092+ && !register_operand (operands[1], DImode)
1093+ && (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
1094+ && operands[1] != CONST0_RTX (DImode))))
1095+ {
1096+ rtx temp = force_reg (DImode, operands[1]);
1097+ emit_move_insn (operands[0], temp);
1098+ DONE;
1099+ }
1100 }
1101 }
1102 )
1103
1104+;; Added for status registers
1105+(define_insn "movdi_status"
1106+ [(set (match_operand:DI 0 "register_operand" "=d,d,z")
1107+ (match_operand:DI 1 "register_operand" "z,d,d"))]
1108+ "microblaze_is_interrupt_variant () && TARGET_MB_64"
1109+ "@
1110+ mfs\t%0,%1 #mfs
1111+ addlk\t%0,%1,r0 #add movdi
1112+ mts\t%0,%1 #mts"
1113+ [(set_attr "type" "move")
1114+ (set_attr "mode" "DI")
1115+ (set_attr "length" "12")])
1116+
1117+;; This move will be not be moved to delay slot.
1118+(define_insn "*movdi_internal3"
1119+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d")
1120+ (match_operand:DI 1 "immediate_operand" "J,I,Mnis"))]
1121+ "TARGET_MB_64 && (register_operand (operands[0], DImode) &&
1122+ (GET_CODE (operands[1]) == CONST_INT &&
1123+ (INTVAL (operands[1]) <= (long)549755813887 && INTVAL (operands[1]) >= (long)-549755813888)))"
1124+ "@
1125+ addlk\t%0,r0,r0\t
1126+ addlik\t%0,r0,%1\t #N1 %X1
1127+ addlik\t%0,r0,%1\t #N2 %X1"
1128+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
1129+ (set_attr "mode" "DI")
1130+ (set_attr "length" "4")])
1131
1132-(define_insn "*movdi_internal_64"
1133- [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
1134- (match_operand:DI 1 "general_operand" " d,K,J,R,o,d,d"))]
1135- "TARGET_MB_64 && (INTVAL(operands[1]) < 0x7fffffffff) && (INTVAL(operands[1]) > 0xffffff8000000000)"
1136+;; This move may be used for PLT label operand
1137+(define_insn "*movdi_internal5_pltop"
1138+ [(set (match_operand:DI 0 "register_operand" "=d,d")
1139+ (match_operand:DI 1 "call_insn_operand" ""))]
1140+ "TARGET_MB_64 && (register_operand (operands[0], Pmode) &&
1141+ PLT_ADDR_P (operands[1]))"
1142+ {
1143+ gcc_unreachable ();
1144+ }
1145+ [(set_attr "type" "load")
1146+ (set_attr "mode" "DI")
1147+ (set_attr "length" "4")])
1148+
1149+(define_insn "*movdi_internal2"
1150+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
1151+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
1152+ "TARGET_MB_64"
1153 {
1154 switch (which_alternative)
1155 {
1156 case 0:
1157- return "addlk\t%0,%1";
1158- case 1:
1159- return "addlik\t%0,r0,%1";
1160- case 2:
1161- return "addlk\t%0,r0,r0";
1162- case 3:
1163- case 4:
1164- return "lli\t%0,%1";
1165- case 5:
1166- case 6:
1167- return "sli\t%1,%0";
1168- }
1169- return "unreachable";
1170- }
1171- [(set_attr "type" "no_delay_move,no_delay_arith,no_delay_arith,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
1172+ return "addlk\t%0,%1,r0";
1173+ case 1:
1174+ case 2:
1175+ if (GET_CODE (operands[1]) == CONST_INT &&
1176+ (INTVAL (operands[1]) > (long)549755813887 || INTVAL (operands[1]) < (long)-549755813888))
1177+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
1178+ else
1179+ return "addlik\t%0,r0,%1";
1180+ case 3:
1181+ case 4:
1182+ return "ll%i1\t%0,%1";
1183+ case 5:
1184+ case 6:
1185+ return "sl%i0\t%z1,%0";
1186+ }
1187+ }
1188+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
1189 (set_attr "mode" "DI")
1190- (set_attr "length" "8,8,8,8,12,8,12")])
1191+ (set_attr "length" "4,4,12,4,8,4,8")])
1192+
1193
1194
1195 (define_insn "*movdi_internal"
1196 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
1197 (match_operand:DI 1 "general_operand" " d,i,J,R,o,d,d"))]
1198- ""
1199+ "!TARGET_MB_64"
1200 {
1201 switch (which_alternative)
1202 {
1203@@ -1182,7 +1276,8 @@
1204 "reload_completed
1205 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1206 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1207- && (REGNO(operands[0]) == (REGNO(operands[1]) + 1))"
1208+ && (REGNO(operands[0]) == (REGNO(operands[1]) + 1))
1209+ && !(TARGET_MB_64)"
1210
1211 [(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))
1212 (set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))]
1213@@ -1194,12 +1289,22 @@
1214 "reload_completed
1215 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1216 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1217- && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))"
1218+ && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))
1219+ && !(TARGET_MB_64)"
1220
1221 [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1222 (set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))]
1223 "")
1224
1225+(define_insn "movdi_long_int"
1226+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1227+ (match_operand:DI 1 "general_operand" "i"))]
1228+ ""
1229+ "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
1230+ [(set_attr "type" "no_delay_arith")
1231+ (set_attr "mode" "DI")
1232+ (set_attr "length" "12")])
1233+
1234 ;; Unlike most other insns, the move insns can't be split with
1235 ;; different predicates, because register spilling and other parts of
1236 ;; the compiler, have memoized the insn number already.
1237@@ -1271,6 +1376,8 @@
1238 (set_attr "length" "4,4,8,4,8,4,8")])
1239
1240
1241+
1242+
1243 ;; 16-bit Integer moves
1244
1245 ;; Unlike most other insns, the move insns can't be split with
1246@@ -1303,8 +1410,8 @@
1247 "@
1248 addik\t%0,r0,%1\t# %X1
1249 addk\t%0,%1,r0
1250- lhui\t%0,%1
1251- lhui\t%0,%1
1252+ lhu%i1\t%0,%1
1253+ lhu%i1\t%0,%1
1254 sh%i0\t%z1,%0
1255 sh%i0\t%z1,%0"
1256 [(set_attr "type" "arith,move,load,no_delay_load,store,no_delay_store")
1257@@ -1347,7 +1454,7 @@
1258 lbu%i1\t%0,%1
1259 lbu%i1\t%0,%1
1260 sb%i0\t%z1,%0
1261- sbi\t%z1,%0"
1262+ sb%i0\t%z1,%0"
1263 [(set_attr "type" "arith,arith,move,load,no_delay_load,store,no_delay_store")
1264 (set_attr "mode" "QI")
1265 (set_attr "length" "4,4,8,4,8,4,8")])
1266@@ -1420,7 +1527,7 @@
1267 addik\t%0,r0,%F1
1268 lw%i1\t%0,%1
1269 sw%i0\t%z1,%0
1270- swi\t%z1,%0"
1271+ sw%i0\t%z1,%0"
1272 [(set_attr "type" "move,no_delay_load,load,no_delay_load,no_delay_load,store,no_delay_store")
1273 (set_attr "mode" "SF")
1274 (set_attr "length" "4,4,4,4,4,4,4")])
1275@@ -1459,6 +1566,33 @@
1276 ;; movdf_internal
1277 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
1278 ;;
1279+(define_insn "*movdf_internal_64"
1280+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
1281+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
1282+ "TARGET_MB_64"
1283+ {
1284+ switch (which_alternative)
1285+ {
1286+ case 0:
1287+ return "addlk\t%0,%1,r0";
1288+ case 1:
1289+ return "addlk\t%0,r0,r0";
1290+ case 2:
1291+ case 4:
1292+ return "ll%i1\t%0,%1";
1293+ case 3:
1294+ {
1295+ return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
1296+ }
1297+ case 5:
1298+ return "sl%i0\t%1,%0";
1299+ }
1300+ gcc_unreachable ();
1301+ }
1302+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
1303+ (set_attr "mode" "DF")
1304+ (set_attr "length" "4,4,4,16,4,4")])
1305+
1306 (define_insn "*movdf_internal"
1307 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,o")
1308 (match_operand:DF 1 "general_operand" "dG,o,F,T,d"))]
1309@@ -1493,7 +1627,8 @@
1310 "reload_completed
1311 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1312 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1313- && (REGNO (operands[0]) == (REGNO (operands[1]) + 1))"
1314+ && (REGNO (operands[0]) == (REGNO (operands[1]) + 1))
1315+ && !TARGET_MB_64"
1316 [(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))
1317 (set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))]
1318 "")
1319@@ -1504,7 +1639,8 @@
1320 "reload_completed
1321 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1322 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1323- && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))"
1324+ && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))
1325+ && !TARGET_MB_64"
1326 [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1327 (set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))]
1328 "")
1329@@ -2003,6 +2139,31 @@ else
1330 "
1331 )
1332
1333+
1334+(define_insn "seq_internal_pat_long"
1335+ [(set (match_operand:DI 0 "register_operand" "=d")
1336+ (eq:DI
1337+ (match_operand:DI 1 "register_operand" "d")
1338+ (match_operand:DI 2 "register_operand" "d")))]
1339+ "TARGET_MB_64"
1340+ "pcmpleq\t%0,%1,%2"
1341+ [(set_attr "type" "arith")
1342+ (set_attr "mode" "DI")
1343+ (set_attr "length" "4")]
1344+)
1345+
1346+(define_insn "sne_internal_pat_long"
1347+ [(set (match_operand:DI 0 "register_operand" "=d")
1348+ (ne:DI
1349+ (match_operand:DI 1 "register_operand" "d")
1350+ (match_operand:DI 2 "register_operand" "d")))]
1351+ "TARGET_MB_64"
1352+ "pcmplne\t%0,%1,%2"
1353+ [(set_attr "type" "arith")
1354+ (set_attr "mode" "DI")
1355+ (set_attr "length" "4")]
1356+)
1357+
1358 (define_insn "seq_internal_pat"
1359 [(set (match_operand:SI 0 "register_operand" "=d")
1360 (eq:SI
1361@@ -2063,8 +2224,8 @@ else
1362 (define_expand "cbranchsi4"
1363 [(set (pc)
1364 (if_then_else (match_operator 0 "ordered_comparison_operator"
1365- [(match_operand:SI 1 "register_operand")
1366- (match_operand:SI 2 "arith_operand" "I,i")])
1367+ [(match_operand 1 "register_operand")
1368+ (match_operand 2 "arith_operand" "I,i")])
1369 (label_ref (match_operand 3 ""))
1370 (pc)))]
1371 ""
1372@@ -2076,13 +2237,13 @@ else
1373 (define_expand "cbranchsi4_reg"
1374 [(set (pc)
1375 (if_then_else (match_operator 0 "ordered_comparison_operator"
1376- [(match_operand:SI 1 "register_operand")
1377- (match_operand:SI 2 "register_operand")])
1378+ [(match_operand 1 "register_operand")
1379+ (match_operand 2 "register_operand")])
1380 (label_ref (match_operand 3 ""))
1381 (pc)))]
1382 ""
1383 {
1384- microblaze_expand_conditional_branch_reg (SImode, operands);
1385+ microblaze_expand_conditional_branch_reg (Pmode, operands);
1386 DONE;
1387 })
1388
1389@@ -2107,6 +2268,26 @@ else
1390 (label_ref (match_operand 1))
1391 (pc)))])
1392
1393+(define_insn "branch_zero64"
1394+ [(set (pc)
1395+ (if_then_else (match_operator 0 "ordered_comparison_operator"
1396+ [(match_operand 1 "register_operand" "d")
1397+ (const_int 0)])
1398+ (match_operand 2 "pc_or_label_operand" "")
1399+ (match_operand 3 "pc_or_label_operand" "")))
1400+ ]
1401+ "TARGET_MB_64"
1402+ {
1403+ if (operands[3] == pc_rtx)
1404+ return "bea%C0i%?\t%z1,%2";
1405+ else
1406+ return "bea%N0i%?\t%z1,%3";
1407+ }
1408+ [(set_attr "type" "branch")
1409+ (set_attr "mode" "none")
1410+ (set_attr "length" "4")]
1411+)
1412+
1413 (define_insn "branch_zero"
1414 [(set (pc)
1415 (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
1416@@ -2127,6 +2308,47 @@ else
1417 (set_attr "length" "4")]
1418 )
1419
1420+(define_insn "branch_compare64"
1421+ [(set (pc)
1422+ (if_then_else (match_operator 0 "cmp_op"
1423+ [(match_operand 1 "register_operand" "d")
1424+ (match_operand 2 "register_operand" "d")
1425+ ])
1426+ (label_ref (match_operand 3))
1427+ (pc)))
1428+ (clobber(reg:SI R_TMP))]
1429+ "TARGET_MB_64"
1430+ {
1431+ operands[4] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
1432+ enum rtx_code code = GET_CODE (operands[0]);
1433+
1434+ if (code == GT || code == LE)
1435+ {
1436+ output_asm_insn ("cmp\tr18,%z1,%z2", operands);
1437+ code = swap_condition (code);
1438+ }
1439+ else if (code == GTU || code == LEU)
1440+ {
1441+ output_asm_insn ("cmpu\tr18,%z1,%z2", operands);
1442+ code = swap_condition (code);
1443+ }
1444+ else if (code == GE || code == LT)
1445+ {
1446+ output_asm_insn ("cmp\tr18,%z2,%z1", operands);
1447+ }
1448+ else if (code == GEU || code == LTU)
1449+ {
1450+ output_asm_insn ("cmpu\tr18,%z2,%z1", operands);
1451+ }
1452+
1453+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), SImode, operands[4], const0_rtx);
1454+ return "bea%C0i%?\tr18,%3";
1455+ }
1456+ [(set_attr "type" "branch")
1457+ (set_attr "mode" "none")
1458+ (set_attr "length" "12")]
1459+)
1460+
1461 (define_insn "branch_compare"
1462 [(set (pc)
1463 (if_then_else (match_operator:SI 0 "cmp_op"
1464@@ -2310,7 +2532,7 @@ else
1465 ;; Indirect jumps. Jump to register values. Assuming absolute jumps
1466
1467 (define_insn "indirect_jump_internal1"
1468- [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
1469+ [(set (pc) (match_operand 0 "register_operand" "d"))]
1470 ""
1471 "bra%?\t%0"
1472 [(set_attr "type" "jump")
1473@@ -2323,7 +2545,7 @@ else
1474 (use (label_ref (match_operand 1 "" "")))]
1475 ""
1476 {
1477- gcc_assert (GET_MODE (operands[0]) == Pmode);
1478+ //gcc_assert (GET_MODE (operands[0]) == Pmode);
1479
1480 if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
1481 emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
1482@@ -2335,7 +2557,7 @@ else
1483
1484 (define_insn "tablejump_internal1"
1485 [(set (pc)
1486- (match_operand:SI 0 "register_operand" "d"))
1487+ (match_operand 0 "register_operand" "d"))
1488 (use (label_ref (match_operand 1 "" "")))]
1489 ""
1490 "bra%?\t%0 "
1491@@ -2345,9 +2567,9 @@ else
1492
1493 (define_expand "tablejump_internal3"
1494 [(parallel [(set (pc)
1495- (plus:SI (match_operand:SI 0 "register_operand" "d")
1496- (label_ref:SI (match_operand:SI 1 "" ""))))
1497- (use (label_ref:SI (match_dup 1)))])]
1498+ (plus (match_operand 0 "register_operand" "d")
1499+ (label_ref (match_operand:SI 1 "" ""))))
1500+ (use (label_ref (match_dup 1)))])]
1501 ""
1502 ""
1503 )
1504@@ -2408,7 +2630,7 @@ else
1505 (minus (reg 1) (match_operand 1 "register_operand" "")))
1506 (set (reg 1)
1507 (minus (reg 1) (match_dup 1)))]
1508- ""
1509+ "!TARGET_MB_64"
1510 {
1511 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1512 rtx reg = gen_reg_rtx (Pmode);
1513@@ -2433,7 +2655,7 @@ else
1514 (define_expand "save_stack_block"
1515 [(match_operand 0 "register_operand" "")
1516 (match_operand 1 "register_operand" "")]
1517- ""
1518+ "!TARGET_MB_64"
1519 {
1520 emit_move_insn (operands[0], operands[1]);
1521 DONE;
1522@@ -2443,7 +2665,7 @@ else
1523 (define_expand "restore_stack_block"
1524 [(match_operand 0 "register_operand" "")
1525 (match_operand 1 "register_operand" "")]
1526- ""
1527+ "!TARGET_MB_64"
1528 {
1529 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1530 rtx rtmp = gen_rtx_REG (SImode, R_TMP);
1531@@ -2490,7 +2712,7 @@ else
1532
1533 (define_insn "<optab>_internal"
1534 [(any_return)
1535- (use (match_operand:SI 0 "register_operand" ""))]
1536+ (use (match_operand 0 "register_operand" ""))]
1537 ""
1538 {
1539 if (microblaze_is_break_handler ())
1540@@ -2523,7 +2745,7 @@ else
1541 (define_expand "call"
1542 [(parallel [(call (match_operand 0 "memory_operand" "m")
1543 (match_operand 1 "" "i"))
1544- (clobber (reg:SI R_SR))
1545+ (clobber (reg R_SR))
1546 (use (match_operand 2 "" ""))
1547 (use (match_operand 3 "" ""))])]
1548 ""
1549@@ -2544,12 +2766,12 @@ else
1550
1551 if (GET_CODE (XEXP (operands[0], 0)) == UNSPEC)
1552 emit_call_insn (gen_call_internal_plt0 (operands[0], operands[1],
1553- gen_rtx_REG (SImode,
1554+ gen_rtx_REG (Pmode,
1555 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM),
1556 pic_offset_table_rtx));
1557 else
1558 emit_call_insn (gen_call_internal0 (operands[0], operands[1],
1559- gen_rtx_REG (SImode,
1560+ gen_rtx_REG (Pmode,
1561 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)));
1562
1563 DONE;
1564@@ -2559,7 +2781,7 @@ else
1565 (define_expand "call_internal0"
1566 [(parallel [(call (match_operand 0 "" "")
1567 (match_operand 1 "" ""))
1568- (clobber (match_operand:SI 2 "" ""))])]
1569+ (clobber (match_operand 2 "" ""))])]
1570 ""
1571 {
1572 }
1573@@ -2568,18 +2790,34 @@ else
1574 (define_expand "call_internal_plt0"
1575 [(parallel [(call (match_operand 0 "" "")
1576 (match_operand 1 "" ""))
1577- (clobber (match_operand:SI 2 "" ""))
1578- (use (match_operand:SI 3 "" ""))])]
1579+ (clobber (match_operand 2 "" ""))
1580+ (use (match_operand 3 "" ""))])]
1581 ""
1582 {
1583 }
1584 )
1585
1586+(define_insn "call_internal_plt_64"
1587+ [(call (mem (match_operand 0 "call_insn_plt_operand" ""))
1588+ (match_operand 1 "" "i"))
1589+ (clobber (reg R_SR))
1590+ (use (reg R_GOT))]
1591+ "flag_pic && TARGET_MB_64"
1592+ {
1593+ register rtx target2 = gen_rtx_REG (Pmode,
1594+ GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1595+ gen_rtx_CLOBBER (VOIDmode, target2);
1596+ return "brealid\tr15,%0\;%#";
1597+ }
1598+ [(set_attr "type" "call")
1599+ (set_attr "mode" "none")
1600+ (set_attr "length" "4")])
1601+
1602 (define_insn "call_internal_plt"
1603- [(call (mem (match_operand:SI 0 "call_insn_plt_operand" ""))
1604- (match_operand:SI 1 "" "i"))
1605- (clobber (reg:SI R_SR))
1606- (use (reg:SI R_GOT))]
1607+ [(call (mem (match_operand 0 "call_insn_plt_operand" ""))
1608+ (match_operand 1 "" "i"))
1609+ (clobber (reg R_SR))
1610+ (use (reg R_GOT))]
1611 "flag_pic"
1612 {
1613 rtx target2
1614@@ -2591,10 +2829,41 @@ else
1615 (set_attr "mode" "none")
1616 (set_attr "length" "4")])
1617
1618+(define_insn "call_internal1_64"
1619+ [(call (mem (match_operand:VOID 0 "call_insn_simple_operand" "ri"))
1620+ (match_operand 1 "" "i"))
1621+ (clobber (reg R_SR))]
1622+ "TARGET_MB_64"
1623+ {
1624+ register rtx target = operands[0];
1625+ register rtx target2 = gen_rtx_REG (Pmode,
1626+ GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1627+ if (GET_CODE (target) == SYMBOL_REF) {
1628+ if (microblaze_break_function_p (SYMBOL_REF_DECL (target))) {
1629+ gen_rtx_CLOBBER (VOIDmode, target2);
1630+ return "breaki\tr16,%0\;%#";
1631+ }
1632+ else {
1633+ gen_rtx_CLOBBER (VOIDmode, target2);
1634+ return "brealid\tr15,%0\;%#";
1635+ }
1636+ } else if (GET_CODE (target) == CONST_INT)
1637+ return "la\t%@,r0,%0\;brald\tr15,%@\;%#";
1638+ else if (GET_CODE (target) == REG)
1639+ return "brald\tr15,%0\;%#";
1640+ else {
1641+ fprintf (stderr,"Unsupported call insn\n");
1642+ return NULL;
1643+ }
1644+ }
1645+ [(set_attr "type" "call")
1646+ (set_attr "mode" "none")
1647+ (set_attr "length" "4")])
1648+
1649 (define_insn "call_internal1"
1650 [(call (mem (match_operand:VOID 0 "call_insn_simple_operand" "ri"))
1651- (match_operand:SI 1 "" "i"))
1652- (clobber (reg:SI R_SR))]
1653+ (match_operand 1 "" "i"))
1654+ (clobber (reg R_SR))]
1655 ""
1656 {
1657 rtx target = operands[0];
1658@@ -2628,7 +2897,7 @@ else
1659 [(parallel [(set (match_operand 0 "register_operand" "=d")
1660 (call (match_operand 1 "memory_operand" "m")
1661 (match_operand 2 "" "i")))
1662- (clobber (reg:SI R_SR))
1663+ (clobber (reg R_SR))
1664 (use (match_operand 3 "" ""))])] ;; next_arg_reg
1665 ""
1666 {
1667@@ -2649,13 +2918,13 @@ else
1668 if (GET_CODE (XEXP (operands[1], 0)) == UNSPEC)
1669 emit_call_insn (gen_call_value_intern_plt0 (operands[0], operands[1],
1670 operands[2],
1671- gen_rtx_REG (SImode,
1672+ gen_rtx_REG (Pmode,
1673 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM),
1674 pic_offset_table_rtx));
1675 else
1676 emit_call_insn (gen_call_value_internal (operands[0], operands[1],
1677 operands[2],
1678- gen_rtx_REG (SImode,
1679+ gen_rtx_REG (Pmode,
1680 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)));
1681
1682 DONE;
1683@@ -2667,7 +2936,7 @@ else
1684 [(parallel [(set (match_operand 0 "" "")
1685 (call (match_operand 1 "" "")
1686 (match_operand 2 "" "")))
1687- (clobber (match_operand:SI 3 "" ""))
1688+ (clobber (match_operand 3 "" ""))
1689 ])]
1690 ""
1691 {}
1692@@ -2677,18 +2946,35 @@ else
1693 [(parallel[(set (match_operand 0 "" "")
1694 (call (match_operand 1 "" "")
1695 (match_operand 2 "" "")))
1696- (clobber (match_operand:SI 3 "" ""))
1697- (use (match_operand:SI 4 "" ""))])]
1698+ (clobber (match_operand 3 "" ""))
1699+ (use (match_operand 4 "" ""))])]
1700 "flag_pic"
1701 {}
1702 )
1703
1704+(define_insn "call_value_intern_plt_64"
1705+ [(set (match_operand:VOID 0 "register_operand" "=d")
1706+ (call (mem (match_operand 1 "call_insn_plt_operand" ""))
1707+ (match_operand 2 "" "i")))
1708+ (clobber (match_operand 3 "register_operand" "=d"))
1709+ (use (match_operand 4 "register_operand"))]
1710+ "flag_pic && TARGET_MB_64"
1711+ {
1712+ register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1713+
1714+ gen_rtx_CLOBBER (VOIDmode,target2);
1715+ return "brealid\tr15,%1\;%#";
1716+ }
1717+ [(set_attr "type" "call")
1718+ (set_attr "mode" "none")
1719+ (set_attr "length" "4")])
1720+
1721 (define_insn "call_value_intern_plt"
1722 [(set (match_operand:VOID 0 "register_operand" "=d")
1723- (call (mem (match_operand:SI 1 "call_insn_plt_operand" ""))
1724- (match_operand:SI 2 "" "i")))
1725- (clobber (match_operand:SI 3 "register_operand" "=d"))
1726- (use (match_operand:SI 4 "register_operand"))]
1727+ (call (mem (match_operand 1 "call_insn_plt_operand" ""))
1728+ (match_operand 2 "" "i")))
1729+ (clobber (match_operand 3 "register_operand" "=d"))
1730+ (use (match_operand 4 "register_operand"))]
1731 "flag_pic"
1732 {
1733 rtx target2
1734@@ -2701,11 +2987,46 @@ else
1735 (set_attr "mode" "none")
1736 (set_attr "length" "4")])
1737
1738+(define_insn "call_value_intern_64"
1739+ [(set (match_operand:VOID 0 "register_operand" "=d")
1740+ (call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
1741+ (match_operand 2 "" "i")))
1742+ (clobber (match_operand 3 "register_operand" "=d"))]
1743+ "TARGET_MB_64"
1744+ {
1745+ register rtx target = operands[1];
1746+ register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1747+
1748+ if (GET_CODE (target) == SYMBOL_REF)
1749+ {
1750+ gen_rtx_CLOBBER (VOIDmode,target2);
1751+ if (microblaze_break_function_p (SYMBOL_REF_DECL (target)))
1752+ return "breaki\tr16,%1\;%#";
1753+ else if (SYMBOL_REF_FLAGS (target) & SYMBOL_FLAG_FUNCTION)
1754+ {
1755+ return "brealid\tr15,%1\;%#";
1756+ }
1757+ else
1758+ {
1759+ return "bralid\tr15,%1\;%#";
1760+ }
1761+ }
1762+ else if (GET_CODE (target) == CONST_INT)
1763+ return "la\t%@,r0,%1\;brald\tr15,%@\;%#";
1764+ else if (GET_CODE (target) == REG)
1765+ return "brald\tr15,%1\;%#";
1766+ else
1767+ return "Unsupported call insn\n";
1768+ }
1769+ [(set_attr "type" "call")
1770+ (set_attr "mode" "none")
1771+ (set_attr "length" "4")])
1772+
1773 (define_insn "call_value_intern"
1774 [(set (match_operand:VOID 0 "register_operand" "=d")
1775 (call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
1776- (match_operand:SI 2 "" "i")))
1777- (clobber (match_operand:SI 3 "register_operand" "=d"))]
1778+ (match_operand 2 "" "i")))
1779+ (clobber (match_operand 3 "register_operand" "=d"))]
1780 ""
1781 {
1782 rtx target = operands[1];
1783diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
1784index 4c25cfe15e7..965132b3513 100644
1785--- a/gcc/config/microblaze/t-microblaze
1786+++ b/gcc/config/microblaze/t-microblaze
1787@@ -2,7 +2,8 @@ MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-en
1788 MULTILIB_DIRNAMES = bs m mh le m64
1789 MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
1790 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
1791-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64
1792+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian/m64
1793+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64 mxl-multiply-high
1794 MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
1795 MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
1796 MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
1797diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
1798index cbbe32d5f6a..ec797e1bf17 100644
1799--- a/libgcc/config/microblaze/crti.S
1800+++ b/libgcc/config/microblaze/crti.S
1801@@ -40,7 +40,7 @@
1802
1803 .align 2
1804 __init:
1805- addik r1, r1, -8
1806+ addik r1, r1, -16
1807 sw r15, r0, r1
1808 la r11, r0, _stack
1809 mts rshr, r11
1810@@ -51,5 +51,5 @@ __init:
1811 .global __fini
1812 .align 2
1813 __fini:
1814- addik r1, r1, -8
1815+ addik r1, r1, -16
1816 sw r15, r0, r1
1817diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
1818index cb8d8ef2bfa..977b43b9436 100644
1819--- a/libgcc/config/microblaze/crtn.S
1820+++ b/libgcc/config/microblaze/crtn.S
1821@@ -33,9 +33,9 @@
1822 .section .init, "ax"
1823 lw r15, r0, r1
1824 rtsd r15, 8
1825- addik r1, r1, 8
1826+ addik r1, r1, 16
1827
1828 .section .fini, "ax"
1829 lw r15, r0, r1
1830 rtsd r15, 8
1831- addik r1, r1, 8
1832+ addik r1, r1, 16
1833diff --git a/libgcc/config/microblaze/divdi3.S b/libgcc/config/microblaze/divdi3.S
1834new file mode 100644
1835index 00000000000..d37bf5165c6
1836--- /dev/null
1837+++ b/libgcc/config/microblaze/divdi3.S
1838@@ -0,0 +1,98 @@
1839+###################################-
1840+#
1841+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
1842+#
1843+# Contributed by Michael Eager <eager@eagercon.com>.
1844+#
1845+# This file is free software; you can redistribute it and/or modify it
1846+# under the terms of the GNU General Public License as published by the
1847+# Free Software Foundation; either version 3, or (at your option) any
1848+# later version.
1849+#
1850+# GCC is distributed in the hope that it will be useful, but WITHOUT
1851+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1852+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1853+# License for more details.
1854+#
1855+# Under Section 7 of GPL version 3, you are granted additional
1856+# permissions described in the GCC Runtime Library Exception, version
1857+# 3.1, as published by the Free Software Foundation.
1858+#
1859+# You should have received a copy of the GNU General Public License and
1860+# a copy of the GCC Runtime Library Exception along with this program;
1861+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1862+# <http://www.gnu.org/licenses/>.
1863+#
1864+# divdi3.S
1865+#
1866+# Divide operation for 32 bit integers.
1867+# Input : Dividend in Reg r5
1868+# Divisor in Reg r6
1869+# Output: Result in Reg r3
1870+#
1871+#######################################
1872+
1873+#ifdef __arch64__
1874+ .globl __divdi3
1875+ .ent __divdi3
1876+ .type __divdi3,@function
1877+__divdi3:
1878+ .frame r1,0,r15
1879+
1880+ ADDLIK r1,r1,-32
1881+ SLI r28,r1,0
1882+ SLI r29,r1,8
1883+ SLI r30,r1,16
1884+ SLI r31,r1,24
1885+
1886+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
1887+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
1888+ XORL r28,r5,r6 # Get the sign of the result
1889+ BEALGEI r5,$LaR5_Pos
1890+ RSUBLI r5,r5,0 # Make r5 positive
1891+$LaR5_Pos:
1892+ BEALGEI r6,$LaR6_Pos
1893+ RSUBLI r6,r6,0 # Make r6 positive
1894+$LaR6_Pos:
1895+ ADDLIK r30,r0,0 # Clear mod
1896+ ADDLIK r3,r0,0 # clear div
1897+ ADDLIK r29,r0,64 # Initialize the loop count
1898+
1899+ # First part try to find the first '1' in the r5
1900+$LaDIV0:
1901+ BEALLTI r5,$LaDIV2 # This traps r5 == 0x80000000
1902+$LaDIV1:
1903+ ADDL r5,r5,r5 # left shift logical r5
1904+ ADDLIK r29,r29,-1
1905+ BEALGTI r5,$LaDIV1
1906+$LaDIV2:
1907+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
1908+ ADDLC r30,r30,r30 # Move that bit into the Mod register
1909+ RSUBL r31,r6,r30 # Try to subtract (r30 a r6)
1910+ BEALLTI r31,$LaMOD_TOO_SMALL
1911+ ORL r30,r0,r31 # Move the r31 to mod since the result was positive
1912+ ADDLIK r3,r3,1
1913+$LaMOD_TOO_SMALL:
1914+ ADDLIK r29,r29,-1
1915+ BEALEQi r29,$LaLOOP_END
1916+ ADDL r3,r3,r3 # Shift in the '1' into div
1917+ BREAI $LaDIV2 # Div2
1918+$LaLOOP_END:
1919+ BEALGEI r28,$LaRETURN_HERE
1920+ RSUBLI r3,r3,0 # Negate the result
1921+ BREAI $LaRETURN_HERE
1922+$LaDiv_By_Zero:
1923+$LaResult_Is_Zero:
1924+ ORL r3,r0,r0 # set result to 0
1925+$LaRETURN_HERE:
1926+# Restore values of CSRs and that of r3 and the divisor and the dividend
1927+ LLI r28,r1,0
1928+ LLI r29,r1,8
1929+ LLI r30,r1,16
1930+ LLI r31,r1,24
1931+ ADDLIK r1,r1,32
1932+ RTSD r15,8
1933+ nop
1934+.end __divdi3
1935+ .size __divdi3, . - __divdi3
1936+#endif
1937diff --git a/libgcc/config/microblaze/divdi3_table.c b/libgcc/config/microblaze/divdi3_table.c
1938new file mode 100644
1939index 00000000000..80962597ea5
1940--- /dev/null
1941+++ b/libgcc/config/microblaze/divdi3_table.c
1942@@ -0,0 +1,62 @@
1943+/* Table for software lookup divide for Xilinx MicroBlaze.
1944+
1945+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
1946+
1947+ Contributed by Michael Eager <eager@eagercon.com>.
1948+
1949+ This file is free software; you can redistribute it and/or modify it
1950+ under the terms of the GNU General Public License as published by the
1951+ Free Software Foundation; either version 3, or (at your option) any
1952+ later version.
1953+
1954+ GCC is distributed in the hope that it will be useful, but WITHOUT
1955+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1956+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1957+ License for more details.
1958+
1959+ Under Section 7 of GPL version 3, you are granted additional
1960+ permissions described in the GCC Runtime Library Exception, version
1961+ 3.1, as published by the Free Software Foundation.
1962+
1963+ You should have received a copy of the GNU General Public License and
1964+ a copy of the GCC Runtime Library Exception along with this program;
1965+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1966+ <http://www.gnu.org/licenses/>. */
1967+
1968+
1969+unsigned char _divdi3_table[] =
1970+{
1971+ 0, 0/1, 0/2, 0/3, 0/4, 0/5, 0/6, 0/7,
1972+ 0/8, 0/9, 0/10, 0/11, 0/12, 0/13, 0/14, 0/15,
1973+ 0, 1/1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7,
1974+ 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15,
1975+ 0, 2/1, 2/2, 2/3, 2/4, 2/5, 2/6, 2/7,
1976+ 2/8, 2/9, 2/10, 2/11, 2/12, 2/13, 2/14, 2/15,
1977+ 0, 3/1, 3/2, 3/3, 3/4, 3/5, 3/6, 3/7,
1978+ 3/8, 3/9, 3/10, 3/11, 3/12, 3/13, 3/14, 3/15,
1979+ 0, 4/1, 4/2, 4/3, 4/4, 4/5, 4/6, 4/7,
1980+ 4/8, 4/9, 4/10, 4/11, 4/12, 4/13, 4/14, 4/15,
1981+ 0, 5/1, 5/2, 5/3, 5/4, 5/5, 5/6, 5/7,
1982+ 5/8, 5/9, 5/10, 5/11, 5/12, 5/13, 5/14, 5/15,
1983+ 0, 6/1, 6/2, 6/3, 6/4, 6/5, 6/6, 6/7,
1984+ 6/8, 6/9, 6/10, 6/11, 6/12, 6/13, 6/14, 6/15,
1985+ 0, 7/1, 7/2, 7/3, 7/4, 7/5, 7/6, 7/7,
1986+ 7/8, 7/9, 7/10, 7/11, 7/12, 7/13, 7/14, 7/15,
1987+ 0, 8/1, 8/2, 8/3, 8/4, 8/5, 8/6, 8/7,
1988+ 8/8, 8/9, 8/10, 8/11, 8/12, 8/13, 8/14, 8/15,
1989+ 0, 9/1, 9/2, 9/3, 9/4, 9/5, 9/6, 9/7,
1990+ 9/8, 9/9, 9/10, 9/11, 9/12, 9/13, 9/14, 9/15,
1991+ 0, 10/1, 10/2, 10/3, 10/4, 10/5, 10/6, 10/7,
1992+ 10/8, 10/9, 10/10, 10/11, 10/12, 10/13, 10/14, 10/15,
1993+ 0, 11/1, 11/2, 11/3, 11/4, 11/5, 11/6, 11/7,
1994+ 11/8, 11/9, 11/10, 11/11, 11/12, 11/13, 11/14, 11/15,
1995+ 0, 12/1, 12/2, 12/3, 12/4, 12/5, 12/6, 12/7,
1996+ 12/8, 12/9, 12/10, 12/11, 12/12, 12/13, 12/14, 12/15,
1997+ 0, 13/1, 13/2, 13/3, 13/4, 13/5, 13/6, 13/7,
1998+ 13/8, 13/9, 13/10, 13/11, 13/12, 13/13, 13/14, 13/15,
1999+ 0, 14/1, 14/2, 14/3, 14/4, 14/5, 14/6, 14/7,
2000+ 14/8, 14/9, 14/10, 14/11, 14/12, 14/13, 14/14, 14/15,
2001+ 0, 15/1, 15/2, 15/3, 15/4, 15/5, 15/6, 15/7,
2002+ 15/8, 15/9, 15/10, 15/11, 15/12, 15/13, 15/14, 15/15,
2003+};
2004+
2005diff --git a/libgcc/config/microblaze/moddi3.S b/libgcc/config/microblaze/moddi3.S
2006new file mode 100644
2007index 00000000000..5d3f7c03fc8
2008--- /dev/null
2009+++ b/libgcc/config/microblaze/moddi3.S
2010@@ -0,0 +1,97 @@
2011+###################################
2012+#
2013+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2014+#
2015+# Contributed by Michael Eager <eager@eagercon.com>.
2016+#
2017+# This file is free software; you can redistribute it and/or modify it
2018+# under the terms of the GNU General Public License as published by the
2019+# Free Software Foundation; either version 3, or (at your option) any
2020+# later version.
2021+#
2022+# GCC is distributed in the hope that it will be useful, but WITHOUT
2023+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2024+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2025+# License for more details.
2026+#
2027+# Under Section 7 of GPL version 3, you are granted additional
2028+# permissions described in the GCC Runtime Library Exception, version
2029+# 3.1, as published by the Free Software Foundation.
2030+#
2031+# You should have received a copy of the GNU General Public License and
2032+# a copy of the GCC Runtime Library Exception along with this program;
2033+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2034+# <http://www.gnu.org/licenses/>.
2035+#
2036+# moddi3.S
2037+#
2038+# modulo operation for 32 bit integers.
2039+# Input : op1 in Reg r5
2040+# op2 in Reg r6
2041+# Output: op1 mod op2 in Reg r3
2042+#
2043+#######################################
2044+
2045+#ifdef __arch64__
2046+ .globl __moddi3
2047+ .ent __moddi3
2048+ .type __moddi3,@function
2049+__moddi3:
2050+ .frame r1,0,r15
2051+
2052+ addlik r1,r1,-32
2053+ sli r28,r1,0
2054+ sli r29,r1,8
2055+ sli r30,r1,16
2056+ sli r31,r1,32
2057+
2058+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2059+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2060+ ADDL r28,r5,r0 # Get the sign of the result [ Depends only on the first arg]
2061+ BEALGEI r5,$LaR5_Pos
2062+ RSUBLI r5,r5,0 # Make r5 positive
2063+$LaR5_Pos:
2064+ BEALGEI r6,$LaR6_Pos
2065+ RSUBLI r6,r6,0 # Make r6 positive
2066+$LaR6_Pos:
2067+ ADDLIK r3,r0,0 # Clear mod
2068+ ADDLIK r30,r0,0 # clear div
2069+ ADDLIK r29,r0,64 # Initialize the loop count
2070+ BEALLTI r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
2071+ # the first bit search.
2072+ # First part try to find the first '1' in the r5
2073+$LaDIV1:
2074+ ADDL r5,r5,r5 # left shift logical r5
2075+ ADDLIK r29,r29,-1
2076+ BEALGEI r5,$LaDIV1 #
2077+$LaDIV2:
2078+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2079+ ADDLC r3,r3,r3 # Move that bit into the Mod register
2080+ rSUBL r31,r6,r3 # Try to subtract (r30 a r6)
2081+ BEALLTi r31,$LaMOD_TOO_SMALL
2082+ ORL r3,r0,r31 # Move the r31 to mod since the result was positive
2083+ ADDLIK r30,r30,1
2084+$LaMOD_TOO_SMALL:
2085+ ADDLIK r29,r29,-1
2086+ BEALEQi r29,$LaLOOP_END
2087+ ADDL r30,r30,r30 # Shift in the '1' into div
2088+ BREAI $LaDIV2 # Div2
2089+$LaLOOP_END:
2090+ BEALGEI r28,$LaRETURN_HERE
2091+ rsubli r3,r3,0 # Negate the result
2092+ BREAI $LaRETURN_HERE
2093+$LaDiv_By_Zero:
2094+$LaResult_Is_Zero:
2095+ orl r3,r0,r0 # set result to 0 [Both mod as well as div are 0]
2096+$LaRETURN_HERE:
2097+# Restore values of CSRs and that of r3 and the divisor and the dividend
2098+ lli r28,r1,0
2099+ lli r29,r1,8
2100+ lli r30,r1,16
2101+ lli r31,r1,24
2102+ addlik r1,r1,32
2103+ rtsd r15,8
2104+ nop
2105+ .end __moddi3
2106+ .size __moddi3, . - __moddi3
2107+#endif
2108diff --git a/libgcc/config/microblaze/muldi3.S b/libgcc/config/microblaze/muldi3.S
2109new file mode 100644
2110index 00000000000..567784197d3
2111--- /dev/null
2112+++ b/libgcc/config/microblaze/muldi3.S
2113@@ -0,0 +1,73 @@
2114+/*###################################-*-asm*-
2115+#
2116+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2117+#
2118+# Contributed by Michael Eager <eager@eagercon.com>.
2119+#
2120+# This file is free software; you can redistribute it and/or modify it
2121+# under the terms of the GNU General Public License as published by the
2122+# Free Software Foundation; either version 3, or (at your option) any
2123+# later version.
2124+#
2125+# GCC is distributed in the hope that it will be useful, but WITHOUT
2126+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2127+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2128+# License for more details.
2129+#
2130+# Under Section 7 of GPL version 3, you are granted additional
2131+# permissions described in the GCC Runtime Library Exception, version
2132+# 3.1, as published by the Free Software Foundation.
2133+#
2134+# You should have received a copy of the GNU General Public License and
2135+# a copy of the GCC Runtime Library Exception along with this program;
2136+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2137+# <http://www.gnu.org/licenses/>.
2138+#
2139+# muldi3.S
2140+#
2141+# Multiply operation for 32 bit integers.
2142+# Input : Operand1 in Reg r5
2143+# Operand2 in Reg r6
2144+# Output: Result [op1 * op2] in Reg r3
2145+#
2146+#######################################*/
2147+
2148+#ifdef __arch64__
2149+ .globl __muldi3
2150+ .ent __muldi3
2151+ .type __muldi3,@function
2152+__muldi3:
2153+ .frame r1,0,r15
2154+ addl r3,r0,r0
2155+ BEALEQI r5,$L_Result_Is_Zero # Multiply by Zero
2156+ BEALEQI r6,$L_Result_Is_Zero # Multiply by Zero
2157+ XORL r4,r5,r6 # Get the sign of the result
2158+ BEALGEI r5,$L_R5_Pos
2159+ RSUBLI r5,r5,0 # Make r5 positive
2160+$L_R5_Pos:
2161+ BEALGEI r6,$L_R6_Pos
2162+ RSUBLI r6,r6,0 # Make r6 positive
2163+$L_R6_Pos:
2164+ breai $L1
2165+$L2:
2166+ addl r5,r5,r5
2167+$L1:
2168+ srll r6,r6
2169+ addlc r7,r0,r0
2170+ bealeqi r7,$L2
2171+ addl r3,r3,r5
2172+ bealnei r6,$L2
2173+ beallti r4,$L_NegateResult
2174+ rtsd r15,8
2175+ nop
2176+$L_NegateResult:
2177+ rsubl r3,r3,r0
2178+ rtsd r15,8
2179+ nop
2180+$L_Result_Is_Zero:
2181+ addli r3,r0,0
2182+ rtsd r15,8
2183+ nop
2184+ .end __muldi3
2185+ .size __muldi3, . - __muldi3
2186+#endif
2187diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
2188index 8d954a49575..35021b24b7d 100644
2189--- a/libgcc/config/microblaze/t-microblaze
2190+++ b/libgcc/config/microblaze/t-microblaze
2191@@ -1,11 +1,16 @@
2192-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
2193+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3 \
2194+ _divdi3 _moddi3 _muldi3 _udivdi3 _umoddi3
2195
2196 LIB2ADD += \
2197 $(srcdir)/config/microblaze/divsi3.S \
2198+ $(srcdir)/config/microblaze/divdi3.S \
2199 $(srcdir)/config/microblaze/modsi3.S \
2200- $(srcdir)/config/microblaze/muldi3_hard.S \
2201+ $(srcdir)/config/microblaze/moddi3.S \
2202 $(srcdir)/config/microblaze/mulsi3.S \
2203+ $(srcdir)/config/microblaze/muldi3.S \
2204 $(srcdir)/config/microblaze/stack_overflow_exit.S \
2205 $(srcdir)/config/microblaze/udivsi3.S \
2206+ $(srcdir)/config/microblaze/udivdi3.S \
2207 $(srcdir)/config/microblaze/umodsi3.S \
2208- $(srcdir)/config/microblaze/divsi3_table.c
2209+ $(srcdir)/config/microblaze/umoddi3.S \
2210+ $(srcdir)/config/microblaze/divsi3_table.c \
2211diff --git a/libgcc/config/microblaze/udivdi3.S b/libgcc/config/microblaze/udivdi3.S
2212new file mode 100644
2213index 00000000000..c210fbc7128
2214--- /dev/null
2215+++ b/libgcc/config/microblaze/udivdi3.S
2216@@ -0,0 +1,107 @@
2217+###################################-
2218+#
2219+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2220+#
2221+# Contributed by Michael Eager <eager@eagercon.com>.
2222+#
2223+# This file is free software; you can redistribute it and/or modify it
2224+# under the terms of the GNU General Public License as published by the
2225+# Free Software Foundation; either version 3, or (at your option) any
2226+# later version.
2227+#
2228+# GCC is distributed in the hope that it will be useful, but WITHOUT
2229+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2230+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2231+# License for more details.
2232+#
2233+# Under Section 7 of GPL version 3, you are granted additional
2234+# permissions described in the GCC Runtime Library Exception, version
2235+# 3.1, as published by the Free Software Foundation.
2236+#
2237+# You should have received a copy of the GNU General Public License and
2238+# a copy of the GCC Runtime Library Exception along with this program;
2239+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2240+# <http://www.gnu.org/licenses/>.
2241+#
2242+# udivdi3.S
2243+#
2244+# Unsigned divide operation.
2245+# Input : Divisor in Reg r5
2246+# Dividend in Reg r6
2247+# Output: Result in Reg r3
2248+#
2249+#######################################
2250+
2251+#ifdef __arch64__
2252+ .globl __udivdi3
2253+ .ent __udivdi3
2254+ .type __udivdi3,@function
2255+__udivdi3:
2256+ .frame r1,0,r15
2257+
2258+ ADDlIK r1,r1,-24
2259+ SLI r29,r1,0
2260+ SLI r30,r1,8
2261+ SLI r31,r1,16
2262+
2263+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2264+ ADDLIK r30,r0,0 # Clear mod
2265+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2266+ ADDLIK r29,r0,64 # Initialize the loop count
2267+
2268+ # Check if r6 and r5 are equal # if yes, return 1
2269+ RSUBL r18,r5,r6
2270+ ADDLIK r3,r0,1
2271+ BEALEQI r18,$LaRETURN_HERE
2272+
2273+ # Check if (uns)r6 is greater than (uns)r5. In that case, just return 0
2274+ XORL r18,r5,r6
2275+ ADDL r3,r0,r0 # We would anyways clear r3
2276+ BEALGEI r18,$LRSUBL
2277+ BEALLTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
2278+ BREAI $LCheckr6
2279+$LRSUBL:
2280+ RSUBL r18,r6,r5 # MICROBLAZEcmp
2281+ BEALLTI r18,$LaRETURN_HERE
2282+
2283+ # If r6 [bit 31] is set, then return result as 1
2284+$LCheckr6:
2285+ BEALGTI r6,$LaDIV0
2286+ ADDLIK r3,r0,1
2287+ BREAI $LaRETURN_HERE
2288+
2289+ # First part try to find the first '1' in the r5
2290+$LaDIV0:
2291+ BEALLTI r5,$LaDIV2
2292+$LaDIV1:
2293+ ADDL r5,r5,r5 # left shift logical r5
2294+ ADDLIK r29,r29,-1
2295+ BEALGTI r5,$LaDIV1
2296+$LaDIV2:
2297+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2298+ ADDLC r30,r30,r30 # Move that bit into the Mod register
2299+ RSUBL r31,r6,r30 # Try to subtract (r30 a r6)
2300+ BEALLTI r31,$LaMOD_TOO_SMALL
2301+ ORL r30,r0,r31 # Move the r31 to mod since the result was positive
2302+ ADDLIK r3,r3,1
2303+$LaMOD_TOO_SMALL:
2304+ ADDLIK r29,r29,-1
2305+ BEALEQi r29,$LaLOOP_END
2306+ ADDL r3,r3,r3 # Shift in the '1' into div
2307+ BREAI $LaDIV2 # Div2
2308+$LaLOOP_END:
2309+ BREAI $LaRETURN_HERE
2310+$LaDiv_By_Zero:
2311+$LaResult_Is_Zero:
2312+ ORL r3,r0,r0 # set result to 0
2313+$LaRETURN_HERE:
2314+ # Restore values of CSRs and that of r3 and the divisor and the dividend
2315+ LLI r29,r1,0
2316+ LLI r30,r1,8
2317+ LLI r31,r1,16
2318+ ADDLIK r1,r1,24
2319+ RTSD r15,8
2320+ NOP
2321+ .end __udivdi3
2322+ .size __udivdi3, . - __udivdi3
2323+#endif
2324diff --git a/libgcc/config/microblaze/umoddi3.S b/libgcc/config/microblaze/umoddi3.S
2325new file mode 100644
2326index 00000000000..7f5cd23f9a1
2327--- /dev/null
2328+++ b/libgcc/config/microblaze/umoddi3.S
2329@@ -0,0 +1,110 @@
2330+###################################
2331+#
2332+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2333+#
2334+# Contributed by Michael Eager <eager@eagercon.com>.
2335+#
2336+# This file is free software; you can redistribute it and/or modify it
2337+# under the terms of the GNU General Public License as published by the
2338+# Free Software Foundation; either version 3, or (at your option) any
2339+# later version.
2340+#
2341+# GCC is distributed in the hope that it will be useful, but WITHOUT
2342+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2343+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2344+# License for more details.
2345+#
2346+# Under Section 7 of GPL version 3, you are granted additional
2347+# permissions described in the GCC Runtime Library Exception, version
2348+# 3.1, as published by the Free Software Foundation.
2349+#
2350+# You should have received a copy of the GNU General Public License and
2351+# a copy of the GCC Runtime Library Exception along with this program;
2352+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2353+# <http://www.gnu.org/licenses/>.
2354+#
2355+# umoddi3.S
2356+#
2357+# Unsigned modulo operation for 32 bit integers.
2358+# Input : op1 in Reg r5
2359+# op2 in Reg r6
2360+# Output: op1 mod op2 in Reg r3
2361+#
2362+#######################################
2363+
2364+#ifdef __arch64__
2365+ .globl __umoddi3
2366+ .ent __umoddi3
2367+ .type __umoddi3,@function
2368+__umoddi3:
2369+ .frame r1,0,r15
2370+
2371+ addlik r1,r1,-24
2372+ sli r29,r1,0
2373+ sli r30,r1,8
2374+ sli r31,r1,16
2375+
2376+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2377+ ADDLIK r3,r0,0 # Clear div
2378+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2379+ ADDLIK r30,r0,0 # clear mod
2380+ ADDLIK r29,r0,64 # Initialize the loop count
2381+
2382+# Check if r6 and r5 are equal # if yes, return 0
2383+ rsubl r18,r5,r6
2384+ bealeqi r18,$LaRETURN_HERE
2385+
2386+# Check if (uns)r6 is greater than (uns)r5. In that case, just return r5
2387+ xorl r18,r5,r6
2388+ addlik r3,r5,0
2389+ bealgei r18,$LRSUB
2390+ beallti r6,$LaRETURN_HERE
2391+ breai $LCheckr6
2392+$LRSUB:
2393+ rsubl r18,r5,r6 # MICROBLAZEcmp
2394+ bealgti r18,$LaRETURN_HERE
2395+
2396+# If r6 [bit 31] is set, then return result as r5-r6
2397+$LCheckr6:
2398+ addlik r3,r0,0
2399+ bealgti r6,$LaDIV0
2400+ addlik r18,r0,0x7fffffff
2401+ andl r5,r5,r18
2402+ andl r6,r6,r18
2403+ breaid $LaRETURN_HERE
2404+ rsubl r3,r6,r5
2405+# First part: try to find the first '1' in the r5
2406+$LaDIV0:
2407+ BEALLTI r5,$LaDIV2
2408+$LaDIV1:
2409+ ADDL r5,r5,r5 # left shift logical r5
2410+ ADDLIK r29,r29,-1
2411+ BEALGEI r5,$LaDIV1 #
2412+$LaDIV2:
2413+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2414+ ADDLC r3,r3,r3 # Move that bit into the Mod register
2415+ rSUBL r31,r6,r3 # Try to subtract (r3 a r6)
2416+ BEALLTi r31,$LaMOD_TOO_SMALL
2417+ ORL r3,r0,r31 # Move the r31 to mod since the result was positive
2418+ ADDLIK r30,r30,1
2419+$LaMOD_TOO_SMALL:
2420+ ADDLIK r29,r29,-1
2421+ BEALEQi r29,$LaLOOP_END
2422+ ADDL r30,r30,r30 # Shift in the '1' into div
2423+ BREAI $LaDIV2 # Div2
2424+$LaLOOP_END:
2425+ BREAI $LaRETURN_HERE
2426+$LaDiv_By_Zero:
2427+$LaResult_Is_Zero:
2428+ orl r3,r0,r0 # set result to 0
2429+$LaRETURN_HERE:
2430+# Restore values of CSRs and that of r3 and the divisor and the dividend
2431+ lli r29,r1,0
2432+ lli r30,r1,8
2433+ lli r31,r1,16
2434+ addlik r1,r1,24
2435+ rtsd r15,8
2436+ nop
2437+.end __umoddi3
2438+ .size __umoddi3, . - __umoddi3
2439+#endif
2440--
24412.37.1 (Apple Git-137.1)
2442
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0029-Patch-MicroBlaze-re-arrangement-of-the-compare-branc.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0029-Patch-MicroBlaze-re-arrangement-of-the-compare-branc.patch
deleted file mode 100644
index 26cdfca2..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0029-Patch-MicroBlaze-re-arrangement-of-the-compare-branc.patch
+++ /dev/null
@@ -1,269 +0,0 @@
1From 10d5e7d6cad5e7349b88b7469eb5ae20d87eb908 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 14:45:15 +0530
4Subject: [PATCH 29/53] [Patch,MicroBlaze] : re-arrangement of the compare
5 branches
6
7---
8 gcc/config/microblaze/microblaze.cc | 28 ++----
9 gcc/config/microblaze/microblaze.md | 141 +++++++++++++---------------
10 2 files changed, 73 insertions(+), 96 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
13index 9d3628c6816..4792e3ba370 100644
14--- a/gcc/config/microblaze/microblaze.cc
15+++ b/gcc/config/microblaze/microblaze.cc
16@@ -3698,11 +3698,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
17 {
18 comp_reg = cmp_op0;
19 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
20- if (mode == Pmode)
21- emit_jump_insn (gen_condjump (condition, label1));
22- else
23- emit_jump_insn (gen_long_condjump (condition, label1));
24-
25+ emit_jump_insn (gen_condjump (condition, label1));
26 }
27
28 else if (code == EQ || code == NE)
29@@ -3713,10 +3709,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
30 else
31 emit_insn (gen_xordi3 (comp_reg, cmp_op0, cmp_op1));
32 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
33- if (mode == SImode)
34- emit_jump_insn (gen_condjump (condition, label1));
35- else
36- emit_jump_insn (gen_long_condjump (condition, label1));
37+ emit_jump_insn (gen_condjump (condition, label1));
38 }
39 else
40 {
41@@ -3749,10 +3742,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
42 comp_reg = cmp_op0;
43 condition = gen_rtx_fmt_ee (signed_condition (code),
44 mode, comp_reg, const0_rtx);
45- if (mode == SImode)
46- emit_jump_insn (gen_condjump (condition, label1));
47- else
48- emit_jump_insn (gen_long_condjump (condition, label1));
49+ emit_jump_insn (gen_condjump (condition, label1));
50 }
51 else if (code == EQ)
52 {
53@@ -3767,10 +3757,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
54 cmp_op1));
55 }
56 condition = gen_rtx_EQ (mode, comp_reg, const0_rtx);
57- if (mode == SImode)
58- emit_jump_insn (gen_condjump (condition, label1));
59- else
60- emit_jump_insn (gen_long_condjump (condition, label1));
61+ emit_jump_insn (gen_condjump (condition, label1));
62
63 }
64 else if (code == NE)
65@@ -3786,10 +3773,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
66 cmp_op1));
67 }
68 condition = gen_rtx_NE (mode, comp_reg, const0_rtx);
69- if (mode == SImode)
70- emit_jump_insn (gen_condjump (condition, label1));
71- else
72- emit_jump_insn (gen_long_condjump (condition, label1));
73+ emit_jump_insn (gen_condjump (condition, label1));
74 }
75 else
76 {
77@@ -3831,7 +3815,7 @@ microblaze_expand_conditional_branch_df (rtx operands[])
78
79 emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
80 condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
81- emit_jump_insn (gen_long_condjump (condition, operands[3]));
82+ emit_jump_insn (gen_condjump (condition, operands[3]));
83 }
84
85 /* Implement TARGET_FRAME_POINTER_REQUIRED. */
86diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
87index c99150ff0da..566c53ba228 100644
88--- a/gcc/config/microblaze/microblaze.md
89+++ b/gcc/config/microblaze/microblaze.md
90@@ -2268,7 +2268,27 @@ else
91 (label_ref (match_operand 1))
92 (pc)))])
93
94-(define_insn "branch_zero64"
95+(define_insn "branch_zero_64"
96+ [(set (pc)
97+ (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
98+ [(match_operand:SI 1 "register_operand" "d")
99+ (const_int 0)])
100+ (match_operand:SI 2 "pc_or_label_operand" "")
101+ (match_operand:SI 3 "pc_or_label_operand" "")))
102+ ]
103+ "TARGET_MB_64"
104+ {
105+ if (operands[3] == pc_rtx)
106+ return "bea%C0i%?\t%z1,%2";
107+ else
108+ return "bea%N0i%?\t%z1,%3";
109+ }
110+ [(set_attr "type" "branch")
111+ (set_attr "mode" "none")
112+ (set_attr "length" "4")]
113+)
114+
115+(define_insn "long_branch_zero"
116 [(set (pc)
117 (if_then_else (match_operator 0 "ordered_comparison_operator"
118 [(match_operand 1 "register_operand" "d")
119@@ -2279,9 +2299,9 @@ else
120 "TARGET_MB_64"
121 {
122 if (operands[3] == pc_rtx)
123- return "bea%C0i%?\t%z1,%2";
124+ return "beal%C0i%?\t%z1,%2";
125 else
126- return "bea%N0i%?\t%z1,%3";
127+ return "beal%N0i%?\t%z1,%3";
128 }
129 [(set_attr "type" "branch")
130 (set_attr "mode" "none")
131@@ -2310,9 +2330,9 @@ else
132
133 (define_insn "branch_compare64"
134 [(set (pc)
135- (if_then_else (match_operator 0 "cmp_op"
136- [(match_operand 1 "register_operand" "d")
137- (match_operand 2 "register_operand" "d")
138+ (if_then_else (match_operator:SI 0 "cmp_op"
139+ [(match_operand:SI 1 "register_operand" "d")
140+ (match_operand:SI 2 "register_operand" "d")
141 ])
142 (label_ref (match_operand 3))
143 (pc)))
144@@ -2349,6 +2369,47 @@ else
145 (set_attr "length" "12")]
146 )
147
148+(define_insn "long_branch_compare"
149+ [(set (pc)
150+ (if_then_else (match_operator 0 "cmp_op"
151+ [(match_operand 1 "register_operand" "d")
152+ (match_operand 2 "register_operand" "d")
153+ ])
154+ (label_ref (match_operand 3))
155+ (pc)))
156+ (clobber(reg:DI R_TMP))]
157+ "TARGET_MB_64"
158+ {
159+ operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
160+ enum rtx_code code = GET_CODE (operands[0]);
161+
162+ if (code == GT || code == LE)
163+ {
164+ output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
165+ code = swap_condition (code);
166+ }
167+ else if (code == GTU || code == LEU)
168+ {
169+ output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
170+ code = swap_condition (code);
171+ }
172+ else if (code == GE || code == LT)
173+ {
174+ output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
175+ }
176+ else if (code == GEU || code == LTU)
177+ {
178+ output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
179+ }
180+
181+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
182+ return "beal%C0i%?\tr18,%3";
183+ }
184+ [(set_attr "type" "branch")
185+ (set_attr "mode" "none")
186+ (set_attr "length" "12")]
187+)
188+
189 (define_insn "branch_compare"
190 [(set (pc)
191 (if_then_else (match_operator:SI 0 "cmp_op"
192@@ -2431,74 +2492,6 @@ else
193
194 })
195
196-;; Used to implement comparison instructions
197-(define_expand "long_condjump"
198- [(set (pc)
199- (if_then_else (match_operand 0)
200- (label_ref (match_operand 1))
201- (pc)))])
202-
203-(define_insn "long_branch_zero"
204- [(set (pc)
205- (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
206- [(match_operand:DI 1 "register_operand" "d")
207- (const_int 0)])
208- (match_operand:DI 2 "pc_or_label_operand" "")
209- (match_operand:DI 3 "pc_or_label_operand" "")))
210- ]
211- "TARGET_MB_64"
212- {
213- if (operands[3] == pc_rtx)
214- return "beal%C0i%?\t%z1,%2";
215- else
216- return "beal%N0i%?\t%z1,%3";
217- }
218- [(set_attr "type" "branch")
219- (set_attr "mode" "none")
220- (set_attr "length" "4")]
221-)
222-
223-(define_insn "long_branch_compare"
224- [(set (pc)
225- (if_then_else (match_operator:DI 0 "cmp_op"
226- [(match_operand:DI 1 "register_operand" "d")
227- (match_operand:DI 2 "register_operand" "d")
228- ])
229- (label_ref (match_operand 3))
230- (pc)))
231- (clobber(reg:DI R_TMP))]
232- "TARGET_MB_64"
233- {
234- operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
235- enum rtx_code code = GET_CODE (operands[0]);
236-
237- if (code == GT || code == LE)
238- {
239- output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
240- code = swap_condition (code);
241- }
242- else if (code == GTU || code == LEU)
243- {
244- output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
245- code = swap_condition (code);
246- }
247- else if (code == GE || code == LT)
248- {
249- output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
250- }
251- else if (code == GEU || code == LTU)
252- {
253- output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
254- }
255-
256- operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
257- return "beal%C0i%?\tr18,%3";
258- }
259- [(set_attr "type" "branch")
260- (set_attr "mode" "none")
261- (set_attr "length" "12")]
262-)
263-
264 ;;----------------------------------------------------------------
265 ;; Unconditional branches
266 ;;----------------------------------------------------------------
267--
2682.37.1 (Apple Git-137.1)
269
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0030-Patch-Microblaze-previous-commit-broke-the-handling-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0030-Patch-Microblaze-previous-commit-broke-the-handling-.patch
deleted file mode 100644
index 83d047cb..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0030-Patch-Microblaze-previous-commit-broke-the-handling-.patch
+++ /dev/null
@@ -1,28 +0,0 @@
1From af910dd71faec99838e421dd76fd5231e34bee3e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 8 Aug 2018 17:37:26 +0530
4Subject: [PATCH 30/53] [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 566c53ba228..e54888550f6 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -2224,8 +2224,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.37.1 (Apple Git-137.1)
28
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0031-Patch-Microblaze-Support-of-multilibs-with-m64.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0031-Patch-Microblaze-Support-of-multilibs-with-m64.patch
deleted file mode 100644
index c230049c..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0031-Patch-Microblaze-Support-of-multilibs-with-m64.patch
+++ /dev/null
@@ -1,77 +0,0 @@
1From 6921698fc0acf40cb036cf71649762e7a21bf604 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 11 Sep 2018 13:43:48 +0530
4Subject: [PATCH 31/53] [Patch, Microblaze] : Support of multilibs with m64 ...
5
6Conflicts:
7 gcc/config/microblaze/microblaze-c.c
8
9signed-off-by : Mahesh Bodapati <mbodapat@xilinx.com>
10---
11 gcc/config/microblaze/microblaze-c.cc | 1 +
12 gcc/config/microblaze/t-microblaze | 15 ++++++---------
13 libgcc/config/microblaze/t-microblaze | 11 +++--------
14 3 files changed, 10 insertions(+), 17 deletions(-)
15
16diff --git a/gcc/config/microblaze/microblaze-c.cc b/gcc/config/microblaze/microblaze-c.cc
17index ef8d2430565..4e83a84b112 100644
18--- a/gcc/config/microblaze/microblaze-c.cc
19+++ b/gcc/config/microblaze/microblaze-c.cc
20@@ -102,6 +102,7 @@ microblaze_cpp_define (cpp_reader *pfile)
21 }
22 if (TARGET_MB_64)
23 {
24+ builtin_define ("__microblaze64");
25 builtin_define ("__arch64__");
26 builtin_define ("__microblaze64__");
27 builtin_define ("__MICROBLAZE64__");
28diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
29index 965132b3513..47b869b9303 100644
30--- a/gcc/config/microblaze/t-microblaze
31+++ b/gcc/config/microblaze/t-microblaze
32@@ -1,12 +1,9 @@
33-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian m64
34-MULTILIB_DIRNAMES = bs m mh le m64
35-MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
36-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
37-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian/m64
38-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64 mxl-multiply-high
39-MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
40-MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
41-MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
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_EXCEPTIONS = *m64/mxl-multiply-high mxl-multiply-high
45+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
46+MULTILIB_EXCEPTIONS += *mlittle-endian/mxl-multiply-high mxl-multiply-high
47+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mlittle-endian/mxl-multiply-high
48
49 # Extra files
50 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.cc \
51diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
52index 35021b24b7d..8d954a49575 100644
53--- a/libgcc/config/microblaze/t-microblaze
54+++ b/libgcc/config/microblaze/t-microblaze
55@@ -1,16 +1,11 @@
56-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3 \
57- _divdi3 _moddi3 _muldi3 _udivdi3 _umoddi3
58+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
59
60 LIB2ADD += \
61 $(srcdir)/config/microblaze/divsi3.S \
62- $(srcdir)/config/microblaze/divdi3.S \
63 $(srcdir)/config/microblaze/modsi3.S \
64- $(srcdir)/config/microblaze/moddi3.S \
65+ $(srcdir)/config/microblaze/muldi3_hard.S \
66 $(srcdir)/config/microblaze/mulsi3.S \
67- $(srcdir)/config/microblaze/muldi3.S \
68 $(srcdir)/config/microblaze/stack_overflow_exit.S \
69 $(srcdir)/config/microblaze/udivsi3.S \
70- $(srcdir)/config/microblaze/udivdi3.S \
71 $(srcdir)/config/microblaze/umodsi3.S \
72- $(srcdir)/config/microblaze/umoddi3.S \
73- $(srcdir)/config/microblaze/divsi3_table.c \
74+ $(srcdir)/config/microblaze/divsi3_table.c
75--
762.37.1 (Apple Git-137.1)
77
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0032-Patch-MicroBlaze-Fixed-issues-like.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0032-Patch-MicroBlaze-Fixed-issues-like.patch
deleted file mode 100644
index 36a20450..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0032-Patch-MicroBlaze-Fixed-issues-like.patch
+++ /dev/null
@@ -1,70 +0,0 @@
1From 7f827e73dff27c764e5f475613e3e06ae546103f Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 15:24:25 +0530
4Subject: [PATCH 32/53] [Patch,MicroBlaze]: Fixed issues like: 1 Interrupt
5 alignment issue 2 Sign extension issue
6
7---
8 gcc/config/microblaze/microblaze.cc | 16 ++++++++++------
9 gcc/config/microblaze/microblaze.md | 2 +-
10 2 files changed, 11 insertions(+), 7 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
13index 4792e3ba370..f1da145232a 100644
14--- a/gcc/config/microblaze/microblaze.cc
15+++ b/gcc/config/microblaze/microblaze.cc
16@@ -2178,9 +2178,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@@ -2465,7 +2470,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@@ -2480,10 +2484,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 e54888550f6..4e5d21a1f4c 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.37.1 (Apple Git-137.1)
70
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch
deleted file mode 100644
index 9c9e4dd2..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch
+++ /dev/null
@@ -1,305 +0,0 @@
1From 0a86428a345ed359f788a72a0e185053b598e908 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 15:28:58 +0530
4Subject: [PATCH 33/53] [Patch,MicroBlaze]: fixed below issues: - Floating
5 point print issues in 64bit mode - Dejagnu Jump related issues -
6 Added dbl instruction
7
8 Conflicts:
9 gcc/config/microblaze/microblaze.md
10---
11 gcc/config/microblaze/microblaze.cc | 12 +++-
12 gcc/config/microblaze/microblaze.h | 7 +++
13 gcc/config/microblaze/microblaze.md | 86 ++++++++++++++++++++++++-----
14 libgcc/config/microblaze/crti.S | 24 +++++++-
15 libgcc/config/microblaze/crtn.S | 13 +++++
16 5 files changed, 125 insertions(+), 17 deletions(-)
17
18diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
19index f1da145232a..7a08390a027 100644
20--- a/gcc/config/microblaze/microblaze.cc
21+++ b/gcc/config/microblaze/microblaze.cc
22@@ -2474,7 +2474,12 @@ print_operand (FILE * file, rtx op, int letter)
23 if (code == CONST_DOUBLE)
24 {
25 if (GET_MODE (op) == DFmode)
26- REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
27+ {
28+ if (TARGET_MB_64)
29+ REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
30+ else
31+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
32+ }
33 else
34 {
35 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
36@@ -3877,7 +3882,10 @@ microblaze_expand_divide (rtx operands[])
37 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
38
39 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
40- jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
41+ if (TARGET_MB_64)
42+ jump = emit_jump_insn_after (gen_jump_64 (div_end_label), insn);
43+ else
44+ jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
45 JUMP_LABEL (jump) = div_end_label;
46 LABEL_NUSES (div_end_label) = 1;
47 emit_barrier ();
48diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
49index 5f30b8ac195..ac4ea43a706 100644
50--- a/gcc/config/microblaze/microblaze.h
51+++ b/gcc/config/microblaze/microblaze.h
52@@ -888,10 +888,17 @@ do { \
53 /* We do this to save a few 10s of code space that would be taken up
54 by the call_FUNC () wrappers, used by the generic CRT_CALL_STATIC_FUNCTION
55 definition in crtstuff.c. */
56+#ifdef __arch64__
57+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
58+ asm ( SECTION_OP "\n" \
59+ "\tbrealid r15, " #FUNC "\n\t nop\n" \
60+ TEXT_SECTION_ASM_OP);
61+#else
62 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
63 asm ( SECTION_OP "\n" \
64 "\tbrlid r15, " #FUNC "\n\t nop\n" \
65 TEXT_SECTION_ASM_OP);
66+#endif
67
68 /* We need to group -lm as well, since some Newlib math functions
69 reference __errno! */
70diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
71index 4e5d21a1f4c..5a950b49591 100644
72--- a/gcc/config/microblaze/microblaze.md
73+++ b/gcc/config/microblaze/microblaze.md
74@@ -527,6 +527,15 @@
75 (set_attr "mode" "SF")
76 (set_attr "length" "4")])
77
78+(define_insn "floatdidf2"
79+ [(set (match_operand:DF 0 "register_operand" "=d")
80+ (float:DF (match_operand:DI 1 "register_operand" "d")))]
81+ "TARGET_MB_64"
82+ "dbl\t%0,%1"
83+ [(set_attr "type" "fcvt")
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@@ -1299,7 +1308,7 @@
91 (define_insn "movdi_long_int"
92 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
93 (match_operand:DI 1 "general_operand" "i"))]
94- ""
95+ "TARGET_MB_64"
96 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
97 [(set_attr "type" "no_delay_arith")
98 (set_attr "mode" "DI")
99@@ -1582,7 +1591,7 @@
100 return "ll%i1\t%0,%1";
101 case 3:
102 {
103- return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
104+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
105 }
106 case 5:
107 return "sl%i0\t%1,%0";
108@@ -2371,9 +2380,9 @@ else
109
110 (define_insn "long_branch_compare"
111 [(set (pc)
112- (if_then_else (match_operator 0 "cmp_op"
113- [(match_operand 1 "register_operand" "d")
114- (match_operand 2 "register_operand" "d")
115+ (if_then_else (match_operator:DI 0 "cmp_op"
116+ [(match_operand:DI 1 "register_operand" "d")
117+ (match_operand:DI 2 "register_operand" "d")
118 ])
119 (label_ref (match_operand 3))
120 (pc)))
121@@ -2495,6 +2504,20 @@ else
122 ;;----------------------------------------------------------------
123 ;; Unconditional branches
124 ;;----------------------------------------------------------------
125+(define_insn "jump_64"
126+ [(set (pc)
127+ (label_ref (match_operand 0 "" "")))]
128+ "TARGET_MB_64"
129+ {
130+ if (GET_CODE (operands[0]) == REG)
131+ return "brea%?\t%0";
132+ else
133+ return "breai%?\t%l0";
134+ }
135+ [(set_attr "type" "jump")
136+ (set_attr "mode" "none")
137+ (set_attr "length" "4")])
138+
139 (define_insn "jump"
140 [(set (pc)
141 (label_ref (match_operand 0 "" "")))]
142@@ -2540,17 +2563,25 @@ else
143 {
144 //gcc_assert (GET_MODE (operands[0]) == Pmode);
145
146- if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
147- emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
148- else
149- emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
150+ if (!flag_pic || TARGET_PIC_DATA_TEXT_REL) {
151+ if (!TARGET_MB_64)
152+ emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
153+ else
154+ emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
155+ }
156+ else {
157+ if (!TARGET_MB_64)
158+ emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
159+ else
160+ emit_jump_insn (gen_tablejump_internal4 (operands[0], operands[1]));
161+ }
162 DONE;
163 }
164 )
165
166 (define_insn "tablejump_internal1"
167 [(set (pc)
168- (match_operand 0 "register_operand" "d"))
169+ (match_operand:SI 0 "register_operand" "d"))
170 (use (label_ref (match_operand 1 "" "")))]
171 ""
172 "bra%?\t%0 "
173@@ -2558,11 +2589,21 @@ else
174 (set_attr "mode" "none")
175 (set_attr "length" "4")])
176
177+(define_insn "tablejump_internal2"
178+ [(set (pc)
179+ (match_operand:DI 0 "register_operand" "d"))
180+ (use (label_ref (match_operand 1 "" "")))]
181+ "TARGET_MB_64"
182+ "bra%?\t%0 "
183+ [(set_attr "type" "jump")
184+ (set_attr "mode" "none")
185+ (set_attr "length" "4")])
186+
187 (define_expand "tablejump_internal3"
188 [(parallel [(set (pc)
189- (plus (match_operand 0 "register_operand" "d")
190- (label_ref (match_operand:SI 1 "" ""))))
191- (use (label_ref (match_dup 1)))])]
192+ (plus:SI (match_operand:SI 0 "register_operand" "d")
193+ (label_ref:SI (match_operand:SI 1 "" ""))))
194+ (use (label_ref:SI (match_dup 1)))])]
195 ""
196 ""
197 )
198@@ -2593,6 +2634,23 @@ else
199 ""
200 )
201
202+(define_insn ""
203+ [(set (pc)
204+ (plus:DI (match_operand:DI 0 "register_operand" "d")
205+ (label_ref:DI (match_operand 1 "" ""))))
206+ (use (label_ref:DI (match_dup 1)))]
207+ "TARGET_MB_64 && NEXT_INSN (as_a <rtx_insn *> (operands[1])) != 0
208+ && GET_CODE (PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1])))) == ADDR_DIFF_VEC
209+ && flag_pic"
210+ {
211+ output_asm_insn ("addlk\t%0,%0,r20",operands);
212+ return "bra%?\t%0";
213+}
214+ [(set_attr "type" "jump")
215+ (set_attr "mode" "none")
216+ (set_attr "length" "4")])
217+
218+
219 ;;----------------------------------------------------------------
220 ;; Function prologue/epilogue and stack allocation
221 ;;----------------------------------------------------------------
222@@ -3101,7 +3159,7 @@ else
223 ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference
224 ;; between "mfs" and "addik" instructions.
225 (define_insn "set_got"
226- [(set (match_operand:SI 0 "register_operand" "=r")
227+ [(set (match_operand 0 "register_operand" "=r")
228 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))]
229 ""
230 "mfs\t%0,rpc\n\taddik\t%0,%0,_GLOBAL_OFFSET_TABLE_+8"
231diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
232index ec797e1bf17..15ebe68c277 100644
233--- a/libgcc/config/microblaze/crti.S
234+++ b/libgcc/config/microblaze/crti.S
235@@ -33,11 +33,32 @@
236 .section .init, "ax"
237 .global __init
238
239+#ifdef __arch64__
240 .weak _stack
241- .set _stack, 0xffffffff
242+ .set _stack, 0xffffffffffffffff
243 .weak _stack_end
244 .set _stack_end, 0
245
246+ .align 3
247+__init:
248+ addlik r1, r1, -32
249+ sl r15, r0, r1
250+ addlik r11, r0, _stack
251+ mts rshr, r11
252+ addlik r11, r0, _stack_end
253+ mts rslr, r11
254+
255+ .section .fini, "ax"
256+ .global __fini
257+ .align 3
258+__fini:
259+ addlik r1, r1, -32
260+ sl r15, r0, r1
261+#else
262+ .weak _stack
263+ .set _stack, 0xffffffff
264+ .weak _stack_end
265+ .set _stack_end, 0
266 .align 2
267 __init:
268 addik r1, r1, -16
269@@ -53,3 +74,4 @@ __init:
270 __fini:
271 addik r1, r1, -16
272 sw r15, r0, r1
273+#endif
274diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
275index 977b43b9436..9de3d4de13c 100644
276--- a/libgcc/config/microblaze/crtn.S
277+++ b/libgcc/config/microblaze/crtn.S
278@@ -29,7 +29,19 @@
279 .section .note.GNU-stack,"",%progbits
280 .previous
281 #endif
282+#ifdef __arch64__
283+ .section .init, "ax"
284+ ll r15, r0, r1
285+ addlik r1, r1, 32
286+ rtsd r15, 8
287+ nop
288
289+ .section .fini, "ax"
290+ ll r15, r0, r1
291+ addlik r1, r1, 32
292+ rtsd r15, 8
293+ nop
294+#else
295 .section .init, "ax"
296 lw r15, r0, r1
297 rtsd r15, 8
298@@ -39,3 +51,4 @@
299 lw r15, r0, r1
300 rtsd r15, 8
301 addik r1, r1, 16
302+#endif
303--
3042.37.1 (Apple Git-137.1)
305
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0034-Added-double-arith-instructions.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0034-Added-double-arith-instructions.patch
deleted file mode 100644
index 7bd3001d..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0034-Added-double-arith-instructions.patch
+++ /dev/null
@@ -1,135 +0,0 @@
1From 80c16e39bdf8643184c353e34f146dc8601c2c1e Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 9 Oct 2018 10:07:08 +0530
4Subject: [PATCH 34/53] -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 5a950b49591..5506aee7be5 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 47b869b9303..3522afd4831 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.37.1 (Apple Git-137.1)
135
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0035-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0035-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch
deleted file mode 100644
index 89018aae..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0035-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From 455216291580ca22767433eec11941c5f2471892 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 12 Oct 2018 16:07:36 +0530
4Subject: [PATCH 35/53] 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 5506aee7be5..4a372f8fd3f 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.37.1 (Apple Git-137.1)
37
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0036-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0036-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch
deleted file mode 100644
index 0c27d69f..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0036-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch
+++ /dev/null
@@ -1,256 +0,0 @@
1From b8c468f1bd467213083b59b54af100ee0c6dea9e Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sat, 13 Oct 2018 21:12:43 +0530
4Subject: [PATCH 36/53] 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 14829ec6701..b464deed481 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 b8f2e37809d..e0fbd91e766 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 f48fcf8270c..657668ef826 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 2c321f94b09..fc6a4b5a248 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 fbe942dc5f2..b68ba7a5ea6 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.37.1 (Apple Git-137.1)
256
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0037-extending-the-Dwarf-support-to-64bit-Microblaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0037-extending-the-Dwarf-support-to-64bit-Microblaze.patch
deleted file mode 100644
index 2eab03ec..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0037-extending-the-Dwarf-support-to-64bit-Microblaze.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1From 2bc476e64f1bacc27874c152340c004c17bfd942 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 15 Oct 2018 12:00:10 +0530
4Subject: [PATCH 37/53] 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 ac4ea43a706..56dfc2a3824 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.37.1 (Apple Git-137.1)
25
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0038-fixing-the-typo-errors-in-umodsi3-file.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0038-fixing-the-typo-errors-in-umodsi3-file.patch
deleted file mode 100644
index 4d6be758..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0038-fixing-the-typo-errors-in-umodsi3-file.patch
+++ /dev/null
@@ -1,29 +0,0 @@
1From 1e0eaa1330f24d4989af6326ce1af4f613ea0d89 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 16 Oct 2018 07:55:46 +0530
4Subject: [PATCH 38/53] 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 b68ba7a5ea6..03be6df1fc6 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.37.1 (Apple Git-137.1)
29
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0039-fixing-the-32bit-LTO-related-issue9-1014024.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0039-fixing-the-32bit-LTO-related-issue9-1014024.patch
deleted file mode 100644
index 1a5a0ef7..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0039-fixing-the-32bit-LTO-related-issue9-1014024.patch
+++ /dev/null
@@ -1,68 +0,0 @@
1From 7dbdc5ba78c9237b0a367ca61f448cf3a0277ea6 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Wed, 17 Oct 2018 16:56:14 +0530
4Subject: [PATCH 39/53] 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 56dfc2a3824..c48b6de0d58 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.37.1 (Apple Git-137.1)
68
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0040-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0040-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch
deleted file mode 100644
index 7c6f9008..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0040-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1From a21a41a0c574b807c7e7edaa7051a0f7395d8142 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 19 Oct 2018 14:26:25 +0530
4Subject: [PATCH 40/53] 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 e0fbd91e766..3ec17685e51 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.37.1 (Apple Git-137.1)
25
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0041-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0041-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch
deleted file mode 100644
index 9cec7be9..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0041-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch
+++ /dev/null
@@ -1,29 +0,0 @@
1From 5f799ea01bae0573a44f3fefa825861e99f4e30a Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 24 Oct 2018 18:31:04 +0530
4Subject: [PATCH 41/53] [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 4a372f8fd3f..5a964e70d1f 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.37.1 (Apple Git-137.1)
29
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0042-fixing-the-long-long-long-mingw-toolchain-issue.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0042-fixing-the-long-long-long-mingw-toolchain-issue.patch
deleted file mode 100644
index 8836d0e7..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0042-fixing-the-long-long-long-mingw-toolchain-issue.patch
+++ /dev/null
@@ -1,59 +0,0 @@
1From 9c37b9690ec2c6290095209c039725f235537379 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 29 Nov 2018 17:55:08 +0530
4Subject: [PATCH 42/53] 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 0ced155340d..3f9805dfe0a 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 5a964e70d1f..f509bd5e665 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@@ -1264,7 +1264,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@@ -1298,7 +1298,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.37.1 (Apple Git-137.1)
59
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0043-Fix-the-MB-64-bug-of-handling-QI-objects.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0043-Fix-the-MB-64-bug-of-handling-QI-objects.patch
deleted file mode 100644
index c8caff29..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0043-Fix-the-MB-64-bug-of-handling-QI-objects.patch
+++ /dev/null
@@ -1,47 +0,0 @@
1From 0ed24f5a2e6e47f5d13896793ab2c6ea89e8c8e6 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 14 Mar 2019 18:11:04 +0530
4Subject: [PATCH 43/53] 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 f509bd5e665..27436c0f660 100644
12--- a/gcc/config/microblaze/microblaze.md
13+++ b/gcc/config/microblaze/microblaze.md
14@@ -2345,11 +2345,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@@ -2365,11 +2365,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.37.1 (Apple Git-137.1)
47
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0044-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0044-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
deleted file mode 100644
index e0d7df3d..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0044-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
+++ /dev/null
@@ -1,87 +0,0 @@
1From e8286e00f939486dde52e9475bc9cca0aa025a42 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Fri, 29 Mar 2019 12:08:39 +0530
4Subject: [PATCH 44/53] [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 27436c0f660..4b9acddb1f1 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.37.1 (Apple Git-137.1)
87
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0045-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0045-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
deleted file mode 100644
index 770d0f70..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0045-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
+++ /dev/null
@@ -1,466 +0,0 @@
1From 29c33e35373d7dc52e43162dce38a3ec0e350db3 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 17 Apr 2019 12:36:16 +0530
4Subject: [PATCH 45/53] [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 b464deed481..ceeed6be1f4 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 3ec17685e51..637b06c09a3 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 657668ef826..6be75dc95e8 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 fc6a4b5a248..f8ce88bd8b7 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 03be6df1fc6..3be3658f7a2 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.37.1 (Apple Git-137.1)
466
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0046-Patch-microblaze-MB-64-removal-of-barrel-shift-instr.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0046-Patch-microblaze-MB-64-removal-of-barrel-shift-instr.patch
deleted file mode 100644
index 29a7b4eb..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0046-Patch-microblaze-MB-64-removal-of-barrel-shift-instr.patch
+++ /dev/null
@@ -1,477 +0,0 @@
1From 39589348962a2e0453ad49118b6bc3dd8a7b1bb5 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 15:59:12 +0530
4Subject: [PATCH 46/53] [Patch, microblaze]: MB-64 removal of barrel-shift
5 instructions from default By default MB-64 is generatting
6 barrel-shift instructions. It has been removed from default.
7 Barrel-shift instructions will be generated only if barrel-shifter is
8 enabled. Similarly to double instructions as well.
9
10 Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11---
12 gcc/config/microblaze/microblaze.cc | 2 +-
13 gcc/config/microblaze/microblaze.md | 269 ++++++++++++++++++++++++++--
14 2 files changed, 252 insertions(+), 19 deletions(-)
15
16diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
17index 7a08390a027..3ee3996a38d 100644
18--- a/gcc/config/microblaze/microblaze.cc
19+++ b/gcc/config/microblaze/microblaze.cc
20@@ -3871,7 +3871,7 @@ microblaze_expand_divide (rtx operands[])
21 emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
22
23 if (TARGET_MB_64) {
24- emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
25+ emit_insn (gen_ashldi3 (regt1, operands[1], GEN_INT(4)));
26 emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
27 }
28 else {
29diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
30index 4b9acddb1f1..3695e9e101d 100644
31--- a/gcc/config/microblaze/microblaze.md
32+++ b/gcc/config/microblaze/microblaze.md
33@@ -547,7 +547,7 @@
34 [(set (match_operand:DF 0 "register_operand" "=d")
35 (plus:DF (match_operand:DF 1 "register_operand" "d")
36 (match_operand:DF 2 "register_operand" "d")))]
37- "TARGET_MB_64"
38+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
39 "dadd\t%0,%1,%2"
40 [(set_attr "type" "fadd")
41 (set_attr "mode" "DF")
42@@ -557,7 +557,7 @@
43 [(set (match_operand:DF 0 "register_operand" "=d")
44 (minus:DF (match_operand:DF 1 "register_operand" "d")
45 (match_operand:DF 2 "register_operand" "d")))]
46- "TARGET_MB_64"
47+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
48 "drsub\t%0,%2,%1"
49 [(set_attr "type" "frsub")
50 (set_attr "mode" "DF")
51@@ -567,7 +567,7 @@
52 [(set (match_operand:DF 0 "register_operand" "=d")
53 (mult:DF (match_operand:DF 1 "register_operand" "d")
54 (match_operand:DF 2 "register_operand" "d")))]
55- "TARGET_MB_64"
56+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
57 "dmul\t%0,%1,%2"
58 [(set_attr "type" "fmul")
59 (set_attr "mode" "DF")
60@@ -577,7 +577,7 @@
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+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
66 "ddiv\t%0,%2,%1"
67 [(set_attr "type" "fdiv")
68 (set_attr "mode" "DF")
69@@ -587,7 +587,7 @@
70 (define_insn "sqrtdf2"
71 [(set (match_operand:DF 0 "register_operand" "=d")
72 (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
73- "TARGET_MB_64"
74+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
75 "dsqrt\t%0,%1"
76 [(set_attr "type" "fsqrt")
77 (set_attr "mode" "DF")
78@@ -596,7 +596,7 @@
79 (define_insn "floatdidf2"
80 [(set (match_operand:DF 0 "register_operand" "=d")
81 (float:DF (match_operand:DI 1 "register_operand" "d")))]
82- "TARGET_MB_64"
83+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
84 "dbl\t%0,%1"
85 [(set_attr "type" "fcvt")
86 (set_attr "mode" "DF")
87@@ -605,7 +605,7 @@
88 (define_insn "fix_truncdfdi2"
89 [(set (match_operand:DI 0 "register_operand" "=d")
90 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
91- "TARGET_MB_64"
92+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
93 "dlong\t%0,%1"
94 [(set_attr "type" "fcvt")
95 (set_attr "mode" "DI")
96@@ -1299,6 +1299,34 @@
97 (set_attr "mode" "DI")
98 (set_attr "length" "4")])
99
100+(define_insn "*movdi_internal2_bshift"
101+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
102+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
103+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
104+ {
105+ switch (which_alternative)
106+ {
107+ case 0:
108+ return "addlk\t%0,%1,r0";
109+ case 1:
110+ case 2:
111+ if (GET_CODE (operands[1]) == CONST_INT &&
112+ (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
113+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
114+ else
115+ return "addlik\t%0,r0,%1";
116+ case 3:
117+ case 4:
118+ return "ll%i1\t%0,%1";
119+ case 5:
120+ case 6:
121+ return "sl%i0\t%z1,%0";
122+ }
123+ }
124+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
125+ (set_attr "mode" "DI")
126+ (set_attr "length" "4,4,12,4,8,4,8")])
127+
128 (define_insn "*movdi_internal2"
129 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
130 (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
131@@ -1312,7 +1340,15 @@
132 case 2:
133 if (GET_CODE (operands[1]) == CONST_INT &&
134 (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
135- return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
136+ {
137+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
138+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
139+ output_asm_insn ("addlik\t%2,r0,32", operands);
140+ output_asm_insn ("addlik\t%2,%2,-1", operands);
141+ output_asm_insn ("beaneid\t%2,.-8", operands);
142+ output_asm_insn ("addlk\t%0,%0,%0", operands);
143+ return "addlik\t%0,%0,%j1 #li => la";
144+ }
145 else
146 return "addlik\t%0,r0,%1";
147 case 3:
148@@ -1387,7 +1423,7 @@
149 (define_insn "movdi_long_int"
150 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
151 (match_operand:DI 1 "general_operand" "i"))]
152- "TARGET_MB_64"
153+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
154 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
155 [(set_attr "type" "no_delay_arith")
156 (set_attr "mode" "DI")
157@@ -1654,6 +1690,33 @@
158 ;; movdf_internal
159 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
160 ;;
161+(define_insn "*movdf_internal_64_bshift"
162+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
163+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
164+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
165+ {
166+ switch (which_alternative)
167+ {
168+ case 0:
169+ return "addlk\t%0,%1,r0";
170+ case 1:
171+ return "addlk\t%0,r0,r0";
172+ case 2:
173+ case 4:
174+ return "ll%i1\t%0,%1";
175+ case 3:
176+ {
177+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
178+ }
179+ case 5:
180+ return "sl%i0\t%1,%0";
181+ }
182+ gcc_unreachable ();
183+ }
184+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
185+ (set_attr "mode" "DF")
186+ (set_attr "length" "4,4,4,16,4,4")])
187+
188 (define_insn "*movdf_internal_64"
189 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
190 (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
191@@ -1670,7 +1733,13 @@
192 return "ll%i1\t%0,%1";
193 case 3:
194 {
195- return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
196+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
197+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
198+ output_asm_insn ("addlik\t%2,r0,32", operands);
199+ output_asm_insn ("addlik\t%2,%2,-1", operands);
200+ output_asm_insn ("beaneid\t%2,.-8", operands);
201+ output_asm_insn ("addlk\t%0,%0,%0", operands);
202+ return "addlik\t%0,%0,%j1 #li => la";
203 }
204 case 5:
205 return "sl%i0\t%1,%0";
206@@ -1790,11 +1859,21 @@
207 "TARGET_MB_64"
208 {
209 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
210-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
211+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
212 {
213 emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
214 DONE;
215 }
216+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
217+ {
218+ emit_insn(gen_ashldi3_const (operands[0], operands[1],operands[2]));
219+ DONE;
220+ }
221+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
222+ {
223+ emit_insn(gen_ashldi3_reg (operands[0], operands[1],operands[2]));
224+ DONE;
225+ }
226 else
227 FAIL;
228 }
229@@ -1804,7 +1883,7 @@ else
230 [(set (match_operand:DI 0 "register_operand" "=d,d")
231 (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
232 (match_operand:DI 2 "arith_operand" "I,d")))]
233- "TARGET_MB_64"
234+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
235 "@
236 bsllli\t%0,%1,%2
237 bslll\t%0,%1,%2"
238@@ -1812,6 +1891,51 @@ else
239 (set_attr "mode" "DI,DI")
240 (set_attr "length" "4,4")]
241 )
242+
243+(define_insn "ashldi3_const"
244+ [(set (match_operand:DI 0 "register_operand" "=&d")
245+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
246+ (match_operand:DI 2 "immediate_operand" "I")))]
247+ "TARGET_MB_64"
248+ {
249+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
250+
251+ output_asm_insn ("orli\t%3,r0,%2", operands);
252+ if (REGNO (operands[0]) != REGNO (operands[1]))
253+ output_asm_insn ("addlk\t%0,%1,r0", operands);
254+
255+ output_asm_insn ("addlik\t%3,%3,-1", operands);
256+ output_asm_insn ("beaneid\t%3,.-8", operands);
257+ return "addlk\t%0,%0,%0";
258+ }
259+ [(set_attr "type" "multi")
260+ (set_attr "mode" "DI")
261+ (set_attr "length" "20")]
262+)
263+
264+(define_insn "ashldi3_reg"
265+ [(set (match_operand:DI 0 "register_operand" "=&d")
266+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
267+ (match_operand:DI 2 "register_operand" "d")))]
268+ "TARGET_MB_64"
269+ {
270+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
271+ output_asm_insn ("andli\t%3,%2,31", operands);
272+ if (REGNO (operands[0]) != REGNO (operands[1]))
273+ output_asm_insn ("addlk\t%0,r0,%1", operands);
274+ /* Exit the loop if zero shift. */
275+ output_asm_insn ("beaeqid\t%3,.+24", operands);
276+ /* Emit the loop. */
277+ output_asm_insn ("addlk\t%0,%0,r0", operands);
278+ output_asm_insn ("addlik\t%3,%3,-1", operands);
279+ output_asm_insn ("beaneid\t%3,.-8", operands);
280+ return "addlk\t%0,%0,%0";
281+ }
282+ [(set_attr "type" "multi")
283+ (set_attr "mode" "DI")
284+ (set_attr "length" "28")]
285+)
286+
287 ;; The following patterns apply when there is no barrel shifter present
288
289 (define_insn "*ashlsi3_with_mul_delay"
290@@ -1945,11 +2069,21 @@ else
291 "TARGET_MB_64"
292 {
293 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
294-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
295+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
296 {
297 emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
298 DONE;
299 }
300+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
301+ {
302+ emit_insn(gen_ashrdi3_const (operands[0], operands[1],operands[2]));
303+ DONE;
304+ }
305+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
306+ {
307+ emit_insn(gen_ashrdi3_reg (operands[0], operands[1],operands[2]));
308+ DONE;
309+ }
310 else
311 FAIL;
312 }
313@@ -1959,7 +2093,7 @@ else
314 [(set (match_operand:DI 0 "register_operand" "=d,d")
315 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
316 (match_operand:DI 2 "arith_operand" "I,d")))]
317- "TARGET_MB_64"
318+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
319 "@
320 bslrai\t%0,%1,%2
321 bslra\t%0,%1,%2"
322@@ -1967,6 +2101,51 @@ else
323 (set_attr "mode" "DI,DI")
324 (set_attr "length" "4,4")]
325 )
326+
327+(define_insn "ashrdi3_const"
328+ [(set (match_operand:DI 0 "register_operand" "=&d")
329+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
330+ (match_operand:DI 2 "immediate_operand" "I")))]
331+ "TARGET_MB_64"
332+ {
333+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
334+
335+ output_asm_insn ("orli\t%3,r0,%2", operands);
336+ if (REGNO (operands[0]) != REGNO (operands[1]))
337+ output_asm_insn ("addlk\t%0,%1,r0", operands);
338+
339+ output_asm_insn ("addlik\t%3,%3,-1", operands);
340+ output_asm_insn ("beaneid\t%3,.-8", operands);
341+ return "srla\t%0,%0";
342+ }
343+ [(set_attr "type" "arith")
344+ (set_attr "mode" "DI")
345+ (set_attr "length" "20")]
346+)
347+
348+(define_insn "ashrdi3_reg"
349+ [(set (match_operand:DI 0 "register_operand" "=&d")
350+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
351+ (match_operand:DI 2 "register_operand" "d")))]
352+ "TARGET_MB_64"
353+ {
354+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
355+ output_asm_insn ("andli\t%3,%2,31", operands);
356+ if (REGNO (operands[0]) != REGNO (operands[1]))
357+ output_asm_insn ("addlk\t%0,r0,%1", operands);
358+ /* Exit the loop if zero shift. */
359+ output_asm_insn ("beaeqid\t%3,.+24", operands);
360+ /* Emit the loop. */
361+ output_asm_insn ("addlk\t%0,%0,r0", operands);
362+ output_asm_insn ("addlik\t%3,%3,-1", operands);
363+ output_asm_insn ("beaneid\t%3,.-8", operands);
364+ return "srla\t%0,%0";
365+ }
366+ [(set_attr "type" "multi")
367+ (set_attr "mode" "DI")
368+ (set_attr "length" "28")]
369+)
370+
371 (define_expand "ashrsi3"
372 [(set (match_operand:SI 0 "register_operand" "=&d")
373 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
374@@ -2084,11 +2263,21 @@ else
375 "TARGET_MB_64"
376 {
377 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
378-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
379+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
380 {
381 emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
382 DONE;
383 }
384+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
385+ {
386+ emit_insn(gen_lshrdi3_const (operands[0], operands[1],operands[2]));
387+ DONE;
388+ }
389+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
390+ {
391+ emit_insn(gen_lshrdi3_reg (operands[0], operands[1],operands[2]));
392+ DONE;
393+ }
394 else
395 FAIL;
396 }
397@@ -2098,7 +2287,7 @@ else
398 [(set (match_operand:DI 0 "register_operand" "=d,d")
399 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
400 (match_operand:DI 2 "arith_operand" "I,d")))]
401- "TARGET_MB_64"
402+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
403 "@
404 bslrli\t%0,%1,%2
405 bslrl\t%0,%1,%2"
406@@ -2107,6 +2296,50 @@ else
407 (set_attr "length" "4,4")]
408 )
409
410+(define_insn "lshrdi3_const"
411+ [(set (match_operand:DI 0 "register_operand" "=&d")
412+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
413+ (match_operand:DI 2 "immediate_operand" "I")))]
414+ "TARGET_MB_64"
415+ {
416+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
417+
418+ output_asm_insn ("orli\t%3,r0,%2", operands);
419+ if (REGNO (operands[0]) != REGNO (operands[1]))
420+ output_asm_insn ("addlk\t%0,%1,r0", operands);
421+
422+ output_asm_insn ("addlik\t%3,%3,-1", operands);
423+ output_asm_insn ("beaneid\t%3,.-8", operands);
424+ return "srll\t%0,%0";
425+ }
426+ [(set_attr "type" "multi")
427+ (set_attr "mode" "DI")
428+ (set_attr "length" "20")]
429+)
430+
431+(define_insn "lshrdi3_reg"
432+ [(set (match_operand:DI 0 "register_operand" "=&d")
433+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
434+ (match_operand:DI 2 "register_operand" "d")))]
435+ "TARGET_MB_64"
436+ {
437+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
438+ output_asm_insn ("andli\t%3,%2,31", operands);
439+ if (REGNO (operands[0]) != REGNO (operands[1]))
440+ output_asm_insn ("addlk\t%0,r0,%1", operands);
441+ /* Exit the loop if zero shift. */
442+ output_asm_insn ("beaeqid\t%3,.+24", operands);
443+ /* Emit the loop. */
444+ output_asm_insn ("addlk\t%0,%0,r0", operands);
445+ output_asm_insn ("addlik\t%3,%3,-1", operands);
446+ output_asm_insn ("beaneid\t%3,.-8", operands);
447+ return "srll\t%0,%0";
448+ }
449+ [(set_attr "type" "multi")
450+ (set_attr "mode" "SI")
451+ (set_attr "length" "28")]
452+)
453+
454 (define_expand "lshrsi3"
455 [(set (match_operand:SI 0 "register_operand" "=&d")
456 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
457@@ -2233,7 +2466,7 @@ else
458 (eq:DI
459 (match_operand:DI 1 "register_operand" "d")
460 (match_operand:DI 2 "register_operand" "d")))]
461- "TARGET_MB_64"
462+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
463 "pcmpleq\t%0,%1,%2"
464 [(set_attr "type" "arith")
465 (set_attr "mode" "DI")
466@@ -2245,7 +2478,7 @@ else
467 (ne:DI
468 (match_operand:DI 1 "register_operand" "d")
469 (match_operand:DI 2 "register_operand" "d")))]
470- "TARGET_MB_64"
471+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
472 "pcmplne\t%0,%1,%2"
473 [(set_attr "type" "arith")
474 (set_attr "mode" "DI")
475--
4762.37.1 (Apple Git-137.1)
477
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0047-Added-new-MB-64-single-register-arithmetic-instructi.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0047-Added-new-MB-64-single-register-arithmetic-instructi.patch
deleted file mode 100644
index 774fad5a..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0047-Added-new-MB-64-single-register-arithmetic-instructi.patch
+++ /dev/null
@@ -1,107 +0,0 @@
1From e32334b0f8a4c9532975001ffab33e86469ea4e1 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Fri, 23 Aug 2019 16:16:53 +0530
4Subject: [PATCH 47/53] 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 3695e9e101d..85c1ab45994 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.37.1 (Apple Git-137.1)
107
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0048-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0048-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch
deleted file mode 100644
index a442bf0f..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0048-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch
+++ /dev/null
@@ -1,44 +0,0 @@
1From f5f262b196de197b7e9ece8cc08c8715f953857f Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 26 Aug 2019 15:55:22 +0530
4Subject: [PATCH 48/53] [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 3f9805dfe0a..91653f36f52 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 85c1ab45994..0ac6e1480e6 100644
30--- a/gcc/config/microblaze/microblaze.md
31+++ b/gcc/config/microblaze/microblaze.md
32@@ -1332,8 +1332,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.37.1 (Apple Git-137.1)
44
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0049-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0049-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch
deleted file mode 100644
index 5732000d..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0049-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch
+++ /dev/null
@@ -1,76 +0,0 @@
1From d45405d05a1f9079f7db86ba60dcd30d358613d4 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 16:06:10 +0530
4Subject: [PATCH 49/53] [Patch, microblaze]: Fix Compiler crash with
5 -freg-struct-return This patch fixes a bug in MB GCC regarding the
6 passing struct values in registers. Currently we are only handling SImode
7 With this patch all other modes are handled properly
8
9 Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10---
11 gcc/config/microblaze/microblaze.cc | 11 ++++++++++-
12 gcc/config/microblaze/microblaze.h | 19 -------------------
13 2 files changed, 10 insertions(+), 20 deletions(-)
14
15diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
16index 3ee3996a38d..4668a81d060 100644
17--- a/gcc/config/microblaze/microblaze.cc
18+++ b/gcc/config/microblaze/microblaze.cc
19@@ -3909,7 +3909,16 @@ microblaze_function_value (const_tree valtype,
20 const_tree func ATTRIBUTE_UNUSED,
21 bool outgoing ATTRIBUTE_UNUSED)
22 {
23- return LIBCALL_VALUE (TYPE_MODE (valtype));
24+ return gen_rtx_REG (TYPE_MODE (valtype), GP_RETURN);
25+}
26+
27+#undef TARGET_LIBCALL_VALUE
28+#define TARGET_LIBCALL_VALUE microblaze_libcall_value
29+
30+rtx
31+microblaze_libcall_value (machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED)
32+{
33+ return gen_rtx_REG (mode, GP_RETURN);
34 }
35
36 /* Implement TARGET_SCHED_ADJUST_COST. */
37diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
38index c48b6de0d58..730ad87b13b 100644
39--- a/gcc/config/microblaze/microblaze.h
40+++ b/gcc/config/microblaze/microblaze.h
41@@ -266,13 +266,6 @@ extern enum pipeline_type microblaze_pipe;
42
43 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
44
45-#ifndef __arch64__
46-#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
47- if (GET_MODE_CLASS (MODE) == MODE_INT \
48- && GET_MODE_SIZE (MODE) < 4) \
49- (MODE) = SImode;
50-#endif
51-
52 /* Standard register usage. */
53
54 /* On the MicroBlaze, we have 32 integer registers */
55@@ -471,18 +464,6 @@ extern struct microblaze_frame_info current_frame_info;
56
57 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
58
59-#ifdef __aarch64__
60-#define LIBCALL_VALUE(MODE) \
61- gen_rtx_REG (MODE,GP_RETURN)
62-#else
63-#define LIBCALL_VALUE(MODE) \
64- gen_rtx_REG ( \
65- ((GET_MODE_CLASS (MODE) != MODE_INT \
66- || GET_MODE_SIZE (MODE) >= 4) \
67- ? (MODE) \
68- : SImode), GP_RETURN)
69-#endif
70-
71 /* 1 if N is a possible register number for a function value.
72 On the MicroBlaze, R2 R3 are the only register thus used.
73 Currently, R2 are only implemented here (C has no complex type) */
74--
752.37.1 (Apple Git-137.1)
76
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0050-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0050-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
deleted file mode 100644
index ed48daf7..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0050-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
+++ /dev/null
@@ -1,50 +0,0 @@
1From a64afc59e82703f40d04d4d7126038811a195467 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 8 May 2019 14:12:03 +0530
4Subject: [PATCH 50/53] [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 Mahesh Bodapati <mbodapat@xilinx.com>
14Conflicts:
15 gcc/common/config/microblaze/microblaze-common.c
16
17Conflicts:
18 gcc/common/config/microblaze/microblaze-common.c
19---
20 gcc/common/config/microblaze/microblaze-common.cc | 13 +++++++++++++
21 1 file changed, 13 insertions(+)
22
23diff --git a/gcc/common/config/microblaze/microblaze-common.cc b/gcc/common/config/microblaze/microblaze-common.cc
24index 21b35f55b92..137332ded25 100644
25--- a/gcc/common/config/microblaze/microblaze-common.cc
26+++ b/gcc/common/config/microblaze/microblaze-common.cc
27@@ -24,7 +24,20 @@
28 #include "common/common-target.h"
29 #include "common/common-target-def.h"
30
31+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
32+static const struct default_options microblaze_option_optimization_table[] =
33+ {
34+ /* Turn off ivopts by default. It messes up cse.
35+ { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, */
36+ { OPT_LEVELS_ALL, OPT_fivopts, NULL, 0 },
37+ { OPT_LEVELS_NONE, 0, NULL, 0 }
38+ };
39+
40+
41 #undef TARGET_DEFAULT_TARGET_FLAGS
42 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
43
44+#undef TARGET_OPTION_OPTIMIZATION_TABLE
45+#define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
46+
47 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
48--
492.37.1 (Apple Git-137.1)
50
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0051-Patch-microblaze-Reducing-Stack-space-for-arguments.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0051-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
deleted file mode 100644
index b9575eac..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0051-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
+++ /dev/null
@@ -1,189 +0,0 @@
1From 09e10c513f8970f4d2402244b7ac69ecd33b4c04 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 16:35:00 +0530
4Subject: [PATCH 51/53] [Patch, microblaze]: Reducing Stack space for arguments
5
6 Currently in Microblaze target stack space for arguments in register is being
7 allocated even if there are no arguments in the function.
8 This patch will optimize the extra 24 bytes that are being allocated.
9
10 Signed-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.cc | 130 ++++++++++++++++++++++
15 gcc/config/microblaze/microblaze.h | 4 +-
16 3 files changed, 133 insertions(+), 2 deletions(-)
17
18diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
19index 7f575c2adec..bd594699940 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.cc. */
30diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
31index 4668a81d060..24ac215b6d5 100644
32--- a/gcc/config/microblaze/microblaze.cc
33+++ b/gcc/config/microblaze/microblaze.cc
34@@ -2081,6 +2081,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
171diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
172index 730ad87b13b..dfacd080b6d 100644
173--- a/gcc/config/microblaze/microblaze.h
174+++ b/gcc/config/microblaze/microblaze.h
175@@ -447,9 +447,9 @@ extern struct microblaze_frame_info current_frame_info;
176 #define ARG_POINTER_CFA_OFFSET(FNDECL) 0
177 #define DWARF_CIE_DATA_ALIGNMENT -1
178
179-#define REG_PARM_STACK_SPACE(FNDECL) (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD)
180+#define REG_PARM_STACK_SPACE(FNDECL) microblaze_reg_parm_stack_space(FNDECL)
181
182-#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
183+#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
184
185 #define STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
186
187--
1882.37.1 (Apple Git-137.1)
189
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0052-Patch-MicroBlaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0052-Patch-MicroBlaze.patch
deleted file mode 100644
index d504a092..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0052-Patch-MicroBlaze.patch
+++ /dev/null
@@ -1,73 +0,0 @@
1From fe2781d189493dc82a3714b48bbc12c6bd5cdfd0 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 16:38:43 +0530
4Subject: [PATCH 52/53] [Patch,MicroBlaze] : If we use break_handler
5 attribute then interrupt vector call happened to break_handler instead of
6 interrupt_handler. this fix will resolve the issue CR-1081780. This
7 fix will not change the behavior of compiler unless there is a usage of
8 break_handler attribute. signed-off-by : Mahesh Bodapati
9 <mbodapat@xilinx.com>
10
11---
12 gcc/config/microblaze/microblaze.cc | 13 +++++--------
13 1 file changed, 5 insertions(+), 8 deletions(-)
14
15diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
16index 24ac215b6d5..66d62f6f909 100644
17--- a/gcc/config/microblaze/microblaze.cc
18+++ b/gcc/config/microblaze/microblaze.cc
19@@ -2020,7 +2020,7 @@ microblaze_save_volatiles (tree func)
20 int
21 microblaze_is_interrupt_variant (void)
22 {
23- return (interrupt_handler || fast_interrupt);
24+ return (interrupt_handler || fast_interrupt || break_handler);
25 }
26 int
27 microblaze_is_break_handler (void)
28@@ -2059,7 +2059,7 @@ microblaze_must_save_register (int regno)
29 {
30 if (df_regs_ever_live_p (regno)
31 || regno == MB_ABI_MSR_SAVE_REG
32- || ((interrupt_handler || fast_interrupt)
33+ || ((interrupt_handler || fast_interrupt || break_handler)
34 && (regno == MB_ABI_ASM_TEMP_REGNUM
35 || regno == MB_ABI_EXCEPTION_RETURN_ADDR_REGNUM)))
36 return 1;
37@@ -2275,9 +2275,6 @@ compute_frame_size (HOST_WIDE_INT size)
38 fast_interrupt =
39 microblaze_fast_interrupt_function_p (current_function_decl);
40 save_volatiles = microblaze_save_volatiles (current_function_decl);
41- if (break_handler)
42- interrupt_handler = break_handler;
43-
44 gp_reg_size = 0;
45 mask = 0;
46 var_size = size;
47@@ -3237,7 +3234,7 @@ microblaze_expand_prologue (void)
48 gen_rtx_PLUS (Pmode, stack_pointer_rtx,
49 const0_rtx));
50
51- if (interrupt_handler)
52+ if (interrupt_handler || break_handler)
53 /* Do not optimize in flow analysis. */
54 MEM_VOLATILE_P (mem_rtx) = 1;
55
56@@ -3348,12 +3345,12 @@ microblaze_expand_epilogue (void)
57 a load-use stall cycle :) This is also important to handle alloca.
58 (See comments for if (frame_pointer_needed) below. */
59
60- if (!crtl->is_leaf || interrupt_handler)
61+ if (!crtl->is_leaf || interrupt_handler || break_handler)
62 {
63 mem_rtx =
64 gen_rtx_MEM (Pmode,
65 gen_rtx_PLUS (Pmode, stack_pointer_rtx, const0_rtx));
66- if (interrupt_handler)
67+ if (interrupt_handler || break_handler)
68 /* Do not optimize in flow analysis. */
69 MEM_VOLATILE_P (mem_rtx) = 1;
70 reg_rtx = gen_rtx_REG (Pmode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
71--
722.37.1 (Apple Git-137.1)
73
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0053-patch-microblaze64-Add-Zero_extended-instructions.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0053-patch-microblaze64-Add-Zero_extended-instructions.patch
deleted file mode 100644
index 6b3f4ddd..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/0053-patch-microblaze64-Add-Zero_extended-instructions.patch
+++ /dev/null
@@ -1,58 +0,0 @@
1From 6c2e67237a12cecfd8c0575fd17314d3024943fc Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 16:45:41 +0530
4Subject: [PATCH 53/53] [patch, microblaze64]: Add Zero_extended instructions
5
6 Due to latest changes in GCC-10.2 MB64 perforamance has reduced
7 We have added zero_extended instructions to get rid of left shift
8 and right shift loops
9
10 [CR/TSR]: TSR-974519
11
12 Signed-off-by: Nagaraju Mekala<nmekala@xilinx.com>
13 Mahesh Bodapati<mbodapat@xilinx.com>
14---
15 gcc/config/microblaze/microblaze.md | 27 +++++++++++++++++++++++++++
16 1 file changed, 27 insertions(+)
17
18diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
19index 0ac6e1480e6..7a7c70d607b 100644
20--- a/gcc/config/microblaze/microblaze.md
21+++ b/gcc/config/microblaze/microblaze.md
22@@ -1191,6 +1191,33 @@
23 (set_attr "mode" "SI,SI,SI")
24 (set_attr "length" "4,4,8")])
25
26+(define_insn "zero_extendhidi2"
27+ [(set (match_operand:DI 0 "register_operand" "=d")
28+ (zero_extend:DI (match_operand:HI 1 "register_operand" "d")))]
29+ "TARGET_MB_64"
30+ "andli\t%0,%1,0xffff"
31+ [(set_attr "type" "no_delay_arith")
32+ (set_attr "mode" "DI")
33+ (set_attr "length" "8")])
34+
35+(define_insn "zero_extendsidi2"
36+ [(set (match_operand:DI 0 "register_operand" "=d")
37+ (zero_extend:DI (match_operand:SI 1 "register_operand" "d")))]
38+ "TARGET_MB_64"
39+ "andli\t%0,%1,0xffffffff"
40+ [(set_attr "type" "no_delay_arith")
41+ (set_attr "mode" "DI")
42+ (set_attr "length" "8")])
43+
44+(define_insn "zero_extendqidi2"
45+ [(set (match_operand:DI 0 "register_operand" "=d")
46+ (zero_extend:DI (match_operand:QI 1 "register_operand" "d")))]
47+ "TARGET_MB_64"
48+ "andli\t%0,%1,0x00ff"
49+ [(set_attr "type" "no_delay_arith")
50+ (set_attr "mode" "DI")
51+ (set_attr "length" "8")])
52+
53 ;;----------------------------------------------------------------
54 ;; Sign extension
55 ;;----------------------------------------------------------------
56--
572.37.1 (Apple Git-137.1)
58
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/microblaze-mulitlib-hack.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/microblaze-mulitlib-hack.patch
deleted file mode 100644
index af8ebf3b..00000000
--- a/meta-microblaze/recipes-devtools/gcc/gcc-12/microblaze-mulitlib-hack.patch
+++ /dev/null
@@ -1,58 +0,0 @@
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