summaryrefslogtreecommitdiff
path: root/compiler/nativeGen
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2019-08-05 20:44:33 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-08-06 20:26:32 -0400
commit6f116005a144b3f09381e0a5967a364eb57a5aa5 (patch)
treee6fa10c5f1f37790d15dff2b9dce7c700b26366a /compiler/nativeGen
parentc83e39bf91cfeb17a54ccfd5d01bfdfa1b4a72c9 (diff)
downloadhaskell-6f116005a144b3f09381e0a5967a364eb57a5aa5.tar.gz
Introduce a type for "platform word size", use it instead of Int
We introduce a PlatformWordSize type and use it in platformWordSize field. This removes to panic/error calls called when platform word size is not 32 or 64. We now check for this when reading the platform config.
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r--compiler/nativeGen/Dwarf.hs2
-rw-r--r--compiler/nativeGen/Dwarf/Types.hs21
-rw-r--r--compiler/nativeGen/PPC/Instr.hs2
3 files changed, 11 insertions, 14 deletions
diff --git a/compiler/nativeGen/Dwarf.hs b/compiler/nativeGen/Dwarf.hs
index b64b4efc33..33f1c5b2f7 100644
--- a/compiler/nativeGen/Dwarf.hs
+++ b/compiler/nativeGen/Dwarf.hs
@@ -116,7 +116,7 @@ compileUnitHeader unitU = sdocWithPlatform $ \plat ->
, pprHalf 3 -- DWARF version
, sectionOffset (ptext dwarfAbbrevLabel) (ptext dwarfAbbrevLabel)
-- abbrevs offset
- , text "\t.byte " <> ppr (platformWordSize plat) -- word size
+ , text "\t.byte " <> ppr (platformWordSizeInBytes plat) -- word size
]
-- | Compilation unit footer, mainly establishing size of debug sections
diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index 01253544e6..a646f0bdfa 100644
--- a/compiler/nativeGen/Dwarf/Types.hs
+++ b/compiler/nativeGen/Dwarf/Types.hs
@@ -224,7 +224,7 @@ data DwarfARange
-- address table entry.
pprDwarfARanges :: [DwarfARange] -> Unique -> SDoc
pprDwarfARanges arngs unitU = sdocWithPlatform $ \plat ->
- let wordSize = platformWordSize plat
+ let wordSize = platformWordSizeInBytes plat
paddingSize = 4 :: Int
-- header is 12 bytes long.
-- entry is 8 bytes (32-bit platform) or 16 bytes (64-bit platform).
@@ -293,7 +293,7 @@ pprDwarfFrame DwarfFrame{dwCieLabel=cieLabel,dwCieInit=cieInit,dwCieProcs=procs}
length = ppr cieEndLabel <> char '-' <> ppr cieStartLabel
spReg = dwarfGlobalRegNo plat Sp
retReg = dwarfReturnRegNo plat
- wordSize = platformWordSize plat
+ wordSize = platformWordSizeInBytes plat
pprInit :: (GlobalReg, Maybe UnwindExpr) -> SDoc
pprInit (g, uw) = pprSetUnwind plat g (Nothing, uw)
@@ -454,9 +454,9 @@ pprSetUnwind plat Sp (_, Just (UwReg s' o'))
pprSetUnwind _ Sp (_, Just uw)
= pprByte dW_CFA_def_cfa_expression $$ pprUnwindExpr False uw
pprSetUnwind plat g (_, Just (UwDeref (UwReg Sp o)))
- | o < 0 && ((-o) `mod` platformWordSize plat) == 0 -- expected case
+ | o < 0 && ((-o) `mod` platformWordSizeInBytes plat) == 0 -- expected case
= pprByte (dW_CFA_offset + dwarfGlobalRegNo plat g) $$
- pprLEBWord (fromIntegral ((-o) `div` platformWordSize plat))
+ pprLEBWord (fromIntegral ((-o) `div` platformWordSizeInBytes plat))
| otherwise
= pprByte dW_CFA_offset_extended_sf $$
pprLEBRegNo plat g $$
@@ -517,10 +517,9 @@ wordAlign :: SDoc
wordAlign = sdocWithPlatform $ \plat ->
text "\t.align " <> case platformOS plat of
OSDarwin -> case platformWordSize plat of
- 8 -> text "3"
- 4 -> text "2"
- _other -> error "wordAlign: Unsupported word size!"
- _other -> ppr (platformWordSize plat)
+ PW8 -> char '3'
+ PW4 -> char '2'
+ _other -> ppr (platformWordSizeInBytes plat)
-- | Assembly for a single byte of constant DWARF data
pprByte :: Word8 -> SDoc
@@ -552,10 +551,8 @@ pprDwWord = pprData4'
pprWord :: SDoc -> SDoc
pprWord s = (<> s) . sdocWithPlatform $ \plat ->
case platformWordSize plat of
- 4 -> text "\t.long "
- 8 -> text "\t.quad "
- n -> panic $ "pprWord: Unsupported target platform word length " ++
- show n ++ "!"
+ PW4 -> text "\t.long "
+ PW8 -> text "\t.quad "
-- | Prints a number in "little endian base 128" format. The idea is
-- to optimize for small numbers by stopping once all further bytes
diff --git a/compiler/nativeGen/PPC/Instr.hs b/compiler/nativeGen/PPC/Instr.hs
index b17ea32f01..ee8edd86fd 100644
--- a/compiler/nativeGen/PPC/Instr.hs
+++ b/compiler/nativeGen/PPC/Instr.hs
@@ -98,7 +98,7 @@ ppc_mkStackAllocInstr' platform amount
, STU fmt r0 (AddrRegReg sp tmp)
]
where
- fmt = intFormat $ widthFromBytes (platformWordSize platform)
+ fmt = intFormat $ widthFromBytes (platformWordSizeInBytes platform)
zero = ImmInt 0
tmp = tmpReg platform
immAmount = ImmInt amount