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