1divert(-1) 2 3dnl m4 macros for amd64 assembler. 4 5dnl Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 Free 6dnl Software Foundation, Inc. 7dnl 8dnl This file is part of the GNU MP Library. 9dnl 10dnl The GNU MP Library is free software; you can redistribute it and/or 11dnl modify it under the terms of the GNU Lesser General Public License as 12dnl published by the Free Software Foundation; either version 3 of the 13dnl License, or (at your option) any later version. 14dnl 15dnl The GNU MP Library is distributed in the hope that it will be useful, 16dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 17dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18dnl Lesser General Public License for more details. 19dnl 20dnl You should have received a copy of the GNU Lesser General Public License 21dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 22 23 24dnl Usage: CPUVEC_FUNCS_LIST 25dnl 26dnl A list of the functions from gmp-impl.h x86 struct cpuvec_t, in the 27dnl order they appear in that structure. 28 29define(CPUVEC_FUNCS_LIST, 30``add_n', 31`addmul_1', 32`copyd', 33`copyi', 34`divexact_1', 35`divexact_by3c', 36`divrem_1', 37`gcd_1', 38`lshift', 39`mod_1', 40`mod_34lsub1', 41`modexact_1c_odd', 42`mul_1', 43`mul_basecase', 44`preinv_divrem_1', 45`preinv_mod_1', 46`rshift', 47`sqr_basecase', 48`sub_n', 49`submul_1'') 50 51 52dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo) 53dnl 54dnl In the amd64 code we use explicit TEXT and ALIGN() calls in the code, 55dnl since different alignments are wanted in various circumstances. So for 56dnl instance, 57dnl 58dnl TEXT 59dnl ALIGN(16) 60dnl PROLOGUE(mpn_add_n) 61dnl ... 62dnl EPILOGUE() 63 64define(`PROLOGUE_cpu', 65m4_assert_numargs(1) 66` GLOBL $1 67 TYPE($1,`function') 68$1: 69') 70 71 72dnl Usage: ASSERT([cond][,instructions]) 73dnl 74dnl If WANT_ASSERT is 1, output the given instructions and expect the given 75dnl flags condition to then be satisfied. For example, 76dnl 77dnl ASSERT(ne, `cmpq %rax, %rbx') 78dnl 79dnl The instructions can be omitted to just assert a flags condition with 80dnl no extra calculation. For example, 81dnl 82dnl ASSERT(nc) 83dnl 84dnl When `instructions' is not empty, a pushfq/popfq is added for 85dnl convenience to preserve the flags, but the instructions themselves must 86dnl preserve any registers that matter. 87dnl 88dnl The condition can be omitted to just output the given instructions when 89dnl assertion checking is wanted. In this case the pushf/popf is omitted. 90dnl For example, 91dnl 92dnl ASSERT(, `movq %rax, VAR_KEEPVAL') 93 94define(ASSERT, 95m4_assert_numargs_range(1,2) 96m4_assert_defined(`WANT_ASSERT') 97`ifelse(WANT_ASSERT,1, 98`ifelse(`$1',, 99` $2', 100`ifelse(`$2',,, 101` pushfq') 102 $2 103 j`$1' L(ASSERT_ok`'ASSERT_counter) 104 ud2 C assertion failed 105L(ASSERT_ok`'ASSERT_counter): 106ifelse(`$2',,,` popfq') 107define(`ASSERT_counter',incr(ASSERT_counter))')')') 108 109define(ASSERT_counter,1) 110 111define(`LEA',` 112 mov $1@GOTPCREL(%rip), $2 113') 114 115 116define(`DEF_OBJECT', 117m4_assert_numargs_range(1,2) 118` RODATA 119 ALIGN(ifelse($#,1,2,$2)) 120$1: 121') 122 123define(`END_OBJECT', 124m4_assert_numargs(1) 125` SIZE(`$1',.-`$1')') 126 127 128define(`R32', 129 `ifelse($1,`%rax',`%eax', 130 $1,`%rbx',`%ebx', 131 $1,`%rcx',`%ecx', 132 $1,`%rdx',`%edx', 133 $1,`%rsi',`%esi', 134 $1,`%rdi',`%edi', 135 $1,`%rbp',`%ebp', 136 $1,`%r8',`%r8d', 137 $1,`%r9',`%r9d', 138 $1,`%r10',`%r10d', 139 $1,`%r11',`%r11d', 140 $1,`%r12',`%r12d', 141 $1,`%r13',`%r13d', 142 $1,`%r14',`%r14d', 143 $1,`%r15',`%r15d')') 144define(`R8', 145 `ifelse($1,`%rax',`%al', 146 $1,`%rbx',`%bl', 147 $1,`%rcx',`%cl', 148 $1,`%rdx',`%dl', 149 $1,`%rsi',`%sil', 150 $1,`%rdi',`%dil', 151 $1,`%rbp',`%bpl', 152 $1,`%r8',`%r8b', 153 $1,`%r9',`%r9b', 154 $1,`%r10',`%r10b', 155 $1,`%r11',`%r11b', 156 $1,`%r12',`%r12b', 157 $1,`%r13',`%r13b', 158 $1,`%r14',`%r14b', 159 $1,`%r15',`%r15b')') 160 161 162dnl Usage: CALL(funcname) 163dnl 164 165ifdef(`PIC', 166 `define(`CALL',`call GSYM_PREFIX`'$1@PLT')', 167 `define(`CALL',`call GSYM_PREFIX`'$1')') 168 169 170define(`JUMPTABSECT', `.section .data.rel.ro.local,"aw",@progbits') 171 172divert`'dnl 173