Blame tests/arm32check.c

Packit 5c3484
/* ARM32 calling conventions checking.
Packit 5c3484
Packit 5c3484
Copyright 2000, 2001, 2004, 2007 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
This file is part of the GNU MP Library test suite.
Packit 5c3484
Packit 5c3484
The GNU MP Library test suite is free software; you can redistribute it
Packit 5c3484
and/or modify it under the terms of the GNU General Public License as
Packit 5c3484
published by the Free Software Foundation; either version 3 of the License,
Packit 5c3484
or (at your option) any later version.
Packit 5c3484
Packit 5c3484
The GNU MP Library test suite is distributed in the hope that it will be
Packit 5c3484
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5c3484
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Packit 5c3484
Public License for more details.
Packit 5c3484
Packit 5c3484
You should have received a copy of the GNU General Public License along with
Packit 5c3484
the GNU MP Library test suite.  If not, see https://www.gnu.org/licenses/.  */
Packit 5c3484
Packit 5c3484
#include <stdio.h>
Packit 5c3484
#include "gmp.h"
Packit 5c3484
#include "gmp-impl.h"
Packit 5c3484
#include "tests.h"
Packit 5c3484
Packit 5c3484
Packit 5c3484
/* Vector if constants and register values.  */
Packit 5c3484
mp_limb_t calling_conventions_values[29] =
Packit 5c3484
{
Packit 5c3484
  0x12345678,	/*  0 want_r4 */
Packit 5c3484
  0x87654321,	/*  1 want_r5 */
Packit 5c3484
  0x89ABCDEF,	/*  2 want_r6 */
Packit 5c3484
  0xFEDCBA98,	/*  3 want_r7 */
Packit 5c3484
  0xDEADBEEF,	/*  4 want_r8 */
Packit 5c3484
  0xBADECAFE,	/*  5 want_r9 */
Packit 5c3484
  0xFFEEDDCC,	/*  6 want_r10 */
Packit 5c3484
  0xBBAA9988,	/*  7 want_r11 */
Packit 5c3484
Packit 5c3484
  0x00000000,	/*  8 save_r4 */
Packit 5c3484
  0x00000000,	/*  9 save_r5 */
Packit 5c3484
  0x00000000,	/* 10 save_r6 */
Packit 5c3484
  0x00000000,	/* 11 save_r7 */
Packit 5c3484
  0x00000000,	/* 12 save_r8 */
Packit 5c3484
  0x00000000,	/* 13 save_r9 */
Packit 5c3484
  0x00000000,	/* 14 save_r10 */
Packit 5c3484
  0x00000000,	/* 15 save_r11 */
Packit 5c3484
  0x00000000,	/* 16 save_r14 */
Packit 5c3484
Packit 5c3484
  0x00000000,	/* 17 got_r4 */
Packit 5c3484
  0x00000000,	/* 18 got_r5 */
Packit 5c3484
  0x00000000,	/* 19 got_r6 */
Packit 5c3484
  0x00000000,	/* 20 got_r7 */
Packit 5c3484
  0x00000000,	/* 21 got_r8 */
Packit 5c3484
  0x00000000,	/* 22 got_r9 */
Packit 5c3484
  0x00000000,	/* 23 got_r10 */
Packit 5c3484
  0x00000000,	/* 24 got_r11 */
Packit 5c3484
Packit 5c3484
  0x00112233,	/* 25 junk_r0 */
Packit 5c3484
  0x44556677,	/* 26 junk_r1 */
Packit 5c3484
  0x12344321,	/* 27 junk_r2 */
Packit 5c3484
  0x56788765,	/* 28 junk_r3 */
Packit 5c3484
};
Packit 5c3484
Packit 5c3484
/* Index starts for various regions in above vector.  */
Packit 5c3484
#define WANT_CALLEE_SAVES	0
Packit 5c3484
#define SAVE_CALLEE_SAVES	8
Packit 5c3484
#define RETADDR			16
Packit 5c3484
#define GOT_CALLEE_SAVES	17
Packit 5c3484
#define JUNK_PARAMS		25
Packit 5c3484
Packit 5c3484
/* Return 1 if ok, 0 if not */
Packit 5c3484
Packit 5c3484
int
Packit 5c3484
calling_conventions_check (void)
Packit 5c3484
{
Packit 5c3484
  const char  *header = "Violated calling conventions:\n";
Packit 5c3484
  int  ret = 1;
Packit 5c3484
  int i;
Packit 5c3484
Packit 5c3484
#define CHECK(callreg, regnum, value)					\
Packit 5c3484
  if (callreg != value)							\
Packit 5c3484
    {									\
Packit 5c3484
      printf ("%s   r%d	got 0x%08lX want 0x%08lX\n",			\
Packit 5c3484
	      header, regnum, callreg, value);				\
Packit 5c3484
      header = "";							\
Packit 5c3484
      ret = 0;								\
Packit 5c3484
    }
Packit 5c3484
Packit 5c3484
  for (i = 0; i < 8; i++)
Packit 5c3484
    {
Packit 5c3484
      CHECK (calling_conventions_values[GOT_CALLEE_SAVES + i],
Packit 5c3484
	     i + 4,
Packit 5c3484
	     calling_conventions_values[WANT_CALLEE_SAVES + i]);
Packit 5c3484
    }
Packit 5c3484
Packit 5c3484
  return ret;
Packit 5c3484
}