Compare commits
21 Commits
master
...
private-da
Author | SHA1 | Date |
---|---|---|
David Abdurachmanov | a24fb4f7f1 | |
David Abdurachmanov | d28e028a04 | |
David Abdurachmanov | b5c8f89da0 | |
David Abdurachmanov | 13ae10ca88 | |
David Abdurachmanov | 0c8a514f2f | |
David Abdurachmanov | 84da12b304 | |
David Abdurachmanov | f12d80983f | |
David Abdurachmanov | 86300223a1 | |
David Abdurachmanov | df0cbdcb5d | |
David Abdurachmanov | 2376be8a2a | |
David Abdurachmanov | 948d611882 | |
David Abdurachmanov | d9a688a462 | |
David Abdurachmanov | a27065ed2b | |
David Abdurachmanov | a26c9756d6 | |
David Abdurachmanov | 61087a9352 | |
David Abdurachmanov | 10e63a9ab4 | |
David Abdurachmanov | 8d1ed6b2bc | |
David Abdurachmanov | 0e0bb97508 | |
David Abdurachmanov | 24bb58f8b3 | |
David Abdurachmanov | 273a6e3e21 | |
David Abdurachmanov | b840e5963d |
|
@ -0,0 +1,156 @@
|
||||||
|
From 35ced3822a12415f7bf7307f43c503736aa4b8e8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Abdurachmanov <david.abdurachmanov@gmail.com>
|
||||||
|
Date: Wed, 23 Jan 2019 21:45:01 +0100
|
||||||
|
Subject: [PATCH] Add RISCV support in libphobos
|
||||||
|
|
||||||
|
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
|
||||||
|
---
|
||||||
|
.../allocator/building_blocks/region.d | 3 +-
|
||||||
|
libphobos/src/std/math.d | 61 +++++++++++++++++++
|
||||||
|
2 files changed, 63 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libphobos/src/std/experimental/allocator/building_blocks/region.d b/libphobos/src/std/experimental/allocator/building_blocks/region.d
|
||||||
|
index 80157aee7e6..ad90d17df00 100644
|
||||||
|
--- a/libphobos/src/std/experimental/allocator/building_blocks/region.d
|
||||||
|
+++ b/libphobos/src/std/experimental/allocator/building_blocks/region.d
|
||||||
|
@@ -390,7 +390,8 @@ struct InSituRegion(size_t size, size_t minAlign = platformAlignment)
|
||||||
|
else version (PPC) enum growDownwards = Yes.growDownwards;
|
||||||
|
else version (PPC64) enum growDownwards = Yes.growDownwards;
|
||||||
|
else version (MIPS32) enum growDownwards = Yes.growDownwards;
|
||||||
|
- else version (MIPS64) enum growDownwards = Yes.growDownwards;
|
||||||
|
+ else version (RISCV32) enum growDownwards = Yes.growDownwards;
|
||||||
|
+ else version (RISCV64) enum growDownwards = Yes.growDownwards;
|
||||||
|
else version (SPARC) enum growDownwards = Yes.growDownwards;
|
||||||
|
else version (SystemZ) enum growDownwards = Yes.growDownwards;
|
||||||
|
else static assert(0, "Dunno how the stack grows on this architecture.");
|
||||||
|
diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d
|
||||||
|
index 7bb4d7c23db..ba9b03c4da9 100644
|
||||||
|
--- a/libphobos/src/std/math.d
|
||||||
|
+++ b/libphobos/src/std/math.d
|
||||||
|
@@ -160,6 +160,8 @@ version (MIPS32) version = MIPS_Any;
|
||||||
|
version (MIPS64) version = MIPS_Any;
|
||||||
|
version (AArch64) version = ARM_Any;
|
||||||
|
version (ARM) version = ARM_Any;
|
||||||
|
+version (RISCV32) version = RISCV_Any;
|
||||||
|
+version (RISCV64) version = RISCV_Any;
|
||||||
|
|
||||||
|
version (D_InlineAsm_X86)
|
||||||
|
{
|
||||||
|
@@ -4654,6 +4656,7 @@ private:
|
||||||
|
// The Pentium SSE2 status register is 32 bits.
|
||||||
|
// The ARM and PowerPC FPSCR is a 32-bit register.
|
||||||
|
// The SPARC FSR is a 32bit register (64 bits for SPARC 7 & 8, but high bits are uninteresting).
|
||||||
|
+ // The RISC-V (32 & 64 bit) are 32-bit register.
|
||||||
|
uint flags;
|
||||||
|
|
||||||
|
version (CRuntime_Microsoft)
|
||||||
|
@@ -4725,6 +4728,15 @@ private:
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ else version (RISCV_Any)
|
||||||
|
+ {
|
||||||
|
+ uint result = void;
|
||||||
|
+ asm pure nothrow @nogc
|
||||||
|
+ {
|
||||||
|
+ "frflags %0" : "=r" (result);
|
||||||
|
+ }
|
||||||
|
+ return result;
|
||||||
|
+ }
|
||||||
|
else
|
||||||
|
assert(0, "Not yet supported");
|
||||||
|
}
|
||||||
|
@@ -4799,6 +4811,15 @@ private:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ else version (RISCV_Any)
|
||||||
|
+ {
|
||||||
|
+ uint oldValues = void;
|
||||||
|
+ uint newValues = 0x0;
|
||||||
|
+ asm pure nothrow @nogc
|
||||||
|
+ {
|
||||||
|
+ "fsflags %0 %1" : "=r" (oldValues) : "r" (newValues);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
else
|
||||||
|
assert(0, "Not yet supported");
|
||||||
|
}
|
||||||
|
@@ -4968,6 +4989,10 @@ else version (PPC_Any)
|
||||||
|
{
|
||||||
|
version = IeeeFlagsSupport;
|
||||||
|
}
|
||||||
|
+else version (RISCV_Any)
|
||||||
|
+{
|
||||||
|
+ version = IeeeFlagsSupport;
|
||||||
|
+}
|
||||||
|
else version (MIPS_Any)
|
||||||
|
{
|
||||||
|
version = IeeeFlagsSupport;
|
||||||
|
@@ -5162,6 +5187,21 @@ struct FloatingPointControl
|
||||||
|
| inexactException,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ else version (RISCV_Any)
|
||||||
|
+ {
|
||||||
|
+ enum : ExceptionMask
|
||||||
|
+ {
|
||||||
|
+ inexactException = 0x01,
|
||||||
|
+ divByZeroException = 0x02,
|
||||||
|
+ underflowException = 0x04,
|
||||||
|
+ overflowException = 0x08,
|
||||||
|
+ invalidException = 0x10,
|
||||||
|
+ severeExceptions = overflowException | divByZeroException
|
||||||
|
+ | invalidException,
|
||||||
|
+ allExceptions = severeExceptions | underflowException
|
||||||
|
+ | inexactException,
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
else version (SPARC64)
|
||||||
|
{
|
||||||
|
enum : ExceptionMask
|
||||||
|
@@ -5292,6 +5332,10 @@ private:
|
||||||
|
{
|
||||||
|
alias ControlState = uint;
|
||||||
|
}
|
||||||
|
+ else version (RISCV_Any)
|
||||||
|
+ {
|
||||||
|
+ alias ControlState = uint;
|
||||||
|
+ }
|
||||||
|
else version (SPARC64)
|
||||||
|
{
|
||||||
|
alias ControlState = ulong;
|
||||||
|
@@ -5359,6 +5403,15 @@ private:
|
||||||
|
}
|
||||||
|
return cont;
|
||||||
|
}
|
||||||
|
+ else version (RISCV_Any)
|
||||||
|
+ {
|
||||||
|
+ ControlState cont;
|
||||||
|
+ asm pure nothrow @nogc
|
||||||
|
+ {
|
||||||
|
+ "frcsr %0" : "=r" (cont);
|
||||||
|
+ }
|
||||||
|
+ return cont;
|
||||||
|
+ }
|
||||||
|
else
|
||||||
|
assert(0, "Not yet supported");
|
||||||
|
}
|
||||||
|
@@ -5444,6 +5497,14 @@ private:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ else version (RISCV_Any)
|
||||||
|
+ {
|
||||||
|
+ uint oldState = void;
|
||||||
|
+ asm pure nothrow @nogc
|
||||||
|
+ {
|
||||||
|
+ "fscsr %0, %1;" : "=r" (oldState) : "r" (newState);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
else
|
||||||
|
assert(0, "Not yet supported");
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
40
gcc.spec
40
gcc.spec
|
@ -28,12 +28,12 @@
|
||||||
%global build_ada 0
|
%global build_ada 0
|
||||||
%endif
|
%endif
|
||||||
%global build_objc 1
|
%global build_objc 1
|
||||||
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips}
|
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips} riscv64
|
||||||
%global build_go 1
|
%global build_go 1
|
||||||
%else
|
%else
|
||||||
%global build_go 0
|
%global build_go 0
|
||||||
%endif
|
%endif
|
||||||
%ifarch %{ix86} x86_64 %{arm} %{mips}
|
%ifarch %{ix86} x86_64 %{arm} %{mips} riscv64
|
||||||
%global build_d 1
|
%global build_d 1
|
||||||
%else
|
%else
|
||||||
%global build_d 0
|
%global build_d 0
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
%else
|
%else
|
||||||
%global build_libubsan 0
|
%global build_libubsan 0
|
||||||
%endif
|
%endif
|
||||||
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips}
|
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips} riscv64
|
||||||
%global build_libatomic 1
|
%global build_libatomic 1
|
||||||
%else
|
%else
|
||||||
%global build_libatomic 0
|
%global build_libatomic 0
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
Summary: Various compilers (C, C++, Objective-C, ...)
|
Summary: Various compilers (C, C++, Objective-C, ...)
|
||||||
Name: gcc
|
Name: gcc
|
||||||
Version: %{gcc_version}
|
Version: %{gcc_version}
|
||||||
Release: %{gcc_release}%{?dist}
|
Release: %{gcc_release}.davidlt.4%{?dist}
|
||||||
# libgcc, libgfortran, libgomp, libstdc++ and crtstuff have
|
# libgcc, libgfortran, libgomp, libstdc++ and crtstuff have
|
||||||
# GCC Runtime Exception.
|
# GCC Runtime Exception.
|
||||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
||||||
|
@ -265,6 +265,10 @@ Patch16: gcc9-pr88904.patch
|
||||||
Patch17: gcc9-pr88905.patch
|
Patch17: gcc9-pr88905.patch
|
||||||
Patch18: gcc9-pr88906.patch
|
Patch18: gcc9-pr88906.patch
|
||||||
|
|
||||||
|
Patch30: libphobos-enable-riscv.patch
|
||||||
|
Patch31: libphobos-asserts.patch
|
||||||
|
Patch32: 0001-Enable-RISC-V-in-libphobos-especially-math.d.patch
|
||||||
|
|
||||||
Patch1000: nvptx-tools-no-ptxas.patch
|
Patch1000: nvptx-tools-no-ptxas.patch
|
||||||
Patch1001: nvptx-tools-build.patch
|
Patch1001: nvptx-tools-build.patch
|
||||||
Patch1002: nvptx-tools-glibc.patch
|
Patch1002: nvptx-tools-glibc.patch
|
||||||
|
@ -850,6 +854,10 @@ to NVidia PTX capable devices if available.
|
||||||
%patch17 -p0 -b .pr88905~
|
%patch17 -p0 -b .pr88905~
|
||||||
%patch18 -p0 -b .pr88906~
|
%patch18 -p0 -b .pr88906~
|
||||||
|
|
||||||
|
%patch30 -p1 -b .libphobos-riscv~
|
||||||
|
%patch31 -p1 -b .libphobos-asserts~
|
||||||
|
%patch32 -p1 -b .libphobos-riscv-math~
|
||||||
|
|
||||||
cd nvptx-tools-%{nvptx_tools_gitrev}
|
cd nvptx-tools-%{nvptx_tools_gitrev}
|
||||||
%patch1000 -p1 -b .nvptx-tools-no-ptxas~
|
%patch1000 -p1 -b .nvptx-tools-no-ptxas~
|
||||||
%patch1001 -p1 -b .nvptx-tools-build~
|
%patch1001 -p1 -b .nvptx-tools-build~
|
||||||
|
@ -974,7 +982,7 @@ CONFIGURE_OPTS="\
|
||||||
%ifarch ppc64le
|
%ifarch ppc64le
|
||||||
--enable-targets=powerpcle-linux \
|
--enable-targets=powerpcle-linux \
|
||||||
%endif
|
%endif
|
||||||
%ifarch ppc64le %{mips} riscv64
|
%ifarch ppc64le %{mips}
|
||||||
--disable-multilib \
|
--disable-multilib \
|
||||||
%else
|
%else
|
||||||
--enable-multilib \
|
--enable-multilib \
|
||||||
|
@ -1076,6 +1084,9 @@ CONFIGURE_OPTS="\
|
||||||
%ifarch mips64 mips64el
|
%ifarch mips64 mips64el
|
||||||
--with-arch=mips64r2 --with-abi=64 \
|
--with-arch=mips64r2 --with-abi=64 \
|
||||||
%endif
|
%endif
|
||||||
|
%ifarch riscv64
|
||||||
|
--with-arch=rv64gc --with-abi=lp64d --with-multilib-list=lp64d \
|
||||||
|
%endif
|
||||||
%ifnarch sparc sparcv9 ppc
|
%ifnarch sparc sparcv9 ppc
|
||||||
--build=%{gcc_target_platform} \
|
--build=%{gcc_target_platform} \
|
||||||
%endif
|
%endif
|
||||||
|
@ -1089,7 +1100,7 @@ CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \
|
||||||
--enable-languages=c,c++,fortran${enablelobjc}${enablelada}${enablelgo}${enableld},lto \
|
--enable-languages=c,c++,fortran${enablelobjc}${enablelada}${enablelgo}${enableld},lto \
|
||||||
$CONFIGURE_OPTS
|
$CONFIGURE_OPTS
|
||||||
|
|
||||||
%ifarch sparc sparcv9 sparc64
|
%ifarch sparc sparcv9 sparc64 riscv64
|
||||||
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" bootstrap
|
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" bootstrap
|
||||||
%else
|
%else
|
||||||
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" profiledbootstrap
|
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" profiledbootstrap
|
||||||
|
@ -1190,6 +1201,17 @@ find rpm.doc -name \*ChangeLog\* | xargs bzip2 -9
|
||||||
|
|
||||||
%install
|
%install
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
|
mkdir -p %{buildroot}
|
||||||
|
|
||||||
|
# RISC-V ABI wants to install everything in /lib64/lp64d or /usr/lib64/lp64d.
|
||||||
|
# Make these be symlinks to /lib64 or /usr/lib64 respectively. See:
|
||||||
|
# https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/DRHT5YTPK4WWVGL3GIN5BF2IKX2ODHZ3/
|
||||||
|
%ifarch riscv64
|
||||||
|
for d in %{buildroot}%{_libdir} %{buildroot}/%{_lib} %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib} %{buildroot}%{_prefix}/include/c++/%{gcc_major}/%{gcc_target_platform}/%{_lib}; do
|
||||||
|
mkdir -p $d
|
||||||
|
(cd $d && ln -sf . lp64d)
|
||||||
|
done
|
||||||
|
%endif
|
||||||
|
|
||||||
%if %{build_offload_nvptx}
|
%if %{build_offload_nvptx}
|
||||||
cd nvptx-tools-%{nvptx_tools_gitrev}
|
cd nvptx-tools-%{nvptx_tools_gitrev}
|
||||||
|
@ -1332,6 +1354,8 @@ find %{buildroot} -name \*.la | xargs rm -f
|
||||||
|
|
||||||
mv %{buildroot}%{_prefix}/%{_lib}/libgfortran.spec $FULLPATH/
|
mv %{buildroot}%{_prefix}/%{_lib}/libgfortran.spec $FULLPATH/
|
||||||
%if %{build_d}
|
%if %{build_d}
|
||||||
|
find %{buildroot} -name libgphobos.spec
|
||||||
|
find %{buildroot}
|
||||||
mv %{buildroot}%{_prefix}/%{_lib}/libgphobos.spec $FULLPATH/
|
mv %{buildroot}%{_prefix}/%{_lib}/libgphobos.spec $FULLPATH/
|
||||||
%endif
|
%endif
|
||||||
%if %{build_libitm}
|
%if %{build_libitm}
|
||||||
|
@ -2531,6 +2555,10 @@ fi
|
||||||
%dir %{_datadir}/gdb/auto-load
|
%dir %{_datadir}/gdb/auto-load
|
||||||
%dir %{_datadir}/gdb/auto-load/%{_prefix}
|
%dir %{_datadir}/gdb/auto-load/%{_prefix}
|
||||||
%dir %{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/
|
%dir %{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/
|
||||||
|
# Package symlink to keep compatibility
|
||||||
|
%ifarch riscv64
|
||||||
|
%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/lp64d
|
||||||
|
%endif
|
||||||
%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/libstdc*gdb.py*
|
%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/libstdc*gdb.py*
|
||||||
%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/__pycache__
|
%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/__pycache__
|
||||||
%dir %{_prefix}/share/gcc-%{gcc_major}
|
%dir %{_prefix}/share/gcc-%{gcc_major}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
diff --git a/libphobos/libdruntime/core/atomic.d b/libphobos/libdruntime/core/atomic.d
|
||||||
|
index 0b39cddb6..5a6c4b854 100644
|
||||||
|
--- a/libphobos/libdruntime/core/atomic.d
|
||||||
|
+++ b/libphobos/libdruntime/core/atomic.d
|
||||||
|
@@ -1353,7 +1353,7 @@ else version (GNU)
|
||||||
|
|
||||||
|
private bool casImpl(T,V1,V2)( shared(T)* here, V1 ifThis, V2 writeThis ) pure nothrow @nogc @trusted
|
||||||
|
{
|
||||||
|
- static assert(GNU_Have_Atomics, "cas() not supported on this architecture");
|
||||||
|
+ static assert(GNU_Have_Atomics || GNU_Have_LibAtomic, "cas() not supported on this architecture");
|
||||||
|
bool res = void;
|
||||||
|
|
||||||
|
static if (T.sizeof == byte.sizeof)
|
||||||
|
@@ -1406,7 +1406,7 @@ else version (GNU)
|
||||||
|
{
|
||||||
|
static assert(ms != MemoryOrder.rel, "Invalid MemoryOrder for atomicLoad");
|
||||||
|
static assert(__traits(isPOD, T), "argument to atomicLoad() must be POD");
|
||||||
|
- static assert(GNU_Have_Atomics, "atomicLoad() not supported on this architecture");
|
||||||
|
+ static assert(GNU_Have_Atomics || GNU_Have_LibAtomic, "atomicLoad() not supported on this architecture");
|
||||||
|
|
||||||
|
static if (T.sizeof == ubyte.sizeof)
|
||||||
|
{
|
||||||
|
@@ -1444,7 +1444,7 @@ else version (GNU)
|
||||||
|
{
|
||||||
|
static assert(ms != MemoryOrder.acq, "Invalid MemoryOrder for atomicStore");
|
||||||
|
static assert(__traits(isPOD, T), "argument to atomicLoad() must be POD");
|
||||||
|
- static assert(GNU_Have_Atomics, "atomicStore() not supported on this architecture");
|
||||||
|
+ static assert(GNU_Have_Atomics || GNU_Have_LibAtomic, "atomicStore() not supported on this architecture");
|
||||||
|
|
||||||
|
static if (T.sizeof == ubyte.sizeof)
|
||||||
|
{
|
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
|
||||||
|
index 2b2a97468..f8775b712 100644
|
||||||
|
--- a/libphobos/configure.tgt
|
||||||
|
+++ b/libphobos/configure.tgt
|
||||||
|
@@ -30,6 +30,8 @@ case "${target}" in
|
||||||
|
;;
|
||||||
|
x86_64-*-linux* | i?86-*-linux*)
|
||||||
|
;;
|
||||||
|
+ riscv*-*-linux*)
|
||||||
|
+ ;;
|
||||||
|
*)
|
||||||
|
UNSUPPORTED=1
|
||||||
|
;;
|
Loading…
Reference in New Issue