Blame tests/arm32call.asm

Packit 5c3484
dnl  ARM32 calling conventions checking.
Packit 5c3484
Packit 5c3484
dnl  Copyright 2000, 2003, 2004, 2006, 2007, 2010, 2013 Free Software
Packit 5c3484
dnl  Foundation, Inc.
Packit 5c3484
Packit 5c3484
dnl  This file is part of the GNU MP Library test suite.
Packit 5c3484
Packit 5c3484
dnl  The GNU MP Library test suite is free software; you can redistribute it
Packit 5c3484
dnl  and/or modify it under the terms of the GNU General Public License as
Packit 5c3484
dnl  published by the Free Software Foundation; either version 3 of the
Packit 5c3484
dnl  License, or (at your option) any later version.
Packit 5c3484
Packit 5c3484
dnl  The GNU MP Library test suite is distributed in the hope that it will be
Packit 5c3484
dnl  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5c3484
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Packit 5c3484
dnl  Public License for more details.
Packit 5c3484
Packit 5c3484
dnl  You should have received a copy of the GNU General Public License along
Packit 5c3484
dnl  with the GNU MP Library test suite.  If not, see
Packit 5c3484
dnl  https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
Packit 5c3484
dnl  The current version of the code attempts to keep the call/return
Packit 5c3484
dnl  prediction stack valid, but matching calls and returns.
Packit 5c3484
Packit 5c3484
include(`../config.m4')
Packit 5c3484
Packit 5c3484
Packit 5c3484
C int calling_conventions (...);
Packit 5c3484
C
Packit 5c3484
C The global variable "calling_conventions_function" is the function to
Packit 5c3484
C call, with the arguments as passed here.
Packit 5c3484
Packit 5c3484
define(`WANT_CALLEE_SAVES',	eval(4*0))
Packit 5c3484
define(`SAVE_CALLEE_SAVES',	eval(4*8))
Packit 5c3484
define(`RETADDR',		eval(4*16))
Packit 5c3484
define(`GOT_CALLEE_SAVES',	eval(4*17))
Packit 5c3484
define(`JUNK_PARAMS',		eval(4*25))
Packit 5c3484
Packit 5c3484
	TEXT
Packit 5c3484
	ALIGN(32)
Packit 5c3484
PROLOGUE(calling_conventions)
Packit 5c3484
	LEA(	r12, calling_conventions_values)
Packit 5c3484
Packit 5c3484
	C Preserve callee-saves registers, including the link register r14
Packit 5c3484
	add	r12, r12, #SAVE_CALLEE_SAVES
Packit 5c3484
	stm	r12, {r4-r11,r14}
Packit 5c3484
	sub	r12, r12, #SAVE_CALLEE_SAVES
Packit 5c3484
Packit 5c3484
	C Put chosen junk into callee-saves registers
Packit 5c3484
	add	r12, r12, #WANT_CALLEE_SAVES
Packit 5c3484
	ldm	r12, {r4-r11}
Packit 5c3484
	sub	r12, r12, #WANT_CALLEE_SAVES
Packit 5c3484
Packit 5c3484
	C No callee-saves registers on arm except r12 and parameter registers
Packit 5c3484
	C
Packit 5c3484
Packit 5c3484
	C Make the actual call
Packit 5c3484
	LEA(	r12, calling_conventions_function)
Packit 5c3484
	ldr	r12, [r12]
Packit 5c3484
	mov	r14, pc
Packit 5c3484
	ret	r12
Packit 5c3484
Packit 5c3484
	LEA(	r12, calling_conventions_values)
Packit 5c3484
Packit 5c3484
	C Save callee-saves registers after call
Packit 5c3484
	add	r12, r12, #GOT_CALLEE_SAVES
Packit 5c3484
	stm	r12, {r4-r11}
Packit 5c3484
	sub	r12, r12, #GOT_CALLEE_SAVES
Packit 5c3484
Packit 5c3484
	C Restore callee-saves registers, including the link register r14
Packit 5c3484
	add	r12, r12, #SAVE_CALLEE_SAVES
Packit 5c3484
	ldm	r12, {r4-r11,r14}
Packit 5c3484
	sub	r12, r12, #SAVE_CALLEE_SAVES
Packit 5c3484
Packit 5c3484
	C Overwrite parameter registers.  Note that we overwrite r1, which
Packit 5c3484
	C could hold one half of a 64-bit return value, since we don't use that
Packit 5c3484
	C in GMP.
Packit 5c3484
	add	r12, r12, #JUNK_PARAMS
Packit 5c3484
	ldm	r12, {r1-r3}
Packit 5c3484
Packit 5c3484
	ret	r14
Packit 5c3484
EPILOGUE()