blob: 2c995e70678818f235415503c3814d4887e8e531 [file] [log] [blame]
Austin Schuhdace2a62020-08-18 10:56:48 -07001divert(-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(`DARWIN')
33
34define(`ASM_START',`')
35
36dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo[,toc])
37dnl EPILOGUE_cpu(GSYM_PREFIX`'foo)
38dnl
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(`lea_list', `')
50
51dnl LEAL -- Load Effective Address Local. This is to be used for symbols
52dnl defined in the same file. It will not work for externally defined
53dnl symbols.
54
55define(`LEAL',
56m4_assert_numargs(2)
57`ifdef(`PIC',
58`
59 mflr r0 C save return address
60 bcl 20, 31, 1f
611: mflr $1
62 addis $1, $1, ha16($2-1b)
63 la $1, lo16($2-1b)($1)
64 mtlr r0 C restore return address
65',`
66 lis $1, ha16($2)
67 la $1, lo16($2)($1)
68')')
69
70dnl LEA -- Load Effective Address. This is to be used for symbols defined in
71dnl another file. It will not work for locally defined symbols.
72
73define(`LEA',
74m4_assert_numargs(2)
75`ifdef(`PIC',
76`define(`lea_list',
77` .non_lazy_symbol_pointer
78`L'$2`'$non_lazy_ptr:
79 .indirect_symbol $2
80 .quad 0
81')
82 mflr r0 C save return address
83 bcl 20, 31, 1f
841: mflr $1
85 addis $1, $1, ha16(`L'$2`'$non_lazy_ptr-1b)
86 ld $1, lo16(`L'$2`'$non_lazy_ptr-1b)($1)
87 mtlr r0 C restore return address
88',`
89 lis $1, ha16($2)
90 la $1, lo16($2)($1)
91')')
92
93define(`EXTERN',
94m4_assert_numargs(1)
95`dnl')
96
97define(`EXTERN_FUNC',
98m4_assert_numargs(1)
99`dnl')
100
101define(`DEF_OBJECT',
102m4_assert_numargs_range(1,2)
103` .const
104 ALIGN(ifelse($#,1,2,$2))
105$1:
106')
107
108define(`END_OBJECT',
109m4_assert_numargs(1))
110
111define(`CALL',
112 `bl GSYM_PREFIX`'$1')
113
114define(`EPILOGUE_cpu',
115`lea_list'
116`define(`lea_list', `')')
117
118define(`ASM_END', `dnl')
119
120define(`EXTRA_REGISTER', r2)
121
122divert