|
Packit |
5c3484 |
Copyright 2002, 2005 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 |
POWERPC 32-BIT MPN SUBROUTINES
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
This directory contains mpn functions for various 32-bit PowerPC chips.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
CODE ORGANIZATION
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
directory used for
|
|
Packit |
5c3484 |
================================================
|
|
Packit |
5c3484 |
powerpc generic, 604, 604e, 744x, 745x
|
|
Packit |
5c3484 |
powerpc/750 740, 750, 7400, 7410
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
The top-level powerpc directory is currently mostly aimed at 604/604e but
|
|
Packit |
5c3484 |
should be reasonable on all powerpcs.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
STATUS
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
The code is quite well optimized for the 604e, other chips have had less
|
|
Packit |
5c3484 |
attention.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
Altivec SIMD available in 74xx might hold some promise, but unfortunately
|
|
Packit |
5c3484 |
GMP only guarantees 32-bit data alignment, so there's lots of fiddling
|
|
Packit |
5c3484 |
around with partial operations at the start and end of limb vectors. A
|
|
Packit |
5c3484 |
128-bit limb would be a novel idea, but is unlikely to be practical, since
|
|
Packit |
5c3484 |
it would have to work with ordinary +, -, * etc in the C code.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
Also, Altivec isn't very well suited for the GMP multiplication needs.
|
|
Packit |
5c3484 |
Using floating-point based multiplication has much better better performance
|
|
Packit |
5c3484 |
potential for all current powerpcs, both the ones with slow integer multiply
|
|
Packit |
5c3484 |
units (603, 740, 750, 7400, 7410) and those with fast (604, 604e, 744x,
|
|
Packit |
5c3484 |
745x). This is because all powerpcs do some level of pipelining in the FPU:
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
603 and 750 can sustain one fmadd every 2nd cycle.
|
|
Packit |
5c3484 |
604 and 604e can sustain one fmadd per cycle.
|
|
Packit |
5c3484 |
7400 and 7410 can sustain 3 fmadd in 4 cycles.
|
|
Packit |
5c3484 |
744x and 745x can sustain 4 fmadd in 5 cycles.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
REGISTER NAMES
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
The normal powerpc convention is to give registers as plain numbers, like
|
|
Packit |
5c3484 |
"mtctr 6", but on Apple MacOS X (powerpc*-*-rhapsody* and
|
|
Packit |
5c3484 |
powerpc*-*-darwin*) the assembler demands an "r" like "mtctr r6". Note
|
|
Packit |
5c3484 |
however when register 0 in an instruction means a literal zero the "r" is
|
|
Packit |
5c3484 |
omitted, for instance "lwzx r6,0,r7".
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
The GMP code uses the "r" forms, powerpc-defs.m4 transforms them to plain
|
|
Packit |
5c3484 |
numbers according to what GMP_ASM_POWERPC_R_REGISTERS finds is needed.
|
|
Packit |
5c3484 |
(Note that this style isn't fully general, as the identifier r4 and the
|
|
Packit |
5c3484 |
register r4 will not be distinguishable on some systems. However, this is
|
|
Packit |
5c3484 |
not a problem for the limited GMP assembly usage.)
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
GLOBAL REFERENCES
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
Linux non-PIC
|
|
Packit |
5c3484 |
lis 9, __gmp_binvert_limb_table@ha
|
|
Packit |
5c3484 |
rlwinm 11, 5, 31, 25, 31
|
|
Packit |
5c3484 |
la 9, __gmp_binvert_limb_table@l(9)
|
|
Packit |
5c3484 |
lbzx 11, 9, 11
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
Linux PIC (FIXME)
|
|
Packit |
5c3484 |
.LCL0:
|
|
Packit |
5c3484 |
.long .LCTOC1-.LCF0
|
|
Packit |
5c3484 |
bcl 20, 31, .LCF0
|
|
Packit |
5c3484 |
.LCF0:
|
|
Packit |
5c3484 |
mflr 30
|
|
Packit |
5c3484 |
lwz 7, .LCL0-.LCF0(30)
|
|
Packit |
5c3484 |
add 30, 7, 30
|
|
Packit |
5c3484 |
lwz 11, .LC0-.LCTOC1(30)
|
|
Packit |
5c3484 |
rlwinm 3, 5, 31, 25, 31
|
|
Packit |
5c3484 |
lbzx 7, 11, 3
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
AIX (always PIC)
|
|
Packit |
5c3484 |
LC..0:
|
|
Packit |
5c3484 |
.tc __gmp_binvert_limb_table[TC],__gmp_binvert_limb_table[RW]
|
|
Packit |
5c3484 |
lwz 9, LC..0(2)
|
|
Packit |
5c3484 |
rlwinm 0, 5, 31, 25, 31
|
|
Packit |
5c3484 |
lbzx 0, 9, 0
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
Darwin (non-PIC)
|
|
Packit |
5c3484 |
lis r2, ha16(___gmp_binvert_limb_table)
|
|
Packit |
5c3484 |
rlwinm r9, r5, 31, 25, 31
|
|
Packit |
5c3484 |
la r2, lo16(___gmp_binvert_limb_table)(r2)
|
|
Packit |
5c3484 |
lbzx r0, r2, r9
|
|
Packit |
5c3484 |
Darwin (PIC)
|
|
Packit |
5c3484 |
mflr r0
|
|
Packit |
5c3484 |
bcl 20, 31, L0001$pb
|
|
Packit |
5c3484 |
L0001$pb:
|
|
Packit |
5c3484 |
mflr r7
|
|
Packit |
5c3484 |
mtlr r0
|
|
Packit |
5c3484 |
addis r2, r7, ha16(L___gmp_binvert_limb_table$non_lazy_ptr-L0001$pb)
|
|
Packit |
5c3484 |
rlwinm r9, r5, 31, 25, 31
|
|
Packit |
5c3484 |
lwz r2, lo16(L___gmp_binvert_limb_table$non_lazy_ptr-L0001$pb)(r2)
|
|
Packit |
5c3484 |
lbzx r0, r2, r9
|
|
Packit |
5c3484 |
------
|
|
Packit |
5c3484 |
.non_lazy_symbol_pointer
|
|
Packit |
5c3484 |
L___gmp_binvert_limb_table$non_lazy_ptr:
|
|
Packit |
5c3484 |
.indirect_symbol ___gmp_binvert_limb_table
|
|
Packit |
5c3484 |
.long 0
|
|
Packit |
5c3484 |
.subsections_via_symbols
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
For GNU/Linux and Darwin, we might want to duplicate __gmp_binvert_limb_table
|
|
Packit |
5c3484 |
into the text section in this file. We should thus be able to reach it like
|
|
Packit |
5c3484 |
this:
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
blr L0
|
|
Packit |
5c3484 |
L0: mflr r2
|
|
Packit |
5c3484 |
rlwinm r9, r5, 31, 25, 31
|
|
Packit |
5c3484 |
addi r9, r9, lo16(local_binvert_table-L0)
|
|
Packit |
5c3484 |
lbzx r0, r2, r9
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
REFERENCES
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
PowerPC Microprocessor Family: The Programming Environments for 32-bit
|
|
Packit |
5c3484 |
Microprocessors, IBM document G522-0290-01, 2000.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
PowerPC 604e RISC Microprocessor User's Manual with Supplement for PowerPC
|
|
Packit |
5c3484 |
604 Microprocessor, IBM document G552-0330-00, Freescale document
|
|
Packit |
5c3484 |
MPC604EUM/AD, 3/1998.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
MPC7410/MPC7400 RISC Microprocessor User's Manual, Freescale document
|
|
Packit |
5c3484 |
MPC7400UM/D, rev 1, 11/2002.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
MPC7450 RISC Microprocessor Family Reference Manual, Freescale document
|
|
Packit |
5c3484 |
MPC7450UM, rev 5, 1/2005.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
The above are available online from
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
http://www.ibm.com/chips/techlib/techlib.nsf/productfamilies/PowerPC
|
|
Packit |
5c3484 |
http://www.freescale.com/PowerPC
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
----------------
|
|
Packit |
5c3484 |
Local variables:
|
|
Packit |
5c3484 |
mode: text
|
|
Packit |
5c3484 |
fill-column: 76
|
|
Packit |
5c3484 |
End:
|