* interp.c (mips16_entry): Add support for floating point cases.
[deliverable/binutils-gdb.git] / sim / mips / support.h
CommitLineData
8ad57737 1/*> support.h <*/
a647a859
JSC
2/* Support for the MIPS architecture simulator.
3
4 This file is part of the MIPS sim
5
6 THIS SOFTWARE IS NOT COPYRIGHTED
7
8 Cygnus offers the following for use in the public domain. Cygnus
9 makes no warranty with regard to the software or it's performance
10 and the user accepts the software "AS IS" with all faults.
11
12 CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
13 THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15
16 $Revision$
17 $Author$
18 $Date$
19*/
8ad57737
JSC
20
21#ifndef __support_h
22#define __support_h
23
24/* For 64bit values either use the GCC "long long" feature, or have a
25 structure made from two 32bit values. We can then have macros for
26 accessing the LO and HI parts of the value. Also we can provide
27 macros for the basic operations we want to perform on 64bit values
28 (i.e. ADD64,SUB64,SHIFTLEFT64, etc.). This means we should be able
29 to host the simulator on non-GCC compilers, and 32bit only
30 architectures if desired. */
31
32/* Control via a build boolean for the moment */
dbeec768 33#if defined(__GNUC__) || defined(_WIN32)
8ad57737 34
dbeec768 35#ifdef _WIN32
2902e8ab
MA
36#define SIGTRAP 5
37#define SIGQUIT 3
4fa14cf7
SG
38typedef signed __int64 word64;
39typedef unsigned __int64 uword64;
40#else
8ad57737
JSC
41typedef long long word64;
42typedef unsigned long long uword64;
4fa14cf7 43#endif
8ad57737
JSC
44
45#define WORD64LO(t) (unsigned int)((t)&0xFFFFFFFF)
a647a859
JSC
46#define WORD64HI(t) (unsigned int)(((uword64)(t))>>32)
47#define SET64LO(t) (((uword64)(t))&0xFFFFFFFF)
48#define SET64HI(t) (((uword64)(t))<<32)
8ad57737
JSC
49
50/* Sign-extend the given value (e) as a value (b) bits long. We cannot
51 assume the HI32bits of the operand are zero, so we must perform a
52 mask to ensure we can use the simple subtraction to sign-extend. */
149ee672
ILT
53#define SIGNEXTEND(e,b) \
54 (((e) & ((uword64) 1 << ((b) - 1))) \
55 ? (((e) & (((uword64) 1 << (b)) - 1)) - ((uword64)1 << (b))) \
56 : ((e) & (((((uword64) 1 << ((b) - 1)) - 1) << 1) | 1)))
8ad57737
JSC
57
58/* Check if a value will fit within a word (unsigned int): */
4fa14cf7 59#define NOTWORDVALUE(v) ((((((uword64)(v)>>32) == 0) && !((v) & ((unsigned)1 << 31))) || ((((uword64)(v)>>32) == 0xFFFFFFFF) && ((v) & ((unsigned)1 << 31)))) ? (1 == 0) : (1 == 1))
8ad57737
JSC
60
61/* Check if a value will fit within a halfword: */
4fa14cf7 62#define NOTHALFWORDVALUE(v) ((((((uword64)(v)>>16) == 0) && !((v) & ((unsigned)1 << 15))) || (((((uword64)(v)>>32) == 0xFFFFFFFF) && ((((uword64)(v)>>16) & 0xFFFF) == 0xFFFF)) && ((v) & ((unsigned)1 << 15)))) ? (1 == 0) : (1 == 1))
8ad57737
JSC
63
64/* The following should be executed once at the start of day in the
65 main emulator control function. The simulator assumes char is
66 8bits, and from this: */
67#define CHECKSIM() {\
68 if (sizeof(int) != (4 * sizeof(char)))\
69 SignalException(SimulatorFault,"sizeof(int) != 4");\
4fa14cf7
SG
70 if (sizeof(word64) != (8 * sizeof(char)))\
71 SignalException(SimulatorFault,"sizeof(word64) != 8");\
8ad57737
JSC
72 }
73
74#else /* non-GCC build */
75
76#error "non-GCC build to be completed" /* avoid using long long */
77
a647a859 78typedef struct uword64 {
8ad57737
JSC
79 unsigned int lo;
80 unsigned int hi;
a647a859 81} uword64;
8ad57737
JSC
82
83#define WORD64LO(t) (unsigned int)(t.lo)
84#define WORD64HI(t) (unsigned int)(t.hi)
a647a859
JSC
85#define SET64LO(t) (..TODO..) /* need structure into which value will be placed */
86#define SET64HI(t) (..TODO..) /* need structure into which value will be placed */
8ad57737
JSC
87
88/* TODO: Update these to manipulate the split structure values */
89#define SIGNEXTEND(e,b) /* TODO */
90#define NOTWORDVALUE(v) /* TODO */
91#define NOTHALFWORDVALUE(v) /* TODO */
92
93/* The following should be executed once at the start of day in the
94 main emulator control function. The simulator assumes char is
95 8bits, and from this: */
96#define CHECKSIM() {\
97 if (sizeof(int) != (4 * sizeof(char)))\
837d2893 98 SignalException(SimulatorFault,"sizeof(int) != 4");\
8ad57737
JSC
99 }
100
101#endif /* non-GCC build */
102
103#endif /* __support_h */
104
105/*> EOF support.h <*/
This page took 0.059752 seconds and 4 git commands to generate.