1 -----------------------------------------------------------------------------
3 -- Pretty-printing assembly language
5 -- (c) The University of Glasgow 1993-2005
7 -----------------------------------------------------------------------------
12 castFloatToWord8Array,
13 castDoubleToWord8Array,
20 import qualified Outputable
25 import Control.Monad.ST
31 asmSDoc :: Outputable.SDoc -> Doc
33 = Outputable.withPprStyleDoc (Outputable.mkCodeStyle Outputable.AsmStyle) d
36 pprCLabel_asm :: CLabel -> Doc
38 = asmSDoc (pprCLabel l)
41 -- -----------------------------------------------------------------------------
42 -- Converting floating-point literals to integrals for printing
44 castFloatToWord8Array :: STUArray s Int Float -> ST s (STUArray s Int Word8)
45 castFloatToWord8Array = castSTUArray
47 castDoubleToWord8Array :: STUArray s Int Double -> ST s (STUArray s Int Word8)
48 castDoubleToWord8Array = castSTUArray
50 -- floatToBytes and doubleToBytes convert to the host's byte
51 -- order. Providing that we're not cross-compiling for a
52 -- target with the opposite endianness, this should work ok
55 -- ToDo: this stuff is very similar to the shenanigans in PprAbs,
56 -- could they be merged?
58 floatToBytes :: Float -> [Int]
61 arr <- newArray_ ((0::Int),3)
63 arr <- castFloatToWord8Array arr
68 return (map fromIntegral [i0,i1,i2,i3])
71 doubleToBytes :: Double -> [Int]
74 arr <- newArray_ ((0::Int),7)
76 arr <- castDoubleToWord8Array arr
85 return (map fromIntegral [i0,i1,i2,i3,i4,i5,i6,i7])