Blame mpn/m68k/README

Packit 5c3484
Copyright 2001, 2003, 2004 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
This file is part of the GNU MP Library.
Packit 5c3484
Packit 5c3484
The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
it under the terms of either:
Packit 5c3484
Packit 5c3484
  * the GNU Lesser General Public License as published by the Free
Packit 5c3484
    Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
    option) any later version.
Packit 5c3484
Packit 5c3484
or
Packit 5c3484
Packit 5c3484
  * the GNU General Public License as published by the Free Software
Packit 5c3484
    Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
    later version.
Packit 5c3484
Packit 5c3484
or both in parallel, as here.
Packit 5c3484
Packit 5c3484
The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
for more details.
Packit 5c3484
Packit 5c3484
You should have received copies of the GNU General Public License and the
Packit 5c3484
GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
                      M68K MPN SUBROUTINES
Packit 5c3484
Packit 5c3484
Packit 5c3484
This directory contains mpn functions for various m68k family chips.
Packit 5c3484
Packit 5c3484
Packit 5c3484
CODE ORGANIZATION
Packit 5c3484
Packit 5c3484
	m68k             m68000, m68010, m68060
Packit 5c3484
	m68k/mc68020     m68020, m68030, m68040, and CPU32
Packit 5c3484
Packit 5c3484
Packit 5c3484
The m5200 "coldfire", which is m68000 less a few instructions, currently has
Packit 5c3484
no assembler code support.
Packit 5c3484
Packit 5c3484
Packit 5c3484
STATUS
Packit 5c3484
Packit 5c3484
The code herein is old and poorly maintained.  If somebody really cared, it
Packit 5c3484
could be optimized substantially.  For example,
Packit 5c3484
Packit 5c3484
* mpn_add_n and mpn_sub_n could, with more unrolling be improved from 6 to
Packit 5c3484
  close to 4 c/l (on m68040).
Packit 5c3484
Packit 5c3484
* The multiplication loops could be sped up by using the FPU.
Packit 5c3484
Packit 5c3484
* mpn_lshift by 31 should use the special-case mpn_rshift by 1 code, and
Packit 5c3484
  vice versa mpn_rshift by 31 use the special lshift by 1, when operand
Packit 5c3484
  overlap permits.
Packit 5c3484
Packit 5c3484
* On 68000, mpn_mul_1, mpn_addmul_1 and mpn_submul_1 could check for a
Packit 5c3484
  16-bit multiplier and use two multiplies per limb, not four.
Packit 5c3484
Packit 5c3484
  Similarly various other _1 operations like mpn_mod_1, mpn_divrem_1,
Packit 5c3484
  mpn_divexact_1, mpn_modexact_1c_odd.
Packit 5c3484
Packit 5c3484
* On 68000, mpn_lshift and mpn_rshift could use a roll and mask instead of
Packit 5c3484
  lsrl and lsll.  This promises to be a speedup, effectively trading a 6+2*n
Packit 5c3484
  shift for one or two 4 cycle masks.  Suggested by Jean-Charles Meyrignac.
Packit 5c3484
Packit 5c3484
* config.guess detects 68000, 68010, CPU32 and 68020 by running some code,
Packit 5c3484
  but relies on system information for 030, 040 and 060.  Can they be
Packit 5c3484
  identified by running some code?  Currently this only makes a difference
Packit 5c3484
  to the compiler options selected, since we have no specific asm code for
Packit 5c3484
  those chips.
Packit 5c3484
Packit 5c3484
One novel idea for 68000 would be to use a 16-bit limb instead of 32-bits.
Packit 5c3484
This would suit the native 16x16 multiply, but might make it difficult to
Packit 5c3484
get full value from the native 32x32 add/sub/etc.  This would be an ABI
Packit 5c3484
option, and would select "__GMP_SHORT_LIMB" in gmp.h.
Packit 5c3484
Packit 5c3484
Naturally an entirely new set of asm subroutines would be needed for a
Packit 5c3484
16-bit limb.  Also there's various places in the C code assuming limb>=long,
Packit 5c3484
which would need to be updated, eg. mpz_set_ui.  Some of the nails changes
Packit 5c3484
may have helped cover some of this.
Packit 5c3484
Packit 5c3484
Packit 5c3484
ASM FILES
Packit 5c3484
Packit 5c3484
The .asm files are put through m4 for macro processing, and with the help of
Packit 5c3484
configure give either MIT or Motorola syntax.  The generic mpn/asm-defs.m4
Packit 5c3484
is used, together with mpn/m68k/m68k-defs.m4.  See comments in those files.
Packit 5c3484
Packit 5c3484
Not all possible syntax variations are covered.  GCC config/m68k for
Packit 5c3484
instance has things like $ for immediates on CRDS or reversed cmp order for
Packit 5c3484
AT&T SGS.  These could probably be handled if anyone really needs it.
Packit 5c3484
Packit 5c3484
Packit 5c3484
CALLING CONVENTIONS
Packit 5c3484
Packit 5c3484
The SVR4 standard has an int of 32 bits, and all parameters 32-bit aligned
Packit 5c3484
on the stack.
Packit 5c3484
Packit 5c3484
PalmOS and perhaps various embedded systems intended for 68000 however use
Packit 5c3484
an int of 16 bits and parameters only 16-bit aligned on the stack.  This is
Packit 5c3484
generated by "gcc -mshort" (and is the default for the PalmOS gcc port, we
Packit 5c3484
believe).
Packit 5c3484
Packit 5c3484
The asm files adapt to these two ABIs by checking sizeof(unsigned), coming
Packit 5c3484
through config.m4 as SIZEOF_UNSIGNED.  Only mpn_lshift and mpn_rshift are
Packit 5c3484
affected, all other routines take longs and pointers, which are 32-bits in
Packit 5c3484
both cases.
Packit 5c3484
Packit 5c3484
Strictly speaking the size of an int doesn't determine the stack padding
Packit 5c3484
convention.  But if int is 16 bits then we can definitely say the host
Packit 5c3484
system is not SVR4, and therefore may as well assume we're in 16-bit stack
Packit 5c3484
alignment.
Packit 5c3484
Packit 5c3484
Packit 5c3484
REFERENCES
Packit 5c3484
Packit 5c3484
"Motorola M68000 Family Programmer's Reference Manual", available online,
Packit 5c3484
Packit 5c3484
	http://e-www.motorola.com/brdata/PDFDB/docs/M68000PM.pdf
Packit 5c3484
Packit 5c3484
"System V Application Binary Interface: Motorola 68000 Processor Family
Packit 5c3484
Supplement", AT&T, 1990, ISBN 0-13-877553-6.  Has details of calling
Packit 5c3484
conventions and ELF style PIC coding.
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
----------------
Packit 5c3484
Local variables:
Packit 5c3484
mode: text
Packit 5c3484
fill-column: 76
Packit 5c3484
End: