From a89a14ef5da44684a16b204e7a70460cc8c4922a Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 21 Jun 2024 23:36:36 +0200 Subject: Basic constant folding implementation --- vendor/gmp-6.3.0/mpn/m68k/README | 138 ++++++++++++++ vendor/gmp-6.3.0/mpn/m68k/aors_n.asm | 99 ++++++++++ vendor/gmp-6.3.0/mpn/m68k/gmp-mparam.h | 76 ++++++++ vendor/gmp-6.3.0/mpn/m68k/lshift.asm | 175 ++++++++++++++++++ vendor/gmp-6.3.0/mpn/m68k/m68k-defs.m4 | 230 ++++++++++++++++++++++++ vendor/gmp-6.3.0/mpn/m68k/mc68020/aorsmul_1.asm | 101 +++++++++++ vendor/gmp-6.3.0/mpn/m68k/mc68020/mul_1.asm | 96 ++++++++++ vendor/gmp-6.3.0/mpn/m68k/mc68020/udiv.asm | 45 +++++ vendor/gmp-6.3.0/mpn/m68k/mc68020/umul.asm | 44 +++++ vendor/gmp-6.3.0/mpn/m68k/rshift.asm | 175 ++++++++++++++++++ vendor/gmp-6.3.0/mpn/m68k/t-m68k-defs.pl | 91 ++++++++++ 11 files changed, 1270 insertions(+) create mode 100644 vendor/gmp-6.3.0/mpn/m68k/README create mode 100644 vendor/gmp-6.3.0/mpn/m68k/aors_n.asm create mode 100644 vendor/gmp-6.3.0/mpn/m68k/gmp-mparam.h create mode 100644 vendor/gmp-6.3.0/mpn/m68k/lshift.asm create mode 100644 vendor/gmp-6.3.0/mpn/m68k/m68k-defs.m4 create mode 100644 vendor/gmp-6.3.0/mpn/m68k/mc68020/aorsmul_1.asm create mode 100644 vendor/gmp-6.3.0/mpn/m68k/mc68020/mul_1.asm create mode 100644 vendor/gmp-6.3.0/mpn/m68k/mc68020/udiv.asm create mode 100644 vendor/gmp-6.3.0/mpn/m68k/mc68020/umul.asm create mode 100644 vendor/gmp-6.3.0/mpn/m68k/rshift.asm create mode 100644 vendor/gmp-6.3.0/mpn/m68k/t-m68k-defs.pl (limited to 'vendor/gmp-6.3.0/mpn/m68k') diff --git a/vendor/gmp-6.3.0/mpn/m68k/README b/vendor/gmp-6.3.0/mpn/m68k/README new file mode 100644 index 0000000..5261564 --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/README @@ -0,0 +1,138 @@ +Copyright 2001, 2003, 2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. + + + + + + M68K MPN SUBROUTINES + + +This directory contains mpn functions for various m68k family chips. + + +CODE ORGANIZATION + + m68k m68000, m68010, m68060 + m68k/mc68020 m68020, m68030, m68040, and CPU32 + + +The m5200 "coldfire", which is m68000 less a few instructions, currently has +no assembler code support. + + +STATUS + +The code herein is old and poorly maintained. If somebody really cared, it +could be optimized substantially. For example, + +* mpn_add_n and mpn_sub_n could, with more unrolling be improved from 6 to + close to 4 c/l (on m68040). + +* The multiplication loops could be sped up by using the FPU. + +* mpn_lshift by 31 should use the special-case mpn_rshift by 1 code, and + vice versa mpn_rshift by 31 use the special lshift by 1, when operand + overlap permits. + +* On 68000, mpn_mul_1, mpn_addmul_1 and mpn_submul_1 could check for a + 16-bit multiplier and use two multiplies per limb, not four. + + Similarly various other _1 operations like mpn_mod_1, mpn_divrem_1, + mpn_divexact_1, mpn_modexact_1c_odd. + +* On 68000, mpn_lshift and mpn_rshift could use a roll and mask instead of + lsrl and lsll. This promises to be a speedup, effectively trading a 6+2*n + shift for one or two 4 cycle masks. Suggested by Jean-Charles Meyrignac. + +* config.guess detects 68000, 68010, CPU32 and 68020 by running some code, + but relies on system information for 030, 040 and 060. Can they be + identified by running some code? Currently this only makes a difference + to the compiler options selected, since we have no specific asm code for + those chips. + +One novel idea for 68000 would be to use a 16-bit limb instead of 32-bits. +This would suit the native 16x16 multiply, but might make it difficult to +get full value from the native 32x32 add/sub/etc. This would be an ABI +option, and would select "__GMP_SHORT_LIMB" in gmp.h. + +Naturally an entirely new set of asm subroutines would be needed for a +16-bit limb. Also there's various places in the C code assuming limb>=long, +which would need to be updated, eg. mpz_set_ui. Some of the nails changes +may have helped cover some of this. + + +ASM FILES + +The .asm files are put through m4 for macro processing, and with the help of +configure give either MIT or Motorola syntax. The generic mpn/asm-defs.m4 +is used, together with mpn/m68k/m68k-defs.m4. See comments in those files. + +Not all possible syntax variations are covered. GCC config/m68k for +instance has things like $ for immediates on CRDS or reversed cmp order for +AT&T SGS. These could probably be handled if anyone really needs it. + + +CALLING CONVENTIONS + +The SVR4 standard has an int of 32 bits, and all parameters 32-bit aligned +on the stack. + +PalmOS and perhaps various embedded systems intended for 68000 however use +an int of 16 bits and parameters only 16-bit aligned on the stack. This is +generated by "gcc -mshort" (and is the default for the PalmOS gcc port, we +believe). + +The asm files adapt to these two ABIs by checking sizeof(unsigned), coming +through config.m4 as SIZEOF_UNSIGNED. Only mpn_lshift and mpn_rshift are +affected, all other routines take longs and pointers, which are 32-bits in +both cases. + +Strictly speaking the size of an int doesn't determine the stack padding +convention. But if int is 16 bits then we can definitely say the host +system is not SVR4, and therefore may as well assume we're in 16-bit stack +alignment. + + +REFERENCES + +"Motorola M68000 Family Programmer's Reference Manual", available online, + + http://e-www.motorola.com/brdata/PDFDB/docs/M68000PM.pdf + +"System V Application Binary Interface: Motorola 68000 Processor Family +Supplement", AT&T, 1990, ISBN 0-13-877553-6. Has details of calling +conventions and ELF style PIC coding. + + + +---------------- +Local variables: +mode: text +fill-column: 76 +End: diff --git a/vendor/gmp-6.3.0/mpn/m68k/aors_n.asm b/vendor/gmp-6.3.0/mpn/m68k/aors_n.asm new file mode 100644 index 0000000..f7d379e --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/aors_n.asm @@ -0,0 +1,99 @@ +dnl mc68020 mpn_add_n, mpn_sub_n -- add or subtract limb vectors + +dnl Copyright 1992, 1994, 1996, 1999-2003, 2005 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C cycles/limb +C 68040: 6 + +ifdef(`OPERATION_add_n',` + define(M4_inst, addxl) + define(M4_function_n, mpn_add_n) +',`ifdef(`OPERATION_sub_n',` + define(M4_inst, subxl) + define(M4_function_n, mpn_sub_n) +', +`m4_error(`Need OPERATION_add_n or OPERATION_sub_n +')')') + +MULFUNC_PROLOGUE(mpn_add_n mpn_sub_n) + + +C INPUT PARAMETERS +C res_ptr (sp + 4) +C s1_ptr (sp + 8) +C s2_ptr (sp + 12) +C size (sp + 16) + + +PROLOGUE(M4_function_n) + +C Save used registers on the stack. + movel d2, M(-,sp) + movel a2, M(-,sp) + +C Copy the arguments to registers. Better use movem? + movel M(sp,12), a2 + movel M(sp,16), a0 + movel M(sp,20), a1 + movel M(sp,24), d2 + + eorw #1, d2 + lsrl #1, d2 + bcc L(L1) + subql #1, d2 C clears cy as side effect + +L(Loop): + movel M(a0,+), d0 + movel M(a1,+), d1 + M4_inst d1, d0 + movel d0, M(a2,+) +L(L1): movel M(a0,+), d0 + movel M(a1,+), d1 + M4_inst d1, d0 + movel d0, M(a2,+) + + dbf d2, L(Loop) C loop until 16 lsb of %4 == -1 + subxl d0, d0 C d0 <= -cy; save cy as 0 or -1 in d0 + subl #0x10000, d2 + bcs L(L2) + addl d0, d0 C restore cy + bra L(Loop) + +L(L2): + negl d0 + +C Restore used registers from stack frame. + movel M(sp,+), a2 + movel M(sp,+), d2 + + rts + +EPILOGUE(M4_function_n) diff --git a/vendor/gmp-6.3.0/mpn/m68k/gmp-mparam.h b/vendor/gmp-6.3.0/mpn/m68k/gmp-mparam.h new file mode 100644 index 0000000..9ac7b41 --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/gmp-mparam.h @@ -0,0 +1,76 @@ +/* gmp-mparam.h -- Compiler/machine parameter header file. + +Copyright 2000-2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. */ + + +#define GMP_LIMB_BITS 32 +#define GMP_LIMB_BYTES 4 + + +/* 25MHz 68040 */ + +/* Generated by tuneup.c, 2004-02-05, gcc 3.2 */ + +#define MUL_TOOM22_THRESHOLD 14 +#define MUL_TOOM33_THRESHOLD 90 + +#define SQR_BASECASE_THRESHOLD 5 +#define SQR_TOOM2_THRESHOLD 28 +#define SQR_TOOM3_THRESHOLD 98 + +#define DIV_SB_PREINV_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIV_DC_THRESHOLD 55 +#define POWM_THRESHOLD 65 + +#define HGCD_THRESHOLD 116 +#define GCD_ACCEL_THRESHOLD 3 +#define GCD_DC_THRESHOLD 590 +#define JACOBI_BASE_METHOD 2 + +#define DIVREM_1_NORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIVREM_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define MOD_1_NORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define MOD_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* never */ +#define USE_PREINV_DIVREM_1 0 +#define USE_PREINV_MOD_1 0 +#define DIVREM_2_THRESHOLD MP_SIZE_T_MAX /* never */ +#define DIVEXACT_1_THRESHOLD MP_SIZE_T_MAX /* never */ +#define MODEXACT_1_ODD_THRESHOLD MP_SIZE_T_MAX /* never */ + +#define GET_STR_DC_THRESHOLD 18 +#define GET_STR_PRECOMPUTE_THRESHOLD 43 +#define SET_STR_THRESHOLD 937 + +#define MUL_FFT_TABLE { 336, 672, 1408, 3584, 10240, 24576, 0 } +#define MUL_FFT_MODF_THRESHOLD 296 +#define MUL_FFT_THRESHOLD 1728 + +#define SQR_FFT_TABLE { 336, 736, 1408, 3584, 10240, 24576, 0 } +#define SQR_FFT_MODF_THRESHOLD 296 +#define SQR_FFT_THRESHOLD 2304 diff --git a/vendor/gmp-6.3.0/mpn/m68k/lshift.asm b/vendor/gmp-6.3.0/mpn/m68k/lshift.asm new file mode 100644 index 0000000..f202abf --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/lshift.asm @@ -0,0 +1,175 @@ +dnl mc68020 mpn_lshift -- mpn left shift. + +dnl Copyright 1996, 1999-2003 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + + +C cycles/limb +C shift==1 shift>1 +C 68040: 5 12 + + +C mp_limb_t mpn_lshift (mp_ptr res_ptr, mp_srcptr s_ptr, mp_size_t s_size, +C unsigned cnt); +C +C The "cnt" parameter is either 16 bits or 32 bits depending on +C SIZEOF_UNSIGNED (see ABI notes in mpn/m68k/README). The value is of +C course only 1 to 31. When loaded as 16 bits there's garbage in the upper +C half, hence the use of cmpw. The shift instructions take the their count +C modulo 64, so the upper part doesn't matter to them either. +C + +C INPUT PARAMETERS +C res_ptr (sp + 4) +C s_ptr (sp + 8) +C s_size (sp + 12) +C cnt (sp + 16) + +define(res_ptr, `a1') +define(s_ptr, `a0') +define(s_size, `d6') +define(cnt, `d4') + +ifdef(`SIZEOF_UNSIGNED',, +`m4_error(`SIZEOF_UNSIGNED not defined, should be in config.m4 +')') + +PROLOGUE(mpn_lshift) +C Save used registers on the stack. + moveml d2-d6/a2, M(-,sp) + +C Copy the arguments to registers. + movel M(sp,28), res_ptr + movel M(sp,32), s_ptr + movel M(sp,36), s_size +ifelse(SIZEOF_UNSIGNED,2, +` movew M(sp,40), cnt', +` movel M(sp,40), cnt') + + moveql #1, d5 + cmpw d5, cnt + bne L(Lnormal) + cmpl s_ptr, res_ptr + bls L(Lspecial) C jump if s_ptr >= res_ptr + +ifelse(scale_available_p,1,` + lea M(s_ptr,s_size,l,4), a2 +',` + movel s_size, d0 + asll #2, d0 + lea M(s_ptr,d0,l), a2 +') + cmpl res_ptr, a2 + bls L(Lspecial) C jump if res_ptr >= s_ptr + s_size + +L(Lnormal): + moveql #32, d5 + subl cnt, d5 + +ifelse(scale_available_p,1,` + lea M(s_ptr,s_size,l,4), s_ptr + lea M(res_ptr,s_size,l,4), res_ptr +',` + movel s_size, d0 + asll #2, d0 + addl d0, s_ptr + addl d0, res_ptr +') + movel M(-,s_ptr), d2 + movel d2, d0 + lsrl d5, d0 C compute carry limb + + lsll cnt, d2 + movel d2, d1 + subql #1, s_size + beq L(Lend) + lsrl #1, s_size + bcs L(L1) + subql #1, s_size + +L(Loop): + movel M(-,s_ptr), d2 + movel d2, d3 + lsrl d5, d3 + orl d3, d1 + movel d1, M(-,res_ptr) + lsll cnt, d2 +L(L1): + movel M(-,s_ptr), d1 + movel d1, d3 + lsrl d5, d3 + orl d3, d2 + movel d2, M(-,res_ptr) + lsll cnt, d1 + + dbf s_size, L(Loop) + subl #0x10000, s_size + bcc L(Loop) + +L(Lend): + movel d1, M(-,res_ptr) C store least significant limb + +C Restore used registers from stack frame. + moveml M(sp,+), d2-d6/a2 + rts + +C We loop from least significant end of the arrays, which is only +C permissable if the source and destination don't overlap, since the +C function is documented to work for overlapping source and destination. + +L(Lspecial): + clrl d0 C initialize carry + eorw #1, s_size + lsrl #1, s_size + bcc L(LL1) + subql #1, s_size + +L(LLoop): + movel M(s_ptr,+), d2 + addxl d2, d2 + movel d2, M(res_ptr,+) +L(LL1): + movel M(s_ptr,+), d2 + addxl d2, d2 + movel d2, M(res_ptr,+) + + dbf s_size, L(LLoop) + addxl d0, d0 C save cy in lsb + subl #0x10000, s_size + bcs L(LLend) + lsrl #1, d0 C restore cy + bra L(LLoop) + +L(LLend): +C Restore used registers from stack frame. + moveml M(sp,+), d2-d6/a2 + rts + +EPILOGUE(mpn_lshift) diff --git a/vendor/gmp-6.3.0/mpn/m68k/m68k-defs.m4 b/vendor/gmp-6.3.0/mpn/m68k/m68k-defs.m4 new file mode 100644 index 0000000..15289f6 --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/m68k-defs.m4 @@ -0,0 +1,230 @@ +divert(-1) + +dnl m4 macros for 68k assembler. + +dnl Copyright 2001-2003 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + + +dnl The default m4 `#' commenting interferes with the assembler syntax for +dnl immediates. `|' would be correct, but it interferes with "||" in +dnl eval(). Would like to disable commenting, but that's not possible (see +dnl mpn/asm-defs.m4), so use `;' which should be harmless. + +changecom(;) + + +dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo) +dnl +dnl Same as the standard PROLOGUE, but align to 2 bytes not 4. + +define(`PROLOGUE_cpu', +m4_assert_numargs(1) +` TEXT + ALIGN(2) + GLOBL `$1' GLOBL_ATTR + TYPE(`$1',`function') +`$1'LABEL_SUFFIX') + + +dnl Usage: d0, etc +dnl +dnl Expand to d0 or %d0 according to the assembler's requirements. +dnl +dnl Actually d0 expands to `d0' or %`d0', the quotes protecting against +dnl further expansion. Definitions are made even if d0 is to be just `d0', +dnl so that any m4 quoting problems will show up everywhere, not just on a +dnl %d0 system. +dnl +dnl Care must be taken with quoting when using these in a definition. For +dnl instance the quotes in the following are essential or two %'s will be +dnl produced when `counter' is used. +dnl +dnl define(counter, `d7') +dnl + +dnl Called: m68k_reg(r) +define(m68k_reg, +m4_assert_numargs(1) +m4_assert_defined(`WANT_REGISTER_PERCENT') +`ifelse(WANT_REGISTER_PERCENT,yes,%)`$1'') + +dnl Usage: m68k_defreg(r) +define(m68k_defreg, +m4_assert_numargs(1) +`deflit($1,`m68k_reg(`$1')')') + +m68k_defreg(d0) +m68k_defreg(d1) +m68k_defreg(d2) +m68k_defreg(d3) +m68k_defreg(d4) +m68k_defreg(d5) +m68k_defreg(d6) +m68k_defreg(d7) + +m68k_defreg(a0) +m68k_defreg(a1) +m68k_defreg(a2) +m68k_defreg(a3) +m68k_defreg(a4) +m68k_defreg(a5) +m68k_defreg(a6) +m68k_defreg(a7) + +m68k_defreg(sp) +m68k_defreg(pc) + + +dnl Usage: M(base) +dnl M(base,displacement) +dnl M(base,index,size) +dnl M(base,index,size,scale) +dnl M(base,+) +dnl M(-,base) +dnl +dnl `base' is an address register, `index' is a data register, `size' is w +dnl or l, and scale is 1, 2, 4 or 8. +dnl +dnl M(-,base) has it's arguments that way around to emphasise it's a +dnl pre-decrement, as opposed to M(base,+) a post-increment. +dnl +dnl Enhancement: Add the memory indirect modes, if/when they're needed. + +define(M, +m4_assert_numargs_range(1,4) +m4_assert_defined(`WANT_ADDRESSING') +`ifelse(WANT_ADDRESSING,mit, +`ifelse($#,1, ``$1'@')dnl +ifelse($#,2, +`ifelse($2,+, ``$1'@+', +`ifelse($1,-, ``$2'@-', + ``$1'@($2)')')')dnl +ifelse($#,3, ``$1'@(`$2':`$3')')dnl +ifelse($#,4, ``$1'@(`$2':`$3':$4)')', + +dnl WANT_ADDRESSING `motorola' +`ifelse($#,1, `(`$1')')dnl +ifelse($#,2, +`ifelse($2,+, `(`$1')+', +`ifelse($1,-, `-(`$2')', + `$2(`$1')')')')dnl +ifelse($#,3, `(`$1',`$2'.$3)')dnl +ifelse($#,4, `(`$1',`$2'.$3*$4)')')') + + +dnl Usage: addl etc +dnl +dnl m68k instructions with special handling for the suffix, with for +dnl instance addl expanding to addl or add.l as necessary. +dnl +dnl See also t-m68k-defs.pl which verifies all mnemonics used in the asm +dnl files have entries here. + +dnl Called: m68k_insn(mnemonic,suffix) +define(m68k_insn, +m4_assert_numargs(2) +m4_assert_defined(`WANT_DOT_SIZE') +`ifelse(WANT_DOT_SIZE,yes, ``$1'.``$2''', + ``$1$2'')') + +dnl Usage: m68k_definsn(mnemonic,suffix) +define(m68k_definsn, +m4_assert_numargs(2) +`deflit($1`'$2,`m68k_insn(`$1',`$2')')') + +m68k_definsn(add, l) +m68k_definsn(addx, l) +m68k_definsn(addq, l) +m68k_definsn(asl, l) +m68k_definsn(cmp, l) +m68k_definsn(cmp, w) +m68k_definsn(clr, l) +m68k_definsn(divu, l) +m68k_definsn(eor, w) +m68k_definsn(lsl, l) +m68k_definsn(lsr, l) +m68k_definsn(move, l) +m68k_definsn(move, w) +m68k_definsn(movem,l) +m68k_definsn(moveq,l) +m68k_definsn(mulu, l) +m68k_definsn(neg, l) +m68k_definsn(or, l) +m68k_definsn(roxl, l) +m68k_definsn(roxr, l) +m68k_definsn(sub, l) +m68k_definsn(subx, l) +m68k_definsn(subq, l) + + +dnl Usage: bra etc +dnl +dnl Expand to `bra', `jra' or `jbra' according to what the assembler will +dnl accept. The latter two give variable-sized branches in gas. +dnl +dnl See also t-m68k-defs.pl which verifies all the bXX branches used in the +dnl asm files have entries here. + +dnl Called: m68k_branch(cond) +define(m68k_branch, +m4_assert_numargs(1) +m4_assert_defined(`WANT_BRANCHES') +`ifelse(WANT_BRANCHES,jra, `j$1', +`ifelse(WANT_BRANCHES,jbra,`jb$1', + ``b$1'')')') + +dnl Called: m68k_defbranch(cond) +define(m68k_defbranch, +m4_assert_numargs(1) +`deflit(b$1,`m68k_branch(`$1')')') + +m68k_defbranch(ra) +m68k_defbranch(cc) +m68k_defbranch(cs) +m68k_defbranch(ls) +m68k_defbranch(eq) +m68k_defbranch(ne) + + +dnl Usage: scale_available_p +dnl +dnl Expand to 1 if a scale factor can be used in addressing modes, or 0 if +dnl not. M(a0,d0,l,4), meaning a0+d0*4, is not available in 68000 or +dnl 68010, but is in CPU32 and in 68020 and up. + +define(scale_available_p, +`m4_ifdef_anyof_p( +`HAVE_HOST_CPU_m68360' +`HAVE_HOST_CPU_m68020' +`HAVE_HOST_CPU_m68030' +`HAVE_HOST_CPU_m68040' +`HAVE_HOST_CPU_m68060')') + + +divert diff --git a/vendor/gmp-6.3.0/mpn/m68k/mc68020/aorsmul_1.asm b/vendor/gmp-6.3.0/mpn/m68k/mc68020/aorsmul_1.asm new file mode 100644 index 0000000..4ee30ad --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/mc68020/aorsmul_1.asm @@ -0,0 +1,101 @@ +dnl mc68020 mpn_addmul_1, mpn_submul_1 -- add or subtract mpn multiple. + +dnl Copyright 1992, 1994, 1996, 1999-2002, 2011 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C cycles/limb +C 68040: 25 + +ifdef(`OPERATION_addmul_1',` + define(M4_inst, addl) + define(M4_function_1, mpn_addmul_1) +',`ifdef(`OPERATION_submul_1',` + define(M4_inst, subl) + define(M4_function_1, mpn_submul_1) +', +`m4_error(`Need OPERATION_addmul_1 or OPERATION_submul_1 +')')') + + +C INPUT PARAMETERS +C res_ptr (sp + 4) +C s1_ptr (sp + 8) +C s1_size (sp + 12) +C s2_limb (sp + 16) + +define(res_ptr, `a0') +define(s1_ptr, `a1') +define(s1_size, `d2') +define(s2_limb, `d4') + +MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1) + +PROLOGUE(M4_function_1) + +C Save used registers on the stack. + moveml d2-d5, M(-,sp) + +C Copy the arguments to registers. Better use movem? + movel M(sp,20), res_ptr + movel M(sp,24), s1_ptr + movel M(sp,28), s1_size + movel M(sp,32), s2_limb + + eorw #1, s1_size + clrl d1 + clrl d5 + lsrl #1, s1_size + bcc L(L1) + subql #1, s1_size + subl d0, d0 C (d0,cy) <= (0,0) + +L(Loop): + movel M(s1_ptr,+), d3 + mulul s2_limb, d1:d3 + addxl d0, d3 + addxl d5, d1 + M4_inst d3, M(res_ptr,+) +L(L1): movel M(s1_ptr,+), d3 + mulul s2_limb, d0:d3 + addxl d1, d3 + addxl d5, d0 + M4_inst d3, M(res_ptr,+) + + dbf s1_size, L(Loop) + addxl d5, d0 + subl #0x10000, s1_size + bcc L(Loop) + +C Restore used registers from stack frame. + moveml M(sp,+), d2-d5 + + rts + +EPILOGUE(M4_function_1) diff --git a/vendor/gmp-6.3.0/mpn/m68k/mc68020/mul_1.asm b/vendor/gmp-6.3.0/mpn/m68k/mc68020/mul_1.asm new file mode 100644 index 0000000..f5fbb30 --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/mc68020/mul_1.asm @@ -0,0 +1,96 @@ +dnl mc68020 mpn_mul_1 -- mpn by limb multiply + +dnl Copyright 1992, 1994, 1996, 1999-2002 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + +C cycles/limb +C 68040: 24 + +C INPUT PARAMETERS +C res_ptr (sp + 4) +C s1_ptr (sp + 8) +C s1_size (sp + 12) +C s2_limb (sp + 16) + + +define(res_ptr, `a0') +define(s1_ptr, `a1') +define(s1_size, `d2') +define(s2_limb, `d4') + + +PROLOGUE(mpn_mul_1) + +C Save used registers on the stack. + moveml d2-d4, M(-,sp) + +C movel d2, M(-,sp) +C movel d3, M(-,sp) +C movel d4, M(-,sp) + +C Copy the arguments to registers. Better use movem? + movel M(sp,16), res_ptr + movel M(sp,20), s1_ptr + movel M(sp,24), s1_size + movel M(sp,28), s2_limb + + eorw #1, s1_size + clrl d1 + lsrl #1, s1_size + bcc L(L1) + subql #1, s1_size + subl d0, d0 C (d0,cy) <= (0,0) + +L(Loop): + movel M(s1_ptr,+), d3 + mulul s2_limb, d1:d3 + addxl d0, d3 + movel d3, M(res_ptr,+) +L(L1): movel M(s1_ptr,+), d3 + mulul s2_limb, d0:d3 + addxl d1, d3 + movel d3, M(res_ptr,+) + + dbf s1_size, L(Loop) + clrl d3 + addxl d3, d0 + subl #0x10000, s1_size + bcc L(Loop) + +C Restore used registers from stack frame. + moveml M(sp,+), d2-d4 + +C movel M(sp,+),d4 +C movel M(sp,+),d3 +C movel M(sp,+),d2 + + rts + +EPILOGUE(mpn_mul_1) diff --git a/vendor/gmp-6.3.0/mpn/m68k/mc68020/udiv.asm b/vendor/gmp-6.3.0/mpn/m68k/mc68020/udiv.asm new file mode 100644 index 0000000..aadeab9 --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/mc68020/udiv.asm @@ -0,0 +1,45 @@ +dnl mc68020 mpn_udiv_qrnnd -- 2x1 limb division + +dnl Copyright 1999-2001 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + + +C mp_limb_t mpn_udiv_qrnnd (mp_limb_t *rp, +C mp_limb_t nh, mp_limb_t nl, mp_limb_t d); +C + +PROLOGUE(mpn_udiv_qrnnd) + movel M(sp,4), a0 C rp + movel M(sp,8), d1 C nh + movel M(sp,12), d0 C nl + divul M(sp,16), d1:d0 + movel d1, M(a0) C r + rts +EPILOGUE(mpn_udiv_qrnnd) diff --git a/vendor/gmp-6.3.0/mpn/m68k/mc68020/umul.asm b/vendor/gmp-6.3.0/mpn/m68k/mc68020/umul.asm new file mode 100644 index 0000000..f19314e --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/mc68020/umul.asm @@ -0,0 +1,44 @@ +dnl mc68020 mpn_umul_ppmm -- limb by limb multiplication + +dnl Copyright 1999-2001 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + + +C mp_limb_t mpn_umul_ppmm (mp_limb_t *lp, mp_limb_t x, mp_limb_t y); +C + +PROLOGUE(mpn_umul_ppmm) + movel M(sp,4), a0 C lp + movel M(sp,8), d1 C x + movel M(sp,12), d0 C y + mulul d0, d0:d1 + movel d1, M(a0) C low + rts +EPILOGUE(mpn_umul_ppmm) diff --git a/vendor/gmp-6.3.0/mpn/m68k/rshift.asm b/vendor/gmp-6.3.0/mpn/m68k/rshift.asm new file mode 100644 index 0000000..21b5f89 --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/rshift.asm @@ -0,0 +1,175 @@ +dnl mc68020 mpn_rshift -- mpn right shift. + +dnl Copyright 1996, 1999-2003 Free Software Foundation, Inc. + +dnl This file is part of the GNU MP Library. +dnl +dnl The GNU MP Library is free software; you can redistribute it and/or modify +dnl it under the terms of either: +dnl +dnl * the GNU Lesser General Public License as published by the Free +dnl Software Foundation; either version 3 of the License, or (at your +dnl option) any later version. +dnl +dnl or +dnl +dnl * the GNU General Public License as published by the Free Software +dnl Foundation; either version 2 of the License, or (at your option) any +dnl later version. +dnl +dnl or both in parallel, as here. +dnl +dnl The GNU MP Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl for more details. +dnl +dnl You should have received copies of the GNU General Public License and the +dnl GNU Lesser General Public License along with the GNU MP Library. If not, +dnl see https://www.gnu.org/licenses/. + +include(`../config.m4') + + +C cycles/limb +C shift==1 shift>1 +C 68040: 9 12 + + +C mp_limb_t mpn_rshift (mp_ptr res_ptr, mp_srcptr s_ptr, mp_size_t s_size, +C unsigned cnt); +C +C The "cnt" parameter is either 16 bits or 32 bits depending on +C SIZEOF_UNSIGNED (see ABI notes in mpn/m68k/README). The value is of +C course only 1 to 31. When loaded as 16 bits there's garbage in the upper +C half, hence the use of cmpw. The shift instructions take the their count +C modulo 64, so the upper part doesn't matter to them either. +C + +C INPUT PARAMETERS +C res_ptr (sp + 4) +C s_ptr (sp + 8) +C s_size (sp + 12) +C cnt (sp + 16) + +define(res_ptr, `a1') +define(s_ptr, `a0') +define(s_size, `d6') +define(cnt, `d4') + +ifdef(`SIZEOF_UNSIGNED',, +`m4_error(`SIZEOF_UNSIGNED not defined, should be in config.m4 +')') + +PROLOGUE(mpn_rshift) +C Save used registers on the stack. + moveml d2-d6/a2, M(-,sp) + +C Copy the arguments to registers. + movel M(sp,28), res_ptr + movel M(sp,32), s_ptr + movel M(sp,36), s_size +ifelse(SIZEOF_UNSIGNED,2, +` movew M(sp,40), cnt', +` movel M(sp,40), cnt') + + moveql #1, d5 + cmpw d5, cnt + bne L(Lnormal) + cmpl res_ptr, s_ptr + bls L(Lspecial) C jump if res_ptr >= s_ptr + +ifelse(scale_available_p,1,` + lea M(res_ptr,s_size,l,4), a2 +',` + movel s_size, d0 + asll #2, d0 + lea M(res_ptr,d0,l), a2 +') + cmpl s_ptr, a2 + bls L(Lspecial) C jump if s_ptr >= res_ptr + s_size + +L(Lnormal): + moveql #32, d5 + subl cnt, d5 + movel M(s_ptr,+), d2 + movel d2, d0 + lsll d5, d0 C compute carry limb + + lsrl cnt, d2 + movel d2, d1 + subql #1, s_size + beq L(Lend) + lsrl #1, s_size + bcs L(L1) + subql #1, s_size + +L(Loop): + movel M(s_ptr,+), d2 + movel d2, d3 + lsll d5, d3 + orl d3, d1 + movel d1, M(res_ptr,+) + lsrl cnt, d2 +L(L1): + movel M(s_ptr,+), d1 + movel d1, d3 + lsll d5, d3 + orl d3, d2 + movel d2, M(res_ptr,+) + lsrl cnt, d1 + + dbf s_size, L(Loop) + subl #0x10000, s_size + bcc L(Loop) + +L(Lend): + movel d1, M(res_ptr) C store most significant limb + +C Restore used registers from stack frame. + moveml M(sp,+), d2-d6/a2 + rts + +C We loop from most significant end of the arrays, which is only permissable +C if the source and destination don't overlap, since the function is +C documented to work for overlapping source and destination. + +L(Lspecial): +ifelse(scale_available_p,1,` + lea M(s_ptr,s_size,l,4), s_ptr + lea M(res_ptr,s_size,l,4), res_ptr +',` + movel s_size, d0 + asll #2, d0 + addl d0, s_ptr + addl d0, res_ptr +') + + clrl d0 C initialize carry + eorw #1, s_size + lsrl #1, s_size + bcc L(LL1) + subql #1, s_size + +L(LLoop): + movel M(-,s_ptr), d2 + roxrl #1, d2 + movel d2, M(-,res_ptr) +L(LL1): + movel M(-,s_ptr), d2 + roxrl #1, d2 + movel d2, M(-,res_ptr) + + dbf s_size, L(LLoop) + roxrl #1, d0 C save cy in msb + subl #0x10000, s_size + bcs L(LLend) + addl d0, d0 C restore cy + bra L(LLoop) + +L(LLend): +C Restore used registers from stack frame. + moveml M(sp,+), d2-d6/a2 + rts + +EPILOGUE(mpn_rshift) diff --git a/vendor/gmp-6.3.0/mpn/m68k/t-m68k-defs.pl b/vendor/gmp-6.3.0/mpn/m68k/t-m68k-defs.pl new file mode 100644 index 0000000..91c21fa --- /dev/null +++ b/vendor/gmp-6.3.0/mpn/m68k/t-m68k-defs.pl @@ -0,0 +1,91 @@ +#! /usr/bin/perl -w + +# Copyright 2001, 2003 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library. +# +# The GNU MP Library is free software; you can redistribute it and/or modify +# it under the terms of either: +# +# * the GNU Lesser General Public License as published by the Free +# Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# or +# +# * the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any +# later version. +# +# or both in parallel, as here. +# +# The GNU MP Library is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received copies of the GNU General Public License and the +# GNU Lesser General Public License along with the GNU MP Library. If not, +# see https://www.gnu.org/licenses/. + + +# Usage: perl t-m68k-defs.pl [-t] +# +# Run this in the mpn/m68k source directory to check that m68k-defs.m4 has +# m68k_defbranch()s or m68k_definsn()s for each instruction used in *.asm +# and */*.asm. Print nothing if everything is ok. The -t option prints +# some diagnostic traces. + +use strict; +use Getopt::Std; + +my %opt; +getopts('t', \%opt); + +my %branch; +my %insn; + +open(FD, ") { + if (/^m68k_defbranch\(\s*(.*)\)/) { $branch{"b".$1} = 1; } + if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { $insn{$1.$2} = 1; } +} +close(FD); + +print "branches: ", join(" ",keys(%branch)), "\n" if $opt{'t'}; +print "insns: ", join(" ",keys(%insn)), "\n" if $opt{'t'}; + + +foreach my $file (glob("*.asm"), glob("*/*.asm")) { + print "file $file\n" if $opt{'t'}; + + open(FD, "<$file") or die "Cannot open $file: $!"; + while () { + if (/^[ \t]*C/) { next; }; + if (/^\t([a-z0-9]+)/) { + my $opcode = $1; + print "opcode $1\n" if $opt{'t'}; + + # instructions with an l, w or b suffix should have a definsn + # (unless they're already a defbranch) + if ($opcode =~ /[lwb]$/ + && ! defined $insn{$opcode} + && ! defined $branch{$opcode}) + { + print "$file: $.: missing m68k_definsn: $opcode\n"; + } + + # instructions bXX should have a defbranch (unless they're + # already a definsn) + if ($opcode =~ /^b/ + && ! defined $insn{$opcode} + && ! defined $branch{$opcode}) + { + print "$file: $.: missing m68k_defbranch: $opcode\n"; + } + } + } + close(FD); +} -- cgit v1.2.3