xref: /netbsd/external/lgpl3/gmp/dist/mpn/x86/darwin.m4 (revision f81b1c5b)
1divert(-1)
2dnl  Copyright 2007, 2011, 2012, 2014 Free Software Foundation, Inc.
3
4dnl  This file is part of the GNU MP Library.
5dnl
6dnl  The GNU MP Library is free software; you can redistribute it and/or modify
7dnl  it under the terms of either:
8dnl
9dnl    * the GNU Lesser General Public License as published by the Free
10dnl      Software Foundation; either version 3 of the License, or (at your
11dnl      option) any later version.
12dnl
13dnl  or
14dnl
15dnl    * the GNU General Public License as published by the Free Software
16dnl      Foundation; either version 2 of the License, or (at your option) any
17dnl      later version.
18dnl
19dnl  or both in parallel, as here.
20dnl
21dnl  The GNU MP Library is distributed in the hope that it will be useful, but
22dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24dnl  for more details.
25dnl
26dnl  You should have received copies of the GNU General Public License and the
27dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
28dnl  see https://www.gnu.org/licenses/.
29
30define(`DARWIN')
31
32
33dnl  Usage LEA(symbol,reg)
34dnl  Usage LEAL(symbol_local_to_file,reg)
35dnl
36dnl  We maintain lists of stuff to append in load_eip and darwin_bd.  The
37dnl  `index' stuff is needed to suppress repeated definitions.  To avoid
38dnl  getting fooled by "var" and "var1", we add 'bol ' (the end of
39dnl  'indirect_symbol') at the beginning and and a newline at the end.  This
40dnl  might be a bit fragile.
41
42define(`LEA',
43m4_assert_numargs(2)
44`ifdef(`PIC',`
45ifelse(index(defn(`load_eip'), `$2'),-1,
46`m4append(`load_eip',
47`	TEXT
48	ALIGN(16)
49L(movl_eip_`'substr($2,1)):
50	movl	(%esp), $2
51	ret_internal
52')')
53ifelse(index(defn(`darwin_bd'), `bol $1
54'),-1,
55`m4append(`darwin_bd',
56`	.section __IMPORT,__pointers,non_lazy_symbol_pointers
57L($1`'$non_lazy_ptr):
58	.indirect_symbol $1
59	.long	 0
60')')
61	call	L(movl_eip_`'substr($2,1))
62	movl	L($1`'$non_lazy_ptr)-.($2), $2
63',`
64	movl	`$'$1, $2
65')')
66
67define(`LEAL',
68m4_assert_numargs(2)
69`ifdef(`PIC',`
70ifelse(index(defn(`load_eip'), `$2'),-1,
71`m4append(`load_eip',
72`	TEXT
73	ALIGN(16)
74L(movl_eip_`'substr($2,1)):
75	movl	(%esp), $2
76	ret_internal
77')')
78	call	L(movl_eip_`'substr($2,1))
79	leal	$1-.($2), $2
80',`
81	movl	`$'$1, $2
82')')
83
84
85dnl ASM_END
86
87define(`ASM_END',`load_eip`'darwin_bd')
88
89define(`load_eip', `')		dnl updated in LEA
90define(`darwin_bd', `')		dnl updated in LEA
91
92
93dnl  Usage: CALL(funcname)
94dnl
95
96define(`CALL',
97m4_assert_numargs(1)
98`call	GSYM_PREFIX`'$1')
99
100undefine(`PIC_WITH_EBX')
101
102divert`'dnl
103