X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FSPARC%2FBase.hs;h=fa79cece92e74d12e3274da984a5cd9f206bc5d1;hb=18691d440f90a3dff4ef538091c886af505e5cf5;hp=1549ab5a84d2b891918d4f9e8f07f2d4bf3ecb38;hpb=547bf6827f1fc3f2fb31bc6323cc0d33b445f32a;p=ghc-hetmet.git diff --git a/compiler/nativeGen/SPARC/Base.hs b/compiler/nativeGen/SPARC/Base.hs index 1549ab5..fa79cec 100644 --- a/compiler/nativeGen/SPARC/Base.hs +++ b/compiler/nativeGen/SPARC/Base.hs @@ -10,7 +10,9 @@ module SPARC.Base ( wordLengthInBits, spillAreaLength, spillSlotSize, + extraStackArgsHere, fits13Bits, + is32BitInteger, largeOffsetError ) @@ -19,6 +21,9 @@ where import qualified Constants import Panic +import Data.Int + + -- On 32 bit SPARC, pointers are 32 bits. wordLength :: Int wordLength = 4 @@ -37,11 +42,28 @@ 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 :: Integral a => a -> b @@ -49,3 +71,5 @@ largeOffsetError i = panic ("ERROR: SPARC native-code generator cannot handle large offset (" ++ show i ++ ");\nprobably because of large constant data structures;" ++ "\nworkaround: use -fvia-C on this module.\n") + +