* [Patch, microblaze]: Add MicroBlaze Little Endian Support
@ 2013-01-21 5:47 David Holsgrove
2013-01-25 0:40 ` David Holsgrove
0 siblings, 1 reply; 3+ messages in thread
From: David Holsgrove @ 2013-01-21 5:47 UTC (permalink / raw)
To: gcc-patches
Cc: Michael Eager, John Williams, Edgar E. Iglesias, Vinod Kathail,
Vidhumouli Hunsigida, Nagaraju Mekala, Tom Shui
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
gcc/Changelog
2013-01-21 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* gcc/config.gcc (microblaze*-linux*): Add TARGET_BIG_ENDIAN_DEFAULT
gcc/config.gcc (microblaze*-*-elf): Likewise
gcc/config.gcc (microblaze*-*-*): Likewise
* gcc/config/microblaze/linux.h: Add -mbig-endian / -mlittle-endian
to LINK_SPEC
* gcc/config/microblaze/microblaze-c.c: Add builtin defines for
_LITTLE_ENDIAN and _BIG_ENDIAN
* gcc/config/microblaze/microblaze.h: Add TARGET_ENDIAN_DEFAULT
and add to TARGET_DEFAULT flags.
Expand ASM_SPEC and LINK_SPEC.
Update BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN
* gcc/config/microblaze/microblaze.md: Update extendsidi2 and
movdi_internal instructions to use low-order / high-order reg
print_operands
* gcc/config/microblaze/microblaze.opt: Add mbig-endian and
mlittle-endian options and inversemask / mask of LITTLE_ENDIAN
* gcc/config/microblaze/t-microblaze: Expand multilib options to
include mlittle-endian (le) and update exceptions patterns
* gcc/config/microblaze/t-microblaze-linux: New file - define
multilibs for microblaze*-linux which dont include little endian.
gcc/testsuite/Changelog
2013-01-21 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* 20101011-1.c: Add __MICROBLAZE__ exception to set DO_TEST 0
[-- Attachment #2: 0005-Add-MicroBlaze-Little-Endian-Support.patch --]
[-- Type: application/octet-stream, Size: 11100 bytes --]
From 93ef3906bb57ef7815e5ea533ff45fa40280f7c4 Mon Sep 17 00:00:00 2001
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Date: Wed, 21 Sep 2011 23:16:21 +0200
Subject: [PATCH] Add MicroBlaze Little Endian Support
gcc/Changelog
2013-01-21 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* gcc/config.gcc (microblaze*-linux*): Add TARGET_BIG_ENDIAN_DEFAULT
gcc/config.gcc (microblaze*-*-elf): Likewise
gcc/config.gcc (microblaze*-*-*): Likewise
* gcc/config/microblaze/linux.h: Add -mbig-endian / -mlittle-endian
to LINK_SPEC
* gcc/config/microblaze/microblaze-c.c: Add builtin defines for
_LITTLE_ENDIAN and _BIG_ENDIAN
* gcc/config/microblaze/microblaze.h: Add TARGET_ENDIAN_DEFAULT
and add to TARGET_DEFAULT flags.
Expand ASM_SPEC and LINK_SPEC.
Update BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN
* gcc/config/microblaze/microblaze.md: Update extendsidi2 and
movdi_internal instructions to use low-order / high-order reg
print_operands
* gcc/config/microblaze/microblaze.opt: Add mbig-endian and
mlittle-endian options and inversemask / mask of LITTLE_ENDIAN
* gcc/config/microblaze/t-microblaze: Expand multilib options to
include mlittle-endian (le) and update exceptions patterns
* gcc/config/microblaze/t-microblaze-linux: New file - define
multilibs for microblaze*-linux which dont include little endian.
gcc/testsuite/Changelog
2013-01-21 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* 20101011-1.c: Add __MICROBLAZE__ exception to set DO_TEST 0
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
---
gcc/config.gcc | 27 +++++++++++++++++++++-
gcc/config/microblaze/linux.h | 4 +++-
gcc/config/microblaze/microblaze-c.c | 13 +++++++++++
gcc/config/microblaze/microblaze.h | 21 +++++++++++++----
gcc/config/microblaze/microblaze.md | 14 +++++------
gcc/config/microblaze/microblaze.opt | 8 +++++++
gcc/config/microblaze/t-microblaze | 6 +++--
gcc/config/microblaze/t-microblaze-linux | 3 +++
gcc/testsuite/gcc.c-torture/execute/20101011-1.c | 3 +++
9 files changed, 84 insertions(+), 15 deletions(-)
create mode 100644 gcc/config/microblaze/t-microblaze-linux
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 0a96d2e..470207d 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1727,11 +1727,20 @@ mep-*-*)
use_gcc_stdint=wrap
;;
microblaze*-linux*)
+ case $target in
+ microblazeel-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=0"
+ ;;
+ microblaze-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=4321"
+ ;;
+ esac
tm_file="${tm_file} dbxelf.h gnu-user.h linux.h microblaze/linux.h"
tm_file="${tm_file} glibc-stdint.h"
c_target_objs="${c_target_objs} microblaze-c.o"
cxx_target_objs="${cxx_target_objs} microblaze-c.o"
tmake_file="${tmake_file} microblaze/t-microblaze"
+ tmake_file="${tmake_file} microblaze/t-microblaze-linux"
;;
microblaze*-*-rtems*)
tm_file="${tm_file} dbxelf.h"
@@ -1742,13 +1751,29 @@ microblaze*-*-rtems*)
tmake_file="${tmake_file} t-rtems microblaze/t-rtems"
;;
microblaze*-*-elf)
+ case $target in
+ microblazeel-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=0"
+ ;;
+ microblaze-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=4321"
+ ;;
+ esac
tm_file="${tm_file} dbxelf.h newlib-stdint.h"
c_target_objs="${c_target_objs} microblaze-c.o"
cxx_target_objs="${cxx_target_objs} microblaze-c.o"
tmake_file="${tmake_file} microblaze/t-microblaze"
;;
microblaze*-*-*)
- tm_file="${tm_file} dbxelf.h"
+ case $target in
+ microblazeel-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=0"
+ ;;
+ microblaze-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=4321"
+ ;;
+ esac
+ tm_file="${tm_file} dbxelf.h"
c_target_objs="${c_target_objs} microblaze-c.o"
cxx_target_objs="${cxx_target_objs} microblaze-c.o"
tmake_file="${tmake_file} microblaze/t-microblaze"
diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
index c0255f7..7455ec7 100644
--- a/gcc/config/microblaze/linux.h
+++ b/gcc/config/microblaze/linux.h
@@ -31,7 +31,9 @@
%{!static: \
%{rdynamic:-export-dynamic} \
-dynamic-linker %(dynamic_linker)} \
- %{static:-static}}"
+ %{static:-static}} \
+ %{mbig-endian:-EB} \
+ %{mlittle-endian:-EL}"
/* For the microblaze-*-linux* subtarget. */
#undef TARGET_OS_CPP_BUILTINS
diff --git a/gcc/config/microblaze/microblaze-c.c b/gcc/config/microblaze/microblaze-c.c
index d22dc2a..a1a20b7 100644
--- a/gcc/config/microblaze/microblaze-c.c
+++ b/gcc/config/microblaze/microblaze-c.c
@@ -41,6 +41,19 @@ microblaze_cpp_define (cpp_reader *pfile)
builtin_assert ("cpu=microblaze");
builtin_assert ("machine=microblaze");
builtin_define ("__MICROBLAZE__");
+ builtin_define ("__microblaze__");
+ if (TARGET_LITTLE_ENDIAN)
+ {
+ builtin_define ("_LITTLE_ENDIAN");
+ builtin_define ("__LITTLE_ENDIAN__");
+ builtin_define ("__MICROBLAZEEL__");
+ }
+ else
+ {
+ builtin_define ("_BIG_ENDIAN");
+ builtin_define ("__BIG_ENDIAN__");
+ builtin_define ("__MICROBLAZEEB__");
+ }
if (!TARGET_SOFT_MUL)
{
if (!flag_iso)
diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
index 78e3642..5b64e39 100644
--- a/gcc/config/microblaze/microblaze.h
+++ b/gcc/config/microblaze/microblaze.h
@@ -46,8 +46,17 @@ extern enum pipeline_type microblaze_pipe;
#define OBJECT_FORMAT_ELF
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_ENDIAN_DEFAULT 0
+#define TARGET_ENDIAN_OPTION "mbig-endian"
+#else
+#define TARGET_ENDIAN_DEFAULT MASK_LITTLE_ENDIAN
+#define TARGET_ENDIAN_OPTION "mlittle-endian"
+#endif
+
/* Default target_flags if no switches are specified */
-#define TARGET_DEFAULT (MASK_SOFT_MUL | MASK_SOFT_DIV | MASK_SOFT_FLOAT)
+#define TARGET_DEFAULT (MASK_SOFT_MUL | MASK_SOFT_DIV | MASK_SOFT_FLOAT \
+ | TARGET_ENDIAN_DEFAULT)
/* What is the default setting for -mcpu= . We set it to v4.00.a even though
we are actually ahead. This is safest version that has generate code
@@ -77,12 +86,16 @@ extern enum pipeline_type microblaze_pipe;
#define TARGET_ASM_SPEC ""
#define ASM_SPEC "\
-%(target_asm_spec)"
+%(target_asm_spec) \
+%{mbig-endian:-EB} \
+%{mlittle-endian:-EL}"
/* Extra switches sometimes passed to the linker. */
/* -xl-mode-xmdstub translated to -Zxl-mode-xmdstub -- deprecated. */
#define LINK_SPEC "%{shared:-shared} -N -relax \
+ %{mbig-endian:-EB --oformat=elf32-microblaze} \
+ %{mlittle-endian:-EL --oformat=elf32-microblazeel} \
%{Zxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
%{mxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
%{mxl-gp-opt:%{G*}} %{!mxl-gp-opt: -G 0} \
@@ -167,8 +180,8 @@ extern enum pipeline_type microblaze_pipe;
/* Target machine storage layout */
#define BITS_BIG_ENDIAN 0
-#define BYTES_BIG_ENDIAN 1
-#define WORDS_BIG_ENDIAN 1
+#define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
+#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)
#define BITS_PER_UNIT 8
#define BITS_PER_WORD 32
#define UNITS_PER_WORD 4
diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
index 8d4203d..69df592 100644
--- a/gcc/config/microblaze/microblaze.md
+++ b/gcc/config/microblaze/microblaze.md
@@ -822,14 +822,14 @@
""
{
if (which_alternative == 0)
- output_asm_insn ("addk\t%D0,r0,%1", operands);
+ output_asm_insn ("addk\t%L0,r0,%1", operands);
else
- output_asm_insn ("lw%i1\t%D0,%1", operands);
+ output_asm_insn ("lw%i1\t%L0,%1", operands);
- output_asm_insn ("add\t%0,%D0,%D0", operands);
- output_asm_insn ("addc\t%0,r0,r0", operands);
- output_asm_insn ("beqi\t%0,.+8", operands);
- return "addi\t%0,r0,0xffffffff";
+ output_asm_insn ("add\t%M0,%L0,%L0", operands);
+ output_asm_insn ("addc\t%M0,r0,r0", operands);
+ output_asm_insn ("beqi\t%M0,.+8", operands);
+ return "addi\t%M0,r0,0xffffffff";
}
[(set_attr "type" "multi,multi,multi")
(set_attr "mode" "DI")
@@ -887,7 +887,7 @@
case 0:
return "addk\t%0,%1\n\taddk\t%D0,%d1";
case 1:
- return "addik\t%0,r0,%h1\n\taddik\t%D0,r0,%j1 #li => la";
+ return "addik\t%M0,r0,%h1\n\taddik\t%L0,r0,%j1 #li => la";
case 2:
return "addk\t%0,r0,r0\n\taddk\t%D0,r0,r0";
case 3:
diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
index e597a94..fc7d0cd 100644
--- a/gcc/config/microblaze/microblaze.opt
+++ b/gcc/config/microblaze/microblaze.opt
@@ -55,6 +55,14 @@ mmemcpy
Target Mask(MEMCPY)
Don't optimize block moves, use memcpy
+mbig-endian
+Target Report RejectNegative InverseMask(LITTLE_ENDIAN)
+Assume target CPU is configured as big endian
+
+mlittle-endian
+Target Report RejectNegative Mask(LITTLE_ENDIAN)
+Assume target CPU is configured as little endian
+
mxl-soft-mul
Target Mask(SOFT_MUL)
Use the soft multiply emulation (default)
diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
index cb49636..41fa9a9 100644
--- a/gcc/config/microblaze/t-microblaze
+++ b/gcc/config/microblaze/t-microblaze
@@ -1,6 +1,8 @@
-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high
-MULTILIB_DIRNAMES = bs m mh
+MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian
+MULTILIB_DIRNAMES = bs m mh le
MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
+MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
# Extra files
microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
diff --git a/gcc/config/microblaze/t-microblaze-linux b/gcc/config/microblaze/t-microblaze-linux
new file mode 100644
index 0000000..e8e8f3c
--- /dev/null
+++ b/gcc/config/microblaze/t-microblaze-linux
@@ -0,0 +1,3 @@
+MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high
+MULTILIB_DIRNAMES = bs m mh
+MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index 76b9f06..8d82183 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -29,6 +29,9 @@
/* Not all Linux kernels deal correctly the breakpoints generated by
MIPS16 divisions by zero. They show up as a SIGTRAP instead. */
# define DO_TEST 0
+#elif defined (__MICROBLAZE__)
+/* We cannot rely on division by zero generating a trap. */
+# define DO_TEST 0
#elif defined (__epiphany__)
/* Epiphany does not have hardware division, and the software implementation
has truly undefined behaviour for division by 0. */
--
1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, microblaze]: Add MicroBlaze Little Endian Support
2013-01-21 5:47 [Patch, microblaze]: Add MicroBlaze Little Endian Support David Holsgrove
@ 2013-01-25 0:40 ` David Holsgrove
2013-02-08 16:05 ` Michael Eager
0 siblings, 1 reply; 3+ messages in thread
From: David Holsgrove @ 2013-01-25 0:40 UTC (permalink / raw)
To: gcc-patches
Cc: Michael Eager, John Williams, Edgar E. Iglesias, Vinod Kathail,
Vidhumouli Hunsigida, Nagaraju Mekala, Tom Shui
[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]
Hi Michael,
Please find attached updated patch for MicroBlaze Little Endian
support to reflect removal of microblaze*-*-* target.
Changelog updated as follows.
thanks,
David
gcc/Changelog
2013-01-25 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* gcc/config.gcc (microblaze*-linux*): Add TARGET_BIG_ENDIAN_DEFAULT
gcc/config.gcc (microblaze*-*-elf): Likewise
* gcc/config/microblaze/linux.h: Add -mbig-endian / -mlittle-endian
to LINK_SPEC
* gcc/config/microblaze/microblaze-c.c: Add builtin defines for
_LITTLE_ENDIAN and _BIG_ENDIAN
* gcc/config/microblaze/microblaze.h: Add TARGET_ENDIAN_DEFAULT
and add to TARGET_DEFAULT flags.
Expand ASM_SPEC and LINK_SPEC.
Update BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN
* gcc/config/microblaze/microblaze.md: Update extendsidi2 and
movdi_internal instructions to use low-order / high-order reg
print_operands
* gcc/config/microblaze/microblaze.opt: Add mbig-endian and
mlittle-endian options and inversemask / mask of LITTLE_ENDIAN
* gcc/config/microblaze/t-microblaze: Expand multilib options to
include mlittle-endian (le) and update exceptions patterns
gcc/testsuite/Changelog
2013-01-25 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* 20101011-1.c: Add __MICROBLAZE__ exception to set DO_TEST 0
[-- Attachment #2: 0003-Add-MicroBlaze-Little-Endian-Support.patch --]
[-- Type: application/octet-stream, Size: 10413 bytes --]
From 8c274916747bcc22c764b71bec9f375558545e31 Mon Sep 17 00:00:00 2001
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Date: Wed, 21 Sep 2011 23:16:21 +0200
Subject: [PATCH] Add MicroBlaze Little Endian Support
gcc/Changelog
2013-01-25 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* gcc/config.gcc (microblaze*-linux*): Add TARGET_BIG_ENDIAN_DEFAULT
gcc/config.gcc (microblaze*-*-elf): Likewise
* gcc/config/microblaze/linux.h: Add -mbig-endian / -mlittle-endian
to LINK_SPEC
* gcc/config/microblaze/microblaze-c.c: Add builtin defines for
_LITTLE_ENDIAN and _BIG_ENDIAN
* gcc/config/microblaze/microblaze.h: Add TARGET_ENDIAN_DEFAULT
and add to TARGET_DEFAULT flags.
Expand ASM_SPEC and LINK_SPEC.
Update BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN
* gcc/config/microblaze/microblaze.md: Update extendsidi2 and
movdi_internal instructions to use low-order / high-order reg
print_operands
* gcc/config/microblaze/microblaze.opt: Add mbig-endian and
mlittle-endian options and inversemask / mask of LITTLE_ENDIAN
* gcc/config/microblaze/t-microblaze: Expand multilib options to
include mlittle-endian (le) and update exceptions patterns
gcc/testsuite/Changelog
2013-01-25 Edgar E. Iglesias <edgar.iglesias@gmail.com>
* 20101011-1.c: Add __MICROBLAZE__ exception to set DO_TEST 0
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
---
gcc/config.gcc | 17 +++++++++++++++++
gcc/config/microblaze/linux.h | 4 +++-
gcc/config/microblaze/microblaze-c.c | 13 +++++++++++++
gcc/config/microblaze/microblaze.h | 21 +++++++++++++++++----
gcc/config/microblaze/microblaze.md | 14 +++++++-------
gcc/config/microblaze/microblaze.opt | 8 ++++++++
gcc/config/microblaze/t-microblaze | 6 ++++--
gcc/config/microblaze/t-microblaze-linux | 3 +++
gcc/testsuite/gcc.c-torture/execute/20101011-1.c | 3 +++
9 files changed, 75 insertions(+), 14 deletions(-)
create mode 100644 gcc/config/microblaze/t-microblaze-linux
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 53a1e4b..0b4a66d 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1727,11 +1727,20 @@ mep-*-*)
use_gcc_stdint=wrap
;;
microblaze*-linux*)
+ case $target in
+ microblazeel-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=0"
+ ;;
+ microblaze-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=4321"
+ ;;
+ esac
tm_file="${tm_file} dbxelf.h gnu-user.h linux.h microblaze/linux.h"
tm_file="${tm_file} glibc-stdint.h"
c_target_objs="${c_target_objs} microblaze-c.o"
cxx_target_objs="${cxx_target_objs} microblaze-c.o"
tmake_file="${tmake_file} microblaze/t-microblaze"
+ tmake_file="${tmake_file} microblaze/t-microblaze-linux"
;;
microblaze*-*-rtems*)
tm_file="${tm_file} dbxelf.h"
@@ -1742,6 +1751,14 @@ microblaze*-*-rtems*)
tmake_file="${tmake_file} t-rtems microblaze/t-rtems"
;;
microblaze*-*-elf)
+ case $target in
+ microblazeel-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=0"
+ ;;
+ microblaze-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=4321"
+ ;;
+ esac
tm_file="${tm_file} dbxelf.h newlib-stdint.h"
c_target_objs="${c_target_objs} microblaze-c.o"
cxx_target_objs="${cxx_target_objs} microblaze-c.o"
diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
index c0255f7..7455ec7 100644
--- a/gcc/config/microblaze/linux.h
+++ b/gcc/config/microblaze/linux.h
@@ -31,7 +31,9 @@
%{!static: \
%{rdynamic:-export-dynamic} \
-dynamic-linker %(dynamic_linker)} \
- %{static:-static}}"
+ %{static:-static}} \
+ %{mbig-endian:-EB} \
+ %{mlittle-endian:-EL}"
/* For the microblaze-*-linux* subtarget. */
#undef TARGET_OS_CPP_BUILTINS
diff --git a/gcc/config/microblaze/microblaze-c.c b/gcc/config/microblaze/microblaze-c.c
index d22dc2a..a1a20b7 100644
--- a/gcc/config/microblaze/microblaze-c.c
+++ b/gcc/config/microblaze/microblaze-c.c
@@ -41,6 +41,19 @@ microblaze_cpp_define (cpp_reader *pfile)
builtin_assert ("cpu=microblaze");
builtin_assert ("machine=microblaze");
builtin_define ("__MICROBLAZE__");
+ builtin_define ("__microblaze__");
+ if (TARGET_LITTLE_ENDIAN)
+ {
+ builtin_define ("_LITTLE_ENDIAN");
+ builtin_define ("__LITTLE_ENDIAN__");
+ builtin_define ("__MICROBLAZEEL__");
+ }
+ else
+ {
+ builtin_define ("_BIG_ENDIAN");
+ builtin_define ("__BIG_ENDIAN__");
+ builtin_define ("__MICROBLAZEEB__");
+ }
if (!TARGET_SOFT_MUL)
{
if (!flag_iso)
diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
index 78e3642..5b64e39 100644
--- a/gcc/config/microblaze/microblaze.h
+++ b/gcc/config/microblaze/microblaze.h
@@ -46,8 +46,17 @@ extern enum pipeline_type microblaze_pipe;
#define OBJECT_FORMAT_ELF
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_ENDIAN_DEFAULT 0
+#define TARGET_ENDIAN_OPTION "mbig-endian"
+#else
+#define TARGET_ENDIAN_DEFAULT MASK_LITTLE_ENDIAN
+#define TARGET_ENDIAN_OPTION "mlittle-endian"
+#endif
+
/* Default target_flags if no switches are specified */
-#define TARGET_DEFAULT (MASK_SOFT_MUL | MASK_SOFT_DIV | MASK_SOFT_FLOAT)
+#define TARGET_DEFAULT (MASK_SOFT_MUL | MASK_SOFT_DIV | MASK_SOFT_FLOAT \
+ | TARGET_ENDIAN_DEFAULT)
/* What is the default setting for -mcpu= . We set it to v4.00.a even though
we are actually ahead. This is safest version that has generate code
@@ -77,12 +86,16 @@ extern enum pipeline_type microblaze_pipe;
#define TARGET_ASM_SPEC ""
#define ASM_SPEC "\
-%(target_asm_spec)"
+%(target_asm_spec) \
+%{mbig-endian:-EB} \
+%{mlittle-endian:-EL}"
/* Extra switches sometimes passed to the linker. */
/* -xl-mode-xmdstub translated to -Zxl-mode-xmdstub -- deprecated. */
#define LINK_SPEC "%{shared:-shared} -N -relax \
+ %{mbig-endian:-EB --oformat=elf32-microblaze} \
+ %{mlittle-endian:-EL --oformat=elf32-microblazeel} \
%{Zxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
%{mxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
%{mxl-gp-opt:%{G*}} %{!mxl-gp-opt: -G 0} \
@@ -167,8 +180,8 @@ extern enum pipeline_type microblaze_pipe;
/* Target machine storage layout */
#define BITS_BIG_ENDIAN 0
-#define BYTES_BIG_ENDIAN 1
-#define WORDS_BIG_ENDIAN 1
+#define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
+#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)
#define BITS_PER_UNIT 8
#define BITS_PER_WORD 32
#define UNITS_PER_WORD 4
diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
index 8d4203d..69df592 100644
--- a/gcc/config/microblaze/microblaze.md
+++ b/gcc/config/microblaze/microblaze.md
@@ -822,14 +822,14 @@
""
{
if (which_alternative == 0)
- output_asm_insn ("addk\t%D0,r0,%1", operands);
+ output_asm_insn ("addk\t%L0,r0,%1", operands);
else
- output_asm_insn ("lw%i1\t%D0,%1", operands);
+ output_asm_insn ("lw%i1\t%L0,%1", operands);
- output_asm_insn ("add\t%0,%D0,%D0", operands);
- output_asm_insn ("addc\t%0,r0,r0", operands);
- output_asm_insn ("beqi\t%0,.+8", operands);
- return "addi\t%0,r0,0xffffffff";
+ output_asm_insn ("add\t%M0,%L0,%L0", operands);
+ output_asm_insn ("addc\t%M0,r0,r0", operands);
+ output_asm_insn ("beqi\t%M0,.+8", operands);
+ return "addi\t%M0,r0,0xffffffff";
}
[(set_attr "type" "multi,multi,multi")
(set_attr "mode" "DI")
@@ -887,7 +887,7 @@
case 0:
return "addk\t%0,%1\n\taddk\t%D0,%d1";
case 1:
- return "addik\t%0,r0,%h1\n\taddik\t%D0,r0,%j1 #li => la";
+ return "addik\t%M0,r0,%h1\n\taddik\t%L0,r0,%j1 #li => la";
case 2:
return "addk\t%0,r0,r0\n\taddk\t%D0,r0,r0";
case 3:
diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
index e597a94..fc7d0cd 100644
--- a/gcc/config/microblaze/microblaze.opt
+++ b/gcc/config/microblaze/microblaze.opt
@@ -55,6 +55,14 @@ mmemcpy
Target Mask(MEMCPY)
Don't optimize block moves, use memcpy
+mbig-endian
+Target Report RejectNegative InverseMask(LITTLE_ENDIAN)
+Assume target CPU is configured as big endian
+
+mlittle-endian
+Target Report RejectNegative Mask(LITTLE_ENDIAN)
+Assume target CPU is configured as little endian
+
mxl-soft-mul
Target Mask(SOFT_MUL)
Use the soft multiply emulation (default)
diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
index cb49636..41fa9a9 100644
--- a/gcc/config/microblaze/t-microblaze
+++ b/gcc/config/microblaze/t-microblaze
@@ -1,6 +1,8 @@
-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high
-MULTILIB_DIRNAMES = bs m mh
+MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian
+MULTILIB_DIRNAMES = bs m mh le
MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
+MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
# Extra files
microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
diff --git a/gcc/config/microblaze/t-microblaze-linux b/gcc/config/microblaze/t-microblaze-linux
new file mode 100644
index 0000000..e8e8f3c
--- /dev/null
+++ b/gcc/config/microblaze/t-microblaze-linux
@@ -0,0 +1,3 @@
+MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high
+MULTILIB_DIRNAMES = bs m mh
+MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index 76b9f06..8d82183 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -29,6 +29,9 @@
/* Not all Linux kernels deal correctly the breakpoints generated by
MIPS16 divisions by zero. They show up as a SIGTRAP instead. */
# define DO_TEST 0
+#elif defined (__MICROBLAZE__)
+/* We cannot rely on division by zero generating a trap. */
+# define DO_TEST 0
#elif defined (__epiphany__)
/* Epiphany does not have hardware division, and the software implementation
has truly undefined behaviour for division by 0. */
--
1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, microblaze]: Add MicroBlaze Little Endian Support
2013-01-25 0:40 ` David Holsgrove
@ 2013-02-08 16:05 ` Michael Eager
0 siblings, 0 replies; 3+ messages in thread
From: Michael Eager @ 2013-02-08 16:05 UTC (permalink / raw)
To: David Holsgrove
Cc: gcc-patches, Michael Eager, John Williams, Edgar E. Iglesias,
Vinod Kathail, Vidhumouli Hunsigida, Nagaraju Mekala, Tom Shui
On 01/24/2013 04:39 PM, David Holsgrove wrote:
> Hi Michael,
>
> Please find attached updated patch for MicroBlaze Little Endian
> support to reflect removal of microblaze*-*-* target.
> Changelog updated as follows.
>
> thanks,
> David
>
> gcc/Changelog
>
> 2013-01-25 Edgar E. Iglesias <edgar.iglesias@gmail.com>
>
> * gcc/config.gcc (microblaze*-linux*): Add TARGET_BIG_ENDIAN_DEFAULT
> gcc/config.gcc (microblaze*-*-elf): Likewise
> * gcc/config/microblaze/linux.h: Add -mbig-endian / -mlittle-endian
> to LINK_SPEC
> * gcc/config/microblaze/microblaze-c.c: Add builtin defines for
> _LITTLE_ENDIAN and _BIG_ENDIAN
> * gcc/config/microblaze/microblaze.h: Add TARGET_ENDIAN_DEFAULT
> and add to TARGET_DEFAULT flags.
> Expand ASM_SPEC and LINK_SPEC.
> Update BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN
> * gcc/config/microblaze/microblaze.md: Update extendsidi2 and
> movdi_internal instructions to use low-order / high-order reg
> print_operands
> * gcc/config/microblaze/microblaze.opt: Add mbig-endian and
> mlittle-endian options and inversemask / mask of LITTLE_ENDIAN
> * gcc/config/microblaze/t-microblaze: Expand multilib options to
> include mlittle-endian (le) and update exceptions patterns
>
> gcc/testsuite/Changelog
>
> 2013-01-25 Edgar E. Iglesias <edgar.iglesias@gmail.com>
>
> * 20101011-1.c: Add __MICROBLAZE__ exception to set DO_TEST 0
Committed revision 195893.
--
Michael Eager eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-08 16:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-21 5:47 [Patch, microblaze]: Add MicroBlaze Little Endian Support David Holsgrove
2013-01-25 0:40 ` David Holsgrove
2013-02-08 16:05 ` Michael Eager
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).