diff options
author | Carter Schonwald <carter.schonwald@gmail.com> | 2019-04-10 20:28:41 -0400 |
---|---|---|
committer | Carter Schonwald <carter.schonwald@gmail.com> | 2019-04-10 20:28:41 -0400 |
commit | 42504f4a575395a35eec5c3fd7c9ef6e2b54e68e (patch) | |
tree | dc68a9ce346a6dd88203b2e70a0eb727082045a3 /compiler/cmm | |
parent | be0dde8e3c27ca56477d1d1801bb77621f3618e1 (diff) | |
download | haskell-42504f4a575395a35eec5c3fd7c9ef6e2b54e68e.tar.gz |
removing x87 register support from native code gen
* simplifies registers to have GPR, Float and Double, by removing the SSE2 and X87 Constructors
* makes -msse2 assumed/default for x86 platforms, fixing a long standing nondeterminism in rounding
behavior in 32bit haskell code
* removes the 80bit floating point representation from the supported float sizes
* theres still 1 tiny bit of x87 support needed,
for handling float and double return values in FFI calls wrt the C ABI on x86_32,
but this one piece does not leak into the rest of NCG.
* Lots of code thats not been touched in a long time got deleted as a
consequence of all of this
all in all, this change paves the way towards a lot of future further
improvements in how GHC handles floating point computations, along with
making the native code gen more accessible to a larger pool of contributors.
Diffstat (limited to 'compiler/cmm')
-rw-r--r-- | compiler/cmm/CmmCallConv.hs | 2 | ||||
-rw-r--r-- | compiler/cmm/CmmExpr.hs | 6 | ||||
-rw-r--r-- | compiler/cmm/CmmType.hs | 13 |
3 files changed, 12 insertions, 9 deletions
diff --git a/compiler/cmm/CmmCallConv.hs b/compiler/cmm/CmmCallConv.hs index f338415adc..078390638d 100644 --- a/compiler/cmm/CmmCallConv.hs +++ b/compiler/cmm/CmmCallConv.hs @@ -81,7 +81,6 @@ assignArgumentsPos dflags off conv arg_ty reps = (stk_off, assignments) | passFloatInXmm -> k (RegisterParam (DoubleReg s), (vs, fs, ds, ls, ss)) (W64, (vs, fs, d:ds, ls, ss)) | not passFloatInXmm -> k (RegisterParam d, (vs, fs, ds, ls, ss)) - (W80, _) -> panic "F80 unsupported register type" _ -> (assts, (r:rs)) int = case (w, regs) of (W128, _) -> panic "W128 unsupported register type" @@ -100,6 +99,7 @@ assignArgumentsPos dflags off conv arg_ty reps = (stk_off, assignments) passFloatArgsInXmm :: DynFlags -> Bool passFloatArgsInXmm dflags = case platformArch (targetPlatform dflags) of ArchX86_64 -> True + ArchX86 -> False _ -> False -- We used to spill vector registers to the stack since the LLVM backend didn't diff --git a/compiler/cmm/CmmExpr.hs b/compiler/cmm/CmmExpr.hs index 601b1d9b85..dd4e777436 100644 --- a/compiler/cmm/CmmExpr.hs +++ b/compiler/cmm/CmmExpr.hs @@ -474,6 +474,9 @@ instance Eq GlobalReg where FloatReg i == FloatReg j = i==j DoubleReg i == DoubleReg j = i==j LongReg i == LongReg j = i==j + -- NOTE: XMM, YMM, ZMM registers actually are the same registers + -- at least with respect to store at YMM i and then read from XMM i + -- and similarly for ZMM etc. XmmReg i == XmmReg j = i==j YmmReg i == YmmReg j = i==j ZmmReg i == ZmmReg j = i==j @@ -584,6 +587,9 @@ globalRegType dflags (VanillaReg _ VNonGcPtr) = bWord dflags globalRegType _ (FloatReg _) = cmmFloat W32 globalRegType _ (DoubleReg _) = cmmFloat W64 globalRegType _ (LongReg _) = cmmBits W64 +-- TODO: improve the internal model of SIMD/vectorized registers +-- the right design SHOULd improve handling of float and double code too. +-- see remarks in "NOTE [SIMD Design for the future]"" in StgCmmPrim globalRegType _ (XmmReg _) = cmmVec 4 (cmmBits W32) globalRegType _ (YmmReg _) = cmmVec 8 (cmmBits W32) globalRegType _ (ZmmReg _) = cmmVec 16 (cmmBits W32) diff --git a/compiler/cmm/CmmType.hs b/compiler/cmm/CmmType.hs index 0d6e770904..276fbff534 100644 --- a/compiler/cmm/CmmType.hs +++ b/compiler/cmm/CmmType.hs @@ -166,9 +166,6 @@ isFloat64 _other = False ----------------------------------------------------------------------------- data Width = W8 | W16 | W32 | W64 - | W80 -- Extended double-precision float, - -- used in x86 native codegen only. - -- (we use Ord, so it'd better be in this order) | W128 | W256 | W512 @@ -185,7 +182,7 @@ mrStr W64 = sLit("W64") mrStr W128 = sLit("W128") mrStr W256 = sLit("W256") mrStr W512 = sLit("W512") -mrStr W80 = sLit("W80") + -------- Common Widths ------------ @@ -222,7 +219,7 @@ widthInBits W64 = 64 widthInBits W128 = 128 widthInBits W256 = 256 widthInBits W512 = 512 -widthInBits W80 = 80 + widthInBytes :: Width -> Int widthInBytes W8 = 1 @@ -232,7 +229,7 @@ widthInBytes W64 = 8 widthInBytes W128 = 16 widthInBytes W256 = 32 widthInBytes W512 = 64 -widthInBytes W80 = 10 + widthFromBytes :: Int -> Width widthFromBytes 1 = W8 @@ -242,7 +239,7 @@ widthFromBytes 8 = W64 widthFromBytes 16 = W128 widthFromBytes 32 = W256 widthFromBytes 64 = W512 -widthFromBytes 10 = W80 + widthFromBytes n = pprPanic "no width for given number of bytes" (ppr n) -- log_2 of the width in bytes, useful for generating shifts. @@ -254,7 +251,7 @@ widthInLog W64 = 3 widthInLog W128 = 4 widthInLog W256 = 5 widthInLog W512 = 6 -widthInLog W80 = panic "widthInLog: F80" + -- widening / narrowing |