xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/powerpc64/darwin.m4 (revision d90047b5d07facf36e6c01dcc0bded8997ce9cc2)
1divert(-1)
2dnl  m4 macros for Mac OS 64-bit assembly.
3
4dnl  Copyright 2005, 2006 Free Software Foundation, Inc.
5
6dnl  This file is part of the GNU MP Library.
7dnl
8dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9dnl  it under the terms of either:
10dnl
11dnl    * the GNU Lesser General Public License as published by the Free
12dnl      Software Foundation; either version 3 of the License, or (at your
13dnl      option) any later version.
14dnl
15dnl  or
16dnl
17dnl    * the GNU General Public License as published by the Free Software
18dnl      Foundation; either version 2 of the License, or (at your option) any
19dnl      later version.
20dnl
21dnl  or both in parallel, as here.
22dnl
23dnl  The GNU MP Library is distributed in the hope that it will be useful, but
24dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26dnl  for more details.
27dnl
28dnl  You should have received copies of the GNU General Public License and the
29dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
30dnl  see https://www.gnu.org/licenses/.
31
32define(`ASM_START',`')
33
34dnl  Called: PROLOGUE_cpu(GSYM_PREFIX`'foo[,toc])
35dnl          EPILOGUE_cpu(GSYM_PREFIX`'foo)
36dnl
37
38define(`DARWIN')
39
40define(`PROLOGUE_cpu',
41m4_assert_numargs_range(1,2)
42`ifelse(`$2',toc,,
43`ifelse(`$2',,,`m4_error(`Unrecognised PROLOGUE parameter')')')dnl
44	.text
45	.globl	$1
46	.align	5
47$1:')
48
49define(`EPILOGUE_cpu',
50m4_assert_numargs(1))
51
52dnl  LEAL -- Load Effective Address Local.  This is to be used for symbols
53dnl  defined in the same file.  It will not work for externally defined
54dnl  symbols.
55
56define(`LEAL',
57m4_assert_numargs(2)
58`ifdef(`PIC',
59`
60	mflr	r0			C save return address
61	bcl	20, 31, 1f
621:	mflr	$1
63	addis	$1, $1, ha16($2-1b)
64	la	$1, lo16($2-1b)($1)
65	mtlr	r0			C restore return address
66',`
67	lis	$1, ha16($2)
68	la	$1, lo16($2)($1)
69')')
70
71dnl  LEA -- Load Effective Address.  This is to be used for symbols defined in
72dnl  another file.  It will not work for locally defined symbols.
73
74define(`LEA',
75m4_assert_numargs(2)
76`ifdef(`PIC',
77`define(`EPILOGUE_cpu',
78`	.non_lazy_symbol_pointer
79`L'$2`'$non_lazy_ptr:
80	.indirect_symbol $2
81	.quad	0
82')
83	mflr	r0			C save return address
84	bcl	20, 31, 1f
851:	mflr	$1
86	addis	$1, $1, ha16(`L'$2`'$non_lazy_ptr-1b)
87	ld	$1, lo16(`L'$2`'$non_lazy_ptr-1b)($1)
88	mtlr	r0			C restore return address
89',`
90	lis	$1, ha16($2)
91	la	$1, lo16($2)($1)
92')')
93
94define(`EXTERN',
95m4_assert_numargs(1)
96`dnl')
97
98define(`EXTERN_FUNC',
99m4_assert_numargs(1)
100`dnl')
101
102define(`DEF_OBJECT',
103m4_assert_numargs_range(1,2)
104`	.const
105	ALIGN(ifelse($#,1,2,$2))
106$1:
107')
108
109define(`END_OBJECT',
110m4_assert_numargs(1))
111
112define(`CALL',
113	`bl	GSYM_PREFIX`'$1')
114
115define(`ASM_END', `dnl')
116
117define(`EXTRA_REGISTER', r2)
118
119divert
120