3 dnl m4 macros for amd64 assembler.
5 dnl Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 Free
6 dnl Software Foundation, Inc.
8 dnl This file is part of the GNU MP Library.
10 dnl The GNU MP Library is free software; you can redistribute it and/or
11 dnl modify it under the terms of the GNU Lesser General Public License as
12 dnl published by the Free Software Foundation; either version 3 of the
13 dnl License, or (at your option) any later version.
15 dnl The GNU MP Library is distributed in the hope that it will be useful,
16 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
17 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 dnl Lesser General Public License for more details.
20 dnl You should have received a copy of the GNU Lesser General Public License
21 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
24 dnl Usage: CPUVEC_FUNCS_LIST
26 dnl A list of the functions from gmp-impl.h x86 struct cpuvec_t, in the
27 dnl order they appear in that structure.
29 define(CPUVEC_FUNCS_LIST,
52 dnl Called: PROLOGUE_cpu(GSYM_PREFIX`'foo)
54 dnl In the amd64 code we use explicit TEXT and ALIGN() calls in the code,
55 dnl since different alignments are wanted in various circumstances. So for
60 dnl PROLOGUE(mpn_add_n)
64 define(`PROLOGUE_cpu',
72 dnl Usage: ASSERT([cond][,instructions])
74 dnl If WANT_ASSERT is 1, output the given instructions and expect the given
75 dnl flags condition to then be satisfied. For example,
77 dnl ASSERT(ne, `cmpq %rax, %rbx')
79 dnl The instructions can be omitted to just assert a flags condition with
80 dnl no extra calculation. For example,
84 dnl When `instructions' is not empty, a pushfq/popfq is added for
85 dnl convenience to preserve the flags, but the instructions themselves must
86 dnl preserve any registers that matter.
88 dnl The condition can be omitted to just output the given instructions when
89 dnl assertion checking is wanted. In this case the pushf/popf is omitted.
92 dnl ASSERT(, `movq %rax, VAR_KEEPVAL')
95 m4_assert_numargs_range(1,2)
96 m4_assert_defined(`WANT_ASSERT')
97 `ifelse(WANT_ASSERT,1,
103 j`$1' L(ASSERT_ok`'ASSERT_counter)
104 ud2 C assertion failed
105 L(ASSERT_ok`'ASSERT_counter):
106 ifelse(`$2',,,` popfq')
107 define(`ASSERT_counter',incr(ASSERT_counter))')')')
109 define(ASSERT_counter,1)
112 mov $1@GOTPCREL(%rip), $2
117 m4_assert_numargs_range(1,2)
119 ALIGN(ifelse($#,1,2,$2))
125 ` SIZE(`$1',.-`$1')')
129 `ifelse($1,`%rax',`%eax',
145 `ifelse($1,`%rax',`%al',
162 dnl Usage: CALL(funcname)
166 `define(`CALL',`call GSYM_PREFIX`'$1@PLT')',
167 `define(`CALL',`call GSYM_PREFIX`'$1')')
170 define(`JUMPTABSECT', `.section .data.rel.ro.local,"aw",@progbits')