xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/riscv/int_mul_impl.inc (revision 2a58b312b62f908ec92311d1bd8536dbaeb8e55b)
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#ifndef __mulxi3
14#error "__mulxi3 must be defined to use this generic implementation"
15#endif
16
17	.text
18	.align 2
19
20	.globl __mulxi3
21	.type  __mulxi3, @function
22__mulxi3:
23	mv     a2, a0
24	mv     a0, zero
25.L1:
26	andi   a3, a1, 1
27	beqz   a3, .L2
28	add    a0, a0, a2
29.L2:
30	srli   a1, a1, 1
31	slli   a2, a2, 1
32	bnez   a1, .L1
33	ret
34