diff options
author | Shiva Chen <shiva0217@gmail.com> | 2018-03-01 07:47:27 +0000 |
---|---|---|
committer | Shiva Chen <shiva0217@gmail.com> | 2018-03-01 07:47:27 +0000 |
commit | 77f19a384c008d319427bf4596d7c00be3b7a82a (patch) | |
tree | 0039897e598a699d2fed86daffcd36f8d831e81a /compiler-rt/lib/builtins | |
parent | e6e534ca22fb38ca06b92d87c7847920f5bf3fe9 (diff) | |
download | bcm5719-llvm-77f19a384c008d319427bf4596d7c00be3b7a82a.tar.gz bcm5719-llvm-77f19a384c008d319427bf4596d7c00be3b7a82a.zip |
[PATCH] [compiler-rt, RISCV] Support builtins for RISC-V
Summary:
Support builtins for RISC-V, RV32 and RV64.
Reviewers: asb, apazos, mgrang
Differential Revision: https://reviews.llvm.org/D42958
llvm-svn: 326420
Diffstat (limited to 'compiler-rt/lib/builtins')
-rw-r--r-- | compiler-rt/lib/builtins/CMakeLists.txt | 6 | ||||
-rw-r--r-- | compiler-rt/lib/builtins/int_types.h | 2 | ||||
-rw-r--r-- | compiler-rt/lib/builtins/riscv/mulsi3.S | 28 |
3 files changed, 35 insertions, 1 deletions
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 13158b90378..6c48a404a18 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -480,6 +480,12 @@ set(powerpc64_SOURCES ${GENERIC_SOURCES}) set(powerpc64le_SOURCES ${powerpc64_SOURCES}) +set(riscv_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES}) +set(riscv32_SOURCES + riscv/mulsi3.S + ${riscv_SOURCES}) +set(riscv64_SOURCES ${riscv_SOURCES}) + set(wasm32_SOURCES ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES}) diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index a92238c5b73..f53f343d35d 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -60,7 +60,7 @@ typedef union }s; } udwords; -#if (defined(__LP64__) || defined(__wasm__) || defined(__mips64)) +#if (defined(__LP64__) || defined(__wasm__) || defined(__mips64)) || defined(__riscv) #define CRT_HAS_128BIT #endif diff --git a/compiler-rt/lib/builtins/riscv/mulsi3.S b/compiler-rt/lib/builtins/riscv/mulsi3.S new file mode 100644 index 00000000000..a58d237040b --- /dev/null +++ b/compiler-rt/lib/builtins/riscv/mulsi3.S @@ -0,0 +1,28 @@ +//===--- mulsi3.S - Integer multiplication routines routines ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if !defined(__riscv_mul) && __riscv_xlen == 32 + .text + .align 2 + + .globl __mulsi3 + .type __mulsi3, @function +__mulsi3: + mv a2, a0 + mv a0, zero +.L1: + andi a3, a1, 1 + beqz a3, .L2 + add a0, a0, a2 +.L2: + srli a1, a1, 1 + slli a2, a2, 1 + bnez a1, .L1 + ret +#endif |