Index: compiler-rt/lib/builtins/CMakeLists.txt =================================================================== --- compiler-rt/lib/builtins/CMakeLists.txt +++ compiler-rt/lib/builtins/CMakeLists.txt @@ -559,7 +559,10 @@ riscv/mulsi3.S ${riscv_SOURCES} ) -set(riscv64_SOURCES ${riscv_SOURCES}) +set(riscv64_SOURCES + riscv/muldi3.S + ${riscv_SOURCES} +) set(sparc_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES}) set(sparcv9_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES}) Index: compiler-rt/lib/builtins/riscv/muldi3.S =================================================================== --- /dev/null +++ compiler-rt/lib/builtins/riscv/muldi3.S @@ -0,0 +1,27 @@ +//===--- muldi3.S - Integer multiplication routines routines ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if !defined(__riscv_mul) && __riscv_xlen == 64 + .text + .align 2 + + .globl __muldi3 + .type __muldi3, @function +__muldi3: + 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