Skip to content

Commit

Permalink
Add RISC-V support
Browse files Browse the repository at this point in the history
This patch adds support for the RISC-V architecture (https://riscv.org).

This patch has been tested using QEMU user-mode emulation and GCC 7.2.0
in the following configurations:

* -march=rv32imac -mabi=ilp32
* -march=rv32g -mabi=ilp32d
* -march=rv64imac -mabi=lp64
* -march=rv64g -mabi=lp64d

The ABI currently can be found at
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md .
  • Loading branch information
sorear committed Feb 19, 2018
1 parent 9429968 commit 9a18b0d
Show file tree
Hide file tree
Showing 6 changed files with 735 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ noinst_HEADERS = \
src/or1k/ffitarget.h \
src/pa/ffitarget.h \
src/powerpc/ffitarget.h src/powerpc/asm.h src/powerpc/ffi_powerpc.h \
src/riscv/ffitarget.h \
src/s390/ffitarget.h src/s390/internal.h \
src/sh/ffitarget.h \
src/sh64/ffitarget.h \
Expand Down Expand Up @@ -144,6 +145,7 @@ EXTRA_libffi_la_SOURCES = \
src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
src/powerpc/aix.S src/powerpc/darwin.S src/powerpc/aix_closure.S \
src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \
src/riscv/ffi.c src/riscv/sysv.S \
src/s390/ffi.c src/s390/sysv.S \
src/sh/ffi.c src/sh/sysv.S \
src/sh64/ffi.c src/sh64/sysv.S \
Expand Down
4 changes: 4 additions & 0 deletions configure.host
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ case "${host}" in
TARGET=POWERPC; TARGETDIR=powerpc
;;

riscv*-*)
TARGET=RISCV; TARGETDIR=riscv
;;

s390-*-* | s390x-*-*)
TARGET=S390; TARGETDIR=s390
SOURCES="ffi.c sysv.S"
Expand Down
2 changes: 2 additions & 0 deletions include/ffi_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void ffi_type_test(ffi_type *a, char *file, int line);
#define FFI_ASSERT_VALID_TYPE(x)
#endif

/* v cast to size_t and aligned up to a multiple of a */
#define FFI_ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
/* v cast to size_t and aligned down to a multiple of a */
#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)

/* Perform machine dependent cif processing */
Expand Down
Loading

0 comments on commit 9a18b0d

Please sign in to comment.