1dnl ARM32 calling conventions checking. 2 3dnl Copyright 2000, 2003, 2004, 2006, 2007, 2010, 2013, 2016 Free Software 4dnl Foundation, Inc. 5 6dnl This file is part of the GNU MP Library test suite. 7 8dnl The GNU MP Library test suite is free software; you can redistribute it 9dnl and/or modify it under the terms of the GNU 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. 12 13dnl The GNU MP Library test suite is distributed in the hope that it will be 14dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 15dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16dnl Public License for more details. 17 18dnl You should have received a copy of the GNU General Public License along 19dnl with the GNU MP Library test suite. If not, see 20dnl https://www.gnu.org/licenses/. 21 22 23dnl The current version of the code attempts to keep the call/return 24dnl prediction stack valid, but matching calls and returns. 25 26include(`../config.m4') 27 28 29C int calling_conventions (...); 30C 31C The global variable "calling_conventions_function" is the function to 32C call, with the arguments as passed here. 33 34define(`WANT_CALLEE_SAVES', eval(4*0)) 35define(`SAVE_CALLEE_SAVES', eval(4*8)) 36define(`RETADDR', eval(4*16)) 37define(`GOT_CALLEE_SAVES', eval(4*17)) 38define(`JUNK_PARAMS', eval(4*25)) 39 40 TEXT 41 ALIGN(32) 42PROLOGUE(calling_conventions) 43 LEA( r12, calling_conventions_values) 44 45 C Preserve callee-saves registers, including the link register r14 46 add r12, r12, #SAVE_CALLEE_SAVES 47 stm r12, {r4-r11,r14} 48 sub r12, r12, #SAVE_CALLEE_SAVES 49 50 C Put chosen junk into callee-saves registers 51 add r12, r12, #WANT_CALLEE_SAVES 52 ldm r12, {r4-r11} 53 sub r12, r12, #WANT_CALLEE_SAVES 54 55 C No callee-saves registers on arm except r12 and parameter registers 56 C 57 58 C Make the actual call 59 LEA( r12, calling_conventions_function) 60 ldr r12, [r12] 61 mov r14, pc 62 return r12 63 64 LEA( r12, calling_conventions_values) 65 66 C Save callee-saves registers after call 67 add r12, r12, #GOT_CALLEE_SAVES 68 stm r12, {r4-r11} 69 sub r12, r12, #GOT_CALLEE_SAVES 70 71 C Restore callee-saves registers, including the link register r14 72 add r12, r12, #SAVE_CALLEE_SAVES 73 ldm r12, {r4-r11,r14} 74 sub r12, r12, #SAVE_CALLEE_SAVES 75 76 C Overwrite parameter registers. Note that we overwrite r1, which 77 C could hold one half of a 64-bit return value, since we don't use that 78 C in GMP. 79 add r12, r12, #JUNK_PARAMS 80 ldm r12, {r1-r3} 81 82 return r14 83EPILOGUE() 84