Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:15:27

0001 /*
0002     Copyright (C) 2023 Albin Ahlbäck
0003 
0004     This file is part of FLINT.
0005 
0006     FLINT is free software: you can redistribute it and/or modify it under
0007     the terms of the GNU Lesser General Public License (LGPL) as published
0008     by the Free Software Foundation; either version 3 of the License, or
0009     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
0010 */
0011 
0012 #ifndef LONGLONG_DIV_H
0013 #define LONGLONG_DIV_H
0014 
0015 #if defined (__amd64__) || (FLINT_BITS == 32 && (defined (__i386__) || defined (__i486__)))
0016 
0017 # if FLINT_BITS == 64 && defined (__amd64__)
0018 #  define _FLINT_ASM_DIV "divq"
0019 #  define _FLINT_ASM_IDIV "idivq"
0020 # else
0021 #  define _FLINT_ASM_DIV "divl"
0022 #  define _FLINT_ASM_IDIV "idivl"
0023 # endif
0024 
0025 # define udiv_qrnnd(q, r, n1, n0, dx) \
0026   __asm__ volatile (_FLINT_ASM_DIV " %4" \
0027     : "=a" (q), "=d" (r) \
0028     : "0" ((ulong)(n0)), "1" ((ulong)(n1)), \
0029       "rm" ((ulong)(dx)))
0030 
0031 # define sdiv_qrnnd(q, r, n1, n0, dx) \
0032   __asm__ volatile (_FLINT_ASM_IDIV " %4" \
0033     : "=a" (q), "=d" (r) \
0034     : "0" ((ulong)(n0)), "1" ((ulong)(n1)), \
0035       "rm" ((ulong)(dx)))
0036 #endif
0037 
0038 #endif