Pass 256-bit-wide vectors in registers.
[ghc.git] / includes / MachDeps.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The University of Glasgow 2002
4 *
5 * Definitions that characterise machine specific properties of basic
6 * types (C & Haskell).
7 *
8 * NB: Keep in sync with HsFFI.h and StgTypes.h.
9 * NB: THIS FILE IS INCLUDED IN HASKELL SOURCE!
10 *
11 * To understand the structure of the RTS headers, see the wiki:
12 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
13 *
14 * ---------------------------------------------------------------------------*/
15
16 #ifndef MACHDEPS_H
17 #define MACHDEPS_H
18
19 /* Sizes of C types come from here... */
20 #include "ghcautoconf.h"
21
22 /* Sizes of Haskell types follow. These sizes correspond to:
23 * - the number of bytes in the primitive type (eg. Int#)
24 * - the number of bytes in the external representation (eg. HsInt)
25 * - the scale offset used by writeFooOffAddr#
26 *
27 * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
28 * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
29 */
30
31 /* First, check some assumptions.. */
32 #if SIZEOF_CHAR != 1
33 #error GHC untested on this architecture: sizeof(char) != 1
34 #endif
35
36 #if SIZEOF_SHORT != 2
37 #error GHC untested on this architecture: sizeof(short) != 2
38 #endif
39
40 #if SIZEOF_UNSIGNED_INT != 4
41 #error GHC untested on this architecture: sizeof(unsigned int) != 4
42 #endif
43
44 #define SIZEOF_HSCHAR SIZEOF_WORD32
45 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
46
47 #define SIZEOF_HSINT SIZEOF_VOID_P
48 #define ALIGNMENT_HSINT ALIGNMENT_VOID_P
49
50 #define SIZEOF_HSWORD SIZEOF_VOID_P
51 #define ALIGNMENT_HSWORD ALIGNMENT_VOID_P
52
53 #define SIZEOF_HSDOUBLE SIZEOF_DOUBLE
54 #define ALIGNMENT_HSDOUBLE ALIGNMENT_DOUBLE
55
56 #define SIZEOF_HSFLOAT SIZEOF_FLOAT
57 #define ALIGNMENT_HSFLOAT ALIGNMENT_FLOAT
58
59 #define SIZEOF_HSPTR SIZEOF_VOID_P
60 #define ALIGNMENT_HSPTR ALIGNMENT_VOID_P
61
62 #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
63 #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
64
65 #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
66 #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
67
68 #define SIZEOF_INT8 SIZEOF_CHAR
69 #define ALIGNMENT_INT8 ALIGNMENT_CHAR
70
71 #define SIZEOF_WORD8 SIZEOF_UNSIGNED_CHAR
72 #define ALIGNMENT_WORD8 ALIGNMENT_UNSIGNED_CHAR
73
74 #define SIZEOF_INT16 SIZEOF_SHORT
75 #define ALIGNMENT_INT16 ALIGNMENT_SHORT
76
77 #define SIZEOF_WORD16 SIZEOF_UNSIGNED_SHORT
78 #define ALIGNMENT_WORD16 ALIGNMENT_UNSIGNED_SHORT
79
80 #define SIZEOF_INT32 SIZEOF_INT
81 #define ALIGNMENT_INT32 ALIGNMENT_INT
82
83 #define SIZEOF_WORD32 SIZEOF_UNSIGNED_INT
84 #define ALIGNMENT_WORD32 ALIGNMENT_UNSIGNED_INT
85
86 #if SIZEOF_LONG == 8
87 #define SIZEOF_INT64 SIZEOF_LONG
88 #define ALIGNMENT_INT64 ALIGNMENT_LONG
89 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG
90 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG
91 #elif HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8
92 #define SIZEOF_INT64 SIZEOF_LONG_LONG
93 #define ALIGNMENT_INT64 ALIGNMENT_LONG_LONG
94 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG_LONG
95 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG_LONG
96 #else
97 #error Cannot find a 64bit type.
98 #endif
99
100 #ifndef WORD_SIZE_IN_BITS
101 #if SIZEOF_HSWORD == 4
102 #define WORD_SIZE_IN_BITS 32
103 #else
104 #define WORD_SIZE_IN_BITS 64
105 #endif
106 #endif
107
108 #ifndef TAG_BITS
109 #if SIZEOF_HSWORD == 4
110 #define TAG_BITS 2
111 #else
112 #define TAG_BITS 3
113 #endif
114 #endif
115
116 #define TAG_MASK ((1 << TAG_BITS) - 1)
117
118 #endif /* MACHDEPS_H */