1549ab5a84d2b891918d4f9e8f07f2d4bf3ecb38
[ghc-hetmet.git] / compiler / nativeGen / SPARC / Base.hs
1
2 -- | Bits and pieces on the bottom of the module dependency tree.
3 --      Also import the required constants, so we know what we're using.
4 --      
5 --      In the interests of cross-compilation, we want to free ourselves
6 --      from the autoconf generated modules like main/Constants
7 --
8 module SPARC.Base (
9         wordLength,
10         wordLengthInBits,
11         spillAreaLength,
12         spillSlotSize,
13         fits13Bits,
14         largeOffsetError
15 )
16
17 where
18
19 import qualified Constants
20 import Panic
21
22 -- On 32 bit SPARC, pointers are 32 bits.
23 wordLength :: Int
24 wordLength = 4
25
26 wordLengthInBits :: Int
27 wordLengthInBits 
28         = wordLength * 8
29
30 -- Size of the available spill area
31 spillAreaLength :: Int
32 spillAreaLength
33         = Constants.rESERVED_C_STACK_BYTES
34
35 -- | We need 8 bytes because our largest registers are 64 bit.
36 spillSlotSize :: Int
37 spillSlotSize = 8
38
39
40 {-# SPECIALIZE fits13Bits :: Int -> Bool, Integer -> Bool #-}
41 -- | Check whether an offset is representable with 13 bits.
42 fits13Bits :: Integral a => a -> Bool
43 fits13Bits x = x >= -4096 && x < 4096
44
45
46 -- | Sadness.
47 largeOffsetError :: Integral a => a -> b
48 largeOffsetError i
49   = panic ("ERROR: SPARC native-code generator cannot handle large offset ("
50                 ++ show i ++ ");\nprobably because of large constant data structures;" ++ 
51                 "\nworkaround: use -fvia-C on this module.\n")