* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[deliverable/binutils-gdb.git] / sim / testsuite / common / alu-tst.c
CommitLineData
afb1dbe8
AC
1#define WITH_TARGET_WORD_MSB 0
2#define WITH_TARGET_WORD_BITSIZE 64
3#define WITH_HOST_WORD_BITSIZE (sizeof (int) * 8)
4
5#define ASSERT(EXPRESSION) \
6{ \
7 if (!(EXPRESSION)) { \
8 fprintf (stderr, "%s:%d: assertion failed - %s\n", \
9 __FILE__, __LINE__, #EXPRESSION); \
10 abort (); \
11 } \
12}
13
14#define SIM_BITS_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE)
15
16#include "sim-basics.h"
17#include "sim-types.h"
18#include "sim-bits.h"
19
20#include "sim-alu.h"
21
22#include <stdio.h>
23
24
25typedef struct {
26 char *op;
27 unsigned64 arg;
28} alu_op;
29
30typedef struct {
31 unsigned64 begin;
32 alu_op ops[3];
33 unsigned64 result;
34 int carry;
35 int overflow;
36} alu_test;
37
38#define MAX_INT16 (32767)
39#define MIN_INT16 (32768)
40
41const alu_test alu16_tests[] = {
42 /* */
43 { MAX_INT16, { { "ADD", 1 }, }, MIN_INT16, 0, 1, },
44 { MIN_INT16, { { "ADD", -1 }, }, MAX_INT16, 1, 1, },
45 { MAX_INT16, { { "ADD", MIN_INT16 }, }, -1, 0, 0, },
46 { MIN_INT16, { { "ADD", MAX_INT16 }, }, -1, 0, 0, },
47 { MAX_INT16, { { "ADD", MAX_INT16 }, }, MAX_INT16 * 2, 0, 1, },
48 { MIN_INT16, { { "ADD", MIN_INT16 }, }, 0, 1, 1, },
49 /* */
50 { 0, { { "SUB", MIN_INT16 }, }, MIN_INT16, 0, 1, },
51 { MAX_INT16, { { "SUB", MAX_INT16 }, }, 0, 0, 0, },
52};
53
54
55static void
56print_hex (unsigned64 val, int nr_bits)
57{
58 switch (nr_bits)
59 {
60 case 16:
61 printf ("0x%04lx", (long) (unsigned16) (val));
62 break;
63 case 32:
64 printf ("0x%08lx", (long) (unsigned32) (val));
65 break;
66 case 64:
67 printf ("0x%08lx%08lx",
68 (long) (unsigned32) (val >> 32),
69 (long) (unsigned32) (val));
70 default:
71 abort ();
72 }
73}
74
75
76int errors = 0;
77
78
79#define N 16
80#include "alu-n-tst.h"
81#undef N
82
83#if 0
84#define N 32
85#include "alu-n-tst.h"
86#undef N
87
88#define N 64
89#include "alu-n-tst.h"
90#undef N
91#endif
92
93int
94main ()
95{
96 int i;
97 for (i = 0; i < sizeof (alu16_tests) / sizeof (*alu16_tests); i++)
98 do_op_16 (alu16_tests + i);
99 return (errors != 0);
100}
This page took 0.097246 seconds and 4 git commands to generate.