* gdbtk.tcl (files_command): Correctly insert list of files into
[deliverable/binutils-gdb.git] / sim / mips / support.h
1 /*> support.h <*/
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 */
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 */
33 #if defined(__GNUC__)
34
35 typedef long long word64;
36 typedef unsigned long long uword64;
37
38 #define WORD64LO(t) (unsigned int)((t)&0xFFFFFFFF)
39 #define WORD64HI(t) (unsigned int)(((uword64)(t))>>32)
40 #define SET64LO(t) (((uword64)(t))&0xFFFFFFFF)
41 #define SET64HI(t) (((uword64)(t))<<32)
42
43 /* Sign-extend the given value (e) as a value (b) bits long. We cannot
44 assume the HI32bits of the operand are zero, so we must perform a
45 mask to ensure we can use the simple subtraction to sign-extend. */
46 #define SIGNEXTEND(e,b) (((e) & ((unsigned long long)1 << ((b) - 1))) ? (((e) & (((unsigned long long)1 << (b)) - 1)) - ((unsigned long long)1 << (b))) : (e))
47
48 /* Check if a value will fit within a word (unsigned int): */
49 #define NOTWORDVALUE(v) ((((((unsigned long long)(v)>>32) == 0) && !((v) & ((unsigned)1 << 31))) || ((((unsigned long long)(v)>>32) == 0xFFFFFFFF) && ((v) & ((unsigned)1 << 31)))) ? (1 == 0) : (1 == 1))
50
51 /* Check if a value will fit within a halfword: */
52 #define NOTHALFWORDVALUE(v) ((((((unsigned long long)(v)>>16) == 0) && !((v) & ((unsigned)1 << 15))) || (((((unsigned long long)(v)>>32) == 0xFFFFFFFF) && ((((unsigned long long)(v)>>16) & 0xFFFF) == 0xFFFF)) && ((v) & ((unsigned)1 << 15)))) ? (1 == 0) : (1 == 1))
53
54 /* The following should be executed once at the start of day in the
55 main emulator control function. The simulator assumes char is
56 8bits, and from this: */
57 #define CHECKSIM() {\
58 if (sizeof(int) != (4 * sizeof(char)))\
59 SignalException(SimulatorFault,"sizeof(int) != 4");\
60 if (sizeof(long long) != (8 * sizeof(char)))\
61 SignalException(SimulatorFault,"sizeof(long long) != 8");\
62 }
63
64 #else /* non-GCC build */
65
66 #error "non-GCC build to be completed" /* avoid using long long */
67
68 typedef struct uword64 {
69 unsigned int lo;
70 unsigned int hi;
71 } uword64;
72
73 #define WORD64LO(t) (unsigned int)(t.lo)
74 #define WORD64HI(t) (unsigned int)(t.hi)
75 #define SET64LO(t) (..TODO..) /* need structure into which value will be placed */
76 #define SET64HI(t) (..TODO..) /* need structure into which value will be placed */
77
78 /* TODO: Update these to manipulate the split structure values */
79 #define SIGNEXTEND(e,b) /* TODO */
80 #define NOTWORDVALUE(v) /* TODO */
81 #define NOTHALFWORDVALUE(v) /* TODO */
82
83 /* The following should be executed once at the start of day in the
84 main emulator control function. The simulator assumes char is
85 8bits, and from this: */
86 #define CHECKSIM() {\
87 if (sizeof(int) != (4 * sizeof(char)))\
88 SignalException(SimulatorFault,"sizeof(int) != 4");\
89 }
90
91 #endif /* non-GCC build */
92
93 #endif /* __support_h */
94
95 /*> EOF support.h <*/
This page took 0.031367 seconds and 4 git commands to generate.