Tizen 2.1 base
[external/gmp.git] / mpn / powerpc32 / powerpc-defs.m4
1 divert(-1)
2
3 dnl  m4 macros for PowerPC assembler (32 and 64 bit).
4
5 dnl  Copyright 2000, 2002, 2003 Free Software Foundation, Inc.
6 dnl
7 dnl  This file is part of the GNU MP Library.
8 dnl
9 dnl  The GNU MP Library is free software; you can redistribute it and/or
10 dnl  modify it under the terms of the GNU Lesser General Public License as
11 dnl  published by the Free Software Foundation; either version 3 of the
12 dnl  License, or (at your option) any later version.
13 dnl
14 dnl  The GNU MP Library is distributed in the hope that it will be useful,
15 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 dnl  Lesser General Public License for more details.
18 dnl
19 dnl  You should have received a copy of the GNU Lesser General Public License
20 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
21
22
23 dnl  Called: PROLOGUE_cpu(GSYM_PREFIX`'foo)
24 dnl
25 dnl  This is the same as the default in mpn/asm-defs.m4, but with ALIGN(4)
26 dnl  not 8.
27 dnl
28 dnl  4-byte alignment is normally enough, certainly it's what gcc gives.  We
29 dnl  don't want bigger alignment within PROLOGUE since it can introduce
30 dnl  padding into multiple-entrypoint routines, and with gas such padding is
31 dnl  zero words, which are not valid instructions.
32
33 define(`PROLOGUE_cpu',
34 m4_assert_numargs(1)
35 `       TEXT
36         ALIGN(4)
37         GLOBL   `$1' GLOBL_ATTR
38         TYPE(`$1',`function')
39 `$1'LABEL_SUFFIX')
40
41
42 dnl  Usage: r0 ... r31, cr0 ... cr7
43 dnl
44 dnl  Registers names, either left as "r0" etc or mapped to plain 0 etc,
45 dnl  according to the result of the GMP_ASM_POWERPC_REGISTERS configure
46 dnl  test.
47
48 ifelse(WANT_R_REGISTERS,no,`
49 forloop(i,0,31,`deflit(`r'i,i)')
50 forloop(i,0,31,`deflit(`v'i,i)')
51 forloop(i,0,31,`deflit(`f'i,i)')
52 forloop(i,0,7, `deflit(`cr'i,i)')
53 ')
54
55
56 dnl  Usage: ASSERT(cond,instructions)
57 dnl
58 dnl  If WANT_ASSERT is 1, output the given instructions and expect the given
59 dnl  flags condition to then be satisfied.  For example,
60 dnl
61 dnl         ASSERT(eq, `cmpwi r6, 123')
62 dnl
63 dnl  The instructions can be omitted to just assert a flags condition with
64 dnl  no extra calculation.  For example,
65 dnl
66 dnl         ASSERT(ne)
67 dnl
68 dnl  The condition can be omitted to just output the given instructions when
69 dnl  assertion checking is wanted.  For example,
70 dnl
71 dnl         ASSERT(, `mr r11, r0')
72 dnl
73 dnl  Using a zero word for an illegal instruction is probably not ideal,
74 dnl  since it marks the beginning of a traceback table in the 64-bit ABI.
75 dnl  But assertions are only for development, so it doesn't matter too much.
76
77 define(ASSERT,
78 m4_assert_numargs_range(1,2)
79 m4_assert_defined(`WANT_ASSERT')
80 `ifelse(WANT_ASSERT,1,
81         `C ASSERT
82         $2
83 ifelse(`$1',,,
84 `       b$1     L(ASSERT_ok`'ASSERT_counter)
85         W32     0       C assertion failed
86 L(ASSERT_ok`'ASSERT_counter):
87 define(`ASSERT_counter',incr(ASSERT_counter))
88 ')')')
89
90 define(ASSERT_counter,1)
91
92
93 divert