aboutsummaryrefslogtreecommitdiff
path: root/vendor/gmp-6.3.0/mpn/m68k/README
blob: 5261564df2bd82ebd160f882c476370de8da825f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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: