Austin Schuh | dace2a6 | 2020-08-18 10:56:48 -0700 | [diff] [blame] | 1 | divert(-1) |
| 2 | dnl m4 macros for Mac OS 64-bit assembly. |
| 3 | |
| 4 | dnl Copyright 2005, 2006 Free Software Foundation, Inc. |
| 5 | |
| 6 | dnl This file is part of the GNU MP Library. |
| 7 | dnl |
| 8 | dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 9 | dnl it under the terms of either: |
| 10 | dnl |
| 11 | dnl * the GNU Lesser General Public License as published by the Free |
| 12 | dnl Software Foundation; either version 3 of the License, or (at your |
| 13 | dnl option) any later version. |
| 14 | dnl |
| 15 | dnl or |
| 16 | dnl |
| 17 | dnl * the GNU General Public License as published by the Free Software |
| 18 | dnl Foundation; either version 2 of the License, or (at your option) any |
| 19 | dnl later version. |
| 20 | dnl |
| 21 | dnl or both in parallel, as here. |
| 22 | dnl |
| 23 | dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 24 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 25 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 26 | dnl for more details. |
| 27 | dnl |
| 28 | dnl You should have received copies of the GNU General Public License and the |
| 29 | dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 30 | dnl see https://www.gnu.org/licenses/. |
| 31 | |
| 32 | define(`DARWIN') |
| 33 | |
| 34 | define(`ASM_START',`') |
| 35 | |
| 36 | dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo[,toc]) |
| 37 | dnl EPILOGUE_cpu(GSYM_PREFIX`'foo) |
| 38 | dnl |
| 39 | |
| 40 | define(`PROLOGUE_cpu', |
| 41 | m4_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 | |
| 49 | define(`lea_list', `') |
| 50 | |
| 51 | dnl LEAL -- Load Effective Address Local. This is to be used for symbols |
| 52 | dnl defined in the same file. It will not work for externally defined |
| 53 | dnl symbols. |
| 54 | |
| 55 | define(`LEAL', |
| 56 | m4_assert_numargs(2) |
| 57 | `ifdef(`PIC', |
| 58 | ` |
| 59 | mflr r0 C save return address |
| 60 | bcl 20, 31, 1f |
| 61 | 1: 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 | |
| 70 | dnl LEA -- Load Effective Address. This is to be used for symbols defined in |
| 71 | dnl another file. It will not work for locally defined symbols. |
| 72 | |
| 73 | define(`LEA', |
| 74 | m4_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 |
| 84 | 1: 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 | |
| 93 | define(`EXTERN', |
| 94 | m4_assert_numargs(1) |
| 95 | `dnl') |
| 96 | |
| 97 | define(`EXTERN_FUNC', |
| 98 | m4_assert_numargs(1) |
| 99 | `dnl') |
| 100 | |
| 101 | define(`DEF_OBJECT', |
| 102 | m4_assert_numargs_range(1,2) |
| 103 | ` .const |
| 104 | ALIGN(ifelse($#,1,2,$2)) |
| 105 | $1: |
| 106 | ') |
| 107 | |
| 108 | define(`END_OBJECT', |
| 109 | m4_assert_numargs(1)) |
| 110 | |
| 111 | define(`CALL', |
| 112 | `bl GSYM_PREFIX`'$1') |
| 113 | |
| 114 | define(`EPILOGUE_cpu', |
| 115 | `lea_list' |
| 116 | `define(`lea_list', `')') |
| 117 | |
| 118 | define(`ASM_END', `dnl') |
| 119 | |
| 120 | define(`EXTRA_REGISTER', r2) |
| 121 | |
| 122 | divert |