Skip to content

Commit 5fa1f1e

Browse files
kamleshbhaluitstellar
authored andcommitted
[RISCV-V] Provide muldi3 builtin assembly implementation
Provides an assembly implementation of muldi3 for RISC-V, to solve bug 43388. Since the implementation is the same as for mulsi3, that code was moved to `riscv/int_mul_impl.inc` and is now reused by both `mulsi3.S` and `muldi3.S`. Differential Revision: https://reviews.llvm.org/D80465 (cherry picked from commit e31ccee)
1 parent 249fef0 commit 5fa1f1e

File tree

3 files changed

+46
-19
lines changed

3 files changed

+46
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===-- int_mul_impl.inc - Integer multiplication -------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// Helpers used by __mulsi3, __muldi3.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#if !defined(__riscv_mul)
14+
.text
15+
.align 2
16+
17+
.globl __mulxi3
18+
.type __mulxi3, @function
19+
__mulxi3:
20+
mv a2, a0
21+
mv a0, zero
22+
.L1:
23+
andi a3, a1, 1
24+
beqz a3, .L2
25+
add a0, a0, a2
26+
.L2:
27+
srli a1, a1, 1
28+
slli a2, a2, 1
29+
bnez a1, .L1
30+
ret
31+
#endif
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//===--- muldi3.S - Integer multiplication routines -----------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#if __riscv_xlen == 64
9+
#define __mulxi3 __muldi3
10+
#include "int_mul_impl.inc"
11+
#endif
+4-19
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
1-
//===--- mulsi3.S - Integer multiplication routines routines ---===//
1+
//===--- mulsi3.S - Integer multiplication routines -----------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#if !defined(__riscv_mul) && __riscv_xlen == 32
10-
.text
11-
.align 2
12-
13-
.globl __mulsi3
14-
.type __mulsi3, @function
15-
__mulsi3:
16-
mv a2, a0
17-
mv a0, zero
18-
.L1:
19-
andi a3, a1, 1
20-
beqz a3, .L2
21-
add a0, a0, a2
22-
.L2:
23-
srli a1, a1, 1
24-
slli a2, a2, 1
25-
bnez a1, .L1
26-
ret
9+
#if __riscv_xlen == 32
10+
#define __mulxi3 __mulsi3
11+
#include "int_mul_impl.inc"
2712
#endif

0 commit comments

Comments
 (0)