aboutsummaryrefslogtreecommitdiff
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2019-04-23 22:53:12 +0000
committerIain Buclaw <ibuclaw@gdcproject.org>2019-04-23 22:53:12 +0000
commit952a73f81703fea946b05b264ea7ba772c8dacac (patch)
tree1eaa98a40c61f1dcde726eeb560ca71882af7b82 /libphobos
parent2862c8a0350fa92a94a8522d3da441a5e3434d82 (diff)
libphobos: Add D support for RISC-V Linux
2019-04-23 Iain Buclaw <ibuclaw@gdcproject.org> * configure.tgt: Add riscv*-*-linux* as supported target. * libdruntime/gcc/sections/elf_shared.d (getDependencies): Adjust dlpi_addr on RISCV32 and RISCV64. * src/std/math.d: Add IEEE FPU control support for RISCV. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@270522 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/ChangeLog7
-rw-r--r--libphobos/configure.tgt3
-rw-r--r--libphobos/libdruntime/gcc/sections/elf_shared.d14
-rw-r--r--libphobos/src/std/math.d33
4 files changed, 56 insertions, 1 deletions
diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog
index 74c9c88730d..1f5ea28ddf7 100644
--- a/libphobos/ChangeLog
+++ b/libphobos/ChangeLog
@@ -1,3 +1,10 @@
+2019-04-23 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * configure.tgt: Add linux/riscv as supported target.
+ * libdruntime/gcc/sections/elf_shared.d (getDependencies): Adjust
+ dlpi_addr on RISCV32 and RISCV64.
+ * src/std/math.d: Add IEEE FPU control support for RISC-V.
+
2019-04-23 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Bernd Edlinger <bernd.edlinger@hotmail.de>
Jakub Jelinek <jakub@redhat.com>
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index b30f0858108..5deba2a9961 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -29,6 +29,9 @@ case "${target}" in
mips*-*-linux*)
LIBPHOBOS_SUPPORTED=yes
;;
+ riscv*-*-linux*)
+ LIBPHOBOS_SUPPORTED=yes
+ ;;
x86_64-*-kfreebsd*-gnu | i?86-*-kfreebsd*-gnu)
LIBPHOBOS_SUPPORTED=yes
;;
diff --git a/libphobos/libdruntime/gcc/sections/elf_shared.d b/libphobos/libdruntime/gcc/sections/elf_shared.d
index 4cf5a233fc4..89adcea889e 100644
--- a/libphobos/libdruntime/gcc/sections/elf_shared.d
+++ b/libphobos/libdruntime/gcc/sections/elf_shared.d
@@ -22,6 +22,9 @@
module gcc.sections.elf_shared;
+version (RISCV32) version = RISCV_Any;
+version (RISCV64) version = RISCV_Any;
+
version (CRuntime_Glibc) enum SharedELF = true;
else version (CRuntime_Musl) enum SharedELF = true;
else version (FreeBSD) enum SharedELF = true;
@@ -723,7 +726,16 @@ version (Shared)
version (CRuntime_Musl)
strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
else version (linux)
- strtab = cast(const(char)*)dyn.d_un.d_ptr;
+ {
+ // This might change in future glibc releases (after 2.29) as dynamic sections
+ // are not required to be read-only on RISC-V. This was copy & pasted from MIPS
+ // while upstreaming RISC-V support. Otherwise MIPS is the only arch which sets
+ // in glibc: #define DL_RO_DYN_SECTION 1
+ version (RISCV_Any)
+ strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
+ else
+ strtab = cast(const(char)*)dyn.d_un.d_ptr;
+ }
else version (FreeBSD)
strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
else version (NetBSD)
diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d
index daee6ec3c33..6dec9cee9a0 100644
--- a/libphobos/src/std/math.d
+++ b/libphobos/src/std/math.d
@@ -4757,6 +4757,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");
}
@@ -4831,6 +4840,14 @@ private:
}
}
}
+ else version (RISCV_Any)
+ {
+ uint newValues = 0x0;
+ asm pure nothrow @nogc
+ {
+ "fsflags %0" : : "r" newValues;
+ }
+ }
else
assert(0, "Not yet supported");
}
@@ -5423,6 +5440,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");
}
@@ -5508,6 +5534,13 @@ private:
}
}
}
+ else version (RISCV_Any)
+ {
+ asm pure nothrow @nogc
+ {
+ "fscsr %0" : : "r" (newState);
+ }
+ }
else
assert(0, "Not yet supported");
}