blob: 86a897dacb1001d8e518874129dee5c93f5365a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-- | Bits and pieces on the bottom of the module dependency tree.
-- Also import the required constants, so we know what we're using.
--
-- In the interests of cross-compilation, we want to free ourselves
-- from the autoconf generated modules like main/Constants
module GHC.CmmToAsm.SPARC.Base (
wordLength,
wordLengthInBits,
spillAreaLength,
spillSlotSize,
extraStackArgsHere,
fits13Bits,
is32BitInteger,
largeOffsetError
)
where
import GhcPrelude
import GHC.Driver.Session
import Panic
import Data.Int
-- On 32 bit SPARC, pointers are 32 bits.
wordLength :: Int
wordLength = 4
wordLengthInBits :: Int
wordLengthInBits
= wordLength * 8
-- Size of the available spill area
spillAreaLength :: DynFlags -> Int
spillAreaLength
= rESERVED_C_STACK_BYTES
-- | We need 8 bytes because our largest registers are 64 bit.
spillSlotSize :: Int
spillSlotSize = 8
-- | We (allegedly) put the first six C-call arguments in registers;
-- where do we start putting the rest of them?
extraStackArgsHere :: Int
extraStackArgsHere = 23
{-# SPECIALIZE fits13Bits :: Int -> Bool, Integer -> Bool #-}
-- | Check whether an offset is representable with 13 bits.
fits13Bits :: Integral a => a -> Bool
fits13Bits x = x >= -4096 && x < 4096
-- | Check whether an integer will fit in 32 bits.
-- A CmmInt is intended to be truncated to the appropriate
-- number of bits, so here we truncate it to Int64. This is
-- important because e.g. -1 as a CmmInt might be either
-- -1 or 18446744073709551615.
--
is32BitInteger :: Integer -> Bool
is32BitInteger i
= i64 <= 0x7fffffff && i64 >= -0x80000000
where i64 = fromIntegral i :: Int64
-- | Sadness.
largeOffsetError :: (Show a) => a -> b
largeOffsetError i
= panic ("ERROR: SPARC native-code generator cannot handle large offset ("
++ show i ++ ");\nprobably because of large constant data structures;" ++
"\nworkaround: use -fllvm on this module.\n")
|