1/* Integer multiplication routines for RISC-V. 2 3 Copyright (C) 2016-2022 Free Software Foundation, Inc. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify it under 8the terms of the GNU General Public License as published by the Free 9Software Foundation; either version 3, or (at your option) any later 10version. 11 12GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13WARRANTY; without even the implied warranty of MERCHANTABILITY or 14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15for more details. 16 17Under Section 7 of GPL version 3, you are granted additional 18permissions described in the GCC Runtime Library Exception, version 193.1, as published by the Free Software Foundation. 20 21You should have received a copy of the GNU General Public License and 22a copy of the GCC Runtime Library Exception along with this program; 23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24<http://www.gnu.org/licenses/>. */ 25 26#include "riscv-asm.h" 27 28 .text 29 .align 2 30 31#if __riscv_xlen == 32 32/* Our RV64 64-bit routine is equivalent to our RV32 32-bit routine. */ 33# define __muldi3 __mulsi3 34#endif 35 36FUNC_BEGIN (__muldi3) 37 mv a2, a0 38 li a0, 0 39.L1: 40 andi a3, a1, 1 41 beqz a3, .L2 42 add a0, a0, a2 43.L2: 44 srli a1, a1, 1 45 slli a2, a2, 1 46 bnez a1, .L1 47 ret 48FUNC_END (__muldi3) 49