summaryrefslogtreecommitdiff
path: root/compiler/llvmGen/Llvm/Types.hs
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2010-06-21 12:36:06 +0000
committerDavid Terei <davidterei@gmail.com>2010-06-21 12:36:06 +0000
commit4bb4a1cfa8b88fefae3405d101dc6ff0f7adbae3 (patch)
tree4ad26b3f9267b4a68ffe47e30c5da9981a572820 /compiler/llvmGen/Llvm/Types.hs
parentf9686dd4f9ff6cee56659319941e136a30fa659d (diff)
downloadhaskell-4bb4a1cfa8b88fefae3405d101dc6ff0f7adbae3.tar.gz
Fix negate op not working for -0 in llvm backend
Diffstat (limited to 'compiler/llvmGen/Llvm/Types.hs')
-rw-r--r--compiler/llvmGen/Llvm/Types.hs22
1 files changed, 7 insertions, 15 deletions
diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs
index 9275c07556..a0b003298c 100644
--- a/compiler/llvmGen/Llvm/Types.hs
+++ b/compiler/llvmGen/Llvm/Types.hs
@@ -95,7 +95,7 @@ data LlvmLit
-- | Refers to an integer constant (i64 42).
= LMIntLit Integer LlvmType
-- | Floating point literal
- | LMFloatLit Rational LlvmType
+ | LMFloatLit Double LlvmType
deriving (Eq)
instance Show LlvmLit where
@@ -191,12 +191,8 @@ getPlainName (LMLitVar x ) = getLit x
-- | Print a literal value. No type.
getLit :: LlvmLit -> String
-getLit (LMIntLit i _) = show ((fromInteger i)::Int)
--- In Llvm float literals can be printed in a big-endian hexadecimal format,
--- regardless of underlying architecture.
-getLit (LMFloatLit r LMFloat) = fToStr $ fromRational r
-getLit (LMFloatLit r LMDouble) = dToStr $ fromRational r
-getLit l = error $ "getLit: Usupported LlvmLit type! " ++ show (getLitType l)
+getLit (LMIntLit i _) = show ((fromInteger i)::Int)
+getLit (LMFloatLit r _) = dToStr r
-- | Return the 'LlvmType' of the 'LlvmVar'
getVarType :: LlvmVar -> LlvmType
@@ -695,11 +691,9 @@ instance Show LlvmCastOp where
-- * Floating point conversion
--
--- | Convert a Haskell Float to an LLVM hex encoded floating point form
-fToStr :: Float -> String
-fToStr f = dToStr $ realToFrac f
-
--- | Convert a Haskell Double to an LLVM hex encoded floating point form
+-- | Convert a Haskell Double to an LLVM hex encoded floating point form. In
+-- Llvm float literals can be printed in a big-endian hexadecimal format,
+-- regardless of underlying architecture.
dToStr :: Double -> String
dToStr d
= let bs = doubleToBytes d
@@ -712,9 +706,7 @@ dToStr d
str = map toUpper $ concat . fixEndian . (map hex) $ bs
in "0x" ++ str
--- | Reverse or leave byte data alone to fix endianness on this
--- target. LLVM generally wants things in Big-Endian form
--- regardless of target architecture.
+-- | Reverse or leave byte data alone to fix endianness on this target.
fixEndian :: [a] -> [a]
#ifdef WORDS_BIGENDIAN
fixEndian = id