(root)/
gcc-13.2.0/
libgcc/
config/
msp430/
lib2divSI.c
       1  /* SI mode divide routines for libgcc for MSP430
       2     Copyright (C) 2012-2023 Free Software Foundation, Inc.
       3     Contributed by Red Hat.
       4  
       5     This file is part of GCC.
       6  
       7     GCC is free software; you can redistribute it and/or modify it
       8     under the terms of the GNU General Public License as published
       9     by the Free Software Foundation; either version 3, or (at your
      10     option) any later version.
      11  
      12     GCC is distributed in the hope that it will be useful, but WITHOUT
      13     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
      14     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
      15     License for more details.
      16  
      17     Under Section 7 of GPL version 3, you are granted additional
      18     permissions described in the GCC Runtime Library Exception, version
      19     3.1, as published by the Free Software Foundation.
      20  
      21     You should have received a copy of the GNU General Public License and
      22     a copy of the GCC Runtime Library Exception along with this program;
      23     see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      24     <http://www.gnu.org/licenses/>.  */
      25  
      26  typedef          int  sint32_type   __attribute__ ((mode (SI)));
      27  typedef unsigned int  uint32_type   __attribute__ ((mode (SI)));
      28  typedef          int  sint16_type   __attribute__ ((mode (HI)));
      29  typedef unsigned int  uint16_type   __attribute__ ((mode (HI)));
      30  typedef          int  sint08_type   __attribute__ ((mode (QI)));
      31  typedef unsigned int  uint08_type   __attribute__ ((mode (QI)));
      32  typedef int           word_type     __attribute__ ((mode (__word__)));
      33  
      34  #define C3B(a,b,c) a##b##c
      35  #define C3(a,b,c) C3B(a,b,c)
      36  
      37  #define UINT_TYPE	uint32_type
      38  #define SINT_TYPE	sint32_type
      39  #define BITS_MINUS_1	31
      40  #define NAME_MODE	si
      41  
      42  #include "msp430-divmod.h"
      43  
      44  /* ---------------------------------------------------------------------*/
      45  
      46  /* There is a typo in the MSP430 ABI document.  It calls the unsigned
      47     long integer division function __mspabi_divlu when it should be
      48     __mspabi_divul.  Likewise the unsigned long long integer division
      49     function is called __mspabi_divllu when it should be __mspabi_divull.
      50  
      51     Earlier versions of this toolchain used generate the ABI compliant
      52     names, so in order to support object files built with those tools
      53     we provide stub functions that call the correct routines.  */
      54  
      55  asm (".global __mspabi_divlu\n\
      56           .set __mspabi_divlu, __mspabi_divul");
      57  
      58  /* We cannot use the same trick for __mspabi_divllu as that is defined
      59     in a different file.  Instead we create a stub here.  The cost of
      60     executing the branch instruction will be trivial compared to the
      61     cost of executing a long long division.  */
      62  
      63  #ifdef __MSP430X_LARGE__
      64  asm (".global __mspabi_divllu\n\
      65        __mspabi_divllu:\n\
      66             BRA #__mspabi_divull");
      67  #else
      68  asm (".global __mspabi_divllu\n\
      69        __mspabi_divllu:\n\
      70             BR #__mspabi_divull");
      71  #endif