[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 00/16] 64-bit RISC-V support
From: |
W. J. van der Laan |
Subject: |
[PATCH 00/16] 64-bit RISC-V support |
Date: |
Sat, 24 Apr 2021 14:17:38 +0000 |
This patch set is the bare minimum to make mescc self-hosting on 64 bit RISC-V.
The exact architecture targeted is RV64IM: 64-bit RISC-V with Multiply
extension. A lowest common denominator. It also adds some basic constants to
prepare for RISC-V 32 bit.
Due to some compromises that were made around immediate values, alignment, and
conditionals, current generated code is much slower than necessary. This can be
improved in future work.
I have developed and tested this on Fedora on a SiFive Unleashed board. All the
tests pass except for "pointer-arithmetic" and "extern", both for gcc and mescc
so at least they are on-par.
Required patches for M1 and hex2_linker can be found at
https://github.com/laanwj/guix-mescc-tools/commits/riscv . I will upstream
these to mescc-tools separately.
W. J. van der Laan (16):
lib/tests: Pass int to va_arg instead of char.
mescc: Add r0-cmp-r1 instruction.
configure: Recognize RISC-V architectures.
mes: Add RISC-V architecture detection.
lib: Make Linux scaffold work for RV64.
lib: Add RV64 Linux syscall numbers header.
lib: Base riscv64-mes-gcc support (dummy setjmp).
lib: Linux riscv64-mes-gcc support.
lib: Add _sys_call_5 for Linux RV64.
lib: General Linux RV64 syscall support.
lib/tests: Take RISC-V into account in size conditionals.
lib: Make stdarg work for GCC on RV64.
mescc: RV64 code generation.
lib: Add RV64 instruction macros for M1
lib: Base riscv64-mes-mescc support.
lib: Linux riscv64-mes-mescc support.
build-aux/build-guile.sh | 2 +
configure | 8 +-
include/fcntl.h | 4 +
include/linux/riscv64/syscall.h | 91 +++
include/linux/syscall.h | 1 +
include/stdarg.h | 14 +-
include/stdint.h | 4 +-
include/sys/stat.h | 4 +-
lib/linux/_open3.c | 6 +
lib/linux/access.c | 9 +-
lib/linux/chmod.c | 7 +
lib/linux/dup2.c | 6 +
lib/linux/fork.c | 8 +
lib/linux/getdents.c | 6 +
lib/linux/link.c | 7 +
lib/linux/lstat.c | 8 +
lib/linux/mkdir.c | 7 +
lib/linux/mknod.c | 7 +
lib/linux/pipe.c | 7 +
lib/linux/readlink.c | 7 +
lib/linux/rename.c | 7 +
lib/linux/riscv64-mes-gcc/_exit.c | 38 +
lib/linux/riscv64-mes-gcc/_write.c | 40 +
lib/linux/riscv64-mes-gcc/crt1.c | 90 +++
lib/linux/riscv64-mes-gcc/exit-42.S | 31 +
lib/linux/riscv64-mes-gcc/hello-mes.S | 45 ++
lib/linux/riscv64-mes-gcc/syscall-internal.c | 62 ++
lib/linux/riscv64-mes-gcc/syscall.c | 197 +++++
lib/linux/riscv64-mes-mescc/_exit.c | 31 +
lib/linux/riscv64-mes-mescc/_write.c | 33 +
lib/linux/riscv64-mes-mescc/crt1.c | 70 ++
.../riscv64-mes-mescc/syscall-internal.c | 56 ++
lib/linux/riscv64-mes-mescc/syscall.c | 182 +++++
lib/linux/riscv64-mes/elf64-0exit-42.hex2 | 34 +
lib/linux/riscv64-mes/elf64-0header.hex2 | 84 ++
lib/linux/riscv64-mes/elf64-0hello-mes.hex2 | 59 ++
lib/linux/riscv64-mes/elf64-body-exit-42.hex2 | 53 ++
.../riscv64-mes/elf64-body-hello-mes.hex2 | 70 ++
.../riscv64-mes/elf64-footer-single-main.hex2 | 62 ++
lib/linux/riscv64-mes/elf64-header.hex2 | 241 ++++++
lib/linux/rmdir.c | 7 +
lib/linux/signal.c | 9 -
lib/linux/stat.c | 7 +
lib/linux/symlink.c | 7 +
lib/linux/unlink.c | 7 +
lib/linux/waitpid.c | 2 +-
lib/riscv64-mes-gcc/setjmp.c | 39 +
lib/riscv64-mes-mescc/setjmp.c | 47 ++
lib/riscv64-mes/riscv64.M1 | 349 +++++++++
lib/tests/scaffold/70-stdarg.c | 6 +-
lib/tests/scaffold/76-pointer-arithmetic.c | 4 +-
lib/tests/scaffold/7k-for-each-elem.c | 6 +-
lib/tests/scaffold/85-sizeof.c | 4 +-
mes/module/mescc/mescc.mes | 1 +
mes/module/mescc/riscv64/as.mes | 24 +
mes/module/mescc/riscv64/info.mes | 23 +
module/mescc/armv4/as.scm | 1 +
module/mescc/compile.scm | 10 +-
module/mescc/i386/as.scm | 1 +
module/mescc/mescc.scm | 37 +-
module/mescc/riscv64/as.scm | 738 ++++++++++++++++++
module/mescc/riscv64/info.scm | 63 ++
module/mescc/x86_64/as.scm | 1 +
src/mes.c | 8 +
64 files changed, 3055 insertions(+), 44 deletions(-)
create mode 100644 include/linux/riscv64/syscall.h
create mode 100644 lib/linux/riscv64-mes-gcc/_exit.c
create mode 100644 lib/linux/riscv64-mes-gcc/_write.c
create mode 100644 lib/linux/riscv64-mes-gcc/crt1.c
create mode 100644 lib/linux/riscv64-mes-gcc/exit-42.S
create mode 100644 lib/linux/riscv64-mes-gcc/hello-mes.S
create mode 100644 lib/linux/riscv64-mes-gcc/syscall-internal.c
create mode 100644 lib/linux/riscv64-mes-gcc/syscall.c
create mode 100644 lib/linux/riscv64-mes-mescc/_exit.c
create mode 100644 lib/linux/riscv64-mes-mescc/_write.c
create mode 100644 lib/linux/riscv64-mes-mescc/crt1.c
create mode 100644 lib/linux/riscv64-mes-mescc/syscall-internal.c
create mode 100644 lib/linux/riscv64-mes-mescc/syscall.c
create mode 100644 lib/linux/riscv64-mes/elf64-0exit-42.hex2
create mode 100644 lib/linux/riscv64-mes/elf64-0header.hex2
create mode 100644 lib/linux/riscv64-mes/elf64-0hello-mes.hex2
create mode 100644 lib/linux/riscv64-mes/elf64-body-exit-42.hex2
create mode 100644 lib/linux/riscv64-mes/elf64-body-hello-mes.hex2
create mode 100644 lib/linux/riscv64-mes/elf64-footer-single-main.hex2
create mode 100644 lib/linux/riscv64-mes/elf64-header.hex2
create mode 100644 lib/riscv64-mes-gcc/setjmp.c
create mode 100644 lib/riscv64-mes-mescc/setjmp.c
create mode 100644 lib/riscv64-mes/riscv64.M1
create mode 100644 mes/module/mescc/riscv64/as.mes
create mode 100644 mes/module/mescc/riscv64/info.mes
create mode 100644 module/mescc/riscv64/as.scm
create mode 100644 module/mescc/riscv64/info.scm
--
2.27.0
- [PATCH 00/16] 64-bit RISC-V support,
W. J. van der Laan <=